--- old/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp 2018-06-20 00:51:28.520875279 -0400 +++ new/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp 2018-06-20 00:51:27.008788222 -0400 @@ -388,6 +388,40 @@ } } +// NestHost_attribute { +// u2 attribute_name_index; +// u4 attribute_length; +// u2 host_class_index; +// } +void JvmtiClassFileReconstituter::write_nest_host_attribute() { + int length = sizeof(u2); + int host_class_index = ik()->nest_host_index(); + + write_attribute_name_index("NestHost"); + write_u4(length); + write_u2(host_class_index); +} + +// NestMembers_attribute { +// u2 attribute_name_index; +// u4 attribute_length; +// u2 number_of_classes; +// u2 classes[number_of_classes]; +// } +void JvmtiClassFileReconstituter::write_nest_members_attribute() { + Array* nest_members = ik()->nest_members(); + int number_of_classes = nest_members->length(); + int length = sizeof(u2) * (1 + number_of_classes); + + write_attribute_name_index("NestMembers"); + write_u4(length); + write_u2(number_of_classes); + for (int i = 0; i < number_of_classes; i++) { + u2 class_cp_index = nest_members->at(i); + write_u2(class_cp_index); + } +} + // Write InnerClasses attribute // JVMSpec| InnerClasses_attribute { @@ -658,6 +692,12 @@ if (cpool()->operands() != NULL) { ++attr_count; } + if (ik()->nest_host_index() != 0) { + ++attr_count; + } + if (ik()->nest_members() != Universe::the_empty_short_array()) { + ++attr_count; + } write_u2(attr_count); @@ -682,6 +722,12 @@ if (cpool()->operands() != NULL) { write_bootstrapmethod_attribute(); } + if (ik()->nest_host_index() != 0) { + write_nest_host_attribute(); + } + if (ik()->nest_members() != Universe::the_empty_short_array()) { + write_nest_members_attribute(); + } } // Write the method information portion of ClassFile structure