From 1a25e9e45c27722d50215ad40b6960d3c3fb9784 Mon Sep 17 00:00:00 2001 From: Jorge Bescos Gascon Date: Mon, 10 Oct 2022 14:33:59 +0200 Subject: [PATCH 1/2] Adopt ASM 9.4 Signed-off-by: Jorge Bescos Gascon --- .../org/objectweb/asm/AnnotationVisitor.java | 11 ++++ .../org/objectweb/asm/Attribute.java | 50 ++++++++--------- .../org/objectweb/asm/ClassReader.java | 6 +-- .../objectweb/asm/ClassTooLargeException.java | 5 +- .../org/objectweb/asm/ClassVisitor.java | 53 +++++++++++++------ .../org/objectweb/asm/ClassWriter.java | 20 ++++--- .../org/objectweb/asm/Constants.java | 1 + .../org/objectweb/asm/FieldVisitor.java | 9 ++++ .../repackaged/org/objectweb/asm/Handle.java | 7 +-- .../asm/MethodTooLargeException.java | 4 +- .../org/objectweb/asm/MethodVisitor.java | 31 +++++++---- .../org/objectweb/asm/ModuleVisitor.java | 27 +++++++--- .../repackaged/org/objectweb/asm/Opcodes.java | 1 + .../objectweb/asm/RecordComponentVisitor.java | 5 +- .../repackaged/org/objectweb/asm/Type.java | 2 +- .../main/resources/META-INF/NOTICE.markdown | 2 +- pom.xml | 2 +- 17 files changed, 154 insertions(+), 82 deletions(-) diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java index 0654582e49..3dd95b3f2d 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/AnnotationVisitor.java @@ -84,6 +84,17 @@ protected AnnotationVisitor(final int api, final AnnotationVisitor annotationVis this.av = annotationVisitor; } + /** + * The annotation visitor to which this visitor must delegate method calls. May be {@literal + * null}. + * + * @return the annotation visitor to which this visitor must delegate method calls, or {@literal + * null}. + */ + public AnnotationVisitor getDelegate() { + return av; + } + /** * Visits a primitive value of the annotation. * diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java index bd090e6a41..f63fc71708 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Attribute.java @@ -28,7 +28,7 @@ package jersey.repackaged.org.objectweb.asm; /** - * A non standard class, field, method or code attribute, as defined in the Java Virtual Machine + * A non standard class, field, method or Code attribute, as defined in the Java Virtual Machine * Specification (JVMS). * * @see JVMS @@ -52,7 +52,7 @@ public class Attribute { /** * The next attribute in this attribute list (Attribute instances can be linked via this field to - * store a list of class, field, method or code attributes). May be {@literal null}. + * store a list of class, field, method or Code attributes). May be {@literal null}. */ Attribute nextAttribute; @@ -80,9 +80,9 @@ public boolean isUnknown() { } /** - * Returns {@literal true} if this type of attribute is a code attribute. + * Returns {@literal true} if this type of attribute is a Code attribute. * - * @return {@literal true} if this type of attribute is a code attribute. + * @return {@literal true} if this type of attribute is a Code attribute. */ public boolean isCodeAttribute() { return false; @@ -92,7 +92,7 @@ public boolean isCodeAttribute() { * Returns the labels corresponding to this attribute. * * @return the labels corresponding to this attribute, or {@literal null} if this attribute is not - * a code attribute that contains labels. + * a Code attribute that contains labels. */ protected Label[] getLabels() { return new Label[0]; @@ -111,11 +111,11 @@ protected Label[] getLabels() { * @param charBuffer the buffer to be used to call the ClassReader methods requiring a * 'charBuffer' parameter. * @param codeAttributeOffset index of the first byte of content of the enclosing Code attribute - * in {@link ClassReader}, or -1 if the attribute to be read is not a code attribute. The 6 + * in {@link ClassReader}, or -1 if the attribute to be read is not a Code attribute. The 6 * attribute header bytes (attribute_name_index and attribute_length) are not taken into * account here. * @param labels the labels of the method's code, or {@literal null} if the attribute to be read - * is not a code attribute. + * is not a Code attribute. * @return a new {@link Attribute} object corresponding to the specified bytes. */ protected Attribute read( @@ -138,16 +138,16 @@ protected Attribute read( * * @param classWriter the class to which this attribute must be added. This parameter can be used * to add the items that corresponds to this attribute to the constant pool of this class. - * @param code the bytecode of the method corresponding to this code attribute, or {@literal null} - * if this attribute is not a code attribute. Corresponds to the 'code' field of the Code + * @param code the bytecode of the method corresponding to this Code attribute, or {@literal null} + * if this attribute is not a Code attribute. Corresponds to the 'code' field of the Code * attribute. * @param codeLength the length of the bytecode of the method corresponding to this code - * attribute, or 0 if this attribute is not a code attribute. Corresponds to the 'code_length' + * attribute, or 0 if this attribute is not a Code attribute. Corresponds to the 'code_length' * field of the Code attribute. - * @param maxStack the maximum stack size of the method corresponding to this code attribute, or - * -1 if this attribute is not a code attribute. + * @param maxStack the maximum stack size of the method corresponding to this Code attribute, or + * -1 if this attribute is not a Code attribute. * @param maxLocals the maximum number of local variables of the method corresponding to this code - * attribute, or -1 if this attribute is not a code attribute. + * attribute, or -1 if this attribute is not a Code attribute. * @return the byte array form of this attribute. */ protected ByteVector write( @@ -197,16 +197,16 @@ final int computeAttributesSize(final SymbolTable symbolTable) { * attribute_length) per attribute. Also adds the attribute type names to the constant pool. * * @param symbolTable where the constants used in the attributes must be stored. - * @param code the bytecode of the method corresponding to these code attributes, or {@literal - * null} if they are not code attributes. Corresponds to the 'code' field of the Code + * @param code the bytecode of the method corresponding to these Code attributes, or {@literal + * null} if they are not Code attributes. Corresponds to the 'code' field of the Code * attribute. * @param codeLength the length of the bytecode of the method corresponding to these code - * attributes, or 0 if they are not code attributes. Corresponds to the 'code_length' field of + * attributes, or 0 if they are not Code attributes. Corresponds to the 'code_length' field of * the Code attribute. - * @param maxStack the maximum stack size of the method corresponding to these code attributes, or - * -1 if they are not code attributes. + * @param maxStack the maximum stack size of the method corresponding to these Code attributes, or + * -1 if they are not Code attributes. * @param maxLocals the maximum number of local variables of the method corresponding to these - * code attributes, or -1 if they are not code attribute. + * Code attributes, or -1 if they are not Code attribute. * @return the size of all the attributes in this attribute list. This size includes the size of * the attribute headers. */ @@ -285,16 +285,16 @@ final void putAttributes(final SymbolTable symbolTable, final ByteVector output) * attribute. * * @param symbolTable where the constants used in the attributes must be stored. - * @param code the bytecode of the method corresponding to these code attributes, or {@literal - * null} if they are not code attributes. Corresponds to the 'code' field of the Code + * @param code the bytecode of the method corresponding to these Code attributes, or {@literal + * null} if they are not Code attributes. Corresponds to the 'code' field of the Code * attribute. * @param codeLength the length of the bytecode of the method corresponding to these code - * attributes, or 0 if they are not code attributes. Corresponds to the 'code_length' field of + * attributes, or 0 if they are not Code attributes. Corresponds to the 'code_length' field of * the Code attribute. - * @param maxStack the maximum stack size of the method corresponding to these code attributes, or - * -1 if they are not code attributes. + * @param maxStack the maximum stack size of the method corresponding to these Code attributes, or + * -1 if they are not Code attributes. * @param maxLocals the maximum number of local variables of the method corresponding to these - * code attributes, or -1 if they are not code attribute. + * Code attributes, or -1 if they are not Code attribute. * @param output where the attributes must be written. */ final void putAttributes( diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java index cd4a6bb5ad..d6e90a7349 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassReader.java @@ -194,7 +194,7 @@ public ClassReader( this.b = classFileBuffer; // Check the class' major_version. This field is after the magic and minor_version fields, which // use 4 and 2 bytes respectively. - if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V19) { + if (checkClassVersion && readShort(classFileOffset + 6) > Opcodes.V20) { throw new IllegalArgumentException( "Unsupported class file major version " + readShort(classFileOffset + 6)); } @@ -375,7 +375,7 @@ public String getClassName() { } /** - * Returns the internal of name of the super class (see {@link Type#getInternalName()}). For + * Returns the internal name of the super class (see {@link Type#getInternalName()}). For * interfaces, the super class is {@link Object}. * * @return the internal name of the super class, or {@literal null} for {@link Object} class. @@ -859,7 +859,7 @@ private void readModuleAttributes( currentOffset += 2; } - // Read the 'provides_count' and 'provides' fields. + // Read the 'provides_count' and 'provides' fields. int providesCount = readUnsignedShort(currentOffset); currentOffset += 2; while (providesCount-- > 0) { diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassTooLargeException.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassTooLargeException.java index 8b462010b7..fefcfe7329 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassTooLargeException.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassTooLargeException.java @@ -42,7 +42,8 @@ public final class ClassTooLargeException extends IndexOutOfBoundsException { /** * Constructs a new {@link ClassTooLargeException}. * - * @param className the internal name of the class. + * @param className the internal name of the class (see {@link + * jersey.repackaged.org.objectweb.asm.Type#getInternalName()}). * @param constantPoolCount the number of constant pool items of the class. */ public ClassTooLargeException(final String className, final int constantPoolCount) { @@ -52,7 +53,7 @@ public ClassTooLargeException(final String className, final int constantPoolCoun } /** - * Returns the internal name of the class. + * Returns the internal name of the class (see {@link jersey.repackaged.org.objectweb.asm.Type#getInternalName()}). * * @return the internal name of the class. */ diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassVisitor.java index 8ebf594f64..44c6535cd4 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassVisitor.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassVisitor.java @@ -67,7 +67,7 @@ protected ClassVisitor(final int api) { * null. */ protected ClassVisitor(final int api, final ClassVisitor classVisitor) { - if (api != Opcodes.ASM9 + if (api != Opcodes.ASM9 && api != Opcodes.ASM8 && api != Opcodes.ASM7 && api != Opcodes.ASM6 @@ -83,6 +83,15 @@ protected ClassVisitor(final int api, final ClassVisitor classVisitor) { this.cv = classVisitor; } + /** + * The class visitor to which this visitor must delegate method calls. May be {@literal null}. + * + * @return the class visitor to which this visitor must delegate method calls, or {@literal null}. + */ + public ClassVisitor getDelegate() { + return cv; + } + /** * Visits the header of the class. * @@ -157,7 +166,8 @@ public ModuleVisitor visitModule(final String name, final int access, final Stri * implicitly its own nest, so it's invalid to call this method with the visited class name as * argument. * - * @param nestHost the internal name of the host class of the nest. + * @param nestHost the internal name of the host class of the nest (see {@link + * Type#getInternalName()}). */ public void visitNestHost(final String nestHost) { if (api < Opcodes.ASM7) { @@ -169,14 +179,19 @@ public void visitNestHost(final String nestHost) { } /** - * Visits the enclosing class of the class. This method must be called only if the class has an - * enclosing class. + * Visits the enclosing class of the class. This method must be called only if this class is a + * local or anonymous class. See the JVMS 4.7.7 section for more details. * - * @param owner internal name of the enclosing class of the class. + * @param owner internal name of the enclosing class of the class (see {@link + * Type#getInternalName()}). * @param name the name of the method that contains the class, or {@literal null} if the class is - * not enclosed in a method of its enclosing class. + * not enclosed in a method or constructor of its enclosing class (e.g. if it is enclosed in + * an instance initializer, static initializer, instance variable initializer, or class + * variable initializer). * @param descriptor the descriptor of the method that contains the class, or {@literal null} if - * the class is not enclosed in a method of its enclosing class. + * the class is not enclosed in a method or constructor of its enclosing class (e.g. if it is + * enclosed in an instance initializer, static initializer, instance variable initializer, or + * class variable initializer). */ public void visitOuterClass(final String owner, final String name, final String descriptor) { if (cv != null) { @@ -243,7 +258,7 @@ public void visitAttribute(final Attribute attribute) { * the visited class is the host of a nest. A nest host is implicitly a member of its own nest, so * it's invalid to call this method with the visited class name as argument. * - * @param nestMember the internal name of a nest member. + * @param nestMember the internal name of a nest member (see {@link Type#getInternalName()}). */ public void visitNestMember(final String nestMember) { if (api < Opcodes.ASM7) { @@ -258,7 +273,8 @@ public void visitNestMember(final String nestMember) { * Visits a permitted subclasses. A permitted subclass is one of the allowed subclasses of the * current class. * - * @param permittedSubclass the internal name of a permitted subclass. + * @param permittedSubclass the internal name of a permitted subclass (see {@link + * Type#getInternalName()}). */ public void visitPermittedSubclass(final String permittedSubclass) { if (api < Opcodes.ASM9) { @@ -271,15 +287,18 @@ public void visitPermittedSubclass(final String permittedSubclass) { /** * Visits information about an inner class. This inner class is not necessarily a member of the - * class being visited. + * class being visited. More precisely, every class or interface C which is referenced by this + * class and which is not a package member must be visited with this method. This class must + * reference its nested class or interface members, and its enclosing class, if any. See the JVMS + * 4.7.6 section for more details. * - * @param name the internal name of an inner class (see {@link Type#getInternalName()}). - * @param outerName the internal name of the class to which the inner class belongs (see {@link - * Type#getInternalName()}). May be {@literal null} for not member classes. - * @param innerName the (simple) name of the inner class inside its enclosing class. May be - * {@literal null} for anonymous inner classes. - * @param access the access flags of the inner class as originally declared in the enclosing - * class. + * @param name the internal name of C (see {@link Type#getInternalName()}). + * @param outerName the internal name of the class or interface C is a member of (see {@link + * Type#getInternalName()}). Must be {@literal null} if C is not the member of a class or + * interface (e.g. for local or anonymous classes). + * @param innerName the (simple) name of C. Must be {@literal null} for anonymous inner classes. + * @param access the access flags of C originally declared in the source code from which this + * class was compiled. */ public void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassWriter.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassWriter.java index de2c44194a..7bb6ab075f 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassWriter.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ClassWriter.java @@ -842,7 +842,7 @@ public int newUTF8(final String value) { * constant pool already contains a similar item. This method is intended for {@link Attribute} * sub classes, and is normally not needed by class generators or adapters. * - * @param value the internal name of the class. + * @param value the internal name of the class (see {@link Type#getInternalName()}). * @return the index of a new or already existing class reference item. */ public int newClass(final String value) { @@ -894,7 +894,8 @@ public int newPackage(final String packageName) { * Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link * Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL}, * {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}. - * @param owner the internal name of the field or method owner class. + * @param owner the internal name of the field or method owner class (see {@link + * Type#getInternalName()}). * @param name the name of the field or method. * @param descriptor the descriptor of the field or method. * @return the index of a new or already existing method type reference item. @@ -916,7 +917,8 @@ public int newHandle( * Opcodes#H_GETSTATIC}, {@link Opcodes#H_PUTFIELD}, {@link Opcodes#H_PUTSTATIC}, {@link * Opcodes#H_INVOKEVIRTUAL}, {@link Opcodes#H_INVOKESTATIC}, {@link Opcodes#H_INVOKESPECIAL}, * {@link Opcodes#H_NEWINVOKESPECIAL} or {@link Opcodes#H_INVOKEINTERFACE}. - * @param owner the internal name of the field or method owner class. + * @param owner the internal name of the field or method owner class (see {@link + * Type#getInternalName()}). * @param name the name of the field or method. * @param descriptor the descriptor of the field or method. * @param isInterface true if the owner is an interface. @@ -978,7 +980,7 @@ public int newInvokeDynamic( * constant pool already contains a similar item. This method is intended for {@link Attribute} * sub classes, and is normally not needed by class generators or adapters. * - * @param owner the internal name of the field's owner class. + * @param owner the internal name of the field's owner class (see {@link Type#getInternalName()}). * @param name the field's name. * @param descriptor the field's descriptor. * @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 * constant pool already contains a similar item. This method is intended for {@link Attribute} * sub classes, and is normally not needed by class generators or adapters. * - * @param owner the internal name of the method's owner class. + * @param owner the internal name of the method's owner class (see {@link + * Type#getInternalName()}). * @param name the method's name. * @param descriptor the method's descriptor. * @param isInterface {@literal true} if {@code owner} is an interface. @@ -1028,9 +1031,10 @@ public int newNameType(final String name, final String descriptor) { * currently being generated by this ClassWriter, which can of course not be loaded since it is * under construction. * - * @param type1 the internal name of a class. - * @param type2 the internal name of another class. - * @return the internal name of the common super class of the two given classes. + * @param type1 the internal name of a class (see {@link Type#getInternalName()}). + * @param type2 the internal name of another class (see {@link Type#getInternalName()}). + * @return the internal name of the common super class of the two given classes (see {@link + * Type#getInternalName()}). */ protected String getCommonSuperClass(final String type1, final String type2) { ClassLoader classLoader = getClassLoader(); diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Constants.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Constants.java index 629d52f35b..9e7b98c658 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Constants.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Constants.java @@ -26,6 +26,7 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF // THE POSSIBILITY OF SUCH DAMAGE. package jersey.repackaged.org.objectweb.asm; + import java.io.DataInputStream; import java.io.IOException; import java.io.InputStream; diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/FieldVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/FieldVisitor.java index 64865d6d9a..a75ad5f30b 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/FieldVisitor.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/FieldVisitor.java @@ -80,6 +80,15 @@ protected FieldVisitor(final int api, final FieldVisitor fieldVisitor) { this.fv = fieldVisitor; } + /** + * The field visitor to which this visitor must delegate method calls. May be {@literal null}. + * + * @return the field visitor to which this visitor must delegate method calls, or {@literal null}. + */ + public FieldVisitor getDelegate() { + return fv; + } + /** * Visits an annotation of the field. * diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handle.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handle.java index 69188e0efa..60aeb0fd04 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handle.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Handle.java @@ -65,7 +65,7 @@ public final class Handle { * {@link Opcodes#H_INVOKESPECIAL}, {@link Opcodes#H_NEWINVOKESPECIAL} or {@link * Opcodes#H_INVOKEINTERFACE}. * @param owner the internal name of the class that owns the field or method designated by this - * handle. + * handle (see {@link Type#getInternalName()}). * @param name the name of the field or method designated by this handle. * @param descriptor the descriptor of the field or method designated by this handle. * @deprecated this constructor has been superseded by {@link #Handle(int, String, String, String, @@ -85,7 +85,7 @@ public Handle(final int tag, final String owner, final String name, final String * {@link Opcodes#H_INVOKESPECIAL}, {@link Opcodes#H_NEWINVOKESPECIAL} or {@link * Opcodes#H_INVOKEINTERFACE}. * @param owner the internal name of the class that owns the field or method designated by this - * handle. + * handle (see {@link Type#getInternalName()}). * @param name the name of the field or method designated by this handle. * @param descriptor the descriptor of the field or method designated by this handle. * @param isInterface whether the owner is an interface or not. @@ -118,7 +118,8 @@ public int getTag() { /** * Returns the internal name of the class that owns the field or method designated by this handle. * - * @return the internal name of the class that owns the field or method designated by this handle. + * @return the internal name of the class that owns the field or method designated by this handle + * (see {@link Type#getInternalName()}). */ public String getOwner() { return owner; diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodTooLargeException.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodTooLargeException.java index 5ce29f4ea2..303579bdb1 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodTooLargeException.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodTooLargeException.java @@ -44,7 +44,7 @@ public final class MethodTooLargeException extends IndexOutOfBoundsException { /** * Constructs a new {@link MethodTooLargeException}. * - * @param className the internal name of the owner class. + * @param className the internal name of the owner class (see {@link Type#getInternalName()}). * @param methodName the name of the method. * @param descriptor the descriptor of the method. * @param codeSize the size of the method's Code attribute, in bytes. @@ -64,7 +64,7 @@ public MethodTooLargeException( /** * Returns the internal name of the owner class. * - * @return the internal name of the owner class. + * @return the internal name of the owner class (see {@link Type#getInternalName()}). */ public String getClassName() { return className; diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java index 805aed5017..269b034d93 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/MethodVisitor.java @@ -96,6 +96,16 @@ protected MethodVisitor(final int api, final MethodVisitor methodVisitor) { this.mv = methodVisitor; } + /** + * The method visitor to which this visitor must delegate method calls. May be {@literal null}. + * + * @return the method visitor to which this visitor must delegate method calls, or {@literal + * null}. + */ + public MethodVisitor getDelegate() { + return mv; + } + // ----------------------------------------------------------------------------------------------- // Parameters, annotations and non standard attributes // ----------------------------------------------------------------------------------------------- @@ -122,7 +132,7 @@ public void visitParameter(final String name, final int access) { * @return a visitor to the visit the actual default value of this annotation interface method, or * {@literal null} if this visitor is not interested in visiting this default value. The * 'name' parameters passed to the methods of this annotation visitor are ignored. Moreover, - * exacly one visit method must be called on this annotation visitor, followed by visitEnd. + * exactly one visit method must be called on this annotation visitor, followed by visitEnd. */ public AnnotationVisitor visitAnnotationDefault() { if (mv != null) { @@ -275,15 +285,17 @@ public void visitCode() { * @param type the type of this stack map frame. Must be {@link Opcodes#F_NEW} for expanded * frames, or {@link Opcodes#F_FULL}, {@link Opcodes#F_APPEND}, {@link Opcodes#F_CHOP}, {@link * Opcodes#F_SAME} or {@link Opcodes#F_APPEND}, {@link Opcodes#F_SAME1} for compressed frames. - * @param numLocal the number of local variables in the visited frame. + * @param numLocal the number of local variables in the visited frame. Long and double values + * count for one variable. * @param local the local variable types in this frame. This array must not be modified. Primitive * types are represented by {@link Opcodes#TOP}, {@link Opcodes#INTEGER}, {@link * Opcodes#FLOAT}, {@link Opcodes#LONG}, {@link Opcodes#DOUBLE}, {@link Opcodes#NULL} or * {@link Opcodes#UNINITIALIZED_THIS} (long and double are represented by a single element). - * Reference types are represented by String objects (representing internal names), and - * uninitialized types by Label objects (this label designates the NEW instruction that - * created this uninitialized value). - * @param numStack the number of operand stack elements in the visited frame. + * Reference types are represented by String objects (representing internal names, see {@link + * Type#getInternalName()}), and uninitialized types by Label objects (this label designates + * the NEW instruction that created this uninitialized value). + * @param numStack the number of operand stack elements in the visited frame. Long and double + * values count for one stack element. * @param stack the operand stack types in this frame. This array must not be modified. Its * content has the same format as the "local" array. * @throws IllegalStateException if a frame is visited just after another one, without any @@ -362,7 +374,7 @@ public void visitVarInsn(final int opcode, final int varIndex) { /** * Visits a type instruction. A type instruction is an instruction that takes the internal name of - * a class as parameter. + * a class as parameter (see {@link Type#getInternalName()}). * * @param opcode the opcode of the type instruction to be visited. This opcode is either NEW, * ANEWARRAY, CHECKCAST or INSTANCEOF. @@ -645,8 +657,9 @@ public AnnotationVisitor visitInsnAnnotation( * @param start the beginning of the exception handler's scope (inclusive). * @param end the end of the exception handler's scope (exclusive). * @param handler the beginning of the exception handler's code. - * @param type the internal name of the type of exceptions handled by the handler, or {@literal - * null} to catch any exceptions (for "finally" blocks). + * @param type the internal name of the type of exceptions handled by the handler (see {@link + * Type#getInternalName()}), or {@literal null} to catch any exceptions (for "finally" + * blocks). * @throws IllegalArgumentException if one of the labels has already been visited by this visitor * (by the {@link #visitLabel} method). */ diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java index 96675909fa..aba02832fe 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/ModuleVisitor.java @@ -82,10 +82,21 @@ protected ModuleVisitor(final int api, final ModuleVisitor moduleVisitor) { this.mv = moduleVisitor; } + /** + * The module visitor to which this visitor must delegate method calls. May be {@literal null}. + * + * @return the module visitor to which this visitor must delegate method calls, or {@literal + * null}. + */ + public ModuleVisitor getDelegate() { + return mv; + } + /** * Visit the main class of the current module. * - * @param mainClass the internal name of the main class of the current module. + * @param mainClass the internal name of the main class of the current module (see {@link + * Type#getInternalName()}). */ public void visitMainClass(final String mainClass) { if (mv != null) { @@ -96,7 +107,7 @@ public void visitMainClass(final String mainClass) { /** * Visit a package of the current module. * - * @param packaze the internal name of a package. + * @param packaze the internal name of a package (see {@link Type#getInternalName()}). */ public void visitPackage(final String packaze) { if (mv != null) { @@ -121,7 +132,7 @@ public void visitRequire(final String module, final int access, final String ver /** * Visit an exported package of the current module. * - * @param packaze the internal name of the exported package. + * @param packaze the internal name of the exported package (see {@link Type#getInternalName()}). * @param access the access flag of the exported package, valid values are among {@code * ACC_SYNTHETIC} and {@code ACC_MANDATED}. * @param modules the fully qualified names (using dots) of the modules that can access the public @@ -136,7 +147,7 @@ public void visitExport(final String packaze, final int access, final String... /** * Visit an open package of the current module. * - * @param packaze the internal name of the opened package. + * @param packaze the internal name of the opened package (see {@link Type#getInternalName()}). * @param access the access flag of the opened package, valid values are among {@code * ACC_SYNTHETIC} and {@code ACC_MANDATED}. * @param modules the fully qualified names (using dots) of the modules that can use deep @@ -152,7 +163,7 @@ public void visitOpen(final String packaze, final int access, final String... mo * Visit a service used by the current module. The name must be the internal name of an interface * or a class. * - * @param service the internal name of the service. + * @param service the internal name of the service (see {@link Type#getInternalName()}). */ public void visitUse(final String service) { if (mv != null) { @@ -163,9 +174,9 @@ public void visitUse(final String service) { /** * Visit an implementation of a service. * - * @param service the internal name of the service. - * @param providers the internal names of the implementations of the service (there is at least - * one provider). + * @param service the internal name of the service (see {@link Type#getInternalName()}). + * @param providers the internal names (see {@link Type#getInternalName()}) of the implementations + * of the service (there is at least one provider). */ public void visitProvide(final String service, final String... providers) { if (mv != null) { diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java index 0a591eccd8..63963b05c3 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Opcodes.java @@ -285,6 +285,7 @@ public interface Opcodes { int V17 = 0 << 16 | 61; int V18 = 0 << 16 | 62; int V19 = 0 << 16 | 63; + int V20 = 0 << 16 | 64; /** * Version flag indicating that the class is using 'preview' features. diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/RecordComponentVisitor.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/RecordComponentVisitor.java index 65cf92c9c8..e753339dc6 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/RecordComponentVisitor.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/RecordComponentVisitor.java @@ -45,7 +45,7 @@ public abstract class RecordComponentVisitor { /** * The record visitor to which this visitor must delegate method calls. May be {@literal null}. */ - /*package-private*/ RecordComponentVisitor delegate; + protected RecordComponentVisitor delegate; /** * Constructs a new {@link RecordComponentVisitor}. @@ -85,7 +85,8 @@ protected RecordComponentVisitor( /** * The record visitor to which this visitor must delegate method calls. May be {@literal null}. * - * @return the record visitor to which this visitor must delegate method calls or {@literal null}. + * @return the record visitor to which this visitor must delegate method calls, or {@literal + * null}. */ public RecordComponentVisitor getDelegate() { return delegate; diff --git a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java index ab8687e4e8..6808aba692 100644 --- a/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java +++ b/core-server/src/main/java/jersey/repackaged/org/objectweb/asm/Type.java @@ -245,7 +245,7 @@ public Type getElementType() { /** * Returns the {@link Type} corresponding to the given internal name. * - * @param internalName an internal name. + * @param internalName an internal name (see {@link Type#getInternalName()}). * @return the {@link Type} corresponding to the given internal name. */ public static Type getObjectType(final String internalName) { diff --git a/core-server/src/main/resources/META-INF/NOTICE.markdown b/core-server/src/main/resources/META-INF/NOTICE.markdown index 9399ca7152..f06adebb15 100644 --- a/core-server/src/main/resources/META-INF/NOTICE.markdown +++ b/core-server/src/main/resources/META-INF/NOTICE.markdown @@ -36,7 +36,7 @@ org.glassfish.jersey.server.internal.monitoring.core * Copyright (c) 2015-2018 Oracle and/or its affiliates. All rights reserved. * Copyright 2010-2013 Coda Hale and Yammer, Inc. -org.objectweb.asm Version 9.3 +org.objectweb.asm Version 9.4 * License: Modified BSD (https://asm.ow2.io/license.html) * Copyright: (c) 2000-2011 INRIA, France Telecom. All rights reserved. diff --git a/pom.xml b/pom.xml index 0f08664574..793b80f331 100644 --- a/pom.xml +++ b/pom.xml @@ -2148,7 +2148,7 @@ ${project.version} - 9.3 + 9.4 2.3.6 2.11.0 3.3.2 From afb7e63e441ead9d2b8239a896742f4b9b28fab5 Mon Sep 17 00:00:00 2001 From: Jorge Bescos Gascon Date: Tue, 11 Oct 2022 07:48:04 +0200 Subject: [PATCH 2/2] ASM test fixes Signed-off-by: Jorge Bescos Gascon --- .../internal/scanning/AnnotationAcceptingListener.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/core-server/src/main/java/org/glassfish/jersey/server/internal/scanning/AnnotationAcceptingListener.java b/core-server/src/main/java/org/glassfish/jersey/server/internal/scanning/AnnotationAcceptingListener.java index df41359f48..420db8f3c7 100644 --- a/core-server/src/main/java/org/glassfish/jersey/server/internal/scanning/AnnotationAcceptingListener.java +++ b/core-server/src/main/java/org/glassfish/jersey/server/internal/scanning/AnnotationAcceptingListener.java @@ -276,6 +276,12 @@ public AnnotationVisitor visitTypeAnnotation( return null; } + @Override + public ClassVisitor getDelegate() { + //do nothing + return null; + } + private Class getClassForName(final String className) { try { final OsgiRegistry osgiRegistry = ReflectionHelper.getOsgiRegistryInstance(); @@ -303,7 +309,7 @@ private Class getClassForName(final String className) { private static class ClassReaderWrapper { private static final Logger LOGGER = Logger.getLogger(ClassReader.class.getName()); - private static final int WARN_VERSION = Opcodes.V19; + private static final int WARN_VERSION = Opcodes.V20; private static final int INPUT_STREAM_DATA_CHUNK_SIZE = 4096; private final byte[] b;