ClassReader throws an exception while parsing Java 9 module_info.class
I ran into an issue compiling one of my Java 9 modules, with Maven failing during testCompile phase with the following exception:
Caused by: java.lang.ArrayIndexOutOfBoundsException: 29 at org.objectweb.asm.ClassReader.readUTF8(ClassReader.java:2591) at org.objectweb.asm.ClassReader.readStringish(ClassReader.java:2659) at org.objectweb.asm.ClassReader.readModule(ClassReader.java:2693) at org.objectweb.asm.ClassReader.readModule(ClassReader.java:726) at org.objectweb.asm.ClassReader.accept(ClassReader.java:632) at org.objectweb.asm.ClassReader.accept(ClassReader.java:500) at org.codehaus.plexus.languages.java.jpms.AsmModuleInfoParser.parse(AsmModuleInfoParser.java:81) at org.codehaus.plexus.languages.java.jpms.AsmModuleInfoParser.getModuleDescriptor(AsmModuleInfoParser.java:65) at org.codehaus.plexus.languages.java.jpms.LocationManager.resolvePaths(LocationManager.java:113) at org.apache.maven.plugin.compiler.TestCompilerMojo.preparePaths(TestCompilerMojo.java:281) at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:762) at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:176) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
There is more, and you can see the full stack trace in MCOMPILER-309, but I believe the above is most relevant.
On suggestion from the Maven team I've upgraded ASM version used by
maven-compiler-plugin to 6.0, but that didn't help and I'm still seeing the exact same exception as before.
Attached is module-info.class file that ASM seems to be having problem with. Thanks in advance for looking into this.
closedToggle commit list
Argh... Sorry for the distraction, I figured out what was going on...
One of the test frameworks I use has a dependency on
cglib 3.2.5, which has a dependency on
ASM 6.0_ALPHA, so that version was picked up by Maven instead of the one specified for the
Once I excluded
cglibfrom my dependencies everything worked fine, both with
ASM 6.0and with whatever version is included by default with
So, considering that the problem is not on your end, I'm gonna close this issue, but it's not bad to have it around as a reference, as others may run into the same problem.
Hi Aleksandar, i'm happy that your have discover the problem.
ASM 6 ALPHA is now useless because it is able to handle an old version of the module-info.class, And i do not think there is a way to say that an artifact is dangerous in Maven Central :(
Yeah, and while most projects (including JDK) shade and relocate ASM version they depend on, unfortunately
cglibdoesn't. And they haven't released a new version since March...
This has already bit me in the past and caused me to rewrite a fairly large test suite to use Mockito instead of EasyMock, so I can't say that I'm all that happy with
cglibcausing me grief again :-(
And BTW, thank you for an awesome job on ASM.
It has helped me so many times over the years, I don't know what the life would be without it