Review Request JDK-8181443: Replace usages of jdk.internal.misc.Unsafe with MethodHandles.Lookup.defineClass

Alan Bateman Alan.Bateman at oracle.com
Wed Oct 3 19:49:14 UTC 2018


On 03/10/2018 18:56, Mandy Chung wrote:
> This patch replaces java.lang.invoke and JFR use of
> jdk.internal.misc.Unsafe::defineClass with Lookup::defineClass.
> It also replaces dynamic proxy and reflection implementation to
> use the shared secret to invoke ClassLoader::defineClass.
>
> Webrev:
> http://cr.openjdk.java.net/~mchung/jdk12/webrevs/8181443/webrev.00
>
> With this change, JDK no longer uses Unsafe::defineClass.
> Any opinion in removing Unsafe::defineClass support?
>
> I ran jdk_core, jdk_jfr, tier1_runtime and tier1_compiler tests.
>
This change looks okay to me.

Nothing outside of java.base should be making direct use of classes in 
jdk.internal.misc so it's okay to refactor or remove classes or methods 
as needed. In this case, the internal defineClass is an attractive 
nuisance as there may be libraries tempted to hack into it. So I think 
it should be removed at some point.

-Alan


More information about the core-libs-dev mailing list