Commit 76e16723 authored by Remi Forax's avatar Remi Forax
Browse files

Merge branch 'asm8-permitted-subtypes' into 'master'

add ASM8_EXPERIMENTAL API + support of PermittedSubtypes attribute

See merge request !274
parents 6359986e f14f4bac
Pipeline #6738 passed with stage
in 10 minutes and 13 seconds
......@@ -61,7 +61,7 @@ public class BasicInterpreter extends Interpreter<BasicValue> implements Opcodes
* version.
*/
public BasicInterpreter() {
super(ASM7);
super(/* latest api = */ ASM7);
if (getClass() != BasicInterpreter.class) {
throw new IllegalStateException();
}
......
......@@ -47,7 +47,7 @@ public class BasicVerifier extends BasicInterpreter {
* use this constructor</i>. Instead, they must use the {@link #BasicVerifier(int)} version.
*/
public BasicVerifier() {
super(ASM7);
super(/* latest api = */ ASM7);
if (getClass() != BasicVerifier.class) {
throw new IllegalStateException();
}
......
......@@ -93,7 +93,12 @@ public class SimpleVerifier extends BasicVerifier {
final Type currentSuperClass,
final List<Type> currentClassInterfaces,
final boolean isInterface) {
this(ASM7, currentClass, currentSuperClass, currentClassInterfaces, isInterface);
this(
/* latest api = */ ASM7,
currentClass,
currentSuperClass,
currentClassInterfaces,
isInterface);
if (getClass() != SimpleVerifier.class) {
throw new IllegalStateException();
}
......
......@@ -51,7 +51,7 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod
* version.
*/
public SourceInterpreter() {
super(ASM7);
super(/* latest api = */ ASM7);
if (getClass() != SourceInterpreter.class) {
throw new IllegalStateException();
}
......
......@@ -1173,7 +1173,7 @@ public class AnalyzerTest extends AsmTest {
private static class MockInterpreter extends Interpreter<MockValue> {
MockInterpreter() {
super(Opcodes.ASM7);
super(/* latest */ Opcodes.ASM8_EXPERIMENTAL);
}
@Override
......
......@@ -125,7 +125,7 @@ public class AnalyzerWithBasicInterpreterTest extends AsmTest {
new ClassReader(PrecompiledClass.JDK8_ALL_FRAMES.getBytes()).accept(classNode, 0);
Analyzer<BasicValue> analyzer =
new Analyzer<BasicValue>(
new BasicInterpreter(Opcodes.ASM7) {
new BasicInterpreter(/* latest */ Opcodes.ASM8_EXPERIMENTAL) {
@Override
public BasicValue merge(final BasicValue value1, final BasicValue value2) {
return new BasicValue(super.merge(value1, value2).getType());
......
......@@ -81,7 +81,12 @@ 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(
/* latest */ Opcodes.ASM8_EXPERIMENTAL,
baseType,
superType,
Arrays.asList(interfaceType),
false) {
@Override
public boolean isAssignableFrom(final Type type1, final Type type2) {
......@@ -114,7 +119,8 @@ 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(
/* latest */ Opcodes.ASM8_EXPERIMENTAL, interfaceType, null, null, true) {
@Override
protected Type getSuperClass(final Type type) {
......
......@@ -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(/* latest api = */ Opcodes.ASM7, owner, access, name, descriptor, methodVisitor);
if (getClass() != AnalyzerAdapter.class) {
throw new IllegalStateException();
}
......
......@@ -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(/* latest api = */ Opcodes.ASM7, annotationVisitor, remapper);
}
/**
......
......@@ -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(/* latest api = */ Opcodes.ASM7, classVisitor, remapper);
}
/**
......@@ -204,6 +204,11 @@ public class ClassRemapper extends ClassVisitor {
super.visitNestMember(remapper.mapType(nestMember));
}
@Override
public void visitPermittedSubtypeExperimental(final String permittedSubtype) {
super.visitPermittedSubtypeExperimental(remapper.mapType(permittedSubtype));
}
/**
* Constructs a new remapper for fields. The default implementation of this method returns a new
* {@link FieldRemapper}.
......
......@@ -47,7 +47,7 @@ public class CodeSizeEvaluator extends MethodVisitor implements Opcodes {
private int maxSize;
public CodeSizeEvaluator(final MethodVisitor methodVisitor) {
this(Opcodes.ASM7, methodVisitor);
this(/* latest api = */ Opcodes.ASM7, methodVisitor);
}
protected CodeSizeEvaluator(final int api, final MethodVisitor methodVisitor) {
......
......@@ -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(/* latest api = */ Opcodes.ASM7, fieldVisitor, remapper);
}
/**
......
......@@ -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(/* latest api = */ Opcodes.ASM7, methodVisitor, access, name, descriptor);
if (getClass() != GeneratorAdapter.class) {
throw new IllegalStateException();
}
......
......@@ -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(/* latest api = */ Opcodes.ASM7, 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) {
......
......@@ -98,7 +98,14 @@ 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(
/* latest api = */ Opcodes.ASM7,
methodVisitor,
access,
name,
descriptor,
signature,
exceptions);
if (getClass() != JSRInlinerAdapter.class) {
throw new IllegalStateException();
}
......
......@@ -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(/* latest api = */ Opcodes.ASM7, access, descriptor, methodVisitor);
if (getClass() != LocalVariablesSorter.class) {
throw new IllegalStateException();
}
......
......@@ -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(/* latest api = */ Opcodes.ASM7, methodVisitor, remapper);
}
/**
......
......@@ -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(/* latest api = */ Opcodes.ASM7, moduleVisitor, remapper);
}
/**
......
......@@ -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(/* latest api = */ Opcodes.ASM7, classVisitor);
if (getClass() != SerialVersionUIDAdder.class) {
throw new IllegalStateException();
}
......
......@@ -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(/* latest api = */ Opcodes.ASM7, signatureVisitor, remapper);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment