Skip to content

Type annotations cause ArrayIndexOutOfBoundsException in ASM ClassReader [SPR-14089] #18661

@spring-projects-issues

Description

@spring-projects-issues

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:

Issue Links:

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions