Commit 4f0da9db authored by Eric Bruneton's avatar Eric Bruneton

Fix some 'bugs' and 'code smells' found with SonarQube.

parent 252d3554
Pipeline #464 passed with stage
in 10 minutes and 27 seconds
......@@ -151,7 +151,8 @@ class ClassDump {
builder.add("minor_version: ", parser.u2());
builder.add("major_version: ", parser.u2());
int constantPoolCount = parser.u2();
for (int cpIndex = 1; cpIndex < constantPoolCount; ) {
int cpIndex = 1;
while (cpIndex < constantPoolCount) {
CpInfo cpInfo = parseCpInfo(parser, builder);
builder.putCpInfo(cpIndex, cpInfo);
cpIndex += cpInfo.size();
......@@ -745,10 +746,8 @@ class ClassDump {
* 4.6</a>
*/
private static void dumpMethodInfo(Parser parser, Builder builder) throws IOException {
builder.add("access_flags: ", parser.u2());
builder.addCpInfo("name_index: ", parser.u2());
builder.addCpInfo("descriptor_index: ", parser.u2());
dumpAttributeList(parser, builder);
// method_info has the same top level structure as field_info.
dumpFieldInfo(parser, builder);
}
/**
......@@ -783,7 +782,7 @@ class ClassDump {
} else if (attributeName.equals("EnclosingMethod")) {
dumpEnclosingMethodAttribute(parser, builder);
} else if (attributeName.equals("Synthetic")) {
dumpSyntheticAttribute(parser, builder);
dumpSyntheticAttribute();
} else if (attributeName.equals("Signature")) {
dumpSignatureAttribute(parser, builder);
} else if (attributeName.equals("SourceFile")) {
......@@ -797,7 +796,7 @@ class ClassDump {
} else if (attributeName.equals("LocalVariableTypeTable")) {
dumpLocalVariableTypeTableAttribute(parser, builder);
} else if (attributeName.equals("Deprecated")) {
dumpDeprecatedAttribute(parser, builder);
dumpDeprecatedAttribute();
} else if (attributeName.equals("RuntimeVisibleAnnotations")) {
dumpRuntimeVisibleAnnotationsAttribute(parser, builder);
} else if (attributeName.equals("RuntimeInvisibleAnnotations")) {
......@@ -1483,12 +1482,10 @@ class ClassDump {
/**
* Parses and dumps a Synthetic attribute.
*
* @param parser a class parser.
* @param builder a dump builder.
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.8">JVMS
* 4.7.8</a>
*/
private static void dumpSyntheticAttribute(Parser parser, Builder builder) {
private static void dumpSyntheticAttribute() {
// Nothing to parse.
}
......@@ -1601,12 +1598,10 @@ class ClassDump {
/**
* Parses and dumps a Deprecated attribute.
*
* @param parser a class parser.
* @param builder a dump builder.
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-4.html#jvms-4.7.15">JVMS
* 4.7.15</a>
*/
private static void dumpDeprecatedAttribute(Parser parser, Builder builder) {
private static void dumpDeprecatedAttribute() {
// Nothing to parse.
}
......@@ -2114,8 +2109,8 @@ class ClassDump {
AbstractBuilder(AbstractBuilder<?> parent) {
this.parent = parent;
this.children = new ArrayList<T>();
this.context = new HashMap<Integer, Object>();
this.children = new ArrayList<>();
this.context = new HashMap<>();
}
/**
......@@ -2132,7 +2127,7 @@ class ClassDump {
public <C extends CpInfo> C getCpInfo(int cpIndex, Class<C> cpInfoType) {
Object cpInfo = get(CP_INFO_KEY | cpIndex);
if (cpInfo != null && !cpInfoType.isInstance(cpInfo)) {
throw new RuntimeException(
throw new IllegalArgumentException(
"Invalid constant pool type :"
+ cpInfo.getClass().getName()
+ " should be "
......@@ -2145,7 +2140,7 @@ class ClassDump {
public int getInsnIndex(int bytecodeOffset) {
Integer insnIndex = (Integer) get(bytecodeOffset);
if (insnIndex == null) {
throw new RuntimeException("Invalid bytecode offset:" + bytecodeOffset);
throw new IllegalArgumentException("Invalid bytecode offset:" + bytecodeOffset);
}
return insnIndex;
}
......@@ -2294,11 +2289,17 @@ class ClassDump {
return name.compareTo(builder.name);
}
@Override
public boolean equals(Object other) {
return (other instanceof Builder) && name.equals(((Builder) other).name);
}
}
@Override
public int hashCode() {
return name.hashCode();
}
}
/** An {@link AbstractBuilder} which sorts its children by name before building. */
private static class SortedBuilder extends AbstractBuilder<Builder> {
SortedBuilder(Builder parent) {
......
......@@ -95,7 +95,7 @@ public class Attribute {
* code attribute that contains labels.
*/
protected Label[] getLabels() {
return null;
return new Label[0];
}
/**
......
......@@ -126,7 +126,7 @@ public abstract class ClassVisitor {
*/
public ModuleVisitor visitModule(final String name, final int access, final String version) {
if (api < Opcodes.ASM6) {
throw new RuntimeException();
throw new UnsupportedOperationException();
}
if (cv != null) {
return cv.visitModule(name, access, version);
......@@ -183,7 +183,7 @@ public abstract class ClassVisitor {
public AnnotationVisitor visitTypeAnnotation(
final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
if (api < Opcodes.ASM5) {
throw new RuntimeException();
throw new UnsupportedOperationException();
}
if (cv != null) {
return cv.visitTypeAnnotation(typeRef, typePath, descriptor, visible);
......
......@@ -393,7 +393,9 @@ public class ClassWriter extends ClassVisitor {
}
@Override
public final void visitEnd() {}
public final void visitEnd() {
// Nothing to do.
}
// -----------------------------------------------------------------------------------------------
// Other public methods
......@@ -436,12 +438,10 @@ public class ClassWriter extends ClassVisitor {
size += 10;
symbolTable.addConstantUtf8("EnclosingMethod");
}
if ((accessFlags & Opcodes.ACC_SYNTHETIC) != 0) {
if ((version & 0xFFFF) < Opcodes.V1_5) {
++attributesCount;
size += 6;
symbolTable.addConstantUtf8("Synthetic");
}
if ((accessFlags & Opcodes.ACC_SYNTHETIC) != 0 && (version & 0xFFFF) < Opcodes.V1_5) {
++attributesCount;
size += 6;
symbolTable.addConstantUtf8("Synthetic");
}
if (signatureIndex != 0) {
++attributesCount;
......@@ -498,7 +498,7 @@ public class ClassWriter extends ClassVisitor {
// statements can add attribute names to the constant pool, thereby changing its size!
size += symbolTable.getConstantPoolLength();
if (symbolTable.getConstantPoolCount() > 0xFFFF) {
throw new RuntimeException("Class file too large!");
throw new IndexOutOfBoundsException("Class file too large!");
}
// Second step: allocate a ByteVector of the correct size (in order to avoid any array copy in
......@@ -809,13 +809,18 @@ public class ClassWriter extends ClassVisitor {
* @return the internal name of the common super class of the two given classes.
*/
protected String getCommonSuperClass(final String type1, final String type2) {
Class<?> class1, class2;
ClassLoader classLoader = getClass().getClassLoader();
Class<?> class1;
try {
class1 = Class.forName(type1.replace('/', '.'), false, classLoader);
} catch (Exception e) {
throw new TypeNotPresentException(type1, e);
}
Class<?> class2;
try {
class2 = Class.forName(type2.replace('/', '.'), false, classLoader);
} catch (Exception e) {
throw new RuntimeException(e.toString());
throw new TypeNotPresentException(type2, e);
}
if (class1.isAssignableFrom(class2)) {
return type1;
......
......@@ -34,14 +34,16 @@ package org.objectweb.asm;
* @see <a href="https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.html">JVMS 6</a>
* @author Eric Bruneton
*/
interface Constants extends Opcodes {
final class Constants implements Opcodes {
private Constants() {}
// ASM specific access flags.
// WARNING: the 16 least significant bits must NOT be used, to avoid conflicts with standard
// access flags, and also to make sure that these flags are automatically filtered out when
// written in class files (because access flags are stored using 16 bits only).
int ACC_CONSTRUCTOR = 0x40000; // method access flag.
static final int ACC_CONSTRUCTOR = 0x40000; // method access flag.
// ASM specific stack map frame types, used in {@link ClassVisitor#visitFrame}.
......@@ -53,90 +55,90 @@ interface Constants extends Opcodes {
* used when an unconditional jump is inserted in a method while expanding an ASM specific
* instruction. Keep in sync with Opcodes.java.
*/
int F_INSERT = 256;
static final int F_INSERT = 256;
// The JVM opcode values which are not part of the ASM public API.
// See https://docs.oracle.com/javase/specs/jvms/se9/html/jvms-6.html.
int LDC_W = 19;
int LDC2_W = 20;
int ILOAD_0 = 26;
int ILOAD_1 = 27;
int ILOAD_2 = 28;
int ILOAD_3 = 29;
int LLOAD_0 = 30;
int LLOAD_1 = 31;
int LLOAD_2 = 32;
int LLOAD_3 = 33;
int FLOAD_0 = 34;
int FLOAD_1 = 35;
int FLOAD_2 = 36;
int FLOAD_3 = 37;
int DLOAD_0 = 38;
int DLOAD_1 = 39;
int DLOAD_2 = 40;
int DLOAD_3 = 41;
int ALOAD_0 = 42;
int ALOAD_1 = 43;
int ALOAD_2 = 44;
int ALOAD_3 = 45;
int ISTORE_0 = 59;
int ISTORE_1 = 60;
int ISTORE_2 = 61;
int ISTORE_3 = 62;
int LSTORE_0 = 63;
int LSTORE_1 = 64;
int LSTORE_2 = 65;
int LSTORE_3 = 66;
int FSTORE_0 = 67;
int FSTORE_1 = 68;
int FSTORE_2 = 69;
int FSTORE_3 = 70;
int DSTORE_0 = 71;
int DSTORE_1 = 72;
int DSTORE_2 = 73;
int DSTORE_3 = 74;
int ASTORE_0 = 75;
int ASTORE_1 = 76;
int ASTORE_2 = 77;
int ASTORE_3 = 78;
int WIDE = 196;
int GOTO_W = 200;
int JSR_W = 201;
static final int LDC_W = 19;
static final int LDC2_W = 20;
static final int ILOAD_0 = 26;
static final int ILOAD_1 = 27;
static final int ILOAD_2 = 28;
static final int ILOAD_3 = 29;
static final int LLOAD_0 = 30;
static final int LLOAD_1 = 31;
static final int LLOAD_2 = 32;
static final int LLOAD_3 = 33;
static final int FLOAD_0 = 34;
static final int FLOAD_1 = 35;
static final int FLOAD_2 = 36;
static final int FLOAD_3 = 37;
static final int DLOAD_0 = 38;
static final int DLOAD_1 = 39;
static final int DLOAD_2 = 40;
static final int DLOAD_3 = 41;
static final int ALOAD_0 = 42;
static final int ALOAD_1 = 43;
static final int ALOAD_2 = 44;
static final int ALOAD_3 = 45;
static final int ISTORE_0 = 59;
static final int ISTORE_1 = 60;
static final int ISTORE_2 = 61;
static final int ISTORE_3 = 62;
static final int LSTORE_0 = 63;
static final int LSTORE_1 = 64;
static final int LSTORE_2 = 65;
static final int LSTORE_3 = 66;
static final int FSTORE_0 = 67;
static final int FSTORE_1 = 68;
static final int FSTORE_2 = 69;
static final int FSTORE_3 = 70;
static final int DSTORE_0 = 71;
static final int DSTORE_1 = 72;
static final int DSTORE_2 = 73;
static final int DSTORE_3 = 74;
static final int ASTORE_0 = 75;
static final int ASTORE_1 = 76;
static final int ASTORE_2 = 77;
static final int ASTORE_3 = 78;
static final int WIDE = 196;
static final int GOTO_W = 200;
static final int JSR_W = 201;
// Constants to convert between normal and wide jump instructions.
// The delta between the GOTO_W and JSR_W opcodes and GOTO and JUMP.
int WIDE_JUMP_OPCODE_DELTA = GOTO_W - GOTO;
static final int WIDE_JUMP_OPCODE_DELTA = GOTO_W - GOTO;
// Constants to convert JVM opcodes to the equivalent ASM specific opcodes, and vice versa.
// The delta between the ASM_IFEQ, ..., ASM_IF_ACMPNE, ASM_GOTO and ASM_JSR opcodes
// and IFEQ, ..., IF_ACMPNE, GOTO and JSR.
int ASM_OPCODE_DELTA = 49;
static final int ASM_OPCODE_DELTA = 49;
// The delta between the ASM_IFNULL and ASM_IFNONNULL opcodes and IFNULL and IFNONNULL.
int ASM_IFNULL_OPCODE_DELTA = 20;
static final int ASM_IFNULL_OPCODE_DELTA = 20;
// ASM specific opcodes, used for long forward jump instructions.
int ASM_IFEQ = IFEQ + ASM_OPCODE_DELTA;
int ASM_IFNE = IFNE + ASM_OPCODE_DELTA;
int ASM_IFLT = IFLT + ASM_OPCODE_DELTA;
int ASM_IFGE = IFGE + ASM_OPCODE_DELTA;
int ASM_IFGT = IFGT + ASM_OPCODE_DELTA;
int ASM_IFLE = IFLE + ASM_OPCODE_DELTA;
int ASM_IF_ICMPEQ = IF_ICMPEQ + ASM_OPCODE_DELTA;
int ASM_IF_ICMPNE = IF_ICMPNE + ASM_OPCODE_DELTA;
int ASM_IF_ICMPLT = IF_ICMPLT + ASM_OPCODE_DELTA;
int ASM_IF_ICMPGE = IF_ICMPGE + ASM_OPCODE_DELTA;
int ASM_IF_ICMPGT = IF_ICMPGT + ASM_OPCODE_DELTA;
int ASM_IF_ICMPLE = IF_ICMPLE + ASM_OPCODE_DELTA;
int ASM_IF_ACMPEQ = IF_ACMPEQ + ASM_OPCODE_DELTA;
int ASM_IF_ACMPNE = IF_ACMPNE + ASM_OPCODE_DELTA;
int ASM_GOTO = GOTO + ASM_OPCODE_DELTA;
int ASM_JSR = JSR + ASM_OPCODE_DELTA;
int ASM_IFNULL = IFNULL + ASM_IFNULL_OPCODE_DELTA;
int ASM_IFNONNULL = IFNONNULL + ASM_IFNULL_OPCODE_DELTA;
int ASM_GOTO_W = 220;
static final int ASM_IFEQ = IFEQ + ASM_OPCODE_DELTA;
static final int ASM_IFNE = IFNE + ASM_OPCODE_DELTA;
static final int ASM_IFLT = IFLT + ASM_OPCODE_DELTA;
static final int ASM_IFGE = IFGE + ASM_OPCODE_DELTA;
static final int ASM_IFGT = IFGT + ASM_OPCODE_DELTA;
static final int ASM_IFLE = IFLE + ASM_OPCODE_DELTA;
static final int ASM_IF_ICMPEQ = IF_ICMPEQ + ASM_OPCODE_DELTA;
static final int ASM_IF_ICMPNE = IF_ICMPNE + ASM_OPCODE_DELTA;
static final int ASM_IF_ICMPLT = IF_ICMPLT + ASM_OPCODE_DELTA;
static final int ASM_IF_ICMPGE = IF_ICMPGE + ASM_OPCODE_DELTA;
static final int ASM_IF_ICMPGT = IF_ICMPGT + ASM_OPCODE_DELTA;
static final int ASM_IF_ICMPLE = IF_ICMPLE + ASM_OPCODE_DELTA;
static final int ASM_IF_ACMPEQ = IF_ACMPEQ + ASM_OPCODE_DELTA;
static final int ASM_IF_ACMPNE = IF_ACMPNE + ASM_OPCODE_DELTA;
static final int ASM_GOTO = GOTO + ASM_OPCODE_DELTA;
static final int ASM_JSR = JSR + ASM_OPCODE_DELTA;
static final int ASM_IFNULL = IFNULL + ASM_IFNULL_OPCODE_DELTA;
static final int ASM_IFNONNULL = IFNONNULL + ASM_IFNULL_OPCODE_DELTA;
static final int ASM_GOTO_W = 220;
}
......@@ -102,7 +102,7 @@ public abstract class FieldVisitor {
public AnnotationVisitor visitTypeAnnotation(
final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
if (api < Opcodes.ASM5) {
throw new RuntimeException();
throw new UnsupportedOperationException();
}
if (fv != null) {
return fv.visitTypeAnnotation(typeRef, typePath, descriptor, visible);
......
......@@ -185,7 +185,9 @@ final class FieldWriter extends FieldVisitor {
}
@Override
public void visitEnd() {}
public void visitEnd() {
// Nothing to do.
}
// -----------------------------------------------------------------------------------------------
// Utility methods
......
......@@ -328,11 +328,11 @@ class Frame {
typeValue = REFERENCE_KIND | symbolTable.addType(internalName);
break;
default:
throw new AssertionError();
throw new IllegalArgumentException();
}
return ((elementDescriptorOffset - offset) << DIM_SHIFT) | typeValue;
default:
throw new AssertionError();
throw new IllegalArgumentException();
}
}
......@@ -445,7 +445,8 @@ class Frame {
}
}
inputStack = new int[nStack + nStackTop];
for (int inputStackIndex = 0, i = 0; i < nStack; ++i) {
int inputStackIndex = 0;
for (int i = 0; i < nStack; ++i) {
inputStack[inputStackIndex++] = getAbstractTypeFromApiFormat(symbolTable, stack[i]);
if (stack[i] == Opcodes.LONG || stack[i] == Opcodes.DOUBLE) {
inputStack[inputStackIndex++] = TOP;
......@@ -746,6 +747,7 @@ class Frame {
break;
case Symbol.CONSTANT_METHOD_HANDLE_TAG:
push(REFERENCE_KIND | symbolTable.addType("java/lang/invoke/MethodHandle"));
break;
default:
throw new AssertionError();
}
......@@ -753,23 +755,12 @@ class Frame {
case Opcodes.ALOAD:
push(getLocal(arg));
break;
case Opcodes.IALOAD:
case Opcodes.BALOAD:
case Opcodes.CALOAD:
case Opcodes.SALOAD:
pop(2);
push(INTEGER);
break;
case Opcodes.LALOAD:
case Opcodes.D2L:
pop(2);
push(LONG);
push(TOP);
break;
case Opcodes.FALOAD:
pop(2);
push(FLOAT);
break;
case Opcodes.DALOAD:
case Opcodes.L2D:
pop(2);
......@@ -917,6 +908,10 @@ class Frame {
push(abstractType1);
push(abstractType2);
break;
case Opcodes.IALOAD:
case Opcodes.BALOAD:
case Opcodes.CALOAD:
case Opcodes.SALOAD:
case Opcodes.IADD:
case Opcodes.ISUB:
case Opcodes.IMUL:
......@@ -947,6 +942,7 @@ class Frame {
push(LONG);
push(TOP);
break;
case Opcodes.FALOAD:
case Opcodes.FADD:
case Opcodes.FSUB:
case Opcodes.FMUL:
......@@ -1006,7 +1002,7 @@ class Frame {
break;
case Opcodes.JSR:
case Opcodes.RET:
throw new RuntimeException("JSR/RET are not supported with computeFrames option");
throw new IllegalArgumentException("JSR/RET are not supported with computeFrames option");
case Opcodes.GETSTATIC:
push(symbolTable, argSymbol.value);
break;
......@@ -1069,7 +1065,7 @@ class Frame {
push(ARRAY_OF | LONG);
break;
default:
throw new AssertionError();
throw new IllegalArgumentException();
}
break;
case Opcodes.ANEWARRAY:
......@@ -1095,7 +1091,7 @@ class Frame {
push(symbolTable, argSymbol.value);
break;
default:
throw new AssertionError();
throw new IllegalArgumentException();
}
}
......@@ -1341,47 +1337,44 @@ class Frame {
* Frame}.
*/
final void accept(final MethodWriter methodWriter) {
int nLocal = 0;
int nStack = 0;
int[] localTypes = inputLocals;
int[] stackTypes = inputStack;
// Compute the number of locals, ignoring TOP types that are just after a LONG or a DOUBLE, and
// all trailing TOP types.
for (int i = 0, nTrailingTop = 0; i < localTypes.length; ++i) {
int[] localTypes = inputLocals;
int nLocal = 0;
int nTrailingTop = 0;
int i = 0;
while (i < localTypes.length) {
int localType = localTypes[i];
i += (localType == LONG || localType == DOUBLE) ? 2 : 1;
if (localType == TOP) {
++nTrailingTop;
nTrailingTop++;
} else {
nLocal += nTrailingTop + 1;
nTrailingTop = 0;
}
if (localType == LONG || localType == DOUBLE) {
++i;
}
}
// Compute the stack size, ignoring TOP types that are just after a LONG or a DOUBLE.
for (int i = 0; i < stackTypes.length; ++i) {
++nStack;
int[] stackTypes = inputStack;
int nStack = 0;
i = 0;
while (i < stackTypes.length) {
int stackType = stackTypes[i];
if (stackType == LONG || stackType == DOUBLE) {
++i;
}
i += (stackType == LONG || stackType == DOUBLE) ? 2 : 1;
nStack++;
}
// Visit the frame and its content.
int frameIndex = methodWriter.visitFrameStart(owner.bytecodeOffset, nLocal, nStack);
for (int i = 0; nLocal > 0; ++i, --nLocal) {
i = 0;
while (nLocal-- > 0) {
int localType = localTypes[i];
i += (localType == LONG || localType == DOUBLE) ? 2 : 1;
methodWriter.visitAbstractType(frameIndex++, localType);
if (localType == LONG || localType == DOUBLE) {
++i;
}
}
for (int i = 0; i < stackTypes.length; ++i) {
i = 0;
while (nStack-- > 0) {
int stackType = stackTypes[i];
i += (stackType == LONG || stackType == DOUBLE) ? 2 : 1;
methodWriter.visitAbstractType(frameIndex++, stackType);
if (stackType == LONG || stackType == DOUBLE) {
++i;
}
}
methodWriter.visitFrameEnd();
}
......
......@@ -287,7 +287,9 @@ public class Label {
// -----------------------------------------------------------------------------------------------
/** Constructs a new label. */
public Label() {}
public Label() {
// Nothing to do.
}
/**
* Returns the bytecode offset corresponding to this label. This offset is computed from the start
......@@ -527,9 +529,8 @@ public class Label {
*
* @param subroutineCaller a basic block that ends with a jsr to the basic block corresponding to
* this label. This label is supposed to correspond to the start of a subroutine.
* @param numSubroutine the total number of subroutines in the method.
*/
final void addSubroutineRetSuccessors(final Label subroutineCaller, final int numSubroutine) {
final void addSubroutineRetSuccessors(final Label subroutineCaller) {
// Data flow algorithm: put this basic block in a list blocks to process (which are blocks
// belonging to a subroutine starting with this label) and, while there are blocks to process,
// remove one from the list, put it in a list of blocks that have been processed, add a return
......@@ -568,9 +569,9 @@ public class Label {
// Reset the {@link #nextListElement} of all the basic blocks that have been processed to null,
// so that this method can be called again with a different subroutine or subroutine caller.
while (listOfProcessedBlocks != EMPTY_LIST) {
Label nextListElement = listOfProcessedBlocks.nextListElement;
Label newListOfProcessedBlocks = listOfProcessedBlocks.nextListElement;
listOfProcessedBlocks.nextListElement = null;
listOfProcessedBlocks = nextListElement;
listOfProcessedBlocks = newListOfProcessedBlocks;
}
}
......@@ -590,13 +591,11 @@ public class Label {
// leads to the jsr target (see {@link #FLAG_SUBROUTINE_CALLER}).
boolean isJsrTarget =
(flags & Label.FLAG_SUBROUTINE_CALLER) != 0 && outgoingEdge == outgoingEdges.nextEdge;
if (!isJsrTarget) {
if (!isJsrTarget && outgoingEdge.successor.nextListElement == null) {
// Add this successor to the list of blocks to process, if it does not already belong to a
// list of labels.
if (outgoingEdge.successor.nextListElement == null) {
outgoingEdge.successor.nextListElement = listOfLabelsToProcess;
listOfLabelsToProcess = outgoingEdge.successor;
}
outgoingEdge.successor.nextListElement = listOfLabelsToProcess;
listOfLabelsToProcess = outgoingEdge.successor;
}
outgoingEdge = outgoingEdge.nextEdge;
}
......
......@@ -96,7 +96,7 @@ public abstract class MethodVisitor {
*/
public void visitParameter(final String name, final int access) {
if (api < Opcodes.ASM5) {
throw new RuntimeException("This feature requires ASM5");
throw new UnsupportedOperationException("This feature requires ASM5");
}
if (mv != null) {
mv.visitParameter(name, access);
......@@ -153,7 +153,7 @@ public abstract class MethodVisitor {
public AnnotationVisitor visitTypeAnnotation(
final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
if (api < Opcodes.ASM5) {
throw new RuntimeException("This feature requires ASM5");
throw new UnsupportedOperationException("This feature requires ASM5");
}
if (mv != null) {
return mv.visitTypeAnnotation(typeRef, typePath, descriptor, visible);
......@@ -266,8 +266,8 @@ public abstract class MethodVisitor {
* @param nLocal the number of local variables in the visited frame.
* @param local the local variable types in this frame. This array must not be modified. Primitive
* types are represented by {@link Opcodes#TOP}, {@link Opcodes#INTEGER}, {@link
* Opcodes#FLOAT}, {@link Opcodes#LONG}, {@link Opcodes#DOUBLE},{@link Opcodes#NULL} or {@link
* Opcodes#UNINITIALIZED_THIS} (long and double are represented by a single element).
* Opcodes#FLOAT}, {@link Opcodes#LONG}, {@link Opcodes#DOUBLE}, {@link Opcodes#NULL} or
* {@link Opcodes#UNINITIALIZED_THIS} (long and double are represented by a single element).
* Reference types are represented by String objects (representing internal names), and
* uninitialized types by Label objects (this label designates the NEW instruction that
* created this uninitialized value).
......@@ -390,6 +390,7 @@ public abstract class MethodVisitor {
* getInternalName}).
* @param name the method's name.
* @param descriptor the method's descriptor (see {@link Type Type}).
* @deprecated
*/
@Deprecated
public void visitMethodInsn(
......@@ -450,7 +451,7 @@ public abstract class MethodVisitor {
final Handle bootstrapMethodHandle,
final Object... bootstrapMethodArguments) {
if (api < Opcodes.ASM5) {
throw new RuntimeException("This feature requires ASM5");
throw new UnsupportedOperationException("This feature requires ASM5");
}
if (mv != null) {
mv.visitInvokeDynamicInsn(name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments);
......@@ -613,7 +614,7 @@ public abstract class MethodVisitor {
public AnnotationVisitor visitInsnAnnotation(
final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
if (api < Opcodes.ASM5) {
throw new RuntimeException("This feature requires ASM5");
throw new UnsupportedOperationException("This feature requires ASM5");
}
if (mv != null) {
return mv.visitInsnAnnotation(typeRef, typePath, descriptor, visible);
......@@ -661,7 +662,7 @@ public abstract class MethodVisitor {
public AnnotationVisitor visitTryCatchAnnotation(
final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
if (api < Opcodes.ASM5) {
throw new RuntimeException("This feature requires ASM5");
throw new UnsupportedOperationException("This feature requires ASM5");
}
if (mv != null) {
return mv.visitTryCatchAnnotation(typeRef, typePath, descriptor, visible);
......@@ -724,7 +725,7 @@ public abstract class MethodVisitor {
final String descriptor,
final boolean visible) {
if (api < Opcodes.ASM5) {
throw new RuntimeException("This feature requires ASM5");
throw new UnsupportedOperationException("This feature requires ASM5");
}
if (mv != null) {
return mv.visitLocalVariableAnnotation(
......
......@@ -720,7 +720,9 @@ final class MethodWriter extends MethodVisitor {
}
@Override
public void visitCode() {}
public void visitCode() {