java - 类文件格式的构造函数存储在哪里

标签 java bytecode .class-file

我一直在研究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/

相关文章:

java - 如何在 Java 中将数据存储区实体转换为 BigQuery TableRow 对象?

java - 向 smali 源添加代码

assembly - CIL nop 操作码的用途是什么?

Java 从 For 循环初始化 ArrayList

java - 创建请求并根据两个变量委托(delegate)它的最优雅的方式

Java .class 文件结构 - InnerClasses 属性

java - 类(class)不变

java - 如何分析Java类文件?

基于Set类型的Java流过滤器

java - 使用中间变量而不是 array.length 会使你的 for 循环更快吗?