mercredi 22 juin 2016

How can I use reflection with Java 9 on the Java internals?

We use this type of Reflection only in our test framework and not in production. We want add some jar files to the app classloader depending of our test code. Is there any workaround for it? How can we get access to not exported classes?

java.lang.reflect.InaccessibleObjectException: Unable to make member of class jdk.internal.loader.ClassLoaders$AppClassLoader accessible:  module java.base does not export jdk.internal.loader to unnamed module @9f73a2
    at jdk.internal.reflect.Reflection.throwInaccessibleObjectException(Reflection.java:414)
    at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:174)
    at java.lang.reflect.Method.checkCanSetAccessible(Method.java:191)
    at java.lang.reflect.Method.setAccessible(Method.java:185)





Aucun commentaire:

Enregistrer un commentaire