AnalyzerAdapter.execute() method doesn't process null array correctly for AALOAD instruction
AnalyzerAdapter (visitInsn(Opcodes.AALOAD)) fails on the following valid Java
construction with ClassCastException:
Object[] arr = null;
try {
Object obj = arr[0];
} catch(NullPointerException e) {
// ...
}
The reason is that AnalyzerAdapter.execute() method consider second stack value
as String for AALOAD instruction:
case Opcodes.AALOAD:
pop(1);
t1 = pop();
pushDesc(((String) t1).substring(1));
break;
However in this case the second value on the stack (array type) will be
Opcodes.NULL which causes ClassCastException.
I'd suggest the following fix for this issue:
case Opcodes.AALOAD:
pop(1);
t1 = pop();
if (t1 instanceof String) {
pushDesc(((String) t1).substring(1));
} else {
push("java/lang/Object");
}
break;