使用“-target 1.5”生成的 Java 类文件的性能影响 在 1.6 虚拟机上运行?
几个月前将我的整个设置从 Java 1.5 迁移到 1.6(J2EE、Tomcat)后,我刚刚意识到 Maven 仍然配置为通过 Sun 的 javac 参数“-target 1.5”生成针对 1.5 的类文件。 将“-target 1.5”更改为“-target 1.6”时,我可以期待性能提升吗?
After migrating my whole setup from Java 1.5 to 1.6 (J2EE, Tomcat) a couple of months ago, I just realized that Maven is still configured to generate class files targeted for 1.5 via Sun's javac parameter "-target 1.5". Can I expect any performance boosts when changing "-target 1.5" to "-target 1.6"?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
应该没有太大区别。 1.6 文件可以具有堆栈映射/表结构,以提高字节码验证速度(Apache Harmony 只是使用更智能的算法)。
如果您要使用 1.4,类常量的初始加载会稍微慢一些,但考虑到类的加载时间,这无关紧要(一种新形式的
ldc
字节码取代了Class .forName
,但结果存储在静态字段中。)一般来说,这并不重要。 运行时编译器是重要的部分,它几乎可以生成相同的机器代码。 过去,已经对 javac 进行了减少优化,以免破坏运行时编译器的代码,但这与
-target
标志无关。It shouldn't make much difference. 1.6 files can have stack map/table structures that improve bytecode verification speed (Apache Harmony just uses a smarter algorithm).
If you were to go to 1.4 the initial loading of a class constant would be slightly slower, but that's irrelevant given how long a class takes to load (a new form of the
ldc
bytecode replacesClass.forName
, but the result was stored in a static field.)In general it doesn't matter. The runtime compiler is the important bit and that can pretty much generate the same machine code. In the past there have been made to javac to reduce the optimisation it does so as not to mangle the code for the runtime compiler, but that is independent of the
-target
flag.Java 1.6 使用不同的类文件格式,简化了字节码的过程-确认。 因此,如果您使用新的类文件格式,启动时间应该会有所改善。
Java 1.6 uses a different class-file-format, that simplifies the process of the bytecode-verification. So startup-times should improve a little, if you use the new class-file-format.
我不明白为什么会有性能差异。 1.5 和 1.6 的课程格式没有重大区别。 如果没有其他变化,指定目标将更改生成的类中的类版本 ID。
I don't see why there'd be a performance difference. There's no major differences between the class format of 1.5 and 1.6. If nothing else changes specifying the target will change the classversion id in the generated classes.