3030/**
3131 * A visitor to visit a Java class. The methods of this class must be called in the following order:
3232 * {@code visit} [ {@code visitSource} ] [ {@code visitModule} ][ {@code visitNestHost} ][ {@code
33- * visitPermittedSubtype } ][ {@code visitOuterClass} ] ( {@code visitAnnotation} | {@code
33+ * visitPermittedSubclass } ][ {@code visitOuterClass} ] ( {@code visitAnnotation} | {@code
3434 * visitTypeAnnotation} | {@code visitAttribute} )* ( {@code visitNestMember} | {@code
35- * visitInnerClass} | {@code visitField} | {@code visitMethod} )* {@code visitEnd}.
35+ * visitInnerClass} | {@code visitRecordComponent} | {@code visitField} | {@code visitMethod} )*
36+ * {@code visitEnd}.
3637 *
3738 * @author Eric Bruneton
3839 */
@@ -61,21 +62,22 @@ public ClassVisitor(final int api) {
6162 * Constructs a new {@link ClassVisitor}.
6263 *
6364 * @param api the ASM API version implemented by this visitor. Must be one of {@link
64- * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7} or {@link
65- * Opcodes#ASM8}.
65+ * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
66+ * Opcodes#ASM8} or {@link Opcodes#ASM9} .
6667 * @param classVisitor the class visitor to which this visitor must delegate method calls. May be
6768 * null.
6869 */
6970 public ClassVisitor (final int api , final ClassVisitor classVisitor ) {
70- if (api != Opcodes .ASM8
71+ if (api != Opcodes .ASM9
72+ && api != Opcodes .ASM8
7173 && api != Opcodes .ASM7
7274 && api != Opcodes .ASM6
7375 && api != Opcodes .ASM5
7476 && api != Opcodes .ASM4
75- && api != Opcodes .ASM9_EXPERIMENTAL ) {
77+ && api != Opcodes .ASM10_EXPERIMENTAL ) {
7678 throw new IllegalArgumentException ("Unsupported api " + api );
7779 }
78- if (api == Opcodes .ASM9_EXPERIMENTAL ) {
80+ if (api == Opcodes .ASM10_EXPERIMENTAL ) {
7981 Constants .checkAsmExperimental (this );
8082 }
8183 this .api = api ;
@@ -88,7 +90,8 @@ public ClassVisitor(final int api, final ClassVisitor classVisitor) {
8890 * @param version the class version. The minor version is stored in the 16 most significant bits,
8991 * and the major version in the 16 least significant bits.
9092 * @param access the class's access flags (see {@link Opcodes}). This parameter also indicates if
91- * the class is deprecated.
93+ * the class is deprecated {@link Opcodes#ACC_DEPRECATED} or a record {@link
94+ * Opcodes#ACC_RECORD}.
9295 * @param name the internal name of the class (see {@link Type#getInternalName()}).
9396 * @param signature the signature of this class. May be {@literal null} if the class is not a
9497 * generic one, and does not extend or implement generic classes or interfaces.
@@ -105,6 +108,9 @@ public void visit(
105108 final String signature ,
106109 final String superName ,
107110 final String [] interfaces ) {
111+ if (api < Opcodes .ASM8 && (access & Opcodes .ACC_RECORD ) != 0 ) {
112+ throw new UnsupportedOperationException ("Records requires ASM8" );
113+ }
108114 if (cv != null ) {
109115 cv .visit (version , access , name , signature , superName , interfaces );
110116 }
@@ -136,7 +142,7 @@ public void visitSource(final String source, final String debug) {
136142 */
137143 public ModuleVisitor visitModule (final String name , final int access , final String version ) {
138144 if (api < Opcodes .ASM6 ) {
139- throw new UnsupportedOperationException ("This feature requires ASM6" );
145+ throw new UnsupportedOperationException ("Module requires ASM6" );
140146 }
141147 if (cv != null ) {
142148 return cv .visitModule (name , access , version );
@@ -156,7 +162,7 @@ public ModuleVisitor visitModule(final String name, final int access, final Stri
156162 */
157163 public void visitNestHost (final String nestHost ) {
158164 if (api < Opcodes .ASM7 ) {
159- throw new UnsupportedOperationException ("This feature requires ASM7" );
165+ throw new UnsupportedOperationException ("NestHost requires ASM7" );
160166 }
161167 if (cv != null ) {
162168 cv .visitNestHost (nestHost );
@@ -212,7 +218,7 @@ public AnnotationVisitor visitAnnotation(final String descriptor, final boolean
212218 public AnnotationVisitor visitTypeAnnotation (
213219 final int typeRef , final TypePath typePath , final String descriptor , final boolean visible ) {
214220 if (api < Opcodes .ASM5 ) {
215- throw new UnsupportedOperationException ("This feature requires ASM5" );
221+ throw new UnsupportedOperationException ("TypeAnnotation requires ASM5" );
216222 }
217223 if (cv != null ) {
218224 return cv .visitTypeAnnotation (typeRef , typePath , descriptor , visible );
@@ -242,28 +248,25 @@ public void visitAttribute(final Attribute attribute) {
242248 */
243249 public void visitNestMember (final String nestMember ) {
244250 if (api < Opcodes .ASM7 ) {
245- throw new UnsupportedOperationException ("This feature requires ASM7" );
251+ throw new UnsupportedOperationException ("NestMember requires ASM7" );
246252 }
247253 if (cv != null ) {
248254 cv .visitNestMember (nestMember );
249255 }
250256 }
251257
252258 /**
253- * <b>Experimental, use at your own risk. This method will be renamed when it becomes stable, this
254- * will break existing code using it</b>. Visits a permitted subtypes. A permitted subtypes is one
255- * of the allowed subtypes of the current class.
259+ * Visits a permitted subclasses. A permitted subclass is one of the allowed subclasses of the
260+ * current class.
256261 *
257- * @param permittedSubtype the internal name of a permitted subtype.
258- * @deprecated this API is experimental.
262+ * @param permittedSubclass the internal name of a permitted subclass.
259263 */
260- @ Deprecated
261- public void visitPermittedSubtypeExperimental (final String permittedSubtype ) {
262- if (api != Opcodes .ASM9_EXPERIMENTAL ) {
263- throw new UnsupportedOperationException ("This feature requires ASM9_EXPERIMENTAL" );
264+ public void visitPermittedSubclass (final String permittedSubclass ) {
265+ if (api < Opcodes .ASM9 ) {
266+ throw new UnsupportedOperationException ("PermittedSubclasses requires ASM9" );
264267 }
265268 if (cv != null ) {
266- cv .visitPermittedSubtypeExperimental ( permittedSubtype );
269+ cv .visitPermittedSubclass ( permittedSubclass );
267270 }
268271 }
269272
@@ -299,7 +302,7 @@ public void visitInnerClass(
299302 public RecordComponentVisitor visitRecordComponent (
300303 final String name , final String descriptor , final String signature ) {
301304 if (api < Opcodes .ASM8 ) {
302- throw new UnsupportedOperationException ("This feature requires ASM8" );
305+ throw new UnsupportedOperationException ("Record requires ASM8" );
303306 }
304307 if (cv != null ) {
305308 return cv .visitRecordComponent (name , descriptor , signature );
0 commit comments