1 Reply Latest reply: Jan 30, 2014 2:31 PM by jschellSomeoneStoleMyAlias RSS

About the "Code" Attributes in class file format

1c0a20ed-689d-4cd7-ae54-5434cafeb68e Newbie
Currently Being Moderated

Hi all,

I have a doubt with "Code" Attributes in class file format, for example:

The Code attribute's structure is: http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.3

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];
}

But, When I analysis a method's Code attribute, Under normal circumstances´╝îattribute_name_index and attribute_length will take up 6 bytes, but in my sample I found they always take up 4 bytes, I guess the attribute_name_index is ignored, because of it has a fixed value "Code", You can verify through a any default <init> method_info,  can anyone give me an detail explaination, my email is lh576240289@gmail.com.

 

Thanks & Regards

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points