Junit5: Classpath scanner should not load JDK 9 module-info.class

Created on 10 Nov 2016  路  15Comments  路  Source: junit-team/junit5

java.lang.NoClassDefFoundError: java/jnlp/module-info (wrong name: module-info)
 at java.lang.ClassLoader.defineClass1(java.base@9-ea/Native Method)
 at java.lang.ClassLoader.defineClass(java.base@9-ea/ClassLoader.java:941)
 at java.security.SecureClassLoader.defineClass(java.base@9-ea/SecureClassLoader.java:150)
 at jdk.internal.loader.BuiltinClassLoader.defineClass(java.base@9-ea/BuiltinClassLoader.java:554)
 at jdk.internal.loader.BuiltinClassLoader.access$200(java.base@9-ea/BuiltinClassLoader.java:89)
 at jdk.internal.loader.BuiltinClassLoader$3.run(java.base@9-ea/BuiltinClassLoader.java:467)
 at jdk.internal.loader.BuiltinClassLoader$3.run(java.base@9-ea/BuiltinClassLoader.java:461)
 at java.security.AccessController.doPrivileged(java.base@9-ea/Native Method)
 at jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(java.base@9-ea/BuiltinClassLoader.java:460)
 at jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(java.base@9-ea/BuiltinClassLoader.java:407)
 at jdk.internal.loader.BuiltinClassLoader.loadClass(java.base@9-ea/BuiltinClassLoader.java:365)
 at jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(java.base@9-ea/ClassLoaders.java:186)
 at java.lang.ClassLoader.loadClass(java.base@9-ea/ClassLoader.java:419)
 at org.junit.platform.commons.util.ReflectionUtils.loadClass(ReflectionUtils.java:330)
 at org.junit.platform.commons.util.ClasspathScanner.processClassFileSafely(ClasspathScanner.java:154)
 at org.junit.platform.commons.util.ClasspathScanner.lambda$findClassesForPath$3(ClasspathScanner.java:139)
 at org.junit.platform.commons.util.ClassFileVisitor.visitFile(ClassFileVisitor.java:40)
 at org.junit.platform.commons.util.ClassFileVisitor.visitFile(ClassFileVisitor.java:24)
 at java.nio.file.Files.walkFileTree(java.base@9-ea/Files.java:2695)
 at java.nio.file.Files.walkFileTree(java.base@9-ea/Files.java:2767)
 at org.junit.platform.commons.util.ClasspathScanner.findClassesForPath(ClasspathScanner.java:139)

Initially reported https://youtrack.jetbrains.com/issue/IDEA-163795

Platform bug

All 15 comments

Good catch, @akozlova.

We'll fix it.

_in progress_

567 too simplistic?

@sormuras, I don't think catching NoClassDefFoundError is appropriate in this scenario.

We have a different approach for explicitly excluding package-info and module-info class files. See d065ec688c2f442942215081eca780a2e5d384ca for details.

Of course, if the community determines the current fix is inappropriate, we will reassess the issue.

Cheers!

@akozlova, please give the fix a try in the next snapshot and let us know how it works for you.

Thanks!

As being the reporter of the issue, I'm test driving your explicite fix just now...

Download https://oss.sonatype.org/.../junit-platform-commons-1.0.0-20161115.171218-290.jar

...was to fast. Travis was still working on https://github.com/junit-team/junit5/commit/d065ec688c2f442942215081eca780a2e5d384ca Next try with:

https://oss.sonatype.org/.../junit-platform-commons-1.0.0-20161115.172241-291.jar

Warning vanished. Works like a charm! Thanks, @sbrannen

Awesome!

Thanks for letting us know so quickly! 馃憤

Thanks Sam, Christian!
BTW Any chances to have M3 this week so we could include it for our upcoming release?

Hmmmm.... M3 this week? 馃槺

We're close, but we still have 8 open issues assigned to M3.

So, we'll do our best, but I can't make any promises.

Maybe we can reduce the scope and get M3 out the door earlier.

@junit-team/junit-lambda thoughts?

Move https://github.com/junit-team/junit5/issues/369 to M4 -- it's screen candy, only. 馃槈

I'll check the snapshot tomorrow, as we use M2 now.

If I have dependency on M2 api in my project and IDEA uses current SNAPSHOT, I get
java.lang.BootstrapMethodError: java.lang.NoClassDefFoundError: org/junit/jupiter/api/function/Executable

at org.junit.jupiter.engine.descriptor.MethodTestDescriptor.invokeBeforeEachCallbacks(MethodTestDescriptor.java:170)
at org.junit.jupiter.engine.descriptor.MethodTestDescriptor.execute(MethodTestDescriptor.java:149)
at org.junit.jupiter.engine.descriptor.MethodTestDescriptor.execute(MethodTestDescriptor.java:63)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$0(HierarchicalTestExecutor.java:80)
at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:76)
at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.lambda$execute$0(HierarchicalTestExecutor.java:87)
at org.junit.platform.engine.support.hierarchical.SingleTestExecutor.executeSafely(SingleTestExecutor.java:66)

I believe that it would be a problem for people. Why this class is in the API actually?

We're not paying close attention to backwards compatibility, yet. This will change when we release the first GA release. For now, the version of the Jupiter engine should match the version of the Jupiter API. Is there a way to ensure that?

As the Jupiter engine is shipped with IDEA, then the only solution I see: we would have to ship all versions to match the user's version. Looks not really great for us, but may be I miss something

Was this page helpful?
0 / 5 - 0 ratings