@@ -406,6 +406,12 @@ public static ConstantPool read(final Buffer b) {
406
406
case InvokeDynamicInfo :
407
407
new InvokeDynamicInfoEntry (pool , b .readUnsignedShort (), b .readUnsignedShort ());
408
408
break ;
409
+ case Module :
410
+ new ModuleEntry (pool , b .readUnsignedShort ());
411
+ break ;
412
+ case Package :
413
+ new PackageEntry (pool , b .readUnsignedShort ());
414
+ break ;
409
415
}
410
416
}
411
417
@@ -520,7 +526,9 @@ public static enum Tag {
520
526
NameAndTypeDescriptor (12 ),
521
527
MethodHandle (15 ),
522
528
MethodType (16 ),
523
- InvokeDynamicInfo (18 );
529
+ InvokeDynamicInfo (18 ),
530
+ Module (19 ),
531
+ Package (20 );
524
532
525
533
public final int value ;
526
534
@@ -529,16 +537,20 @@ public static enum Tag {
529
537
}
530
538
531
539
public static Tag fromValue (final int value ) {
532
- VerifyArgument .inRange (Tag . Utf8StringConstant . value , Tag . InvokeDynamicInfo .value , value , "value" );
540
+ VerifyArgument .inRange (minTag . value , maxTag .value , value , "value" );
533
541
return lookup [value ];
534
542
}
535
543
544
+ private final static Tag minTag ;
545
+ private final static Tag maxTag ;
536
546
private final static Tag [] lookup ;
537
547
538
548
static {
539
549
final Tag [] values = Tag .values ();
540
550
541
- lookup = new Tag [Tag .InvokeDynamicInfo .value + 1 ];
551
+ minTag = values [0 ];
552
+ maxTag = values [values .length - 1 ];
553
+ lookup = new Tag [maxTag .value + 1 ];
542
554
543
555
for (final Tag tag : values ) {
544
556
lookup [tag .value ] = tag ;
@@ -566,6 +578,8 @@ public interface Visitor {
566
578
void visitMethodType (MethodTypeEntry info );
567
579
void visitStringConstant (StringConstantEntry info );
568
580
void visitUtf8StringConstant (Utf8StringConstantEntry info );
581
+ void visitModule (ModuleEntry info );
582
+ void visitPackage (PackageEntry info );
569
583
void visitEnd ();
570
584
571
585
// <editor-fold defaultstate="collapsed" desc="Empty Visitor (No-Op)">
@@ -631,6 +645,14 @@ public void visitStringConstant(final StringConstantEntry info) {
631
645
public void visitUtf8StringConstant (final Utf8StringConstantEntry info ) {
632
646
}
633
647
648
+ @ Override
649
+ public void visitModule (final ModuleEntry info ) {
650
+ }
651
+
652
+ @ Override
653
+ public void visitPackage (final PackageEntry info ) {
654
+ }
655
+
634
656
@ Override
635
657
public void visitEnd () {
636
658
}
@@ -745,6 +767,18 @@ public void visitUtf8StringConstant(final Utf8StringConstantEntry info) {
745
767
codeStream .writeUtf8 (info .value );
746
768
}
747
769
770
+ @ Override
771
+ public void visitModule (final ModuleEntry info ) {
772
+ codeStream .writeByte (info .getTag ().value );
773
+ codeStream .writeShort (info .nameIndex );
774
+ }
775
+
776
+ @ Override
777
+ public void visitPackage (final PackageEntry info ) {
778
+ codeStream .writeByte (info .getTag ().value );
779
+ codeStream .writeShort (info .nameIndex );
780
+ }
781
+
748
782
@ Override
749
783
public void visitEnd () {
750
784
}
@@ -1073,6 +1107,96 @@ public String toString() {
1073
1107
}
1074
1108
}
1075
1109
1110
+ public static class ModuleEntry extends ConstantEntry {
1111
+
1112
+ public final int nameIndex ;
1113
+
1114
+ public ModuleEntry (final ConstantPool owner , final int nameIndex ) {
1115
+ super (owner );
1116
+
1117
+ this .nameIndex = nameIndex ;
1118
+ owner ._newKey .set (getTag (), nameIndex );
1119
+ owner ._entryMap .put (owner ._newKey .clone (), this );
1120
+ owner ._newKey .clear ();
1121
+ }
1122
+
1123
+ @ Override
1124
+ void fixupKey (final Key key ) {
1125
+ key .set (Tag .Module , nameIndex );
1126
+ }
1127
+
1128
+ public Tag getTag () {
1129
+ return Tag .Module ;
1130
+ }
1131
+
1132
+ public int byteLength () {
1133
+ return 3 ;
1134
+ }
1135
+
1136
+ public String getName () {
1137
+ return ((Utf8StringConstantEntry ) owner .get (nameIndex , Tag .Utf8StringConstant )).value ;
1138
+ }
1139
+
1140
+ public void accept (final Visitor visitor ) {
1141
+ visitor .visitModule (this );
1142
+ }
1143
+
1144
+ @ Override
1145
+ public String toString () {
1146
+ return "ModuleEntry[nameIndex: " + nameIndex + "]" ;
1147
+ }
1148
+
1149
+ @ Override
1150
+ public Object getConstantValue () {
1151
+ return getName ();
1152
+ }
1153
+ }
1154
+
1155
+ public static class PackageEntry extends ConstantEntry {
1156
+
1157
+ public final int nameIndex ;
1158
+
1159
+ public PackageEntry (final ConstantPool owner , final int nameIndex ) {
1160
+ super (owner );
1161
+
1162
+ this .nameIndex = nameIndex ;
1163
+ owner ._newKey .set (getTag (), nameIndex );
1164
+ owner ._entryMap .put (owner ._newKey .clone (), this );
1165
+ owner ._newKey .clear ();
1166
+ }
1167
+
1168
+ @ Override
1169
+ void fixupKey (final Key key ) {
1170
+ key .set (Tag .Package , nameIndex );
1171
+ }
1172
+
1173
+ public Tag getTag () {
1174
+ return Tag .Package ;
1175
+ }
1176
+
1177
+ public int byteLength () {
1178
+ return 3 ;
1179
+ }
1180
+
1181
+ public String getName () {
1182
+ return ((Utf8StringConstantEntry ) owner .get (nameIndex , Tag .Utf8StringConstant )).value ;
1183
+ }
1184
+
1185
+ public void accept (final Visitor visitor ) {
1186
+ visitor .visitPackage (this );
1187
+ }
1188
+
1189
+ @ Override
1190
+ public String toString () {
1191
+ return "PackageEntry[nameIndex: " + nameIndex + "]" ;
1192
+ }
1193
+
1194
+ @ Override
1195
+ public Object getConstantValue () {
1196
+ return getName ();
1197
+ }
1198
+ }
1199
+
1076
1200
public static final class DoubleConstantEntry extends ConstantEntry {
1077
1201
public final double value ;
1078
1202
0 commit comments