Re: trySetAccessible​

Alan Bateman Alan.Bateman at oracle.com
Mon Jul 10 10:02:16 UTC 2017


On 10/07/2017 09:43, Uwe Schindler wrote:
> Hi Alan,
>
> I was trying to fix Groovy to use trySetAccessible() instead of setAccessible() and this did not change any warnings at all: The code can be found here:
>
> https://github.com/apache/groovy/compare/master...uschindler:java9/trySetAccessible
>
> It did not change anything. In fact, the code behaved as it did before - no change at all! Warnings are almost the same (actually worse, because of how I did it using MethodHandles, see bwlow). It also granted full access, like the usual call to setAccessible()!
This is because the java.lang package is open at runtime in JDK 9. Once 
open then you can use both old and new APIs to do so-called "deep 
reflection" on members of all classes in the package.

-Alan


More information about the jigsaw-dev mailing list