我正在考虑构建一个非常大的 Java 类,Java 类可以拥有的方法数量是否有限制?能进数百万个方法吗?
更新: 是的,目的是制作一个“上帝”类。
最佳答案
根据Java class file specification限制为 65535:
4.10 Limitations of the Java Virtual Machine
The following limitations of the Java virtual machine are implicit in the
class
file format:
- The number of methods that may be declared by a class or interface is limited to 65535 by the size of the
methods_count
item of theClassFile
structure (§4.1). Note that the value of themethods_count
item of theClassFile
structure does not include methods that are inherited from superclasses or superinterfaces.
关于java - Java 类可以拥有的最大方法数是多少?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4342072/