src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp
changeset 50735 2f2af62dfac7
parent 49480 d7df2dd501ce
child 51329 9c68699bebe5
--- a/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp	Fri Jun 22 17:49:21 2018 -0700
+++ b/src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp	Sat Jun 23 01:32:41 2018 -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<u2>* 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