On 09.12.2016 12:59, Alan Bateman wrote:
On 09/12/2016 07:55, Jochen Theodorou wrote:
Maybe we have luck here and it does not apply, but if the field comes
from a class of a module and is private, my current level knowledge of
jigsaw says, that setAccessible will fail with an exception. It does
not matter at all if the class with the field is exported or not. That
is because just before the JavaOne #AwkwardStrongEncapsulation made it
into jigsaw. Only way around this is to use the Lookup object that has
the correct rights from the beginning. How to get it... well... there
will be only solutions for certain types of classes.
MethodHandles.privateLookupIn [1] was recently added to get a Lookup
with private access, it may be useful here.
I think the documentation needs some improvement to make it clear what
lookup modes are set when. And by that I mean really using the mode
names in the description. Just from a short lookup for example I have no
idea when the MODULE mode is set for a Lookup and when not.
[...]
[1]
http://download.java.net/java/jdk9/docs/api/java/lang/invoke/MethodHandles.html#privateLookupIn-java.lang.Class-java.lang.invoke.MethodHandles.Lookup-
bye Jochen