< prev index next >

src/hotspot/share/prims/jvmtiClassFileReconstituter.cpp

Print this page
rev 50604 : imported patch jep181-rev1

@@ -386,10 +386,44 @@
       write_u2(bootstrap_argument);
     }
   }
 }
 
+//  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 {
 // JVMSpec|     u2 attribute_name_index;
 // JVMSpec|     u4 attribute_length;

@@ -656,10 +690,16 @@
     ++attr_count;     // has RuntimeVisibleTypeAnnotations attribute
   }
   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);
 
   if (generic_signature != NULL) {
     write_signature_attribute(symbol_to_cpool_index(generic_signature));

@@ -680,10 +720,16 @@
     write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno);
   }
   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
 // JVMSpec|     u2 methods_count;
 // JVMSpec|     method_info methods[methods_count];
< prev index next >