Java编译错误:代码太大 [英] Java compile error: code too large

查看:91
本文介绍了Java编译错误:代码太大的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我们正在开发一个注册系统,现在由于编译期间的内存错误而陷入困境。



我们在网上进行了研究,发现错误消息的原因是.java文件的大小。现在,我们的EnrollmentSystem类具有10171行代码。



我们使用Netbeans的GUI生成器对其进行了设计。我们曾考虑创建一个单独的类来包含其他面板,但是我们不知道如何从另一个类中获取组件并将其添加到原始类(包含10171行的类)中,然后在同一选项卡上显示其内容。 / p>





*我们需要完成的是,当用户单击特定的选项卡式窗格时,它会显示另一个类的面板。



我知道这与
object.add()
实例化



我们尝试过getComponent(nth );但是真的不知道如何管理类以及如何添加来自不同类的组件。

解决方案

有64K字节码大小 Java 由于执行了异常处理:


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


对于Java 7 8



您必须将违反此约束的任何方法一分为二。使用GUI Builder可能有或没有办法做到这一点。如果您手动构建界面,肯定会拥有此选项。


So we're working on an Enrollment System and now we're stuck because of memory error during compile.

We researched online and found that the reason is for the error message is the size of the .java file. Our EnrollmentSystem class now has 10171 lines of code.

We designed it using the GUI builder of Netbeans. We thought of creating a separate class to contain other panels but we don't know how to get the components from another class and add it to the original class(the one that contains 10171 lines) then show it's contents on the same tab.

*What we need to accomplish is that when user clicks on a specific tabbed pane, it shows the panels from another class.

I know it has something to do with object.add() instantiation

We tried getComponent(nth); but really don't know how to manage classes and add components from different classes.

解决方案

There is a 64K byte-code size limit on a method in Java due to the exception handling implementation:

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.

This is true for Java 7 and 8.

You will have to split whatever method violates this constraint in two. There might or might not be a way to do this using the GUI Builder; you'll definitely have this option if you build your interface manually.

这篇关于Java编译错误:代码太大的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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