jdk.internal.reflect.ReflectionFactory and SecurityManager

Uwe Schindler uschindler at apache.org
Mon Jan 9 18:49:44 UTC 2017


It's also inconsistent, because the same type of code works with MethodHandles. If you make something accessible (and succeed doing this), it uses some special internal lookup that has no restrictions for unreflect. 


Am 9. Januar 2017 19:43:44 MEZ schrieb Martin Buchholz <martinrb at google.com>:
>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");
>        f.setAccessible(true);
>        VarHandle v = java.lang.invoke.MethodHandles.lookup()
>            .unreflectVarHandle(f);
> 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
>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/461e2bd6/attachment-0001.html>

More information about the jtreg-use mailing list