lundi 26 novembre 2018

How to prevent java.lang.IllegalAccessError with JDK11?

We receive the follow exception in our test system. Any idea how we can prevent this exception for example with a command line switch. And any idea how this exception can occur?

Can the completely access check be disabled in a test system that use intensively reflection and class loading?

java.lang.IllegalAccessError: class java.io.File (in module java.base) cannot access class javax.print.PrintException (in module java.desktop) because module java.base does not read module java.desktop
    at java.io.File.exists(File.java)
    at jdk.internal.loader.URLClassPath$FileLoader.getResource(URLClassPath.java:1199)
    at jdk.internal.loader.URLClassPath.getResource(URLClassPath.java:314)
    at jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:697)
    at jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:623)
    at jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:398)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.runTestClass(JUnitTestClassExecutor.java:67)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:58)
    at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecutor.execute(JUnitTestClassExecutor.java:38)
    at org.gradle.api.internal.tasks.testing.junit.AbstractJUnitTestClassProcessor.processTestClass(AbstractJUnitTestClassProcessor.java:66)

Aucun commentaire:

Enregistrer un commentaire