cannot access class jdk.internal.ref.Cleaner (in module java.base) because module java.base does not export jdk.internal.ref to unnamed module

Julien Gouesse gouessej at yahoo.fr
Sat Aug 6 09:52:51 UTC 2016


Hi


I need to run the cleaner of a direct NIO byte buffer by using the reflection API to access to non public APIs as I successfully did with previous versions of Java. The cleaner is in the class "Cleaner" in the package "jdk.internal.ref" in the module "java.base" and my own module is unnamed. Then, I tried to pass "--add-exports java.base/jdk.internal.ref=ALL-UNNAMED" to the command "java" but I get the following exception:
[gouessej at localhost test-classes]$ ~/Téléchargements/jdk-9/bin/java -cp ../classes:../test-classes engine/misc/TestDeallocationHelper --add-exports java.base/jdk.internal.ref=ALL-UNNAMED 
août 06, 2016 11:25:22 AM engine.misc.DeallocationHelper$OracleSunOpenJdkDeallocator run
AVERTISSEMENT: The deallocation of a direct NIO buffer has failed
java.lang.IllegalAccessException: class engine.misc.DeallocationHelper$OracleSunOpenJdkDeallocator cannot access class jdk.internal.ref.Cleaner (in module java.base) because module java.base does not export jdk.internal.ref to unnamed module @464bee09
at jdk.internal.reflect.Reflection.throwIllegalAccessException(java.base at 9-ea/Reflection.java:405)
at jdk.internal.reflect.Reflection.throwIllegalAccessException(java.base at 9-ea/Reflection.java:396)
at jdk.internal.reflect.Reflection.ensureMemberAccess(java.base at 9-ea/Reflection.java:98)
at java.lang.reflect.AccessibleObject.slowCheckMemberAccess(java.base at 9-ea/AccessibleObject.java:355)
at java.lang.reflect.AccessibleObject.checkAccess(java.base at 9-ea/AccessibleObject.java:347)
at java.lang.reflect.Method.invoke(java.base at 9-ea/Method.java:527)
at engine.misc.DeallocationHelper$OracleSunOpenJdkDeallocator.run(DeallocationHelper.java:109)
at engine.misc.DeallocationHelper.deallocate(DeallocationHelper.java:729)
at engine.misc.TestDeallocationHelper.main(TestDeallocationHelper.java:137)

What am I missing?


More information about the jigsaw-dev mailing list