MagicAccessorImpl
Remi Forax
forax at univ-mlv.fr
Thu Jun 8 15:53:32 UTC 2017
Hi Henry,
----- Mail original -----
> De: "Henri Tremblay" <henri.tremblay at gmail.com>
> À: "jdk9-dev" <jdk9-dev at openjdk.java.net>
> Envoyé: Jeudi 8 Juin 2017 17:16:34
> Objet: MagicAccessorImpl
> Hi,
>
> As usual I'm doing evil things and I need your help.
don't do evil :)
>
> 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
>
> org.objenesis.instantiator.sun.MagicInstantiator$$$EmptyClass is the name
> of the generated class.
>
> Is there a way to make it work? Ideally through code or if it's impossible
> through parameters.
>
> I already tried -Xverify:none --add-opens java.base/jdk.internal.
> reflect=ALL-UNNAMED
you're trying to access to an unexported class not by reflection so you should use --add-exports
>
> The defineClass is the following (I did also ClassLoader.defineClass):
>
> PROTECTION_DOMAIN = AccessController.doPrivileged(new
> PrivilegedAction<ProtectionDomain>() {
> public ProtectionDomain run() {
> return ClassDefinitionUtils.class.getProtectionDomain();
> }
> });
>
> Class<T> c = (Class<T>) UnsafeUtil.getUnsafe().defineClass(className,
> b, 0, b.length, loader, PROTECTION_DOMAIN);
>
> Thanks,
>
> Henri
regards,
Rémi
More information about the jdk9-dev
mailing list