Java 1.8 ASM ClassReader 无法解析类文件 - 可能是由于尚不支持新的 Java 类文件版本
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22526695/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java 1.8 ASM ClassReader failed to parse class file - probably due to a new Java class file version that isn't supported yet
提问by stanislav.chetvertkov
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.
我的 Web 应用程序在 JDK 1.7 上运行良好,但在 1.8 上崩溃,出现以下异常(在使用 Jetty 8 启动应用程序服务器期间)。我使用的是 Spring 版本: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
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.
我认为这个问题是由于 spring 和它所依赖的“asm.jar”库而发生的。
How do I resolve this?
我该如何解决?
采纳答案by Leszek Grucha?a
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.
正如@prunge 和@Pablo Lozano 所说,如果您想将代码编译为 Java 8(--target 1.8),您需要 Spring 4,但如果您在 Spring 3.2.X 上运行,您仍然可以在编译为 Java 7 的 Java 8 上运行应用程序。
Check out http://docs.spring.io/spring/docs/current/spring-framework-reference/html/new-in-4.0.html
查看 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.
请注意,仅从 Spring Framework 4.0 开始完全支持 Java 8 字节码级别(-target 1.8,如 -source 1.8 所要求的)。特别是,基于 Spring 3.2 的应用程序最多需要以 Java 7 为目标进行编译,即使它们恰好部署到 Java 8 运行时。对于基于 Java 8 的应用程序,请升级到 Spring 4。
回答by ItayK
If you encounter this error even if you compile with -target 1.7, please note that this is because of a bug in Spring Framework which causes ASM classreader to load jdk classes (java.* or javax.*), which are, of course, compiled with -target 1.8.
如果即使使用-target 1.7编译也遇到这个错误,请注意这是由于Spring Framework中的一个bug导致ASM classreader加载jdk类(java.*或javax.*),当然,使用 -target 1.8 编译。
This, combined with the old ASM version in spring 3.2.8 and below, which does not support parsing of 1.8 class files, can also lead to this error.
这个,结合spring 3.2.8及以下不支持解析1.8类文件的旧ASM版本,也会导致这个错误。
More info about the issue can be found here: https://jira.spring.io/browse/SPR-11719
可以在此处找到有关该问题的更多信息:https: //jira.spring.io/browse/SPR-11719
This should be fixed in Spring Framework version 3.2.9, which is due to be released soon.
这应该在即将发布的 Spring Framework 3.2.9 版中得到修复。
Of course, upgrading to Spring Framework 4 will also resolve the issue, as it already contains a newer version of ASM.
当然,升级到 Spring Framework 4 也能解决这个问题,因为它已经包含了 ASM 的更新版本。
However, if for some reason you can't upgrade to version 4 yet, it's good to know there's an alternative (soon).
但是,如果由于某种原因您还不能升级到版本 4,那么很高兴知道有替代方案(很快)。
回答by AdZzZ
Spring 4 can be used for java 8 to resolve this issue. I just tested it and it works. This issue is fixed since Spring 3.2.9-RELEASE version.
Spring 4 可以用于 java 8 来解决这个问题。我刚刚测试了它并且它有效。此问题自 Spring 3.2.9-RELEASE 版本以来已修复。
回答by shafaetjsr
if you use java 8 or next version you need to upgrade spring version and spring version should be 4.xxx
如果您使用 java 8 或下一个版本,则需要升级 spring 版本,spring 版本应为 4.xxx
回答by rohan
I had the same problem and solved it. I am using spring 3.x with java 8. If above solutions are not working change the jars and search whether those jars are compatible with the java version you are using or not. spring 3.x is not compatible with java 8.
我遇到了同样的问题并解决了它。我在 java 8 中使用 spring 3.x。如果上述解决方案不起作用,请更改 jars 并搜索这些 jars 是否与您使用的 java 版本兼容。spring 3.x 与 java 8 不兼容。