66 import jdk.internal.org.objectweb.asm.TypeReference;
67
68 /**
69 * A {@link FieldVisitor} that checks that its methods are properly used.
70 */
71 public class CheckFieldAdapter extends FieldVisitor {
72
73 private boolean end;
74
75 /**
76 * Constructs a new {@link CheckFieldAdapter}. <i>Subclasses must not use
77 * this constructor</i>. Instead, they must use the
78 * {@link #CheckFieldAdapter(int, FieldVisitor)} version.
79 *
80 * @param fv
81 * the field visitor to which this adapter must delegate calls.
82 * @throws IllegalStateException
83 * If a subclass calls this constructor.
84 */
85 public CheckFieldAdapter(final FieldVisitor fv) {
86 this(Opcodes.ASM5, fv);
87 if (getClass() != CheckFieldAdapter.class) {
88 throw new IllegalStateException();
89 }
90 }
91
92 /**
93 * Constructs a new {@link CheckFieldAdapter}.
94 *
95 * @param api
96 * the ASM API version implemented by this visitor. Must be one
97 * of {@link Opcodes#ASM4} or {@link Opcodes#ASM5}.
98 * @param fv
99 * the field visitor to which this adapter must delegate calls.
100 */
101 protected CheckFieldAdapter(final int api, final FieldVisitor fv) {
102 super(api, fv);
103 }
104
105 @Override
106 public AnnotationVisitor visitAnnotation(final String desc,
107 final boolean visible) {
108 checkEnd();
109 CheckMethodAdapter.checkDesc(desc, false);
110 return new CheckAnnotationAdapter(super.visitAnnotation(desc, visible));
111 }
112
113 @Override
114 public AnnotationVisitor visitTypeAnnotation(final int typeRef,
115 final TypePath typePath, final String desc, final boolean visible) {
116 checkEnd();
117 int sort = typeRef >>> 24;
|
66 import jdk.internal.org.objectweb.asm.TypeReference;
67
68 /**
69 * A {@link FieldVisitor} that checks that its methods are properly used.
70 */
71 public class CheckFieldAdapter extends FieldVisitor {
72
73 private boolean end;
74
75 /**
76 * Constructs a new {@link CheckFieldAdapter}. <i>Subclasses must not use
77 * this constructor</i>. Instead, they must use the
78 * {@link #CheckFieldAdapter(int, FieldVisitor)} version.
79 *
80 * @param fv
81 * the field visitor to which this adapter must delegate calls.
82 * @throws IllegalStateException
83 * If a subclass calls this constructor.
84 */
85 public CheckFieldAdapter(final FieldVisitor fv) {
86 this(Opcodes.ASM6, fv);
87 if (getClass() != CheckFieldAdapter.class) {
88 throw new IllegalStateException();
89 }
90 }
91
92 /**
93 * Constructs a new {@link CheckFieldAdapter}.
94 *
95 * @param api
96 * the ASM API version implemented by this visitor. Must be one
97 * of {@link Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
98 * @param fv
99 * the field visitor to which this adapter must delegate calls.
100 */
101 protected CheckFieldAdapter(final int api, final FieldVisitor fv) {
102 super(api, fv);
103 }
104
105 @Override
106 public AnnotationVisitor visitAnnotation(final String desc,
107 final boolean visible) {
108 checkEnd();
109 CheckMethodAdapter.checkDesc(desc, false);
110 return new CheckAnnotationAdapter(super.visitAnnotation(desc, visible));
111 }
112
113 @Override
114 public AnnotationVisitor visitTypeAnnotation(final int typeRef,
115 final TypePath typePath, final String desc, final boolean visible) {
116 checkEnd();
117 int sort = typeRef >>> 24;
|