我一直在研究java类文件格式。我一直在专门研究从字节码创建类。我已经能够从 oracle 文档和其他 Google 搜索中找到我需要的大部分信息。但是我无法找出构造函数在类文件中的存储方式和位置。我认为它们可能存储在方法表中,但我不确定,如果是的话,我想要一个关于它们如何存储的规范。
最佳答案
来自JVM specification, section 2.9 :
At the level of the Java Virtual Machine, every constructor written in the Java programming language (JLS §8.8) appears as an instance initialization method that has the special name
<init>
. This name is supplied by a compiler. Because the name<init>
is not a valid identifier, it cannot be used directly in a program written in the Java programming language.
另外:
A class or interface has at most one class or interface initialization method and is initialized (§5.5) by invoking that method. The initialization method of a class or interface has the special name
<clinit>
, takes no arguments, and is void (§4.3.3).
关于java - 类文件格式的构造函数存储在哪里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16846093/