根据发行说明,从 JVM 1.4 切换到 1.5 具有性能优势。 http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html#performance
我们有在 1.5 JVM 上运行的 Java 1.4 编译类,这些类会因为使用 1.4 编译而降低性能吗?
最佳答案
其中许多功能都是“语法糖”。这意味着该语言具有新功能,但它编译为相同的字节码。所以不,你不应该在性能上受到影响。更新后的 VM 上的相同字节码。
"J2SE 5.0 is strongly compatible with previous versions of the Java 2 platform. Almost all existing programs should run on J2SE 5.0 without modification. However, there are some minor potential source and binary incompatibilities in the JRE and JDK that involve rare circumstances and "corner cases" that we are documenting here for completeness." -Sun/Oracle
http://java.sun.com/j2se/1.5.0/compatibility.html#incompatibilities
此外,根据谁编写了您的 1.4 类,他们可能对特定的 VM/gc 实现有深入的了解并为此进行了优化。不太可能,但谁知道呢。
了解某项性能的最佳方式是运行和配置文件。 “测量,不要猜测。”
关于Java 1.4 类在 1.5 JVM 上的性能,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2601233/