Mon, 06 May 2013 19:49:18 +0200
8009615: JvmtiClassFileReconstituter does not create BootstrapMethod attributes
Reviewed-by: coleenp, sspitsyn
src/share/vm/prims/jvmtiClassFileReconstituter.cpp | file | annotate | diff | comparison | revisions | |
src/share/vm/prims/jvmtiClassFileReconstituter.hpp | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/prims/jvmtiClassFileReconstituter.cpp Mon May 06 09:10:21 2013 -0400 1.2 +++ b/src/share/vm/prims/jvmtiClassFileReconstituter.cpp Mon May 06 19:49:18 2013 +0200 1.3 @@ -341,6 +341,44 @@ 1.4 memcpy(writeable_address(length), annos->adr_at(0), length); 1.5 } 1.6 1.7 +// BootstrapMethods_attribute { 1.8 +// u2 attribute_name_index; 1.9 +// u4 attribute_length; 1.10 +// u2 num_bootstrap_methods; 1.11 +// { u2 bootstrap_method_ref; 1.12 +// u2 num_bootstrap_arguments; 1.13 +// u2 bootstrap_arguments[num_bootstrap_arguments]; 1.14 +// } bootstrap_methods[num_bootstrap_methods]; 1.15 +// } 1.16 +void JvmtiClassFileReconstituter::write_boostrapmethod_attribute() { 1.17 + Array<u2>* operands = cpool()->operands(); 1.18 + write_attribute_name_index("BootstrapMethods"); 1.19 + int num_bootstrap_methods = ConstantPool::operand_array_length(operands); 1.20 + 1.21 + // calculate length of attribute 1.22 + int length = sizeof(u2); // num_boostrap_methods 1.23 + for (int n = 0; n < num_bootstrap_methods; n++) { 1.24 + u2 num_bootstrap_arguments = cpool()->operand_argument_count_at(n); 1.25 + length += sizeof(u2); // bootstrap_method_ref 1.26 + length += sizeof(u2); // num_bootstrap_arguments 1.27 + length += sizeof(u2) * num_bootstrap_arguments; // bootstrap_arguments[num_bootstrap_arguments] 1.28 + } 1.29 + write_u4(length); 1.30 + 1.31 + // write attribute 1.32 + write_u2(num_bootstrap_methods); 1.33 + for (int n = 0; n < num_bootstrap_methods; n++) { 1.34 + u2 bootstrap_method_ref = cpool()->operand_bootstrap_method_ref_index_at(n); 1.35 + u2 num_bootstrap_arguments = cpool()->operand_argument_count_at(n); 1.36 + write_u2(bootstrap_method_ref); 1.37 + write_u2(num_bootstrap_arguments); 1.38 + for (int arg = 0; arg < num_bootstrap_arguments; arg++) { 1.39 + u2 bootstrap_argument = cpool()->operand_argument_index_at(n, arg); 1.40 + write_u2(bootstrap_argument); 1.41 + } 1.42 + } 1.43 +} 1.44 + 1.45 1.46 // Write InnerClasses attribute 1.47 // JVMSpec| InnerClasses_attribute { 1.48 @@ -597,6 +635,9 @@ 1.49 if (anno != NULL) { 1.50 ++attr_count; // has RuntimeVisibleAnnotations attribute 1.51 } 1.52 + if (cpool()->operands() != NULL) { 1.53 + ++attr_count; 1.54 + } 1.55 1.56 write_u2(attr_count); 1.57 1.58 @@ -615,6 +656,9 @@ 1.59 if (anno != NULL) { 1.60 write_annotations_attribute("RuntimeVisibleAnnotations", anno); 1.61 } 1.62 + if (cpool()->operands() != NULL) { 1.63 + write_boostrapmethod_attribute(); 1.64 + } 1.65 } 1.66 1.67 // Write the method information portion of ClassFile structure
2.1 --- a/src/share/vm/prims/jvmtiClassFileReconstituter.hpp Mon May 06 09:10:21 2013 -0400 2.2 +++ b/src/share/vm/prims/jvmtiClassFileReconstituter.hpp Mon May 06 19:49:18 2013 +0200 2.3 @@ -127,6 +127,7 @@ 2.4 void write_signature_attribute(u2 generic_signaure_index); 2.5 void write_attribute_name_index(const char* name); 2.6 void write_annotations_attribute(const char* attr_name, AnnotationArray* annos); 2.7 + void write_boostrapmethod_attribute(); 2.8 2.9 address writeable_address(size_t size); 2.10 void write_u1(u1 x);