Java 1.8 ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet

sta*_*kov 78 java spring java-8

My web application runs fine on JDK 1.7 but crashes on 1.8 with the following exception (during application server startup with Jetty 8). I am using Spring version: 3.2.5.RELEASE.

Exception:

org.springframework.core.NestedIOException: ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet

I assume that problem occurs because of spring and "asm.jar" library on which it depends.

How do I resolve this?

Les*_*ała 112

As @prunge and @Pablo Lozano stated, you need Spring 4 if you want compile code to Java 8 (--target 1.8), but you can still run apps on Java 8 compiled to Java 7 if you run on Spring 3.2.X.

Check out http://docs.spring.io/spring/docs/current/spring-framework-reference/html/new-in-4.0.html

Note that the Java 8 bytecode level (-target 1.8, as required by -source 1.8) is only fully supported as of Spring Framework 4.0. In particular, Spring 3.2 based applications need to be compiled with a maximum of Java 7 as the target, even if they happen to be deployed onto a Java 8 runtime. Please upgrade to Spring 4 for Java 8 based applications.

  • 这也发生在我身上,即使代码仍然编译为目标1.7,我只将运行时改为java 8.任何想法? (2认同)
  • 请参阅 ItayK 的回答,spring 3.2.8 及以下版本存在一个错误,无法使用正确的 asm 版本,已在 3.2.9 中修复- (2认同)
  • 3.2.10中还修复了另一个错误,因此我建议使用3.2.16或其他最新版本.以下是修复的关键Spring错误:[元数据读取不应该使用ASM for java.*和javax.*类型(特别是在JDK 8上)](https://jira.spring.io/browse/SPR-11719 )[Java 8:在接口上解析INVOKESPECIAL/STATIC所需的ASM5访问者](https://jira.spring.io/browse/SPR-11979) (2认同)

小智 65

如果你使用-target 1.7编译时遇到这个错误,请注意这是因为Spring Framework中的一个错误导致ASM类重写器加载jdk类(java.*或javax.*),当然,用-target 1.8编译.

这与春季3.2.8及更低版本中的旧ASM版本相结合,不支持解析1.8类文件,也可能导致此错误.

有关该问题的更多信息,请访问:https://jira.spring.io/browse/SPR-11719

这应该在Spring Framework版本3.2.9中修复,该版本即将发布.

当然,升级到Spring Framework 4也将解决该问题,因为它已经包含更新版本的ASM.

但是,如果由于某种原因你还无法升级到版本4,那么很高兴知道有一种替代方案(很快).

  • 升级到Spring 3.2.9对我有所帮助. (5认同)
  • 这应该是公认的答案,因为它清楚地解释了问题所在 (2认同)
  • 有了Spring 3.2.5的这个问题,改为3.2.9并且问题解决了.完美答案. (2认同)