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

Alan Bateman Alan.Bateman at
Sat Aug 6 14:01:54 UTC 2016

On 06/08/2016 02:52, Julien Gouesse wrote:

> 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
You've put the --add-exports option after your main class on the command 
line, try place it before the main class so that it's considered as an 
argument to the java launcher rather an argument to your main class.

One other thing to point out if that jdk.internal.ref.Cleaner is a 
Runnable so you can at least stay in the world of standard types.


More information about the jigsaw-dev mailing list