MagicAccessorImpl

Alan Bateman Alan.Bateman at oracle.com
Thu Jun 8 15:55:56 UTC 2017


On 08/06/2017 16:16, Henri Tremblay wrote:
> Hi,
>
> As usual I'm doing evil things and I need your help.
>
> I'm trying to use MagicAccessorImpl in Java 9 (jigsaw). So I am not using
> jdk.internal.reflect.MagicAccessorImpl.
>
> So I'm generating a class extending MagicAccessorImpl. And I'm getting the
> following exception:
>
> Caused by: java.lang.IllegalAccessError: class org.objenesis.instantiator.
> sun.MagicInstantiator$$$EmptyClass loaded by
> jdk/internal/loader/ClassLoaders$AppClassLoader
> cannot access jdk/internal/reflect superclass jdk.internal.reflect.
> MagicAccessorImpl
jdk.internal.reflect.MagicAccessorImpl is package private and it looks 
like you are trying to create the sub-type in a different package (and a 
different class loader). There are CLI options for patching java.base at 
both compile-time and run-time. If java.base/jdk.internal.reflect is 
opened then it's possible to inject classes into that package at 
run-time too. Maybe it better if you could start by explaining why you 
are trying to do, maybe there is a way to steer you away from hacking 
the classes in jdk.internal.reflect.

-Alan


More information about the jdk9-dev mailing list