Prepare ObjectTeams for Java 9 and beyond [message #1784184] |
Fri, 23 March 2018 09:29 |
|
Hi all,
I am using Object Teams currently in the context of a Java 9 application.
Object Teams plugins are compiled with Java 7 and 8, except the runtime, which I also compile with Java 9.
When building my application which is using ObjectTeams and is compiled with Java 9 I have to change my script executing the project as follows:
Without changing my JVM parameters I get the following error:
Error: A JNI error has occurred, please check your installation and try again
Error: A JNI error has occurred, please check your installation and try again
Exception in thread "main" java.lang.IllegalAccessError: superinterface check failed: class sun.launcher.LauncherHelper (in module java.base) cannot access class org.objectteams.IBoundBase2 (in unnamed module @0x64616ca2) because module java.base does not read unnamed module @0x64616ca2
Okay, that is because I did not provide a module-info.java. But also, because the project does not provide a module-info.java, where it exports the module so I can export it transitively (if needed).
So, I have to add the JVM parameter MODULES="--add-reads=java.base=ALL-UNNAMED" to make it run.
Now I get the following warnings:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.eclipse.objectteams.otredyn.bytecode.asm.verify.OTCheckClassAdapter$ShyLoader (file:/Users/lschuetze/Development/repos/role-benchmarks/benchmarks/objectteams-compiler-work/invy/build/objectteams-benchmark.jar) to method java.lang.ClassLoader.findLoadedClass(java.lang.String)
WARNING: Please consider reporting this to the maintainers of org.eclipse.objectteams.otredyn.bytecode.asm.verify.OTCheckClassAdapter$ShyLoader
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
The following code is responsible for the warning:
if (findLoadedClass == null) {
findLoadedClass = ClassLoader.class.getDeclaredMethod("findLoadedClass", String.class);
findLoadedClass.setAccessible(true);
}
As it tells you, in future Java releases this illegal reflective access could be forbidden completely and maybe also not be configurable through JVM parameters.
Since in the future more and more software will be written that leverages the modules system is there a plan to support that in the near/far future? For example I could think of a possible generation of module-info.java using the data from META-INF.md.
[Updated on: Mon, 26 March 2018 10:18] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.03753 seconds