Proposal: Allow illegal reflective access by default in JDK 9

Alan Bateman Alan.Bateman at oracle.com
Fri May 19 11:14:00 UTC 2017


On 19/05/2017 11:58, Peter Levart wrote:

> :
>
> ...the example works (does not throw exception), but when run with:
>
>     --add-opens java.base/jdk.internal.misc=ALL-UNNAMED
>
> ...the example still works!!!! OOOPS - this is a bug!!! This is 
> definitely a bug.
No, the behavior is correct as jdk.internal.misc.Unsafe is public and 
it's getUnsafe is public. It's different to sun.misc.Unsafe.

However, you do have a point that opening all packages by default means 
that the internal Unsafe might need to be looked at again. The long term 
plan is to reduce the need for sun.misc.Unsafe but not by having 
libraries move to the internal Unsafe.

BTW: For the security manager case then I assume you code fragment would 
need to accessClassInPackage.jdk.internal.misc permission.

-Alan


More information about the jigsaw-dev mailing list