Java是向后兼容的,但是为什么我们在将jdk从1.6升级到1.8的时候需要升级很多库呢?
最近,我们在我的一个 Java 项目中将 Jdk 版本从 1.6
升级到 1.8
.但是有一些编译或运行时错误,所以我不得不升级一些库:
Recently, we upgrade the Jdk version from 1.6
to 1.8
in one of my Java project. But there are some compilation or runtime errors, so I have to upgrade some libraries:
- gradle:
1.9
到1.10
- spring:
3.x
到4.x
- gradle:
1.9
to1.10
- spring:
3.x
to4.x
那是因为他们使用的是 ASM 的一些早期版本,但仅从 5.x
That because they are using some early versions of ASM, but which supports jdk 1.8 only from 5.x
Java说是向后兼容,但是为什么原版的库不能直接用jdk 1.8呢?
Java said it is backward compatible, but why the original versions of libraries can't work with jdk 1.8 directly?
推荐答案
因为 ASM 是一个对 Java 字节进行操作的工具-代码.并且改变了字节码格式以引入新功能.因此,您必须升级工具以支持新的字节码.
Because ASM is a tool that operates on the Java byte-code. And the byte-code format changed to introduce new features. As such, you had to upgrade the tool to support the new byte-code.
请注意,使用旧版 JDK 编译的软件并不总是适用于新版 Java.例如,enum
在 JDK 的早期版本中不是关键字.
Note, that software compiled with an older version of the JDK does not always work with newer versions of Java. For example, enum
was not a keyword in early versions of the JDK.
相关文章