加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

为什么Java 6编译的类大小大于Java 5?

发布时间:2020-12-14 16:33:11 所属栏目:Java 来源:网络整理
导读:我们注意到,当我们在 Java 6上编译我们的类时,它们始终大于Java 5. 我明白到目前为止,字节码没有改变,所以我认为Java 6编译器正在投入更多的东西.这是否需要,还是有什么办法把它关闭,仍然编译Java 6源代码? 解决方法 版本6 javac正在类文件中生成额外的“St
我们注意到,当我们在 Java 6上编译我们的类时,它们始终大于Java 5.

我明白到目前为止,字节码没有改变,所以我认为Java 6编译器正在投入更多的东西.这是否需要,还是有什么办法把它关闭,仍然编译Java 6源代码?

解决方法

版本6 javac正在类文件中生成额外的“Stack Map”属性,以使jvm的验证更容易,更快.我怀疑这个数量太大了,你可以通过使用-target 1.5选项来生成与之前版本相同的字节码.

编辑:有关此新属性的详细信息,请参见jsr 202的4.8.4节

4.8.4 The StackMapTable Attribute

The stack map attribute is a variable-length attribute in the attributes table of a Code
attribute. The name of the attribute is StackMapTable. This attribute is used during
the process of verification by typechecking (§4.11.1).

A stack map attribute consists of zero or more stack map frames. Each stack map frame specifies (either explicitly or implicitly) a bytecode offset,the verification types (§4.11.1) for the local variables,and the verification types for the operand stack.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读