@@ -119,10 +119,10 @@ void JvmtiClassFileReconstituter::write_field_infos() {
119
119
write_signature_attribute (generic_signature_index);
120
120
}
121
121
if (anno != nullptr ) {
122
- write_annotations_attribute (" RuntimeVisibleAnnotations" , anno);
122
+ write_annotations_attribute (" RuntimeVisibleAnnotations" , " RuntimeInvisibleAnnotations " , anno);
123
123
}
124
124
if (type_anno != nullptr ) {
125
- write_annotations_attribute (" RuntimeVisibleTypeAnnotations" , type_anno);
125
+ write_annotations_attribute (" RuntimeVisibleTypeAnnotations" , " RuntimeInvisibleTypeAnnotations " , type_anno);
126
126
}
127
127
}
128
128
}
@@ -380,6 +380,20 @@ void JvmtiClassFileReconstituter::write_annotations_attribute(const char* attr_n
380
380
memcpy (writeable_address (length), annos->adr_at (0 ), length);
381
381
}
382
382
383
+ void JvmtiClassFileReconstituter::write_annotations_attribute (const char * attr_name,
384
+ const char * fallback_attr_name,
385
+ AnnotationArray* annos) {
386
+ TempNewSymbol sym = SymbolTable::probe (attr_name, (int )strlen (attr_name));
387
+ if (sym != nullptr ) {
388
+ if (symbol_to_cpool_index (sym) != 0 ) {
389
+ write_annotations_attribute (attr_name, annos);
390
+ return ;
391
+ }
392
+ }
393
+ // use fallback name
394
+ write_annotations_attribute (fallback_attr_name, annos);
395
+ }
396
+
383
397
// BootstrapMethods_attribute {
384
398
// u2 attribute_name_index;
385
399
// u4 attribute_length;
@@ -519,10 +533,10 @@ void JvmtiClassFileReconstituter::write_record_attribute() {
519
533
write_signature_attribute (component->generic_signature_index ());
520
534
}
521
535
if (component->annotations () != nullptr ) {
522
- write_annotations_attribute (" RuntimeVisibleAnnotations" , component->annotations ());
536
+ write_annotations_attribute (" RuntimeVisibleAnnotations" , " RuntimeInvisibleAnnotations " , component->annotations ());
523
537
}
524
538
if (component->type_annotations () != nullptr ) {
525
- write_annotations_attribute (" RuntimeVisibleTypeAnnotations" , component->type_annotations ());
539
+ write_annotations_attribute (" RuntimeVisibleTypeAnnotations" , " RuntimeInvisibleTypeAnnotations " , component->type_annotations ());
526
540
}
527
541
}
528
542
}
@@ -761,13 +775,13 @@ void JvmtiClassFileReconstituter::write_method_info(const methodHandle& method)
761
775
write_signature_attribute (generic_signature_index);
762
776
}
763
777
if (anno != nullptr ) {
764
- write_annotations_attribute (" RuntimeVisibleAnnotations" , anno);
778
+ write_annotations_attribute (" RuntimeVisibleAnnotations" , " RuntimeInvisibleAnnotations " , anno);
765
779
}
766
780
if (param_anno != nullptr ) {
767
- write_annotations_attribute (" RuntimeVisibleParameterAnnotations" , param_anno);
781
+ write_annotations_attribute (" RuntimeVisibleParameterAnnotations" , " RuntimeInvisibleParameterAnnotations " , param_anno);
768
782
}
769
783
if (type_anno != nullptr ) {
770
- write_annotations_attribute (" RuntimeVisibleTypeAnnotations" , type_anno);
784
+ write_annotations_attribute (" RuntimeVisibleTypeAnnotations" , " RuntimeInvisibleTypeAnnotations " , type_anno);
771
785
}
772
786
}
773
787
@@ -827,10 +841,10 @@ void JvmtiClassFileReconstituter::write_class_attributes() {
827
841
write_source_debug_extension_attribute ();
828
842
}
829
843
if (anno != nullptr ) {
830
- write_annotations_attribute (" RuntimeVisibleAnnotations" , anno);
844
+ write_annotations_attribute (" RuntimeVisibleAnnotations" , " RuntimeInvisibleAnnotations " , anno);
831
845
}
832
846
if (type_anno != nullptr ) {
833
- write_annotations_attribute (" RuntimeVisibleTypeAnnotations" , type_anno);
847
+ write_annotations_attribute (" RuntimeVisibleTypeAnnotations" , " RuntimeInvisibleTypeAnnotations " , type_anno);
834
848
}
835
849
if (ik ()->nest_host_index () != 0 ) {
836
850
write_nest_host_attribute ();
0 commit comments