-
Notifications
You must be signed in to change notification settings - Fork 30
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate to Java 21 FFM API #241
Migrate to Java 21 FFM API #241
Conversation
Thank you for your work on this. A couple of things:
|
I can look at adding another commit on this PR to address the GitHub Actions/Workflows changes required once I familiarize myself with them.
Yes, that's the case... I see now that I should have simply added it to the
I can amend the PR to do so.
I can remove that as well since when building locally I could just skip the spurious license check failure with the right local |
65edda9
to
fac061c
Compare
The project's minimum Java release requirements moved from Java 17 to Java 21. Package imports changed from `jdk.incubator.foreign` -> `java.lang.foreign` and a number of API changes were required. Notably, the new `java.lang.foreign.Arena` class needs to be exposed when allocating native memory regions as it controls the scope and lifecycle of allocations. Respective API docs are as follows: - https://docs.oracle.com/en/java/javase/17/docs/api/jdk.incubator.foreign/jdk/incubator/foreign/package-summary.html - https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/foreign/package-summary.html
fac061c
to
56bc3f3
Compare
@leerho FYI, |
Hmm. Some sort of failure on Windows having to do with file access?? I haven't used Windows for over 16 years, so I'm not sure what that is about. All the other OSs passed! Oddly, the 4.1.0 version, Which I assume you based this on, worked with Windows. |
* @param scope the given ResourceScope. | ||
* It must be non-null. | ||
* Typically use <i>ResourceScope.newConfinedScope()</i>. | ||
* Warning: specifying a <i>newSharedScope()</i> is not supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In cases where the user supplies the Arena I suggest we add in the javadoc something to the effect:
This Memory component is not thread-safe as it was designed to be used in environments where threading and parallel operation are handled at higher levels. Specifying global(), ofAuto() or ofShared() Arenas could produce unpredictable results
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Arena.ofConfined()
is the only one which makes sense and is applicable here, then perhaps the Arena shouldn't be exposed in the public API at all?
} | ||
|
||
/** | ||
* Maps the specified portion of the given file into Memory for write operations. | ||
* @param file the given file to map. It must be non-null and writable. | ||
* Maps the specified portion of the given file into Memory for write operations with a ResourceScope. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you meant Arena, but that isn't correct either. The write operations of WritableMemory assume that the MemorySegment exists and has already been allocated using an Arena. (I think I made that mistake too.)
* @param byteOrder the byte order to be used. It must be non-null. | ||
* @return mapped WritableMemory. | ||
* @throws IllegalArgumentException -- if file is not readable or writable. | ||
* @throws IllegalArgumentException -- if file is not writable. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good Catch!
* @param scope the given ResourceScope. | ||
* It must be non-null. | ||
* Typically use <i>ResourceScope.newConfinedScope()</i>. | ||
* Warning: specifying a <i>newSharedScope()</i> is not supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar warning as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow! This represents a huge amount of work on your part! Thank you!
I also recognize some improvements you made along the way!
I don't know if I caught all the issues, many of which were related to comments.
This is a huge PR and when I merge I will be merging into a dedicated branch, which will make it easier for both of us to see and find some things and run tests as we go. I do suspect this will take several passes to review and get right. --cheers!
} | ||
|
||
/** | ||
* Request new WritableMemory with the given newCapacityBytes. The current Writable Memory can be used to | ||
* determine the byte order of the returned WritableMemory and other properties. | ||
* @param currentWritableMemory the current writableMemory of the client. It must be non-null. | ||
* @param newCapacityBytes The capacity being requested. It must be > the capacity of the currentWritableMemory. | ||
* @param scope the ResourceScope to be used for the newly allocated memory. | ||
* It must be non-null. | ||
* @param arena the Arena to be used for the newly allocated memory. It must be non-null. | ||
* Typically use <i>ResourceScope.newConfinedScope()</i>. | ||
* Warning: specifying a <i>newSharedScope()</i> is not supported. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add warning as above. Also replace ResourceScope
@@ -194,12 +193,13 @@ static WritableMemory allocateDirect( | |||
* @return WritableMemory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add warning as above, also ResourceScope needs to be replaced at about L186
long capacityBytes, | ||
long alignmentBytes, | ||
ResourceScope scope, | ||
Scope scope, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need and Arena and a MemorySegment.Scope.
Interesting... My guess is that the default directory on |
This is to try to address file permission errors seen in some GitHub Action Workflow runs on Windows: "[INFO] Error: Failures: Error: LeafImplTest.checkMapLeafs:118 » AccessDenied TestFile2.bin Error: SpecificLeafTest.checkMapLeafs:108 » AccessDenied TestFile2.bin"
Now it is getting an Apache Rat failure on the file: force_original.txt |
If this is a temp file we can either make sure it is deleted before you run the rat test, if possible, or put it in the excludes list. |
This is to try to address following errors seen in some GitHub Action Workflow runs on Windows: "Warning: Files with unapproved licenses: force_original.txt"
Excellent! It now passes all tests. Good work! |
There are a couple of things I want to look at once I get this into a branch where it will be easier to me look at and use other tools to search for consistency, etc. |
@frankgrimes97, |
The project's minimium java release requirements moved from Java 17 to Java 21.
Package imports changed from
jdk.incubator.foreign
->java.lang.foreign
and a number of API changes were required.Notably, the new
java.lang.foreign.Arena
class needs to be exposed when allocating native memory regions as it controls the scope and lifecycle of allocations.Respective API docs are as follows: