On 07/07/2016 19:05, Martin Buchholz wrote:

When jdk9 is released, an army of white, black, grey, and red hats will try
to keep their old Unsafe hacks alive and maybe get their hands on a
jdk.internal.misc.Unsafe.
I assume these Unsafe usages are sun.misc.Unsafe so they should continue to work. More details in JEP 260 [1].


Here's some code that tries to do that. The call
to setAccessible succeeds! And the code succeeds in getting hold
of jdk.internal.misc.Unsafe.class and of its instance before finally
failing with IllegalAccessError.  So this may actually be safe, in that
user code may not be able to actually invoke methods on their ill-gotten
Unsafe object, but the intent is probably that they shouldn't be able to
get this far:
The behavior you see is expected. Many us would like setAccessible(true) to go away but there are many use-cases that would need alternatives first.

-Alan

[1] http://openjdk.java.net/jeps/260

Reply via email to