ArrayIndexOutOfBoundsException
Henry Coles <[email protected]> Tue, 10 Jul 2018 16:50:13 +0100
| Newsgroups | gmane.comp.java.objectweb.asm |
|---|---|
| Message-ID | <CALGd+STqYiY0pnQgoKWi6kQoP5DhOvWDGRtsN7Aex6UbbVu8zQ@mail.gmail.com> |
I've recently had a bug reported against a project I maintain that looks
like it might be a bug in ASM (thanks for a great library by the way).
https://github.com/hcoles/pitest/issues/481
Reading the following class (from this project
https://github.com/ReedOei/eunomia/blob/master/src/main/java/com/reedoei/eunomia/ast/resolved/ResolvedMethod.java
)
public class ResolvedMethod {
public final List<ResolvedMethodCall> methodCalls = new ArrayList<>();
public final MethodDeclaration base;
public final ResolvedMethodDeclaration declaration;
public ResolvedMethod(final MethodDeclaration base) {
this.base = base;
declaration = base.resolve();
for (final MethodCallExpr calls : base.findAll(MethodCallExpr.class)) {
methodCalls.add(new ResolvedMethodCall(calls));
}
// Sort by line, then by column.
methodCalls.sort((a, b) ->
new NOptionalBuilder<String, Range>().
add("a", a.base.getRange())
.add("b", b.base.getRange())
.build()
.fromOptional(0, m -> {
final @Nullable Range aRange = m.get("a");
final @Nullable Range bRange = m.get("b");
if (aRange != null && bRange != null) {
if (aRange.begin.line < bRange.begin.line ||
(aRange.begin.line ==
bRange.begin.line && aRange.begin.column < bRange.begin.column)) {
return -1;
} else if (aRange.begin.line == bRange.begin.line &&
aRange.begin.column == bRange.begin.column){
return 0;
} else {
return 1;
}
} else {
return 0;
}
}));
}
}
Results in
Caused by: java.lang.ArrayIndexOutOfBoundsException: 137
at org.pitest.reloc.asm.ClassReader.readLabel (ClassReader.java:2442)
at org.pitest.reloc.asm.ClassReader.createLabel (ClassReader.java:2458)
at org.pitest.reloc.asm.ClassReader.readTypeAnnotations
(ClassReader.java:2524)
at org.pitest.reloc.asm.ClassReader.readCode (ClassReader.java:1688)
at org.pitest.reloc.asm.ClassReader.readMethod (ClassReader.java:1274)
at org.pitest.reloc.asm.ClassReader.accept (ClassReader.java:679)
at org.pitest.reloc.asm.ClassReader.accept (ClassReader.java:391)
This is reproducible with both ASM 6.1.1 and 6.2.
The issue seems to relate to the @Nullable annotations.
Is this a known issue?
The code used to read the class is here
https://github.com/hcoles/pitest/blob/3e2e77fb38793f534a1bb93dff7d45c975764a57/pitest/src/main/java/org/pitest/classinfo/ClassInfoVisitor.java#L39
Thanks
Henry
--
You receive this message as a subscriber of the [email protected] mailing list.
To unsubscribe: mailto:[email protected]
For general help: mailto:[email protected]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws