"Incompatible InnerClasses attribute" error in IBM J9 VM
ASM generates unexpected bytecode get's the following exception in some certain
cases on IBM JVM:
Caused by: java.lang.IncompatibleClassChangeError: incompatible InnerClasses
attribute between "org.zeroturnaround.Erroneous$MyInner" and
"org.zeroturnaround.Erroneous"
I have seen this error before and also found a jenkins bug caused by it:
https://issues.jenkins-ci.org/browse/JENKINS-22525
The cause seems to be that in some cases the compiled byte code has 2 class
references to the same class. In the original bytecode the first reference is
used, but after ASM parses the class both references are used and this causes
some trouble for IBM JVM.
Based on that I managed to make a reproduction application. When you look at
the bytecode before and after the transformation you can see the difference.
One fix I found would be to change
ClassWriter
private Item get(final Item key) {
Item i = items[key.hashCode % items.length];
Item best = null;
while (i != null) {
if (i.type == key.type && key.isEqualTo(i)) {
if (best == null) {
best = i;
} else if (best.index > i.index) {
best = i;
}
}
i = i.next;
}
return best;
}