SPRING PATCH: no preview mode check for ASM 9 experimental, enabling it by default. */ - @Deprecated int ASM8_EXPERIMENTAL = 1 << 24 | 8 << 16 | 0 << 8; + int ASM9_EXPERIMENTAL = 1 << 24 | 9 << 16 | 0 << 8; /* * Internal flags used to redirect calls to deprecated methods. For instance, if a visitOldStuff @@ -323,6 +323,7 @@ public interface Opcodes { // access flags, and also to make sure that these flags are automatically filtered out when // written in class files (because access flags are stored using 16 bits only). + int ACC_RECORD = 0x10000; // class int ACC_DEPRECATED = 0x20000; // class, field, method // Possible values for the type operand of the NEWARRAY instruction. diff --git a/spring-core/src/main/java/org/springframework/asm/RecordComponentVisitor.java b/spring-core/src/main/java/org/springframework/asm/RecordComponentVisitor.java index 0112bd5adbb..60db34c9c58 100644 --- a/spring-core/src/main/java/org/springframework/asm/RecordComponentVisitor.java +++ b/spring-core/src/main/java/org/springframework/asm/RecordComponentVisitor.java @@ -34,13 +34,11 @@ package org.springframework.asm; * * @author Remi Forax * @author Eric Bruneton - * @deprecated this API is experimental. */ -@Deprecated public abstract class RecordComponentVisitor { /** * The ASM API version implemented by this visitor. The value of this field must be {@link - * Opcodes#ASM8_EXPERIMENTAL}. + * Opcodes#ASM8}. */ protected final int api; @@ -52,11 +50,8 @@ public abstract class RecordComponentVisitor { /** * Constructs a new {@link RecordComponentVisitor}. * - * @param api the ASM API version implemented by this visitor. Must be {@link - * Opcodes#ASM8_EXPERIMENTAL}. - * @deprecated this API is experimental. + * @param api the ASM API version implemented by this visitor. Must be {@link Opcodes#ASM8}. */ - @Deprecated public RecordComponentVisitor(final int api) { this(api, null); } @@ -64,23 +59,21 @@ public abstract class RecordComponentVisitor { /** * Constructs a new {@link RecordComponentVisitor}. * - * @param api the ASM API version implemented by this visitor. Must be {@link - * Opcodes#ASM8_EXPERIMENTAL}. + * @param api the ASM API version implemented by this visitor. Must be {@link Opcodes#ASM8}. * @param recordComponentVisitor the record component visitor to which this visitor must delegate * method calls. May be null. - * @deprecated this API is experimental. */ - @Deprecated public RecordComponentVisitor( final int api, final RecordComponentVisitor recordComponentVisitor) { - if (api != Opcodes.ASM7 + if (api != Opcodes.ASM8 + && api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4 - && api != Opcodes.ASM8_EXPERIMENTAL) { + && api != Opcodes.ASM9_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } - // SPRING PATCH: no preview mode check for ASM 8 experimental + // SPRING PATCH: no preview mode check for ASM 9 experimental this.api = api; this.delegate = recordComponentVisitor; } @@ -89,10 +82,8 @@ public abstract class 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}. - * @deprecated this API is experimental. */ - @Deprecated - public RecordComponentVisitor getDelegateExperimental() { + public RecordComponentVisitor getDelegate() { return delegate; } @@ -103,13 +94,10 @@ public abstract class RecordComponentVisitor { * @param visible {@literal true} if the annotation is visible at runtime. * @return a visitor to visit the annotation values, or {@literal null} if this visitor is not * interested in visiting this annotation. - * @deprecated this API is experimental. */ - @Deprecated - public AnnotationVisitor visitAnnotationExperimental( - final String descriptor, final boolean visible) { + public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) { if (delegate != null) { - return delegate.visitAnnotationExperimental(descriptor, visible); + return delegate.visitAnnotation(descriptor, visible); } return null; } @@ -128,13 +116,11 @@ public abstract class RecordComponentVisitor { * @param visible {@literal true} if the annotation is visible at runtime. * @return a visitor to visit the annotation values, or {@literal null} if this visitor is not * interested in visiting this annotation. - * @deprecated this API is experimental. */ - @Deprecated - public AnnotationVisitor visitTypeAnnotationExperimental( + public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { if (delegate != null) { - return delegate.visitTypeAnnotationExperimental(typeRef, typePath, descriptor, visible); + return delegate.visitTypeAnnotation(typeRef, typePath, descriptor, visible); } return null; } @@ -143,25 +129,20 @@ public abstract class RecordComponentVisitor { * Visits a non standard attribute of the record component. * * @param attribute an attribute. - * @deprecated this API is experimental. */ - @Deprecated - public void visitAttributeExperimental(final Attribute attribute) { + public void visitAttribute(final Attribute attribute) { if (delegate != null) { - delegate.visitAttributeExperimental(attribute); + delegate.visitAttribute(attribute); } } /** * Visits the end of the record component. This method, which is the last one to be called, is * used to inform the visitor that everything have been visited. - * - * @deprecated this API is experimental. */ - @Deprecated - public void visitEndExperimental() { + public void visitEnd() { if (delegate != null) { - delegate.visitEndExperimental(); + delegate.visitEnd(); } } } diff --git a/spring-core/src/main/java/org/springframework/asm/RecordComponentWriter.java b/spring-core/src/main/java/org/springframework/asm/RecordComponentWriter.java index c775fc4bd8f..98687e60df9 100644 --- a/spring-core/src/main/java/org/springframework/asm/RecordComponentWriter.java +++ b/spring-core/src/main/java/org/springframework/asm/RecordComponentWriter.java @@ -27,19 +27,12 @@ // THE POSSIBILITY OF SUCH DAMAGE. package org.springframework.asm; -@SuppressWarnings("deprecation") final class RecordComponentWriter extends RecordComponentVisitor { /** Where the constants used in this RecordComponentWriter must be stored. */ private final SymbolTable symbolTable; - // Note: fields are ordered as in the component_info structure, and those related to attributes - // are ordered as in Section TODO of the JVMS. - // The field accessFlag doesn't exist in the component_info structure but is used to carry - // ACC_DEPRECATED which is represented by an attribute in the structure and as an access flag by - // ASM. - - /** The access_flags field can only be {@link Opcodes#ACC_DEPRECATED}. */ - private final int accessFlags; + // Note: fields are ordered as in the record_component_info structure, and those related to + // attributes are ordered as in Section 4.7 of the JVMS. /** The name_index field of the Record attribute. */ private final int nameIndex; @@ -82,10 +75,9 @@ final class RecordComponentWriter extends RecordComponentVisitor { * the {@link Attribute#nextAttribute} field. May be {@literal null}. * *
WARNING: this list stores the attributes in the reverse order of their visit. - * firstAttribute is actually the last attribute visited in {@link - * #visitAttributeExperimental(Attribute)}. The {@link #putRecordComponentInfo(ByteVector)} method - * writes the attributes in the order defined by this list, i.e. in the reverse order specified by - * the user. + * firstAttribute is actually the last attribute visited in {@link #visitAttribute(Attribute)}. + * The {@link #putRecordComponentInfo(ByteVector)} method writes the attributes in the order + * defined by this list, i.e. in the reverse order specified by the user. */ private Attribute firstAttribute; @@ -93,20 +85,17 @@ final class RecordComponentWriter extends RecordComponentVisitor { * Constructs a new {@link RecordComponentWriter}. * * @param symbolTable where the constants used in this RecordComponentWriter must be stored. - * @param accessFlags the record component access flags, only synthetic and/or deprecated. * @param name the record component name. * @param descriptor the record component descriptor (see {@link Type}). * @param signature the record component signature. May be {@literal null}. */ RecordComponentWriter( final SymbolTable symbolTable, - final int accessFlags, final String name, final String descriptor, final String signature) { - super(/* latest api = */ Opcodes.ASM7); + super(/* latest api = */ Opcodes.ASM8); this.symbolTable = symbolTable; - this.accessFlags = accessFlags; this.nameIndex = symbolTable.addConstantUtf8(name); this.descriptorIndex = symbolTable.addConstantUtf8(descriptor); if (signature != null) { @@ -119,8 +108,7 @@ final class RecordComponentWriter extends RecordComponentVisitor { // ----------------------------------------------------------------------------------------------- @Override - public AnnotationVisitor visitAnnotationExperimental( - final String descriptor, final boolean visible) { + public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) { if (visible) { return lastRuntimeVisibleAnnotation = AnnotationWriter.create(symbolTable, descriptor, lastRuntimeVisibleAnnotation); @@ -131,7 +119,7 @@ final class RecordComponentWriter extends RecordComponentVisitor { } @Override - public AnnotationVisitor visitTypeAnnotationExperimental( + public AnnotationVisitor visitTypeAnnotation( final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) { if (visible) { return lastRuntimeVisibleTypeAnnotation = @@ -145,14 +133,14 @@ final class RecordComponentWriter extends RecordComponentVisitor { } @Override - public void visitAttributeExperimental(final Attribute attribute) { + public void visitAttribute(final Attribute attribute) { // Store the attributes in the reverse order of their visit by this method. attribute.nextAttribute = firstAttribute; firstAttribute = attribute; } @Override - public void visitEndExperimental() { + public void visitEnd() { // Nothing to do. } @@ -170,9 +158,7 @@ final class RecordComponentWriter extends RecordComponentVisitor { int computeRecordComponentInfoSize() { // name_index, descriptor_index and attributes_count fields use 6 bytes. int size = 6; - size += - Attribute.computeAttributesSize( - symbolTable, accessFlags & Opcodes.ACC_DEPRECATED, signatureIndex); + size += Attribute.computeAttributesSize(symbolTable, 0, signatureIndex); size += AnnotationWriter.computeAnnotationsSize( lastRuntimeVisibleAnnotation, @@ -199,9 +185,6 @@ final class RecordComponentWriter extends RecordComponentVisitor { if (signatureIndex != 0) { ++attributesCount; } - if ((accessFlags & Opcodes.ACC_DEPRECATED) != 0) { - ++attributesCount; - } if (lastRuntimeVisibleAnnotation != null) { ++attributesCount; } @@ -218,7 +201,7 @@ final class RecordComponentWriter extends RecordComponentVisitor { attributesCount += firstAttribute.getAttributeCount(); } output.putShort(attributesCount); - Attribute.putAttributes(symbolTable, accessFlags, signatureIndex, output); + Attribute.putAttributes(symbolTable, 0, signatureIndex, output); AnnotationWriter.putAnnotations( symbolTable, lastRuntimeVisibleAnnotation, diff --git a/spring-core/src/main/java/org/springframework/asm/SpringAsmInfo.java b/spring-core/src/main/java/org/springframework/asm/SpringAsmInfo.java index 85972c56075..aa34d8d470d 100644 --- a/spring-core/src/main/java/org/springframework/asm/SpringAsmInfo.java +++ b/spring-core/src/main/java/org/springframework/asm/SpringAsmInfo.java @@ -18,7 +18,7 @@ package org.springframework.asm; /** * Utility class exposing constants related to Spring's internal repackaging - * of the ASM bytecode library: currently based on ASM 7.x plus minor patches. + * of the ASM bytecode library: currently based on ASM 8.x plus minor patches. * *
See package-level javadocs for more * information on {@code org.springframework.asm}. @@ -31,9 +31,8 @@ public final class SpringAsmInfo { /** * The ASM compatibility version for Spring's ASM visitor implementations: - * currently {@link Opcodes#ASM8_EXPERIMENTAL}, as of Spring Framework 5.2.5. + * currently {@link Opcodes#ASM9_EXPERIMENTAL}, as of Spring Framework 5.3. */ - @SuppressWarnings("deprecation") - public static final int ASM_VERSION = Opcodes.ASM8_EXPERIMENTAL; + public static final int ASM_VERSION = Opcodes.ASM9_EXPERIMENTAL; } diff --git a/spring-core/src/main/java/org/springframework/asm/SymbolTable.java b/spring-core/src/main/java/org/springframework/asm/SymbolTable.java index c2142392d0e..e4c4a8461e7 100644 --- a/spring-core/src/main/java/org/springframework/asm/SymbolTable.java +++ b/spring-core/src/main/java/org/springframework/asm/SymbolTable.java @@ -31,11 +31,11 @@ package org.springframework.asm; * The constant pool entries, the BootstrapMethods attribute entries and the (ASM specific) type * table entries of a class. * + * @author Eric Bruneton * @see JVMS * 4.4 * @see JVMS * 4.7.23 - * @author Eric Bruneton */ final class SymbolTable { @@ -1046,8 +1046,10 @@ final class SymbolTable { // bootstrap methods. We must therefore add the bootstrap method arguments to the constant pool // and BootstrapMethods attribute first, so that the BootstrapMethods attribute is not modified // while adding the given bootstrap method to it, in the rest of this method. - for (Object bootstrapMethodArgument : bootstrapMethodArguments) { - addConstant(bootstrapMethodArgument); + int numBootstrapArguments = bootstrapMethodArguments.length; + int[] bootstrapMethodArgumentIndexes = new int[numBootstrapArguments]; + for (int i = 0; i < numBootstrapArguments; i++) { + bootstrapMethodArgumentIndexes[i] = addConstant(bootstrapMethodArguments[i]).index; } // Write the bootstrap method in the BootstrapMethods table. This is necessary to be able to @@ -1062,10 +1064,10 @@ final class SymbolTable { bootstrapMethodHandle.getDesc(), bootstrapMethodHandle.isInterface()) .index); - int numBootstrapArguments = bootstrapMethodArguments.length; + bootstrapMethodsAttribute.putShort(numBootstrapArguments); - for (Object bootstrapMethodArgument : bootstrapMethodArguments) { - bootstrapMethodsAttribute.putShort(addConstant(bootstrapMethodArgument).index); + for (int i = 0; i < numBootstrapArguments; i++) { + bootstrapMethodsAttribute.putShort(bootstrapMethodArgumentIndexes[i]); } // Compute the length and the hash code of the bootstrap method. diff --git a/spring-core/src/main/java/org/springframework/asm/package-info.java b/spring-core/src/main/java/org/springframework/asm/package-info.java index 85f6ccbfd79..b1ae94438ce 100644 --- a/spring-core/src/main/java/org/springframework/asm/package-info.java +++ b/spring-core/src/main/java/org/springframework/asm/package-info.java @@ -1,6 +1,6 @@ /** * Spring's repackaging of - * ASM 7.0 + * ASM 8.1 * (with Spring-specific patches; for internal use only). * *
This repackaging technique avoids any potential conflicts with