8284361: Updating ASM to 9.3 for JDK 19
Reviewed-by: mchung
This commit is contained in:
parent
0a0267590f
commit
1bd8975caf
src/java.base/share
classes/jdk/internal/org/objectweb/asm
AnnotationVisitor.javaByteVector.javaClassReader.javaClassVisitor.javaClassWriter.javaFieldVisitor.javaMethodVisitor.javaMethodWriter.javaModuleVisitor.javaRecordComponentVisitor.javaType.java
commons
AdviceAdapter.javaAnalyzerAdapter.javaAnnotationRemapper.javaClassRemapper.javaCodeSizeEvaluator.javaFieldRemapper.javaGeneratorAdapter.javaInstructionAdapter.javaJSRInlinerAdapter.javaLocalVariablesSorter.javaMethodRemapper.javaModuleRemapper.javaRemapper.javaSerialVersionUIDAdder.javaSignatureRemapper.javaStaticInitMerger.java
signature
tree
AnnotationNode.javaClassNode.javaFieldNode.javaIincInsnNode.javaLocalVariableAnnotationNode.javaMethodNode.javaTypeAnnotationNode.javaUtil.javaVarInsnNode.java
analysis
util
ASMifier.javaCheckClassAdapter.javaCheckFieldAdapter.javaCheckMethodAdapter.javaCheckModuleAdapter.javaCheckSignatureAdapter.javaPrinter.javaTextifier.javaTraceMethodVisitor.java
version.txtlegal
test/langtools/tools/javac/sealed
@ -70,8 +70,8 @@ package jdk.internal.org.objectweb.asm;
|
||||
public abstract class AnnotationVisitor {
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
@ -84,22 +84,22 @@ public abstract class AnnotationVisitor {
|
||||
/**
|
||||
* Constructs a new {@link AnnotationVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public AnnotationVisitor(final int api) {
|
||||
protected AnnotationVisitor(final int api) {
|
||||
this(api, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link AnnotationVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param annotationVisitor the annotation visitor to which this visitor must delegate method
|
||||
* calls. May be {@literal null}.
|
||||
*/
|
||||
public AnnotationVisitor(final int api, final AnnotationVisitor annotationVisitor) {
|
||||
protected AnnotationVisitor(final int api, final AnnotationVisitor annotationVisitor) {
|
||||
if (api != Opcodes.ASM9
|
||||
&& api != Opcodes.ASM8
|
||||
&& api != Opcodes.ASM7
|
||||
|
@ -97,6 +97,15 @@ public class ByteVector {
|
||||
this.length = data.length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the actual number of bytes in this vector.
|
||||
*
|
||||
* @return the actual number of bytes in this vector.
|
||||
*/
|
||||
public int size() {
|
||||
return length;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts a byte into this byte vector. The byte vector is automatically enlarged if necessary.
|
||||
*
|
||||
@ -384,6 +393,9 @@ public class ByteVector {
|
||||
* @param size number of additional bytes that this byte vector should be able to receive.
|
||||
*/
|
||||
private void enlarge(final int size) {
|
||||
if (length > data.length) {
|
||||
throw new AssertionError("Internal error");
|
||||
}
|
||||
int doubleCapacity = 2 * data.length;
|
||||
int minimalCapacity = length + size;
|
||||
byte[] newData = new byte[doubleCapacity > minimalCapacity ? doubleCapacity : minimalCapacity];
|
||||
|
@ -340,12 +340,13 @@ public class ClassReader {
|
||||
* @return the content of the given input stream.
|
||||
* @throws IOException if a problem occurs during reading.
|
||||
*/
|
||||
@SuppressWarnings("PMD.UseTryWithResources")
|
||||
private static byte[] readStream(final InputStream inputStream, final boolean close)
|
||||
throws IOException {
|
||||
if (inputStream == null) {
|
||||
throw new IOException("Class not found");
|
||||
}
|
||||
int bufferSize = calculateBufferSize(inputStream);
|
||||
int bufferSize = computeBufferSize(inputStream);
|
||||
try (ByteArrayOutputStream outputStream = new ByteArrayOutputStream()) {
|
||||
byte[] data = new byte[bufferSize];
|
||||
int bytesRead;
|
||||
@ -366,13 +367,12 @@ public class ClassReader {
|
||||
}
|
||||
}
|
||||
|
||||
private static int calculateBufferSize(final InputStream inputStream) throws IOException {
|
||||
private static int computeBufferSize(final InputStream inputStream) throws IOException {
|
||||
int expectedLength = inputStream.available();
|
||||
/*
|
||||
* Some implementations can return 0 while holding available data
|
||||
* (e.g. new FileInputStream("/proc/a_file"))
|
||||
* Also in some pathological cases a very small number might be returned,
|
||||
* and in this case we use default size
|
||||
* Some implementations can return 0 while holding available data (e.g. new
|
||||
* FileInputStream("/proc/a_file")). Also in some pathological cases a very small number might
|
||||
* be returned, and in this case we use a default size.
|
||||
*/
|
||||
if (expectedLength < 256) {
|
||||
return INPUT_STREAM_DATA_CHUNK_SIZE;
|
||||
@ -891,7 +891,7 @@ public class ClassReader {
|
||||
currentOffset += 2;
|
||||
}
|
||||
|
||||
// Read the 'provides_count' and 'provides' fields.
|
||||
// Read the 'provides_count' and 'provides' fields.
|
||||
int providesCount = readUnsignedShort(currentOffset);
|
||||
currentOffset += 2;
|
||||
while (providesCount-- > 0) {
|
||||
|
@ -72,8 +72,8 @@ package jdk.internal.org.objectweb.asm;
|
||||
public abstract class ClassVisitor {
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
@ -83,23 +83,22 @@ public abstract class ClassVisitor {
|
||||
/**
|
||||
* Constructs a new {@link ClassVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public ClassVisitor(final int api) {
|
||||
protected ClassVisitor(final int api) {
|
||||
this(api, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link ClassVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param classVisitor the class visitor to which this visitor must delegate method calls. May be
|
||||
* null.
|
||||
*/
|
||||
public ClassVisitor(final int api, final ClassVisitor classVisitor) {
|
||||
protected ClassVisitor(final int api, final ClassVisitor classVisitor) {
|
||||
if (api != Opcodes.ASM9
|
||||
&& api != Opcodes.ASM8
|
||||
&& api != Opcodes.ASM7
|
||||
|
@ -97,6 +97,12 @@ public class ClassWriter extends ClassVisitor {
|
||||
*/
|
||||
public static final int COMPUTE_FRAMES = 2;
|
||||
|
||||
/**
|
||||
* The flags passed to the constructor. Must be zero or more of {@link #COMPUTE_MAXS} and {@link
|
||||
* #COMPUTE_FRAMES}.
|
||||
*/
|
||||
private final int flags;
|
||||
|
||||
// Note: fields are ordered as in the ClassFile structure, and those related to attributes are
|
||||
// ordered as in Section 4.7 of the JVMS.
|
||||
|
||||
@ -280,23 +286,39 @@ public class ClassWriter extends ClassVisitor {
|
||||
* @param classReader the {@link ClassReader} used to read the original class. It will be used to
|
||||
* copy the entire constant pool and bootstrap methods from the original class and also to
|
||||
* copy other fragments of original bytecode where applicable.
|
||||
* @param flags option flags that can be used to modify the default behavior of this class.Must be
|
||||
* zero or more of {@link #COMPUTE_MAXS} and {@link #COMPUTE_FRAMES}. <i>These option flags do
|
||||
* not affect methods that are copied as is in the new class. This means that neither the
|
||||
* @param flags option flags that can be used to modify the default behavior of this class. Must
|
||||
* be zero or more of {@link #COMPUTE_MAXS} and {@link #COMPUTE_FRAMES}. <i>These option flags
|
||||
* do not affect methods that are copied as is in the new class. This means that neither the
|
||||
* maximum stack size nor the stack frames will be computed for these methods</i>.
|
||||
*/
|
||||
public ClassWriter(final ClassReader classReader, final int flags) {
|
||||
super(/* latest api = */ Opcodes.ASM9);
|
||||
this.flags = flags;
|
||||
symbolTable = classReader == null ? new SymbolTable(this) : new SymbolTable(this, classReader);
|
||||
if ((flags & COMPUTE_FRAMES) != 0) {
|
||||
this.compute = MethodWriter.COMPUTE_ALL_FRAMES;
|
||||
compute = MethodWriter.COMPUTE_ALL_FRAMES;
|
||||
} else if ((flags & COMPUTE_MAXS) != 0) {
|
||||
this.compute = MethodWriter.COMPUTE_MAX_STACK_AND_LOCAL;
|
||||
compute = MethodWriter.COMPUTE_MAX_STACK_AND_LOCAL;
|
||||
} else {
|
||||
this.compute = MethodWriter.COMPUTE_NOTHING;
|
||||
compute = MethodWriter.COMPUTE_NOTHING;
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// Accessors
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Returns true if all the given flags were passed to the constructor.
|
||||
*
|
||||
* @param flags some option flags. Must be zero or more of {@link #COMPUTE_MAXS} and {@link
|
||||
* #COMPUTE_FRAMES}.
|
||||
* @return true if all the given flags, or more, were passed to the constructor.
|
||||
*/
|
||||
public boolean hasFlags(final int flags) {
|
||||
return (this.flags & flags) == flags;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
// Implementation of the ClassVisitor abstract class
|
||||
// -----------------------------------------------------------------------------------------------
|
||||
|
@ -69,9 +69,8 @@ package jdk.internal.org.objectweb.asm;
|
||||
public abstract class FieldVisitor {
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
@ -81,24 +80,22 @@ public abstract class FieldVisitor {
|
||||
/**
|
||||
* Constructs a new {@link FieldVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public FieldVisitor(final int api) {
|
||||
protected FieldVisitor(final int api) {
|
||||
this(api, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link FieldVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7} or {@link
|
||||
* Opcodes#ASM8}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param fieldVisitor the field visitor to which this visitor must delegate method calls. May be
|
||||
* null.
|
||||
*/
|
||||
public FieldVisitor(final int api, final FieldVisitor fieldVisitor) {
|
||||
protected FieldVisitor(final int api, final FieldVisitor fieldVisitor) {
|
||||
if (api != Opcodes.ASM9
|
||||
&& api != Opcodes.ASM8
|
||||
&& api != Opcodes.ASM7
|
||||
|
@ -83,8 +83,8 @@ public abstract class MethodVisitor {
|
||||
private static final String REQUIRES_ASM5 = "This feature requires ASM5";
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
@ -96,22 +96,22 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Constructs a new {@link MethodVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public MethodVisitor(final int api) {
|
||||
protected MethodVisitor(final int api) {
|
||||
this(api, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link MethodVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param methodVisitor the method visitor to which this visitor must delegate method calls. May
|
||||
* be null.
|
||||
*/
|
||||
public MethodVisitor(final int api, final MethodVisitor methodVisitor) {
|
||||
protected MethodVisitor(final int api, final MethodVisitor methodVisitor) {
|
||||
if (api != Opcodes.ASM9
|
||||
&& api != Opcodes.ASM8
|
||||
&& api != Opcodes.ASM7
|
||||
@ -379,12 +379,12 @@ public abstract class MethodVisitor {
|
||||
*
|
||||
* @param opcode the opcode of the local variable instruction to be visited. This opcode is either
|
||||
* ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
|
||||
* @param var the operand of the instruction to be visited. This operand is the index of a local
|
||||
* variable.
|
||||
* @param varIndex the operand of the instruction to be visited. This operand is the index of a
|
||||
* local variable.
|
||||
*/
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
if (mv != null) {
|
||||
mv.visitVarInsn(opcode, var);
|
||||
mv.visitVarInsn(opcode, varIndex);
|
||||
}
|
||||
}
|
||||
|
||||
@ -582,12 +582,12 @@ public abstract class MethodVisitor {
|
||||
/**
|
||||
* Visits an IINC instruction.
|
||||
*
|
||||
* @param var index of the local variable to be incremented.
|
||||
* @param varIndex index of the local variable to be incremented.
|
||||
* @param increment amount to increment the local variable by.
|
||||
*/
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
if (mv != null) {
|
||||
mv.visitIincInsn(var, increment);
|
||||
mv.visitIincInsn(varIndex, increment);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -498,7 +498,8 @@ final class MethodWriter extends MethodVisitor {
|
||||
|
||||
/**
|
||||
* Indicates what must be computed. Must be one of {@link #COMPUTE_ALL_FRAMES}, {@link
|
||||
* #COMPUTE_INSERTED_FRAMES}, {@link #COMPUTE_MAX_STACK_AND_LOCAL} or {@link #COMPUTE_NOTHING}.
|
||||
* #COMPUTE_INSERTED_FRAMES}, {@link COMPUTE_MAX_STACK_AND_LOCAL_FROM_FRAMES}, {@link
|
||||
* #COMPUTE_MAX_STACK_AND_LOCAL} or {@link #COMPUTE_NOTHING}.
|
||||
*/
|
||||
private final int compute;
|
||||
|
||||
@ -936,26 +937,26 @@ final class MethodWriter extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
lastBytecodeOffset = code.length;
|
||||
// Add the instruction to the bytecode of the method.
|
||||
if (var < 4 && opcode != Opcodes.RET) {
|
||||
if (varIndex < 4 && opcode != Opcodes.RET) {
|
||||
int optimizedOpcode;
|
||||
if (opcode < Opcodes.ISTORE) {
|
||||
optimizedOpcode = Constants.ILOAD_0 + ((opcode - Opcodes.ILOAD) << 2) + var;
|
||||
optimizedOpcode = Constants.ILOAD_0 + ((opcode - Opcodes.ILOAD) << 2) + varIndex;
|
||||
} else {
|
||||
optimizedOpcode = Constants.ISTORE_0 + ((opcode - Opcodes.ISTORE) << 2) + var;
|
||||
optimizedOpcode = Constants.ISTORE_0 + ((opcode - Opcodes.ISTORE) << 2) + varIndex;
|
||||
}
|
||||
code.putByte(optimizedOpcode);
|
||||
} else if (var >= 256) {
|
||||
code.putByte(Constants.WIDE).put12(opcode, var);
|
||||
} else if (varIndex >= 256) {
|
||||
code.putByte(Constants.WIDE).put12(opcode, varIndex);
|
||||
} else {
|
||||
code.put11(opcode, var);
|
||||
code.put11(opcode, varIndex);
|
||||
}
|
||||
// If needed, update the maximum stack size and number of locals, and stack map frames.
|
||||
if (currentBasicBlock != null) {
|
||||
if (compute == COMPUTE_ALL_FRAMES || compute == COMPUTE_INSERTED_FRAMES) {
|
||||
currentBasicBlock.frame.execute(opcode, var, null, null);
|
||||
currentBasicBlock.frame.execute(opcode, varIndex, null, null);
|
||||
} else {
|
||||
if (opcode == Opcodes.RET) {
|
||||
// No stack size delta.
|
||||
@ -977,9 +978,9 @@ final class MethodWriter extends MethodVisitor {
|
||||
|| opcode == Opcodes.DLOAD
|
||||
|| opcode == Opcodes.LSTORE
|
||||
|| opcode == Opcodes.DSTORE) {
|
||||
currentMaxLocals = var + 2;
|
||||
currentMaxLocals = varIndex + 2;
|
||||
} else {
|
||||
currentMaxLocals = var + 1;
|
||||
currentMaxLocals = varIndex + 1;
|
||||
}
|
||||
if (currentMaxLocals > maxLocals) {
|
||||
maxLocals = currentMaxLocals;
|
||||
@ -1339,21 +1340,21 @@ final class MethodWriter extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
lastBytecodeOffset = code.length;
|
||||
// Add the instruction to the bytecode of the method.
|
||||
if ((var > 255) || (increment > 127) || (increment < -128)) {
|
||||
code.putByte(Constants.WIDE).put12(Opcodes.IINC, var).putShort(increment);
|
||||
if ((varIndex > 255) || (increment > 127) || (increment < -128)) {
|
||||
code.putByte(Constants.WIDE).put12(Opcodes.IINC, varIndex).putShort(increment);
|
||||
} else {
|
||||
code.putByte(Opcodes.IINC).put11(var, increment);
|
||||
code.putByte(Opcodes.IINC).put11(varIndex, increment);
|
||||
}
|
||||
// If needed, update the maximum stack size and number of locals, and stack map frames.
|
||||
if (currentBasicBlock != null
|
||||
&& (compute == COMPUTE_ALL_FRAMES || compute == COMPUTE_INSERTED_FRAMES)) {
|
||||
currentBasicBlock.frame.execute(Opcodes.IINC, var, null, null);
|
||||
currentBasicBlock.frame.execute(Opcodes.IINC, varIndex, null, null);
|
||||
}
|
||||
if (compute != COMPUTE_NOTHING) {
|
||||
int currentMaxLocals = var + 1;
|
||||
int currentMaxLocals = varIndex + 1;
|
||||
if (currentMaxLocals > maxLocals) {
|
||||
maxLocals = currentMaxLocals;
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public abstract class ModuleVisitor {
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM6}
|
||||
* or {@link Opcodes#ASM7}.
|
||||
*/
|
||||
public ModuleVisitor(final int api) {
|
||||
protected ModuleVisitor(final int api) {
|
||||
this(api, null);
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ public abstract class ModuleVisitor {
|
||||
* @param moduleVisitor the module visitor to which this visitor must delegate method calls. May
|
||||
* be null.
|
||||
*/
|
||||
public ModuleVisitor(final int api, final ModuleVisitor moduleVisitor) {
|
||||
protected ModuleVisitor(final int api, final ModuleVisitor moduleVisitor) {
|
||||
if (api != Opcodes.ASM9
|
||||
&& api != Opcodes.ASM8
|
||||
&& api != Opcodes.ASM7
|
||||
|
@ -85,7 +85,7 @@ public abstract class RecordComponentVisitor {
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link Opcodes#ASM8}
|
||||
* or {@link Opcodes#ASM9}.
|
||||
*/
|
||||
public RecordComponentVisitor(final int api) {
|
||||
protected RecordComponentVisitor(final int api) {
|
||||
this(api, null);
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ public abstract class RecordComponentVisitor {
|
||||
* @param recordComponentVisitor the record component visitor to which this visitor must delegate
|
||||
* method calls. May be null.
|
||||
*/
|
||||
public RecordComponentVisitor(
|
||||
protected RecordComponentVisitor(
|
||||
final int api, final RecordComponentVisitor recordComponentVisitor) {
|
||||
if (api != Opcodes.ASM9
|
||||
&& api != Opcodes.ASM8
|
||||
|
@ -472,7 +472,7 @@ public final class Type {
|
||||
case '(':
|
||||
return new Type(METHOD, descriptorBuffer, descriptorBegin, descriptorEnd);
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
throw new IllegalArgumentException("Invalid descriptor: " + descriptorBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -130,8 +130,8 @@ public abstract class AdviceAdapter extends GeneratorAdapter implements Opcodes
|
||||
/**
|
||||
* Constructs a new {@link AdviceAdapter}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param methodVisitor the method visitor to which this adapter delegates calls.
|
||||
* @param access the method's access flags (see {@link Opcodes}).
|
||||
* @param name the method's name.
|
||||
@ -359,8 +359,8 @@ public abstract class AdviceAdapter extends GeneratorAdapter implements Opcodes
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
super.visitVarInsn(opcode, var);
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
super.visitVarInsn(opcode, varIndex);
|
||||
if (isConstructor && !superClassConstructorCalled) {
|
||||
switch (opcode) {
|
||||
case ILOAD:
|
||||
@ -373,7 +373,7 @@ public abstract class AdviceAdapter extends GeneratorAdapter implements Opcodes
|
||||
pushValue(OTHER);
|
||||
break;
|
||||
case ALOAD:
|
||||
pushValue(var == 0 ? UNINITIALIZED_THIS : OTHER);
|
||||
pushValue(varIndex == 0 ? UNINITIALIZED_THIS : OTHER);
|
||||
break;
|
||||
case ASTORE:
|
||||
case ISTORE:
|
||||
|
@ -157,9 +157,8 @@ public class AnalyzerAdapter extends MethodVisitor {
|
||||
/**
|
||||
* Constructs a new {@link AnalyzerAdapter}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param owner the owner's class name.
|
||||
* @param access the method's access flags (see {@link Opcodes}).
|
||||
* @param name the method's name.
|
||||
@ -275,15 +274,15 @@ public class AnalyzerAdapter extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
super.visitVarInsn(opcode, var);
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
super.visitVarInsn(opcode, varIndex);
|
||||
boolean isLongOrDouble =
|
||||
opcode == Opcodes.LLOAD
|
||||
|| opcode == Opcodes.DLOAD
|
||||
|| opcode == Opcodes.LSTORE
|
||||
|| opcode == Opcodes.DSTORE;
|
||||
maxLocals = Math.max(maxLocals, var + (isLongOrDouble ? 2 : 1));
|
||||
execute(opcode, var, null);
|
||||
maxLocals = Math.max(maxLocals, varIndex + (isLongOrDouble ? 2 : 1));
|
||||
execute(opcode, varIndex, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -431,10 +430,10 @@ public class AnalyzerAdapter extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
super.visitIincInsn(var, increment);
|
||||
maxLocals = Math.max(maxLocals, var + 1);
|
||||
execute(Opcodes.IINC, var, null);
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
super.visitIincInsn(varIndex, increment);
|
||||
maxLocals = Math.max(maxLocals, varIndex + 1);
|
||||
execute(Opcodes.IINC, varIndex, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,10 +108,8 @@ public class AnnotationRemapper extends AnnotationVisitor {
|
||||
/**
|
||||
* Constructs a new {@link AnnotationRemapper}.
|
||||
*
|
||||
* @param api the ASM API version supported by this remapper. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM8} or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this remapper. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param annotationVisitor the annotation visitor this remapper must delegate to.
|
||||
* @param remapper the remapper to use to remap the types in the visited annotation.
|
||||
* @deprecated use {@link #AnnotationRemapper(int, String, AnnotationVisitor, Remapper)} instead.
|
||||
@ -125,10 +123,8 @@ public class AnnotationRemapper extends AnnotationVisitor {
|
||||
/**
|
||||
* Constructs a new {@link AnnotationRemapper}.
|
||||
*
|
||||
* @param api the ASM API version supported by this remapper. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM8} or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this remapper. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param descriptor the descriptor of the visited annotation. May be {@literal null}.
|
||||
* @param annotationVisitor the annotation visitor this remapper must delegate to.
|
||||
* @param remapper the remapper to use to remap the types in the visited annotation.
|
||||
|
@ -111,10 +111,8 @@ public class ClassRemapper extends ClassVisitor {
|
||||
/**
|
||||
* Constructs a new {@link ClassRemapper}.
|
||||
*
|
||||
* @param api the ASM API version supported by this remapper. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM8} or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this remapper. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param classVisitor the class visitor this remapper must delegate to.
|
||||
* @param remapper the remapper to use to remap the types in the visited class.
|
||||
*/
|
||||
|
@ -114,18 +114,18 @@ public class CodeSizeEvaluator extends MethodVisitor implements Opcodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
if (var < 4 && opcode != RET) {
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
if (varIndex < 4 && opcode != RET) {
|
||||
minSize += 1;
|
||||
maxSize += 1;
|
||||
} else if (var >= 256) {
|
||||
} else if (varIndex >= 256) {
|
||||
minSize += 4;
|
||||
maxSize += 4;
|
||||
} else {
|
||||
minSize += 2;
|
||||
maxSize += 2;
|
||||
}
|
||||
super.visitVarInsn(opcode, var);
|
||||
super.visitVarInsn(opcode, varIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -204,15 +204,15 @@ public class CodeSizeEvaluator extends MethodVisitor implements Opcodes {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
if (var > 255 || increment > 127 || increment < -128) {
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
if (varIndex > 255 || increment > 127 || increment < -128) {
|
||||
minSize += 6;
|
||||
maxSize += 6;
|
||||
} else {
|
||||
minSize += 3;
|
||||
maxSize += 3;
|
||||
}
|
||||
super.visitIincInsn(var, increment);
|
||||
super.visitIincInsn(varIndex, increment);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -88,9 +88,8 @@ public class FieldRemapper extends FieldVisitor {
|
||||
/**
|
||||
* Constructs a new {@link FieldRemapper}.
|
||||
*
|
||||
* @param api the ASM API version supported by this remapper. Must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link Opcodes#ASM8}, or
|
||||
* {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this remapper. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param fieldVisitor the field visitor this remapper must delegate to.
|
||||
* @param remapper the remapper to use to remap the types in the visited field.
|
||||
*/
|
||||
|
@ -242,9 +242,8 @@ public class GeneratorAdapter extends LocalVariablesSorter {
|
||||
/**
|
||||
* Constructs a new {@link GeneratorAdapter}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param methodVisitor the method visitor to which this adapter delegates calls.
|
||||
* @param access the method's access flags (see {@link Opcodes}).
|
||||
* @param name the method's name.
|
||||
|
@ -93,9 +93,8 @@ public class InstructionAdapter extends MethodVisitor {
|
||||
/**
|
||||
* Constructs a new {@link InstructionAdapter}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param methodVisitor the method visitor to which this adapter delegates calls.
|
||||
*/
|
||||
protected InstructionAdapter(final int api, final MethodVisitor methodVisitor) {
|
||||
@ -456,40 +455,40 @@ public class InstructionAdapter extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
switch (opcode) {
|
||||
case Opcodes.ILOAD:
|
||||
load(var, Type.INT_TYPE);
|
||||
load(varIndex, Type.INT_TYPE);
|
||||
break;
|
||||
case Opcodes.LLOAD:
|
||||
load(var, Type.LONG_TYPE);
|
||||
load(varIndex, Type.LONG_TYPE);
|
||||
break;
|
||||
case Opcodes.FLOAD:
|
||||
load(var, Type.FLOAT_TYPE);
|
||||
load(varIndex, Type.FLOAT_TYPE);
|
||||
break;
|
||||
case Opcodes.DLOAD:
|
||||
load(var, Type.DOUBLE_TYPE);
|
||||
load(varIndex, Type.DOUBLE_TYPE);
|
||||
break;
|
||||
case Opcodes.ALOAD:
|
||||
load(var, OBJECT_TYPE);
|
||||
load(varIndex, OBJECT_TYPE);
|
||||
break;
|
||||
case Opcodes.ISTORE:
|
||||
store(var, Type.INT_TYPE);
|
||||
store(varIndex, Type.INT_TYPE);
|
||||
break;
|
||||
case Opcodes.LSTORE:
|
||||
store(var, Type.LONG_TYPE);
|
||||
store(varIndex, Type.LONG_TYPE);
|
||||
break;
|
||||
case Opcodes.FSTORE:
|
||||
store(var, Type.FLOAT_TYPE);
|
||||
store(varIndex, Type.FLOAT_TYPE);
|
||||
break;
|
||||
case Opcodes.DSTORE:
|
||||
store(var, Type.DOUBLE_TYPE);
|
||||
store(varIndex, Type.DOUBLE_TYPE);
|
||||
break;
|
||||
case Opcodes.ASTORE:
|
||||
store(var, OBJECT_TYPE);
|
||||
store(varIndex, OBJECT_TYPE);
|
||||
break;
|
||||
case Opcodes.RET:
|
||||
ret(var);
|
||||
ret(varIndex);
|
||||
break;
|
||||
default:
|
||||
throw new IllegalArgumentException();
|
||||
@ -686,8 +685,8 @@ public class InstructionAdapter extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
iinc(var, increment);
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
iinc(varIndex, increment);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -816,16 +815,16 @@ public class InstructionAdapter extends MethodVisitor {
|
||||
mv.visitLdcInsn(constantDynamic);
|
||||
}
|
||||
|
||||
public void load(final int var, final Type type) {
|
||||
mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), var);
|
||||
public void load(final int varIndex, final Type type) {
|
||||
mv.visitVarInsn(type.getOpcode(Opcodes.ILOAD), varIndex);
|
||||
}
|
||||
|
||||
public void aload(final Type type) {
|
||||
mv.visitInsn(type.getOpcode(Opcodes.IALOAD));
|
||||
}
|
||||
|
||||
public void store(final int var, final Type type) {
|
||||
mv.visitVarInsn(type.getOpcode(Opcodes.ISTORE), var);
|
||||
public void store(final int varIndex, final Type type) {
|
||||
mv.visitVarInsn(type.getOpcode(Opcodes.ISTORE), varIndex);
|
||||
}
|
||||
|
||||
public void astore(final Type type) {
|
||||
@ -916,8 +915,8 @@ public class InstructionAdapter extends MethodVisitor {
|
||||
mv.visitInsn(type.getOpcode(Opcodes.IXOR));
|
||||
}
|
||||
|
||||
public void iinc(final int var, final int increment) {
|
||||
mv.visitIincInsn(var, increment);
|
||||
public void iinc(final int varIndex, final int increment) {
|
||||
mv.visitIincInsn(varIndex, increment);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1060,8 +1059,8 @@ public class InstructionAdapter extends MethodVisitor {
|
||||
mv.visitJumpInsn(Opcodes.JSR, label);
|
||||
}
|
||||
|
||||
public void ret(final int var) {
|
||||
mv.visitVarInsn(Opcodes.RET, var);
|
||||
public void ret(final int varIndex) {
|
||||
mv.visitVarInsn(Opcodes.RET, varIndex);
|
||||
}
|
||||
|
||||
public void tableswitch(final int min, final int max, final Label dflt, final Label... labels) {
|
||||
|
@ -146,9 +146,8 @@ public class JSRInlinerAdapter extends MethodNode implements Opcodes {
|
||||
/**
|
||||
* Constructs a new {@link JSRInlinerAdapter}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param methodVisitor the method visitor to send the resulting inlined method code to, or <code>
|
||||
* null</code>.
|
||||
* @param access the method's access flags (see {@link Opcodes}). This parameter also indicates if
|
||||
|
@ -122,9 +122,8 @@ public class LocalVariablesSorter extends MethodVisitor {
|
||||
/**
|
||||
* Constructs a new {@link LocalVariablesSorter}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param access access flags of the adapted method.
|
||||
* @param descriptor the method's descriptor (see {@link Type}).
|
||||
* @param methodVisitor the method visitor to which this adapter delegates calls.
|
||||
@ -140,7 +139,7 @@ public class LocalVariablesSorter extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
Type varType;
|
||||
switch (opcode) {
|
||||
case Opcodes.LLOAD:
|
||||
@ -167,12 +166,12 @@ public class LocalVariablesSorter extends MethodVisitor {
|
||||
default:
|
||||
throw new IllegalArgumentException("Invalid opcode " + opcode);
|
||||
}
|
||||
super.visitVarInsn(opcode, remap(var, varType));
|
||||
super.visitVarInsn(opcode, remap(varIndex, varType));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
super.visitIincInsn(remap(var, Type.INT_TYPE), increment);
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
super.visitIincInsn(remap(varIndex, Type.INT_TYPE), increment);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -354,11 +353,11 @@ public class LocalVariablesSorter extends MethodVisitor {
|
||||
remappedLocalTypes[local] = type;
|
||||
}
|
||||
|
||||
private int remap(final int var, final Type type) {
|
||||
if (var + type.getSize() <= firstLocal) {
|
||||
return var;
|
||||
private int remap(final int varIndex, final Type type) {
|
||||
if (varIndex + type.getSize() <= firstLocal) {
|
||||
return varIndex;
|
||||
}
|
||||
int key = 2 * var + type.getSize() - 1;
|
||||
int key = 2 * varIndex + type.getSize() - 1;
|
||||
int size = remappedVariableIndices.length;
|
||||
if (key >= size) {
|
||||
int[] newRemappedVariableIndices = new int[Math.max(2 * size, key + 1)];
|
||||
|
@ -90,10 +90,8 @@ public class MethodRemapper extends MethodVisitor {
|
||||
/**
|
||||
* Constructs a new {@link MethodRemapper}.
|
||||
*
|
||||
* @param api the ASM API version supported by this remapper. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM8} or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this remapper. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param methodVisitor the method visitor this remapper must delegate to.
|
||||
* @param remapper the remapper to use to remap the types in the visited method.
|
||||
*/
|
||||
|
@ -86,10 +86,8 @@ public class ModuleRemapper extends ModuleVisitor {
|
||||
/**
|
||||
* Constructs a new {@link ModuleRemapper}.
|
||||
*
|
||||
* @param api the ASM API version supported by this remapper. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM8} or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this remapper. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param moduleVisitor the module visitor this remapper must delegate to.
|
||||
* @param remapper the remapper to use to remap the types in the visited module.
|
||||
*/
|
||||
|
@ -191,13 +191,15 @@ public abstract class Remapper {
|
||||
}
|
||||
if (value instanceof Handle) {
|
||||
Handle handle = (Handle) value;
|
||||
boolean isFieldHandle = handle.getTag() <= Opcodes.H_PUTSTATIC;
|
||||
|
||||
return new Handle(
|
||||
handle.getTag(),
|
||||
mapType(handle.getOwner()),
|
||||
mapMethodName(handle.getOwner(), handle.getName(), handle.getDesc()),
|
||||
handle.getTag() <= Opcodes.H_PUTSTATIC
|
||||
? mapDesc(handle.getDesc())
|
||||
: mapMethodDesc(handle.getDesc()),
|
||||
isFieldHandle
|
||||
? mapFieldName(handle.getOwner(), handle.getName(), handle.getDesc())
|
||||
: mapMethodName(handle.getOwner(), handle.getName(), handle.getDesc()),
|
||||
isFieldHandle ? mapDesc(handle.getDesc()) : mapMethodDesc(handle.getDesc()),
|
||||
handle.isInterface());
|
||||
}
|
||||
if (value instanceof ConstantDynamic) {
|
||||
|
@ -191,9 +191,8 @@ public class SerialVersionUIDAdder extends ClassVisitor {
|
||||
/**
|
||||
* Constructs a new {@link SerialVersionUIDAdder}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param classVisitor a {@link ClassVisitor} to which this visitor will delegate calls.
|
||||
*/
|
||||
protected SerialVersionUIDAdder(final int api, final ClassVisitor classVisitor) {
|
||||
|
@ -90,10 +90,8 @@ public class SignatureRemapper extends SignatureVisitor {
|
||||
/**
|
||||
* Constructs a new {@link SignatureRemapper}.
|
||||
*
|
||||
* @param api the ASM API version supported by this remapper. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5},{@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM8} or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this remapper. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param signatureVisitor the signature visitor this remapper must delegate to.
|
||||
* @param remapper the remapper to use to remap the types in the visited signature.
|
||||
*/
|
||||
|
@ -99,9 +99,8 @@ public class StaticInitMerger extends ClassVisitor {
|
||||
/**
|
||||
* Constructs a new {@link StaticInitMerger}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param prefix the prefix to use to rename the existing <clinit> methods.
|
||||
* @param classVisitor the class visitor to which this visitor must delegate method calls. May be
|
||||
* null.
|
||||
|
@ -92,18 +92,18 @@ public abstract class SignatureVisitor {
|
||||
public static final char INSTANCEOF = '=';
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* The ASM API version implemented by this visitor. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link SignatureVisitor}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public SignatureVisitor(final int api) {
|
||||
protected SignatureVisitor(final int api) {
|
||||
if (api != Opcodes.ASM9
|
||||
&& api != Opcodes.ASM8
|
||||
&& api != Opcodes.ASM7
|
||||
|
@ -101,9 +101,8 @@ public class AnnotationNode extends AnnotationVisitor {
|
||||
/**
|
||||
* Constructs a new {@link AnnotationNode}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param descriptor the class descriptor of the annotation class.
|
||||
*/
|
||||
public AnnotationNode(final int api, final String descriptor) {
|
||||
@ -205,8 +204,8 @@ public class AnnotationNode extends AnnotationVisitor {
|
||||
* checks that this node, and all its children recursively, do not contain elements that were
|
||||
* introduced in more recent versions of the ASM API than the given version.
|
||||
*
|
||||
* @param api an ASM API version. Must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5},
|
||||
* {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api an ASM API version. Must be one of the {@code ASM}<i>x</i> values in {@link
|
||||
* Opcodes}.
|
||||
*/
|
||||
public void check(final int api) {
|
||||
// nothing to do
|
||||
|
@ -187,9 +187,8 @@ public class ClassNode extends ClassVisitor {
|
||||
/**
|
||||
* Constructs a new {@link ClassNode}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8}, or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public ClassNode(final int api) {
|
||||
super(api);
|
||||
@ -334,8 +333,8 @@ public class ClassNode extends ClassVisitor {
|
||||
* that this node, and all its children recursively, do not contain elements that were introduced
|
||||
* in more recent versions of the ASM API than the given version.
|
||||
*
|
||||
* @param api an ASM API version. Must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5},
|
||||
* {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api an ASM API version. Must be one of the {@code ASM}<i>x</i> values in {@link
|
||||
* Opcodes}.
|
||||
*/
|
||||
public void check(final int api) {
|
||||
if (api < Opcodes.ASM9 && permittedSubclasses != null) {
|
||||
|
@ -140,9 +140,8 @@ public class FieldNode extends FieldVisitor {
|
||||
/**
|
||||
* Constructs a new {@link FieldNode}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param access the field's access flags (see {@link jdk.internal.org.objectweb.asm.Opcodes}). This parameter
|
||||
* also indicates if the field is synthetic and/or deprecated.
|
||||
* @param name the field's name.
|
||||
@ -213,8 +212,8 @@ public class FieldNode extends FieldVisitor {
|
||||
* that this node, and all its children recursively, do not contain elements that were introduced
|
||||
* in more recent versions of the ASM API than the given version.
|
||||
*
|
||||
* @param api an ASM API version. Must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5},
|
||||
* {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api an ASM API version. Must be one of the {@code ASM}<i>x</i> values in {@link
|
||||
* Opcodes}.
|
||||
*/
|
||||
public void check(final int api) {
|
||||
if (api == Opcodes.ASM4) {
|
||||
|
@ -79,12 +79,12 @@ public class IincInsnNode extends AbstractInsnNode {
|
||||
/**
|
||||
* Constructs a new {@link IincInsnNode}.
|
||||
*
|
||||
* @param var index of the local variable to be incremented.
|
||||
* @param varIndex index of the local variable to be incremented.
|
||||
* @param incr increment amount to increment the local variable by.
|
||||
*/
|
||||
public IincInsnNode(final int var, final int incr) {
|
||||
public IincInsnNode(final int varIndex, final int incr) {
|
||||
super(Opcodes.IINC);
|
||||
this.var = var;
|
||||
this.var = varIndex;
|
||||
this.incr = incr;
|
||||
}
|
||||
|
||||
|
@ -121,9 +121,8 @@ public class LocalVariableAnnotationNode extends TypeAnnotationNode {
|
||||
/**
|
||||
* Constructs a new {@link LocalVariableAnnotationNode}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param typeRef a reference to the annotated type. See {@link jdk.internal.org.objectweb.asm.TypeReference}.
|
||||
* @param start the fist instructions corresponding to the continuous ranges that make the scope
|
||||
* of this local variable (inclusive).
|
||||
|
@ -196,9 +196,8 @@ public class MethodNode extends MethodVisitor {
|
||||
/**
|
||||
* Constructs an uninitialized {@link MethodNode}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
public MethodNode(final int api) {
|
||||
super(api);
|
||||
@ -233,9 +232,8 @@ public class MethodNode extends MethodVisitor {
|
||||
/**
|
||||
* Constructs a new {@link MethodNode}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param access the method's access flags (see {@link Opcodes}). This parameter also indicates if
|
||||
* the method is synthetic and/or deprecated.
|
||||
* @param name the method's name.
|
||||
@ -381,8 +379,8 @@ public class MethodNode extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
instructions.add(new VarInsnNode(opcode, var));
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
instructions.add(new VarInsnNode(opcode, varIndex));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -440,8 +438,8 @@ public class MethodNode extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
instructions.add(new IincInsnNode(var, increment));
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
instructions.add(new IincInsnNode(varIndex, increment));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -599,8 +597,8 @@ public class MethodNode extends MethodVisitor {
|
||||
* that this node, and all its children recursively, do not contain elements that were introduced
|
||||
* in more recent versions of the ASM API than the given version.
|
||||
*
|
||||
* @param api an ASM API version. Must be one of {@link Opcodes#ASM4}, {@link Opcodes#ASM5},
|
||||
* {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api an ASM API version. Must be one of the {@code ASM}<i>x</i> values in {@link
|
||||
* Opcodes}.
|
||||
*/
|
||||
public void check(final int api) {
|
||||
if (api == Opcodes.ASM4) {
|
||||
|
@ -100,9 +100,8 @@ public class TypeAnnotationNode extends AnnotationNode {
|
||||
/**
|
||||
* Constructs a new {@link AnnotationNode}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param typeRef a reference to the annotated type. See {@link jdk.internal.org.objectweb.asm.TypeReference}.
|
||||
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or
|
||||
* static inner type within 'typeRef'. May be {@literal null} if the annotation targets
|
||||
|
@ -92,7 +92,7 @@ final class Util {
|
||||
}
|
||||
ArrayList<T> list = new ArrayList<>(array.length);
|
||||
for (T t : array) {
|
||||
list.add(t);
|
||||
list.add(t); // NOPMD(UseArraysAsList): we want a modifiable list.
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -103,7 +103,7 @@ final class Util {
|
||||
}
|
||||
ArrayList<Byte> byteList = new ArrayList<>(byteArray.length);
|
||||
for (byte b : byteArray) {
|
||||
byteList.add(b);
|
||||
byteList.add(b); // NOPMD(UseArraysAsList): we want a modifiable list.
|
||||
}
|
||||
return byteList;
|
||||
}
|
||||
@ -114,7 +114,7 @@ final class Util {
|
||||
}
|
||||
ArrayList<Boolean> booleanList = new ArrayList<>(booleanArray.length);
|
||||
for (boolean b : booleanArray) {
|
||||
booleanList.add(b);
|
||||
booleanList.add(b); // NOPMD(UseArraysAsList): we want a modifiable list.
|
||||
}
|
||||
return booleanList;
|
||||
}
|
||||
@ -125,7 +125,7 @@ final class Util {
|
||||
}
|
||||
ArrayList<Short> shortList = new ArrayList<>(shortArray.length);
|
||||
for (short s : shortArray) {
|
||||
shortList.add(s);
|
||||
shortList.add(s); // NOPMD(UseArraysAsList): we want a modifiable list.
|
||||
}
|
||||
return shortList;
|
||||
}
|
||||
@ -136,7 +136,7 @@ final class Util {
|
||||
}
|
||||
ArrayList<Character> charList = new ArrayList<>(charArray.length);
|
||||
for (char c : charArray) {
|
||||
charList.add(c);
|
||||
charList.add(c); // NOPMD(UseArraysAsList): we want a modifiable list.
|
||||
}
|
||||
return charList;
|
||||
}
|
||||
@ -147,7 +147,7 @@ final class Util {
|
||||
}
|
||||
ArrayList<Integer> intList = new ArrayList<>(intArray.length);
|
||||
for (int i : intArray) {
|
||||
intList.add(i);
|
||||
intList.add(i); // NOPMD(UseArraysAsList): we want a modifiable list.
|
||||
}
|
||||
return intList;
|
||||
}
|
||||
@ -158,7 +158,7 @@ final class Util {
|
||||
}
|
||||
ArrayList<Float> floatList = new ArrayList<>(floatArray.length);
|
||||
for (float f : floatArray) {
|
||||
floatList.add(f);
|
||||
floatList.add(f); // NOPMD(UseArraysAsList): we want a modifiable list.
|
||||
}
|
||||
return floatList;
|
||||
}
|
||||
@ -169,7 +169,7 @@ final class Util {
|
||||
}
|
||||
ArrayList<Long> longList = new ArrayList<>(longArray.length);
|
||||
for (long l : longArray) {
|
||||
longList.add(l);
|
||||
longList.add(l); // NOPMD(UseArraysAsList): we want a modifiable list.
|
||||
}
|
||||
return longList;
|
||||
}
|
||||
@ -180,7 +180,7 @@ final class Util {
|
||||
}
|
||||
ArrayList<Double> doubleList = new ArrayList<>(doubleArray.length);
|
||||
for (double d : doubleArray) {
|
||||
doubleList.add(d);
|
||||
doubleList.add(d); // NOPMD(UseArraysAsList): we want a modifiable list.
|
||||
}
|
||||
return doubleList;
|
||||
}
|
||||
|
@ -78,12 +78,12 @@ public class VarInsnNode extends AbstractInsnNode {
|
||||
*
|
||||
* @param opcode the opcode of the local variable instruction to be constructed. This opcode must
|
||||
* be ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
|
||||
* @param var the operand of the instruction to be constructed. This operand is the index of a
|
||||
* local variable.
|
||||
* @param varIndex the operand of the instruction to be constructed. This operand is the index of
|
||||
* a local variable.
|
||||
*/
|
||||
public VarInsnNode(final int opcode, final int var) {
|
||||
public VarInsnNode(final int opcode, final int varIndex) {
|
||||
super(opcode);
|
||||
this.var = var;
|
||||
this.var = varIndex;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -284,17 +284,17 @@ public class Analyzer<V extends Value> implements Opcodes {
|
||||
} else if (insnOpcode != ATHROW && (insnOpcode < IRETURN || insnOpcode > RETURN)) {
|
||||
if (subroutine != null) {
|
||||
if (insnNode instanceof VarInsnNode) {
|
||||
int var = ((VarInsnNode) insnNode).var;
|
||||
subroutine.localsUsed[var] = true;
|
||||
int varIndex = ((VarInsnNode) insnNode).var;
|
||||
subroutine.localsUsed[varIndex] = true;
|
||||
if (insnOpcode == LLOAD
|
||||
|| insnOpcode == DLOAD
|
||||
|| insnOpcode == LSTORE
|
||||
|| insnOpcode == DSTORE) {
|
||||
subroutine.localsUsed[var + 1] = true;
|
||||
subroutine.localsUsed[varIndex + 1] = true;
|
||||
}
|
||||
} else if (insnNode instanceof IincInsnNode) {
|
||||
int var = ((IincInsnNode) insnNode).var;
|
||||
subroutine.localsUsed[var] = true;
|
||||
int varIndex = ((IincInsnNode) insnNode).var;
|
||||
subroutine.localsUsed[varIndex] = true;
|
||||
}
|
||||
}
|
||||
merge(insnIndex + 1, currentFrame, subroutine);
|
||||
|
@ -102,10 +102,8 @@ public class BasicInterpreter extends Interpreter<BasicValue> implements Opcodes
|
||||
/**
|
||||
* Constructs a new {@link BasicInterpreter}.
|
||||
*
|
||||
* @param api the ASM API version supported by this interpreter. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM8} or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this interpreter. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected BasicInterpreter(final int api) {
|
||||
super(api);
|
||||
|
@ -60,6 +60,7 @@
|
||||
package jdk.internal.org.objectweb.asm.tree.analysis;
|
||||
|
||||
import java.util.List;
|
||||
import jdk.internal.org.objectweb.asm.Opcodes;
|
||||
import jdk.internal.org.objectweb.asm.Type;
|
||||
import jdk.internal.org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import jdk.internal.org.objectweb.asm.tree.FieldInsnNode;
|
||||
@ -88,10 +89,8 @@ public class BasicVerifier extends BasicInterpreter {
|
||||
/**
|
||||
* Constructs a new {@link BasicVerifier}.
|
||||
*
|
||||
* @param api the ASM API version supported by this interpreter. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM8} or or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this interpreter. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected BasicVerifier(final int api) {
|
||||
super(api);
|
||||
|
@ -325,7 +325,7 @@ public class Frame<V extends Value> {
|
||||
V value2;
|
||||
V value3;
|
||||
V value4;
|
||||
int var;
|
||||
int varIndex;
|
||||
|
||||
switch (insn.getOpcode()) {
|
||||
case Opcodes.NOP:
|
||||
@ -363,15 +363,15 @@ public class Frame<V extends Value> {
|
||||
case Opcodes.DSTORE:
|
||||
case Opcodes.ASTORE:
|
||||
value1 = interpreter.copyOperation(insn, pop());
|
||||
var = ((VarInsnNode) insn).var;
|
||||
setLocal(var, value1);
|
||||
varIndex = ((VarInsnNode) insn).var;
|
||||
setLocal(varIndex, value1);
|
||||
if (value1.getSize() == 2) {
|
||||
setLocal(var + 1, interpreter.newEmptyValue(var + 1));
|
||||
setLocal(varIndex + 1, interpreter.newEmptyValue(varIndex + 1));
|
||||
}
|
||||
if (var > 0) {
|
||||
Value local = getLocal(var - 1);
|
||||
if (varIndex > 0) {
|
||||
Value local = getLocal(varIndex - 1);
|
||||
if (local != null && local.getSize() == 2) {
|
||||
setLocal(var - 1, interpreter.newEmptyValue(var - 1));
|
||||
setLocal(varIndex - 1, interpreter.newEmptyValue(varIndex - 1));
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -559,8 +559,8 @@ public class Frame<V extends Value> {
|
||||
push(interpreter.unaryOperation(insn, pop()));
|
||||
break;
|
||||
case Opcodes.IINC:
|
||||
var = ((IincInsnNode) insn).var;
|
||||
setLocal(var, interpreter.unaryOperation(insn, getLocal(var)));
|
||||
varIndex = ((IincInsnNode) insn).var;
|
||||
setLocal(varIndex, interpreter.unaryOperation(insn, getLocal(varIndex)));
|
||||
break;
|
||||
case Opcodes.I2L:
|
||||
case Opcodes.I2F:
|
||||
|
@ -60,6 +60,7 @@
|
||||
package jdk.internal.org.objectweb.asm.tree.analysis;
|
||||
|
||||
import java.util.List;
|
||||
import jdk.internal.org.objectweb.asm.Opcodes;
|
||||
import jdk.internal.org.objectweb.asm.Type;
|
||||
import jdk.internal.org.objectweb.asm.tree.AbstractInsnNode;
|
||||
import jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode;
|
||||
@ -77,18 +78,16 @@ import jdk.internal.org.objectweb.asm.tree.TryCatchBlockNode;
|
||||
public abstract class Interpreter<V extends Value> {
|
||||
|
||||
/**
|
||||
* The ASM API version supported by this interpreter. The value of this field must be one of
|
||||
* {@link jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6} or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}.
|
||||
* The ASM API version supported by this interpreter. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
/**
|
||||
* Constructs a new {@link Interpreter}.
|
||||
*
|
||||
* @param api the ASM API version supported by this interpreter. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6} or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}.
|
||||
* @param api the ASM API version supported by this interpreter. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected Interpreter(final int api) {
|
||||
this.api = api;
|
||||
|
@ -60,6 +60,7 @@
|
||||
package jdk.internal.org.objectweb.asm.tree.analysis;
|
||||
|
||||
import java.util.List;
|
||||
import jdk.internal.org.objectweb.asm.Opcodes;
|
||||
import jdk.internal.org.objectweb.asm.Type;
|
||||
|
||||
/**
|
||||
@ -140,10 +141,8 @@ public class SimpleVerifier extends BasicVerifier {
|
||||
* Constructs a new {@link SimpleVerifier} to verify a specific class. This class will not be
|
||||
* loaded into the JVM since it may be incorrect.
|
||||
*
|
||||
* @param api the ASM API version supported by this verifier. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM8} or or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this verifier. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param currentClass the type of the class to be verified.
|
||||
* @param currentSuperClass the type of the super class of the class to be verified.
|
||||
* @param currentClassInterfaces the types of the interfaces directly implemented by the class to
|
||||
|
@ -92,10 +92,8 @@ public class SourceInterpreter extends Interpreter<SourceValue> implements Opcod
|
||||
/**
|
||||
* Constructs a new {@link SourceInterpreter}.
|
||||
*
|
||||
* @param api the ASM API version supported by this interpreter. Must be one of {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM4}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM5}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM6}, {@link jdk.internal.org.objectweb.asm.Opcodes#ASM7}, {@link
|
||||
* jdk.internal.org.objectweb.asm.Opcodes#ASM8} or or {@link jdk.internal.org.objectweb.asm.Opcodes#ASM9}.
|
||||
* @param api the ASM API version supported by this interpreter. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected SourceInterpreter(final int api) {
|
||||
super(api);
|
||||
|
@ -97,7 +97,7 @@ public class SourceValue implements Value {
|
||||
* short, int, float, object and array types, and 2 for long and double.
|
||||
*/
|
||||
public SourceValue(final int size) {
|
||||
this(size, new SmallSet<AbstractInsnNode>());
|
||||
this(size, new SmallSet<>());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,6 +140,7 @@ public class ASMifier extends Printer {
|
||||
classVersions.put(Opcodes.V16, "V16");
|
||||
classVersions.put(Opcodes.V17, "V17");
|
||||
classVersions.put(Opcodes.V18, "V18");
|
||||
classVersions.put(Opcodes.V19, "V19");
|
||||
CLASS_VERSIONS = Collections.unmodifiableMap(classVersions);
|
||||
}
|
||||
|
||||
@ -168,9 +169,8 @@ public class ASMifier extends Printer {
|
||||
/**
|
||||
* Constructs a new {@link ASMifier}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this class. Must be one of {@link Opcodes#ASM4},
|
||||
* {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link Opcodes#ASM8} or
|
||||
* {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this class. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param visitorVariableName the name of the visitor variable in the produced code.
|
||||
* @param annotationVisitorId identifier of the annotation visitor variable in the produced code.
|
||||
*/
|
||||
@ -298,6 +298,7 @@ public class ASMifier extends Printer {
|
||||
@Override
|
||||
public Printer visitModule(final String name, final int flags, final String version) {
|
||||
stringBuilder.setLength(0);
|
||||
stringBuilder.append("{\n");
|
||||
stringBuilder.append("ModuleVisitor moduleVisitor = classWriter.visitModule(");
|
||||
appendConstant(name);
|
||||
stringBuilder.append(", ");
|
||||
@ -854,14 +855,14 @@ public class ASMifier extends Printer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
stringBuilder.setLength(0);
|
||||
stringBuilder
|
||||
.append(name)
|
||||
.append(".visitVarInsn(")
|
||||
.append(OPCODES[opcode])
|
||||
.append(", ")
|
||||
.append(var)
|
||||
.append(varIndex)
|
||||
.append(");\n");
|
||||
text.add(stringBuilder.toString());
|
||||
}
|
||||
@ -967,12 +968,12 @@ public class ASMifier extends Printer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
stringBuilder.setLength(0);
|
||||
stringBuilder
|
||||
.append(name)
|
||||
.append(".visitIincInsn(")
|
||||
.append(var)
|
||||
.append(varIndex)
|
||||
.append(", ")
|
||||
.append(increment)
|
||||
.append(");\n");
|
||||
@ -1232,9 +1233,9 @@ public class ASMifier extends Printer {
|
||||
.append("{\n")
|
||||
.append(ANNOTATION_VISITOR0)
|
||||
.append(name)
|
||||
.append(".")
|
||||
.append('.')
|
||||
.append(method)
|
||||
.append("(")
|
||||
.append('(')
|
||||
.append(typeRef);
|
||||
if (typePath == null) {
|
||||
stringBuilder.append(", null, ");
|
||||
@ -1317,11 +1318,7 @@ public class ASMifier extends Printer {
|
||||
if (!isEmpty) {
|
||||
stringBuilder.append(" | ");
|
||||
}
|
||||
if ((accessFlags & ACCESS_MODULE) == 0) {
|
||||
stringBuilder.append("ACC_FINAL");
|
||||
} else {
|
||||
stringBuilder.append("ACC_TRANSITIVE");
|
||||
}
|
||||
stringBuilder.append("ACC_FINAL");
|
||||
isEmpty = false;
|
||||
}
|
||||
if ((accessFlags & Opcodes.ACC_STATIC) != 0) {
|
||||
@ -1483,7 +1480,7 @@ public class ASMifier extends Printer {
|
||||
stringBuilder.append(handle.getOwner()).append(COMMA);
|
||||
stringBuilder.append(handle.getName()).append(COMMA);
|
||||
stringBuilder.append(handle.getDesc()).append("\", ");
|
||||
stringBuilder.append(handle.isInterface()).append(")");
|
||||
stringBuilder.append(handle.isInterface()).append(')');
|
||||
} else if (value instanceof ConstantDynamic) {
|
||||
stringBuilder.append("new ConstantDynamic(\"");
|
||||
ConstantDynamic constantDynamic = (ConstantDynamic) value;
|
||||
|
@ -71,6 +71,7 @@ import jdk.internal.org.objectweb.asm.AnnotationVisitor;
|
||||
import jdk.internal.org.objectweb.asm.Attribute;
|
||||
import jdk.internal.org.objectweb.asm.ClassReader;
|
||||
import jdk.internal.org.objectweb.asm.ClassVisitor;
|
||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||
import jdk.internal.org.objectweb.asm.FieldVisitor;
|
||||
import jdk.internal.org.objectweb.asm.Label;
|
||||
import jdk.internal.org.objectweb.asm.MethodVisitor;
|
||||
@ -193,7 +194,7 @@ public class CheckClassAdapter extends ClassVisitor {
|
||||
* @param classVisitor the class visitor to which this adapter must delegate calls.
|
||||
*/
|
||||
public CheckClassAdapter(final ClassVisitor classVisitor) {
|
||||
this(classVisitor, true);
|
||||
this(classVisitor, /* checkDataFlow = */ true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -201,8 +202,7 @@ public class CheckClassAdapter extends ClassVisitor {
|
||||
* Instead, they must use the {@link #CheckClassAdapter(int, ClassVisitor, boolean)} version.
|
||||
*
|
||||
* @param classVisitor the class visitor to which this adapter must delegate calls.
|
||||
* @param checkDataFlow whether to perform basic data flow checks. This option requires valid
|
||||
* maxLocals and maxStack values.
|
||||
* @param checkDataFlow whether to perform basic data flow checks.
|
||||
* @throws IllegalStateException If a subclass calls this constructor.
|
||||
*/
|
||||
public CheckClassAdapter(final ClassVisitor classVisitor, final boolean checkDataFlow) {
|
||||
@ -215,13 +215,11 @@ public class CheckClassAdapter extends ClassVisitor {
|
||||
/**
|
||||
* Constructs a new {@link CheckClassAdapter}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param classVisitor the class visitor to which this adapter must delegate calls.
|
||||
* @param checkDataFlow {@literal true} to perform basic data flow checks, or {@literal false} to
|
||||
* not perform any data flow check (see {@link CheckMethodAdapter}). This option requires
|
||||
* valid maxLocals and maxStack values.
|
||||
* not perform any data flow check (see {@link CheckMethodAdapter}).
|
||||
*/
|
||||
protected CheckClassAdapter(
|
||||
final int api, final ClassVisitor classVisitor, final boolean checkDataFlow) {
|
||||
@ -493,21 +491,17 @@ public class CheckClassAdapter extends ClassVisitor {
|
||||
}
|
||||
}
|
||||
CheckMethodAdapter checkMethodAdapter;
|
||||
MethodVisitor methodVisitor =
|
||||
super.visitMethod(access, name, descriptor, signature, exceptions);
|
||||
if (checkDataFlow) {
|
||||
if (cv instanceof ClassWriter) {
|
||||
methodVisitor =
|
||||
new CheckMethodAdapter.MethodWriterWrapper(api, (ClassWriter) cv, methodVisitor);
|
||||
}
|
||||
checkMethodAdapter =
|
||||
new CheckMethodAdapter(
|
||||
api,
|
||||
access,
|
||||
name,
|
||||
descriptor,
|
||||
super.visitMethod(access, name, descriptor, signature, exceptions),
|
||||
labelInsnIndices);
|
||||
new CheckMethodAdapter(api, access, name, descriptor, methodVisitor, labelInsnIndices);
|
||||
} else {
|
||||
checkMethodAdapter =
|
||||
new CheckMethodAdapter(
|
||||
api,
|
||||
super.visitMethod(access, name, descriptor, signature, exceptions),
|
||||
labelInsnIndices);
|
||||
checkMethodAdapter = new CheckMethodAdapter(api, methodVisitor, labelInsnIndices);
|
||||
}
|
||||
checkMethodAdapter.version = version;
|
||||
return checkMethodAdapter;
|
||||
|
@ -93,9 +93,8 @@ public class CheckFieldAdapter extends FieldVisitor {
|
||||
/**
|
||||
* Constructs a new {@link CheckFieldAdapter}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param fieldVisitor the field visitor to which this adapter must delegate calls.
|
||||
*/
|
||||
protected CheckFieldAdapter(final int api, final FieldVisitor fieldVisitor) {
|
||||
|
@ -70,6 +70,7 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import jdk.internal.org.objectweb.asm.AnnotationVisitor;
|
||||
import jdk.internal.org.objectweb.asm.Attribute;
|
||||
import jdk.internal.org.objectweb.asm.ClassWriter;
|
||||
import jdk.internal.org.objectweb.asm.ConstantDynamic;
|
||||
import jdk.internal.org.objectweb.asm.Handle;
|
||||
import jdk.internal.org.objectweb.asm.Label;
|
||||
@ -383,7 +384,7 @@ public class CheckMethodAdapter extends MethodVisitor {
|
||||
* @param methodvisitor the method visitor to which this adapter must delegate calls.
|
||||
*/
|
||||
public CheckMethodAdapter(final MethodVisitor methodvisitor) {
|
||||
this(methodvisitor, new HashMap<Label, Integer>());
|
||||
this(methodvisitor, new HashMap<>());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -409,9 +410,8 @@ public class CheckMethodAdapter extends MethodVisitor {
|
||||
* Constructs a new {@link CheckMethodAdapter} object. This method adapter will not perform any
|
||||
* data flow check (see {@link #CheckMethodAdapter(int,String,String,MethodVisitor,Map)}).
|
||||
*
|
||||
* @param api the ASM API version implemented by this CheckMethodAdapter. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this CheckMethodAdapter. Must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param methodVisitor the method visitor to which this adapter must delegate calls.
|
||||
* @param labelInsnIndices the index of the instruction designated by each visited label so far
|
||||
* (in other methods). This map is updated with the labels from the visited method.
|
||||
@ -458,9 +458,8 @@ public class CheckMethodAdapter extends MethodVisitor {
|
||||
* flow checks. For instance in a method whose signature is {@code void m ()}, the invalid
|
||||
* instruction IRETURN, or the invalid sequence IADD L2I will be detected.
|
||||
*
|
||||
* @param api the ASM API version implemented by this CheckMethodAdapter. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this CheckMethodAdapter. Must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param access the method's access flags.
|
||||
* @param name the method's name.
|
||||
* @param descriptor the method's descriptor (see {@link Type}).
|
||||
@ -482,15 +481,20 @@ public class CheckMethodAdapter extends MethodVisitor {
|
||||
public void visitEnd() {
|
||||
Analyzer<BasicValue> analyzer = new Analyzer<>(new BasicVerifier());
|
||||
try {
|
||||
analyzer.analyze("dummy", this);
|
||||
} catch (IndexOutOfBoundsException e) {
|
||||
if (maxLocals == 0 && maxStack == 0) {
|
||||
throw new IllegalArgumentException(
|
||||
"Data flow checking option requires valid, non zero maxLocals and maxStack.",
|
||||
e);
|
||||
// If 'methodVisitor' is a MethodWriter of a ClassWriter with no flags to compute the
|
||||
// max stack and locals nor the stack map frames, we know that valid max stack and
|
||||
// locals must be provided. Otherwise we assume they are not needed at this stage.
|
||||
// TODO(ebruneton): similarly, check that valid stack map frames are provided if the
|
||||
// class writer has no flags to compute them, and the class version is V1_7 or more.
|
||||
boolean checkMaxStackAndLocals =
|
||||
(methodVisitor instanceof MethodWriterWrapper)
|
||||
&& !((MethodWriterWrapper) methodVisitor).computesMaxs();
|
||||
if (checkMaxStackAndLocals) {
|
||||
analyzer.analyze("dummy", this);
|
||||
} else {
|
||||
analyzer.analyzeAndComputeMaxs("dummy", this);
|
||||
}
|
||||
throwError(analyzer, e);
|
||||
} catch (AnalyzerException e) {
|
||||
} catch (IndexOutOfBoundsException | AnalyzerException e) {
|
||||
throwError(analyzer, e);
|
||||
}
|
||||
if (methodVisitor != null) {
|
||||
@ -707,12 +711,12 @@ public class CheckMethodAdapter extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
checkVisitCodeCalled();
|
||||
checkVisitMaxsNotCalled();
|
||||
checkOpcodeMethod(opcode, Method.VISIT_VAR_INSN);
|
||||
checkUnsignedShort(var, INVALID_LOCAL_VARIABLE_INDEX);
|
||||
super.visitVarInsn(opcode, var);
|
||||
checkUnsignedShort(varIndex, INVALID_LOCAL_VARIABLE_INDEX);
|
||||
super.visitVarInsn(opcode, varIndex);
|
||||
++insnCount;
|
||||
}
|
||||
|
||||
@ -832,12 +836,12 @@ public class CheckMethodAdapter extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
checkVisitCodeCalled();
|
||||
checkVisitMaxsNotCalled();
|
||||
checkUnsignedShort(var, INVALID_LOCAL_VARIABLE_INDEX);
|
||||
checkUnsignedShort(varIndex, INVALID_LOCAL_VARIABLE_INDEX);
|
||||
checkSignedShort(increment, "Invalid increment");
|
||||
super.visitIincInsn(var, increment);
|
||||
super.visitIincInsn(varIndex, increment);
|
||||
++insnCount;
|
||||
}
|
||||
|
||||
@ -1473,5 +1477,19 @@ public class CheckMethodAdapter extends MethodVisitor {
|
||||
throw new IllegalArgumentException(INVALID + message + " (must be visited first)");
|
||||
}
|
||||
}
|
||||
|
||||
static class MethodWriterWrapper extends MethodVisitor {
|
||||
|
||||
private final ClassWriter owner;
|
||||
|
||||
MethodWriterWrapper(final int api, final ClassWriter owner, final MethodVisitor methodWriter) {
|
||||
super(api, methodWriter);
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
boolean computesMaxs() {
|
||||
return owner.hasFlags(ClassWriter.COMPUTE_MAXS) || owner.hasFlags(ClassWriter.COMPUTE_FRAMES);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -112,9 +112,8 @@ public class CheckModuleAdapter extends ModuleVisitor {
|
||||
/**
|
||||
* Constructs a new {@link CheckModuleAdapter}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param moduleVisitor the module visitor to which this adapter must delegate calls.
|
||||
* @param isOpen whether the visited module is open. Open modules have their {@link
|
||||
* Opcodes#ACC_OPEN} access flag set in {@link jdk.internal.org.objectweb.asm.ClassVisitor#visitModule}.
|
||||
|
@ -161,9 +161,8 @@ public class CheckSignatureAdapter extends SignatureVisitor {
|
||||
/**
|
||||
* Constructs a new {@link CheckSignatureAdapter}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
* @param type the type of signature to be checked. See {@link #CLASS_SIGNATURE}, {@link
|
||||
* #METHOD_SIGNATURE} and {@link #TYPE_SIGNATURE}.
|
||||
* @param signatureVisitor the visitor to which this adapter must delegate calls. May be {@literal
|
||||
|
@ -323,9 +323,8 @@ public abstract class Printer {
|
||||
private static final String UNSUPPORTED_OPERATION = "Must be overridden";
|
||||
|
||||
/**
|
||||
* The ASM API version implemented by this class. The value of this field must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* The ASM API version implemented by this class. The value of this field must be one of the
|
||||
* {@code ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected final int api;
|
||||
|
||||
@ -351,8 +350,8 @@ public abstract class Printer {
|
||||
/**
|
||||
* Constructs a new {@link Printer}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this printer. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6} or {@link Opcodes#ASM7}.
|
||||
* @param api the ASM API version implemented by this printer. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected Printer(final int api) {
|
||||
this.api = api;
|
||||
@ -950,10 +949,10 @@ public abstract class Printer {
|
||||
*
|
||||
* @param opcode the opcode of the local variable instruction to be visited. This opcode is either
|
||||
* ILOAD, LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
|
||||
* @param var the operand of the instruction to be visited. This operand is the index of a local
|
||||
* variable.
|
||||
* @param varIndex the operand of the instruction to be visited. This operand is the index of a
|
||||
* local variable.
|
||||
*/
|
||||
public abstract void visitVarInsn(int opcode, int var);
|
||||
public abstract void visitVarInsn(int opcode, int varIndex);
|
||||
|
||||
/**
|
||||
* Method instruction. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTypeInsn}.
|
||||
@ -1067,10 +1066,10 @@ public abstract class Printer {
|
||||
/**
|
||||
* Method instruction. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitIincInsn}.
|
||||
*
|
||||
* @param var index of the local variable to be incremented.
|
||||
* @param varIndex index of the local variable to be incremented.
|
||||
* @param increment amount to increment the local variable by.
|
||||
*/
|
||||
public abstract void visitIincInsn(int var, int increment);
|
||||
public abstract void visitIincInsn(int varIndex, int increment);
|
||||
|
||||
/**
|
||||
* Method instruction. See {@link jdk.internal.org.objectweb.asm.MethodVisitor#visitTableSwitchInsn}.
|
||||
|
@ -153,9 +153,8 @@ public class Textifier extends Printer {
|
||||
/**
|
||||
* Constructs a new {@link Textifier}.
|
||||
*
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of {@link
|
||||
* Opcodes#ASM4}, {@link Opcodes#ASM5}, {@link Opcodes#ASM6}, {@link Opcodes#ASM7}, {@link
|
||||
* Opcodes#ASM8} or {@link Opcodes#ASM9}.
|
||||
* @param api the ASM API version implemented by this visitor. Must be one of the {@code
|
||||
* ASM}<i>x</i> values in {@link Opcodes}.
|
||||
*/
|
||||
protected Textifier(final int api) {
|
||||
super(api);
|
||||
@ -920,9 +919,9 @@ public class Textifier extends Printer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
stringBuilder.setLength(0);
|
||||
stringBuilder.append(tab2).append(OPCODES[opcode]).append(' ').append(var).append('\n');
|
||||
stringBuilder.append(tab2).append(OPCODES[opcode]).append(' ').append(varIndex).append('\n');
|
||||
text.add(stringBuilder.toString());
|
||||
}
|
||||
|
||||
@ -1045,12 +1044,12 @@ public class Textifier extends Printer {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
stringBuilder.setLength(0);
|
||||
stringBuilder
|
||||
.append(tab2)
|
||||
.append("IINC ")
|
||||
.append(var)
|
||||
.append(varIndex)
|
||||
.append(' ')
|
||||
.append(increment)
|
||||
.append('\n');
|
||||
|
@ -175,9 +175,9 @@ public final class TraceMethodVisitor extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitVarInsn(final int opcode, final int var) {
|
||||
p.visitVarInsn(opcode, var);
|
||||
super.visitVarInsn(opcode, var);
|
||||
public void visitVarInsn(final int opcode, final int varIndex) {
|
||||
p.visitVarInsn(opcode, varIndex);
|
||||
super.visitVarInsn(opcode, varIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -248,9 +248,9 @@ public final class TraceMethodVisitor extends MethodVisitor {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visitIincInsn(final int var, final int increment) {
|
||||
p.visitIincInsn(var, increment);
|
||||
super.visitIincInsn(var, increment);
|
||||
public void visitIincInsn(final int varIndex, final int increment) {
|
||||
p.visitIincInsn(varIndex, increment);
|
||||
super.visitIincInsn(varIndex, increment);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,2 +1,2 @@
|
||||
ASM_9_2
|
||||
ASM_9_3
|
||||
origin http://gitlab.ow2.org/asm/asm.git (fetch)
|
||||
|
@ -1,4 +1,4 @@
|
||||
## ASM Bytecode Manipulation Framework v9.2
|
||||
## ASM Bytecode Manipulation Framework v9.3
|
||||
|
||||
### ASM License
|
||||
<pre>
|
||||
|
@ -50,8 +50,9 @@ public class ValidateJarWithSealedAndRecord {
|
||||
s.close();
|
||||
}
|
||||
|
||||
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar").orElseThrow(() -> new RuntimeException("jar tool not found"));
|
||||
|
||||
void generateFilesNeeded() throws Exception {
|
||||
ToolProvider jarTool = ToolProvider.findFirst("jar").orElseThrow(() -> new RuntimeException("jar tool not found"));
|
||||
writeFile("Foo.java",
|
||||
"""
|
||||
public sealed interface Foo {
|
||||
@ -60,12 +61,11 @@ public class ValidateJarWithSealedAndRecord {
|
||||
"""
|
||||
);
|
||||
com.sun.tools.javac.Main.compile(new String[]{"-d", "out", "Foo.java"});
|
||||
jarTool.run(System.out, System.err, new String[] {"--create", "--file", "foo.jar", "-C", "out", "."});
|
||||
JAR_TOOL.run(System.out, System.err, new String[] {"--create", "--file", "foo.jar", "-C", "out", "."});
|
||||
/* we need to create a fresh instance with clean options in other case the tool will
|
||||
* keep a copy of the options we just passed above
|
||||
*/
|
||||
jarTool = ToolProvider.findFirst("jar").orElseThrow(() -> new RuntimeException("jar tool not found"));
|
||||
if (jarTool.run(System.out, System.err, new String[]{"--validate", "--file", "foo.jar"}) != 0) {
|
||||
if (JAR_TOOL.run(System.out, System.err, new String[]{"--validate", "--file", "foo.jar"}) != 0) {
|
||||
throw new AssertionError("jar file couldn't be validated");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user