jdk.internal.reflect.ReflectionFactory and SecurityManager

Martin Buchholz martinrb at google.com
Mon Jan 9 18:43:44 UTC 2017

Relatedly, I'm writing whitebox jtreg tests and would like to use
VarHandles to access internal data structures.
Because I have:

 * @modules java.base/java.util.concurrent:open

I can use reflection with setAccessible to obtain a usable Field, but if I
try to turn that into a VarHandle I get:

        Field f = ConcurrentLinkedQueue.class.getDeclaredField("head");
        VarHandle v = java.lang.invoke.MethodHandles.lookup()

 java.lang.IllegalAccessException: member is private to package:
from WhiteBox (unnamed module @7a187f14)

It seems wrong to have this sort of mismatch - setAccessible works, but the
strictly more powerful VarHandles remain unobtainable.

I happen to have a workaround, but I don't see a general solution for
whitebox testing.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/jtreg-use/attachments/20170109/12000fb8/attachment.html>

More information about the jtreg-use mailing list