|
35 | 35 | import org.objectweb.asm.Label;
|
36 | 36 | import org.objectweb.asm.MethodVisitor;
|
37 | 37 | import org.objectweb.asm.Opcodes;
|
| 38 | +import org.objectweb.asm.RecordComponentVisitor; |
38 | 39 | import org.objectweb.asm.Type;
|
39 | 40 | import org.objectweb.asm.TypePath;
|
40 | 41 | import org.objectweb.asm.commons.Method;
|
@@ -63,7 +64,7 @@ public final class ClassScanner extends ClassVisitor implements Constants {
|
63 | 64 | boolean classSuppressed = false;
|
64 | 65 |
|
65 | 66 | public ClassScanner(RelatedClassLookup lookup, Signatures forbiddenSignatures, final Pattern suppressAnnotations) {
|
66 |
| - super(Opcodes.ASM7); |
| 67 | + super(Opcodes.ASM8); |
67 | 68 | this.lookup = lookup;
|
68 | 69 | this.forbiddenSignatures = forbiddenSignatures;
|
69 | 70 | this.suppressAnnotations = suppressAnnotations;
|
@@ -249,7 +250,7 @@ public FieldVisitor visitField(final int access, final String name, final String
|
249 | 250 | if (classSuppressed) {
|
250 | 251 | return null;
|
251 | 252 | }
|
252 |
| - return new FieldVisitor(Opcodes.ASM7) { |
| 253 | + return new FieldVisitor(Opcodes.ASM8) { |
253 | 254 | final boolean isDeprecated = (access & Opcodes.ACC_DEPRECATED) != 0;
|
254 | 255 | {
|
255 | 256 | // only check signature, if field is not synthetic
|
@@ -294,7 +295,7 @@ public MethodVisitor visitMethod(final int access, final String name, final Stri
|
294 | 295 | if (classSuppressed) {
|
295 | 296 | return null;
|
296 | 297 | }
|
297 |
| - return new MethodVisitor(Opcodes.ASM7) { |
| 298 | + return new MethodVisitor(Opcodes.ASM8) { |
298 | 299 | private final Method myself = new Method(name, desc);
|
299 | 300 | private final boolean isDeprecated = (access & Opcodes.ACC_DEPRECATED) != 0;
|
300 | 301 | private int lineNo = -1;
|
@@ -531,6 +532,39 @@ public void visitLineNumber(int lineNo, Label start) {
|
531 | 532 | };
|
532 | 533 | }
|
533 | 534 |
|
| 535 | + @Override |
| 536 | + public RecordComponentVisitor visitRecordComponent(final String name, final String desc, final String signature) { |
| 537 | + currentGroupId++; |
| 538 | + if (classSuppressed) { |
| 539 | + return null; |
| 540 | + } |
| 541 | + return new RecordComponentVisitor(Opcodes.ASM8) { |
| 542 | + { |
| 543 | + reportRecordComponentViolation(checkDescriptor(desc), "record component declaration"); |
| 544 | + } |
| 545 | + |
| 546 | + @Override |
| 547 | + public AnnotationVisitor visitAnnotation(String desc, boolean visible) { |
| 548 | + final Type type = Type.getType(desc); |
| 549 | + maybeSuppressCurrentGroup(type); |
| 550 | + reportRecordComponentViolation(checkAnnotationDescriptor(type, visible), "annotation on record component declaration"); |
| 551 | + return null; |
| 552 | + } |
| 553 | + |
| 554 | + @Override |
| 555 | + public AnnotationVisitor visitTypeAnnotation(int typeRef, TypePath typePath, String desc, boolean visible) { |
| 556 | + reportRecordComponentViolation(checkAnnotationDescriptor(Type.getType(desc), visible), "type annotation on record component declaration"); |
| 557 | + return null; |
| 558 | + } |
| 559 | + |
| 560 | + private void reportRecordComponentViolation(String violation, String where) { |
| 561 | + if (violation != null) { |
| 562 | + violations.add(new ForbiddenViolation(currentGroupId, violation, String.format(Locale.ENGLISH, "%s of '%s'", where, name), -1)); |
| 563 | + } |
| 564 | + } |
| 565 | + }; |
| 566 | + } |
| 567 | + |
534 | 568 | @Override
|
535 | 569 | public void visitEnd() {
|
536 | 570 | // fixup lambdas by assigning them the groupId where they were originally declared:
|
|
0 commit comments