From cd9eb575e736284dbd09ee5b4dff2cef062407ee Mon Sep 17 00:00:00 2001 From: forax Date: Fri, 4 Oct 2019 23:32:58 +0200 Subject: [PATCH 1/8] add ASM8_EXPERIMENTAL API + support of PermittedSubtypes attribute --- .../objectweb/asm/commons/ClassRemapper.java | 5 +++ .../org/objectweb/asm/tree/ClassNode.java | 17 ++++++++++ .../org/objectweb/asm/tree/ClassNodeTest.java | 3 ++ .../java/org/objectweb/asm/util/ASMifier.java | 9 +++++ .../objectweb/asm/util/CheckClassAdapter.java | 7 ++++ .../java/org/objectweb/asm/util/Printer.java | 10 ++++++ .../objectweb/asm/util/TraceClassVisitor.java | 6 ++++ .../org/objectweb/asm/util/PrinterTest.java | 11 ++++++ .../org/objectweb/asm/AnnotationVisitor.java | 9 ++++- .../java/org/objectweb/asm/ClassReader.java | 14 ++++++++ .../java/org/objectweb/asm/ClassVisitor.java | 30 +++++++++++++--- .../java/org/objectweb/asm/ClassWriter.java | 29 ++++++++++++++++ .../java/org/objectweb/asm/Constants.java | 34 +++++++++++++++++++ .../java/org/objectweb/asm/FieldVisitor.java | 9 ++++- .../java/org/objectweb/asm/MethodVisitor.java | 9 ++++- .../java/org/objectweb/asm/ModuleVisitor.java | 9 ++++- .../main/java/org/objectweb/asm/Opcodes.java | 8 +++++ .../asm/signature/SignatureVisitor.java | 6 +++- .../org/objectweb/asm/ClassReaderTest.java | 3 ++ .../org/objectweb/asm/ClassWriterTest.java | 2 ++ .../java/org/objectweb/asm/ConstantsTest.java | 1 + .../org/objectweb/asm/MethodWriterTest.java | 3 +- 22 files changed, 224 insertions(+), 10 deletions(-) diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java index 4860b8271..339dfb76d 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java @@ -204,6 +204,11 @@ public class ClassRemapper extends ClassVisitor { super.visitNestMember(remapper.mapType(nestMember)); } + @Override + public void visitPermittedSubtype(final String permittedSubtype) { + super.visitPermittedSubtype(remapper.mapType(permittedSubtype)); + } + /** * Constructs a new remapper for fields. The default implementation of this method returns a new * {@link FieldRemapper}. diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java index 97dd1c693..5b964f82f 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java @@ -126,6 +126,9 @@ public class ClassNode extends ClassVisitor { /** The internal names of the nest members of this class. May be {@literal null}. */ public List nestMembers; + /** The internal names of the permitted subtypes of this class. May be {@literal null}. */ + public List permittedSubtypes; + /** The fields of this class. */ public List fields; @@ -236,6 +239,11 @@ public class ClassNode extends ClassVisitor { nestMembers = Util.add(nestMembers, nestMember); } + @Override + public void visitPermittedSubtype(final String permittedSubtype) { + permittedSubtypes = Util.add(permittedSubtypes, permittedSubtype); + } + @Override public void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { @@ -285,6 +293,9 @@ public class ClassNode extends ClassVisitor { * {@link Opcodes#ASM6} or {@link Opcodes#ASM7}. */ public void check(final int api) { + if (api != Opcodes.ASM8_EXPERIMENTAL && permittedSubtypes != null) { + throw new UnsupportedClassVersionException(); + } if (api < Opcodes.ASM7 && (nestHostClass != null || nestMembers != null)) { throw new UnsupportedClassVersionException(); } @@ -395,6 +406,12 @@ public class ClassNode extends ClassVisitor { classVisitor.visitNestMember(nestMembers.get(i)); } } + // Visit the permitted subtypes. + if (permittedSubtypes != null) { + for (int i = 0, n = permittedSubtypes.size(); i < n; ++i) { + classVisitor.visitPermittedSubtype(permittedSubtypes.get(i)); + } + } // Visit the inner classes. for (int i = 0, n = innerClasses.size(); i < n; ++i) { innerClasses.get(i).accept(classVisitor); diff --git a/asm-tree/src/test/java/org/objectweb/asm/tree/ClassNodeTest.java b/asm-tree/src/test/java/org/objectweb/asm/tree/ClassNodeTest.java index 2cf2a144c..cd1328eef 100644 --- a/asm-tree/src/test/java/org/objectweb/asm/tree/ClassNodeTest.java +++ b/asm-tree/src/test/java/org/objectweb/asm/tree/ClassNodeTest.java @@ -221,6 +221,9 @@ public class ClassNodeTest extends AsmTest { @Override public void visitNestMember(final String nestMember) {} + @Override + public void visitPermittedSubtype(final String permittedSubtype) {} + @Override public void visitAttribute(final Attribute attribute) {} } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java b/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java index f459eddc4..8953c04ab 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java @@ -320,6 +320,15 @@ public class ASMifier extends Printer { text.add(stringBuilder.toString()); } + @Override + public void visitPermittedSubtype(final String visitPermittedSubtype) { + stringBuilder.setLength(0); + stringBuilder.append("classWriter.visitPermittedSubtype("); + appendConstant(visitPermittedSubtype); + stringBuilder.append(END_PARAMETERS); + text.add(stringBuilder.toString()); + } + @Override public void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java index 11792a0cd..d1c53eae4 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java @@ -319,6 +319,13 @@ public class CheckClassAdapter extends ClassVisitor { super.visitNestMember(nestMember); } + @Override + public void visitPermittedSubtype(final String permittedSubtype) { + checkState(); + CheckMethodAdapter.checkInternalName(version, permittedSubtype, "permittedSubtype"); + super.visitPermittedSubtype(permittedSubtype); + } + @Override public void visitOuterClass(final String owner, final String name, final String descriptor) { checkState(); diff --git a/asm-util/src/main/java/org/objectweb/asm/util/Printer.java b/asm-util/src/main/java/org/objectweb/asm/util/Printer.java index 93f6e35a5..1ddff983b 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/Printer.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/Printer.java @@ -452,6 +452,16 @@ public abstract class Printer { throw new UnsupportedOperationException(UNSUPPORTED_OPERATION); } + /** + * Visits a permitted subtypes. A permitted subtypes is one of the allowed subtypes of the current + * class. + * + * @param permittedSubtype the internal name of a permitted subtype. + */ + public void visitPermittedSubtype(final String permittedSubtype) { + throw new UnsupportedOperationException(UNSUPPORTED_OPERATION); + } + /** * Class inner name. See {@link org.objectweb.asm.ClassVisitor#visitInnerClass}. * diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java index cf9fa51e2..48a29bc3d 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java @@ -186,6 +186,12 @@ public final class TraceClassVisitor extends ClassVisitor { super.visitNestMember(nestMember); } + @Override + public void visitPermittedSubtype(final String permittedSubtype) { + p.visitPermittedSubtype(permittedSubtype); + super.visitPermittedSubtype(permittedSubtype); + } + @Override public void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { diff --git a/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java b/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java index 9c6072a94..72dab0e71 100644 --- a/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java +++ b/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java @@ -88,6 +88,17 @@ public class PrinterTest { assertEquals(UNSUPPORTED_OPERATION_MESSAGE, exception.getMessage()); } + /* Experimental feature for now + @Test + public void testVisitPermittedSubtype_unsupportedByDefault() { + Printer printer = new EmptyPrinter(Opcodes.ASM8_EXPERIMENTAL); + + Executable visitPermittedSubtype = () -> printer.visitPermittedSubtype(null); + + Exception exception = assertThrows(UnsupportedOperationException.class, visitPermittedSubtype); + assertEquals(UNSUPPORTED_OPERATION_MESSAGE, exception.getMessage()); + }*/ + @Test public void testVisitMainClass_unsupportedByDefault() { Printer printer = new EmptyPrinter(Opcodes.ASM7); diff --git a/asm/src/main/java/org/objectweb/asm/AnnotationVisitor.java b/asm/src/main/java/org/objectweb/asm/AnnotationVisitor.java index 63d536071..92f7feb07 100644 --- a/asm/src/main/java/org/objectweb/asm/AnnotationVisitor.java +++ b/asm/src/main/java/org/objectweb/asm/AnnotationVisitor.java @@ -68,9 +68,16 @@ public abstract class AnnotationVisitor { * calls. May be {@literal null}. */ public AnnotationVisitor(final int api, final AnnotationVisitor annotationVisitor) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } this.api = api; this.av = annotationVisitor; } diff --git a/asm/src/main/java/org/objectweb/asm/ClassReader.java b/asm/src/main/java/org/objectweb/asm/ClassReader.java index 8ebc7a237..5b1f1309f 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassReader.java +++ b/asm/src/main/java/org/objectweb/asm/ClassReader.java @@ -466,6 +466,8 @@ public class ClassReader { String nestHostClass = null; // - The offset of the NestMembers attribute, or 0. int nestMembersOffset = 0; + // - The offset of the PermittedSubtypes attribute, or 0 + int permittedSubtypesOffset = 0; // - The non standard attributes (linked with their {@link Attribute#nextAttribute} field). // This list in the reverse order or their order in the ClassFile structure. Attribute attributes = null; @@ -488,6 +490,8 @@ public class ClassReader { nestHostClass = readClass(currentAttributeOffset, charBuffer); } else if (Constants.NEST_MEMBERS.equals(attributeName)) { nestMembersOffset = currentAttributeOffset; + } else if (Constants.PERMITTED_SUBTYPES.equals(attributeName)) { + permittedSubtypesOffset = currentAttributeOffset; } else if (Constants.SIGNATURE.equals(attributeName)) { signature = readUTF8(currentAttributeOffset, charBuffer); } else if (Constants.RUNTIME_VISIBLE_ANNOTATIONS.equals(attributeName)) { @@ -662,6 +666,16 @@ public class ClassReader { } } + // Visit the PermittedSubtypes attribute. + if (permittedSubtypesOffset != 0) { + int numberOfPermittedSubtypes = readUnsignedShort(permittedSubtypesOffset); + int currentPermittedSubtypeOffset = permittedSubtypesOffset + 2; + while (numberOfPermittedSubtypes-- > 0) { + classVisitor.visitPermittedSubtype(readClass(currentPermittedSubtypeOffset, charBuffer)); + currentPermittedSubtypeOffset += 2; + } + } + // Visit the InnerClasses attribute. if (innerClassesOffset != 0) { int numberOfClasses = readUnsignedShort(innerClassesOffset); diff --git a/asm/src/main/java/org/objectweb/asm/ClassVisitor.java b/asm/src/main/java/org/objectweb/asm/ClassVisitor.java index 0c3d2decc..3dee2c2a3 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassVisitor.java +++ b/asm/src/main/java/org/objectweb/asm/ClassVisitor.java @@ -30,9 +30,9 @@ package org.objectweb.asm; /** * A visitor to visit a Java class. The methods of this class must be called in the following order: * {@code visit} [ {@code visitSource} ] [ {@code visitModule} ][ {@code visitNestHost} ][ {@code - * visitOuterClass} ] ( {@code visitAnnotation} | {@code visitTypeAnnotation} | {@code - * visitAttribute} )* ( {@code visitNestMember} | {@code visitInnerClass} | {@code visitField} | - * {@code visitMethod} )* {@code visitEnd}. + * visitPermittedSubtype} ][ {@code visitOuterClass} ] ( {@code visitAnnotation} | {@code + * visitTypeAnnotation} | {@code visitAttribute} )* ( {@code visitNestMember} | {@code + * visitInnerClass} | {@code visitField} | {@code visitMethod} )* {@code visitEnd}. * * @author Eric Bruneton */ @@ -66,9 +66,16 @@ public abstract class ClassVisitor { * null. */ public ClassVisitor(final int api, final ClassVisitor classVisitor) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } this.api = api; this.cv = classVisitor; } @@ -240,6 +247,21 @@ public abstract class ClassVisitor { } } + /** + * Visits a permitted subtypes. A permitted subtypes is one of the allowed subtypes of the current + * class. + * + * @param permittedSubtype the internal name of a permitted subtype. + */ + public void visitPermittedSubtype(final String permittedSubtype) { + if (api != Opcodes.ASM8_EXPERIMENTAL) { + throw new UnsupportedOperationException("This feature requires ASM8_EXPERIMENTAL"); + } + if (cv != null) { + cv.visitPermittedSubtype(permittedSubtype); + } + } + /** * Visits information about an inner class. This inner class is not necessarily a member of the * class being visited. diff --git a/asm/src/main/java/org/objectweb/asm/ClassWriter.java b/asm/src/main/java/org/objectweb/asm/ClassWriter.java index d18797418..163bc0b92 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassWriter.java +++ b/asm/src/main/java/org/objectweb/asm/ClassWriter.java @@ -177,6 +177,12 @@ public class ClassWriter extends ClassVisitor { /** The 'classes' array of the NestMembers attribute, or {@literal null}. */ private ByteVector nestMemberClasses; + /** The number_of_classes field of the PermittedSubtypes attribute, or 0. */ + private int numberOfPermittedSubtypeClasses; + + /** The 'classes' array of the PermittedSubtypes attribute, or {@literal null}. */ + private ByteVector permittedSubtypeClasses; + /** * The first non standard attribute of this class. The next ones can be accessed with the {@link * Attribute#nextAttribute} field. May be {@literal null}. @@ -352,6 +358,15 @@ public class ClassWriter extends ClassVisitor { nestMemberClasses.putShort(symbolTable.addConstantClass(nestMember).index); } + @Override + public final void visitPermittedSubtype(final String permittedSubtype) { + if (permittedSubtypeClasses == null) { + permittedSubtypeClasses = new ByteVector(); + } + ++numberOfPermittedSubtypeClasses; + permittedSubtypeClasses.putShort(symbolTable.addConstantClass(permittedSubtype).index); + } + @Override public final void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { @@ -526,6 +541,11 @@ public class ClassWriter extends ClassVisitor { size += 8 + nestMemberClasses.length; symbolTable.addConstantUtf8(Constants.NEST_MEMBERS); } + if (permittedSubtypeClasses != null) { + ++attributesCount; + size += 8 + permittedSubtypeClasses.length; + symbolTable.addConstantUtf8(Constants.PERMITTED_SUBTYPES); + } if (firstAttribute != null) { attributesCount += firstAttribute.getAttributeCount(); size += firstAttribute.computeAttributesSize(symbolTable); @@ -630,6 +650,13 @@ public class ClassWriter extends ClassVisitor { .putShort(numberOfNestMemberClasses) .putByteArray(nestMemberClasses.data, 0, nestMemberClasses.length); } + if (permittedSubtypeClasses != null) { + result + .putShort(symbolTable.addConstantUtf8(Constants.PERMITTED_SUBTYPES)) + .putInt(permittedSubtypeClasses.length + 2) + .putShort(numberOfPermittedSubtypeClasses) + .putByteArray(permittedSubtypeClasses.data, 0, permittedSubtypeClasses.length); + } if (firstAttribute != null) { firstAttribute.putAttributes(symbolTable, result); } @@ -666,6 +693,8 @@ public class ClassWriter extends ClassVisitor { nestHostClassIndex = 0; numberOfNestMemberClasses = 0; nestMemberClasses = null; + numberOfPermittedSubtypeClasses = 0; + permittedSubtypeClasses = null; firstAttribute = null; compute = hasFrames ? MethodWriter.COMPUTE_INSERTED_FRAMES : MethodWriter.COMPUTE_NOTHING; new ClassReader(classFile, 0, /* checkClassVersion = */ false) diff --git a/asm/src/main/java/org/objectweb/asm/Constants.java b/asm/src/main/java/org/objectweb/asm/Constants.java index 26db7e9c8..5ab99792b 100644 --- a/asm/src/main/java/org/objectweb/asm/Constants.java +++ b/asm/src/main/java/org/objectweb/asm/Constants.java @@ -27,6 +27,10 @@ // THE POSSIBILITY OF SUCH DAMAGE. package org.objectweb.asm; +import java.io.DataInputStream; +import java.io.IOException; +import java.io.InputStream; + /** * Defines additional JVM opcodes, access flags and constants which are not part of the ASM public * API. @@ -68,6 +72,7 @@ final class Constants implements Opcodes { static final String MODULE_MAIN_CLASS = "ModuleMainClass"; static final String NEST_HOST = "NestHost"; static final String NEST_MEMBERS = "NestMembers"; + static final String PERMITTED_SUBTYPES = "PermittedSubtypes"; // ASM specific access flags. // WARNING: the 16 least significant bits must NOT be used, to avoid conflicts with standard @@ -174,4 +179,33 @@ final class Constants implements Opcodes { static final int ASM_GOTO_W = 220; private Constants() {} + + static void checkAsm8Experimental(final Object caller) { + Class callerClass = caller.getClass(); + String callerClassResource = callerClass.getName().replace('.', '/') + ".class"; + InputStream inputStream = callerClass.getClassLoader().getResourceAsStream(callerClassResource); + if (inputStream == null) { + throw new IllegalStateException("Bytecode not available, can't check class version"); + } + int minorVersion; + try { + DataInputStream callerClassStream = new DataInputStream(inputStream); + try { + callerClassStream.readInt(); + minorVersion = callerClassStream.readUnsignedShort(); + } catch (IOException ioe) { + throw new IllegalStateException("i/O error, can't check class version", ioe); + } + } finally { + try { + inputStream.close(); + } catch (IOException e) { + inputStream = null; // PMD rule should allow an empty block if there is a comment in it + } + } + if (minorVersion != 0xFFFF) { + throw new IllegalStateException( + "ASM8_EXPERIMENTAL can only be used by classes compiled with --enable-preview"); + } + } } diff --git a/asm/src/main/java/org/objectweb/asm/FieldVisitor.java b/asm/src/main/java/org/objectweb/asm/FieldVisitor.java index 2371baa44..797651c3c 100644 --- a/asm/src/main/java/org/objectweb/asm/FieldVisitor.java +++ b/asm/src/main/java/org/objectweb/asm/FieldVisitor.java @@ -64,9 +64,16 @@ public abstract class FieldVisitor { * null. */ public FieldVisitor(final int api, final FieldVisitor fieldVisitor) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } this.api = api; this.fv = fieldVisitor; } diff --git a/asm/src/main/java/org/objectweb/asm/MethodVisitor.java b/asm/src/main/java/org/objectweb/asm/MethodVisitor.java index fadfd6a43..fa5cc2f5b 100644 --- a/asm/src/main/java/org/objectweb/asm/MethodVisitor.java +++ b/asm/src/main/java/org/objectweb/asm/MethodVisitor.java @@ -80,9 +80,16 @@ public abstract class MethodVisitor { * be null. */ public MethodVisitor(final int api, final MethodVisitor methodVisitor) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } this.api = api; this.mv = methodVisitor; } diff --git a/asm/src/main/java/org/objectweb/asm/ModuleVisitor.java b/asm/src/main/java/org/objectweb/asm/ModuleVisitor.java index dced10ba1..0aec7ded6 100644 --- a/asm/src/main/java/org/objectweb/asm/ModuleVisitor.java +++ b/asm/src/main/java/org/objectweb/asm/ModuleVisitor.java @@ -66,9 +66,16 @@ public abstract class ModuleVisitor { * be null. */ public ModuleVisitor(final int api, final ModuleVisitor moduleVisitor) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } + if (api == Opcodes.ASM8_EXPERIMENTAL) { + Constants.checkAsm8Experimental(this); + } this.api = api; this.mv = moduleVisitor; } diff --git a/asm/src/main/java/org/objectweb/asm/Opcodes.java b/asm/src/main/java/org/objectweb/asm/Opcodes.java index ef25ea5a3..e11867a77 100644 --- a/asm/src/main/java/org/objectweb/asm/Opcodes.java +++ b/asm/src/main/java/org/objectweb/asm/Opcodes.java @@ -48,6 +48,14 @@ public interface Opcodes { int ASM6 = 6 << 16 | 0 << 8; int ASM7 = 7 << 16 | 0 << 8; + /** + * Experimental, use at your own risk. This field will be renamed when it becomes stable, this + * will break existing code using it. Only code compiled with --enable-preview can use this. + * + * @deprecated This API is experimental. + */ + @Deprecated int ASM8_EXPERIMENTAL = 1 << 24 | 8 << 16 | 0 << 8; + /* * Internal flags used to redirect calls to deprecated methods. For instance, if a visitOldStuff * method in API_OLD is deprecated and replaced with visitNewStuff in API_NEW, then the diff --git a/asm/src/main/java/org/objectweb/asm/signature/SignatureVisitor.java b/asm/src/main/java/org/objectweb/asm/signature/SignatureVisitor.java index 4b1f2b62b..f2d21862d 100644 --- a/asm/src/main/java/org/objectweb/asm/signature/SignatureVisitor.java +++ b/asm/src/main/java/org/objectweb/asm/signature/SignatureVisitor.java @@ -72,7 +72,11 @@ public abstract class SignatureVisitor { * Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}. */ public SignatureVisitor(final int api) { - if (api != Opcodes.ASM7 && api != Opcodes.ASM6 && api != Opcodes.ASM5 && api != Opcodes.ASM4) { + if (api != Opcodes.ASM7 + && api != Opcodes.ASM6 + && api != Opcodes.ASM5 + && api != Opcodes.ASM4 + && api != Opcodes.ASM8_EXPERIMENTAL) { throw new IllegalArgumentException("Unsupported api " + api); } this.api = api; diff --git a/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java b/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java index 0be0442d1..51893c2b8 100644 --- a/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java +++ b/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java @@ -398,6 +398,9 @@ public class ClassReaderTest extends AsmTest implements Opcodes { @Override public void visitNestMember(final String nestMember) {} + + @Override + public void visitPermittedSubtype(final String permittedSubtype) {} }; Executable accept = () -> classReader.accept(classVisitor, 0); diff --git a/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java b/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java index 99dcc81e6..0ecab7ae7 100644 --- a/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java +++ b/asm/src/test/java/org/objectweb/asm/ClassWriterTest.java @@ -105,6 +105,8 @@ public class ClassWriterTest extends AsmTest { "nestHostClassIndex", "numberOfNestMemberClasses", "nestMemberClasses", + "numberOfPermittedSubtypeClasses", + "permittedSubtypeClasses", "firstAttribute", "compute")); // IMPORTANT: if this fails, update the string list AND update the logic that resets the diff --git a/asm/src/test/java/org/objectweb/asm/ConstantsTest.java b/asm/src/test/java/org/objectweb/asm/ConstantsTest.java index 4fa80bcd7..295933580 100644 --- a/asm/src/test/java/org/objectweb/asm/ConstantsTest.java +++ b/asm/src/test/java/org/objectweb/asm/ConstantsTest.java @@ -175,6 +175,7 @@ public class ConstantsTest { case "ASM5": case "ASM6": case "ASM7": + case "ASM8_EXPERIMENTAL": return ConstantType.ASM_VERSION; case "V_PREVIEW": case "V1_1": diff --git a/asm/src/test/java/org/objectweb/asm/MethodWriterTest.java b/asm/src/test/java/org/objectweb/asm/MethodWriterTest.java index c3fa04879..ba8179f2c 100644 --- a/asm/src/test/java/org/objectweb/asm/MethodWriterTest.java +++ b/asm/src/test/java/org/objectweb/asm/MethodWriterTest.java @@ -92,7 +92,8 @@ public class MethodWriterTest { Constants.MODULE_PACKAGES, Constants.MODULE_MAIN_CLASS, Constants.NEST_HOST, - Constants.NEST_MEMBERS)); + Constants.NEST_MEMBERS, + Constants.PERMITTED_SUBTYPES)); // IMPORTANT: if this fails, update the list AND update MethodWriter.canCopyMethodAttributes(), // if needed. assertEquals(expectedAttributes, actualAttributes); -- GitLab From 5f2351ae1a9ebbc4148b5fa539a5591bac7e0438 Mon Sep 17 00:00:00 2001 From: forax Date: Sun, 6 Oct 2019 12:43:49 +0200 Subject: [PATCH 2/8] Add the suffix experimental and marke the method as @Deprecated --- .../java/org/objectweb/asm/commons/ClassRemapper.java | 4 ++-- .../main/java/org/objectweb/asm/tree/ClassNode.java | 4 ++-- .../java/org/objectweb/asm/tree/ClassNodeTest.java | 2 +- .../main/java/org/objectweb/asm/util/ASMifier.java | 2 +- .../org/objectweb/asm/util/CheckClassAdapter.java | 4 ++-- .../src/main/java/org/objectweb/asm/util/Printer.java | 9 ++++++--- .../org/objectweb/asm/util/TraceClassVisitor.java | 6 +++--- asm/src/main/java/org/objectweb/asm/ClassReader.java | 3 ++- asm/src/main/java/org/objectweb/asm/ClassVisitor.java | 11 +++++++---- asm/src/main/java/org/objectweb/asm/ClassWriter.java | 2 +- .../test/java/org/objectweb/asm/ClassReaderTest.java | 2 +- 11 files changed, 28 insertions(+), 21 deletions(-) diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java index 339dfb76d..fc0de3ed9 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java @@ -205,8 +205,8 @@ public class ClassRemapper extends ClassVisitor { } @Override - public void visitPermittedSubtype(final String permittedSubtype) { - super.visitPermittedSubtype(remapper.mapType(permittedSubtype)); + public void visitPermittedSubtypeExperimental(final String permittedSubtype) { + super.visitPermittedSubtypeExperimental(remapper.mapType(permittedSubtype)); } /** diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java index 5b964f82f..139bdc592 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java @@ -240,7 +240,7 @@ public class ClassNode extends ClassVisitor { } @Override - public void visitPermittedSubtype(final String permittedSubtype) { + public void visitPermittedSubtypeExperimental(final String permittedSubtype) { permittedSubtypes = Util.add(permittedSubtypes, permittedSubtype); } @@ -409,7 +409,7 @@ public class ClassNode extends ClassVisitor { // Visit the permitted subtypes. if (permittedSubtypes != null) { for (int i = 0, n = permittedSubtypes.size(); i < n; ++i) { - classVisitor.visitPermittedSubtype(permittedSubtypes.get(i)); + classVisitor.visitPermittedSubtypeExperimental(permittedSubtypes.get(i)); } } // Visit the inner classes. diff --git a/asm-tree/src/test/java/org/objectweb/asm/tree/ClassNodeTest.java b/asm-tree/src/test/java/org/objectweb/asm/tree/ClassNodeTest.java index cd1328eef..0b9985fdd 100644 --- a/asm-tree/src/test/java/org/objectweb/asm/tree/ClassNodeTest.java +++ b/asm-tree/src/test/java/org/objectweb/asm/tree/ClassNodeTest.java @@ -222,7 +222,7 @@ public class ClassNodeTest extends AsmTest { public void visitNestMember(final String nestMember) {} @Override - public void visitPermittedSubtype(final String permittedSubtype) {} + public void visitPermittedSubtypeExperimental(final String permittedSubtype) {} @Override public void visitAttribute(final Attribute attribute) {} diff --git a/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java b/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java index 8953c04ab..e8921bcc2 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java @@ -321,7 +321,7 @@ public class ASMifier extends Printer { } @Override - public void visitPermittedSubtype(final String visitPermittedSubtype) { + public void visitPermittedSubtypeExperimental(final String visitPermittedSubtype) { stringBuilder.setLength(0); stringBuilder.append("classWriter.visitPermittedSubtype("); appendConstant(visitPermittedSubtype); diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java index d1c53eae4..529e516d7 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java @@ -320,10 +320,10 @@ public class CheckClassAdapter extends ClassVisitor { } @Override - public void visitPermittedSubtype(final String permittedSubtype) { + public void visitPermittedSubtypeExperimental(final String permittedSubtype) { checkState(); CheckMethodAdapter.checkInternalName(version, permittedSubtype, "permittedSubtype"); - super.visitPermittedSubtype(permittedSubtype); + super.visitPermittedSubtypeExperimental(permittedSubtype); } @Override diff --git a/asm-util/src/main/java/org/objectweb/asm/util/Printer.java b/asm-util/src/main/java/org/objectweb/asm/util/Printer.java index 1ddff983b..9889540e7 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/Printer.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/Printer.java @@ -453,12 +453,15 @@ public abstract class Printer { } /** - * Visits a permitted subtypes. A permitted subtypes is one of the allowed subtypes of the current - * class. + * Experimental, use at your own risk. This method will be renamed when it becomes stable, this + * will break existing code using it. Visits a permitted subtypes. A permitted subtypes is one + * of the allowed subtypes of the current class. * * @param permittedSubtype the internal name of a permitted subtype. + * @deprecated this API is experimental. */ - public void visitPermittedSubtype(final String permittedSubtype) { + @Deprecated + public void visitPermittedSubtypeExperimental(final String permittedSubtype) { throw new UnsupportedOperationException(UNSUPPORTED_OPERATION); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java index 48a29bc3d..32cb007ac 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java @@ -187,9 +187,9 @@ public final class TraceClassVisitor extends ClassVisitor { } @Override - public void visitPermittedSubtype(final String permittedSubtype) { - p.visitPermittedSubtype(permittedSubtype); - super.visitPermittedSubtype(permittedSubtype); + public void visitPermittedSubtypeExperimental(final String permittedSubtype) { + p.visitPermittedSubtypeExperimental(permittedSubtype); + super.visitPermittedSubtypeExperimental(permittedSubtype); } @Override diff --git a/asm/src/main/java/org/objectweb/asm/ClassReader.java b/asm/src/main/java/org/objectweb/asm/ClassReader.java index 5b1f1309f..a7520739a 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassReader.java +++ b/asm/src/main/java/org/objectweb/asm/ClassReader.java @@ -671,7 +671,8 @@ public class ClassReader { int numberOfPermittedSubtypes = readUnsignedShort(permittedSubtypesOffset); int currentPermittedSubtypeOffset = permittedSubtypesOffset + 2; while (numberOfPermittedSubtypes-- > 0) { - classVisitor.visitPermittedSubtype(readClass(currentPermittedSubtypeOffset, charBuffer)); + classVisitor.visitPermittedSubtypeExperimental( + readClass(currentPermittedSubtypeOffset, charBuffer)); currentPermittedSubtypeOffset += 2; } } diff --git a/asm/src/main/java/org/objectweb/asm/ClassVisitor.java b/asm/src/main/java/org/objectweb/asm/ClassVisitor.java index 3dee2c2a3..5fd79987e 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassVisitor.java +++ b/asm/src/main/java/org/objectweb/asm/ClassVisitor.java @@ -248,17 +248,20 @@ public abstract class ClassVisitor { } /** - * Visits a permitted subtypes. A permitted subtypes is one of the allowed subtypes of the current - * class. + * Experimental, use at your own risk. This method will be renamed when it becomes stable, this + * will break existing code using it. Visits a permitted subtypes. A permitted subtypes is one + * of the allowed subtypes of the current class. * * @param permittedSubtype the internal name of a permitted subtype. + * @deprecated this API is experimental. */ - public void visitPermittedSubtype(final String permittedSubtype) { + @Deprecated + public void visitPermittedSubtypeExperimental(final String permittedSubtype) { if (api != Opcodes.ASM8_EXPERIMENTAL) { throw new UnsupportedOperationException("This feature requires ASM8_EXPERIMENTAL"); } if (cv != null) { - cv.visitPermittedSubtype(permittedSubtype); + cv.visitPermittedSubtypeExperimental(permittedSubtype); } } diff --git a/asm/src/main/java/org/objectweb/asm/ClassWriter.java b/asm/src/main/java/org/objectweb/asm/ClassWriter.java index 163bc0b92..1b054f564 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassWriter.java +++ b/asm/src/main/java/org/objectweb/asm/ClassWriter.java @@ -359,7 +359,7 @@ public class ClassWriter extends ClassVisitor { } @Override - public final void visitPermittedSubtype(final String permittedSubtype) { + public final void visitPermittedSubtypeExperimental(final String permittedSubtype) { if (permittedSubtypeClasses == null) { permittedSubtypeClasses = new ByteVector(); } diff --git a/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java b/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java index 51893c2b8..6648817d0 100644 --- a/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java +++ b/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java @@ -400,7 +400,7 @@ public class ClassReaderTest extends AsmTest implements Opcodes { public void visitNestMember(final String nestMember) {} @Override - public void visitPermittedSubtype(final String permittedSubtype) {} + public void visitPermittedSubtypeExperimental(final String permittedSubtype) {} }; Executable accept = () -> classReader.accept(classVisitor, 0); -- GitLab From f39f60a77e7bd111316a3969e9fdb1ace0dba7f3 Mon Sep 17 00:00:00 2001 From: forax Date: Mon, 7 Oct 2019 00:49:46 +0200 Subject: [PATCH 3/8] finish the support of permitted subtypes --- .../asm/tree/analysis/BasicInterpreter.java | 2 +- .../asm/tree/analysis/BasicVerifier.java | 2 +- .../asm/tree/analysis/SimpleVerifier.java | 2 +- .../asm/tree/analysis/SourceInterpreter.java | 2 +- .../asm/tree/analysis/AnalyzerTest.java | 2 +- .../AnalyzerWithBasicInterpreterTest.java | 2 +- .../asm/tree/analysis/SimpleVerifierTest.java | 7 +-- .../asm/commons/AnalyzerAdapter.java | 2 +- .../asm/commons/AnnotationRemapper.java | 2 +- .../objectweb/asm/commons/ClassRemapper.java | 2 +- .../asm/commons/CodeSizeEvaluator.java | 2 +- .../objectweb/asm/commons/FieldRemapper.java | 2 +- .../asm/commons/GeneratorAdapter.java | 2 +- .../asm/commons/InstructionAdapter.java | 4 +- .../asm/commons/JSRInlinerAdapter.java | 2 +- .../asm/commons/LocalVariablesSorter.java | 2 +- .../objectweb/asm/commons/MethodRemapper.java | 2 +- .../objectweb/asm/commons/ModuleRemapper.java | 2 +- .../asm/commons/SerialVersionUIDAdder.java | 2 +- .../asm/commons/SignatureRemapper.java | 2 +- .../asm/commons/StaticInitMerger.java | 2 +- .../asm/commons/TryCatchBlockSorter.java | 2 +- .../asm/commons/AdviceAdapterTest.java | 6 +-- .../asm/commons/AnalyzerAdapterTest.java | 2 +- .../asm/commons/ClassRemapperTest.java | 2 +- .../asm/commons/GeneratorAdapterTest.java | 7 ++- .../asm/commons/InstructionAdapterTest.java | 4 +- .../asm/commons/LocalVariablesSorterTest.java | 2 +- .../commons/ModuleHashesAttributeTest.java | 4 +- .../ModuleResolutionAttributeTest.java | 4 +- .../commons/ModuleTargetAttributeTest.java | 4 +- .../commons/SerialVersionUidAdderTest.java | 2 +- .../java/org/objectweb/asm/test/AsmTest.java | 31 +++++++++---- .../org/objectweb/asm/test/ClassFile.java | 18 ++++++++ .../jdk14/AllStructures$ClassSubType.class | Bin 0 -> 309 bytes .../jdk14/AllStructures$RecordSubType.class | Bin 0 -> 1829 bytes .../main/resources/jdk14/AllStructures.class | Bin 0 -> 318 bytes .../resources/java/jdk14/AllStructures.java | 37 +++++++++++++++ .../org/objectweb/asm/test/AsmTestTest.java | 2 +- .../objectweb/asm/tree/AnnotationNode.java | 4 +- .../org/objectweb/asm/tree/FieldNode.java | 2 +- .../asm/tree/LocalVariableAnnotationNode.java | 2 +- .../org/objectweb/asm/tree/MethodNode.java | 6 +-- .../org/objectweb/asm/tree/ModuleNode.java | 2 +- .../asm/tree/TypeAnnotationNode.java | 2 +- .../asm/tree/AnnotationNodeTest.java | 3 +- .../org/objectweb/asm/tree/InsnListTest.java | 4 +- .../objectweb/asm/tree/ModuleNodeTest.java | 5 +- .../java/org/objectweb/asm/util/ASMifier.java | 11 ++++- .../asm/util/CheckAnnotationAdapter.java | 2 +- .../objectweb/asm/util/CheckClassAdapter.java | 11 +++-- .../objectweb/asm/util/CheckFieldAdapter.java | 2 +- .../asm/util/CheckMethodAdapter.java | 4 +- .../asm/util/CheckModuleAdapter.java | 2 +- .../asm/util/CheckSignatureAdapter.java | 2 +- .../org/objectweb/asm/util/Textifier.java | 14 +++++- .../asm/util/TraceAnnotationVisitor.java | 2 +- .../objectweb/asm/util/TraceClassVisitor.java | 2 +- .../objectweb/asm/util/TraceFieldVisitor.java | 2 +- .../asm/util/TraceMethodVisitor.java | 2 +- .../asm/util/TraceModuleVisitor.java | 2 +- .../asm/util/TraceSignatureVisitor.java | 4 +- .../asm/util/CheckClassAdapterTest.java | 3 +- .../org/objectweb/asm/util/PrinterTest.java | 43 +++++++++--------- .../asm/util/SignaturesProviders.java | 3 +- .../test/resources/jdk14.AllStructures.txt | 14 ++++++ .../org/objectweb/asm/AnnotationWriter.java | 2 +- .../java/org/objectweb/asm/ClassReader.java | 1 + .../java/org/objectweb/asm/ClassWriter.java | 6 +-- .../java/org/objectweb/asm/Constants.java | 22 ++++----- .../java/org/objectweb/asm/FieldWriter.java | 2 +- .../java/org/objectweb/asm/MethodVisitor.java | 2 +- .../java/org/objectweb/asm/MethodWriter.java | 2 +- .../java/org/objectweb/asm/ModuleWriter.java | 2 +- .../main/java/org/objectweb/asm/Opcodes.java | 1 + .../org/objectweb/asm/ClassReaderTest.java | 10 ++-- .../org/objectweb/asm/ClassVisitorTest.java | 12 ++--- .../java/org/objectweb/asm/ConstantsTest.java | 7 ++- .../org/objectweb/asm/MethodVisitorTest.java | 4 +- .../asm/signature/SignatureReaderTest.java | 7 ++- .../asm/signature/SignaturesProviders.java | 3 +- .../asm/benchmarks/TypeBenchmark.java | 4 +- build.gradle | 1 + 83 files changed, 259 insertions(+), 160 deletions(-) create mode 100644 asm-test/src/main/resources/jdk14/AllStructures$ClassSubType.class create mode 100644 asm-test/src/main/resources/jdk14/AllStructures$RecordSubType.class create mode 100644 asm-test/src/main/resources/jdk14/AllStructures.class create mode 100644 asm-test/src/resources/java/jdk14/AllStructures.java create mode 100644 asm-util/src/test/resources/jdk14.AllStructures.txt diff --git a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicInterpreter.java b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicInterpreter.java index e82b29136..f82fe3e76 100644 --- a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicInterpreter.java +++ b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicInterpreter.java @@ -61,7 +61,7 @@ public class BasicInterpreter extends Interpreter implements Opcodes * version. */ public BasicInterpreter() { - super(ASM7); + super(ASM8_EXPERIMENTAL); if (getClass() != BasicInterpreter.class) { throw new IllegalStateException(); } diff --git a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicVerifier.java b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicVerifier.java index 72f68937e..b91b2c80d 100644 --- a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicVerifier.java +++ b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicVerifier.java @@ -47,7 +47,7 @@ public class BasicVerifier extends BasicInterpreter { * use this constructor. Instead, they must use the {@link #BasicVerifier(int)} version. */ public BasicVerifier() { - super(ASM7); + super(ASM8_EXPERIMENTAL); if (getClass() != BasicVerifier.class) { throw new IllegalStateException(); } diff --git a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SimpleVerifier.java b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SimpleVerifier.java index 351af441e..f6fa56100 100644 --- a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SimpleVerifier.java +++ b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SimpleVerifier.java @@ -93,7 +93,7 @@ public class SimpleVerifier extends BasicVerifier { final Type currentSuperClass, final List currentClassInterfaces, final boolean isInterface) { - this(ASM7, currentClass, currentSuperClass, currentClassInterfaces, isInterface); + this(ASM8_EXPERIMENTAL, currentClass, currentSuperClass, currentClassInterfaces, isInterface); if (getClass() != SimpleVerifier.class) { throw new IllegalStateException(); } diff --git a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SourceInterpreter.java b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SourceInterpreter.java index 4bdbd2a9f..10c20f978 100644 --- a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SourceInterpreter.java +++ b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SourceInterpreter.java @@ -51,7 +51,7 @@ public class SourceInterpreter extends Interpreter implements Opcod * version. */ public SourceInterpreter() { - super(ASM7); + super(ASM8_EXPERIMENTAL); if (getClass() != SourceInterpreter.class) { throw new IllegalStateException(); } diff --git a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerTest.java b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerTest.java index 32ea8780c..3771718b9 100644 --- a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerTest.java +++ b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerTest.java @@ -1173,7 +1173,7 @@ public class AnalyzerTest extends AsmTest { private static class MockInterpreter extends Interpreter { MockInterpreter() { - super(Opcodes.ASM7); + super(LATEST_API); } @Override diff --git a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java index 3741e074f..c80f4d213 100644 --- a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java +++ b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java @@ -125,7 +125,7 @@ public class AnalyzerWithBasicInterpreterTest extends AsmTest { new ClassReader(PrecompiledClass.JDK8_ALL_FRAMES.getBytes()).accept(classNode, 0); Analyzer analyzer = new Analyzer( - new BasicInterpreter(Opcodes.ASM7) { + new BasicInterpreter(LATEST_API) { @Override public BasicValue merge(final BasicValue value1, final BasicValue value2) { return new BasicValue(super.merge(value1, value2).getType()); diff --git a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java index 95bf87a7e..cd8783b5b 100644 --- a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java +++ b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java @@ -37,8 +37,8 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; -import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; +import org.objectweb.asm.test.AsmTest; /** * Unit tests for {@link SimpleVerifier}. @@ -81,7 +81,8 @@ public class SimpleVerifierTest { Type superType = Type.getObjectType("D"); Type interfaceType = Type.getObjectType("I"); SimpleVerifier simpleVerifier = - new SimpleVerifier(Opcodes.ASM7, baseType, superType, Arrays.asList(interfaceType), false) { + new SimpleVerifier( + AsmTest.LATEST_API, baseType, superType, Arrays.asList(interfaceType), false) { @Override public boolean isAssignableFrom(final Type type1, final Type type2) { @@ -114,7 +115,7 @@ public class SimpleVerifierTest { Type baseType = Type.getObjectType("C"); Type interfaceType = Type.getObjectType("I"); SimpleVerifier simpleVerifier = - new SimpleVerifier(Opcodes.ASM7, interfaceType, null, null, true) { + new SimpleVerifier(AsmTest.LATEST_API, interfaceType, null, null, true) { @Override protected Type getSuperClass(final Type type) { diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/AnalyzerAdapter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/AnalyzerAdapter.java index 2e4412bc1..84e7f475c 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/AnalyzerAdapter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/AnalyzerAdapter.java @@ -116,7 +116,7 @@ public class AnalyzerAdapter extends MethodVisitor { final String name, final String descriptor, final MethodVisitor methodVisitor) { - this(Opcodes.ASM7, owner, access, name, descriptor, methodVisitor); + this(Opcodes.ASM8_EXPERIMENTAL, owner, access, name, descriptor, methodVisitor); if (getClass() != AnalyzerAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/AnnotationRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/AnnotationRemapper.java index fd86b455a..39fb190e6 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/AnnotationRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/AnnotationRemapper.java @@ -49,7 +49,7 @@ public class AnnotationRemapper extends AnnotationVisitor { * @param remapper the remapper to use to remap the types in the visited annotation. */ public AnnotationRemapper(final AnnotationVisitor annotationVisitor, final Remapper remapper) { - this(Opcodes.ASM7, annotationVisitor, remapper); + this(Opcodes.ASM8_EXPERIMENTAL, annotationVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java index fc0de3ed9..5e1438e77 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java @@ -73,7 +73,7 @@ public class ClassRemapper extends ClassVisitor { * @param remapper the remapper to use to remap the types in the visited class. */ public ClassRemapper(final ClassVisitor classVisitor, final Remapper remapper) { - this(Opcodes.ASM7, classVisitor, remapper); + this(Opcodes.ASM8_EXPERIMENTAL, classVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/CodeSizeEvaluator.java b/asm-commons/src/main/java/org/objectweb/asm/commons/CodeSizeEvaluator.java index f9b4120e1..31e3d6a8c 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/CodeSizeEvaluator.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/CodeSizeEvaluator.java @@ -47,7 +47,7 @@ public class CodeSizeEvaluator extends MethodVisitor implements Opcodes { private int maxSize; public CodeSizeEvaluator(final MethodVisitor methodVisitor) { - this(Opcodes.ASM7, methodVisitor); + this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor); } protected CodeSizeEvaluator(final int api, final MethodVisitor methodVisitor) { diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/FieldRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/FieldRemapper.java index fd1936b62..c73555144 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/FieldRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/FieldRemapper.java @@ -51,7 +51,7 @@ public class FieldRemapper extends FieldVisitor { * @param remapper the remapper to use to remap the types in the visited field. */ public FieldRemapper(final FieldVisitor fieldVisitor, final Remapper remapper) { - this(Opcodes.ASM7, fieldVisitor, remapper); + this(Opcodes.ASM8_EXPERIMENTAL, fieldVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/GeneratorAdapter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/GeneratorAdapter.java index d5a5edddb..8d551e0a5 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/GeneratorAdapter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/GeneratorAdapter.java @@ -201,7 +201,7 @@ public class GeneratorAdapter extends LocalVariablesSorter { final int access, final String name, final String descriptor) { - this(Opcodes.ASM7, methodVisitor, access, name, descriptor); + this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor, access, name, descriptor); if (getClass() != GeneratorAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/InstructionAdapter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/InstructionAdapter.java index 3c58a672b..4a8801320 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/InstructionAdapter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/InstructionAdapter.java @@ -53,7 +53,7 @@ public class InstructionAdapter extends MethodVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public InstructionAdapter(final MethodVisitor methodVisitor) { - this(Opcodes.ASM7, methodVisitor); + this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor); if (getClass() != InstructionAdapter.class) { throw new IllegalStateException(); } @@ -621,7 +621,7 @@ public class InstructionAdapter extends MethodVisitor { || (value instanceof Type && ((Type) value).getSort() == Type.METHOD))) { throw new UnsupportedOperationException("This feature requires ASM5"); } - if (api != Opcodes.ASM7 && value instanceof ConstantDynamic) { + if (api < Opcodes.ASM7 && value instanceof ConstantDynamic) { throw new UnsupportedOperationException("This feature requires ASM7"); } if (value instanceof Integer) { diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/JSRInlinerAdapter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/JSRInlinerAdapter.java index eca5266fb..bb6d65d77 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/JSRInlinerAdapter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/JSRInlinerAdapter.java @@ -98,7 +98,7 @@ public class JSRInlinerAdapter extends MethodNode implements Opcodes { final String descriptor, final String signature, final String[] exceptions) { - this(Opcodes.ASM7, methodVisitor, access, name, descriptor, signature, exceptions); + this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor, access, name, descriptor, signature, exceptions); if (getClass() != JSRInlinerAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/LocalVariablesSorter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/LocalVariablesSorter.java index 73c0e0468..bb8aca456 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/LocalVariablesSorter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/LocalVariablesSorter.java @@ -81,7 +81,7 @@ public class LocalVariablesSorter extends MethodVisitor { */ public LocalVariablesSorter( final int access, final String descriptor, final MethodVisitor methodVisitor) { - this(Opcodes.ASM7, access, descriptor, methodVisitor); + this(Opcodes.ASM8_EXPERIMENTAL, access, descriptor, methodVisitor); if (getClass() != LocalVariablesSorter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/MethodRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/MethodRemapper.java index b54a54d10..fed27422c 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/MethodRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/MethodRemapper.java @@ -53,7 +53,7 @@ public class MethodRemapper extends MethodVisitor { * @param remapper the remapper to use to remap the types in the visited method. */ public MethodRemapper(final MethodVisitor methodVisitor, final Remapper remapper) { - this(Opcodes.ASM7, methodVisitor, remapper); + this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/ModuleRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/ModuleRemapper.java index 7792bbdbe..3baffbf9b 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/ModuleRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/ModuleRemapper.java @@ -49,7 +49,7 @@ public class ModuleRemapper extends ModuleVisitor { * @param remapper the remapper to use to remap the types in the visited module. */ public ModuleRemapper(final ModuleVisitor moduleVisitor, final Remapper remapper) { - this(Opcodes.ASM7, moduleVisitor, remapper); + this(Opcodes.ASM8_EXPERIMENTAL, moduleVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/SerialVersionUIDAdder.java b/asm-commons/src/main/java/org/objectweb/asm/commons/SerialVersionUIDAdder.java index 279f91edc..0a285235c 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/SerialVersionUIDAdder.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/SerialVersionUIDAdder.java @@ -150,7 +150,7 @@ public class SerialVersionUIDAdder extends ClassVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public SerialVersionUIDAdder(final ClassVisitor classVisitor) { - this(Opcodes.ASM7, classVisitor); + this(Opcodes.ASM8_EXPERIMENTAL, classVisitor); if (getClass() != SerialVersionUIDAdder.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/SignatureRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/SignatureRemapper.java index e3eb2d585..27e125fc7 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/SignatureRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/SignatureRemapper.java @@ -53,7 +53,7 @@ public class SignatureRemapper extends SignatureVisitor { * @param remapper the remapper to use to remap the types in the visited signature. */ public SignatureRemapper(final SignatureVisitor signatureVisitor, final Remapper remapper) { - this(Opcodes.ASM7, signatureVisitor, remapper); + this(Opcodes.ASM8_EXPERIMENTAL, signatureVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/StaticInitMerger.java b/asm-commons/src/main/java/org/objectweb/asm/commons/StaticInitMerger.java index db1da0497..8f9f232b2 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/StaticInitMerger.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/StaticInitMerger.java @@ -61,7 +61,7 @@ public class StaticInitMerger extends ClassVisitor { * null. */ public StaticInitMerger(final String prefix, final ClassVisitor classVisitor) { - this(Opcodes.ASM7, prefix, classVisitor); + this(Opcodes.ASM8_EXPERIMENTAL, prefix, classVisitor); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java index e245d2f67..45edf7b7b 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java @@ -70,7 +70,7 @@ public class TryCatchBlockSorter extends MethodNode { final String descriptor, final String signature, final String[] exceptions) { - this(Opcodes.ASM7, methodVisitor, access, name, descriptor, signature, exceptions); + this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor, access, name, descriptor, signature, exceptions); if (getClass() != TryCatchBlockSorter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/AdviceAdapterTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/AdviceAdapterTest.java index d6088872e..fc71769eb 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/AdviceAdapterTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/AdviceAdapterTest.java @@ -557,8 +557,8 @@ public class AdviceAdapterTest extends AsmTest { MethodNode outputMethod = new MethodNode(Opcodes.ACC_PUBLIC, "", "(I)V", null, null); AdviceAdapter adviceAdapter = new AdviceAdapter( - Opcodes.ASM7, - new MethodVisitor(Opcodes.ASM7, outputMethod) {}, + LATEST_API, + new MethodVisitor(LATEST_API, outputMethod) {}, Opcodes.ACC_PUBLIC, "", "()V") { @@ -616,7 +616,7 @@ public class AdviceAdapterTest extends AsmTest { private static class BasicAdviceAdapter extends AdviceAdapter { BasicAdviceAdapter(final MethodVisitor methodVisitor) { - super(Opcodes.ASM7, methodVisitor, Opcodes.ACC_PUBLIC, "", "(I)V"); + super(LATEST_API, methodVisitor, Opcodes.ACC_PUBLIC, "", "(I)V"); } @Override diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/AnalyzerAdapterTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/AnalyzerAdapterTest.java index e10754187..3a71e2de2 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/AnalyzerAdapterTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/AnalyzerAdapterTest.java @@ -181,7 +181,7 @@ public class AnalyzerAdapterTest extends AsmTest { private boolean hasOriginalFrame; AnalyzedFramesInserter(final MethodVisitor methodVisitor) { - super(Opcodes.ASM7, methodVisitor); + super(LATEST_API, methodVisitor); } void setAnalyzerAdapter(final AnalyzerAdapter analyzerAdapter) { diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/ClassRemapperTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/ClassRemapperTest.java index 106089145..a311fd194 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/ClassRemapperTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/ClassRemapperTest.java @@ -149,7 +149,7 @@ public class ClassRemapperTest extends AsmTest { ClassNode classNode = new ClassNode(); ClassRemapper classRemapper = new ClassRemapper( - Opcodes.ASM7, + LATEST_API, classNode, new Remapper() { @Override diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/GeneratorAdapterTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/GeneratorAdapterTest.java index 5007c1aec..44b1a07f6 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/GeneratorAdapterTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/GeneratorAdapterTest.java @@ -45,6 +45,7 @@ import org.objectweb.asm.Handle; import org.objectweb.asm.Label; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; +import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.util.Textifier; @@ -848,7 +849,7 @@ public class GeneratorAdapterTest { textifier = new Textifier(); generatorAdapter = new GeneratorAdapter( - Opcodes.ASM7, new TraceMethodVisitor(textifier), access, name, descriptor); + AsmTest.LATEST_API, new TraceMethodVisitor(textifier), access, name, descriptor); } public String push(final boolean value) { @@ -1221,9 +1222,7 @@ public class GeneratorAdapterTest { @Override public String toString() { String result = - textifier - .text - .stream() + textifier.text.stream() .map(text -> text.toString().trim()) .collect(Collectors.joining(" ")); textifier.text.clear(); diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/InstructionAdapterTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/InstructionAdapterTest.java index 0551ae6b2..14dab5198 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/InstructionAdapterTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/InstructionAdapterTest.java @@ -174,9 +174,7 @@ public class InstructionAdapterTest extends AsmTest { assertEquals( "ICONST_0 ICONST_1 ICONST_2 BIPUSH 51 ICONST_4 ICONST_5 LDC 6 LDC 7.0 LDC 8.0 LDC \"9\" " + "LDC Lpkg/Class;.class LDC pkg/Class.nameI (1)", - textifier - .text - .stream() + textifier.text.stream() .map(text -> text.toString().trim()) .collect(Collectors.joining(" "))); } diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/LocalVariablesSorterTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/LocalVariablesSorterTest.java index 79d53e029..d1911c56a 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/LocalVariablesSorterTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/LocalVariablesSorterTest.java @@ -218,7 +218,7 @@ public class LocalVariablesSorterTest extends AsmTest { new ClassReader(Files.newInputStream(Paths.get("src/test/resources/Issue317586.class"))); ClassWriter classWriter = new ClassWriter(0); ClassVisitor localVariablesSorter = - new LocalVariablesSorterClassAdapter(Opcodes.ASM7, classWriter); + new LocalVariablesSorterClassAdapter(LATEST_API, classWriter); classReader.accept(localVariablesSorter, ClassReader.EXPAND_FRAMES); diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleHashesAttributeTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleHashesAttributeTest.java index d305d5b03..dca377d28 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleHashesAttributeTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleHashesAttributeTest.java @@ -36,7 +36,7 @@ import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Opcodes; +import org.objectweb.asm.test.AsmTest; /** * Unit tests for {@link ModuleHashesAttribute}. @@ -60,7 +60,7 @@ public class ModuleHashesAttributeTest { ModuleHashesAttribute moduleHashesAttribute = new ModuleHashesAttribute(); new ClassReader(classWriter.toByteArray()) .accept( - new ClassVisitor(Opcodes.ASM7) { + new ClassVisitor(AsmTest.LATEST_API) { @Override public void visitAttribute(final Attribute attribute) { diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleResolutionAttributeTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleResolutionAttributeTest.java index ff0fc94f9..7ef1f8c52 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleResolutionAttributeTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleResolutionAttributeTest.java @@ -34,7 +34,7 @@ import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Opcodes; +import org.objectweb.asm.test.AsmTest; /** * Unit tests for {@link ModuleResolutionAttribute}. @@ -51,7 +51,7 @@ public class ModuleResolutionAttributeTest { ModuleResolutionAttribute moduleResolutionAttribute = new ModuleResolutionAttribute(); new ClassReader(classWriter.toByteArray()) .accept( - new ClassVisitor(Opcodes.ASM7) { + new ClassVisitor(AsmTest.LATEST_API) { @Override public void visitAttribute(final Attribute attribute) { diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleTargetAttributeTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleTargetAttributeTest.java index 9a4a86ba3..1cacb0e23 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleTargetAttributeTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleTargetAttributeTest.java @@ -34,7 +34,7 @@ import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.Opcodes; +import org.objectweb.asm.test.AsmTest; /** * Unit tests for {@link ModuleTargetAttribute}. @@ -51,7 +51,7 @@ public class ModuleTargetAttributeTest { ModuleTargetAttribute moduleTargetAttribute = new ModuleTargetAttribute(); new ClassReader(classWriter.toByteArray()) .accept( - new ClassVisitor(Opcodes.ASM7) { + new ClassVisitor(AsmTest.LATEST_API) { @Override public void visitAttribute(final Attribute attribute) { diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/SerialVersionUidAdderTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/SerialVersionUidAdderTest.java index 04f506b7e..3ff7d0f59 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/SerialVersionUidAdderTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/SerialVersionUidAdderTest.java @@ -122,7 +122,7 @@ public class SerialVersionUidAdderTest extends AsmTest { ClassReader classReader = new ClassReader(classParameter.getBytes()); ClassWriter classWriter = new ClassWriter(0); - classReader.accept(new SerialVersionUIDAdder(classWriter), 0); + classReader.accept(new SerialVersionUIDAdder(LATEST_API, classWriter), 0); if ((classReader.getAccess() & Opcodes.ACC_ENUM) == 0) { assertTrue(new ClassFile(classWriter.toByteArray()).toString().contains("serialVersionUID")); diff --git a/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java b/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java index ba37d1cb4..632c33445 100644 --- a/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java +++ b/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java @@ -92,7 +92,10 @@ public abstract class AsmTest { * The expected pattern (i.e. regular expression) that ASM's UnsupportedOperationException * messages are supposed to match. */ - public static final String UNSUPPORTED_OPERATION_MESSAGE_PATTERN = ".* requires ASM[567]"; + public static final String UNSUPPORTED_OPERATION_MESSAGE_PATTERN = ".* requires ASM[5678].*"; + + /** Value of the latest API. */ + public static final int LATEST_API = Api.ASM8.value(); /** * A precompiled class, hand-crafted to contain some set of class file structures. These classes @@ -122,7 +125,8 @@ public abstract class AsmTest { JDK9_MODULE("jdk9.module-info"), JDK11_ALL_INSTRUCTIONS("jdk11.AllInstructions"), JDK11_ALL_STRUCTURES("jdk11.AllStructures"), - JDK11_ALL_STRUCTURES_NESTED("jdk11.AllStructures$Nested"); + JDK11_ALL_STRUCTURES_NESTED("jdk11.AllStructures$Nested"), + JDK14_ALL_STRUCTURES("jdk14.AllStructures"); private final String name; private byte[] bytes; @@ -164,7 +168,13 @@ public abstract class AsmTest { if (name.startsWith("jdk9.") && api.value() < Api.ASM6.value()) { return true; } - return name.startsWith("jdk11.") && api.value() < Api.ASM7.value(); + if (name.startsWith("jdk11.") && api.value() < Api.ASM7.value()) { + return true; + } + if (name.startsWith("jdk14.") && api.value() < Api.ASM8.value()) { + return true; + } + return false; } /** @@ -181,6 +191,9 @@ public abstract class AsmTest { if (name.startsWith("jdk11.")) { return Util.getMajorJavaVersion() < 11; } + if (name.startsWith("jdk14.")) { + return Util.getMajorJavaVersion() < 14; + } return false; } @@ -247,7 +260,8 @@ public abstract class AsmTest { ASM4("ASM4", 4 << 16), ASM5("ASM5", 5 << 16), ASM6("ASM6", 6 << 16), - ASM7("ASM7", 7 << 16); + ASM7("ASM7", 7 << 16), + ASM8("ASM8", 1 << 24 | 8 << 16 | 0 << 8); private final String name; private final int value; @@ -260,7 +274,7 @@ public abstract class AsmTest { /** * Returns the int value of this version, as expected by ASM. * - * @return one of the ASM4, ASM5, ASM6 or ASM7 constants from the ASM Opcodes interface. + * @return one of the ASM4, ASM5, ASM6, ASM7 or ASM8 constants from the ASM Opcodes interface. */ public int value() { return value; @@ -269,7 +283,7 @@ public abstract class AsmTest { /** * Returns a human readable symbol corresponding to this version. * - * @return one of "ASM4", "ASM5", "ASM6" or "ASM7". + * @return one of "ASM4", "ASM5", "ASM6" "ASM7" or or "ASM8". */ @Override public String toString() { @@ -294,10 +308,11 @@ public abstract class AsmTest { * with {@code @MethodSource("allClassesAndLatestApi")} will be executed on all the precompiled * classes, with the latest api. * - * @return all the possible (precompiledClass, ASM7) pairs, for all the precompiled classes. + * @return all the possible (precompiledClass, ASM8_EXPERIMENTAL) pairs, for all the precompiled + * classes. */ public static Stream allClassesAndLatestApi() { - return classesAndApis(Api.ASM7); + return classesAndApis(Api.ASM8); } private static Stream classesAndApis(final Api... apis) { diff --git a/asm-test/src/main/java/org/objectweb/asm/test/ClassFile.java b/asm-test/src/main/java/org/objectweb/asm/test/ClassFile.java index b26bc8a76..a796256c9 100644 --- a/asm-test/src/main/java/org/objectweb/asm/test/ClassFile.java +++ b/asm-test/src/main/java/org/objectweb/asm/test/ClassFile.java @@ -494,6 +494,8 @@ public class ClassFile { dumpNestHostAttribute(parser, builder); } else if (attributeName.equals("NestMembers")) { dumpNestMembersAttribute(parser, builder); + } else if (attributeName.equals("PermittedSubtypes")) { + dumpPermittedSubtypesAttribute(parser, builder); } else if (attributeName.equals("StackMap")) { dumpStackMapAttribute(parser, builder); } else if (!attributeName.equals("CodeComment") && !attributeName.equals("Comment")) { @@ -1686,6 +1688,22 @@ public class ClassFile { } } + /** + * Parses and dumps a PermittedSubtypes attribute. + * + * @param parser a class parser. + * @param builder a dump builder. + * @throws IOException if the class can't be parsed. + * @see JEP 360 + */ + private static void dumpPermittedSubtypesAttribute(final Parser parser, final Builder builder) + throws IOException { + int numberOfClasses = builder.add("number_of_classes: ", parser.u2()); + for (int i = 0; i < numberOfClasses; ++i) { + builder.addCpInfo("class: ", parser.u2()); + } + } + /** * Parses and dumps a StackMap attribute. * diff --git a/asm-test/src/main/resources/jdk14/AllStructures$ClassSubType.class b/asm-test/src/main/resources/jdk14/AllStructures$ClassSubType.class new file mode 100644 index 0000000000000000000000000000000000000000..eec72864674a54bb12c1d0b92f21acbd49f87f00 GIT binary patch literal 309 zcmZusO-sW-6r9(j-5O(C>&b)Q!Gn4*6g-ItQV<2HhZOIdbdkh$Bl{uvvpfkN`~m(b z>q|}wz6UeR8+gNfeSdte*Eqv8K@X8YoT85bVN%N%nQ3Vrvb&;Ir6&x|D^vLkLUed^ zFEAwR*Q>|bX?Ce~?rkW2u*x0GwRA2I#q#x85#o8XVjAC8MlHfqq3lu?nlDM-1Y4@B zsuj~eFHYKQ!f>ISziylt7!!8>$s(jT#wgoGD#!A7IA#!BsvY9xT8ta4_BsvpkKaLW dot-eYHV`AiCUXxdwmKeR!kn-xFv2!=e*l2{M0WrH literal 0 HcmV?d00001 diff --git a/asm-test/src/main/resources/jdk14/AllStructures$RecordSubType.class b/asm-test/src/main/resources/jdk14/AllStructures$RecordSubType.class new file mode 100644 index 0000000000000000000000000000000000000000..b144463f51fe5ae0317c9bdff305c9392238ffa8 GIT binary patch literal 1829 zcmb_d+fEZv6kVrWrY(al6%a)Plxka$3f|D7$VH?{MIwX;?aQ=1!a$i*=R$(D-ub z12?VG)=`Z!M9bo!CN!>@GYl+mBV3RXL)^bL%aABE&n7fg+sP#WBxGDfKSS6Qu9e|o zs_@rybLn8XK^d1YL~y%`vAZlPl;F*C!R75_uE-e1RnmmNx0I^EFn69au?gA&)blv0(nh`;3KuBdD%x^loNBcj-!3Xsz2 zhCIUn@jvUBGja?!T7v$RUvyJgdYP}P_R)!!E}FJssZ8tKFxP}(O1RB%F`(>Jj7F!% zmxM44Q&(y(3nSKznJ8v)SHe9R_wj%s*-Tf}4#hstx>>ssOO{%#IIJV31{TAypQIP% z`nyUS69pmmty<2fg(tSp;sx46vBHhAuGUPU`$LwiiedN-9>&{t5dY~do$i$&j5(@J zbMSI!ud^`*iGIDL&3qJ3@KnNrjAvM67;9=1STSmbxOi7kJ{)c6!tP^LXbhkJi#l!O zUBka{56qdSK+bC#*Bv}g6na}mOv3Y^rtk~gD6fPUG_y^Of;xe^(d`Ay&^;HTDEA8;0;V;V`39C5K7o{(IzjI-nP`mY*-fh*G(pcu2t9T3 zt)ouUfFy0%7^Ad0PMK5m0bj_}5?k-1OYdfY^8oNUz3LEenm zHK0c*%Fd%J^A%D%Fe3pPDf?Y}+Y&~EIHkNCh8;|xBQetM*o8D57(xb<&N_u@S}%~r r5#5tKOSU1h-9aan+w$N-`5TThxnsJr#>rZzVG+-NzS)IC=-k5wDl+CwJrU|Ri-g)WA?+y7Ssy(%gi5$Bbi%`> zVnTJy#(wfDW-TLs%6hf5mJd%@dBQk8N+{zLWz?i-iQ`IE@B&Y?Dq0u6ghw<)o#WiY H^QGPcB)L*^ literal 0 HcmV?d00001 diff --git a/asm-test/src/resources/java/jdk14/AllStructures.java b/asm-test/src/resources/java/jdk14/AllStructures.java new file mode 100644 index 000000000..120c9ad8a --- /dev/null +++ b/asm-test/src/resources/java/jdk14/AllStructures.java @@ -0,0 +1,37 @@ +// ASM: a very small and fast Java bytecode manipulation framework +// Copyright (c) 2000-2011 INRIA, France Telecom +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions +// are met: +// 1. Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// 2. Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// 3. Neither the name of the copyright holders nor the names of its +// contributors may be used to endorse or promote products derived from +// this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +// THE POSSIBILITY OF SUCH DAMAGE. +package jdk14; + +public sealed interface AllStructures { + final class ClassSubType { + + } + record RecordSubType(int component1, String component2) { + + } +} \ No newline at end of file diff --git a/asm-test/src/test/java/org/objectweb/asm/test/AsmTestTest.java b/asm-test/src/test/java/org/objectweb/asm/test/AsmTestTest.java index e69f36f0d..482d8c09d 100644 --- a/asm-test/src/test/java/org/objectweb/asm/test/AsmTestTest.java +++ b/asm-test/src/test/java/org/objectweb/asm/test/AsmTestTest.java @@ -98,7 +98,7 @@ public class AsmTestTest extends AsmTest { new HashSet(Arrays.asList(PrecompiledClass.values())), allArguments.stream().map(arg -> arg.get()[0]).collect(Collectors.toSet())); assertEquals( - new HashSet(Arrays.asList(Api.ASM7)), + new HashSet(Arrays.asList(Api.ASM8)), allArguments.stream().map(arg -> arg.get()[1]).collect(Collectors.toSet())); } } diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java index ecbb2efd8..800415831 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java @@ -60,7 +60,7 @@ public class AnnotationNode extends AnnotationVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public AnnotationNode(final String descriptor) { - this(Opcodes.ASM7, descriptor); + this(Opcodes.ASM8_EXPERIMENTAL, descriptor); if (getClass() != AnnotationNode.class) { throw new IllegalStateException(); } @@ -84,7 +84,7 @@ public class AnnotationNode extends AnnotationVisitor { * @param values where the visited values must be stored. */ AnnotationNode(final List values) { - super(Opcodes.ASM7); + super(Opcodes.ASM8_EXPERIMENTAL); this.values = values; } diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java index 5b5084d5c..07c9b4fef 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java @@ -99,7 +99,7 @@ public class FieldNode extends FieldVisitor { final String descriptor, final String signature, final Object value) { - this(Opcodes.ASM7, access, name, descriptor, signature, value); + this(Opcodes.ASM8_EXPERIMENTAL, access, name, descriptor, signature, value); if (getClass() != FieldNode.class) { throw new IllegalStateException(); } diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java index e22033c14..e6038c029 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java @@ -84,7 +84,7 @@ public class LocalVariableAnnotationNode extends TypeAnnotationNode { final LabelNode[] end, final int[] index, final String descriptor) { - this(Opcodes.ASM7, typeRef, typePath, start, end, index, descriptor); + this(Opcodes.ASM8_EXPERIMENTAL, typeRef, typePath, start, end, index, descriptor); } /** diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java index 2ab6bb2db..edbc738c9 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java @@ -155,7 +155,7 @@ public class MethodNode extends MethodVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public MethodNode() { - this(Opcodes.ASM7); + this(Opcodes.ASM8_EXPERIMENTAL); if (getClass() != MethodNode.class) { throw new IllegalStateException(); } @@ -191,7 +191,7 @@ public class MethodNode extends MethodVisitor { final String descriptor, final String signature, final String[] exceptions) { - this(Opcodes.ASM7, access, name, descriptor, signature, exceptions); + this(Opcodes.ASM8_EXPERIMENTAL, access, name, descriptor, signature, exceptions); if (getClass() != MethodNode.class) { throw new IllegalStateException(); } @@ -621,7 +621,7 @@ public class MethodNode extends MethodVisitor { throw new UnsupportedClassVersionException(); } } - if (api != Opcodes.ASM7) { + if (api < Opcodes.ASM7) { for (int i = instructions.size() - 1; i >= 0; --i) { AbstractInsnNode insn = instructions.get(i); if (insn instanceof LdcInsnNode) { diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java index c1c8705f4..670d742c3 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java @@ -84,7 +84,7 @@ public class ModuleNode extends ModuleVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public ModuleNode(final String name, final int access, final String version) { - super(Opcodes.ASM7); + super(Opcodes.ASM8_EXPERIMENTAL); if (getClass() != ModuleNode.class) { throw new IllegalStateException(); } diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java index 8634828ba..64ee84b39 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java @@ -59,7 +59,7 @@ public class TypeAnnotationNode extends AnnotationNode { * @throws IllegalStateException If a subclass calls this constructor. */ public TypeAnnotationNode(final int typeRef, final TypePath typePath, final String descriptor) { - this(Opcodes.ASM7, typeRef, typePath, descriptor); + this(Opcodes.ASM8_EXPERIMENTAL, typeRef, typePath, descriptor); if (getClass() != TypeAnnotationNode.class) { throw new IllegalStateException(); } diff --git a/asm-tree/src/test/java/org/objectweb/asm/tree/AnnotationNodeTest.java b/asm-tree/src/test/java/org/objectweb/asm/tree/AnnotationNodeTest.java index 87069b57d..7123a110c 100644 --- a/asm-tree/src/test/java/org/objectweb/asm/tree/AnnotationNodeTest.java +++ b/asm-tree/src/test/java/org/objectweb/asm/tree/AnnotationNodeTest.java @@ -35,7 +35,6 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.objectweb.asm.AnnotationVisitor; -import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; /** @@ -103,7 +102,7 @@ public class AnnotationNodeTest extends AsmTest { annotationNode.visitAnnotation("annotation", "Lpkg/Annotation;"); AnnotationNode dstAnnotationNode = new AnnotationNode("LJ;"); AnnotationVisitor skipNestedAnnotationsVisitor = - new AnnotationVisitor(Opcodes.ASM7, dstAnnotationNode) { + new AnnotationVisitor(LATEST_API, dstAnnotationNode) { @Override public AnnotationVisitor visitAnnotation(final String name, final String descriptor) { diff --git a/asm-tree/src/test/java/org/objectweb/asm/tree/InsnListTest.java b/asm-tree/src/test/java/org/objectweb/asm/tree/InsnListTest.java index d5ebeb72e..66beff010 100644 --- a/asm-tree/src/test/java/org/objectweb/asm/tree/InsnListTest.java +++ b/asm-tree/src/test/java/org/objectweb/asm/tree/InsnListTest.java @@ -41,7 +41,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; +import org.objectweb.asm.test.AsmTest; /** * Unit tests for {@link InsnList}. @@ -109,7 +109,7 @@ public class InsnListTest { InsnList dstInsnList = new InsnList(); insnList.accept( - new MethodVisitor(Opcodes.ASM7) { + new MethodVisitor(AsmTest.LATEST_API) { @Override public void visitInsn(final int opcode) { dstInsnList.add(new InsnNode(opcode)); diff --git a/asm-tree/src/test/java/org/objectweb/asm/tree/ModuleNodeTest.java b/asm-tree/src/test/java/org/objectweb/asm/tree/ModuleNodeTest.java index fa6134e9f..d1d2e3e08 100644 --- a/asm-tree/src/test/java/org/objectweb/asm/tree/ModuleNodeTest.java +++ b/asm-tree/src/test/java/org/objectweb/asm/tree/ModuleNodeTest.java @@ -34,7 +34,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ModuleVisitor; -import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; /** @@ -48,7 +47,7 @@ public class ModuleNodeTest extends AsmTest { public void testConstructor() { ModuleNode moduleNode1 = new ModuleNode("module1", 123, "1.0"); ModuleNode moduleNode2 = - new ModuleNode(Opcodes.ASM7, "module2", 456, "2.0", null, null, null, null, null); + new ModuleNode(LATEST_API, "module2", 456, "2.0", null, null, null, null, null); assertEquals("module1", moduleNode1.name); assertEquals(123, moduleNode1.access); @@ -70,7 +69,7 @@ public class ModuleNodeTest extends AsmTest { ModuleNode moduleNode = new ModuleNode("module", 123, "1.0"); ModuleNode dstModuleNode = new ModuleNode("", 0, ""); ClassVisitor copyModuleVisitor = - new ClassVisitor(Opcodes.ASM7) { + new ClassVisitor(LATEST_API) { @Override public ModuleVisitor visitModule( final String name, final int access, final String version) { diff --git a/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java b/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java index e8921bcc2..2353261a5 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java @@ -123,7 +123,7 @@ public class ASMifier extends Printer { * @throws IllegalStateException If a subclass calls this constructor. */ public ASMifier() { - this(Opcodes.ASM7, "classWriter", 0); + this(Opcodes.ASM8_EXPERIMENTAL, "classWriter", 0); if (getClass() != ASMifier.class) { throw new IllegalStateException(); } @@ -323,7 +323,7 @@ public class ASMifier extends Printer { @Override public void visitPermittedSubtypeExperimental(final String visitPermittedSubtype) { stringBuilder.setLength(0); - stringBuilder.append("classWriter.visitPermittedSubtype("); + stringBuilder.append("classWriter.visitPermittedSubtypeExperimental("); appendConstant(visitPermittedSubtype); stringBuilder.append(END_PARAMETERS); text.add(stringBuilder.toString()); @@ -1351,6 +1351,13 @@ public class ASMifier extends Printer { stringBuilder.append("ACC_DEPRECATED"); isEmpty = false; } + if ((accessFlags & Opcodes.ACC_SEALED) != 0) { + if (!isEmpty) { + stringBuilder.append(" | "); + } + stringBuilder.append("ACC_SEALED"); + isEmpty = false; + } if ((accessFlags & (Opcodes.ACC_MANDATED | Opcodes.ACC_MODULE)) != 0) { if (!isEmpty) { stringBuilder.append(" | "); diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckAnnotationAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckAnnotationAdapter.java index 6a868f367..d39f96dcc 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckAnnotationAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckAnnotationAdapter.java @@ -52,7 +52,7 @@ public class CheckAnnotationAdapter extends AnnotationVisitor { } CheckAnnotationAdapter(final AnnotationVisitor annotationVisitor, final boolean useNamedValues) { - super(Opcodes.ASM7, annotationVisitor); + super(Opcodes.ASM8_EXPERIMENTAL, annotationVisitor); this.useNamedValue = useNamedValues; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java index 529e516d7..4f331537f 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java @@ -173,7 +173,7 @@ public class CheckClassAdapter extends ClassVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public CheckClassAdapter(final ClassVisitor classVisitor, final boolean checkDataFlow) { - this(Opcodes.ASM7, classVisitor, checkDataFlow); + this(Opcodes.ASM8_EXPERIMENTAL, classVisitor, checkDataFlow); if (getClass() != CheckClassAdapter.class) { throw new IllegalStateException(); } @@ -224,7 +224,8 @@ public class CheckClassAdapter extends ClassVisitor { | Opcodes.ACC_ANNOTATION | Opcodes.ACC_ENUM | Opcodes.ACC_DEPRECATED - | Opcodes.ACC_MODULE); + | Opcodes.ACC_MODULE + | Opcodes.ACC_SEALED); if (name == null) { throw new IllegalArgumentException("Illegal class name (null)"); } @@ -532,7 +533,8 @@ public class CheckClassAdapter extends ClassVisitor { throw new IllegalArgumentException( "public, protected and private are mutually exclusive: " + access); } - if (Integer.bitCount(access & (Opcodes.ACC_FINAL | Opcodes.ACC_ABSTRACT)) > 1) { + if ((access & Opcodes.ACC_SEALED) == 0 + && Integer.bitCount(access & (Opcodes.ACC_FINAL | Opcodes.ACC_ABSTRACT)) > 1) { throw new IllegalArgumentException("final and abstract are mutually exclusive: " + access); } } @@ -1016,7 +1018,8 @@ public class CheckClassAdapter extends ClassVisitor { final PrintWriter printWriter) { ClassNode classNode = new ClassNode(); classReader.accept( - new CheckClassAdapter(Opcodes.ASM7, classNode, false) {}, ClassReader.SKIP_DEBUG); + new CheckClassAdapter(Opcodes.ASM8_EXPERIMENTAL, classNode, false) {}, + ClassReader.SKIP_DEBUG); Type syperType = classNode.superName == null ? null : Type.getObjectType(classNode.superName); List methods = classNode.methods; diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckFieldAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckFieldAdapter.java index 205d94845..907e06fdd 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckFieldAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckFieldAdapter.java @@ -52,7 +52,7 @@ public class CheckFieldAdapter extends FieldVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public CheckFieldAdapter(final FieldVisitor fieldVisitor) { - this(Opcodes.ASM7, fieldVisitor); + this(Opcodes.ASM8_EXPERIMENTAL, fieldVisitor); if (getClass() != CheckFieldAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java index ba8c0e1be..5bdb023c0 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java @@ -366,7 +366,7 @@ public class CheckMethodAdapter extends MethodVisitor { */ public CheckMethodAdapter( final MethodVisitor methodVisitor, final Map labelInsnIndices) { - this(Opcodes.ASM7, methodVisitor, labelInsnIndices); + this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor, labelInsnIndices); if (getClass() != CheckMethodAdapter.class) { throw new IllegalStateException(); } @@ -412,7 +412,7 @@ public class CheckMethodAdapter extends MethodVisitor { final String descriptor, final MethodVisitor methodVisitor, final Map labelInsnIndices) { - this(Opcodes.ASM7, access, name, descriptor, methodVisitor, labelInsnIndices); + this(Opcodes.ASM8_EXPERIMENTAL, access, name, descriptor, methodVisitor, labelInsnIndices); if (getClass() != CheckMethodAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckModuleAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckModuleAdapter.java index c2e292d28..580787b8f 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckModuleAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckModuleAdapter.java @@ -71,7 +71,7 @@ public class CheckModuleAdapter extends ModuleVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public CheckModuleAdapter(final ModuleVisitor moduleVisitor, final boolean isOpen) { - this(Opcodes.ASM7, moduleVisitor, isOpen); + this(Opcodes.ASM8_EXPERIMENTAL, moduleVisitor, isOpen); if (getClass() != CheckModuleAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckSignatureAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckSignatureAdapter.java index 2ec182e1b..67ffdd469 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckSignatureAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckSignatureAdapter.java @@ -123,7 +123,7 @@ public class CheckSignatureAdapter extends SignatureVisitor { * null}. */ public CheckSignatureAdapter(final int type, final SignatureVisitor signatureVisitor) { - this(Opcodes.ASM7, type, signatureVisitor); + this(Opcodes.ASM8_EXPERIMENTAL, type, signatureVisitor); } /** diff --git a/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java b/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java index ff81b2c61..8a6ff3d0f 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java @@ -111,7 +111,7 @@ public class Textifier extends Printer { * @throws IllegalStateException If a subclass calls this constructor. */ public Textifier() { - this(Opcodes.ASM7); + this(Opcodes.ASM8_EXPERIMENTAL); if (getClass() != Textifier.class) { throw new IllegalStateException(); } @@ -301,6 +301,15 @@ public class Textifier extends Printer { text.add(stringBuilder.toString()); } + @Override + public void visitPermittedSubtypeExperimental(final String permittedSubtype) { + stringBuilder.setLength(0); + stringBuilder.append(tab).append("PERMITTEDSUBTYPE "); + appendDescriptor(INTERNAL_NAME, permittedSubtype); + stringBuilder.append('\n'); + text.add(stringBuilder.toString()); + } + @Override public void visitInnerClass( final String name, final String outerName, final String innerName, final int access) { @@ -1243,6 +1252,9 @@ public class Textifier extends Printer { if ((accessFlags & Opcodes.ACC_ENUM) != 0) { stringBuilder.append("enum "); } + if ((accessFlags & Opcodes.ACC_SEALED) != 0) { + stringBuilder.append("sealed "); + } } /** diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceAnnotationVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceAnnotationVisitor.java index 1cc9621a6..15bda3b90 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceAnnotationVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceAnnotationVisitor.java @@ -57,7 +57,7 @@ public final class TraceAnnotationVisitor extends AnnotationVisitor { * @param printer the printer to convert the visited annotation into text. */ public TraceAnnotationVisitor(final AnnotationVisitor annotationVisitor, final Printer printer) { - super(Opcodes.ASM7, annotationVisitor); + super(Opcodes.ASM8_EXPERIMENTAL, annotationVisitor); this.printer = printer; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java index 32cb007ac..e0b5924dd 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java @@ -118,7 +118,7 @@ public final class TraceClassVisitor extends ClassVisitor { */ public TraceClassVisitor( final ClassVisitor classVisitor, final Printer printer, final PrintWriter printWriter) { - super(Opcodes.ASM7, classVisitor); + super(Opcodes.ASM8_EXPERIMENTAL, classVisitor); this.printWriter = printWriter; this.p = printer; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceFieldVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceFieldVisitor.java index 7405d3449..475138ebb 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceFieldVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceFieldVisitor.java @@ -60,7 +60,7 @@ public final class TraceFieldVisitor extends FieldVisitor { * @param printer the printer to convert the visited field into text. */ public TraceFieldVisitor(final FieldVisitor fieldVisitor, final Printer printer) { - super(Opcodes.ASM7, fieldVisitor); + super(Opcodes.ASM8_EXPERIMENTAL, fieldVisitor); this.p = printer; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceMethodVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceMethodVisitor.java index 10b8f7f4c..f0c43b975 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceMethodVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceMethodVisitor.java @@ -62,7 +62,7 @@ public final class TraceMethodVisitor extends MethodVisitor { * @param printer the printer to convert the visited method into text. */ public TraceMethodVisitor(final MethodVisitor methodVisitor, final Printer printer) { - super(Opcodes.ASM7, methodVisitor); + super(Opcodes.ASM8_EXPERIMENTAL, methodVisitor); this.p = printer; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceModuleVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceModuleVisitor.java index 84bbfb1f6..ea57ea6b6 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceModuleVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceModuleVisitor.java @@ -57,7 +57,7 @@ public final class TraceModuleVisitor extends ModuleVisitor { * @param printer the printer to convert the visited module into text. */ public TraceModuleVisitor(final ModuleVisitor moduleVisitor, final Printer printer) { - super(Opcodes.ASM7, moduleVisitor); + super(Opcodes.ASM8_EXPERIMENTAL, moduleVisitor); this.p = printer; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceSignatureVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceSignatureVisitor.java index 09485a5c2..be0069812 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceSignatureVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceSignatureVisitor.java @@ -109,13 +109,13 @@ public final class TraceSignatureVisitor extends SignatureVisitor { * @param accessFlags for class type signatures, the access flags of the class. */ public TraceSignatureVisitor(final int accessFlags) { - super(Opcodes.ASM7); + super(Opcodes.ASM8_EXPERIMENTAL); this.isInterface = (accessFlags & Opcodes.ACC_INTERFACE) != 0; this.declaration = new StringBuilder(); } private TraceSignatureVisitor(final StringBuilder stringBuilder) { - super(Opcodes.ASM7); + super(Opcodes.ASM8_EXPERIMENTAL); this.isInterface = false; this.declaration = stringBuilder; } diff --git a/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java b/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java index 47b57ab78..844df172a 100644 --- a/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java +++ b/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java @@ -417,7 +417,8 @@ public class CheckClassAdapterTest extends AsmTest implements Opcodes { final PrecompiledClass classParameter, final Api apiParameter) { byte[] classFile = classParameter.getBytes(); ClassReader classReader = new ClassReader(classFile); - ClassVisitor classVisitor = new CheckClassAdapter(new ClassVisitor(Opcodes.ASM7, null) {}); + ClassVisitor classVisitor = + new CheckClassAdapter(new ClassVisitor(AsmTest.LATEST_API, null) {}); Executable accept = () -> classReader.accept(classVisitor, attributes(), 0); diff --git a/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java b/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java index 72dab0e71..232d4d05c 100644 --- a/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java +++ b/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java @@ -36,6 +36,7 @@ import org.objectweb.asm.Attribute; import org.objectweb.asm.Handle; import org.objectweb.asm.Label; import org.objectweb.asm.Opcodes; +import org.objectweb.asm.test.AsmTest; /** * Unit tests for {@link Printer}. @@ -48,7 +49,7 @@ public class PrinterTest { @Test public void testVisitModule_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitModule = () -> printer.visitModule(null, 0, null); @@ -58,7 +59,7 @@ public class PrinterTest { @Test public void testVisitNestHost_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitNestHost = () -> printer.visitNestHost(null); @@ -68,7 +69,7 @@ public class PrinterTest { @Test public void testVisitClassTypeAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitClassTypeAnnotation = () -> printer.visitClassTypeAnnotation(0, null, null, false); @@ -80,7 +81,7 @@ public class PrinterTest { @Test public void testVisitNestMember_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitNestMember = () -> printer.visitNestMember(null); @@ -101,7 +102,7 @@ public class PrinterTest { @Test public void testVisitMainClass_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitMainClass = () -> printer.visitMainClass(null); @@ -111,7 +112,7 @@ public class PrinterTest { @Test public void testVisitPackage_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitPackage = () -> printer.visitPackage(null); @@ -121,7 +122,7 @@ public class PrinterTest { @Test public void testVisitRequire_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitRequire = () -> printer.visitRequire(null, 0, null); @@ -131,7 +132,7 @@ public class PrinterTest { @Test public void testVisitExport_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitExport = () -> printer.visitExport(null, 0); @@ -141,7 +142,7 @@ public class PrinterTest { @Test public void testVisitOpen_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitOpen = () -> printer.visitOpen(null, 0); @@ -151,7 +152,7 @@ public class PrinterTest { @Test public void testVisitUse_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitUse = () -> printer.visitUse(null); @@ -161,7 +162,7 @@ public class PrinterTest { @Test public void testVisitProvide_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitProvide = () -> printer.visitProvide(null); @@ -171,7 +172,7 @@ public class PrinterTest { @Test public void testVisitModuleEnd_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitModuleEnd = () -> printer.visitModuleEnd(); @@ -181,7 +182,7 @@ public class PrinterTest { @Test public void testVisitFieldTypeAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitFieldTypeAnnotation = () -> printer.visitFieldTypeAnnotation(0, null, null, false); @@ -193,7 +194,7 @@ public class PrinterTest { @Test public void testVisitParameter_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitParameter = () -> printer.visitParameter(null, 0); @@ -203,7 +204,7 @@ public class PrinterTest { @Test public void testVisitMethodTypeAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitMethodTypeAnnotation = () -> printer.visitMethodTypeAnnotation(0, null, null, false); @@ -215,7 +216,7 @@ public class PrinterTest { @Test public void testVisitAnnotableParameterCount_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitAnnotableParameterCount = () -> printer.visitAnnotableParameterCount(0, false); @@ -237,7 +238,7 @@ public class PrinterTest { @Test public void testVisitMethodInsn_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitMethodInsn = () -> printer.visitMethodInsn(Opcodes.INVOKESPECIAL, "owner", "name", "()V", false); @@ -248,7 +249,7 @@ public class PrinterTest { @Test public void testVisitMethodInsn_ifItf_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitMethodInsn = () -> printer.visitMethodInsn(Opcodes.INVOKESPECIAL, "owner", "name", "()V", true); @@ -259,7 +260,7 @@ public class PrinterTest { @Test public void testVisitInsnAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitInsnAnnotation = () -> printer.visitInsnAnnotation(0, null, null, false); @@ -269,7 +270,7 @@ public class PrinterTest { @Test public void testVisitTryCatchAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitTryCatchAnnotation = () -> printer.visitTryCatchAnnotation(0, null, null, false); @@ -281,7 +282,7 @@ public class PrinterTest { @Test public void testVisitLocalVariableAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM7); + Printer printer = new EmptyPrinter(AsmTest.LATEST_API); Executable visitLocalVariableAnnotation = () -> printer.visitLocalVariableAnnotation(0, null, null, null, null, null, false); diff --git a/asm-util/src/test/java/org/objectweb/asm/util/SignaturesProviders.java b/asm-util/src/test/java/org/objectweb/asm/util/SignaturesProviders.java index 4cd24f7ad..a19edac5d 100644 --- a/asm-util/src/test/java/org/objectweb/asm/util/SignaturesProviders.java +++ b/asm-util/src/test/java/org/objectweb/asm/util/SignaturesProviders.java @@ -9,7 +9,6 @@ import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.test.AsmTest.PrecompiledClass; @@ -37,7 +36,7 @@ public final class SignaturesProviders { private static void collectSignatures(final PrecompiledClass classParameter) { ClassReader classReader = new ClassReader(classParameter.getBytes()); classReader.accept( - new ClassVisitor(Opcodes.ASM7) { + new ClassVisitor(AsmTest.LATEST_API) { @Override public void visit( final int version, diff --git a/asm-util/src/test/resources/jdk14.AllStructures.txt b/asm-util/src/test/resources/jdk14.AllStructures.txt new file mode 100644 index 000000000..95ac4c537 --- /dev/null +++ b/asm-util/src/test/resources/jdk14.AllStructures.txt @@ -0,0 +1,14 @@ +// class version 58.65535 (-65478) +// access flags 0x40611 +public final abstract sealed interface jdk14/AllStructures { + + // compiled from: AllStructures.java + NESTMEMBER jdk14/AllStructures$RecordSubType + NESTMEMBER jdk14/AllStructures$ClassSubType + PERMITTEDSUBTYPE jdk14/AllStructures$RecordSubType + PERMITTEDSUBTYPE jdk14/AllStructures$ClassSubType + // access flags 0x19 + public final static INNERCLASS jdk14/AllStructures$RecordSubType jdk14/AllStructures RecordSubType + // access flags 0x19 + public final static INNERCLASS jdk14/AllStructures$ClassSubType jdk14/AllStructures ClassSubType +} diff --git a/asm/src/main/java/org/objectweb/asm/AnnotationWriter.java b/asm/src/main/java/org/objectweb/asm/AnnotationWriter.java index d85e255d8..b48e58024 100644 --- a/asm/src/main/java/org/objectweb/asm/AnnotationWriter.java +++ b/asm/src/main/java/org/objectweb/asm/AnnotationWriter.java @@ -112,7 +112,7 @@ final class AnnotationWriter extends AnnotationVisitor { final boolean useNamedValues, final ByteVector annotation, final AnnotationWriter previousAnnotation) { - super(Opcodes.ASM7); + super(Opcodes.ASM8_EXPERIMENTAL); this.symbolTable = symbolTable; this.useNamedValues = useNamedValues; this.annotation = annotation; diff --git a/asm/src/main/java/org/objectweb/asm/ClassReader.java b/asm/src/main/java/org/objectweb/asm/ClassReader.java index a7520739a..92bbee0f5 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassReader.java +++ b/asm/src/main/java/org/objectweb/asm/ClassReader.java @@ -492,6 +492,7 @@ public class ClassReader { nestMembersOffset = currentAttributeOffset; } else if (Constants.PERMITTED_SUBTYPES.equals(attributeName)) { permittedSubtypesOffset = currentAttributeOffset; + accessFlags |= Opcodes.ACC_SEALED; } else if (Constants.SIGNATURE.equals(attributeName)) { signature = readUTF8(currentAttributeOffset, charBuffer); } else if (Constants.RUNTIME_VISIBLE_ANNOTATIONS.equals(attributeName)) { diff --git a/asm/src/main/java/org/objectweb/asm/ClassWriter.java b/asm/src/main/java/org/objectweb/asm/ClassWriter.java index 1b054f564..c0ca22bf1 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassWriter.java +++ b/asm/src/main/java/org/objectweb/asm/ClassWriter.java @@ -79,8 +79,8 @@ public class ClassWriter extends ClassVisitor { /** * The access_flags field of the JVMS ClassFile structure. This field can contain ASM specific - * access flags, such as {@link Opcodes#ACC_DEPRECATED}, which are removed when generating the - * ClassFile structure. + * access flags, such as {@link Opcodes#ACC_DEPRECATED}, or {@link Opcodes#ACC_SEALED} which are + * removed when generating the ClassFile structure. */ private int accessFlags; @@ -240,7 +240,7 @@ public class ClassWriter extends ClassVisitor { * maximum stack size nor the stack frames will be computed for these methods. */ public ClassWriter(final ClassReader classReader, final int flags) { - super(Opcodes.ASM7); + super(Opcodes.ASM8_EXPERIMENTAL); symbolTable = classReader == null ? new SymbolTable(this) : new SymbolTable(this, classReader); if ((flags & COMPUTE_FRAMES) != 0) { this.compute = MethodWriter.COMPUTE_ALL_FRAMES; diff --git a/asm/src/main/java/org/objectweb/asm/Constants.java b/asm/src/main/java/org/objectweb/asm/Constants.java index 5ab99792b..8e4beef2e 100644 --- a/asm/src/main/java/org/objectweb/asm/Constants.java +++ b/asm/src/main/java/org/objectweb/asm/Constants.java @@ -182,26 +182,20 @@ final class Constants implements Opcodes { static void checkAsm8Experimental(final Object caller) { Class callerClass = caller.getClass(); + if (callerClass.getName().startsWith("org.objectweb.asm.")) { + return; + } String callerClassResource = callerClass.getName().replace('.', '/') + ".class"; InputStream inputStream = callerClass.getClassLoader().getResourceAsStream(callerClassResource); if (inputStream == null) { throw new IllegalStateException("Bytecode not available, can't check class version"); } int minorVersion; - try { - DataInputStream callerClassStream = new DataInputStream(inputStream); - try { - callerClassStream.readInt(); - minorVersion = callerClassStream.readUnsignedShort(); - } catch (IOException ioe) { - throw new IllegalStateException("i/O error, can't check class version", ioe); - } - } finally { - try { - inputStream.close(); - } catch (IOException e) { - inputStream = null; // PMD rule should allow an empty block if there is a comment in it - } + try (DataInputStream callerClassStream = new DataInputStream(inputStream); ) { + callerClassStream.readInt(); + minorVersion = callerClassStream.readUnsignedShort(); + } catch (IOException ioe) { + throw new IllegalStateException("i/O error, can't check class version", ioe); } if (minorVersion != 0xFFFF) { throw new IllegalStateException( diff --git a/asm/src/main/java/org/objectweb/asm/FieldWriter.java b/asm/src/main/java/org/objectweb/asm/FieldWriter.java index dec33121e..c4672c25b 100644 --- a/asm/src/main/java/org/objectweb/asm/FieldWriter.java +++ b/asm/src/main/java/org/objectweb/asm/FieldWriter.java @@ -124,7 +124,7 @@ final class FieldWriter extends FieldVisitor { final String descriptor, final String signature, final Object constantValue) { - super(Opcodes.ASM7); + super(Opcodes.ASM8_EXPERIMENTAL); this.symbolTable = symbolTable; this.accessFlags = access; this.nameIndex = symbolTable.addConstantUtf8(name); diff --git a/asm/src/main/java/org/objectweb/asm/MethodVisitor.java b/asm/src/main/java/org/objectweb/asm/MethodVisitor.java index fa5cc2f5b..0088aef3c 100644 --- a/asm/src/main/java/org/objectweb/asm/MethodVisitor.java +++ b/asm/src/main/java/org/objectweb/asm/MethodVisitor.java @@ -541,7 +541,7 @@ public abstract class MethodVisitor { || (value instanceof Type && ((Type) value).getSort() == Type.METHOD))) { throw new UnsupportedOperationException(REQUIRES_ASM5); } - if (api != Opcodes.ASM7 && value instanceof ConstantDynamic) { + if (api < Opcodes.ASM7 && value instanceof ConstantDynamic) { throw new UnsupportedOperationException("This feature requires ASM7"); } if (mv != null) { diff --git a/asm/src/main/java/org/objectweb/asm/MethodWriter.java b/asm/src/main/java/org/objectweb/asm/MethodWriter.java index 6bd72efcc..de198e5f6 100644 --- a/asm/src/main/java/org/objectweb/asm/MethodWriter.java +++ b/asm/src/main/java/org/objectweb/asm/MethodWriter.java @@ -592,7 +592,7 @@ final class MethodWriter extends MethodVisitor { final String signature, final String[] exceptions, final int compute) { - super(Opcodes.ASM7); + super(Opcodes.ASM8_EXPERIMENTAL); this.symbolTable = symbolTable; this.accessFlags = "".equals(name) ? access | Constants.ACC_CONSTRUCTOR : access; this.nameIndex = symbolTable.addConstantUtf8(name); diff --git a/asm/src/main/java/org/objectweb/asm/ModuleWriter.java b/asm/src/main/java/org/objectweb/asm/ModuleWriter.java index 7658734db..3bb5ce59d 100644 --- a/asm/src/main/java/org/objectweb/asm/ModuleWriter.java +++ b/asm/src/main/java/org/objectweb/asm/ModuleWriter.java @@ -94,7 +94,7 @@ final class ModuleWriter extends ModuleVisitor { private int mainClassIndex; ModuleWriter(final SymbolTable symbolTable, final int name, final int access, final int version) { - super(Opcodes.ASM7); + super(Opcodes.ASM8_EXPERIMENTAL); this.symbolTable = symbolTable; this.moduleNameIndex = name; this.moduleFlags = access; diff --git a/asm/src/main/java/org/objectweb/asm/Opcodes.java b/asm/src/main/java/org/objectweb/asm/Opcodes.java index e11867a77..dc8380fc5 100644 --- a/asm/src/main/java/org/objectweb/asm/Opcodes.java +++ b/asm/src/main/java/org/objectweb/asm/Opcodes.java @@ -323,6 +323,7 @@ public interface Opcodes { // written in class files (because access flags are stored using 16 bits only). int ACC_DEPRECATED = 0x20000; // class, field, method + int ACC_SEALED = 0x40000; // class // Possible values for the type operand of the NEWARRAY instruction. // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.html#jvms-6.5.newarray. diff --git a/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java b/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java index 6648817d0..97d3136f0 100644 --- a/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java +++ b/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java @@ -417,7 +417,7 @@ public class ClassReaderTest extends AsmTest implements Opcodes { || invalidClass == InvalidClass.INVALID_CP_INFO_TAG); ClassReader classReader = new ClassReader(invalidClass.getBytes()); - Executable accept = () -> classReader.accept(new EmptyClassVisitor(ASM7), 0); + Executable accept = () -> classReader.accept(new EmptyClassVisitor(LATEST_API), 0); if (invalidClass == InvalidClass.INVALID_CONSTANT_POOL_INDEX || invalidClass == InvalidClass.INVALID_CONSTANT_POOL_REFERENCE @@ -440,12 +440,14 @@ public class ClassReaderTest extends AsmTest implements Opcodes { Executable accept = () -> classReader.accept(classVisitor, 0); + boolean hasPermittedSubtypes = classParameter == PrecompiledClass.JDK14_ALL_STRUCTURES; boolean hasNestHostOrMembers = classParameter == PrecompiledClass.JDK11_ALL_STRUCTURES || classParameter == PrecompiledClass.JDK11_ALL_STRUCTURES_NESTED; boolean hasModules = classParameter == PrecompiledClass.JDK9_MODULE; boolean hasTypeAnnotations = classParameter == PrecompiledClass.JDK8_ALL_STRUCTURES; - if ((hasNestHostOrMembers && apiParameter.value() < ASM7) + if ((hasPermittedSubtypes && apiParameter.value() != ASM8_EXPERIMENTAL) + || (hasNestHostOrMembers && apiParameter.value() < ASM7) || (hasModules && apiParameter.value() < ASM6) || (hasTypeAnnotations && apiParameter.value() < ASM5)) { Exception exception = assertThrows(UnsupportedOperationException.class, accept); @@ -523,7 +525,7 @@ public class ClassReaderTest extends AsmTest implements Opcodes { ClassReader classReader = new ClassReader(PrecompiledClass.JDK5_LOCAL_CLASS.getBytes()); AtomicInteger parameterIndex = new AtomicInteger(-1); ClassVisitor readParameterIndexVisitor = - new ClassVisitor(Opcodes.ASM7) { + new ClassVisitor(LATEST_API) { @Override public MethodVisitor visitMethod( final int access, @@ -558,7 +560,7 @@ public class ClassReaderTest extends AsmTest implements Opcodes { ClassReader classReader = new ClassReader(classFile); AtomicInteger classVersion = new AtomicInteger(0); ClassVisitor readVersionVisitor = - new ClassVisitor(Opcodes.ASM7) { + new ClassVisitor(LATEST_API) { @Override public void visit( final int version, diff --git a/asm/src/test/java/org/objectweb/asm/ClassVisitorTest.java b/asm/src/test/java/org/objectweb/asm/ClassVisitorTest.java index 292d56560..f9b45b9cf 100644 --- a/asm/src/test/java/org/objectweb/asm/ClassVisitorTest.java +++ b/asm/src/test/java/org/objectweb/asm/ClassVisitorTest.java @@ -250,7 +250,7 @@ public class ClassVisitorTest extends AsmTest { ClassReader classReader = new ClassReader(classFile); ClassWriter classWriter = new ClassWriter(0); ClassVisitor classVisitor = - new ClassVisitor(Opcodes.ASM7, classWriter) { + new ClassVisitor(LATEST_API, classWriter) { @Override public ModuleVisitor visitModule( @@ -454,7 +454,7 @@ public class ClassVisitorTest extends AsmTest { private static class ChangeExceptionAdapter extends ClassVisitor { ChangeExceptionAdapter(final ClassVisitor classVisitor) { - super(Opcodes.ASM7, classVisitor); + super(LATEST_API, classVisitor); } @Override @@ -476,7 +476,7 @@ public class ClassVisitorTest extends AsmTest { private final int newVersion; ChangeVersionAdapter(final ClassVisitor classVisitor, final int newVersion) { - super(Opcodes.ASM7, classVisitor); + super(LATEST_API, classVisitor); this.newVersion = newVersion; } @@ -497,7 +497,7 @@ public class ClassVisitorTest extends AsmTest { private final int accessFlags; ChangeAccessAdapter(final ClassVisitor classVisitor, final int accessFlags) { - super(Opcodes.ASM7, classVisitor); + super(LATEST_API, classVisitor); this.accessFlags = accessFlags; } @@ -518,7 +518,7 @@ public class ClassVisitorTest extends AsmTest { private final boolean visibilityValue; RemoveAnnotationAdapter(final ClassVisitor classVisitor, final boolean visibilityValue) { - super(Opcodes.ASM7, classVisitor); + super(LATEST_API, classVisitor); this.visibilityValue = visibilityValue; } @@ -659,7 +659,7 @@ public class ClassVisitorTest extends AsmTest { private static class AddParameterAdapter extends ClassVisitor { public AddParameterAdapter(final ClassVisitor classVisitor) { - super(Opcodes.ASM7, classVisitor); + super(LATEST_API, classVisitor); } @Override diff --git a/asm/src/test/java/org/objectweb/asm/ConstantsTest.java b/asm/src/test/java/org/objectweb/asm/ConstantsTest.java index 295933580..35db5daf9 100644 --- a/asm/src/test/java/org/objectweb/asm/ConstantsTest.java +++ b/asm/src/test/java/org/objectweb/asm/ConstantsTest.java @@ -137,8 +137,7 @@ public class ConstantsTest { List verificationTypeInfoTags = getConstants(ConstantType.VERIFICATION_TYPE_INFO_TAG); Set verificationTypeInfoTagValues = - verificationTypeInfoTags - .stream() + verificationTypeInfoTags.stream() .map(ConstantsTest::getIntegerValue) .collect(Collectors.toSet()); @@ -163,8 +162,7 @@ public class ConstantsTest { } private static List getConstants(final ConstantType constantType) { - return Arrays.asList(Constants.class.getFields()) - .stream() + return Arrays.asList(Constants.class.getFields()).stream() .filter(field -> getType(field).equals(constantType)) .collect(Collectors.toList()); } @@ -218,6 +216,7 @@ public class ConstantsTest { case "ACC_MODULE": return ConstantType.ACCESS_FLAG; case "ACC_DEPRECATED": + case "ACC_SEALED": case "ACC_CONSTRUCTOR": return ConstantType.ASM_ACCESS_FLAG; case "T_BOOLEAN": diff --git a/asm/src/test/java/org/objectweb/asm/MethodVisitorTest.java b/asm/src/test/java/org/objectweb/asm/MethodVisitorTest.java index c5cd57bc4..e379f889c 100644 --- a/asm/src/test/java/org/objectweb/asm/MethodVisitorTest.java +++ b/asm/src/test/java/org/objectweb/asm/MethodVisitorTest.java @@ -535,13 +535,13 @@ public class MethodVisitorTest extends AsmTest { } } - /** A {@link MethodVisitor} that logs the calls to its ASM5 visitMethodInsn method. */ + /** A {@link MethodVisitor} that logs the calls to its visitMethodInsn method. */ private static class LogMethodVisitor extends MethodVisitor { private final StringWriter log; LogMethodVisitor(final StringWriter log) { - super(Opcodes.ASM7); + super(LATEST_API); this.log = log; } diff --git a/asm/src/test/java/org/objectweb/asm/signature/SignatureReaderTest.java b/asm/src/test/java/org/objectweb/asm/signature/SignatureReaderTest.java index d2646817a..94cbd5cf9 100644 --- a/asm/src/test/java/org/objectweb/asm/signature/SignatureReaderTest.java +++ b/asm/src/test/java/org/objectweb/asm/signature/SignatureReaderTest.java @@ -34,7 +34,6 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; -import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; /** @@ -51,7 +50,7 @@ public class SignatureReaderTest extends AsmTest { }) public void testAccept_validClassOrMethodSignature(final String signature) { SignatureReader signatureReader = new SignatureReader(signature); - SignatureVisitor signatureVisitor = new SignatureVisitor(Opcodes.ASM7) {}; + SignatureVisitor signatureVisitor = new SignatureVisitor(LATEST_API) {}; Executable acceptVisitor = () -> signatureReader.accept(signatureVisitor); @@ -62,7 +61,7 @@ public class SignatureReaderTest extends AsmTest { @MethodSource("org.objectweb.asm.signature.SignaturesProviders#fieldSignatures") public void testAccept_validFieldSignature(final String signature) { SignatureReader signatureReader = new SignatureReader(signature); - SignatureVisitor signatureVisitor = new SignatureVisitor(Opcodes.ASM7) {}; + SignatureVisitor signatureVisitor = new SignatureVisitor(LATEST_API) {}; Executable acceptVisitor = () -> signatureReader.acceptType(signatureVisitor); @@ -73,7 +72,7 @@ public class SignatureReaderTest extends AsmTest { public void testAccept_invalidSignature() { String invalidSignature = "-"; SignatureReader signatureReader = new SignatureReader(invalidSignature); - SignatureVisitor signatureVisitor = new SignatureVisitor(Opcodes.ASM7) {}; + SignatureVisitor signatureVisitor = new SignatureVisitor(LATEST_API) {}; Executable acceptVisitor = () -> signatureReader.accept(signatureVisitor); diff --git a/asm/src/test/java/org/objectweb/asm/signature/SignaturesProviders.java b/asm/src/test/java/org/objectweb/asm/signature/SignaturesProviders.java index 382098653..4b821a9d3 100644 --- a/asm/src/test/java/org/objectweb/asm/signature/SignaturesProviders.java +++ b/asm/src/test/java/org/objectweb/asm/signature/SignaturesProviders.java @@ -9,7 +9,6 @@ import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.test.AsmTest.PrecompiledClass; @@ -37,7 +36,7 @@ public final class SignaturesProviders { private static void collectSignatures(final PrecompiledClass classParameter) { ClassReader classReader = new ClassReader(classParameter.getBytes()); classReader.accept( - new ClassVisitor(Opcodes.ASM7) { + new ClassVisitor(AsmTest.LATEST_API) { @Override public void visit( final int version, diff --git a/benchmarks/src/jmh/java/org/objectweb/asm/benchmarks/TypeBenchmark.java b/benchmarks/src/jmh/java/org/objectweb/asm/benchmarks/TypeBenchmark.java index 79505312b..1d80ca662 100644 --- a/benchmarks/src/jmh/java/org/objectweb/asm/benchmarks/TypeBenchmark.java +++ b/benchmarks/src/jmh/java/org/objectweb/asm/benchmarks/TypeBenchmark.java @@ -9,9 +9,9 @@ import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.Handle; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.TypePath; +import org.objectweb.asm.test.AsmTest; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; @@ -88,7 +88,7 @@ public class TypeBenchmark extends AbstractBenchmark { }; CollectTypesVisitor() { - super(Opcodes.ASM7); + super(AsmTest.LATEST_API); } @Override diff --git a/build.gradle b/build.gradle index 174ff81b6..2bf14fd36 100644 --- a/build.gradle +++ b/build.gradle @@ -169,6 +169,7 @@ project(':tools:retrofitter') { // and tested with :asm-test and JUnit. subprojects { apply plugin: 'com.github.sherter.google-java-format' + googleJavaFormat.toolVersion = '1.7' googleJavaFormat.exclude 'src/resources/java/**/*' // Check the coding style with Checkstyle. Fail in case of error or warning. -- GitLab From f8612d6e0cda253f960b07c85bb644f4a9e0dc9b Mon Sep 17 00:00:00 2001 From: forax Date: Mon, 7 Oct 2019 23:37:29 +0200 Subject: [PATCH 4/8] ClassNode field permittedSubtypes should use the Experimental suffix --- .../java/org/objectweb/asm/tree/ClassNode.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java index 139bdc592..cde8fa977 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java @@ -126,8 +126,12 @@ public class ClassNode extends ClassVisitor { /** The internal names of the nest members of this class. May be {@literal null}. */ public List nestMembers; - /** The internal names of the permitted subtypes of this class. May be {@literal null}. */ - public List permittedSubtypes; + /** + * Experimental, use at your own risk. This method will be renamed when it becomes stable, this + * will break existing code using it. The internal names of the permitted subtypes of this + * class. May be {@literal null}. + */ + @Deprecated public List permittedSubtypesExperimental; /** The fields of this class. */ public List fields; @@ -241,7 +245,7 @@ public class ClassNode extends ClassVisitor { @Override public void visitPermittedSubtypeExperimental(final String permittedSubtype) { - permittedSubtypes = Util.add(permittedSubtypes, permittedSubtype); + permittedSubtypesExperimental = Util.add(permittedSubtypesExperimental, permittedSubtype); } @Override @@ -293,7 +297,7 @@ public class ClassNode extends ClassVisitor { * {@link Opcodes#ASM6} or {@link Opcodes#ASM7}. */ public void check(final int api) { - if (api != Opcodes.ASM8_EXPERIMENTAL && permittedSubtypes != null) { + if (api != Opcodes.ASM8_EXPERIMENTAL && permittedSubtypesExperimental != null) { throw new UnsupportedClassVersionException(); } if (api < Opcodes.ASM7 && (nestHostClass != null || nestMembers != null)) { @@ -407,9 +411,9 @@ public class ClassNode extends ClassVisitor { } } // Visit the permitted subtypes. - if (permittedSubtypes != null) { - for (int i = 0, n = permittedSubtypes.size(); i < n; ++i) { - classVisitor.visitPermittedSubtypeExperimental(permittedSubtypes.get(i)); + if (permittedSubtypesExperimental != null) { + for (int i = 0, n = permittedSubtypesExperimental.size(); i < n; ++i) { + classVisitor.visitPermittedSubtypeExperimental(permittedSubtypesExperimental.get(i)); } } // Visit the inner classes. -- GitLab From 0c06fb1b713cea4bd030e52f8c3944372abfad7e Mon Sep 17 00:00:00 2001 From: forax Date: Tue, 8 Oct 2019 21:19:50 +0200 Subject: [PATCH 5/8] remove ACC_SEALED --- .../src/main/java/org/objectweb/asm/util/ASMifier.java | 7 ------- .../java/org/objectweb/asm/util/CheckClassAdapter.java | 6 ++---- .../src/main/java/org/objectweb/asm/util/Textifier.java | 3 --- asm/src/main/java/org/objectweb/asm/ClassReader.java | 1 - asm/src/main/java/org/objectweb/asm/ClassWriter.java | 4 ++-- asm/src/main/java/org/objectweb/asm/Opcodes.java | 1 - asm/src/test/java/org/objectweb/asm/ConstantsTest.java | 3 ++- 7 files changed, 6 insertions(+), 19 deletions(-) diff --git a/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java b/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java index 2353261a5..105bf7c22 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java @@ -1351,13 +1351,6 @@ public class ASMifier extends Printer { stringBuilder.append("ACC_DEPRECATED"); isEmpty = false; } - if ((accessFlags & Opcodes.ACC_SEALED) != 0) { - if (!isEmpty) { - stringBuilder.append(" | "); - } - stringBuilder.append("ACC_SEALED"); - isEmpty = false; - } if ((accessFlags & (Opcodes.ACC_MANDATED | Opcodes.ACC_MODULE)) != 0) { if (!isEmpty) { stringBuilder.append(" | "); diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java index 4f331537f..ae980f765 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java @@ -224,8 +224,7 @@ public class CheckClassAdapter extends ClassVisitor { | Opcodes.ACC_ANNOTATION | Opcodes.ACC_ENUM | Opcodes.ACC_DEPRECATED - | Opcodes.ACC_MODULE - | Opcodes.ACC_SEALED); + | Opcodes.ACC_MODULE); if (name == null) { throw new IllegalArgumentException("Illegal class name (null)"); } @@ -533,8 +532,7 @@ public class CheckClassAdapter extends ClassVisitor { throw new IllegalArgumentException( "public, protected and private are mutually exclusive: " + access); } - if ((access & Opcodes.ACC_SEALED) == 0 - && Integer.bitCount(access & (Opcodes.ACC_FINAL | Opcodes.ACC_ABSTRACT)) > 1) { + if (Integer.bitCount(access & (Opcodes.ACC_FINAL | Opcodes.ACC_ABSTRACT)) > 1) { throw new IllegalArgumentException("final and abstract are mutually exclusive: " + access); } } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java b/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java index 8a6ff3d0f..65d499480 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java @@ -1252,9 +1252,6 @@ public class Textifier extends Printer { if ((accessFlags & Opcodes.ACC_ENUM) != 0) { stringBuilder.append("enum "); } - if ((accessFlags & Opcodes.ACC_SEALED) != 0) { - stringBuilder.append("sealed "); - } } /** diff --git a/asm/src/main/java/org/objectweb/asm/ClassReader.java b/asm/src/main/java/org/objectweb/asm/ClassReader.java index 92bbee0f5..a7520739a 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassReader.java +++ b/asm/src/main/java/org/objectweb/asm/ClassReader.java @@ -492,7 +492,6 @@ public class ClassReader { nestMembersOffset = currentAttributeOffset; } else if (Constants.PERMITTED_SUBTYPES.equals(attributeName)) { permittedSubtypesOffset = currentAttributeOffset; - accessFlags |= Opcodes.ACC_SEALED; } else if (Constants.SIGNATURE.equals(attributeName)) { signature = readUTF8(currentAttributeOffset, charBuffer); } else if (Constants.RUNTIME_VISIBLE_ANNOTATIONS.equals(attributeName)) { diff --git a/asm/src/main/java/org/objectweb/asm/ClassWriter.java b/asm/src/main/java/org/objectweb/asm/ClassWriter.java index c0ca22bf1..9b65508c1 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassWriter.java +++ b/asm/src/main/java/org/objectweb/asm/ClassWriter.java @@ -79,8 +79,8 @@ public class ClassWriter extends ClassVisitor { /** * The access_flags field of the JVMS ClassFile structure. This field can contain ASM specific - * access flags, such as {@link Opcodes#ACC_DEPRECATED}, or {@link Opcodes#ACC_SEALED} which are - * removed when generating the ClassFile structure. + * access flags, such as {@link Opcodes#ACC_DEPRECATED}, which are removed when generating the + * ClassFile structure. */ private int accessFlags; diff --git a/asm/src/main/java/org/objectweb/asm/Opcodes.java b/asm/src/main/java/org/objectweb/asm/Opcodes.java index dc8380fc5..e11867a77 100644 --- a/asm/src/main/java/org/objectweb/asm/Opcodes.java +++ b/asm/src/main/java/org/objectweb/asm/Opcodes.java @@ -323,7 +323,6 @@ public interface Opcodes { // written in class files (because access flags are stored using 16 bits only). int ACC_DEPRECATED = 0x20000; // class, field, method - int ACC_SEALED = 0x40000; // class // Possible values for the type operand of the NEWARRAY instruction. // See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.html#jvms-6.5.newarray. diff --git a/asm/src/test/java/org/objectweb/asm/ConstantsTest.java b/asm/src/test/java/org/objectweb/asm/ConstantsTest.java index 35db5daf9..f9b0cb61d 100644 --- a/asm/src/test/java/org/objectweb/asm/ConstantsTest.java +++ b/asm/src/test/java/org/objectweb/asm/ConstantsTest.java @@ -137,7 +137,8 @@ public class ConstantsTest { List verificationTypeInfoTags = getConstants(ConstantType.VERIFICATION_TYPE_INFO_TAG); Set verificationTypeInfoTagValues = - verificationTypeInfoTags.stream() + verificationTypeInfoTags + .stream() .map(ConstantsTest::getIntegerValue) .collect(Collectors.toSet()); -- GitLab From 189ea5384e46a7fbfda55f41a3f2e4fcc7db6ca1 Mon Sep 17 00:00:00 2001 From: forax Date: Tue, 8 Oct 2019 22:08:16 +0200 Subject: [PATCH 6/8] use ASM7 as default version + change test to use protected constructor --- .../asm/tree/analysis/BasicInterpreter.java | 2 +- .../asm/tree/analysis/BasicVerifier.java | 2 +- .../asm/tree/analysis/SimpleVerifier.java | 7 ++++++- .../asm/tree/analysis/SourceInterpreter.java | 2 +- .../objectweb/asm/commons/AnalyzerAdapter.java | 2 +- .../asm/commons/AnnotationRemapper.java | 2 +- .../objectweb/asm/commons/ClassRemapper.java | 2 +- .../asm/commons/CodeSizeEvaluator.java | 2 +- .../objectweb/asm/commons/FieldRemapper.java | 2 +- .../objectweb/asm/commons/GeneratorAdapter.java | 2 +- .../asm/commons/InstructionAdapter.java | 2 +- .../asm/commons/JSRInlinerAdapter.java | 9 ++++++++- .../asm/commons/LocalVariablesSorter.java | 2 +- .../objectweb/asm/commons/MethodRemapper.java | 2 +- .../objectweb/asm/commons/ModuleRemapper.java | 2 +- .../asm/commons/SerialVersionUIDAdder.java | 2 +- .../asm/commons/SignatureRemapper.java | 2 +- .../objectweb/asm/commons/StaticInitMerger.java | 2 +- .../asm/commons/TryCatchBlockSorter.java | 9 ++++++++- .../main/resources/jdk14/AllStructures.class | Bin 318 -> 318 bytes .../org/objectweb/asm/tree/AnnotationNode.java | 4 ++-- .../java/org/objectweb/asm/tree/FieldNode.java | 2 +- .../asm/tree/LocalVariableAnnotationNode.java | 2 +- .../java/org/objectweb/asm/tree/MethodNode.java | 4 ++-- .../java/org/objectweb/asm/tree/ModuleNode.java | 2 +- .../objectweb/asm/tree/TypeAnnotationNode.java | 2 +- .../java/org/objectweb/asm/util/ASMifier.java | 2 +- .../asm/util/CheckAnnotationAdapter.java | 2 +- .../objectweb/asm/util/CheckClassAdapter.java | 2 +- .../objectweb/asm/util/CheckFieldAdapter.java | 2 +- .../objectweb/asm/util/CheckMethodAdapter.java | 5 +++-- .../objectweb/asm/util/CheckModuleAdapter.java | 2 +- .../asm/util/CheckSignatureAdapter.java | 2 +- .../java/org/objectweb/asm/util/Textifier.java | 2 +- .../asm/util/TraceAnnotationVisitor.java | 2 +- .../objectweb/asm/util/TraceClassVisitor.java | 2 +- .../objectweb/asm/util/TraceFieldVisitor.java | 2 +- .../objectweb/asm/util/TraceMethodVisitor.java | 2 +- .../objectweb/asm/util/TraceModuleVisitor.java | 2 +- .../asm/util/TraceSignatureVisitor.java | 4 ++-- .../asm/util/CheckClassAdapterTest.java | 5 +++-- .../src/test/resources/jdk14.AllStructures.txt | 4 ++-- .../org/objectweb/asm/AnnotationWriter.java | 2 +- .../java/org/objectweb/asm/ClassWriter.java | 2 +- .../java/org/objectweb/asm/FieldWriter.java | 2 +- .../java/org/objectweb/asm/MethodWriter.java | 2 +- .../java/org/objectweb/asm/ModuleWriter.java | 2 +- .../java/org/objectweb/asm/ConstantsTest.java | 3 +-- 48 files changed, 74 insertions(+), 54 deletions(-) diff --git a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicInterpreter.java b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicInterpreter.java index f82fe3e76..b8249dbd7 100644 --- a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicInterpreter.java +++ b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicInterpreter.java @@ -61,7 +61,7 @@ public class BasicInterpreter extends Interpreter implements Opcodes * version. */ public BasicInterpreter() { - super(ASM8_EXPERIMENTAL); + super(/* latest api = */ ASM7); if (getClass() != BasicInterpreter.class) { throw new IllegalStateException(); } diff --git a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicVerifier.java b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicVerifier.java index b91b2c80d..2b7b64bd0 100644 --- a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicVerifier.java +++ b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/BasicVerifier.java @@ -47,7 +47,7 @@ public class BasicVerifier extends BasicInterpreter { * use this constructor. Instead, they must use the {@link #BasicVerifier(int)} version. */ public BasicVerifier() { - super(ASM8_EXPERIMENTAL); + super(/* latest api = */ ASM7); if (getClass() != BasicVerifier.class) { throw new IllegalStateException(); } diff --git a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SimpleVerifier.java b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SimpleVerifier.java index f6fa56100..6b305ca5a 100644 --- a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SimpleVerifier.java +++ b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SimpleVerifier.java @@ -93,7 +93,12 @@ public class SimpleVerifier extends BasicVerifier { final Type currentSuperClass, final List currentClassInterfaces, final boolean isInterface) { - this(ASM8_EXPERIMENTAL, currentClass, currentSuperClass, currentClassInterfaces, isInterface); + this( + /* latest api = */ ASM7, + currentClass, + currentSuperClass, + currentClassInterfaces, + isInterface); if (getClass() != SimpleVerifier.class) { throw new IllegalStateException(); } diff --git a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SourceInterpreter.java b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SourceInterpreter.java index 10c20f978..b987031ca 100644 --- a/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SourceInterpreter.java +++ b/asm-analysis/src/main/java/org/objectweb/asm/tree/analysis/SourceInterpreter.java @@ -51,7 +51,7 @@ public class SourceInterpreter extends Interpreter implements Opcod * version. */ public SourceInterpreter() { - super(ASM8_EXPERIMENTAL); + super(/* latest api = */ ASM7); if (getClass() != SourceInterpreter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/AnalyzerAdapter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/AnalyzerAdapter.java index 84e7f475c..bbf4e57b6 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/AnalyzerAdapter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/AnalyzerAdapter.java @@ -116,7 +116,7 @@ public class AnalyzerAdapter extends MethodVisitor { final String name, final String descriptor, final MethodVisitor methodVisitor) { - this(Opcodes.ASM8_EXPERIMENTAL, owner, access, name, descriptor, methodVisitor); + this(/* latest api = */ Opcodes.ASM7, owner, access, name, descriptor, methodVisitor); if (getClass() != AnalyzerAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/AnnotationRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/AnnotationRemapper.java index 39fb190e6..36e32ad73 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/AnnotationRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/AnnotationRemapper.java @@ -49,7 +49,7 @@ public class AnnotationRemapper extends AnnotationVisitor { * @param remapper the remapper to use to remap the types in the visited annotation. */ public AnnotationRemapper(final AnnotationVisitor annotationVisitor, final Remapper remapper) { - this(Opcodes.ASM8_EXPERIMENTAL, annotationVisitor, remapper); + this(/* latest api = */ Opcodes.ASM7, annotationVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java index 5e1438e77..415746182 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/ClassRemapper.java @@ -73,7 +73,7 @@ public class ClassRemapper extends ClassVisitor { * @param remapper the remapper to use to remap the types in the visited class. */ public ClassRemapper(final ClassVisitor classVisitor, final Remapper remapper) { - this(Opcodes.ASM8_EXPERIMENTAL, classVisitor, remapper); + this(/* latest api = */ Opcodes.ASM7, classVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/CodeSizeEvaluator.java b/asm-commons/src/main/java/org/objectweb/asm/commons/CodeSizeEvaluator.java index 31e3d6a8c..9aee1d37c 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/CodeSizeEvaluator.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/CodeSizeEvaluator.java @@ -47,7 +47,7 @@ public class CodeSizeEvaluator extends MethodVisitor implements Opcodes { private int maxSize; public CodeSizeEvaluator(final MethodVisitor methodVisitor) { - this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor); + this(/* latest api = */ Opcodes.ASM7, methodVisitor); } protected CodeSizeEvaluator(final int api, final MethodVisitor methodVisitor) { diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/FieldRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/FieldRemapper.java index c73555144..b4c818cad 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/FieldRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/FieldRemapper.java @@ -51,7 +51,7 @@ public class FieldRemapper extends FieldVisitor { * @param remapper the remapper to use to remap the types in the visited field. */ public FieldRemapper(final FieldVisitor fieldVisitor, final Remapper remapper) { - this(Opcodes.ASM8_EXPERIMENTAL, fieldVisitor, remapper); + this(/* latest api = */ Opcodes.ASM7, fieldVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/GeneratorAdapter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/GeneratorAdapter.java index 8d551e0a5..283c637da 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/GeneratorAdapter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/GeneratorAdapter.java @@ -201,7 +201,7 @@ public class GeneratorAdapter extends LocalVariablesSorter { final int access, final String name, final String descriptor) { - this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor, access, name, descriptor); + this(/* latest api = */ Opcodes.ASM7, methodVisitor, access, name, descriptor); if (getClass() != GeneratorAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/InstructionAdapter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/InstructionAdapter.java index 4a8801320..2bad7a8fe 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/InstructionAdapter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/InstructionAdapter.java @@ -53,7 +53,7 @@ public class InstructionAdapter extends MethodVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public InstructionAdapter(final MethodVisitor methodVisitor) { - this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor); + this(/* latest api = */ Opcodes.ASM7, methodVisitor); if (getClass() != InstructionAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/JSRInlinerAdapter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/JSRInlinerAdapter.java index bb6d65d77..33bc9715a 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/JSRInlinerAdapter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/JSRInlinerAdapter.java @@ -98,7 +98,14 @@ public class JSRInlinerAdapter extends MethodNode implements Opcodes { final String descriptor, final String signature, final String[] exceptions) { - this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor, access, name, descriptor, signature, exceptions); + this( + /* latest api = */ Opcodes.ASM7, + methodVisitor, + access, + name, + descriptor, + signature, + exceptions); if (getClass() != JSRInlinerAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/LocalVariablesSorter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/LocalVariablesSorter.java index bb8aca456..c139f9e92 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/LocalVariablesSorter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/LocalVariablesSorter.java @@ -81,7 +81,7 @@ public class LocalVariablesSorter extends MethodVisitor { */ public LocalVariablesSorter( final int access, final String descriptor, final MethodVisitor methodVisitor) { - this(Opcodes.ASM8_EXPERIMENTAL, access, descriptor, methodVisitor); + this(/* latest api = */ Opcodes.ASM7, access, descriptor, methodVisitor); if (getClass() != LocalVariablesSorter.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/MethodRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/MethodRemapper.java index fed27422c..3fe7e8331 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/MethodRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/MethodRemapper.java @@ -53,7 +53,7 @@ public class MethodRemapper extends MethodVisitor { * @param remapper the remapper to use to remap the types in the visited method. */ public MethodRemapper(final MethodVisitor methodVisitor, final Remapper remapper) { - this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor, remapper); + this(/* latest api = */ Opcodes.ASM7, methodVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/ModuleRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/ModuleRemapper.java index 3baffbf9b..e3eafba09 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/ModuleRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/ModuleRemapper.java @@ -49,7 +49,7 @@ public class ModuleRemapper extends ModuleVisitor { * @param remapper the remapper to use to remap the types in the visited module. */ public ModuleRemapper(final ModuleVisitor moduleVisitor, final Remapper remapper) { - this(Opcodes.ASM8_EXPERIMENTAL, moduleVisitor, remapper); + this(/* latest api = */ Opcodes.ASM7, moduleVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/SerialVersionUIDAdder.java b/asm-commons/src/main/java/org/objectweb/asm/commons/SerialVersionUIDAdder.java index 0a285235c..d193684b5 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/SerialVersionUIDAdder.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/SerialVersionUIDAdder.java @@ -150,7 +150,7 @@ public class SerialVersionUIDAdder extends ClassVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public SerialVersionUIDAdder(final ClassVisitor classVisitor) { - this(Opcodes.ASM8_EXPERIMENTAL, classVisitor); + this(/* latest api = */ Opcodes.ASM7, classVisitor); if (getClass() != SerialVersionUIDAdder.class) { throw new IllegalStateException(); } diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/SignatureRemapper.java b/asm-commons/src/main/java/org/objectweb/asm/commons/SignatureRemapper.java index 27e125fc7..003759fc1 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/SignatureRemapper.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/SignatureRemapper.java @@ -53,7 +53,7 @@ public class SignatureRemapper extends SignatureVisitor { * @param remapper the remapper to use to remap the types in the visited signature. */ public SignatureRemapper(final SignatureVisitor signatureVisitor, final Remapper remapper) { - this(Opcodes.ASM8_EXPERIMENTAL, signatureVisitor, remapper); + this(/* latest api = */ Opcodes.ASM7, signatureVisitor, remapper); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/StaticInitMerger.java b/asm-commons/src/main/java/org/objectweb/asm/commons/StaticInitMerger.java index 8f9f232b2..eb3b46f54 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/StaticInitMerger.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/StaticInitMerger.java @@ -61,7 +61,7 @@ public class StaticInitMerger extends ClassVisitor { * null. */ public StaticInitMerger(final String prefix, final ClassVisitor classVisitor) { - this(Opcodes.ASM8_EXPERIMENTAL, prefix, classVisitor); + this(/* latest api = */ Opcodes.ASM7, prefix, classVisitor); } /** diff --git a/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java b/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java index 45edf7b7b..4989f6a71 100644 --- a/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java +++ b/asm-commons/src/main/java/org/objectweb/asm/commons/TryCatchBlockSorter.java @@ -70,7 +70,14 @@ public class TryCatchBlockSorter extends MethodNode { final String descriptor, final String signature, final String[] exceptions) { - this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor, access, name, descriptor, signature, exceptions); + this( + /* latest api = */ Opcodes.ASM7, + methodVisitor, + access, + name, + descriptor, + signature, + exceptions); if (getClass() != TryCatchBlockSorter.class) { throw new IllegalStateException(); } diff --git a/asm-test/src/main/resources/jdk14/AllStructures.class b/asm-test/src/main/resources/jdk14/AllStructures.class index abda6ac27d2eeac17c88a1cf0d317d5a33e59971..88ca1ecd6910468ab7392548d906c51e34752221 100644 GIT binary patch delta 11 ScmdnTw2x`RPe#Uxzgz$u!35g? delta 11 ScmdnTw2x`RPe#Fszgz$v0R-y+ diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java index 800415831..3915e3b40 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java @@ -60,7 +60,7 @@ public class AnnotationNode extends AnnotationVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public AnnotationNode(final String descriptor) { - this(Opcodes.ASM8_EXPERIMENTAL, descriptor); + this(/* latest api = */ Opcodes.ASM7, descriptor); if (getClass() != AnnotationNode.class) { throw new IllegalStateException(); } @@ -84,7 +84,7 @@ public class AnnotationNode extends AnnotationVisitor { * @param values where the visited values must be stored. */ AnnotationNode(final List values) { - super(Opcodes.ASM8_EXPERIMENTAL); + super(/* latest api = */ Opcodes.ASM7); this.values = values; } diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java index 07c9b4fef..40f51594f 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java @@ -99,7 +99,7 @@ public class FieldNode extends FieldVisitor { final String descriptor, final String signature, final Object value) { - this(Opcodes.ASM8_EXPERIMENTAL, access, name, descriptor, signature, value); + this(/* latest api = */ Opcodes.ASM7, access, name, descriptor, signature, value); if (getClass() != FieldNode.class) { throw new IllegalStateException(); } diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java index e6038c029..f93bf3aaf 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java @@ -84,7 +84,7 @@ public class LocalVariableAnnotationNode extends TypeAnnotationNode { final LabelNode[] end, final int[] index, final String descriptor) { - this(Opcodes.ASM8_EXPERIMENTAL, typeRef, typePath, start, end, index, descriptor); + this(/* latest api = */ Opcodes.ASM7, typeRef, typePath, start, end, index, descriptor); } /** diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java index edbc738c9..274a02be2 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java @@ -155,7 +155,7 @@ public class MethodNode extends MethodVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public MethodNode() { - this(Opcodes.ASM8_EXPERIMENTAL); + this(/* latest api = */ Opcodes.ASM7); if (getClass() != MethodNode.class) { throw new IllegalStateException(); } @@ -191,7 +191,7 @@ public class MethodNode extends MethodVisitor { final String descriptor, final String signature, final String[] exceptions) { - this(Opcodes.ASM8_EXPERIMENTAL, access, name, descriptor, signature, exceptions); + this(/* latest api = */ Opcodes.ASM7, access, name, descriptor, signature, exceptions); if (getClass() != MethodNode.class) { throw new IllegalStateException(); } diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java index 670d742c3..7fa8a9ded 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java @@ -84,7 +84,7 @@ public class ModuleNode extends ModuleVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public ModuleNode(final String name, final int access, final String version) { - super(Opcodes.ASM8_EXPERIMENTAL); + super(/* latest api = */ Opcodes.ASM7); if (getClass() != ModuleNode.class) { throw new IllegalStateException(); } diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java index 64ee84b39..66825fc42 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java @@ -59,7 +59,7 @@ public class TypeAnnotationNode extends AnnotationNode { * @throws IllegalStateException If a subclass calls this constructor. */ public TypeAnnotationNode(final int typeRef, final TypePath typePath, final String descriptor) { - this(Opcodes.ASM8_EXPERIMENTAL, typeRef, typePath, descriptor); + this(/* latest api = */ Opcodes.ASM7, typeRef, typePath, descriptor); if (getClass() != TypeAnnotationNode.class) { throw new IllegalStateException(); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java b/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java index 105bf7c22..25266df79 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/ASMifier.java @@ -123,7 +123,7 @@ public class ASMifier extends Printer { * @throws IllegalStateException If a subclass calls this constructor. */ public ASMifier() { - this(Opcodes.ASM8_EXPERIMENTAL, "classWriter", 0); + this(/* latest api = */ Opcodes.ASM7, "classWriter", 0); if (getClass() != ASMifier.class) { throw new IllegalStateException(); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckAnnotationAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckAnnotationAdapter.java index d39f96dcc..372658ca8 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckAnnotationAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckAnnotationAdapter.java @@ -52,7 +52,7 @@ public class CheckAnnotationAdapter extends AnnotationVisitor { } CheckAnnotationAdapter(final AnnotationVisitor annotationVisitor, final boolean useNamedValues) { - super(Opcodes.ASM8_EXPERIMENTAL, annotationVisitor); + super(/* latest api = */ Opcodes.ASM7, annotationVisitor); this.useNamedValue = useNamedValues; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java index ae980f765..54117fed4 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckClassAdapter.java @@ -173,7 +173,7 @@ public class CheckClassAdapter extends ClassVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public CheckClassAdapter(final ClassVisitor classVisitor, final boolean checkDataFlow) { - this(Opcodes.ASM8_EXPERIMENTAL, classVisitor, checkDataFlow); + this(/* latest api = */ Opcodes.ASM7, classVisitor, checkDataFlow); if (getClass() != CheckClassAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckFieldAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckFieldAdapter.java index 907e06fdd..12a6eef64 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckFieldAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckFieldAdapter.java @@ -52,7 +52,7 @@ public class CheckFieldAdapter extends FieldVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public CheckFieldAdapter(final FieldVisitor fieldVisitor) { - this(Opcodes.ASM8_EXPERIMENTAL, fieldVisitor); + this(/* latest api = */ Opcodes.ASM7, fieldVisitor); if (getClass() != CheckFieldAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java index 5bdb023c0..7a7813431 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckMethodAdapter.java @@ -366,7 +366,7 @@ public class CheckMethodAdapter extends MethodVisitor { */ public CheckMethodAdapter( final MethodVisitor methodVisitor, final Map labelInsnIndices) { - this(Opcodes.ASM8_EXPERIMENTAL, methodVisitor, labelInsnIndices); + this(/* latest api = */ Opcodes.ASM7, methodVisitor, labelInsnIndices); if (getClass() != CheckMethodAdapter.class) { throw new IllegalStateException(); } @@ -412,7 +412,8 @@ public class CheckMethodAdapter extends MethodVisitor { final String descriptor, final MethodVisitor methodVisitor, final Map labelInsnIndices) { - this(Opcodes.ASM8_EXPERIMENTAL, access, name, descriptor, methodVisitor, labelInsnIndices); + this( + /* latest api = */ Opcodes.ASM7, access, name, descriptor, methodVisitor, labelInsnIndices); if (getClass() != CheckMethodAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckModuleAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckModuleAdapter.java index 580787b8f..f1943da57 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckModuleAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckModuleAdapter.java @@ -71,7 +71,7 @@ public class CheckModuleAdapter extends ModuleVisitor { * @throws IllegalStateException If a subclass calls this constructor. */ public CheckModuleAdapter(final ModuleVisitor moduleVisitor, final boolean isOpen) { - this(Opcodes.ASM8_EXPERIMENTAL, moduleVisitor, isOpen); + this(/* latest api = */ Opcodes.ASM7, moduleVisitor, isOpen); if (getClass() != CheckModuleAdapter.class) { throw new IllegalStateException(); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/CheckSignatureAdapter.java b/asm-util/src/main/java/org/objectweb/asm/util/CheckSignatureAdapter.java index 67ffdd469..800f90bef 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/CheckSignatureAdapter.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/CheckSignatureAdapter.java @@ -123,7 +123,7 @@ public class CheckSignatureAdapter extends SignatureVisitor { * null}. */ public CheckSignatureAdapter(final int type, final SignatureVisitor signatureVisitor) { - this(Opcodes.ASM8_EXPERIMENTAL, type, signatureVisitor); + this(/* latest api = */ Opcodes.ASM7, type, signatureVisitor); } /** diff --git a/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java b/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java index 65d499480..3fb36499f 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/Textifier.java @@ -111,7 +111,7 @@ public class Textifier extends Printer { * @throws IllegalStateException If a subclass calls this constructor. */ public Textifier() { - this(Opcodes.ASM8_EXPERIMENTAL); + this(/* latest api = */ Opcodes.ASM7); if (getClass() != Textifier.class) { throw new IllegalStateException(); } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceAnnotationVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceAnnotationVisitor.java index 15bda3b90..01b22a753 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceAnnotationVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceAnnotationVisitor.java @@ -57,7 +57,7 @@ public final class TraceAnnotationVisitor extends AnnotationVisitor { * @param printer the printer to convert the visited annotation into text. */ public TraceAnnotationVisitor(final AnnotationVisitor annotationVisitor, final Printer printer) { - super(Opcodes.ASM8_EXPERIMENTAL, annotationVisitor); + super(/* latest api = */ Opcodes.ASM7, annotationVisitor); this.printer = printer; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java index e0b5924dd..12397fe8b 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceClassVisitor.java @@ -118,7 +118,7 @@ public final class TraceClassVisitor extends ClassVisitor { */ public TraceClassVisitor( final ClassVisitor classVisitor, final Printer printer, final PrintWriter printWriter) { - super(Opcodes.ASM8_EXPERIMENTAL, classVisitor); + super(/* latest api = */ Opcodes.ASM8_EXPERIMENTAL, classVisitor); this.printWriter = printWriter; this.p = printer; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceFieldVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceFieldVisitor.java index 475138ebb..642cf0d6e 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceFieldVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceFieldVisitor.java @@ -60,7 +60,7 @@ public final class TraceFieldVisitor extends FieldVisitor { * @param printer the printer to convert the visited field into text. */ public TraceFieldVisitor(final FieldVisitor fieldVisitor, final Printer printer) { - super(Opcodes.ASM8_EXPERIMENTAL, fieldVisitor); + super(/* latest api = */ Opcodes.ASM7, fieldVisitor); this.p = printer; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceMethodVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceMethodVisitor.java index f0c43b975..6a06c48b1 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceMethodVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceMethodVisitor.java @@ -62,7 +62,7 @@ public final class TraceMethodVisitor extends MethodVisitor { * @param printer the printer to convert the visited method into text. */ public TraceMethodVisitor(final MethodVisitor methodVisitor, final Printer printer) { - super(Opcodes.ASM8_EXPERIMENTAL, methodVisitor); + super(/* latest api = */ Opcodes.ASM7, methodVisitor); this.p = printer; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceModuleVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceModuleVisitor.java index ea57ea6b6..b08ed6c7e 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceModuleVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceModuleVisitor.java @@ -57,7 +57,7 @@ public final class TraceModuleVisitor extends ModuleVisitor { * @param printer the printer to convert the visited module into text. */ public TraceModuleVisitor(final ModuleVisitor moduleVisitor, final Printer printer) { - super(Opcodes.ASM8_EXPERIMENTAL, moduleVisitor); + super(/* latest api = */ Opcodes.ASM7, moduleVisitor); this.p = printer; } diff --git a/asm-util/src/main/java/org/objectweb/asm/util/TraceSignatureVisitor.java b/asm-util/src/main/java/org/objectweb/asm/util/TraceSignatureVisitor.java index be0069812..77ffe4ff1 100644 --- a/asm-util/src/main/java/org/objectweb/asm/util/TraceSignatureVisitor.java +++ b/asm-util/src/main/java/org/objectweb/asm/util/TraceSignatureVisitor.java @@ -109,13 +109,13 @@ public final class TraceSignatureVisitor extends SignatureVisitor { * @param accessFlags for class type signatures, the access flags of the class. */ public TraceSignatureVisitor(final int accessFlags) { - super(Opcodes.ASM8_EXPERIMENTAL); + super(/* latest api = */ Opcodes.ASM7); this.isInterface = (accessFlags & Opcodes.ACC_INTERFACE) != 0; this.declaration = new StringBuilder(); } private TraceSignatureVisitor(final StringBuilder stringBuilder) { - super(Opcodes.ASM8_EXPERIMENTAL); + super(/* latest api = */ Opcodes.ASM7); this.isInterface = false; this.declaration = stringBuilder; } diff --git a/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java b/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java index 844df172a..82929f96c 100644 --- a/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java +++ b/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java @@ -404,7 +404,7 @@ public class CheckClassAdapterTest extends AsmTest implements Opcodes { final PrecompiledClass classParameter, final Api apiParameter) { byte[] classFile = classParameter.getBytes(); ClassReader classReader = new ClassReader(classFile); - ClassVisitor classVisitor = new CheckClassAdapter(null); + ClassVisitor classVisitor = new CheckClassAdapter(apiParameter.value(), null, true) {}; Executable accept = () -> classReader.accept(classVisitor, attributes(), 0); @@ -418,7 +418,8 @@ public class CheckClassAdapterTest extends AsmTest implements Opcodes { byte[] classFile = classParameter.getBytes(); ClassReader classReader = new ClassReader(classFile); ClassVisitor classVisitor = - new CheckClassAdapter(new ClassVisitor(AsmTest.LATEST_API, null) {}); + new CheckClassAdapter( + apiParameter.value(), new ClassVisitor(AsmTest.LATEST_API, null) {}, true) {}; Executable accept = () -> classReader.accept(classVisitor, attributes(), 0); diff --git a/asm-util/src/test/resources/jdk14.AllStructures.txt b/asm-util/src/test/resources/jdk14.AllStructures.txt index 95ac4c537..9dfe2bd03 100644 --- a/asm-util/src/test/resources/jdk14.AllStructures.txt +++ b/asm-util/src/test/resources/jdk14.AllStructures.txt @@ -1,6 +1,6 @@ // class version 58.65535 (-65478) -// access flags 0x40611 -public final abstract sealed interface jdk14/AllStructures { +// access flags 0x601 +public abstract interface jdk14/AllStructures { // compiled from: AllStructures.java NESTMEMBER jdk14/AllStructures$RecordSubType diff --git a/asm/src/main/java/org/objectweb/asm/AnnotationWriter.java b/asm/src/main/java/org/objectweb/asm/AnnotationWriter.java index b48e58024..009d94bb9 100644 --- a/asm/src/main/java/org/objectweb/asm/AnnotationWriter.java +++ b/asm/src/main/java/org/objectweb/asm/AnnotationWriter.java @@ -112,7 +112,7 @@ final class AnnotationWriter extends AnnotationVisitor { final boolean useNamedValues, final ByteVector annotation, final AnnotationWriter previousAnnotation) { - super(Opcodes.ASM8_EXPERIMENTAL); + super(/* latest api = */ Opcodes.ASM7); this.symbolTable = symbolTable; this.useNamedValues = useNamedValues; this.annotation = annotation; diff --git a/asm/src/main/java/org/objectweb/asm/ClassWriter.java b/asm/src/main/java/org/objectweb/asm/ClassWriter.java index 9b65508c1..40c2af033 100644 --- a/asm/src/main/java/org/objectweb/asm/ClassWriter.java +++ b/asm/src/main/java/org/objectweb/asm/ClassWriter.java @@ -240,7 +240,7 @@ public class ClassWriter extends ClassVisitor { * maximum stack size nor the stack frames will be computed for these methods. */ public ClassWriter(final ClassReader classReader, final int flags) { - super(Opcodes.ASM8_EXPERIMENTAL); + super(/* latest api = */ Opcodes.ASM7); symbolTable = classReader == null ? new SymbolTable(this) : new SymbolTable(this, classReader); if ((flags & COMPUTE_FRAMES) != 0) { this.compute = MethodWriter.COMPUTE_ALL_FRAMES; diff --git a/asm/src/main/java/org/objectweb/asm/FieldWriter.java b/asm/src/main/java/org/objectweb/asm/FieldWriter.java index c4672c25b..bd5fd858f 100644 --- a/asm/src/main/java/org/objectweb/asm/FieldWriter.java +++ b/asm/src/main/java/org/objectweb/asm/FieldWriter.java @@ -124,7 +124,7 @@ final class FieldWriter extends FieldVisitor { final String descriptor, final String signature, final Object constantValue) { - super(Opcodes.ASM8_EXPERIMENTAL); + super(/* latest api = */ Opcodes.ASM7); this.symbolTable = symbolTable; this.accessFlags = access; this.nameIndex = symbolTable.addConstantUtf8(name); diff --git a/asm/src/main/java/org/objectweb/asm/MethodWriter.java b/asm/src/main/java/org/objectweb/asm/MethodWriter.java index de198e5f6..0eda40c75 100644 --- a/asm/src/main/java/org/objectweb/asm/MethodWriter.java +++ b/asm/src/main/java/org/objectweb/asm/MethodWriter.java @@ -592,7 +592,7 @@ final class MethodWriter extends MethodVisitor { final String signature, final String[] exceptions, final int compute) { - super(Opcodes.ASM8_EXPERIMENTAL); + super(/* latest api = */ Opcodes.ASM7); this.symbolTable = symbolTable; this.accessFlags = "".equals(name) ? access | Constants.ACC_CONSTRUCTOR : access; this.nameIndex = symbolTable.addConstantUtf8(name); diff --git a/asm/src/main/java/org/objectweb/asm/ModuleWriter.java b/asm/src/main/java/org/objectweb/asm/ModuleWriter.java index 3bb5ce59d..b7015f502 100644 --- a/asm/src/main/java/org/objectweb/asm/ModuleWriter.java +++ b/asm/src/main/java/org/objectweb/asm/ModuleWriter.java @@ -94,7 +94,7 @@ final class ModuleWriter extends ModuleVisitor { private int mainClassIndex; ModuleWriter(final SymbolTable symbolTable, final int name, final int access, final int version) { - super(Opcodes.ASM8_EXPERIMENTAL); + super(/* latest api = */ Opcodes.ASM7); this.symbolTable = symbolTable; this.moduleNameIndex = name; this.moduleFlags = access; diff --git a/asm/src/test/java/org/objectweb/asm/ConstantsTest.java b/asm/src/test/java/org/objectweb/asm/ConstantsTest.java index f9b0cb61d..35db5daf9 100644 --- a/asm/src/test/java/org/objectweb/asm/ConstantsTest.java +++ b/asm/src/test/java/org/objectweb/asm/ConstantsTest.java @@ -137,8 +137,7 @@ public class ConstantsTest { List verificationTypeInfoTags = getConstants(ConstantType.VERIFICATION_TYPE_INFO_TAG); Set verificationTypeInfoTagValues = - verificationTypeInfoTags - .stream() + verificationTypeInfoTags.stream() .map(ConstantsTest::getIntegerValue) .collect(Collectors.toSet()); -- GitLab From f903330ef0cf5f0676b287ef06ab4014578e551c Mon Sep 17 00:00:00 2001 From: forax Date: Tue, 8 Oct 2019 23:02:00 +0200 Subject: [PATCH 7/8] remove LATEST_API --- .../asm/tree/analysis/AnalyzerTest.java | 2 +- .../AnalyzerWithBasicInterpreterTest.java | 2 +- .../asm/tree/analysis/SimpleVerifierTest.java | 11 +++-- .../asm/commons/AdviceAdapterTest.java | 11 +++-- .../asm/commons/AnalyzerAdapterTest.java | 2 +- .../asm/commons/ClassRemapperTest.java | 2 +- .../asm/commons/GeneratorAdapterTest.java | 7 ++- .../asm/commons/LocalVariablesSorterTest.java | 2 +- .../commons/ModuleHashesAttributeTest.java | 4 +- .../ModuleResolutionAttributeTest.java | 4 +- .../commons/ModuleTargetAttributeTest.java | 4 +- .../commons/SerialVersionUidAdderTest.java | 3 +- .../java/org/objectweb/asm/test/AsmTest.java | 3 -- .../asm/tree/AnnotationNodeTest.java | 3 +- .../org/objectweb/asm/tree/InsnListTest.java | 4 +- .../objectweb/asm/tree/ModuleNodeTest.java | 14 +++++- .../asm/util/CheckClassAdapterTest.java | 4 +- .../org/objectweb/asm/util/PrinterTest.java | 43 +++++++++---------- .../asm/util/SignaturesProviders.java | 3 +- .../org/objectweb/asm/ClassReaderTest.java | 7 +-- .../org/objectweb/asm/ClassVisitorTest.java | 12 +++--- .../org/objectweb/asm/MethodVisitorTest.java | 2 +- .../asm/signature/SignatureReaderTest.java | 10 +++-- .../asm/signature/SignaturesProviders.java | 3 +- .../asm/benchmarks/TypeBenchmark.java | 4 +- 25 files changed, 98 insertions(+), 68 deletions(-) diff --git a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerTest.java b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerTest.java index 3771718b9..80644ace6 100644 --- a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerTest.java +++ b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerTest.java @@ -1173,7 +1173,7 @@ public class AnalyzerTest extends AsmTest { private static class MockInterpreter extends Interpreter { MockInterpreter() { - super(LATEST_API); + super(/* latest */ Opcodes.ASM8_EXPERIMENTAL); } @Override diff --git a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java index c80f4d213..1ea146a64 100644 --- a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java +++ b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/AnalyzerWithBasicInterpreterTest.java @@ -125,7 +125,7 @@ public class AnalyzerWithBasicInterpreterTest extends AsmTest { new ClassReader(PrecompiledClass.JDK8_ALL_FRAMES.getBytes()).accept(classNode, 0); Analyzer analyzer = new Analyzer( - new BasicInterpreter(LATEST_API) { + new BasicInterpreter(/* latest */ Opcodes.ASM8_EXPERIMENTAL) { @Override public BasicValue merge(final BasicValue value1, final BasicValue value2) { return new BasicValue(super.merge(value1, value2).getType()); diff --git a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java index cd8783b5b..5a8a42d2a 100644 --- a/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java +++ b/asm-analysis/src/test/java/org/objectweb/asm/tree/analysis/SimpleVerifierTest.java @@ -37,8 +37,8 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.CsvSource; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; -import org.objectweb.asm.test.AsmTest; /** * Unit tests for {@link SimpleVerifier}. @@ -82,7 +82,11 @@ public class SimpleVerifierTest { Type interfaceType = Type.getObjectType("I"); SimpleVerifier simpleVerifier = new SimpleVerifier( - AsmTest.LATEST_API, baseType, superType, Arrays.asList(interfaceType), false) { + /* latest */ Opcodes.ASM8_EXPERIMENTAL, + baseType, + superType, + Arrays.asList(interfaceType), + false) { @Override public boolean isAssignableFrom(final Type type1, final Type type2) { @@ -115,7 +119,8 @@ public class SimpleVerifierTest { Type baseType = Type.getObjectType("C"); Type interfaceType = Type.getObjectType("I"); SimpleVerifier simpleVerifier = - new SimpleVerifier(AsmTest.LATEST_API, interfaceType, null, null, true) { + new SimpleVerifier( + /* latest */ Opcodes.ASM8_EXPERIMENTAL, interfaceType, null, null, true) { @Override protected Type getSuperClass(final Type type) { diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/AdviceAdapterTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/AdviceAdapterTest.java index fc71769eb..8023c1ecc 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/AdviceAdapterTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/AdviceAdapterTest.java @@ -557,8 +557,8 @@ public class AdviceAdapterTest extends AsmTest { MethodNode outputMethod = new MethodNode(Opcodes.ACC_PUBLIC, "", "(I)V", null, null); AdviceAdapter adviceAdapter = new AdviceAdapter( - LATEST_API, - new MethodVisitor(LATEST_API, outputMethod) {}, + /* latest */ Opcodes.ASM8_EXPERIMENTAL, + new MethodVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL, outputMethod) {}, Opcodes.ACC_PUBLIC, "", "()V") { @@ -616,7 +616,12 @@ public class AdviceAdapterTest extends AsmTest { private static class BasicAdviceAdapter extends AdviceAdapter { BasicAdviceAdapter(final MethodVisitor methodVisitor) { - super(LATEST_API, methodVisitor, Opcodes.ACC_PUBLIC, "", "(I)V"); + super( + /* latest */ Opcodes.ASM8_EXPERIMENTAL, + methodVisitor, + Opcodes.ACC_PUBLIC, + "", + "(I)V"); } @Override diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/AnalyzerAdapterTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/AnalyzerAdapterTest.java index 3a71e2de2..3d22a449e 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/AnalyzerAdapterTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/AnalyzerAdapterTest.java @@ -181,7 +181,7 @@ public class AnalyzerAdapterTest extends AsmTest { private boolean hasOriginalFrame; AnalyzedFramesInserter(final MethodVisitor methodVisitor) { - super(LATEST_API, methodVisitor); + super(/* latest */ Opcodes.ASM8_EXPERIMENTAL, methodVisitor); } void setAnalyzerAdapter(final AnalyzerAdapter analyzerAdapter) { diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/ClassRemapperTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/ClassRemapperTest.java index a311fd194..3e1e47b78 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/ClassRemapperTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/ClassRemapperTest.java @@ -149,7 +149,7 @@ public class ClassRemapperTest extends AsmTest { ClassNode classNode = new ClassNode(); ClassRemapper classRemapper = new ClassRemapper( - LATEST_API, + /* latest */ Opcodes.ASM8_EXPERIMENTAL, classNode, new Remapper() { @Override diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/GeneratorAdapterTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/GeneratorAdapterTest.java index 44b1a07f6..c6d0fd617 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/GeneratorAdapterTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/GeneratorAdapterTest.java @@ -45,7 +45,6 @@ import org.objectweb.asm.Handle; import org.objectweb.asm.Label; import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; -import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.tree.ClassNode; import org.objectweb.asm.tree.MethodNode; import org.objectweb.asm.util.Textifier; @@ -849,7 +848,11 @@ public class GeneratorAdapterTest { textifier = new Textifier(); generatorAdapter = new GeneratorAdapter( - AsmTest.LATEST_API, new TraceMethodVisitor(textifier), access, name, descriptor); + /* latest */ Opcodes.ASM8_EXPERIMENTAL, + new TraceMethodVisitor(textifier), + access, + name, + descriptor); } public String push(final boolean value) { diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/LocalVariablesSorterTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/LocalVariablesSorterTest.java index d1911c56a..c95f93efe 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/LocalVariablesSorterTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/LocalVariablesSorterTest.java @@ -218,7 +218,7 @@ public class LocalVariablesSorterTest extends AsmTest { new ClassReader(Files.newInputStream(Paths.get("src/test/resources/Issue317586.class"))); ClassWriter classWriter = new ClassWriter(0); ClassVisitor localVariablesSorter = - new LocalVariablesSorterClassAdapter(LATEST_API, classWriter); + new LocalVariablesSorterClassAdapter(/* latest */ Opcodes.ASM8_EXPERIMENTAL, classWriter); classReader.accept(localVariablesSorter, ClassReader.EXPAND_FRAMES); diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleHashesAttributeTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleHashesAttributeTest.java index dca377d28..49d59afa2 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleHashesAttributeTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleHashesAttributeTest.java @@ -36,7 +36,7 @@ import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.test.AsmTest; +import org.objectweb.asm.Opcodes; /** * Unit tests for {@link ModuleHashesAttribute}. @@ -60,7 +60,7 @@ public class ModuleHashesAttributeTest { ModuleHashesAttribute moduleHashesAttribute = new ModuleHashesAttribute(); new ClassReader(classWriter.toByteArray()) .accept( - new ClassVisitor(AsmTest.LATEST_API) { + new ClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) { @Override public void visitAttribute(final Attribute attribute) { diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleResolutionAttributeTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleResolutionAttributeTest.java index 7ef1f8c52..5bad87b60 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleResolutionAttributeTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleResolutionAttributeTest.java @@ -34,7 +34,7 @@ import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.test.AsmTest; +import org.objectweb.asm.Opcodes; /** * Unit tests for {@link ModuleResolutionAttribute}. @@ -51,7 +51,7 @@ public class ModuleResolutionAttributeTest { ModuleResolutionAttribute moduleResolutionAttribute = new ModuleResolutionAttribute(); new ClassReader(classWriter.toByteArray()) .accept( - new ClassVisitor(AsmTest.LATEST_API) { + new ClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) { @Override public void visitAttribute(final Attribute attribute) { diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleTargetAttributeTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleTargetAttributeTest.java index 1cacb0e23..39efd9db1 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleTargetAttributeTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/ModuleTargetAttributeTest.java @@ -34,7 +34,7 @@ import org.objectweb.asm.Attribute; import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.test.AsmTest; +import org.objectweb.asm.Opcodes; /** * Unit tests for {@link ModuleTargetAttribute}. @@ -51,7 +51,7 @@ public class ModuleTargetAttributeTest { ModuleTargetAttribute moduleTargetAttribute = new ModuleTargetAttribute(); new ClassReader(classWriter.toByteArray()) .accept( - new ClassVisitor(AsmTest.LATEST_API) { + new ClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) { @Override public void visitAttribute(final Attribute attribute) { diff --git a/asm-commons/src/test/java/org/objectweb/asm/commons/SerialVersionUidAdderTest.java b/asm-commons/src/test/java/org/objectweb/asm/commons/SerialVersionUidAdderTest.java index 3ff7d0f59..58716a759 100644 --- a/asm-commons/src/test/java/org/objectweb/asm/commons/SerialVersionUidAdderTest.java +++ b/asm-commons/src/test/java/org/objectweb/asm/commons/SerialVersionUidAdderTest.java @@ -122,7 +122,8 @@ public class SerialVersionUidAdderTest extends AsmTest { ClassReader classReader = new ClassReader(classParameter.getBytes()); ClassWriter classWriter = new ClassWriter(0); - classReader.accept(new SerialVersionUIDAdder(LATEST_API, classWriter), 0); + classReader.accept( + new SerialVersionUIDAdder(/* latest */ Opcodes.ASM8_EXPERIMENTAL, classWriter), 0); if ((classReader.getAccess() & Opcodes.ACC_ENUM) == 0) { assertTrue(new ClassFile(classWriter.toByteArray()).toString().contains("serialVersionUID")); diff --git a/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java b/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java index 632c33445..b9d5b4809 100644 --- a/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java +++ b/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java @@ -94,9 +94,6 @@ public abstract class AsmTest { */ public static final String UNSUPPORTED_OPERATION_MESSAGE_PATTERN = ".* requires ASM[5678].*"; - /** Value of the latest API. */ - public static final int LATEST_API = Api.ASM8.value(); - /** * A precompiled class, hand-crafted to contain some set of class file structures. These classes * are not compiled as part of the build. Instead, they have been compiled beforehand, with the diff --git a/asm-tree/src/test/java/org/objectweb/asm/tree/AnnotationNodeTest.java b/asm-tree/src/test/java/org/objectweb/asm/tree/AnnotationNodeTest.java index 7123a110c..4db26993f 100644 --- a/asm-tree/src/test/java/org/objectweb/asm/tree/AnnotationNodeTest.java +++ b/asm-tree/src/test/java/org/objectweb/asm/tree/AnnotationNodeTest.java @@ -35,6 +35,7 @@ import java.util.Arrays; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.objectweb.asm.AnnotationVisitor; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; /** @@ -102,7 +103,7 @@ public class AnnotationNodeTest extends AsmTest { annotationNode.visitAnnotation("annotation", "Lpkg/Annotation;"); AnnotationNode dstAnnotationNode = new AnnotationNode("LJ;"); AnnotationVisitor skipNestedAnnotationsVisitor = - new AnnotationVisitor(LATEST_API, dstAnnotationNode) { + new AnnotationVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL, dstAnnotationNode) { @Override public AnnotationVisitor visitAnnotation(final String name, final String descriptor) { diff --git a/asm-tree/src/test/java/org/objectweb/asm/tree/InsnListTest.java b/asm-tree/src/test/java/org/objectweb/asm/tree/InsnListTest.java index 66beff010..1a523e738 100644 --- a/asm-tree/src/test/java/org/objectweb/asm/tree/InsnListTest.java +++ b/asm-tree/src/test/java/org/objectweb/asm/tree/InsnListTest.java @@ -41,7 +41,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; -import org.objectweb.asm.test.AsmTest; +import org.objectweb.asm.Opcodes; /** * Unit tests for {@link InsnList}. @@ -109,7 +109,7 @@ public class InsnListTest { InsnList dstInsnList = new InsnList(); insnList.accept( - new MethodVisitor(AsmTest.LATEST_API) { + new MethodVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) { @Override public void visitInsn(final int opcode) { dstInsnList.add(new InsnNode(opcode)); diff --git a/asm-tree/src/test/java/org/objectweb/asm/tree/ModuleNodeTest.java b/asm-tree/src/test/java/org/objectweb/asm/tree/ModuleNodeTest.java index d1d2e3e08..0dab5d2f8 100644 --- a/asm-tree/src/test/java/org/objectweb/asm/tree/ModuleNodeTest.java +++ b/asm-tree/src/test/java/org/objectweb/asm/tree/ModuleNodeTest.java @@ -34,6 +34,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.ModuleVisitor; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; /** @@ -47,7 +48,16 @@ public class ModuleNodeTest extends AsmTest { public void testConstructor() { ModuleNode moduleNode1 = new ModuleNode("module1", 123, "1.0"); ModuleNode moduleNode2 = - new ModuleNode(LATEST_API, "module2", 456, "2.0", null, null, null, null, null); + new ModuleNode( + /* latest */ Opcodes.ASM8_EXPERIMENTAL, + "module2", + 456, + "2.0", + null, + null, + null, + null, + null); assertEquals("module1", moduleNode1.name); assertEquals(123, moduleNode1.access); @@ -69,7 +79,7 @@ public class ModuleNodeTest extends AsmTest { ModuleNode moduleNode = new ModuleNode("module", 123, "1.0"); ModuleNode dstModuleNode = new ModuleNode("", 0, ""); ClassVisitor copyModuleVisitor = - new ClassVisitor(LATEST_API) { + new ClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) { @Override public ModuleVisitor visitModule( final String name, final int access, final String version) { diff --git a/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java b/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java index 82929f96c..01352b521 100644 --- a/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java +++ b/asm-util/src/test/java/org/objectweb/asm/util/CheckClassAdapterTest.java @@ -419,7 +419,9 @@ public class CheckClassAdapterTest extends AsmTest implements Opcodes { ClassReader classReader = new ClassReader(classFile); ClassVisitor classVisitor = new CheckClassAdapter( - apiParameter.value(), new ClassVisitor(AsmTest.LATEST_API, null) {}, true) {}; + apiParameter.value(), + new ClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL, null) {}, + true) {}; Executable accept = () -> classReader.accept(classVisitor, attributes(), 0); diff --git a/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java b/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java index 232d4d05c..d19e68a00 100644 --- a/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java +++ b/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java @@ -36,7 +36,6 @@ import org.objectweb.asm.Attribute; import org.objectweb.asm.Handle; import org.objectweb.asm.Label; import org.objectweb.asm.Opcodes; -import org.objectweb.asm.test.AsmTest; /** * Unit tests for {@link Printer}. @@ -49,7 +48,7 @@ public class PrinterTest { @Test public void testVisitModule_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitModule = () -> printer.visitModule(null, 0, null); @@ -59,7 +58,7 @@ public class PrinterTest { @Test public void testVisitNestHost_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitNestHost = () -> printer.visitNestHost(null); @@ -69,7 +68,7 @@ public class PrinterTest { @Test public void testVisitClassTypeAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitClassTypeAnnotation = () -> printer.visitClassTypeAnnotation(0, null, null, false); @@ -81,7 +80,7 @@ public class PrinterTest { @Test public void testVisitNestMember_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitNestMember = () -> printer.visitNestMember(null); @@ -102,7 +101,7 @@ public class PrinterTest { @Test public void testVisitMainClass_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitMainClass = () -> printer.visitMainClass(null); @@ -112,7 +111,7 @@ public class PrinterTest { @Test public void testVisitPackage_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitPackage = () -> printer.visitPackage(null); @@ -122,7 +121,7 @@ public class PrinterTest { @Test public void testVisitRequire_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitRequire = () -> printer.visitRequire(null, 0, null); @@ -132,7 +131,7 @@ public class PrinterTest { @Test public void testVisitExport_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitExport = () -> printer.visitExport(null, 0); @@ -142,7 +141,7 @@ public class PrinterTest { @Test public void testVisitOpen_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitOpen = () -> printer.visitOpen(null, 0); @@ -152,7 +151,7 @@ public class PrinterTest { @Test public void testVisitUse_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitUse = () -> printer.visitUse(null); @@ -162,7 +161,7 @@ public class PrinterTest { @Test public void testVisitProvide_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitProvide = () -> printer.visitProvide(null); @@ -172,7 +171,7 @@ public class PrinterTest { @Test public void testVisitModuleEnd_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitModuleEnd = () -> printer.visitModuleEnd(); @@ -182,7 +181,7 @@ public class PrinterTest { @Test public void testVisitFieldTypeAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitFieldTypeAnnotation = () -> printer.visitFieldTypeAnnotation(0, null, null, false); @@ -194,7 +193,7 @@ public class PrinterTest { @Test public void testVisitParameter_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitParameter = () -> printer.visitParameter(null, 0); @@ -204,7 +203,7 @@ public class PrinterTest { @Test public void testVisitMethodTypeAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitMethodTypeAnnotation = () -> printer.visitMethodTypeAnnotation(0, null, null, false); @@ -216,7 +215,7 @@ public class PrinterTest { @Test public void testVisitAnnotableParameterCount_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitAnnotableParameterCount = () -> printer.visitAnnotableParameterCount(0, false); @@ -238,7 +237,7 @@ public class PrinterTest { @Test public void testVisitMethodInsn_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitMethodInsn = () -> printer.visitMethodInsn(Opcodes.INVOKESPECIAL, "owner", "name", "()V", false); @@ -249,7 +248,7 @@ public class PrinterTest { @Test public void testVisitMethodInsn_ifItf_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitMethodInsn = () -> printer.visitMethodInsn(Opcodes.INVOKESPECIAL, "owner", "name", "()V", true); @@ -260,7 +259,7 @@ public class PrinterTest { @Test public void testVisitInsnAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitInsnAnnotation = () -> printer.visitInsnAnnotation(0, null, null, false); @@ -270,7 +269,7 @@ public class PrinterTest { @Test public void testVisitTryCatchAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitTryCatchAnnotation = () -> printer.visitTryCatchAnnotation(0, null, null, false); @@ -282,7 +281,7 @@ public class PrinterTest { @Test public void testVisitLocalVariableAnnotation_unsupportedByDefault() { - Printer printer = new EmptyPrinter(AsmTest.LATEST_API); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); Executable visitLocalVariableAnnotation = () -> printer.visitLocalVariableAnnotation(0, null, null, null, null, null, false); diff --git a/asm-util/src/test/java/org/objectweb/asm/util/SignaturesProviders.java b/asm-util/src/test/java/org/objectweb/asm/util/SignaturesProviders.java index a19edac5d..dceb914ec 100644 --- a/asm-util/src/test/java/org/objectweb/asm/util/SignaturesProviders.java +++ b/asm-util/src/test/java/org/objectweb/asm/util/SignaturesProviders.java @@ -9,6 +9,7 @@ import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.test.AsmTest.PrecompiledClass; @@ -36,7 +37,7 @@ public final class SignaturesProviders { private static void collectSignatures(final PrecompiledClass classParameter) { ClassReader classReader = new ClassReader(classParameter.getBytes()); classReader.accept( - new ClassVisitor(AsmTest.LATEST_API) { + new ClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) { @Override public void visit( final int version, diff --git a/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java b/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java index 97d3136f0..df649189f 100644 --- a/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java +++ b/asm/src/test/java/org/objectweb/asm/ClassReaderTest.java @@ -417,7 +417,8 @@ public class ClassReaderTest extends AsmTest implements Opcodes { || invalidClass == InvalidClass.INVALID_CP_INFO_TAG); ClassReader classReader = new ClassReader(invalidClass.getBytes()); - Executable accept = () -> classReader.accept(new EmptyClassVisitor(LATEST_API), 0); + Executable accept = + () -> classReader.accept(new EmptyClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL), 0); if (invalidClass == InvalidClass.INVALID_CONSTANT_POOL_INDEX || invalidClass == InvalidClass.INVALID_CONSTANT_POOL_REFERENCE @@ -525,7 +526,7 @@ public class ClassReaderTest extends AsmTest implements Opcodes { ClassReader classReader = new ClassReader(PrecompiledClass.JDK5_LOCAL_CLASS.getBytes()); AtomicInteger parameterIndex = new AtomicInteger(-1); ClassVisitor readParameterIndexVisitor = - new ClassVisitor(LATEST_API) { + new ClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) { @Override public MethodVisitor visitMethod( final int access, @@ -560,7 +561,7 @@ public class ClassReaderTest extends AsmTest implements Opcodes { ClassReader classReader = new ClassReader(classFile); AtomicInteger classVersion = new AtomicInteger(0); ClassVisitor readVersionVisitor = - new ClassVisitor(LATEST_API) { + new ClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) { @Override public void visit( final int version, diff --git a/asm/src/test/java/org/objectweb/asm/ClassVisitorTest.java b/asm/src/test/java/org/objectweb/asm/ClassVisitorTest.java index f9b45b9cf..e81e2af8f 100644 --- a/asm/src/test/java/org/objectweb/asm/ClassVisitorTest.java +++ b/asm/src/test/java/org/objectweb/asm/ClassVisitorTest.java @@ -250,7 +250,7 @@ public class ClassVisitorTest extends AsmTest { ClassReader classReader = new ClassReader(classFile); ClassWriter classWriter = new ClassWriter(0); ClassVisitor classVisitor = - new ClassVisitor(LATEST_API, classWriter) { + new ClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL, classWriter) { @Override public ModuleVisitor visitModule( @@ -454,7 +454,7 @@ public class ClassVisitorTest extends AsmTest { private static class ChangeExceptionAdapter extends ClassVisitor { ChangeExceptionAdapter(final ClassVisitor classVisitor) { - super(LATEST_API, classVisitor); + super(/* latest */ Opcodes.ASM8_EXPERIMENTAL, classVisitor); } @Override @@ -476,7 +476,7 @@ public class ClassVisitorTest extends AsmTest { private final int newVersion; ChangeVersionAdapter(final ClassVisitor classVisitor, final int newVersion) { - super(LATEST_API, classVisitor); + super(/* latest */ Opcodes.ASM8_EXPERIMENTAL, classVisitor); this.newVersion = newVersion; } @@ -497,7 +497,7 @@ public class ClassVisitorTest extends AsmTest { private final int accessFlags; ChangeAccessAdapter(final ClassVisitor classVisitor, final int accessFlags) { - super(LATEST_API, classVisitor); + super(/* latest */ Opcodes.ASM8_EXPERIMENTAL, classVisitor); this.accessFlags = accessFlags; } @@ -518,7 +518,7 @@ public class ClassVisitorTest extends AsmTest { private final boolean visibilityValue; RemoveAnnotationAdapter(final ClassVisitor classVisitor, final boolean visibilityValue) { - super(LATEST_API, classVisitor); + super(/* latest */ Opcodes.ASM8_EXPERIMENTAL, classVisitor); this.visibilityValue = visibilityValue; } @@ -659,7 +659,7 @@ public class ClassVisitorTest extends AsmTest { private static class AddParameterAdapter extends ClassVisitor { public AddParameterAdapter(final ClassVisitor classVisitor) { - super(LATEST_API, classVisitor); + super(/* latest */ Opcodes.ASM8_EXPERIMENTAL, classVisitor); } @Override diff --git a/asm/src/test/java/org/objectweb/asm/MethodVisitorTest.java b/asm/src/test/java/org/objectweb/asm/MethodVisitorTest.java index e379f889c..da4b31e41 100644 --- a/asm/src/test/java/org/objectweb/asm/MethodVisitorTest.java +++ b/asm/src/test/java/org/objectweb/asm/MethodVisitorTest.java @@ -541,7 +541,7 @@ public class MethodVisitorTest extends AsmTest { private final StringWriter log; LogMethodVisitor(final StringWriter log) { - super(LATEST_API); + super(/* latest */ Opcodes.ASM8_EXPERIMENTAL); this.log = log; } diff --git a/asm/src/test/java/org/objectweb/asm/signature/SignatureReaderTest.java b/asm/src/test/java/org/objectweb/asm/signature/SignatureReaderTest.java index 94cbd5cf9..fba35b859 100644 --- a/asm/src/test/java/org/objectweb/asm/signature/SignatureReaderTest.java +++ b/asm/src/test/java/org/objectweb/asm/signature/SignatureReaderTest.java @@ -34,6 +34,7 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.function.Executable; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; /** @@ -50,7 +51,8 @@ public class SignatureReaderTest extends AsmTest { }) public void testAccept_validClassOrMethodSignature(final String signature) { SignatureReader signatureReader = new SignatureReader(signature); - SignatureVisitor signatureVisitor = new SignatureVisitor(LATEST_API) {}; + SignatureVisitor signatureVisitor = + new SignatureVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) {}; Executable acceptVisitor = () -> signatureReader.accept(signatureVisitor); @@ -61,7 +63,8 @@ public class SignatureReaderTest extends AsmTest { @MethodSource("org.objectweb.asm.signature.SignaturesProviders#fieldSignatures") public void testAccept_validFieldSignature(final String signature) { SignatureReader signatureReader = new SignatureReader(signature); - SignatureVisitor signatureVisitor = new SignatureVisitor(LATEST_API) {}; + SignatureVisitor signatureVisitor = + new SignatureVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) {}; Executable acceptVisitor = () -> signatureReader.acceptType(signatureVisitor); @@ -72,7 +75,8 @@ public class SignatureReaderTest extends AsmTest { public void testAccept_invalidSignature() { String invalidSignature = "-"; SignatureReader signatureReader = new SignatureReader(invalidSignature); - SignatureVisitor signatureVisitor = new SignatureVisitor(LATEST_API) {}; + SignatureVisitor signatureVisitor = + new SignatureVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) {}; Executable acceptVisitor = () -> signatureReader.accept(signatureVisitor); diff --git a/asm/src/test/java/org/objectweb/asm/signature/SignaturesProviders.java b/asm/src/test/java/org/objectweb/asm/signature/SignaturesProviders.java index 4b821a9d3..e1207ecb2 100644 --- a/asm/src/test/java/org/objectweb/asm/signature/SignaturesProviders.java +++ b/asm/src/test/java/org/objectweb/asm/signature/SignaturesProviders.java @@ -9,6 +9,7 @@ import org.objectweb.asm.ClassReader; import org.objectweb.asm.ClassVisitor; import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.test.AsmTest; import org.objectweb.asm.test.AsmTest.PrecompiledClass; @@ -36,7 +37,7 @@ public final class SignaturesProviders { private static void collectSignatures(final PrecompiledClass classParameter) { ClassReader classReader = new ClassReader(classParameter.getBytes()); classReader.accept( - new ClassVisitor(AsmTest.LATEST_API) { + new ClassVisitor(/* latest */ Opcodes.ASM8_EXPERIMENTAL) { @Override public void visit( final int version, diff --git a/benchmarks/src/jmh/java/org/objectweb/asm/benchmarks/TypeBenchmark.java b/benchmarks/src/jmh/java/org/objectweb/asm/benchmarks/TypeBenchmark.java index 1d80ca662..98d66ed48 100644 --- a/benchmarks/src/jmh/java/org/objectweb/asm/benchmarks/TypeBenchmark.java +++ b/benchmarks/src/jmh/java/org/objectweb/asm/benchmarks/TypeBenchmark.java @@ -9,9 +9,9 @@ import org.objectweb.asm.FieldVisitor; import org.objectweb.asm.Handle; import org.objectweb.asm.Label; import org.objectweb.asm.MethodVisitor; +import org.objectweb.asm.Opcodes; import org.objectweb.asm.Type; import org.objectweb.asm.TypePath; -import org.objectweb.asm.test.AsmTest; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.Fork; import org.openjdk.jmh.annotations.Measurement; @@ -88,7 +88,7 @@ public class TypeBenchmark extends AbstractBenchmark { }; CollectTypesVisitor() { - super(AsmTest.LATEST_API); + super(/* latest */ Opcodes.ASM8_EXPERIMENTAL); } @Override -- GitLab From 895bc5200124e7c99dc30088e1246089c04d7fa0 Mon Sep 17 00:00:00 2001 From: forax Date: Wed, 9 Oct 2019 10:32:32 +0200 Subject: [PATCH 8/8] fix latest nits from the code review --- asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java | 3 +-- .../src/main/java/org/objectweb/asm/tree/ClassNode.java | 2 ++ .../src/test/java/org/objectweb/asm/util/PrinterTest.java | 7 +++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java b/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java index b9d5b4809..015cadf00 100644 --- a/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java +++ b/asm-test/src/main/java/org/objectweb/asm/test/AsmTest.java @@ -305,8 +305,7 @@ public abstract class AsmTest { * with {@code @MethodSource("allClassesAndLatestApi")} will be executed on all the precompiled * classes, with the latest api. * - * @return all the possible (precompiledClass, ASM8_EXPERIMENTAL) pairs, for all the precompiled - * classes. + * @return all the possible (precompiledClass, ASM8) pairs, for all the precompiled classes. */ public static Stream allClassesAndLatestApi() { return classesAndApis(Api.ASM8); diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java index cde8fa977..6f455bd7b 100644 --- a/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java +++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java @@ -130,6 +130,8 @@ public class ClassNode extends ClassVisitor { * Experimental, use at your own risk. This method will be renamed when it becomes stable, this * will break existing code using it. The internal names of the permitted subtypes of this * class. May be {@literal null}. + * + * @deprecated this API is experimental. */ @Deprecated public List permittedSubtypesExperimental; diff --git a/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java b/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java index d19e68a00..3bb00e293 100644 --- a/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java +++ b/asm-util/src/test/java/org/objectweb/asm/util/PrinterTest.java @@ -88,16 +88,15 @@ public class PrinterTest { assertEquals(UNSUPPORTED_OPERATION_MESSAGE, exception.getMessage()); } - /* Experimental feature for now @Test public void testVisitPermittedSubtype_unsupportedByDefault() { - Printer printer = new EmptyPrinter(Opcodes.ASM8_EXPERIMENTAL); + Printer printer = new EmptyPrinter(/* latest */ Opcodes.ASM8_EXPERIMENTAL); - Executable visitPermittedSubtype = () -> printer.visitPermittedSubtype(null); + Executable visitPermittedSubtype = () -> printer.visitPermittedSubtypeExperimental(null); Exception exception = assertThrows(UnsupportedOperationException.class, visitPermittedSubtype); assertEquals(UNSUPPORTED_OPERATION_MESSAGE, exception.getMessage()); - }*/ + } @Test public void testVisitMainClass_unsupportedByDefault() { -- GitLab