Exception processing a module-info.class found in the wild
The package libjson-smart-java
in Debian pre-release currently contains an embedded module-info.class
which ASM barfs on.
- Package page: https://packages.debian.org/search?keywords=libjson-smart-java
- Upstream: https://netplex.github.io/json-smart/
- Build script: https://sources.debian.org/src/json-smart/2.2-2/json-smart/pom.xml/#L60
- Build-script weirdness: Maven Bundle Plugin
<Embed-Dependency>accessors-smart;groupId=net.minidev;inline=true</Embed-Dependency>
. - The file: module-info.class
Error message in HEAD (0cae8ffa):
% java -cp asm-util/build/libs/asm-util-7.0-beta-SNAPSHOT.jar:asm/build/libs/asm-7.0-beta-SNAPSHOT.jar org.objectweb.asm.util.ASMifier module-info.class
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 29
at org.objectweb.asm.ClassReader.readUtf(ClassReader.java:3424)
at org.objectweb.asm.ClassReader.readUTF8(ClassReader.java:3411)
at org.objectweb.asm.ClassReader.readStringish(ClassReader.java:3480)
at org.objectweb.asm.ClassReader.readModule(ClassReader.java:3508)
at org.objectweb.asm.ClassReader.readModuleAttributes(ClassReader.java:710)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:534)
at org.objectweb.asm.ClassReader.accept(ClassReader.java:389)
at org.objectweb.asm.util.Printer.main(Printer.java:1247)
at org.objectweb.asm.util.ASMifier.main(ASMifier.java:137)
Almost identical failure from our repackaged 6.2.1(?):
Caused by: java.lang.ArrayIndexOutOfBoundsException: 29
at ...asm.ClassReader.readUTF(ClassReader.java:3388)
at ...asm.ClassReader.readUTF8(ClassReader.java:3375)
at ...asm.ClassReader.readStringish(ClassReader.java:3445)
at ...asm.ClassReader.readModule(ClassReader.java:3473)
at ...asm.ClassReader.readModule(ClassReader.java:711)
at ...asm.ClassReader.accept(ClassReader.java:536)
at ...asm.ClassReader.accept(ClassReader.java:391)
...
Note that javap also has some issues with the file:
% javap -c /var/tmp/faux180917.profuse/module-info.class
class org.objectweb.asm.module-info {
}
% javap -c -verbose /var/tmp/faux180917.profuse/module-info.class
Classfile /var/tmp/faux180917.profuse/module-info.class
Last modified 16 Oct 2017; size 186 bytes
MD5 checksum 14376005a9a1306d35901dc9522bece7
class org.objectweb.asm.module-info
minor version: 0
major version: 53
flags: (0x8000) ACC_MODULE
this_class: #2 // "org/objectweb/asm/module-info"
super_class: #0
interfaces: 0, fields: 0, methods: 0, attributes: 2
Constant pool:
#1 = Utf8 org/objectweb/asm/module-info
#2 = Class #1 // "org/objectweb/asm/module-info"
#3 = Utf8 java.base
#4 = Utf8 org/objectweb/asm
#5 = Utf8 org/objectweb/asm/signature
#6 = Utf8 Module
#7 = Utf8 Version
#8 = Utf8 6.0_ALPHA
{
}
Error: java.lang.reflect.InvocationTargetException
Module: length = 0x14
00 01 00 03 80 20 00 02 00 04 00 00 00 05 00 00
00 00 00 00
Error: unknown attribute
Version: length = 0x2
00 08
(Note the errors towards the end, and the irony of it being an older embedded ASM.)
This is almost certainly an invalid file, but it was probably produced by an OpenJDK build at some point, so it's not impossible others will see them.
Maybe you think the exception is okay, and that I shouldn't be processing module-info
files. I don't care, but I didn't know that when I started!