Weird use case: compiling against dummy sun.misc.* class

Aleksey Shipilev aleksey.shipilev at oracle.com
Fri May 20 15:55:04 UTC 2016


Hi,

I have a weird use case in jcstress around @Contended.

In order to support both JDK 8 and JDK 9 we build against *our own*
sun.misc.Contended and jdk.internal.annotations.Contended. This works
arguably well for both compiling and running with both JDK 8 and JDK 9:
the real annotation gets picked up from the JDK.

However, since JDK 9b118 we cannot build anymore, because:

LongResult1_jcstress.java:[3,13] error: Contended is not visible because
package sun.misc is not visible

...even though sun/misc/Contended.java is right here in my source tree.
Is there a magic incantation to make javac proceed? The usual tricks did
not help (probably because the target class is not in jdk.unsupported,
but rather in the source tree itself):
  -addmods jdk.unsupported
  -XaddExports:jdk.unsupported/sun.misc=ALL-UNNAMED
  -XaddReads:jdk.unsupported=ALL-UNNAMED

Thanks,
-Aleksey



More information about the jigsaw-dev mailing list