5、Java仮想マシン実行サブシステム

クラスファイル構造

クラスファイルは、C言語の構造で表されます。

ClassFile {
    u4 magic; // 魔数
    u2 minor_version; // 次版本号
    u2 major_version; // 主版本号
    u2 constant_pool_count; // 常量池大小
    cp_info constant_pool[constant_pool_count-1]; // 常量池主要存放两大类常量:字面量(Literal)和符号引用(Symbolic References)
    u2 access_flags; // 访问标志,这个标志用于识别一些类或者接口层次的访问信息
    u2 this_class;  // 类索引
    u2 super_class;  // 父类索引
    u2 interfaces_count;  // 接口计数器,标识索引表的容量
    u2 interfaces[interfaces_count];  // 接口索引集合
    u2 fields_count;  // 字段表容量
    field_info fields[fields_count];  // 字段表集合
    u2 methods_count;  // 方法表容量
    method_info methods[methods_count];  // 方法表集合
    u2 attributes_count;  // 属性表容量
    attribute_info attributes[attributes_count];  // 属性表集合
}

2.バイトコード命令の概要

同期命令

Java仮想マシンは、メソッドレベルの同期とメソッド内の一連の命令の同期をサポートできます。これらの同期構造は両方とも、モニター(より一般的には「ロック」と呼ばれます)を使用して実装されます。同期はJavaで使用され、同期を実現します。Java仮想マシンには、monitorenterとmonitorexitの命令セットに2つの命令があり、synchronizedキーワードのセマンティクスをサポートします。synchronizedキーワードを正しく実装するには、Javacコンパイラとの協力とサポートが必要です。 Java仮想マシン。

 

 

参照:<Java仮想マシンの詳細な理解:JVMの高度な機能とベストプラクティス第3版>

おすすめ

転載: blog.csdn.net/qq_32323239/article/details/105913337