Wed, 21 Dec 2011 18:22:14 -0800
Merge
1.1 --- a/src/share/vm/prims/jvmtiClassFileReconstituter.cpp Wed Dec 21 15:48:16 2011 -0500 1.2 +++ b/src/share/vm/prims/jvmtiClassFileReconstituter.cpp Wed Dec 21 18:22:14 2011 -0800 1.3 @@ -43,7 +43,7 @@ 1.4 #ifdef TARGET_ARCH_ppc 1.5 # include "bytes_ppc.hpp" 1.6 #endif 1.7 -// FIXME: add Deprecated, LVT, LVTT attributes 1.8 +// FIXME: add Deprecated, LVTT attributes 1.9 // FIXME: fix Synthetic attribute 1.10 // FIXME: per Serguei, add error return handling for constantPoolOopDesc::copy_cpool_bytes() 1.11 1.12 @@ -136,8 +136,9 @@ 1.13 constMethodHandle const_method(thread(), method->constMethod()); 1.14 u2 line_num_cnt = 0; 1.15 int stackmap_len = 0; 1.16 + int local_variable_table_length = 0; 1.17 1.18 - // compute number and length of attributes -- FIXME: for now no LVT 1.19 + // compute number and length of attributes 1.20 int attr_count = 0; 1.21 int attr_size = 0; 1.22 if (const_method->has_linenumber_table()) { 1.23 @@ -170,6 +171,25 @@ 1.24 attr_size += 2 + 4 + stackmap_len; 1.25 } 1.26 } 1.27 + if (method->has_localvariable_table()) { 1.28 + local_variable_table_length = method->localvariable_table_length(); 1.29 + ++attr_count; 1.30 + if (local_variable_table_length != 0) { 1.31 + // Compute the size of the local variable table attribute (VM stores raw): 1.32 + // LocalVariableTable_attribute { 1.33 + // u2 attribute_name_index; 1.34 + // u4 attribute_length; 1.35 + // u2 local_variable_table_length; 1.36 + // { 1.37 + // u2 start_pc; 1.38 + // u2 length; 1.39 + // u2 name_index; 1.40 + // u2 descriptor_index; 1.41 + // u2 index; 1.42 + // } 1.43 + attr_size += 2 + 4 + 2 + local_variable_table_length * (2 + 2 + 2 + 2 + 2); 1.44 + } 1.45 + } 1.46 1.47 typeArrayHandle exception_table(thread(), const_method->exception_table()); 1.48 int exception_table_length = exception_table->length(); 1.49 @@ -203,8 +223,9 @@ 1.50 if (stackmap_len != 0) { 1.51 write_stackmap_table_attribute(method, stackmap_len); 1.52 } 1.53 - 1.54 - // FIXME: write LVT attribute 1.55 + if (local_variable_table_length != 0) { 1.56 + write_local_variable_table_attribute(method, local_variable_table_length); 1.57 + } 1.58 } 1.59 1.60 // Write Exceptions attribute 1.61 @@ -371,6 +392,36 @@ 1.62 } 1.63 } 1.64 1.65 +// Write LineNumberTable attribute 1.66 +// JVMSpec| LocalVariableTable_attribute { 1.67 +// JVMSpec| u2 attribute_name_index; 1.68 +// JVMSpec| u4 attribute_length; 1.69 +// JVMSpec| u2 local_variable_table_length; 1.70 +// JVMSpec| { u2 start_pc; 1.71 +// JVMSpec| u2 length; 1.72 +// JVMSpec| u2 name_index; 1.73 +// JVMSpec| u2 descriptor_index; 1.74 +// JVMSpec| u2 index; 1.75 +// JVMSpec| } local_variable_table[local_variable_table_length]; 1.76 +// JVMSpec| } 1.77 +void JvmtiClassFileReconstituter::write_local_variable_table_attribute(methodHandle method, u2 num_entries) { 1.78 + write_attribute_name_index("LocalVariableTable"); 1.79 + write_u4(2 + num_entries * (2 + 2 + 2 + 2 + 2)); 1.80 + write_u2(num_entries); 1.81 + 1.82 + assert(method->localvariable_table_length() == num_entries, "just checking"); 1.83 + 1.84 + LocalVariableTableElement *elem = method->localvariable_table_start(); 1.85 + for (int j=0; j<method->localvariable_table_length(); j++) { 1.86 + write_u2(elem->start_bci); 1.87 + write_u2(elem->length); 1.88 + write_u2(elem->name_cp_index); 1.89 + write_u2(elem->descriptor_cp_index); 1.90 + write_u2(elem->slot); 1.91 + elem++; 1.92 + } 1.93 +} 1.94 + 1.95 // Write stack map table attribute 1.96 // JSR-202| StackMapTable_attribute { 1.97 // JSR-202| u2 attribute_name_index;
2.1 --- a/src/share/vm/prims/jvmtiClassFileReconstituter.hpp Wed Dec 21 15:48:16 2011 -0500 2.2 +++ b/src/share/vm/prims/jvmtiClassFileReconstituter.hpp Wed Dec 21 18:22:14 2011 -0800 2.3 @@ -119,6 +119,7 @@ 2.4 void write_source_debug_extension_attribute(); 2.5 u2 line_number_table_entries(methodHandle method); 2.6 void write_line_number_table_attribute(methodHandle method, u2 num_entries); 2.7 + void write_local_variable_table_attribute(methodHandle method, u2 num_entries); 2.8 void write_stackmap_table_attribute(methodHandle method, int stackmap_table_len); 2.9 u2 inner_classes_attribute_length(); 2.10 void write_inner_classes_attribute(int length);