Java 7和8中方法的最大大小 [英] Maximum size of a method in Java 7 and 8

查看:135
本文介绍了Java 7和8中方法的最大大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道一个方法不能大于64 KB的Java。该限制导致我们使用 JavaCC 语法生成的代码出现问题。我们遇到了Java 6的问题,并且能够通过更改语法来解决这个问题。是否已针对Java 7更改了限制,还是计划用于Java 8?

I know that a method cannot be larger than 64 KB with Java. The limitation causes us problems with generated code from a JavaCC grammar. We had problems with Java 6 and were able to fix this by changing the grammar. Has the limit been changed for Java 7 or is it planned for Java 8?

只是为了清楚说明。我自己不需要大于64 KB的方法。但我写了一个语法,编译成一个非常大的方法。

Just to make it clear. I don't need a method larger than 64 KB by myself. But I wrote a grammar which compiles to a very large method.

推荐答案

根据 JVMS7


end_pc是独占的这一事实是Java虚拟机的
设计中的历史错误:如果方法的Java虚拟机代码
正好是65535如果字节长,并以一个1字节长的指令
结束,则该指令不能受
异常处理程序的保护。编译器编写者可以通过
来解决这个错误,限制生成的Java虚拟机代码的最大大小
,用于任何方法,实例初始化方法或静态初始化程序
(任何代码数组的大小) )到65534字节。

The fact that end_pc is exclusive is a historical mistake in the design of the Java virtual machine: if the Java virtual machine code for a method is exactly 65535 bytes long and ends with an instruction that is 1 byte long, then that instruction cannot be protected by an exception handler. A compiler writer can work around this bug by limiting the maximum size of the generated Java virtual machine code for any method, instance initialization method, or static initializer (the size of any code array) to 65534 bytes.

但这是关于 Java 7 Java 8没有最终规范,所以没有人(除了它的开发者)可以回答这个问题。

UPD(2015- 04-06)根据 JVM8 对于 Java 8 也是如此。

这篇关于Java 7和8中方法的最大大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆