uschindler commented on PR #912:
URL: https://github.com/apache/lucene/pull/912#issuecomment-1140344703

   I updated the PR to  use an MR-JAR (multi release JAR) to implement the new 
functionality. It also uses Gradle's toolchain support to automatically 
download the JDK 19 release just to compile the MR part. This is commented out 
at the moment, because the Gradle toolchain API does not support EA releases.
   
   The cool thing: Once OpenJDK 19 got out of the door in September, we can 
enable the toochanin support an then also backport this patch to Lucene 9.x.
   
   The MR-JAR part works the following way:
   - The `MappedByteBuffer` part and all the Java 9+ hacks with Unsafe are 
moved to a new pkg-private interface `MMapIndexInputProvider`.
   - In the MR-JAR part for Java 19 there's a separate implementation of 
`MMapIndexInputProvider`, compiled with `--enable-preview`
   - the main `MMapDirectory` has a static initializer that tries to load and 
link the Java19 `MemorySegmentIndexInputProvider`. It uses method handles for 
that because reflection would need `setAccessible()`. If loading fails it logs 
a warning if Java 19 is used, but `--enable-preview` is missing on Java's 
command line. In all cases it falls back to the default 
`MappedByteBufferIndexInputProvider` implementation in the main part of JAR 
file.
   
   I also added distribution test that checks if the built JAR file is a 
correct MR-JAR and it also works with module system.
   
   The current PR still requires Java 19 as `RUNTIME_JAVA_HOME` because of 
missing toolchain support. To test the "legacy" byte buffer implementation, one 
can comment the `--enable-preview` from the test's JVM args.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to