only be able to read the class file format and correctly perform the operations specified therein. The Java® Virtual Machine Specification: Chapter 2. The Structure of the Java Virtual Machine, https://docs.oracle.com/javase/specs/jvms/se13/html/jvms-2.html Java仮想マシン (JVM) を正しく実装するには、クラスファイル形式を読み 取って、そこに指定されている命令を正しく実行する必要があるだけです。
Structure, https://docs.oracle.com/javase/specs/jvms/se13/html/jvms-4.html#jvms-4.1 ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; 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]; } u4: 符号なし4バイト量 u2: 符号なし2バイト量 ① ② ③ ③ ① ④ ② ④
major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; 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]; } The Java® Virtual Machine Specification: Chapter 4.1. The ClassFile Structure, https://docs.oracle.com/javase/specs/jvms/se13/html/jvms-4.html#jvms-4.1
major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; 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]; } The Java® Virtual Machine Specification: Chapter 4.1. The ClassFile Structure, https://docs.oracle.com/javase/specs/jvms/se13/html/jvms-4.html#jvms-4.1
u4 code_length; u1 code[code_length]; u2 exception_table_length; { u2 start_pc; u2 end_pc; u2 handler_pc; u2 catch_type; } exception_table[exception_table_length]; u2 attributes_count; attribute_info attributes[attributes_count]; } method_info { u2 access_flags; u2 name_index; u2 descriptor_index; u2 attributes_count; attribute_info attributes[attributes_count]; } ClassFile { u4 magic; u2 minor_version; u2 major_version; u2 constant_pool_count; cp_info constant_pool[constant_pool_count-1]; 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]; } 命令列の実行 どこに格納されてるのか? 05 3c b2 00 07 1b b6 00 0d b1
specifying the operation to be performed, followed by zero or more operands embodying values to be operated upon. This chapter gives details about the format of each Java Virtual Machine instruction and the operation it performs. The Java® Virtual Machine Specification: Chapter 6. The Java Virtual Machine Instruction Set, https://docs.oracle.com/javase/specs/jvms/se13/html/jvms-2.html 実行する操作を指定するオペコードと 0個以上の操作対象の値を指定するオペラン ド