微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

我们注意到,当我们在 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.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐