Mercurial > hg > truffle
comparison src/share/vm/prims/jvmtiClassFileReconstituter.cpp @ 20804:7848fc12602b
Merge with jdk8u40-b25
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Tue, 07 Apr 2015 14:58:49 +0200 |
parents | 89152779163c 50054b63f0aa |
children |
comparison
equal
deleted
inserted
replaced
20184:84105dcdb05b | 20804:7848fc12602b |
---|---|
52 // JVMSpec| u2 fields_count; | 52 // JVMSpec| u2 fields_count; |
53 // JVMSpec| field_info fields[fields_count]; | 53 // JVMSpec| field_info fields[fields_count]; |
54 void JvmtiClassFileReconstituter::write_field_infos() { | 54 void JvmtiClassFileReconstituter::write_field_infos() { |
55 HandleMark hm(thread()); | 55 HandleMark hm(thread()); |
56 Array<AnnotationArray*>* fields_anno = ikh()->fields_annotations(); | 56 Array<AnnotationArray*>* fields_anno = ikh()->fields_annotations(); |
57 Array<AnnotationArray*>* fields_type_anno = ikh()->fields_type_annotations(); | |
57 | 58 |
58 // Compute the real number of Java fields | 59 // Compute the real number of Java fields |
59 int java_fields = ikh()->java_fields_count(); | 60 int java_fields = ikh()->java_fields_count(); |
60 | 61 |
61 write_u2(java_fields); | 62 write_u2(java_fields); |
66 int initial_value_index = fs.initval_index(); | 67 int initial_value_index = fs.initval_index(); |
67 guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field"); | 68 guarantee(name_index != 0 && signature_index != 0, "bad constant pool index for field"); |
68 // int offset = ikh()->field_offset( index ); | 69 // int offset = ikh()->field_offset( index ); |
69 int generic_signature_index = fs.generic_signature_index(); | 70 int generic_signature_index = fs.generic_signature_index(); |
70 AnnotationArray* anno = fields_anno == NULL ? NULL : fields_anno->at(fs.index()); | 71 AnnotationArray* anno = fields_anno == NULL ? NULL : fields_anno->at(fs.index()); |
72 AnnotationArray* type_anno = fields_type_anno == NULL ? NULL : fields_type_anno->at(fs.index()); | |
71 | 73 |
72 // JVMSpec| field_info { | 74 // JVMSpec| field_info { |
73 // JVMSpec| u2 access_flags; | 75 // JVMSpec| u2 access_flags; |
74 // JVMSpec| u2 name_index; | 76 // JVMSpec| u2 name_index; |
75 // JVMSpec| u2 descriptor_index; | 77 // JVMSpec| u2 descriptor_index; |
91 ++attr_count; | 93 ++attr_count; |
92 } | 94 } |
93 if (anno != NULL) { | 95 if (anno != NULL) { |
94 ++attr_count; // has RuntimeVisibleAnnotations attribute | 96 ++attr_count; // has RuntimeVisibleAnnotations attribute |
95 } | 97 } |
98 if (type_anno != NULL) { | |
99 ++attr_count; // has RuntimeVisibleTypeAnnotations attribute | |
100 } | |
96 | 101 |
97 write_u2(attr_count); | 102 write_u2(attr_count); |
98 | 103 |
99 if (initial_value_index != 0) { | 104 if (initial_value_index != 0) { |
100 write_attribute_name_index("ConstantValue"); | 105 write_attribute_name_index("ConstantValue"); |
107 if (generic_signature_index != 0) { | 112 if (generic_signature_index != 0) { |
108 write_signature_attribute(generic_signature_index); | 113 write_signature_attribute(generic_signature_index); |
109 } | 114 } |
110 if (anno != NULL) { | 115 if (anno != NULL) { |
111 write_annotations_attribute("RuntimeVisibleAnnotations", anno); | 116 write_annotations_attribute("RuntimeVisibleAnnotations", anno); |
117 } | |
118 if (type_anno != NULL) { | |
119 write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno); | |
112 } | 120 } |
113 } | 121 } |
114 } | 122 } |
115 | 123 |
116 // Write Code attribute | 124 // Write Code attribute |
548 ConstMethod* const_method = method->constMethod(); | 556 ConstMethod* const_method = method->constMethod(); |
549 u2 generic_signature_index = const_method->generic_signature_index(); | 557 u2 generic_signature_index = const_method->generic_signature_index(); |
550 AnnotationArray* anno = method->annotations(); | 558 AnnotationArray* anno = method->annotations(); |
551 AnnotationArray* param_anno = method->parameter_annotations(); | 559 AnnotationArray* param_anno = method->parameter_annotations(); |
552 AnnotationArray* default_anno = method->annotation_default(); | 560 AnnotationArray* default_anno = method->annotation_default(); |
561 AnnotationArray* type_anno = method->type_annotations(); | |
553 | 562 |
554 // skip generated default interface methods | 563 // skip generated default interface methods |
555 if (method->is_overpass()) { | 564 if (method->is_overpass()) { |
556 return; | 565 return; |
557 } | 566 } |
583 ++attr_count; // has RuntimeVisibleAnnotations attribute | 592 ++attr_count; // has RuntimeVisibleAnnotations attribute |
584 } | 593 } |
585 if (param_anno != NULL) { | 594 if (param_anno != NULL) { |
586 ++attr_count; // has RuntimeVisibleParameterAnnotations attribute | 595 ++attr_count; // has RuntimeVisibleParameterAnnotations attribute |
587 } | 596 } |
597 if (type_anno != NULL) { | |
598 ++attr_count; // has RuntimeVisibleTypeAnnotations attribute | |
599 } | |
588 | 600 |
589 write_u2(attr_count); | 601 write_u2(attr_count); |
590 if (const_method->code_size() > 0) { | 602 if (const_method->code_size() > 0) { |
591 write_code_attribute(method); | 603 write_code_attribute(method); |
592 } | 604 } |
606 if (anno != NULL) { | 618 if (anno != NULL) { |
607 write_annotations_attribute("RuntimeVisibleAnnotations", anno); | 619 write_annotations_attribute("RuntimeVisibleAnnotations", anno); |
608 } | 620 } |
609 if (param_anno != NULL) { | 621 if (param_anno != NULL) { |
610 write_annotations_attribute("RuntimeVisibleParameterAnnotations", param_anno); | 622 write_annotations_attribute("RuntimeVisibleParameterAnnotations", param_anno); |
623 } | |
624 if (type_anno != NULL) { | |
625 write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno); | |
611 } | 626 } |
612 } | 627 } |
613 | 628 |
614 // Write the class attributes portion of ClassFile structure | 629 // Write the class attributes portion of ClassFile structure |
615 // JVMSpec| u2 attributes_count; | 630 // JVMSpec| u2 attributes_count; |
616 // JVMSpec| attribute_info attributes[attributes_count]; | 631 // JVMSpec| attribute_info attributes[attributes_count]; |
617 void JvmtiClassFileReconstituter::write_class_attributes() { | 632 void JvmtiClassFileReconstituter::write_class_attributes() { |
618 u2 inner_classes_length = inner_classes_attribute_length(); | 633 u2 inner_classes_length = inner_classes_attribute_length(); |
619 Symbol* generic_signature = ikh()->generic_signature(); | 634 Symbol* generic_signature = ikh()->generic_signature(); |
620 AnnotationArray* anno = ikh()->class_annotations(); | 635 AnnotationArray* anno = ikh()->class_annotations(); |
636 AnnotationArray* type_anno = ikh()->class_type_annotations(); | |
621 | 637 |
622 int attr_count = 0; | 638 int attr_count = 0; |
623 if (generic_signature != NULL) { | 639 if (generic_signature != NULL) { |
624 ++attr_count; | 640 ++attr_count; |
625 } | 641 } |
633 ++attr_count; | 649 ++attr_count; |
634 } | 650 } |
635 if (anno != NULL) { | 651 if (anno != NULL) { |
636 ++attr_count; // has RuntimeVisibleAnnotations attribute | 652 ++attr_count; // has RuntimeVisibleAnnotations attribute |
637 } | 653 } |
654 if (type_anno != NULL) { | |
655 ++attr_count; // has RuntimeVisibleTypeAnnotations attribute | |
656 } | |
638 if (cpool()->operands() != NULL) { | 657 if (cpool()->operands() != NULL) { |
639 ++attr_count; | 658 ++attr_count; |
640 } | 659 } |
641 | 660 |
642 write_u2(attr_count); | 661 write_u2(attr_count); |
653 if (inner_classes_length > 0) { | 672 if (inner_classes_length > 0) { |
654 write_inner_classes_attribute(inner_classes_length); | 673 write_inner_classes_attribute(inner_classes_length); |
655 } | 674 } |
656 if (anno != NULL) { | 675 if (anno != NULL) { |
657 write_annotations_attribute("RuntimeVisibleAnnotations", anno); | 676 write_annotations_attribute("RuntimeVisibleAnnotations", anno); |
677 } | |
678 if (type_anno != NULL) { | |
679 write_annotations_attribute("RuntimeVisibleTypeAnnotations", type_anno); | |
658 } | 680 } |
659 if (cpool()->operands() != NULL) { | 681 if (cpool()->operands() != NULL) { |
660 write_bootstrapmethod_attribute(); | 682 write_bootstrapmethod_attribute(); |
661 } | 683 } |
662 } | 684 } |