@@ -47,6 +47,8 @@ public class AttributeInfo {
47
47
public const string Signature = "Signature" ;
48
48
public const string SourceFile = "SourceFile" ;
49
49
public const string StackMapTable = "StackMapTable" ;
50
+ public const string RuntimeVisibleAnnotations = "RuntimeVisibleAnnotations" ;
51
+ public const string RuntimeInvisibleAnnotations = "RuntimeInvisibleAnnotations" ;
50
52
51
53
ushort nameIndex ;
52
54
@@ -76,6 +78,8 @@ public string Name {
76
78
{ typeof ( InnerClassesAttribute ) , InnerClasses } ,
77
79
{ typeof ( LocalVariableTableAttribute ) , LocalVariableTable } ,
78
80
{ typeof ( MethodParametersAttribute ) , MethodParameters } ,
81
+ { typeof ( RuntimeVisibleAnnotationsAttribute ) , RuntimeVisibleAnnotations } ,
82
+ { typeof ( RuntimeInvisibleAnnotationsAttribute ) , RuntimeInvisibleAnnotations } ,
79
83
{ typeof ( SignatureAttribute ) , Signature } ,
80
84
{ typeof ( SourceFileAttribute ) , SourceFile } ,
81
85
{ typeof ( StackMapTableAttribute ) , StackMapTable } ,
@@ -109,6 +113,8 @@ static AttributeInfo CreateAttribute (string name, ConstantPool constantPool, us
109
113
case InnerClasses : return new InnerClassesAttribute ( constantPool , nameIndex , stream ) ;
110
114
case LocalVariableTable : return new LocalVariableTableAttribute ( constantPool , nameIndex , stream ) ;
111
115
case MethodParameters : return new MethodParametersAttribute ( constantPool , nameIndex , stream ) ;
116
+ case RuntimeVisibleAnnotations : return new RuntimeVisibleAnnotationsAttribute ( constantPool , nameIndex , stream ) ;
117
+ case RuntimeInvisibleAnnotations : return new RuntimeInvisibleAnnotationsAttribute ( constantPool , nameIndex , stream ) ;
112
118
case Signature : return new SignatureAttribute ( constantPool , nameIndex , stream ) ;
113
119
case SourceFile : return new SourceFileAttribute ( constantPool , nameIndex , stream ) ;
114
120
case StackMapTable : return new StackMapTableAttribute ( constantPool , nameIndex , stream ) ;
@@ -493,6 +499,54 @@ public override string ToString ()
493
499
}
494
500
}
495
501
502
+ // https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.16
503
+ public sealed class RuntimeVisibleAnnotationsAttribute : AttributeInfo
504
+ {
505
+
506
+ public IList < Annotation > Annotations { get ; } = new List < Annotation > ( ) ;
507
+
508
+ public RuntimeVisibleAnnotationsAttribute ( ConstantPool constantPool , ushort nameIndex , Stream stream )
509
+ : base ( constantPool , nameIndex , stream )
510
+ {
511
+ var length = stream . ReadNetworkUInt32 ( ) ;
512
+ var count = stream . ReadNetworkUInt16 ( ) ;
513
+
514
+ for ( int i = 0 ; i < count ; ++ i ) {
515
+ Annotations . Add ( new Annotation ( constantPool , stream ) ) ;
516
+ }
517
+ }
518
+
519
+ public override string ToString ( )
520
+ {
521
+ var annotations = string . Join ( ", " , Annotations . Select ( v => v . ToString ( ) ) ) ;
522
+ return $ "RuntimeVisibleAnnotations({ annotations } )";
523
+ }
524
+ }
525
+
526
+ // https://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.17
527
+ public sealed class RuntimeInvisibleAnnotationsAttribute : AttributeInfo
528
+ {
529
+ public IList < Annotation > Annotations { get ; } = new List < Annotation > ( ) ;
530
+
531
+ public RuntimeInvisibleAnnotationsAttribute ( ConstantPool constantPool , ushort nameIndex , Stream stream )
532
+ : base ( constantPool , nameIndex , stream )
533
+ {
534
+ var length = stream . ReadNetworkUInt32 ( ) ;
535
+ var count = stream . ReadNetworkUInt16 ( ) ;
536
+
537
+ for ( int i = 0 ; i < count ; ++ i ) {
538
+ var a = new Annotation ( constantPool , stream ) ;
539
+ Annotations . Add ( a ) ;
540
+ }
541
+ }
542
+
543
+ public override string ToString ( )
544
+ {
545
+ var annotations = string . Join ( ", " , Annotations . Select ( v => v . ToString ( ) ) ) ;
546
+ return $ "RuntimeVisibleAnnotations({ annotations } )";
547
+ }
548
+ }
549
+
496
550
// http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-4.html#jvms-4.7.9
497
551
public sealed class SignatureAttribute : AttributeInfo {
498
552
0 commit comments