Browse Source

Upgrade to ASM 9.3

Closes gh-28390
pull/27953/head
Juergen Hoeller 4 years ago
parent
commit
b55eee1b0d
  1. 4
      spring-core/src/main/java/org/springframework/asm/AnnotationVisitor.java
  2. 9
      spring-core/src/main/java/org/springframework/asm/ByteVector.java
  3. 4
      spring-core/src/main/java/org/springframework/asm/ClassVisitor.java
  4. 4
      spring-core/src/main/java/org/springframework/asm/FieldVisitor.java
  5. 12
      spring-core/src/main/java/org/springframework/asm/MethodVisitor.java
  6. 35
      spring-core/src/main/java/org/springframework/asm/MethodWriter.java
  7. 4
      spring-core/src/main/java/org/springframework/asm/ModuleVisitor.java
  8. 4
      spring-core/src/main/java/org/springframework/asm/RecordComponentVisitor.java
  9. 2
      spring-core/src/main/java/org/springframework/asm/Type.java

4
spring-core/src/main/java/org/springframework/asm/AnnotationVisitor.java

@ -55,7 +55,7 @@ public abstract class AnnotationVisitor { @@ -55,7 +55,7 @@ public abstract class AnnotationVisitor {
* @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);
}
@ -67,7 +67,7 @@ public abstract class AnnotationVisitor { @@ -67,7 +67,7 @@ public abstract class AnnotationVisitor {
* @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

9
spring-core/src/main/java/org/springframework/asm/ByteVector.java

@ -65,6 +65,15 @@ public class ByteVector { @@ -65,6 +65,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.
*

4
spring-core/src/main/java/org/springframework/asm/ClassVisitor.java

@ -54,7 +54,7 @@ public abstract class ClassVisitor { @@ -54,7 +54,7 @@ public abstract class ClassVisitor {
* @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);
}
@ -66,7 +66,7 @@ public abstract class ClassVisitor { @@ -66,7 +66,7 @@ public abstract class ClassVisitor {
* @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

4
spring-core/src/main/java/org/springframework/asm/FieldVisitor.java

@ -51,7 +51,7 @@ public abstract class FieldVisitor { @@ -51,7 +51,7 @@ public abstract class FieldVisitor {
* @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);
}
@ -63,7 +63,7 @@ public abstract class FieldVisitor { @@ -63,7 +63,7 @@ public abstract class FieldVisitor {
* @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

12
spring-core/src/main/java/org/springframework/asm/MethodVisitor.java

@ -67,7 +67,7 @@ public abstract class MethodVisitor { @@ -67,7 +67,7 @@ public abstract class MethodVisitor {
* @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);
}
@ -79,7 +79,7 @@ public abstract class MethodVisitor { @@ -79,7 +79,7 @@ public abstract class MethodVisitor {
* @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
@ -349,12 +349,12 @@ public abstract class MethodVisitor { @@ -349,12 +349,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);
}
}

35
spring-core/src/main/java/org/springframework/asm/MethodWriter.java

@ -466,7 +466,8 @@ final class MethodWriter extends MethodVisitor { @@ -466,7 +466,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;
@ -904,26 +905,26 @@ final class MethodWriter extends MethodVisitor { @@ -904,26 +905,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.
@ -945,9 +946,9 @@ final class MethodWriter extends MethodVisitor { @@ -945,9 +946,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;
@ -1307,21 +1308,21 @@ final class MethodWriter extends MethodVisitor { @@ -1307,21 +1308,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;
}

4
spring-core/src/main/java/org/springframework/asm/ModuleVisitor.java

@ -53,7 +53,7 @@ public abstract class ModuleVisitor { @@ -53,7 +53,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);
}
@ -65,7 +65,7 @@ public abstract class ModuleVisitor { @@ -65,7 +65,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

4
spring-core/src/main/java/org/springframework/asm/RecordComponentVisitor.java

@ -53,7 +53,7 @@ public abstract class RecordComponentVisitor { @@ -53,7 +53,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);
}
@ -64,7 +64,7 @@ public abstract class RecordComponentVisitor { @@ -64,7 +64,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

2
spring-core/src/main/java/org/springframework/asm/Type.java

@ -440,7 +440,7 @@ public final class Type { @@ -440,7 +440,7 @@ public final class Type {
case '(':
return new Type(METHOD, descriptorBuffer, descriptorBegin, descriptorEnd);
default:
throw new IllegalArgumentException();
throw new IllegalArgumentException("Invalid descriptor: " + descriptorBuffer);
}
}

Loading…
Cancel
Save