lmdbjava: Replace Unsafe and illegal reflection operations
Gave a quick try to lmdbjava with JDK 9 and wanted to record the findings here.
Due the the class access restrictions imposed by Jigsaw, the following JVM arguments have to be specified:
--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 6
- Comments: 31 (17 by maintainers)
Commit 5687bd61ff8de770800fa319b4b98a0f61a92b24 shows how to add the required JVM parameters for running tests in Maven builds etc. It’s implemented as a profile as we presently perform CI builds with Java 8.
https://openjdk.java.net/jeps/412 looks a promising pathway for Java 17 and above, particularly given Java 17 is LTS.
How would people feel about LmdbJava 1.x targeting Java 16 and below, with LmdbJava 2.x requiring Java 17 and above? This would draw a line in the sand and allow use of newer APIs.
I just wanted to ask if there is any progress on this issue. I’m using
--add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED
where possible, but in some cases I cannot do that and then the “illegal reflective access” warnings show up. BTW: Does anybody know how to get rid of the warnings without the commandline arguments?The main thing it would solve is removing all illegal code from LmdbJava, in turn simplifying our maintenance effort, Java 9 compliance status and Android porting compatibility. Those using Agrona, Netty, safe
ByteBuffer
andbyte[]
will see no material performance difference.I concede JNR-FFI, Agrona and Netty still have to solve these issues, but they should be better positioned to do so given they are popular, low-level libraries.
My broader (non-LmdbJava) testing with Java 9 found countless issues with other applications and libraries as well. As such I have put Java 9 on ice for now and suggest we sit back and see what happens over the next few months. This seems pragmatic anyway given the build and tooling ecosystem isn’t there yet (eg Java 9 meaning broken Maven plugins, lack of working CI etc).