src/share/vm/prims/jvmtiClassFileReconstituter.cpp

Print this page




 311   memcpy(writeable_address(length), annos->byte_at_addr(0), length);
 312 }
 313 
 314 
 315 // Write InnerClasses attribute
 316 // JVMSpec|   InnerClasses_attribute {
 317 // JVMSpec|     u2 attribute_name_index;
 318 // JVMSpec|     u4 attribute_length;
 319 // JVMSpec|     u2 number_of_classes;
 320 // JVMSpec|     {  u2 inner_class_info_index;
 321 // JVMSpec|        u2 outer_class_info_index;
 322 // JVMSpec|        u2 inner_name_index;
 323 // JVMSpec|        u2 inner_class_access_flags;
 324 // JVMSpec|     } classes[number_of_classes];
 325 // JVMSpec|   }
 326 void JvmtiClassFileReconstituter::write_inner_classes_attribute(int length) {
 327   typeArrayOop inner_class_list = ikh()->inner_classes();
 328   guarantee(inner_class_list != NULL && inner_class_list->length() == length,
 329             "caller must check");
 330   typeArrayHandle inner_class_list_h(thread(), inner_class_list);
 331   assert (length % instanceKlass::inner_class_next_offset == 0, "just checking");


 332   u2 entry_count = length / instanceKlass::inner_class_next_offset;
 333   u4 size = 2 + entry_count * (2+2+2+2);
 334 
 335   write_attribute_name_index("InnerClasses");
 336   write_u4(size);
 337   write_u2(entry_count);
 338   for (int i = 0; i < length; i += instanceKlass::inner_class_next_offset) {



 339     write_u2(inner_class_list_h->ushort_at(
 340                       i + instanceKlass::inner_class_inner_class_info_offset));
 341     write_u2(inner_class_list_h->ushort_at(
 342                       i + instanceKlass::inner_class_outer_class_info_offset));
 343     write_u2(inner_class_list_h->ushort_at(
 344                       i + instanceKlass::inner_class_inner_name_offset));
 345     write_u2(inner_class_list_h->ushort_at(
 346                       i + instanceKlass::inner_class_access_flags_offset));
 347   }
 348 }
 349 
 350 // Write Synthetic attribute
 351 // JVMSpec|   Synthetic_attribute {
 352 // JVMSpec|     u2 attribute_name_index;
 353 // JVMSpec|     u4 attribute_length;
 354 // JVMSpec|   }
 355 void JvmtiClassFileReconstituter::write_synthetic_attribute() {
 356   write_attribute_name_index("Synthetic");
 357   write_u4(0); //length always zero
 358 }




 311   memcpy(writeable_address(length), annos->byte_at_addr(0), length);
 312 }
 313 
 314 
 315 // Write InnerClasses attribute
 316 // JVMSpec|   InnerClasses_attribute {
 317 // JVMSpec|     u2 attribute_name_index;
 318 // JVMSpec|     u4 attribute_length;
 319 // JVMSpec|     u2 number_of_classes;
 320 // JVMSpec|     {  u2 inner_class_info_index;
 321 // JVMSpec|        u2 outer_class_info_index;
 322 // JVMSpec|        u2 inner_name_index;
 323 // JVMSpec|        u2 inner_class_access_flags;
 324 // JVMSpec|     } classes[number_of_classes];
 325 // JVMSpec|   }
 326 void JvmtiClassFileReconstituter::write_inner_classes_attribute(int length) {
 327   typeArrayOop inner_class_list = ikh()->inner_classes();
 328   guarantee(inner_class_list != NULL && inner_class_list->length() == length,
 329             "caller must check");
 330   typeArrayHandle inner_class_list_h(thread(), inner_class_list);
 331   assert ((length % instanceKlass::inner_class_next_offset == 0 ||
 332            length % instanceKlass::inner_class_next_offset == instanceKlass::enclosing_method_attribute_size),
 333            "just checking");
 334   u2 entry_count = length / instanceKlass::inner_class_next_offset;
 335   u4 size = 2 + entry_count * (2+2+2+2);
 336 
 337   write_attribute_name_index("InnerClasses");
 338   write_u4(size);
 339   write_u2(entry_count);
 340   for (int i = 0; i < length; i += instanceKlass::inner_class_next_offset) {
 341     if (i == length - instanceKlass::enclosing_method_attribute_size) {
 342       break;
 343     }
 344     write_u2(inner_class_list_h->ushort_at(
 345                       i + instanceKlass::inner_class_inner_class_info_offset));
 346     write_u2(inner_class_list_h->ushort_at(
 347                       i + instanceKlass::inner_class_outer_class_info_offset));
 348     write_u2(inner_class_list_h->ushort_at(
 349                       i + instanceKlass::inner_class_inner_name_offset));
 350     write_u2(inner_class_list_h->ushort_at(
 351                       i + instanceKlass::inner_class_access_flags_offset));
 352   }
 353 }
 354 
 355 // Write Synthetic attribute
 356 // JVMSpec|   Synthetic_attribute {
 357 // JVMSpec|     u2 attribute_name_index;
 358 // JVMSpec|     u4 attribute_length;
 359 // JVMSpec|   }
 360 void JvmtiClassFileReconstituter::write_synthetic_attribute() {
 361   write_attribute_name_index("Synthetic");
 362   write_u4(0); //length always zero
 363 }