设为首页 加入收藏

TOP

Javaclass文件结构(2)
2014-11-23 22:16:42 】 浏览:470
Tags:Javaclass 文件 结构

  现在已经预定义的属性有:


  1. SourceFile : attribute_info被替代为:


  SourceFile_attribute {


  u2 attribute_name_index;


  u4 attribute_length;


  u2 sourcefile_index; //指向constant_pool中的一个CONSTANT_Utf8_info 结构。


  }


  2. ConstantValue : attribute_info被替代为:


  ConstantValue_attribute {


  u2 attribute_name_index;


  u4 attribute_length; //必须为2


  u2 constantvalue_index;


  }


  对于constantvalue_index意义如下:


  long CONSTANT_Long


  float CONSTANT_Float


  double CONSTANT_Double


  int, short, char, byte, boolean CONSTANT_Integer


  String CONSTANT_String


  ConstantValue用于field_info 中,用于描述一个static常量,


  且此时field_info的access_flags应为ACC_STATIC


  3. Code : attribute_info被替代为:


  Code_attribute {


  u2 attribute_name_index;


  u4 attribute_length;


  u2 max_stack; //执行此函数时可用的栈的最大深度


  u2 max_locals; //执行此函数可用到的最大本地变量数目,包括参数。


  // 注意:一个long/double相当于2个变量数目.


  u4 code_length; //本函数用到的代码长度。


  u1 code[code_length]; //实现本函数的真正字节码


  u2 exception_table_length;


  { u2 start_pc;


  u2 end_pc; //捕获违例时执行代码数组中的[start_pc, end_pc)部分


  u2 handler_pc; //现在还不大明白他是干嘛的!!


  u2 catch_type; //指向constant_pool的索引,对应CONSTANT_Class_info


  }exception_table[exception_table_length];


  u2 attributes_count;


  attribute_info attributes[attributes_count];


  }


  CONSTANT_Class_info {


  u1 tag; //必须为CONSTANT_Class (7)


  u2 name_index; //不用我再说了吧


  }


  Code属性用于method_info结构中。


  4. Exceptions : attribute_info被替代为:


  Exceptions_attribute {


  u2 attribute_name_index;


  u4 attribute_length;


  u2 number_of_exceptions;


  u2 exception_index_table[number_of_exceptions];


  }


  5. InnerClasses : attribute_info被替代为:


  InnerClasses_attribute {


  u2 attribute_name_index;


  u4 attribute_length;


  u2 number_of_classes;


  { u2 inner_class_info_index;


  u2 outer_class_info_index;


  u2 inner_name_index;


  u2 inner_class_access_flags;


  } classes[number_of_classes];


  }


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Javaclass文件结构(1) 下一篇Java访问windows活动目录(1)

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目