Skip to content

Commit a0c0421

Browse files
authored
Adopt ASM 9.4 (#5174)
* Adopt ASM 9.4 Signed-off-by: Jorge Bescos Gascon <[email protected]>
1 parent b06385c commit a0c0421

File tree

18 files changed

+161
-83
lines changed

18 files changed

+161
-83
lines changed

core-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,17 @@ protected AnnotationVisitor(final int api, final AnnotationVisitor annotationVis
8484
this.av = annotationVisitor;
8585
}
8686

87+
/**
88+
* The annotation visitor to which this visitor must delegate method calls. May be {@literal
89+
* null}.
90+
*
91+
* @return the annotation visitor to which this visitor must delegate method calls, or {@literal
92+
* null}.
93+
*/
94+
public AnnotationVisitor getDelegate() {
95+
return av;
96+
}
97+
8798
/**
8899
* Visits a primitive value of the annotation.
89100
*

core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
package jersey.repackaged.org.objectweb.asm;
2929

3030
/**
31-
* A non standard class, field, method or code attribute, as defined in the Java Virtual Machine
31+
* A non standard class, field, method or Code attribute, as defined in the Java Virtual Machine
3232
* Specification (JVMS).
3333
*
3434
* @see <a href= "https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7">JVMS
@@ -52,7 +52,7 @@ public class Attribute {
5252

5353
/**
5454
* The next attribute in this attribute list (Attribute instances can be linked via this field to
55-
* store a list of class, field, method or code attributes). May be {@literal null}.
55+
* store a list of class, field, method or Code attributes). May be {@literal null}.
5656
*/
5757
Attribute nextAttribute;
5858

@@ -80,9 +80,9 @@ public boolean isUnknown() {
8080
}
8181

8282
/**
83-
* Returns {@literal true} if this type of attribute is a code attribute.
83+
* Returns {@literal true} if this type of attribute is a Code attribute.
8484
*
85-
* @return {@literal true} if this type of attribute is a code attribute.
85+
* @return {@literal true} if this type of attribute is a Code attribute.
8686
*/
8787
public boolean isCodeAttribute() {
8888
return false;
@@ -92,7 +92,7 @@ public boolean isCodeAttribute() {
9292
* Returns the labels corresponding to this attribute.
9393
*
9494
* @return the labels corresponding to this attribute, or {@literal null} if this attribute is not
95-
* a code attribute that contains labels.
95+
* a Code attribute that contains labels.
9696
*/
9797
protected Label[] getLabels() {
9898
return new Label[0];
@@ -111,11 +111,11 @@ protected Label[] getLabels() {
111111
* @param charBuffer the buffer to be used to call the ClassReader methods requiring a
112112
* 'charBuffer' parameter.
113113
* @param codeAttributeOffset index of the first byte of content of the enclosing Code attribute
114-
* in {@link ClassReader}, or -1 if the attribute to be read is not a code attribute. The 6
114+
* in {@link ClassReader}, or -1 if the attribute to be read is not a Code attribute. The 6
115115
* attribute header bytes (attribute_name_index and attribute_length) are not taken into
116116
* account here.
117117
* @param labels the labels of the method's code, or {@literal null} if the attribute to be read
118-
* is not a code attribute.
118+
* is not a Code attribute.
119119
* @return a <i>new</i> {@link Attribute} object corresponding to the specified bytes.
120120
*/
121121
protected Attribute read(
@@ -138,16 +138,16 @@ protected Attribute read(
138138
*
139139
* @param classWriter the class to which this attribute must be added. This parameter can be used
140140
* to add the items that corresponds to this attribute to the constant pool of this class.
141-
* @param code the bytecode of the method corresponding to this code attribute, or {@literal null}
142-
* if this attribute is not a code attribute. Corresponds to the 'code' field of the Code
141+
* @param code the bytecode of the method corresponding to this Code attribute, or {@literal null}
142+
* if this attribute is not a Code attribute. Corresponds to the 'code' field of the Code
143143
* attribute.
144144
* @param codeLength the length of the bytecode of the method corresponding to this code
145-
* attribute, or 0 if this attribute is not a code attribute. Corresponds to the 'code_length'
145+
* attribute, or 0 if this attribute is not a Code attribute. Corresponds to the 'code_length'
146146
* field of the Code attribute.
147-
* @param maxStack the maximum stack size of the method corresponding to this code attribute, or
148-
* -1 if this attribute is not a code attribute.
147+
* @param maxStack the maximum stack size of the method corresponding to this Code attribute, or
148+
* -1 if this attribute is not a Code attribute.
149149
* @param maxLocals the maximum number of local variables of the method corresponding to this code
150-
* attribute, or -1 if this attribute is not a code attribute.
150+
* attribute, or -1 if this attribute is not a Code attribute.
151151
* @return the byte array form of this attribute.
152152
*/
153153
protected ByteVector write(
@@ -197,16 +197,16 @@ final int computeAttributesSize(final SymbolTable symbolTable) {
197197
* attribute_length) per attribute. Also adds the attribute type names to the constant pool.
198198
*
199199
* @param symbolTable where the constants used in the attributes must be stored.
200-
* @param code the bytecode of the method corresponding to these code attributes, or {@literal
201-
* null} if they are not code attributes. Corresponds to the 'code' field of the Code
200+
* @param code the bytecode of the method corresponding to these Code attributes, or {@literal
201+
* null} if they are not Code attributes. Corresponds to the 'code' field of the Code
202202
* attribute.
203203
* @param codeLength the length of the bytecode of the method corresponding to these code
204-
* attributes, or 0 if they are not code attributes. Corresponds to the 'code_length' field of
204+
* attributes, or 0 if they are not Code attributes. Corresponds to the 'code_length' field of
205205
* the Code attribute.
206-
* @param maxStack the maximum stack size of the method corresponding to these code attributes, or
207-
* -1 if they are not code attributes.
206+
* @param maxStack the maximum stack size of the method corresponding to these Code attributes, or
207+
* -1 if they are not Code attributes.
208208
* @param maxLocals the maximum number of local variables of the method corresponding to these
209-
* code attributes, or -1 if they are not code attribute.
209+
* Code attributes, or -1 if they are not Code attribute.
210210
* @return the size of all the attributes in this attribute list. This size includes the size of
211211
* the attribute headers.
212212
*/
@@ -285,16 +285,16 @@ final void putAttributes(final SymbolTable symbolTable, final ByteVector output)
285285
* attribute.
286286
*
287287
* @param symbolTable where the constants used in the attributes must be stored.
288-
* @param code the bytecode of the method corresponding to these code attributes, or {@literal
289-
* null} if they are not code attributes. Corresponds to the 'code' field of the Code
288+
* @param code the bytecode of the method corresponding to these Code attributes, or {@literal
289+
* null} if they are not Code attributes. Corresponds to the 'code' field of the Code
290290
* attribute.
291291
* @param codeLength the length of the bytecode of the method corresponding to these code
292-
* attributes, or 0 if they are not code attributes. Corresponds to the 'code_length' field of
292+
* attributes, or 0 if they are not Code attributes. Corresponds to the 'code_length' field of
293293
* the Code attribute.
294-
* @param maxStack the maximum stack size of the method corresponding to these code attributes, or
295-
* -1 if they are not code attributes.
294+
* @param maxStack the maximum stack size of the method corresponding to these Code attributes, or
295+
* -1 if they are not Code attributes.
296296
* @param maxLocals the maximum number of local variables of the method corresponding to these
297-
* code attributes, or -1 if they are not code attribute.
297+
* Code attributes, or -1 if they are not Code attribute.
298298
* @param output where the attributes must be written.
299299
*/
300300
final void putAttributes(

core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ public ClassReader(
194194
this.b = classFileBuffer;
195195
// Check the class' major_version. This field is after the magic and minor_version fields, which
196196
// use 4 and 2 bytes respectively.
197-
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V19) {
197+
if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V20) {
198198
throw new IllegalArgumentException(
199199
"Unsupported class file major version " + readShort(classFileOffset + 6));
200200
}
@@ -375,7 +375,7 @@ public String getClassName() {
375375
}
376376

377377
/**
378-
* Returns the internal of name of the super class (see {@link Type#getInternalName()}). For
378+
* Returns the internal name of the super class (see {@link Type#getInternalName()}). For
379379
* interfaces, the super class is {@link Object}.
380380
*
381381
* @return the internal name of the super class, or {@literal null} for {@link Object} class.
@@ -859,7 +859,7 @@ private void readModuleAttributes(
859859
currentOffset += 2;
860860
}
861861

862-
// Read the 'provides_count' and 'provides' fields.
862+
// Read the 'provides_count' and 'provides' fields.
863863
int providesCount = readUnsignedShort(currentOffset);
864864
currentOffset += 2;
865865
while (providesCount-- > 0) {

core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassTooLargeException.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ public final class ClassTooLargeException extends IndexOutOfBoundsException {
4242
/**
4343
* Constructs a new {@link ClassTooLargeException}.
4444
*
45-
* @param className the internal name of the class.
45+
* @param className the internal name of the class (see {@link
46+
* jersey.repackaged.org.objectweb.asm.Type#getInternalName()}).
4647
* @param constantPoolCount the number of constant pool items of the class.
4748
*/
4849
public ClassTooLargeException(final String className, final int constantPoolCount) {
@@ -52,7 +53,7 @@ public ClassTooLargeException(final String className, final int constantPoolCoun
5253
}
5354

5455
/**
55-
* Returns the internal name of the class.
56+
* Returns the internal name of the class (see {@link jersey.repackaged.org.objectweb.asm.Type#getInternalName()}).
5657
*
5758
* @return the internal name of the class.
5859
*/

core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassVisitor.java

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected ClassVisitor(final int api) {
6767
* null.
6868
*/
6969
protected ClassVisitor(final int api, final ClassVisitor classVisitor) {
70-
if (api != Opcodes.ASM9
70+
if (api != Opcodes.ASM9
7171
&& api != Opcodes.ASM8
7272
&& api != Opcodes.ASM7
7373
&& api != Opcodes.ASM6
@@ -83,6 +83,15 @@ protected ClassVisitor(final int api, final ClassVisitor classVisitor) {
8383
this.cv = classVisitor;
8484
}
8585

86+
/**
87+
* The class visitor to which this visitor must delegate method calls. May be {@literal null}.
88+
*
89+
* @return the class visitor to which this visitor must delegate method calls, or {@literal null}.
90+
*/
91+
public ClassVisitor getDelegate() {
92+
return cv;
93+
}
94+
8695
/**
8796
* Visits the header of the class.
8897
*
@@ -157,7 +166,8 @@ public ModuleVisitor visitModule(final String name, final int access, final Stri
157166
* implicitly its own nest, so it's invalid to call this method with the visited class name as
158167
* argument.
159168
*
160-
* @param nestHost the internal name of the host class of the nest.
169+
* @param nestHost the internal name of the host class of the nest (see {@link
170+
* Type#getInternalName()}).
161171
*/
162172
public void visitNestHost(final String nestHost) {
163173
if (api < Opcodes.ASM7) {
@@ -169,14 +179,19 @@ public void visitNestHost(final String nestHost) {
169179
}
170180

171181
/**
172-
* Visits the enclosing class of the class. This method must be called only if the class has an
173-
* enclosing class.
182+
* Visits the enclosing class of the class. This method must be called only if this class is a
183+
* local or anonymous class. See the JVMS 4.7.7 section for more details.
174184
*
175-
* @param owner internal name of the enclosing class of the class.
185+
* @param owner internal name of the enclosing class of the class (see {@link
186+
* Type#getInternalName()}).
176187
* @param name the name of the method that contains the class, or {@literal null} if the class is
177-
* not enclosed in a method of its enclosing class.
188+
* not enclosed in a method or constructor of its enclosing class (e.g. if it is enclosed in
189+
* an instance initializer, static initializer, instance variable initializer, or class
190+
* variable initializer).
178191
* @param descriptor the descriptor of the method that contains the class, or {@literal null} if
179-
* the class is not enclosed in a method of its enclosing class.
192+
* the class is not enclosed in a method or constructor of its enclosing class (e.g. if it is
193+
* enclosed in an instance initializer, static initializer, instance variable initializer, or
194+
* class variable initializer).
180195
*/
181196
public void visitOuterClass(final String owner, final String name, final String descriptor) {
182197
if (cv != null) {
@@ -243,7 +258,7 @@ public void visitAttribute(final Attribute attribute) {
243258
* the visited class is the host of a nest. A nest host is implicitly a member of its own nest, so
244259
* it's invalid to call this method with the visited class name as argument.
245260
*
246-
* @param nestMember the internal name of a nest member.
261+
* @param nestMember the internal name of a nest member (see {@link Type#getInternalName()}).
247262
*/
248263
public void visitNestMember(final String nestMember) {
249264
if (api < Opcodes.ASM7) {
@@ -258,7 +273,8 @@ public void visitNestMember(final String nestMember) {
258273
* Visits a permitted subclasses. A permitted subclass is one of the allowed subclasses of the
259274
* current class.
260275
*
261-
* @param permittedSubclass the internal name of a permitted subclass.
276+
* @param permittedSubclass the internal name of a permitted subclass (see {@link
277+
* Type#getInternalName()}).
262278
*/
263279
public void visitPermittedSubclass(final String permittedSubclass) {
264280
if (api < Opcodes.ASM9) {
@@ -271,15 +287,18 @@ public void visitPermittedSubclass(final String permittedSubclass) {
271287

272288
/**
273289
* Visits information about an inner class. This inner class is not necessarily a member of the
274-
* class being visited.
290+
* class being visited. More precisely, every class or interface C which is referenced by this
291+
* class and which is not a package member must be visited with this method. This class must
292+
* reference its nested class or interface members, and its enclosing class, if any. See the JVMS
293+
* 4.7.6 section for more details.
275294
*
276-
* @param name the internal name of an inner class (see {@link Type#getInternalName()}).
277-
* @param outerName the internal name of the class to which the inner class belongs (see {@link
278-
* Type#getInternalName()}). May be {@literal null} for not member classes.
279-
* @param innerName the (simple) name of the inner class inside its enclosing class. May be
280-
* {@literal null} for anonymous inner classes.
281-
* @param access the access flags of the inner class as originally declared in the enclosing
282-
* class.
295+
* @param name the internal name of C (see {@link Type#getInternalName()}).
296+
* @param outerName the internal name of the class or interface C is a member of (see {@link
297+
* Type#getInternalName()}). Must be {@literal null} if C is not the member of a class or
298+
* interface (e.g. for local or anonymous classes).
299+
* @param innerName the (simple) name of C. Must be {@literal null} for anonymous inner classes.
300+
* @param access the access flags of C originally declared in the source code from which this
301+
* class was compiled.
283302
*/
284303
public void visitInnerClass(
285304
final String name, final String outerName, final String innerName, final int access) {

core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassWriter.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ public int newUTF8(final String value) {
842842
* constant pool already contains a similar item. <i>This method is intended for {@link Attribute}
843843
* sub classes, and is normally not needed by class generators or adapters.</i>
844844
*
845-
* @param value the internal name of the class.
845+
* @param value the internal name of the class (see {@link Type#getInternalName()}).
846846
* @return the index of a new or already existing class reference item.
847847
*/
848848
public int newClass(final String value) {
@@ -894,7 +894,8 @@ public int newPackage(final String packageName) {
894894
* Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link
895895
* Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL},
896896
* {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}.
897-
* @param owner the internal name of the field or method owner class.
897+
* @param owner the internal name of the field or method owner class (see {@link
898+
* Type#getInternalName()}).
898899
* @param name the name of the field or method.
899900
* @param descriptor the descriptor of the field or method.
900901
* @return the index of a new or already existing method type reference item.
@@ -916,7 +917,8 @@ public int newHandle(
916917
* Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link
917918
* Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL},
918919
* {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}.
919-
* @param owner the internal name of the field or method owner class.
920+
* @param owner the internal name of the field or method owner class (see {@link
921+
* Type#getInternalName()}).
920922
* @param name the name of the field or method.
921923
* @param descriptor the descriptor of the field or method.
922924
* @param isInterface true if the owner is an interface.
@@ -978,7 +980,7 @@ public int newInvokeDynamic(
978980
* constant pool already contains a similar item. <i>This method is intended for {@link Attribute}
979981
* sub classes, and is normally not needed by class generators or adapters.</i>
980982
*
981-
* @param owner the internal name of the field's owner class.
983+
* @param owner the internal name of the field's owner class (see {@link Type#getInternalName()}).
982984
* @param name the field's name.
983985
* @param descriptor the field's descriptor.
984986
* @return the index of a new or already existing field reference item.
@@ -992,7 +994,8 @@ public int newField(final String owner, final String name, final String descript
992994
* constant pool already contains a similar item. <i>This method is intended for {@link Attribute}
993995
* sub classes, and is normally not needed by class generators or adapters.</i>
994996
*
995-
* @param owner the internal name of the method's owner class.
997+
* @param owner the internal name of the method's owner class (see {@link
998+
* Type#getInternalName()}).
996999
* @param name the method's name.
9971000
* @param descriptor the method's descriptor.
9981001
* @param isInterface {@literal true} if {@code owner} is an interface.
@@ -1028,9 +1031,10 @@ public int newNameType(final String name, final String descriptor) {
10281031
* currently being generated by this ClassWriter, which can of course not be loaded since it is
10291032
* under construction.
10301033
*
1031-
* @param type1 the internal name of a class.
1032-
* @param type2 the internal name of another class.
1033-
* @return the internal name of the common super class of the two given classes.
1034+
* @param type1 the internal name of a class (see {@link Type#getInternalName()}).
1035+
* @param type2 the internal name of another class (see {@link Type#getInternalName()}).
1036+
* @return the internal name of the common super class of the two given classes (see {@link
1037+
* Type#getInternalName()}).
10341038
*/
10351039
protected String getCommonSuperClass(final String type1, final String type2) {
10361040
ClassLoader classLoader = getClassLoader();

core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Constants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
2727
// THE POSSIBILITY OF SUCH DAMAGE.
2828
package jersey.repackaged.org.objectweb.asm;
29+
2930
import java.io.DataInputStream;
3031
import java.io.IOException;
3132
import java.io.InputStream;

core-server/src/main/java/jersey/repackaged/org/objectweb/asm/FieldVisitor.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,15 @@ protected FieldVisitor(final int api, final FieldVisitor fieldVisitor) {
8080
this.fv = fieldVisitor;
8181
}
8282

83+
/**
84+
* The field visitor to which this visitor must delegate method calls. May be {@literal null}.
85+
*
86+
* @return the field visitor to which this visitor must delegate method calls, or {@literal null}.
87+
*/
88+
public FieldVisitor getDelegate() {
89+
return fv;
90+
}
91+
8392
/**
8493
* Visits an annotation of the field.
8594
*

0 commit comments

Comments
 (0)