You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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.
Technically, this is an issue in ASM which we're forking there, currently at ASM 5.0.4 level. As of Spring Framework 4.3, this is based on ASM 5.1... However, your issue doesn't seem to be addressed there either yet, and I'm not aware of a workaround either.
So we can certainly address this in a custom fashion within our ASM fork, through a defensive catch block around type annotation parsing (and possibly similar metadata that Spring does not actually need for its component introspection, which is the only purpose of our repackaged ASM ClassReader). We'll do this for 4.3 RC1 as well as 4.2.6.
We're leniently handling any label offset mismatch now. Please give it a try against the upcoming 4.3.0.BUILD-SNAPSHOT; to be backported to 4.2.6 in a bit.
Once ASM published an official fix for the actual cause of the mismatch, we'll roll it in as well.
Tom van den Berge opened SPR-14089 and commented
I'm getting an exception when starting up my Spring Boot application:
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
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:
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:
The text was updated successfully, but these errors were encountered: