-
Notifications
You must be signed in to change notification settings - Fork 38.8k
Description
Tom van den Berge opened SPR-14089 and commented
I'm getting an exception when starting up my Spring Boot application:
java.lang.ArrayIndexOutOfBoundsException: 193
at org.springframework.asm.ClassReader.readLabel(ClassReader.java:2185)
at org.springframework.asm.ClassReader.readTypeAnnotations(ClassReader.java:1614)
...
It seems that when my classes are inspected for annotations, ClassReader (Spring 4.2.5) chokes on one of my classes containing Java-8 type annotations. This is extremely unfortunate, because it means that I can't use Spring annotations in combination with type annotations.
I've attached a very small (maven) project that reproduces the problem. All you need to do is run "mvn test". The included unit test attempts to read the problematic class file using org.springframework.asm.ClassReader, and gives the same exception as above.
The class that can't be read is
public class Problem implements Interface<String> {
public void serialize(String request) {
Map<String, @Nullable Object> values = new HashMap<>();
values.clear();
}
}
The @Nullable
type annotation is from org.eclipse.jdt.annotation 2.0.0. I've included the source code in the attached project.
And the interface:
public interface Interface<T> {
void serialize(T request);
}
Without the interface, the problem doesn't occur. Also the type parameter is essential to reproduce the problem.
What is also surprising, is that when the class is not compiled by maven (javac), but by Eclipse, the problem does not occur.
It would be great to know if there is a workaround for this problem, e.g. compiler settings that can be included in the pom file.
Affects: 4.2.5
Attachments:
- project.tar (8.50 kB)
Issue Links:
- Type annotations and generic types causing ArrayIndexOutOfBoundsException [SPR-17467] #21999 Type annotations and generic types causing ArrayIndexOutOfBoundsException