comparison src/share/vm/prims/jvmtiClassFileReconstituter.cpp @ 10408:836a62f43af9

Merge with http://hg.openjdk.java.net/hsx/hsx25/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Wed, 19 Jun 2013 10:45:56 +0200
parents b5fef8013a95
children de6a9e811145
comparison
equal deleted inserted replaced
10086:e0fb8a213650 10408:836a62f43af9
339 write_attribute_name_index(attr_name); 339 write_attribute_name_index(attr_name);
340 write_u4(length); 340 write_u4(length);
341 memcpy(writeable_address(length), annos->adr_at(0), length); 341 memcpy(writeable_address(length), annos->adr_at(0), length);
342 } 342 }
343 343
344 // BootstrapMethods_attribute {
345 // u2 attribute_name_index;
346 // u4 attribute_length;
347 // u2 num_bootstrap_methods;
348 // { u2 bootstrap_method_ref;
349 // u2 num_bootstrap_arguments;
350 // u2 bootstrap_arguments[num_bootstrap_arguments];
351 // } bootstrap_methods[num_bootstrap_methods];
352 // }
353 void JvmtiClassFileReconstituter::write_bootstrapmethod_attribute() {
354 Array<u2>* operands = cpool()->operands();
355 write_attribute_name_index("BootstrapMethods");
356 int num_bootstrap_methods = ConstantPool::operand_array_length(operands);
357
358 // calculate length of attribute
359 int length = sizeof(u2); // num_bootstrap_methods
360 for (int n = 0; n < num_bootstrap_methods; n++) {
361 u2 num_bootstrap_arguments = cpool()->operand_argument_count_at(n);
362 length += sizeof(u2); // bootstrap_method_ref
363 length += sizeof(u2); // num_bootstrap_arguments
364 length += sizeof(u2) * num_bootstrap_arguments; // bootstrap_arguments[num_bootstrap_arguments]
365 }
366 write_u4(length);
367
368 // write attribute
369 write_u2(num_bootstrap_methods);
370 for (int n = 0; n < num_bootstrap_methods; n++) {
371 u2 bootstrap_method_ref = cpool()->operand_bootstrap_method_ref_index_at(n);
372 u2 num_bootstrap_arguments = cpool()->operand_argument_count_at(n);
373 write_u2(bootstrap_method_ref);
374 write_u2(num_bootstrap_arguments);
375 for (int arg = 0; arg < num_bootstrap_arguments; arg++) {
376 u2 bootstrap_argument = cpool()->operand_argument_index_at(n, arg);
377 write_u2(bootstrap_argument);
378 }
379 }
380 }
381
344 382
345 // Write InnerClasses attribute 383 // Write InnerClasses attribute
346 // JVMSpec| InnerClasses_attribute { 384 // JVMSpec| InnerClasses_attribute {
347 // JVMSpec| u2 attribute_name_index; 385 // JVMSpec| u2 attribute_name_index;
348 // JVMSpec| u4 attribute_length; 386 // JVMSpec| u4 attribute_length;
511 u2 generic_signature_index = const_method->generic_signature_index(); 549 u2 generic_signature_index = const_method->generic_signature_index();
512 AnnotationArray* anno = method->annotations(); 550 AnnotationArray* anno = method->annotations();
513 AnnotationArray* param_anno = method->parameter_annotations(); 551 AnnotationArray* param_anno = method->parameter_annotations();
514 AnnotationArray* default_anno = method->annotation_default(); 552 AnnotationArray* default_anno = method->annotation_default();
515 553
554 // skip generated default interface methods
555 if (method->is_overpass()) {
556 return;
557 }
558
516 write_u2(access_flags.get_flags() & JVM_RECOGNIZED_METHOD_MODIFIERS); 559 write_u2(access_flags.get_flags() & JVM_RECOGNIZED_METHOD_MODIFIERS);
517 write_u2(const_method->name_index()); 560 write_u2(const_method->name_index());
518 write_u2(const_method->signature_index()); 561 write_u2(const_method->signature_index());
519 562
520 // write attributes in the same order javac does, so we can test with byte for 563 // write attributes in the same order javac does, so we can test with byte for
590 ++attr_count; 633 ++attr_count;
591 } 634 }
592 if (anno != NULL) { 635 if (anno != NULL) {
593 ++attr_count; // has RuntimeVisibleAnnotations attribute 636 ++attr_count; // has RuntimeVisibleAnnotations attribute
594 } 637 }
638 if (cpool()->operands() != NULL) {
639 ++attr_count;
640 }
595 641
596 write_u2(attr_count); 642 write_u2(attr_count);
597 643
598 if (generic_signature != NULL) { 644 if (generic_signature != NULL) {
599 write_signature_attribute(symbol_to_cpool_index(generic_signature)); 645 write_signature_attribute(symbol_to_cpool_index(generic_signature));
607 if (inner_classes_length > 0) { 653 if (inner_classes_length > 0) {
608 write_inner_classes_attribute(inner_classes_length); 654 write_inner_classes_attribute(inner_classes_length);
609 } 655 }
610 if (anno != NULL) { 656 if (anno != NULL) {
611 write_annotations_attribute("RuntimeVisibleAnnotations", anno); 657 write_annotations_attribute("RuntimeVisibleAnnotations", anno);
658 }
659 if (cpool()->operands() != NULL) {
660 write_bootstrapmethod_attribute();
612 } 661 }
613 } 662 }
614 663
615 // Write the method information portion of ClassFile structure 664 // Write the method information portion of ClassFile structure
616 // JVMSpec| u2 methods_count; 665 // JVMSpec| u2 methods_count;
617 // JVMSpec| method_info methods[methods_count]; 666 // JVMSpec| method_info methods[methods_count];
618 void JvmtiClassFileReconstituter::write_method_infos() { 667 void JvmtiClassFileReconstituter::write_method_infos() {
619 HandleMark hm(thread()); 668 HandleMark hm(thread());
620 Array<Method*>* methods = ikh()->methods(); 669 Array<Method*>* methods = ikh()->methods();
621 int num_methods = methods->length(); 670 int num_methods = methods->length();
622 671 int num_overpass = 0;
623 write_u2(num_methods); 672
673 // count the generated default interface methods
674 // these will not be re-created by write_method_info
675 // and should not be included in the total count
676 for (int index = 0; index < num_methods; index++) {
677 Method* method = methods->at(index);
678 if (method->is_overpass()) {
679 num_overpass++;
680 }
681 }
682
683 write_u2(num_methods - num_overpass);
624 if (JvmtiExport::can_maintain_original_method_order()) { 684 if (JvmtiExport::can_maintain_original_method_order()) {
625 int index; 685 int index;
626 int original_index; 686 int original_index;
627 intArray method_order(num_methods, 0); 687 intArray method_order(num_methods, 0);
628 688