JVM初学二
Class文件的结构其实也很简单,主要可通过下面的数据结构表示
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]; }
Object method(int i,double d,Thread t)
(IDLjava/lang/Thread;)LJava/Object
CONSTANT_NameAndType_info { u1 tag; u2 name_index; u2 descriptor_index; }
attribute_info { u2 attribute_name_index; u4 attribute_length; u1 info[attribute_length]; }
Code_attribute { u2 attribute_name_index; u4 attribute_length; u2 max_stack; u2 max_locals; 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]; }