Skip to content

Commit d8c4be3

Browse files
authored
Merge pull request #212 from ebean-orm/feature/asm97
Update to ASM 9.7
2 parents e3519eb + ec9c38f commit d8c4be3

File tree

14 files changed

+370
-146
lines changed

14 files changed

+370
-146
lines changed

ebean-agent/src/main/java/io/ebean/enhance/asm/AnnotationWriter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static AnnotationWriter create(
144144
// Write type_index and reserve space for num_element_value_pairs.
145145
annotation.putShort(symbolTable.addConstantUtf8(descriptor)).putShort(0);
146146
return new AnnotationWriter(
147-
symbolTable, /* useNamedValues = */ true, annotation, previousAnnotation);
147+
symbolTable, /* useNamedValues= */ true, annotation, previousAnnotation);
148148
}
149149

150150
/**
@@ -179,7 +179,7 @@ static AnnotationWriter create(
179179
// Write type_index and reserve space for num_element_value_pairs.
180180
typeAnnotation.putShort(symbolTable.addConstantUtf8(descriptor)).putShort(0);
181181
return new AnnotationWriter(
182-
symbolTable, /* useNamedValues = */ true, typeAnnotation, previousAnnotation);
182+
symbolTable, /* useNamedValues= */ true, typeAnnotation, previousAnnotation);
183183
}
184184

185185
// -----------------------------------------------------------------------------------------------
@@ -284,7 +284,7 @@ public AnnotationVisitor visitAnnotation(final String name, final String descrip
284284
}
285285
// Write tag and type_index, and reserve 2 bytes for num_element_value_pairs.
286286
annotation.put12('@', symbolTable.addConstantUtf8(descriptor)).putShort(0);
287-
return new AnnotationWriter(symbolTable, /* useNamedValues = */ true, annotation, null);
287+
return new AnnotationWriter(symbolTable, /* useNamedValues= */ true, annotation, null);
288288
}
289289

290290
@Override
@@ -303,7 +303,7 @@ public AnnotationVisitor visitArray(final String name) {
303303
// visit the array elements. Its num_element_value_pairs will correspond to the number of array
304304
// elements and will be stored in what is in fact num_values.
305305
annotation.put12('[', 0);
306-
return new AnnotationWriter(symbolTable, /* useNamedValues = */ false, annotation, null);
306+
return new AnnotationWriter(symbolTable, /* useNamedValues= */ false, annotation, null);
307307
}
308308

309309
@Override

ebean-agent/src/main/java/io/ebean/enhance/asm/ClassReader.java

Lines changed: 54 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ public ClassReader(
177177
final byte[] classFileBuffer,
178178
final int classFileOffset,
179179
final int classFileLength) { // NOPMD(UnusedFormalParameter) used for backward compatibility.
180-
this(classFileBuffer, classFileOffset, /* checkClassVersion = */ true);
180+
this(classFileBuffer, classFileOffset, /* checkClassVersion= */ true);
181181
}
182182

183183
/**
@@ -188,13 +188,14 @@ public ClassReader(
188188
* @param classFileOffset the offset in byteBuffer of the first byte of the ClassFile to be read.
189189
* @param checkClassVersion whether to check the class version or not.
190190
*/
191+
@SuppressWarnings("PMD.ConstructorCallsOverridableMethod")
191192
ClassReader(
192193
final byte[] classFileBuffer, final int classFileOffset, final boolean checkClassVersion) {
193194
this.classFileBuffer = classFileBuffer;
194195
this.b = classFileBuffer;
195196
// Check the class' major_version. This field is after the magic and minor_version fields, which
196197
// use 4 and 2 bytes respectively.
197-
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V21) {
198+
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V23) {
198199
throw new IllegalArgumentException(
199200
"Unsupported class file major version " + readShort(classFileOffset + 6));
200201
}
@@ -606,9 +607,9 @@ public void accept(
606607
// Parse num_element_value_pairs and element_value_pairs and visit these values.
607608
currentAnnotationOffset =
608609
readElementValues(
609-
classVisitor.visitAnnotation(annotationDescriptor, /* visible = */ true),
610+
classVisitor.visitAnnotation(annotationDescriptor, /* visible= */ true),
610611
currentAnnotationOffset,
611-
/* named = */ true,
612+
/* named= */ true,
612613
charBuffer);
613614
}
614615
}
@@ -624,9 +625,9 @@ public void accept(
624625
// Parse num_element_value_pairs and element_value_pairs and visit these values.
625626
currentAnnotationOffset =
626627
readElementValues(
627-
classVisitor.visitAnnotation(annotationDescriptor, /* visible = */ false),
628+
classVisitor.visitAnnotation(annotationDescriptor, /* visible= */ false),
628629
currentAnnotationOffset,
629-
/* named = */ true,
630+
/* named= */ true,
630631
charBuffer);
631632
}
632633
}
@@ -648,9 +649,9 @@ public void accept(
648649
context.currentTypeAnnotationTarget,
649650
context.currentTypeAnnotationTargetPath,
650651
annotationDescriptor,
651-
/* visible = */ true),
652+
/* visible= */ true),
652653
currentAnnotationOffset,
653-
/* named = */ true,
654+
/* named= */ true,
654655
charBuffer);
655656
}
656657
}
@@ -672,9 +673,9 @@ public void accept(
672673
context.currentTypeAnnotationTarget,
673674
context.currentTypeAnnotationTargetPath,
674675
annotationDescriptor,
675-
/* visible = */ false),
676+
/* visible= */ false),
676677
currentAnnotationOffset,
677-
/* named = */ true,
678+
/* named= */ true,
678679
charBuffer);
679680
}
680681
}
@@ -966,9 +967,9 @@ private int readRecordComponent(
966967
// Parse num_element_value_pairs and element_value_pairs and visit these values.
967968
currentAnnotationOffset =
968969
readElementValues(
969-
recordComponentVisitor.visitAnnotation(annotationDescriptor, /* visible = */ true),
970+
recordComponentVisitor.visitAnnotation(annotationDescriptor, /* visible= */ true),
970971
currentAnnotationOffset,
971-
/* named = */ true,
972+
/* named= */ true,
972973
charBuffer);
973974
}
974975
}
@@ -984,9 +985,9 @@ private int readRecordComponent(
984985
// Parse num_element_value_pairs and element_value_pairs and visit these values.
985986
currentAnnotationOffset =
986987
readElementValues(
987-
recordComponentVisitor.visitAnnotation(annotationDescriptor, /* visible = */ false),
988+
recordComponentVisitor.visitAnnotation(annotationDescriptor, /* visible= */ false),
988989
currentAnnotationOffset,
989-
/* named = */ true,
990+
/* named= */ true,
990991
charBuffer);
991992
}
992993
}
@@ -1008,9 +1009,9 @@ private int readRecordComponent(
10081009
context.currentTypeAnnotationTarget,
10091010
context.currentTypeAnnotationTargetPath,
10101011
annotationDescriptor,
1011-
/* visible = */ true),
1012+
/* visible= */ true),
10121013
currentAnnotationOffset,
1013-
/* named = */ true,
1014+
/* named= */ true,
10141015
charBuffer);
10151016
}
10161017
}
@@ -1032,9 +1033,9 @@ private int readRecordComponent(
10321033
context.currentTypeAnnotationTarget,
10331034
context.currentTypeAnnotationTargetPath,
10341035
annotationDescriptor,
1035-
/* visible = */ false),
1036+
/* visible= */ false),
10361037
currentAnnotationOffset,
1037-
/* named = */ true,
1038+
/* named= */ true,
10381039
charBuffer);
10391040
}
10401041
}
@@ -1150,9 +1151,9 @@ private int readField(
11501151
// Parse num_element_value_pairs and element_value_pairs and visit these values.
11511152
currentAnnotationOffset =
11521153
readElementValues(
1153-
fieldVisitor.visitAnnotation(annotationDescriptor, /* visible = */ true),
1154+
fieldVisitor.visitAnnotation(annotationDescriptor, /* visible= */ true),
11541155
currentAnnotationOffset,
1155-
/* named = */ true,
1156+
/* named= */ true,
11561157
charBuffer);
11571158
}
11581159
}
@@ -1168,9 +1169,9 @@ private int readField(
11681169
// Parse num_element_value_pairs and element_value_pairs and visit these values.
11691170
currentAnnotationOffset =
11701171
readElementValues(
1171-
fieldVisitor.visitAnnotation(annotationDescriptor, /* visible = */ false),
1172+
fieldVisitor.visitAnnotation(annotationDescriptor, /* visible= */ false),
11721173
currentAnnotationOffset,
1173-
/* named = */ true,
1174+
/* named= */ true,
11741175
charBuffer);
11751176
}
11761177
}
@@ -1192,9 +1193,9 @@ private int readField(
11921193
context.currentTypeAnnotationTarget,
11931194
context.currentTypeAnnotationTargetPath,
11941195
annotationDescriptor,
1195-
/* visible = */ true),
1196+
/* visible= */ true),
11961197
currentAnnotationOffset,
1197-
/* named = */ true,
1198+
/* named= */ true,
11981199
charBuffer);
11991200
}
12001201
}
@@ -1216,9 +1217,9 @@ private int readField(
12161217
context.currentTypeAnnotationTarget,
12171218
context.currentTypeAnnotationTargetPath,
12181219
annotationDescriptor,
1219-
/* visible = */ false),
1220+
/* visible= */ false),
12201221
currentAnnotationOffset,
1221-
/* named = */ true,
1222+
/* named= */ true,
12221223
charBuffer);
12231224
}
12241225
}
@@ -1411,9 +1412,9 @@ private int readMethod(
14111412
// Parse num_element_value_pairs and element_value_pairs and visit these values.
14121413
currentAnnotationOffset =
14131414
readElementValues(
1414-
methodVisitor.visitAnnotation(annotationDescriptor, /* visible = */ true),
1415+
methodVisitor.visitAnnotation(annotationDescriptor, /* visible= */ true),
14151416
currentAnnotationOffset,
1416-
/* named = */ true,
1417+
/* named= */ true,
14171418
charBuffer);
14181419
}
14191420
}
@@ -1429,9 +1430,9 @@ private int readMethod(
14291430
// Parse num_element_value_pairs and element_value_pairs and visit these values.
14301431
currentAnnotationOffset =
14311432
readElementValues(
1432-
methodVisitor.visitAnnotation(annotationDescriptor, /* visible = */ false),
1433+
methodVisitor.visitAnnotation(annotationDescriptor, /* visible= */ false),
14331434
currentAnnotationOffset,
1434-
/* named = */ true,
1435+
/* named= */ true,
14351436
charBuffer);
14361437
}
14371438
}
@@ -1453,9 +1454,9 @@ private int readMethod(
14531454
context.currentTypeAnnotationTarget,
14541455
context.currentTypeAnnotationTargetPath,
14551456
annotationDescriptor,
1456-
/* visible = */ true),
1457+
/* visible= */ true),
14571458
currentAnnotationOffset,
1458-
/* named = */ true,
1459+
/* named= */ true,
14591460
charBuffer);
14601461
}
14611462
}
@@ -1477,26 +1478,23 @@ private int readMethod(
14771478
context.currentTypeAnnotationTarget,
14781479
context.currentTypeAnnotationTargetPath,
14791480
annotationDescriptor,
1480-
/* visible = */ false),
1481+
/* visible= */ false),
14811482
currentAnnotationOffset,
1482-
/* named = */ true,
1483+
/* named= */ true,
14831484
charBuffer);
14841485
}
14851486
}
14861487

14871488
// Visit the RuntimeVisibleParameterAnnotations attribute.
14881489
if (runtimeVisibleParameterAnnotationsOffset != 0) {
14891490
readParameterAnnotations(
1490-
methodVisitor, context, runtimeVisibleParameterAnnotationsOffset, /* visible = */ true);
1491+
methodVisitor, context, runtimeVisibleParameterAnnotationsOffset, /* visible= */ true);
14911492
}
14921493

14931494
// Visit the RuntimeInvisibleParameterAnnotations attribute.
14941495
if (runtimeInvisibleParameterAnnotationsOffset != 0) {
14951496
readParameterAnnotations(
1496-
methodVisitor,
1497-
context,
1498-
runtimeInvisibleParameterAnnotationsOffset,
1499-
/* visible = */ false);
1497+
methodVisitor, context, runtimeInvisibleParameterAnnotationsOffset, /* visible= */ false);
15001498
}
15011499

15021500
// Visit the non standard attributes.
@@ -1925,7 +1923,7 @@ private void readCode(
19251923
}
19261924
} else if (Constants.RUNTIME_VISIBLE_TYPE_ANNOTATIONS.equals(attributeName)) {
19271925
visibleTypeAnnotationOffsets =
1928-
readTypeAnnotations(methodVisitor, context, currentOffset, /* visible = */ true);
1926+
readTypeAnnotations(methodVisitor, context, currentOffset, /* visible= */ true);
19291927
// Here we do not extract the labels corresponding to the attribute content. This would
19301928
// require a full parsing of the attribute, which would need to be repeated when parsing
19311929
// the bytecode instructions (see below). Instead, the content of the attribute is read one
@@ -1934,7 +1932,7 @@ private void readCode(
19341932
// time. This assumes that type annotations are ordered by increasing bytecode offset.
19351933
} else if (Constants.RUNTIME_INVISIBLE_TYPE_ANNOTATIONS.equals(attributeName)) {
19361934
invisibleTypeAnnotationOffsets =
1937-
readTypeAnnotations(methodVisitor, context, currentOffset, /* visible = */ false);
1935+
readTypeAnnotations(methodVisitor, context, currentOffset, /* visible= */ false);
19381936
// Same comment as above for the RuntimeVisibleTypeAnnotations attribute.
19391937
} else if (Constants.STACK_MAP_TABLE.equals(attributeName)) {
19401938
if ((context.parsingOptions & SKIP_FRAMES) == 0) {
@@ -2516,9 +2514,9 @@ private void readCode(
25162514
context.currentTypeAnnotationTarget,
25172515
context.currentTypeAnnotationTargetPath,
25182516
annotationDescriptor,
2519-
/* visible = */ true),
2517+
/* visible= */ true),
25202518
currentAnnotationOffset,
2521-
/* named = */ true,
2519+
/* named= */ true,
25222520
charBuffer);
25232521
}
25242522
currentVisibleTypeAnnotationBytecodeOffset =
@@ -2544,9 +2542,9 @@ private void readCode(
25442542
context.currentTypeAnnotationTarget,
25452543
context.currentTypeAnnotationTargetPath,
25462544
annotationDescriptor,
2547-
/* visible = */ false),
2545+
/* visible= */ false),
25482546
currentAnnotationOffset,
2549-
/* named = */ true,
2547+
/* named= */ true,
25502548
charBuffer);
25512549
}
25522550
currentInvisibleTypeAnnotationBytecodeOffset =
@@ -2617,9 +2615,9 @@ private void readCode(
26172615
context.currentLocalVariableAnnotationRangeEnds,
26182616
context.currentLocalVariableAnnotationRangeIndices,
26192617
annotationDescriptor,
2620-
/* visible = */ true),
2618+
/* visible= */ true),
26212619
currentOffset,
2622-
/* named = */ true,
2620+
/* named= */ true,
26232621
charBuffer);
26242622
}
26252623
}
@@ -2645,9 +2643,9 @@ private void readCode(
26452643
context.currentLocalVariableAnnotationRangeEnds,
26462644
context.currentLocalVariableAnnotationRangeIndices,
26472645
annotationDescriptor,
2648-
/* visible = */ false),
2646+
/* visible= */ false),
26492647
currentOffset,
2650-
/* named = */ true,
2648+
/* named= */ true,
26512649
charBuffer);
26522650
}
26532651
}
@@ -2820,7 +2818,7 @@ private int[] readTypeAnnotations(
28202818
methodVisitor.visitTryCatchAnnotation(
28212819
targetType & 0xFFFFFF00, path, annotationDescriptor, visible),
28222820
currentOffset,
2823-
/* named = */ true,
2821+
/* named= */ true,
28242822
charBuffer);
28252823
} else {
28262824
// We don't want to visit the other target_type annotations, so we just skip them (which
@@ -2831,7 +2829,7 @@ private int[] readTypeAnnotations(
28312829
// with a null AnnotationVisitor).
28322830
currentOffset =
28332831
readElementValues(
2834-
/* annotationVisitor = */ null, currentOffset, /* named = */ true, charBuffer);
2832+
/* annotationVisitor= */ null, currentOffset, /* named= */ true, charBuffer);
28352833
}
28362834
}
28372835
return typeAnnotationsOffsets;
@@ -2971,7 +2969,7 @@ private void readParameterAnnotations(
29712969
readElementValues(
29722970
methodVisitor.visitParameterAnnotation(i, annotationDescriptor, visible),
29732971
currentOffset,
2974-
/* named = */ true,
2972+
/* named= */ true,
29752973
charBuffer);
29762974
}
29772975
}
@@ -3041,9 +3039,9 @@ private int readElementValue(
30413039
case 'e': // enum_const_value
30423040
return currentOffset + 5;
30433041
case '@': // annotation_value
3044-
return readElementValues(null, currentOffset + 3, /* named = */ true, charBuffer);
3042+
return readElementValues(null, currentOffset + 3, /* named= */ true, charBuffer);
30453043
case '[': // array_value
3046-
return readElementValues(null, currentOffset + 1, /* named = */ false, charBuffer);
3044+
return readElementValues(null, currentOffset + 1, /* named= */ false, charBuffer);
30473045
default:
30483046
return currentOffset + 3;
30493047
}
@@ -3111,7 +3109,7 @@ private int readElementValue(
31113109
return readElementValues(
31123110
annotationVisitor.visitArray(elementName),
31133111
currentOffset - 2,
3114-
/* named = */ false,
3112+
/* named= */ false,
31153113
charBuffer);
31163114
}
31173115
switch (classFileBuffer[currentOffset] & 0xFF) {
@@ -3188,7 +3186,7 @@ private int readElementValue(
31883186
readElementValues(
31893187
annotationVisitor.visitArray(elementName),
31903188
currentOffset - 2,
3191-
/* named = */ false,
3189+
/* named= */ false,
31923190
charBuffer);
31933191
break;
31943192
}

0 commit comments

Comments
 (0)