Improve the code quality of the tree package.
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/AbstractInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/AbstractInsnNode.java
index 087b73a..579658e 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/AbstractInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/AbstractInsnNode.java
@@ -106,16 +106,16 @@
*/
public List<TypeAnnotationNode> invisibleTypeAnnotations;
- /** Previous instruction in the list to which this instruction belongs. */
- AbstractInsnNode prev;
+ /** The previous instruction in the list to which this instruction belongs. */
+ AbstractInsnNode previousInsn;
- /** Next instruction in the list to which this instruction belongs. */
- AbstractInsnNode next;
+ /** The next instruction in the list to which this instruction belongs. */
+ AbstractInsnNode nextInsn;
/**
- * Index of this instruction in the list to which it belongs. The value of this field is correct
- * only when {@link InsnList#cache} is not null. A value of -1 indicates that this instruction
- * does not belong to any {@link InsnList}.
+ * The index of this instruction in the list to which it belongs. The value of this field is
+ * correct only when {@link InsnList#cache} is not null. A value of -1 indicates that this
+ * instruction does not belong to any {@link InsnList}.
*/
int index;
@@ -152,7 +152,7 @@
* <tt>null</tt>.
*/
public AbstractInsnNode getPrevious() {
- return prev;
+ return previousInsn;
}
/**
@@ -162,65 +162,72 @@
* <tt>null</tt>.
*/
public AbstractInsnNode getNext() {
- return next;
+ return nextInsn;
}
/**
- * Makes the given code visitor visit this instruction.
+ * Makes the given method visitor visit this instruction.
*
- * @param cv a code visitor.
+ * @param methodVisitor a method visitor.
*/
- public abstract void accept(final MethodVisitor cv);
+ public abstract void accept(final MethodVisitor methodVisitor);
/**
* Makes the given visitor visit the annotations of this instruction.
*
- * @param mv a method visitor.
+ * @param methodVisitor a method visitor.
*/
- protected final void acceptAnnotations(final MethodVisitor mv) {
- int n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size();
- for (int i = 0; i < n; ++i) {
- TypeAnnotationNode an = visibleTypeAnnotations.get(i);
- an.accept(mv.visitInsnAnnotation(an.typeRef, an.typePath, an.desc, true));
+ protected final void acceptAnnotations(final MethodVisitor methodVisitor) {
+ if (visibleTypeAnnotations != null) {
+ for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode typeAnnotation = visibleTypeAnnotations.get(i);
+ typeAnnotation.accept(
+ methodVisitor.visitInsnAnnotation(
+ typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, true));
+ }
}
- n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations.size();
- for (int i = 0; i < n; ++i) {
- TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
- an.accept(mv.visitInsnAnnotation(an.typeRef, an.typePath, an.desc, false));
+ if (invisibleTypeAnnotations != null) {
+ for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode typeAnnotation = invisibleTypeAnnotations.get(i);
+ typeAnnotation.accept(
+ methodVisitor.visitInsnAnnotation(
+ typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, false));
+ }
}
}
/**
* Returns a copy of this instruction.
*
- * @param labels a map from LabelNodes to cloned LabelNodes.
+ * @param clonedLabels a map from LabelNodes to cloned LabelNodes.
* @return a copy of this instruction. The returned instruction does not belong to any {@link
* InsnList}.
*/
- public abstract AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels);
+ public abstract AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels);
/**
* Returns the clone of the given label.
*
* @param label a label.
- * @param map a map from LabelNodes to cloned LabelNodes.
+ * @param clonedLabels a map from LabelNodes to cloned LabelNodes.
* @return the clone of the given label.
*/
- static LabelNode clone(final LabelNode label, final Map<LabelNode, LabelNode> map) {
- return map.get(label);
+ static LabelNode clone(final LabelNode label, final Map<LabelNode, LabelNode> clonedLabels) {
+ return clonedLabels.get(label);
}
/**
* Returns the clones of the given labels.
*
* @param labels a list of labels.
- * @param map a map from LabelNodes to cloned LabelNodes.
+ * @param clonedLabels a map from LabelNodes to cloned LabelNodes.
* @return the clones of the given labels.
*/
- static LabelNode[] clone(final List<LabelNode> labels, final Map<LabelNode, LabelNode> map) {
+ static LabelNode[] clone(
+ final List<LabelNode> labels, final Map<LabelNode, LabelNode> clonedLabels) {
LabelNode[] clones = new LabelNode[labels.size()];
- for (int i = 0; i < clones.length; ++i) {
- clones[i] = map.get(labels.get(i));
+ for (int i = 0, n = clones.length; i < n; ++i) {
+ clones[i] = clonedLabels.get(labels.get(i));
}
return clones;
}
@@ -228,26 +235,30 @@
/**
* Clones the annotations of the given instruction into this instruction.
*
- * @param insn the source instruction.
+ * @param insnNode the source instruction.
* @return this instruction.
*/
- protected final AbstractInsnNode cloneAnnotations(final AbstractInsnNode insn) {
- if (insn.visibleTypeAnnotations != null) {
+ protected final AbstractInsnNode cloneAnnotations(final AbstractInsnNode insnNode) {
+ if (insnNode.visibleTypeAnnotations != null) {
this.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>();
- for (int i = 0; i < insn.visibleTypeAnnotations.size(); ++i) {
- TypeAnnotationNode src = insn.visibleTypeAnnotations.get(i);
- TypeAnnotationNode ann = new TypeAnnotationNode(src.typeRef, src.typePath, src.desc);
- src.accept(ann);
- this.visibleTypeAnnotations.add(ann);
+ for (int i = 0, n = insnNode.visibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode sourceAnnotation = insnNode.visibleTypeAnnotations.get(i);
+ TypeAnnotationNode cloneAnnotation =
+ new TypeAnnotationNode(
+ sourceAnnotation.typeRef, sourceAnnotation.typePath, sourceAnnotation.desc);
+ sourceAnnotation.accept(cloneAnnotation);
+ this.visibleTypeAnnotations.add(cloneAnnotation);
}
}
- if (insn.invisibleTypeAnnotations != null) {
+ if (insnNode.invisibleTypeAnnotations != null) {
this.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>();
- for (int i = 0; i < insn.invisibleTypeAnnotations.size(); ++i) {
- TypeAnnotationNode src = insn.invisibleTypeAnnotations.get(i);
- TypeAnnotationNode ann = new TypeAnnotationNode(src.typeRef, src.typePath, src.desc);
- src.accept(ann);
- this.invisibleTypeAnnotations.add(ann);
+ for (int i = 0, n = insnNode.invisibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode sourceAnnotation = insnNode.invisibleTypeAnnotations.get(i);
+ TypeAnnotationNode cloneAnnotation =
+ new TypeAnnotationNode(
+ sourceAnnotation.typeRef, sourceAnnotation.typePath, sourceAnnotation.desc);
+ sourceAnnotation.accept(cloneAnnotation);
+ this.invisibleTypeAnnotations.add(cloneAnnotation);
}
}
return this;
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java
index b22ef72..17068b0 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/AnnotationNode.java
@@ -57,11 +57,11 @@
* Constructs a new {@link AnnotationNode}. <i>Subclasses must not use this constructor</i>.
* Instead, they must use the {@link #AnnotationNode(int, String)} version.
*
- * @param desc the class descriptor of the annotation class.
+ * @param descriptor the class descriptor of the annotation class.
* @throws IllegalStateException If a subclass calls this constructor.
*/
- public AnnotationNode(final String desc) {
- this(Opcodes.ASM6, desc);
+ public AnnotationNode(final String descriptor) {
+ this(Opcodes.ASM6, descriptor);
if (getClass() != AnnotationNode.class) {
throw new IllegalStateException();
}
@@ -72,11 +72,11 @@
*
* @param api the ASM API version implemented by this visitor. Must be one of {@link
* Opcodes#ASM4}, {@link Opcodes#ASM5} or {@link Opcodes#ASM6}.
- * @param desc the class descriptor of the annotation class.
+ * @param descriptor the class descriptor of the annotation class.
*/
- public AnnotationNode(final int api, final String desc) {
+ public AnnotationNode(final int api, final String descriptor) {
super(api);
- this.desc = desc;
+ this.desc = descriptor;
}
/**
@@ -102,86 +102,46 @@
values.add(name);
}
if (value instanceof byte[]) {
- byte[] v = (byte[]) value;
- ArrayList<Byte> l = new ArrayList<Byte>(v.length);
- for (byte b : v) {
- l.add(b);
- }
- values.add(l);
+ values.add(Util.asArrayList((byte[]) value));
} else if (value instanceof boolean[]) {
- boolean[] v = (boolean[]) value;
- ArrayList<Boolean> l = new ArrayList<Boolean>(v.length);
- for (boolean b : v) {
- l.add(b);
- }
- values.add(l);
+ values.add(Util.asArrayList((boolean[]) value));
} else if (value instanceof short[]) {
- short[] v = (short[]) value;
- ArrayList<Short> l = new ArrayList<Short>(v.length);
- for (short s : v) {
- l.add(s);
- }
- values.add(l);
+ values.add(Util.asArrayList((short[]) value));
} else if (value instanceof char[]) {
- char[] v = (char[]) value;
- ArrayList<Character> l = new ArrayList<Character>(v.length);
- for (char c : v) {
- l.add(c);
- }
- values.add(l);
+ values.add(Util.asArrayList((char[]) value));
} else if (value instanceof int[]) {
- int[] v = (int[]) value;
- ArrayList<Integer> l = new ArrayList<Integer>(v.length);
- for (int i : v) {
- l.add(i);
- }
- values.add(l);
+ values.add(Util.asArrayList((int[]) value));
} else if (value instanceof long[]) {
- long[] v = (long[]) value;
- ArrayList<Long> l = new ArrayList<Long>(v.length);
- for (long lng : v) {
- l.add(lng);
- }
- values.add(l);
+ values.add(Util.asArrayList((long[]) value));
} else if (value instanceof float[]) {
- float[] v = (float[]) value;
- ArrayList<Float> l = new ArrayList<Float>(v.length);
- for (float f : v) {
- l.add(f);
- }
- values.add(l);
+ values.add(Util.asArrayList((float[]) value));
} else if (value instanceof double[]) {
- double[] v = (double[]) value;
- ArrayList<Double> l = new ArrayList<Double>(v.length);
- for (double d : v) {
- l.add(d);
- }
- values.add(l);
+ values.add(Util.asArrayList((double[]) value));
} else {
values.add(value);
}
}
@Override
- public void visitEnum(final String name, final String desc, final String value) {
+ public void visitEnum(final String name, final String descriptor, final String value) {
if (values == null) {
values = new ArrayList<Object>(this.desc != null ? 2 : 1);
}
if (this.desc != null) {
values.add(name);
}
- values.add(new String[] {desc, value});
+ values.add(new String[] {descriptor, value});
}
@Override
- public AnnotationVisitor visitAnnotation(final String name, final String desc) {
+ public AnnotationVisitor visitAnnotation(final String name, final String descriptor) {
if (values == null) {
values = new ArrayList<Object>(this.desc != null ? 2 : 1);
}
if (this.desc != null) {
values.add(name);
}
- AnnotationNode annotation = new AnnotationNode(desc);
+ AnnotationNode annotation = new AnnotationNode(descriptor);
values.add(annotation);
return annotation;
}
@@ -200,15 +160,17 @@
}
@Override
- public void visitEnd() {}
+ public void visitEnd() {
+ // Nothing to do.
+ }
// ------------------------------------------------------------------------
// Accept methods
// ------------------------------------------------------------------------
/**
- * Checks that this annotation node is compatible with the given ASM API version. This methods
- * checks that this node, and all its nodes recursively, do not contain elements that were
+ * Checks that this annotation node is compatible with the given ASM API version. This method
+ * 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} or
@@ -221,47 +183,48 @@
/**
* Makes the given visitor visit this annotation.
*
- * @param av an annotation visitor. Maybe <tt>null</tt>.
+ * @param annotationVisitor an annotation visitor. Maybe <tt>null</tt>.
*/
- public void accept(final AnnotationVisitor av) {
- if (av != null) {
+ public void accept(final AnnotationVisitor annotationVisitor) {
+ if (annotationVisitor != null) {
if (values != null) {
- for (int i = 0; i < values.size(); i += 2) {
+ for (int i = 0, n = values.size(); i < n; i += 2) {
String name = (String) values.get(i);
Object value = values.get(i + 1);
- accept(av, name, value);
+ accept(annotationVisitor, name, value);
}
}
- av.visitEnd();
+ annotationVisitor.visitEnd();
}
}
/**
* Makes the given visitor visit a given annotation value.
*
- * @param av an annotation visitor. Maybe <tt>null</tt>.
+ * @param annotationVisitor an annotation visitor. Maybe <tt>null</tt>.
* @param name the value name.
* @param value the actual value.
*/
- static void accept(final AnnotationVisitor av, final String name, final Object value) {
- if (av != null) {
+ static void accept(
+ final AnnotationVisitor annotationVisitor, final String name, final Object value) {
+ if (annotationVisitor != null) {
if (value instanceof String[]) {
- String[] typeconst = (String[]) value;
- av.visitEnum(name, typeconst[0], typeconst[1]);
+ String[] typeValue = (String[]) value;
+ annotationVisitor.visitEnum(name, typeValue[0], typeValue[1]);
} else if (value instanceof AnnotationNode) {
- AnnotationNode an = (AnnotationNode) value;
- an.accept(av.visitAnnotation(name, an.desc));
+ AnnotationNode annotationValue = (AnnotationNode) value;
+ annotationValue.accept(annotationVisitor.visitAnnotation(name, annotationValue.desc));
} else if (value instanceof List) {
- AnnotationVisitor v = av.visitArray(name);
- if (v != null) {
- List<?> array = (List<?>) value;
- for (int j = 0; j < array.size(); ++j) {
- accept(v, null, array.get(j));
+ AnnotationVisitor arrayAnnotationVisitor = annotationVisitor.visitArray(name);
+ if (arrayAnnotationVisitor != null) {
+ List<?> arrayValue = (List<?>) value;
+ for (int i = 0, n = arrayValue.size(); i < n; ++i) {
+ accept(arrayAnnotationVisitor, null, arrayValue.get(i));
}
- v.visitEnd();
+ arrayAnnotationVisitor.visitEnd();
}
} else {
- av.visit(name, value);
+ annotationVisitor.visit(name, value);
}
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java
index 19100db..00cf26a 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ClassNode.java
@@ -28,7 +28,6 @@
package org.objectweb.asm.tree;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.objectweb.asm.AnnotationVisitor;
@@ -47,7 +46,10 @@
*/
public class ClassNode extends ClassVisitor {
- /** The class version. */
+ /**
+ * The class version. The minor version is stored in the 16 most significant bits, and the major
+ * version in the 16 least significant bits.
+ */
public int version;
/**
@@ -56,26 +58,22 @@
*/
public int access;
- /**
- * The internal name of the class (see {@link org.objectweb.asm.Type#getInternalName()
- * getInternalName}).
- */
+ /** The internal name of this class (see {@link org.objectweb.asm.Type#getInternalName}). */
public String name;
- /** The signature of the class. May be <tt>null</tt>. */
+ /** The signature of this class. May be <tt>null</tt>. */
public String signature;
/**
- * The internal of name of the super class (see {@link org.objectweb.asm.Type#getInternalName()
- * getInternalName}). For interfaces, the super class is {@link Object}. May be <tt>null</tt>, but
- * only for the {@link Object} class.
+ * The internal of name of the super class (see {@link org.objectweb.asm.Type#getInternalName}).
+ * For interfaces, the super class is {@link Object}. May be <tt>null</tt>, but only for the
+ * {@link Object} class.
*/
public String superName;
/**
- * The internal names of the class's interfaces (see {@link
- * org.objectweb.asm.Type#getInternalName() getInternalName}). This list is a list of {@link
- * String} objects.
+ * The internal names of the interfaces directly implemented by this class (see {@link
+ * org.objectweb.asm.Type#getInternalName}).
*/
public List<String> interfaces;
@@ -83,73 +81,50 @@
public String sourceFile;
/**
- * Debug information to compute the correspondence between source and compiled elements of the
- * class. May be <tt>null</tt>.
+ * The correspondence between source and compiled elements of this class. May be <tt>null</tt>.
*/
public String sourceDebug;
- /** Module information. May be <tt>null</tt>. */
+ /** The module stored in this class. May be <tt>null</tt>. */
public ModuleNode module;
- /** The internal name of the enclosing class of the class. May be <tt>null</tt>. */
+ /** The internal name of the enclosing class of this class. May be <tt>null</tt>. */
public String outerClass;
/**
- * The name of the method that contains the class, or <tt>null</tt> if the class is not enclosed
+ * The name of the method that contains this class, or <tt>null</tt> if this class is not enclosed
* in a method.
*/
public String outerMethod;
/**
- * The descriptor of the method that contains the class, or <tt>null</tt> if the class is not
+ * The descriptor of the method that contains this class, or <tt>null</tt> if this class is not
* enclosed in a method.
*/
public String outerMethodDesc;
- /**
- * The runtime visible annotations of this class. This list is a list of {@link AnnotationNode}
- * objects. May be <tt>null</tt>.
- */
+ /** The runtime visible annotations of this class. May be <tt>null</tt>. */
public List<AnnotationNode> visibleAnnotations;
- /**
- * The runtime invisible annotations of this class. This list is a list of {@link AnnotationNode}
- * objects. May be <tt>null</tt>.
- */
+ /** The runtime invisible annotations of this class. May be <tt>null</tt>. */
public List<AnnotationNode> invisibleAnnotations;
- /**
- * The runtime visible type annotations of this class. This list is a list of {@link
- * TypeAnnotationNode} objects. May be <tt>null</tt>.
- */
+ /** The runtime visible type annotations of this class. May be <tt>null</tt>. */
public List<TypeAnnotationNode> visibleTypeAnnotations;
- /**
- * The runtime invisible type annotations of this class. This list is a list of {@link
- * TypeAnnotationNode} objects. May be <tt>null</tt>.
- */
+ /** The runtime invisible type annotations of this class. May be <tt>null</tt>. */
public List<TypeAnnotationNode> invisibleTypeAnnotations;
- /**
- * The non standard attributes of this class. This list is a list of {@link Attribute} objects.
- * May be <tt>null</tt>.
- */
+ /** The non standard attributes of this class. May be <tt>null</tt>. */
public List<Attribute> attrs;
- /**
- * Informations about the inner classes of this class. This list is a list of {@link
- * InnerClassNode} objects.
- */
+ /** The inner classes of this class. */
public List<InnerClassNode> innerClasses;
- /**
- * The fields of this class. This list is a list of {@link FieldNode} objects.
- */
+ /** The fields of this class. */
public List<FieldNode> fields;
- /**
- * The methods of this class. This list is a list of {@link MethodNode} objects.
- */
+ /** The methods of this class. */
public List<MethodNode> methods;
/**
@@ -179,9 +154,9 @@
this.methods = new ArrayList<MethodNode>();
}
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
// Implementation of the ClassVisitor abstract class
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
@Override
public void visit(
@@ -196,9 +171,7 @@
this.name = name;
this.signature = signature;
this.superName = superName;
- if (interfaces != null) {
- this.interfaces.addAll(Arrays.asList(interfaces));
- }
+ this.interfaces = Util.asArrayList(interfaces);
}
@Override
@@ -209,206 +182,218 @@
@Override
public ModuleVisitor visitModule(final String name, final int access, final String version) {
- return module = new ModuleNode(name, access, version);
+ module = new ModuleNode(name, access, version);
+ return module;
}
@Override
- public void visitOuterClass(final String owner, final String name, final String desc) {
+ public void visitOuterClass(final String owner, final String name, final String descriptor) {
outerClass = owner;
outerMethod = name;
- outerMethodDesc = desc;
+ outerMethodDesc = descriptor;
}
@Override
- public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
- AnnotationNode an = new AnnotationNode(desc);
+ public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
+ AnnotationNode annotation = new AnnotationNode(descriptor);
if (visible) {
if (visibleAnnotations == null) {
visibleAnnotations = new ArrayList<AnnotationNode>(1);
}
- visibleAnnotations.add(an);
+ visibleAnnotations.add(annotation);
} else {
if (invisibleAnnotations == null) {
invisibleAnnotations = new ArrayList<AnnotationNode>(1);
}
- invisibleAnnotations.add(an);
+ invisibleAnnotations.add(annotation);
}
- return an;
+ return annotation;
}
@Override
public AnnotationVisitor visitTypeAnnotation(
- int typeRef, TypePath typePath, String desc, boolean visible) {
- TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc);
+ final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
+ TypeAnnotationNode typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor);
if (visible) {
if (visibleTypeAnnotations == null) {
visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
- visibleTypeAnnotations.add(an);
+ visibleTypeAnnotations.add(typeAnnotation);
} else {
if (invisibleTypeAnnotations == null) {
invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
- invisibleTypeAnnotations.add(an);
+ invisibleTypeAnnotations.add(typeAnnotation);
}
- return an;
+ return typeAnnotation;
}
@Override
- public void visitAttribute(final Attribute attr) {
+ public void visitAttribute(final Attribute attribute) {
if (attrs == null) {
attrs = new ArrayList<Attribute>(1);
}
- attrs.add(attr);
+ attrs.add(attribute);
}
@Override
public void visitInnerClass(
final String name, final String outerName, final String innerName, final int access) {
- InnerClassNode icn = new InnerClassNode(name, outerName, innerName, access);
- innerClasses.add(icn);
+ InnerClassNode innerClass = new InnerClassNode(name, outerName, innerName, access);
+ innerClasses.add(innerClass);
}
@Override
public FieldVisitor visitField(
final int access,
final String name,
- final String desc,
+ final String descriptor,
final String signature,
final Object value) {
- FieldNode fn = new FieldNode(access, name, desc, signature, value);
- fields.add(fn);
- return fn;
+ FieldNode field = new FieldNode(access, name, descriptor, signature, value);
+ fields.add(field);
+ return field;
}
@Override
public MethodVisitor visitMethod(
final int access,
final String name,
- final String desc,
+ final String descriptor,
final String signature,
final String[] exceptions) {
- MethodNode mn = new MethodNode(access, name, desc, signature, exceptions);
- methods.add(mn);
- return mn;
+ MethodNode method = new MethodNode(access, name, descriptor, signature, exceptions);
+ methods.add(method);
+ return method;
}
@Override
- public void visitEnd() {}
+ public void visitEnd() {
+ // Nothing to do.
+ }
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
// Accept method
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
/**
- * Checks that this class node is compatible with the given ASM API version. This methods checks
- * that this node, and all its nodes recursively, do not contain elements that were introduced in
- * more recent versions of the ASM API than the given version.
+ * Checks that this class node is compatible with the given ASM API version. This method 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} or
* {@link Opcodes#ASM6}.
*/
public void check(final int api) {
- if (api < Opcodes.ASM6) {
- if (module != null) {
- throw new RuntimeException();
- }
+ if (api < Opcodes.ASM6 && module != null) {
+ throw new UnsupportedClassVersionException();
}
if (api < Opcodes.ASM5) {
- if (visibleTypeAnnotations != null && visibleTypeAnnotations.size() > 0) {
- throw new RuntimeException();
+ if (visibleTypeAnnotations != null && !visibleTypeAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
- if (invisibleTypeAnnotations != null && invisibleTypeAnnotations.size() > 0) {
- throw new RuntimeException();
+ if (invisibleTypeAnnotations != null && !invisibleTypeAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
}
- // checks attributes
- int i, n;
- n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
- for (i = 0; i < n; ++i) {
- visibleAnnotations.get(i).check(api);
+ // Check the annotations.
+ if (visibleAnnotations != null) {
+ for (int i = visibleAnnotations.size() - 1; i >= 0; --i) {
+ visibleAnnotations.get(i).check(api);
+ }
}
- n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
- for (i = 0; i < n; ++i) {
- invisibleAnnotations.get(i).check(api);
+ if (invisibleAnnotations != null) {
+ for (int i = invisibleAnnotations.size() - 1; i >= 0; --i) {
+ invisibleAnnotations.get(i).check(api);
+ }
}
- n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size();
- for (i = 0; i < n; ++i) {
- visibleTypeAnnotations.get(i).check(api);
+ if (visibleTypeAnnotations != null) {
+ for (int i = visibleTypeAnnotations.size() - 1; i >= 0; --i) {
+ visibleTypeAnnotations.get(i).check(api);
+ }
}
- n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations.size();
- for (i = 0; i < n; ++i) {
- invisibleTypeAnnotations.get(i).check(api);
+ if (invisibleTypeAnnotations != null) {
+ for (int i = invisibleTypeAnnotations.size() - 1; i >= 0; --i) {
+ invisibleTypeAnnotations.get(i).check(api);
+ }
}
- for (FieldNode f : fields) {
- f.check(api);
+ for (int i = fields.size() - 1; i >= 0; --i) {
+ fields.get(i).check(api);
}
- for (MethodNode m : methods) {
- m.check(api);
+ for (int i = methods.size() - 1; i >= 0; --i) {
+ methods.get(i).check(api);
}
}
/**
* Makes the given class visitor visit this class.
*
- * @param cv a class visitor.
+ * @param classVisitor a class visitor.
*/
- public void accept(final ClassVisitor cv) {
- // visits header
- String[] interfaces = new String[this.interfaces.size()];
- this.interfaces.toArray(interfaces);
- cv.visit(version, access, name, signature, superName, interfaces);
- // visits source
+ public void accept(final ClassVisitor classVisitor) {
+ // Visit the header.
+ String[] interfacesArray = new String[this.interfaces.size()];
+ this.interfaces.toArray(interfacesArray);
+ classVisitor.visit(version, access, name, signature, superName, interfacesArray);
+ // Visit the source.
if (sourceFile != null || sourceDebug != null) {
- cv.visitSource(sourceFile, sourceDebug);
+ classVisitor.visitSource(sourceFile, sourceDebug);
}
- // visits module
+ // Visit the module.
if (module != null) {
- module.accept(cv);
+ module.accept(classVisitor);
}
- // visits outer class
+ // Visit the outer class.
if (outerClass != null) {
- cv.visitOuterClass(outerClass, outerMethod, outerMethodDesc);
+ classVisitor.visitOuterClass(outerClass, outerMethod, outerMethodDesc);
}
- // visits attributes
- int i, n;
- n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
- for (i = 0; i < n; ++i) {
- AnnotationNode an = visibleAnnotations.get(i);
- an.accept(cv.visitAnnotation(an.desc, true));
+ // Visit the annotations.
+ if (visibleAnnotations != null) {
+ for (int i = 0, n = visibleAnnotations.size(); i < n; ++i) {
+ AnnotationNode annotation = visibleAnnotations.get(i);
+ annotation.accept(classVisitor.visitAnnotation(annotation.desc, true));
+ }
}
- n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
- for (i = 0; i < n; ++i) {
- AnnotationNode an = invisibleAnnotations.get(i);
- an.accept(cv.visitAnnotation(an.desc, false));
+ if (invisibleAnnotations != null) {
+ for (int i = 0, n = invisibleAnnotations.size(); i < n; ++i) {
+ AnnotationNode annotation = invisibleAnnotations.get(i);
+ annotation.accept(classVisitor.visitAnnotation(annotation.desc, false));
+ }
}
- n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size();
- for (i = 0; i < n; ++i) {
- TypeAnnotationNode an = visibleTypeAnnotations.get(i);
- an.accept(cv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, true));
+ if (visibleTypeAnnotations != null) {
+ for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode typeAnnotation = visibleTypeAnnotations.get(i);
+ typeAnnotation.accept(
+ classVisitor.visitTypeAnnotation(
+ typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, true));
+ }
}
- n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations.size();
- for (i = 0; i < n; ++i) {
- TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
- an.accept(cv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, false));
+ if (invisibleTypeAnnotations != null) {
+ for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode typeAnnotation = invisibleTypeAnnotations.get(i);
+ typeAnnotation.accept(
+ classVisitor.visitTypeAnnotation(
+ typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, false));
+ }
}
- n = attrs == null ? 0 : attrs.size();
- for (i = 0; i < n; ++i) {
- cv.visitAttribute(attrs.get(i));
+ // Visit the non standard attributes.
+ if (attrs != null) {
+ for (int i = 0, n = attrs.size(); i < n; ++i) {
+ classVisitor.visitAttribute(attrs.get(i));
+ }
}
- // visits inner classes
- for (i = 0; i < innerClasses.size(); ++i) {
- innerClasses.get(i).accept(cv);
+ // Visit the inner classes.
+ for (int i = 0, n = innerClasses.size(); i < n; ++i) {
+ innerClasses.get(i).accept(classVisitor);
}
- // visits fields
- for (i = 0; i < fields.size(); ++i) {
- fields.get(i).accept(cv);
+ // Visit the fields.
+ for (int i = 0, n = fields.size(); i < n; ++i) {
+ fields.get(i).accept(classVisitor);
}
- // visits methods
- for (i = 0; i < methods.size(); ++i) {
- methods.get(i).accept(cv);
+ // Visit the methods.
+ for (int i = 0, n = methods.size(); i < n; ++i) {
+ methods.get(i).accept(classVisitor);
}
- // visits end
- cv.visitEnd();
+ classVisitor.visitEnd();
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/FieldInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/FieldInsnNode.java
index db979f5..cbf4ba2 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/FieldInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/FieldInsnNode.java
@@ -41,7 +41,7 @@
/**
* The internal name of the field's owner class (see {@link
- * org.objectweb.asm.Type#getInternalName() getInternalName}).
+ * org.objectweb.asm.Type#getInternalName}).
*/
public String owner;
@@ -57,15 +57,16 @@
* @param opcode the opcode of the type instruction to be constructed. This opcode must be
* GETSTATIC, PUTSTATIC, GETFIELD or PUTFIELD.
* @param owner the internal name of the field's owner class (see {@link
- * org.objectweb.asm.Type#getInternalName() getInternalName}).
+ * org.objectweb.asm.Type#getInternalName}).
* @param name the field's name.
- * @param desc the field's descriptor (see {@link org.objectweb.asm.Type}).
+ * @param descriptor the field's descriptor (see {@link org.objectweb.asm.Type}).
*/
- public FieldInsnNode(final int opcode, final String owner, final String name, final String desc) {
+ public FieldInsnNode(
+ final int opcode, final String owner, final String name, final String descriptor) {
super(opcode);
this.owner = owner;
this.name = name;
- this.desc = desc;
+ this.desc = descriptor;
}
/**
@@ -84,13 +85,13 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitFieldInsn(opcode, owner, name, desc);
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitFieldInsn(opcode, owner, name, desc);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
return new FieldInsnNode(opcode, owner, name, desc).cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java
index 05750f4..26ec3bc 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/FieldNode.java
@@ -66,34 +66,19 @@
*/
public Object value;
- /**
- * The runtime visible annotations of this field. This list is a list of {@link AnnotationNode}
- * objects. May be <tt>null</tt>.
- */
+ /** The runtime visible annotations of this field. May be <tt>null</tt>. */
public List<AnnotationNode> visibleAnnotations;
- /**
- * The runtime invisible annotations of this field. This list is a list of {@link AnnotationNode}
- * objects. May be <tt>null</tt>.
- */
+ /** The runtime invisible annotations of this field. May be <tt>null</tt>. */
public List<AnnotationNode> invisibleAnnotations;
- /**
- * The runtime visible type annotations of this field. This list is a list of {@link
- * TypeAnnotationNode} objects. May be <tt>null</tt>.
- */
+ /** The runtime visible type annotations of this field. May be <tt>null</tt>. */
public List<TypeAnnotationNode> visibleTypeAnnotations;
- /**
- * The runtime invisible type annotations of this field. This list is a list of {@link
- * TypeAnnotationNode} objects. May be <tt>null</tt>.
- */
+ /** The runtime invisible type annotations of this field. May be <tt>null</tt>. */
public List<TypeAnnotationNode> invisibleTypeAnnotations;
- /**
- * The non standard attributes of this field. This list is a list of {@link Attribute} objects.
- * May be <tt>null</tt>.
- */
+ /** The non standard attributes of this field. * May be <tt>null</tt>. */
public List<Attribute> attrs;
/**
@@ -103,7 +88,7 @@
* @param access the field's access flags (see {@link org.objectweb.asm.Opcodes}). This parameter
* also indicates if the field is synthetic and/or deprecated.
* @param name the field's name.
- * @param desc the field's descriptor (see {@link org.objectweb.asm.Type Type}).
+ * @param descriptor the field's descriptor (see {@link org.objectweb.asm.Type}).
* @param signature the field's signature.
* @param value the field's initial value. This parameter, which may be <tt>null</tt> if the field
* does not have an initial value, must be an {@link Integer}, a {@link Float}, a {@link
@@ -113,10 +98,10 @@
public FieldNode(
final int access,
final String name,
- final String desc,
+ final String descriptor,
final String signature,
final Object value) {
- this(Opcodes.ASM6, access, name, desc, signature, value);
+ this(Opcodes.ASM6, access, name, descriptor, signature, value);
if (getClass() != FieldNode.class) {
throw new IllegalStateException();
}
@@ -130,7 +115,7 @@
* @param access the field's access flags (see {@link org.objectweb.asm.Opcodes}). This parameter
* also indicates if the field is synthetic and/or deprecated.
* @param name the field's name.
- * @param desc the field's descriptor (see {@link org.objectweb.asm.Type Type}).
+ * @param descriptor the field's descriptor (see {@link org.objectweb.asm.Type}).
* @param signature the field's signature.
* @param value the field's initial value. This parameter, which may be <tt>null</tt> if the field
* does not have an initial value, must be an {@link Integer}, a {@link Float}, a {@link
@@ -140,86 +125,88 @@
final int api,
final int access,
final String name,
- final String desc,
+ final String descriptor,
final String signature,
final Object value) {
super(api);
this.access = access;
this.name = name;
- this.desc = desc;
+ this.desc = descriptor;
this.signature = signature;
this.value = value;
}
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
// Implementation of the FieldVisitor abstract class
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
@Override
- public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
- AnnotationNode an = new AnnotationNode(desc);
+ public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
+ AnnotationNode annotation = new AnnotationNode(descriptor);
if (visible) {
if (visibleAnnotations == null) {
visibleAnnotations = new ArrayList<AnnotationNode>(1);
}
- visibleAnnotations.add(an);
+ visibleAnnotations.add(annotation);
} else {
if (invisibleAnnotations == null) {
invisibleAnnotations = new ArrayList<AnnotationNode>(1);
}
- invisibleAnnotations.add(an);
+ invisibleAnnotations.add(annotation);
}
- return an;
+ return annotation;
}
@Override
public AnnotationVisitor visitTypeAnnotation(
- int typeRef, TypePath typePath, String desc, boolean visible) {
- TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc);
+ final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
+ TypeAnnotationNode typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor);
if (visible) {
if (visibleTypeAnnotations == null) {
visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
- visibleTypeAnnotations.add(an);
+ visibleTypeAnnotations.add(typeAnnotation);
} else {
if (invisibleTypeAnnotations == null) {
invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
- invisibleTypeAnnotations.add(an);
+ invisibleTypeAnnotations.add(typeAnnotation);
}
- return an;
+ return typeAnnotation;
}
@Override
- public void visitAttribute(final Attribute attr) {
+ public void visitAttribute(final Attribute attribute) {
if (attrs == null) {
attrs = new ArrayList<Attribute>(1);
}
- attrs.add(attr);
+ attrs.add(attribute);
}
@Override
- public void visitEnd() {}
+ public void visitEnd() {
+ // Nothing to do.
+ }
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
// Accept methods
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
/**
- * Checks that this field node is compatible with the given ASM API version. This methods checks
- * that this node, and all its nodes recursively, do not contain elements that were introduced in
- * more recent versions of the ASM API than the given version.
+ * Checks that this field node is compatible with the given ASM API version. This method 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} or
* {@link Opcodes#ASM6}.
*/
public void check(final int api) {
if (api == Opcodes.ASM4) {
- if (visibleTypeAnnotations != null && visibleTypeAnnotations.size() > 0) {
- throw new RuntimeException();
+ if (visibleTypeAnnotations != null && !visibleTypeAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
- if (invisibleTypeAnnotations != null && invisibleTypeAnnotations.size() > 0) {
- throw new RuntimeException();
+ if (invisibleTypeAnnotations != null && !invisibleTypeAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
}
}
@@ -227,38 +214,48 @@
/**
* Makes the given class visitor visit this field.
*
- * @param cv a class visitor.
+ * @param classVisitor a class visitor.
*/
- public void accept(final ClassVisitor cv) {
- FieldVisitor fv = cv.visitField(access, name, desc, signature, value);
- if (fv == null) {
+ public void accept(final ClassVisitor classVisitor) {
+ FieldVisitor fieldVisitor = classVisitor.visitField(access, name, desc, signature, value);
+ if (fieldVisitor == null) {
return;
}
- int i, n;
- n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
- for (i = 0; i < n; ++i) {
- AnnotationNode an = visibleAnnotations.get(i);
- an.accept(fv.visitAnnotation(an.desc, true));
+ // Visit the annotations.
+ if (visibleAnnotations != null) {
+ for (int i = 0, n = visibleAnnotations.size(); i < n; ++i) {
+ AnnotationNode annotation = visibleAnnotations.get(i);
+ annotation.accept(fieldVisitor.visitAnnotation(annotation.desc, true));
+ }
}
- n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
- for (i = 0; i < n; ++i) {
- AnnotationNode an = invisibleAnnotations.get(i);
- an.accept(fv.visitAnnotation(an.desc, false));
+ if (invisibleAnnotations != null) {
+ for (int i = 0, n = invisibleAnnotations.size(); i < n; ++i) {
+ AnnotationNode annotation = invisibleAnnotations.get(i);
+ annotation.accept(fieldVisitor.visitAnnotation(annotation.desc, false));
+ }
}
- n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size();
- for (i = 0; i < n; ++i) {
- TypeAnnotationNode an = visibleTypeAnnotations.get(i);
- an.accept(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, true));
+ if (visibleTypeAnnotations != null) {
+ for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode typeAnnotation = visibleTypeAnnotations.get(i);
+ typeAnnotation.accept(
+ fieldVisitor.visitTypeAnnotation(
+ typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, true));
+ }
}
- n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations.size();
- for (i = 0; i < n; ++i) {
- TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
- an.accept(fv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, false));
+ if (invisibleTypeAnnotations != null) {
+ for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode typeAnnotation = invisibleTypeAnnotations.get(i);
+ typeAnnotation.accept(
+ fieldVisitor.visitTypeAnnotation(
+ typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, false));
+ }
}
- n = attrs == null ? 0 : attrs.size();
- for (i = 0; i < n; ++i) {
- fv.visitAttribute(attrs.get(i));
+ // Visit the non standard attributes.
+ if (attrs != null) {
+ for (int i = 0, n = attrs.size(); i < n; ++i) {
+ fieldVisitor.visitAttribute(attrs.get(i));
+ }
}
- fv.visitEnd();
+ fieldVisitor.visitEnd();
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/FrameNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/FrameNode.java
index 3004f4d..27e6719 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/FrameNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/FrameNode.java
@@ -28,7 +28,6 @@
package org.objectweb.asm.tree;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -44,7 +43,7 @@
* elements <i>just before</i> <b>i</b> is executed. <br>
* <br>
* (*) this is mandatory only for classes whose version is greater than or equal to {@link
- * Opcodes#V1_6 V1_6}.
+ * Opcodes#V1_6}.
*
* @author Eric Bruneton
*/
@@ -101,20 +100,22 @@
switch (type) {
case Opcodes.F_NEW:
case Opcodes.F_FULL:
- this.local = asList(nLocal, local);
- this.stack = asList(nStack, stack);
+ this.local = Util.asArrayList(nLocal, local);
+ this.stack = Util.asArrayList(nStack, stack);
break;
case Opcodes.F_APPEND:
- this.local = asList(nLocal, local);
+ this.local = Util.asArrayList(nLocal, local);
break;
case Opcodes.F_CHOP:
- this.local = Arrays.asList(new Object[nLocal]);
+ this.local = Util.asArrayList(nLocal);
break;
case Opcodes.F_SAME:
break;
case Opcodes.F_SAME1:
- this.stack = asList(1, stack);
+ this.stack = Util.asArrayList(1, stack);
break;
+ default:
+ throw new IllegalArgumentException();
}
}
@@ -123,75 +124,66 @@
return FRAME;
}
- /**
- * Makes the given visitor visit this stack map frame.
- *
- * @param mv a method visitor.
- */
@Override
- public void accept(final MethodVisitor mv) {
+ public void accept(final MethodVisitor methodVisitor) {
switch (type) {
case Opcodes.F_NEW:
case Opcodes.F_FULL:
- mv.visitFrame(type, local.size(), asArray(local), stack.size(), asArray(stack));
+ methodVisitor.visitFrame(type, local.size(), asArray(local), stack.size(), asArray(stack));
break;
case Opcodes.F_APPEND:
- mv.visitFrame(type, local.size(), asArray(local), 0, null);
+ methodVisitor.visitFrame(type, local.size(), asArray(local), 0, null);
break;
case Opcodes.F_CHOP:
- mv.visitFrame(type, local.size(), null, 0, null);
+ methodVisitor.visitFrame(type, local.size(), null, 0, null);
break;
case Opcodes.F_SAME:
- mv.visitFrame(type, 0, null, 0, null);
+ methodVisitor.visitFrame(type, 0, null, 0, null);
break;
case Opcodes.F_SAME1:
- mv.visitFrame(type, 0, null, 1, asArray(stack));
+ methodVisitor.visitFrame(type, 0, null, 1, asArray(stack));
break;
+ default:
+ throw new IllegalArgumentException();
}
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
FrameNode clone = new FrameNode();
clone.type = type;
if (local != null) {
clone.local = new ArrayList<Object>();
- for (int i = 0; i < local.size(); ++i) {
- Object l = local.get(i);
- if (l instanceof LabelNode) {
- l = labels.get(l);
+ for (int i = 0, n = local.size(); i < n; ++i) {
+ Object localElement = local.get(i);
+ if (localElement instanceof LabelNode) {
+ localElement = clonedLabels.get(localElement);
}
- clone.local.add(l);
+ clone.local.add(localElement);
}
}
if (stack != null) {
clone.stack = new ArrayList<Object>();
- for (int i = 0; i < stack.size(); ++i) {
- Object s = stack.get(i);
- if (s instanceof LabelNode) {
- s = labels.get(s);
+ for (int i = 0, n = stack.size(); i < n; ++i) {
+ Object stackElement = stack.get(i);
+ if (stackElement instanceof LabelNode) {
+ stackElement = clonedLabels.get(stackElement);
}
- clone.stack.add(s);
+ clone.stack.add(stackElement);
}
}
return clone;
}
- // ------------------------------------------------------------------------
-
- private static List<Object> asList(final int n, final Object[] o) {
- return Arrays.asList(o).subList(0, n);
- }
-
- private static Object[] asArray(final List<Object> l) {
- Object[] objs = new Object[l.size()];
- for (int i = 0; i < objs.length; ++i) {
- Object o = l.get(i);
+ private static Object[] asArray(final List<Object> list) {
+ Object[] array = new Object[list.size()];
+ for (int i = 0, n = array.length; i < n; ++i) {
+ Object o = list.get(i);
if (o instanceof LabelNode) {
o = ((LabelNode) o).getLabel();
}
- objs[i] = o;
+ array[i] = o;
}
- return objs;
+ return array;
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/IincInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/IincInsnNode.java
index 1008d35..8f2ca6e 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/IincInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/IincInsnNode.java
@@ -63,13 +63,13 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitIincInsn(var, incr);
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitIincInsn(var, incr);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
return new IincInsnNode(var, incr).cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/InnerClassNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/InnerClassNode.java
index 3c19113..5516a3f 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/InnerClassNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/InnerClassNode.java
@@ -36,15 +36,12 @@
*/
public class InnerClassNode {
- /**
- * The internal name of an inner class (see {@link org.objectweb.asm.Type#getInternalName()
- * getInternalName}).
- */
+ /** The internal name of an inner class (see {@link org.objectweb.asm.Type#getInternalName()}). */
public String name;
/**
* The internal name of the class to which the inner class belongs (see {@link
- * org.objectweb.asm.Type#getInternalName() getInternalName}). May be <tt>null</tt>.
+ * org.objectweb.asm.Type#getInternalName()}). May be <tt>null</tt>.
*/
public String outerName;
@@ -61,9 +58,9 @@
* Constructs a new {@link InnerClassNode}.
*
* @param name the internal name of an inner class (see {@link
- * org.objectweb.asm.Type#getInternalName() getInternalName}).
+ * org.objectweb.asm.Type#getInternalName()}).
* @param outerName the internal name of the class to which the inner class belongs (see {@link
- * org.objectweb.asm.Type#getInternalName() getInternalName}). May be <tt>null</tt>.
+ * org.objectweb.asm.Type#getInternalName()}). May be <tt>null</tt>.
* @param innerName the (simple) name of the inner class inside its enclosing class. May be
* <tt>null</tt> for anonymous inner classes.
* @param access the access flags of the inner class as originally declared in the enclosing
@@ -80,9 +77,9 @@
/**
* Makes the given class visitor visit this inner class.
*
- * @param cv a class visitor.
+ * @param classVisitor a class visitor.
*/
- public void accept(final ClassVisitor cv) {
- cv.visitInnerClass(name, outerName, innerName, access);
+ public void accept(final ClassVisitor classVisitor) {
+ classVisitor.visitInnerClass(name, outerName, innerName, access);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/InsnList.java b/asm-tree/src/main/java/org/objectweb/asm/tree/InsnList.java
index 72223f2..14019f2 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/InsnList.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/InsnList.java
@@ -42,10 +42,10 @@
private int size;
/** The first instruction in this list. May be <tt>null</tt>. */
- private AbstractInsnNode first;
+ private AbstractInsnNode firstInsn;
/** The last instruction in this list. May be <tt>null</tt>. */
- private AbstractInsnNode last;
+ private AbstractInsnNode lastInsn;
/**
* A cache of the instructions of this list. This cache is used to improve the performance of the
@@ -68,7 +68,7 @@
* @return the first instruction in this list, or <tt>null</tt> if the list is empty.
*/
public AbstractInsnNode getFirst() {
- return first;
+ return firstInsn;
}
/**
@@ -77,13 +77,13 @@
* @return the last instruction in this list, or <tt>null</tt> if the list is empty.
*/
public AbstractInsnNode getLast() {
- return last;
+ return lastInsn;
}
/**
* Returns the instruction whose index is given. This method builds a cache of the instructions in
* this list to avoid scanning the whole list each time it is called. Once the cache is built,
- * this method run in constant time. This cache is invalidated by all the methods that modify the
+ * this method runs in constant time. This cache is invalidated by all the methods that modify the
* list.
*
* @param index the index of the instruction that must be returned.
@@ -105,15 +105,15 @@
* the instructions of this list until it finds the given instruction or reaches the end of the
* list.
*
- * @param insn an instruction.
+ * @param insnNode an instruction.
* @return <tt>true</tt> if the given instruction belongs to this list.
*/
- public boolean contains(final AbstractInsnNode insn) {
- AbstractInsnNode i = first;
- while (i != null && i != insn) {
- i = i.next;
+ public boolean contains(final AbstractInsnNode insnNode) {
+ AbstractInsnNode currentInsn = firstInsn;
+ while (currentInsn != null && currentInsn != insnNode) {
+ currentInsn = currentInsn.nextInsn;
}
- return i != null;
+ return currentInsn != null;
}
/**
@@ -122,28 +122,28 @@
* built, this method run in constant time. The cache is invalidated by all the methods that
* modify the list.
*
- * @param insn an instruction <i>of this list</i>.
+ * @param insnNode an instruction <i>of this list</i>.
* @return the index of the given instruction in this list. <i>The result of this method is
- * undefined if the given instruction does not belong to this list</i>. Use {@link #contains
- * contains} to test if an instruction belongs to an instruction list or not.
+ * undefined if the given instruction does not belong to this list</i>. Use {@link #contains }
+ * to test if an instruction belongs to an instruction list or not.
*/
- public int indexOf(final AbstractInsnNode insn) {
+ public int indexOf(final AbstractInsnNode insnNode) {
if (cache == null) {
cache = toArray();
}
- return insn.index;
+ return insnNode.index;
}
/**
- * Makes the given visitor visit all of the instructions in this list.
+ * Makes the given visitor visit all the instructions in this list.
*
- * @param mv the method visitor that must visit the instructions.
+ * @param methodVisitor the method visitor that must visit the instructions.
*/
- public void accept(final MethodVisitor mv) {
- AbstractInsnNode insn = first;
- while (insn != null) {
- insn.accept(mv);
- insn = insn.next;
+ public void accept(final MethodVisitor methodVisitor) {
+ AbstractInsnNode currentInsn = firstInsn;
+ while (currentInsn != null) {
+ currentInsn.accept(methodVisitor);
+ currentInsn = currentInsn.nextInsn;
}
}
@@ -159,364 +159,364 @@
/**
* Returns an iterator over the instructions in this list.
*
- * @param index index of instruction for the iterator to start at
+ * @param index index of instruction for the iterator to start at.
* @return an iterator over the instructions in this list.
*/
@SuppressWarnings("unchecked")
- public ListIterator<AbstractInsnNode> iterator(int index) {
+ public ListIterator<AbstractInsnNode> iterator(final int index) {
return new InsnListIterator(index);
}
/**
- * Returns an array containing all of the instructions in this list.
+ * Returns an array containing all the instructions in this list.
*
- * @return an array containing all of the instructions in this list.
+ * @return an array containing all the instructions in this list.
*/
public AbstractInsnNode[] toArray() {
- int i = 0;
- AbstractInsnNode elem = first;
- AbstractInsnNode[] insns = new AbstractInsnNode[size];
- while (elem != null) {
- insns[i] = elem;
- elem.index = i++;
- elem = elem.next;
+ int currentInsnIndex = 0;
+ AbstractInsnNode currentInsn = firstInsn;
+ AbstractInsnNode[] insnNodeArray = new AbstractInsnNode[size];
+ while (currentInsn != null) {
+ insnNodeArray[currentInsnIndex] = currentInsn;
+ currentInsn.index = currentInsnIndex++;
+ currentInsn = currentInsn.nextInsn;
}
- return insns;
+ return insnNodeArray;
}
/**
* Replaces an instruction of this list with another instruction.
*
- * @param location an instruction <i>of this list</i>.
- * @param insn another instruction, <i>which must not belong to any {@link InsnList}</i>.
+ * @param oldInsnNode an instruction <i>of this list</i>.
+ * @param newInsnNode another instruction, <i>which must not belong to any {@link InsnList}</i>.
*/
- public void set(final AbstractInsnNode location, final AbstractInsnNode insn) {
- AbstractInsnNode next = location.next;
- insn.next = next;
- if (next != null) {
- next.prev = insn;
+ public void set(final AbstractInsnNode oldInsnNode, final AbstractInsnNode newInsnNode) {
+ AbstractInsnNode nextInsn = oldInsnNode.nextInsn;
+ newInsnNode.nextInsn = nextInsn;
+ if (nextInsn != null) {
+ nextInsn.previousInsn = newInsnNode;
} else {
- last = insn;
+ lastInsn = newInsnNode;
}
- AbstractInsnNode prev = location.prev;
- insn.prev = prev;
- if (prev != null) {
- prev.next = insn;
+ AbstractInsnNode previousInsn = oldInsnNode.previousInsn;
+ newInsnNode.previousInsn = previousInsn;
+ if (previousInsn != null) {
+ previousInsn.nextInsn = newInsnNode;
} else {
- first = insn;
+ firstInsn = newInsnNode;
}
if (cache != null) {
- int index = location.index;
- cache[index] = insn;
- insn.index = index;
+ int index = oldInsnNode.index;
+ cache[index] = newInsnNode;
+ newInsnNode.index = index;
} else {
- insn.index = 0; // insn now belongs to an InsnList
+ newInsnNode.index = 0; // newInnsnNode now belongs to an InsnList.
}
- location.index = -1; // i no longer belongs to an InsnList
- location.prev = null;
- location.next = null;
+ oldInsnNode.index = -1; // oldInsnNode no longer belongs to an InsnList.
+ oldInsnNode.previousInsn = null;
+ oldInsnNode.nextInsn = null;
}
/**
* Adds the given instruction to the end of this list.
*
- * @param insn an instruction, <i>which must not belong to any {@link InsnList}</i>.
+ * @param insnNode an instruction, <i>which must not belong to any {@link InsnList}</i>.
*/
- public void add(final AbstractInsnNode insn) {
+ public void add(final AbstractInsnNode insnNode) {
++size;
- if (last == null) {
- first = insn;
- last = insn;
+ if (lastInsn == null) {
+ firstInsn = insnNode;
+ lastInsn = insnNode;
} else {
- last.next = insn;
- insn.prev = last;
+ lastInsn.nextInsn = insnNode;
+ insnNode.previousInsn = lastInsn;
}
- last = insn;
+ lastInsn = insnNode;
cache = null;
- insn.index = 0; // insn now belongs to an InsnList
+ insnNode.index = 0; // insnNode now belongs to an InsnList.
}
/**
* Adds the given instructions to the end of this list.
*
- * @param insns an instruction list, which is cleared during the process. This list must be
+ * @param insnList an instruction list, which is cleared during the process. This list must be
* different from 'this'.
*/
- public void add(final InsnList insns) {
- if (insns.size == 0) {
+ public void add(final InsnList insnList) {
+ if (insnList.size == 0) {
return;
}
- size += insns.size;
- if (last == null) {
- first = insns.first;
- last = insns.last;
+ size += insnList.size;
+ if (lastInsn == null) {
+ firstInsn = insnList.firstInsn;
+ lastInsn = insnList.lastInsn;
} else {
- AbstractInsnNode elem = insns.first;
- last.next = elem;
- elem.prev = last;
- last = insns.last;
+ AbstractInsnNode firstInsnListElement = insnList.firstInsn;
+ lastInsn.nextInsn = firstInsnListElement;
+ firstInsnListElement.previousInsn = lastInsn;
+ lastInsn = insnList.lastInsn;
}
cache = null;
- insns.removeAll(false);
+ insnList.removeAll(false);
}
/**
- * Inserts the given instruction at the begining of this list.
+ * Inserts the given instruction at the beginning of this list.
*
- * @param insn an instruction, <i>which must not belong to any {@link InsnList}</i>.
+ * @param insnNode an instruction, <i>which must not belong to any {@link InsnList}</i>.
*/
- public void insert(final AbstractInsnNode insn) {
+ public void insert(final AbstractInsnNode insnNode) {
++size;
- if (first == null) {
- first = insn;
- last = insn;
+ if (firstInsn == null) {
+ firstInsn = insnNode;
+ lastInsn = insnNode;
} else {
- first.prev = insn;
- insn.next = first;
+ firstInsn.previousInsn = insnNode;
+ insnNode.nextInsn = firstInsn;
}
- first = insn;
+ firstInsn = insnNode;
cache = null;
- insn.index = 0; // insn now belongs to an InsnList
+ insnNode.index = 0; // insnNode now belongs to an InsnList.
}
/**
- * Inserts the given instructions at the begining of this list.
+ * Inserts the given instructions at the beginning of this list.
*
- * @param insns an instruction list, which is cleared during the process. This list must be
+ * @param insnList an instruction list, which is cleared during the process. This list must be
* different from 'this'.
*/
- public void insert(final InsnList insns) {
- if (insns.size == 0) {
+ public void insert(final InsnList insnList) {
+ if (insnList.size == 0) {
return;
}
- size += insns.size;
- if (first == null) {
- first = insns.first;
- last = insns.last;
+ size += insnList.size;
+ if (firstInsn == null) {
+ firstInsn = insnList.firstInsn;
+ lastInsn = insnList.lastInsn;
} else {
- AbstractInsnNode elem = insns.last;
- first.prev = elem;
- elem.next = first;
- first = insns.first;
+ AbstractInsnNode lastInsnListElement = insnList.lastInsn;
+ firstInsn.previousInsn = lastInsnListElement;
+ lastInsnListElement.nextInsn = firstInsn;
+ firstInsn = insnList.firstInsn;
}
cache = null;
- insns.removeAll(false);
+ insnList.removeAll(false);
}
/**
* Inserts the given instruction after the specified instruction.
*
- * @param location an instruction <i>of this list</i> after which insn must be inserted.
- * @param insn the instruction to be inserted, <i>which must not belong to any {@link
+ * @param previousInsn an instruction <i>of this list</i> after which insnNode must be inserted.
+ * @param insnNode the instruction to be inserted, <i>which must not belong to any {@link
* InsnList}</i>.
*/
- public void insert(final AbstractInsnNode location, final AbstractInsnNode insn) {
+ public void insert(final AbstractInsnNode previousInsn, final AbstractInsnNode insnNode) {
++size;
- AbstractInsnNode next = location.next;
- if (next == null) {
- last = insn;
+ AbstractInsnNode nextInsn = previousInsn.nextInsn;
+ if (nextInsn == null) {
+ lastInsn = insnNode;
} else {
- next.prev = insn;
+ nextInsn.previousInsn = insnNode;
}
- location.next = insn;
- insn.next = next;
- insn.prev = location;
+ previousInsn.nextInsn = insnNode;
+ insnNode.nextInsn = nextInsn;
+ insnNode.previousInsn = previousInsn;
cache = null;
- insn.index = 0; // insn now belongs to an InsnList
+ insnNode.index = 0; // insnNode now belongs to an InsnList.
}
/**
* Inserts the given instructions after the specified instruction.
*
- * @param location an instruction <i>of this list</i> after which the instructions must be
+ * @param previousInsn an instruction <i>of this list</i> after which the instructions must be
* inserted.
- * @param insns the instruction list to be inserted, which is cleared during the process. This
+ * @param insnList the instruction list to be inserted, which is cleared during the process. This
* list must be different from 'this'.
*/
- public void insert(final AbstractInsnNode location, final InsnList insns) {
- if (insns.size == 0) {
+ public void insert(final AbstractInsnNode previousInsn, final InsnList insnList) {
+ if (insnList.size == 0) {
return;
}
- size += insns.size;
- AbstractInsnNode ifirst = insns.first;
- AbstractInsnNode ilast = insns.last;
- AbstractInsnNode next = location.next;
- if (next == null) {
- last = ilast;
+ size += insnList.size;
+ AbstractInsnNode firstInsnListElement = insnList.firstInsn;
+ AbstractInsnNode lastInsnListElement = insnList.lastInsn;
+ AbstractInsnNode nextInsn = previousInsn.nextInsn;
+ if (nextInsn == null) {
+ lastInsn = lastInsnListElement;
} else {
- next.prev = ilast;
+ nextInsn.previousInsn = lastInsnListElement;
}
- location.next = ifirst;
- ilast.next = next;
- ifirst.prev = location;
+ previousInsn.nextInsn = firstInsnListElement;
+ lastInsnListElement.nextInsn = nextInsn;
+ firstInsnListElement.previousInsn = previousInsn;
cache = null;
- insns.removeAll(false);
+ insnList.removeAll(false);
}
/**
* Inserts the given instruction before the specified instruction.
*
- * @param location an instruction <i>of this list</i> before which insn must be inserted.
- * @param insn the instruction to be inserted, <i>which must not belong to any {@link
+ * @param nextInsn an instruction <i>of this list</i> before which insnNode must be inserted.
+ * @param insnNode the instruction to be inserted, <i>which must not belong to any {@link
* InsnList}</i>.
*/
- public void insertBefore(final AbstractInsnNode location, final AbstractInsnNode insn) {
+ public void insertBefore(final AbstractInsnNode nextInsn, final AbstractInsnNode insnNode) {
++size;
- AbstractInsnNode prev = location.prev;
- if (prev == null) {
- first = insn;
+ AbstractInsnNode previousInsn = nextInsn.previousInsn;
+ if (previousInsn == null) {
+ firstInsn = insnNode;
} else {
- prev.next = insn;
+ previousInsn.nextInsn = insnNode;
}
- location.prev = insn;
- insn.next = location;
- insn.prev = prev;
+ nextInsn.previousInsn = insnNode;
+ insnNode.nextInsn = nextInsn;
+ insnNode.previousInsn = previousInsn;
cache = null;
- insn.index = 0; // insn now belongs to an InsnList
+ insnNode.index = 0; // insnNode now belongs to an InsnList.
}
/**
* Inserts the given instructions before the specified instruction.
*
- * @param location an instruction <i>of this list</i> before which the instructions must be
+ * @param nextInsn an instruction <i>of this list</i> before which the instructions must be
* inserted.
- * @param insns the instruction list to be inserted, which is cleared during the process. This
+ * @param insnList the instruction list to be inserted, which is cleared during the process. This
* list must be different from 'this'.
*/
- public void insertBefore(final AbstractInsnNode location, final InsnList insns) {
- if (insns.size == 0) {
+ public void insertBefore(final AbstractInsnNode nextInsn, final InsnList insnList) {
+ if (insnList.size == 0) {
return;
}
- size += insns.size;
- AbstractInsnNode ifirst = insns.first;
- AbstractInsnNode ilast = insns.last;
- AbstractInsnNode prev = location.prev;
- if (prev == null) {
- first = ifirst;
+ size += insnList.size;
+ AbstractInsnNode firstInsnListElement = insnList.firstInsn;
+ AbstractInsnNode lastInsnListElement = insnList.lastInsn;
+ AbstractInsnNode previousInsn = nextInsn.previousInsn;
+ if (previousInsn == null) {
+ firstInsn = firstInsnListElement;
} else {
- prev.next = ifirst;
+ previousInsn.nextInsn = firstInsnListElement;
}
- location.prev = ilast;
- ilast.next = location;
- ifirst.prev = prev;
+ nextInsn.previousInsn = lastInsnListElement;
+ lastInsnListElement.nextInsn = nextInsn;
+ firstInsnListElement.previousInsn = previousInsn;
cache = null;
- insns.removeAll(false);
+ insnList.removeAll(false);
}
/**
* Removes the given instruction from this list.
*
- * @param insn the instruction <i>of this list</i> that must be removed.
+ * @param insnNode the instruction <i>of this list</i> that must be removed.
*/
- public void remove(final AbstractInsnNode insn) {
+ public void remove(final AbstractInsnNode insnNode) {
--size;
- AbstractInsnNode next = insn.next;
- AbstractInsnNode prev = insn.prev;
- if (next == null) {
- if (prev == null) {
- first = null;
- last = null;
+ AbstractInsnNode nextInsn = insnNode.nextInsn;
+ AbstractInsnNode previousInsn = insnNode.previousInsn;
+ if (nextInsn == null) {
+ if (previousInsn == null) {
+ firstInsn = null;
+ lastInsn = null;
} else {
- prev.next = null;
- last = prev;
+ previousInsn.nextInsn = null;
+ lastInsn = previousInsn;
}
} else {
- if (prev == null) {
- first = next;
- next.prev = null;
+ if (previousInsn == null) {
+ firstInsn = nextInsn;
+ nextInsn.previousInsn = null;
} else {
- prev.next = next;
- next.prev = prev;
+ previousInsn.nextInsn = nextInsn;
+ nextInsn.previousInsn = previousInsn;
}
}
cache = null;
- insn.index = -1; // insn no longer belongs to an InsnList
- insn.prev = null;
- insn.next = null;
+ insnNode.index = -1; // insnNode no longer belongs to an InsnList.
+ insnNode.previousInsn = null;
+ insnNode.nextInsn = null;
}
/**
- * Removes all of the instructions of this list.
+ * Removes all the instructions of this list.
*
* @param mark if the instructions must be marked as no longer belonging to any {@link InsnList}.
*/
void removeAll(final boolean mark) {
if (mark) {
- AbstractInsnNode insn = first;
- while (insn != null) {
- AbstractInsnNode next = insn.next;
- insn.index = -1; // insn no longer belongs to an InsnList
- insn.prev = null;
- insn.next = null;
- insn = next;
+ AbstractInsnNode currentInsn = firstInsn;
+ while (currentInsn != null) {
+ AbstractInsnNode next = currentInsn.nextInsn;
+ currentInsn.index = -1; // currentInsn no longer belongs to an InsnList.
+ currentInsn.previousInsn = null;
+ currentInsn.nextInsn = null;
+ currentInsn = next;
}
}
size = 0;
- first = null;
- last = null;
+ firstInsn = null;
+ lastInsn = null;
cache = null;
}
- /** Removes all of the instructions of this list. */
+ /** Removes all the instructions of this list. */
public void clear() {
removeAll(false);
}
/**
- * Reset all labels in the instruction list. This method should be called before reusing same
- * instructions list between several <code>ClassWriter</code>s.
+ * Resets all the labels in the instruction list. This method should be called before reusing an
+ * instruction list between several <code>ClassWriter</code>s.
*/
public void resetLabels() {
- AbstractInsnNode insn = first;
- while (insn != null) {
- if (insn instanceof LabelNode) {
- ((LabelNode) insn).resetLabel();
+ AbstractInsnNode currentInsn = firstInsn;
+ while (currentInsn != null) {
+ if (currentInsn instanceof LabelNode) {
+ ((LabelNode) currentInsn).resetLabel();
}
- insn = insn.next;
+ currentInsn = currentInsn.nextInsn;
}
}
- // this class is not generified because it will create bridges
+ // Note: this class is not generified because it would create bridges.
@SuppressWarnings("rawtypes")
private final class InsnListIterator implements ListIterator {
- AbstractInsnNode next;
+ AbstractInsnNode nextInsn;
- AbstractInsnNode prev;
+ AbstractInsnNode previousInsn;
AbstractInsnNode remove;
- InsnListIterator(int index) {
+ InsnListIterator(final int index) {
if (index == size()) {
- next = null;
- prev = getLast();
+ nextInsn = null;
+ previousInsn = getLast();
} else {
- next = get(index);
- prev = next.prev;
+ nextInsn = get(index);
+ previousInsn = nextInsn.previousInsn;
}
}
public boolean hasNext() {
- return next != null;
+ return nextInsn != null;
}
public Object next() {
- if (next == null) {
+ if (nextInsn == null) {
throw new NoSuchElementException();
}
- AbstractInsnNode result = next;
- prev = result;
- next = result.next;
+ AbstractInsnNode result = nextInsn;
+ previousInsn = result;
+ nextInsn = result.nextInsn;
remove = result;
return result;
}
public void remove() {
if (remove != null) {
- if (remove == next) {
- next = next.next;
+ if (remove == nextInsn) {
+ nextInsn = nextInsn.nextInsn;
} else {
- prev = prev.prev;
+ previousInsn = previousInsn.previousInsn;
}
InsnList.this.remove(remove);
remove = null;
@@ -526,56 +526,56 @@
}
public boolean hasPrevious() {
- return prev != null;
+ return previousInsn != null;
}
public Object previous() {
- AbstractInsnNode result = prev;
- next = result;
- prev = result.prev;
+ AbstractInsnNode result = previousInsn;
+ nextInsn = result;
+ previousInsn = result.previousInsn;
remove = result;
return result;
}
public int nextIndex() {
- if (next == null) {
+ if (nextInsn == null) {
return size();
}
if (cache == null) {
cache = toArray();
}
- return next.index;
+ return nextInsn.index;
}
public int previousIndex() {
- if (prev == null) {
+ if (previousInsn == null) {
return -1;
}
if (cache == null) {
cache = toArray();
}
- return prev.index;
+ return previousInsn.index;
}
- public void add(Object o) {
- if (next != null) {
- InsnList.this.insertBefore(next, (AbstractInsnNode) o);
- } else if (prev != null) {
- InsnList.this.insert(prev, (AbstractInsnNode) o);
+ public void add(final Object o) {
+ if (nextInsn != null) {
+ InsnList.this.insertBefore(nextInsn, (AbstractInsnNode) o);
+ } else if (previousInsn != null) {
+ InsnList.this.insert(previousInsn, (AbstractInsnNode) o);
} else {
InsnList.this.add((AbstractInsnNode) o);
}
- prev = (AbstractInsnNode) o;
+ previousInsn = (AbstractInsnNode) o;
remove = null;
}
- public void set(Object o) {
+ public void set(final Object o) {
if (remove != null) {
InsnList.this.set(remove, (AbstractInsnNode) o);
- if (remove == prev) {
- prev = (AbstractInsnNode) o;
+ if (remove == previousInsn) {
+ previousInsn = (AbstractInsnNode) o;
} else {
- next = (AbstractInsnNode) o;
+ nextInsn = (AbstractInsnNode) o;
}
} else {
throw new IllegalStateException();
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/InsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/InsnNode.java
index dcf60ee..68dd3d9 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/InsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/InsnNode.java
@@ -61,19 +61,14 @@
return INSN;
}
- /**
- * Makes the given visitor visit this instruction.
- *
- * @param mv a method visitor.
- */
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitInsn(opcode);
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitInsn(opcode);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
return new InsnNode(opcode).cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/IntInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/IntInsnNode.java
index 1a456f1..9884dd3 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/IntInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/IntInsnNode.java
@@ -68,13 +68,13 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitIntInsn(opcode, operand);
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitIntInsn(opcode, operand);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
return new IntInsnNode(opcode, operand).cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/InvokeDynamicInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/InvokeDynamicInsnNode.java
index f0ed279..27bc891 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/InvokeDynamicInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/InvokeDynamicInsnNode.java
@@ -32,6 +32,7 @@
import org.objectweb.asm.Handle;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.Type;
/**
* A node that represents an invokedynamic instruction.
@@ -40,33 +41,39 @@
*/
public class InvokeDynamicInsnNode extends AbstractInsnNode {
- /** Invokedynamic name. */
+ /** The method's name. */
public String name;
- /** Invokedynamic descriptor. */
+ /** The method's descriptor (see {@link org.objectweb.asm.Type}). */
public String desc;
- /** Bootstrap method */
+ /** The bootstrap method. */
public Handle bsm;
- /** Bootstrap constant arguments */
+ /** The bootstrap method constant arguments. */
public Object[] bsmArgs;
/**
* Constructs a new {@link InvokeDynamicInsnNode}.
*
- * @param name invokedynamic name.
- * @param desc invokedynamic descriptor (see {@link org.objectweb.asm.Type}).
- * @param bsm the bootstrap method.
- * @param bsmArgs the boostrap constant arguments.
+ * @param name the method's name.
+ * @param descriptor the method's descriptor (see {@link Type Type}).
+ * @param bootstrapMethodHandle the bootstrap method.
+ * @param bootstrapMethodArguments the bootstrap method constant arguments. Each argument must be
+ * an {@link Integer}, {@link Float}, {@link Long}, {@link Double}, {@link String}, {@link
+ * Type} or {@link Handle} value. This method is allowed to modify the content of the array so
+ * a caller should expect that this array may change.
*/
public InvokeDynamicInsnNode(
- final String name, final String desc, final Handle bsm, final Object... bsmArgs) {
+ final String name,
+ final String descriptor,
+ final Handle bootstrapMethodHandle,
+ final Object... bootstrapMethodArguments) {
super(Opcodes.INVOKEDYNAMIC);
this.name = name;
- this.desc = desc;
- this.bsm = bsm;
- this.bsmArgs = bsmArgs;
+ this.desc = descriptor;
+ this.bsm = bootstrapMethodHandle;
+ this.bsmArgs = bootstrapMethodArguments;
}
@Override
@@ -75,13 +82,13 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitInvokeDynamicInsn(name, desc, bsm, bsmArgs);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
return new InvokeDynamicInsnNode(name, desc, bsm, bsmArgs).cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/JumpInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/JumpInsnNode.java
index 59cdfeb..33600fa 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/JumpInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/JumpInsnNode.java
@@ -76,13 +76,13 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitJumpInsn(opcode, label.getLabel());
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitJumpInsn(opcode, label.getLabel());
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
- return new JumpInsnNode(opcode, clone(label, labels)).cloneAnnotations(this);
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
+ return new JumpInsnNode(opcode, clone(label, clonedLabels)).cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/LabelNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/LabelNode.java
index 771f3b7..d48b5c3 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/LabelNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/LabelNode.java
@@ -35,7 +35,7 @@
/** An {@link AbstractInsnNode} that encapsulates a {@link Label}. */
public class LabelNode extends AbstractInsnNode {
- private Label label;
+ private Label value;
public LabelNode() {
super(-1);
@@ -43,7 +43,7 @@
public LabelNode(final Label label) {
super(-1);
- this.label = label;
+ this.value = label;
}
@Override
@@ -52,23 +52,23 @@
}
public Label getLabel() {
- if (label == null) {
- label = new Label();
+ if (value == null) {
+ value = new Label();
}
- return label;
+ return value;
}
@Override
- public void accept(final MethodVisitor cv) {
- cv.visitLabel(getLabel());
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitLabel(getLabel());
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
- return labels.get(this);
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
+ return clonedLabels.get(this);
}
public void resetLabel() {
- label = null;
+ value = null;
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/LdcInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/LdcInsnNode.java
index ab4f870..96c0dcd 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/LdcInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/LdcInsnNode.java
@@ -49,12 +49,12 @@
/**
* Constructs a new {@link LdcInsnNode}.
*
- * @param cst the constant to be loaded on the stack. This parameter must be a non null {@link
+ * @param value the constant to be loaded on the stack. This parameter must be a non null {@link
* Integer}, a {@link Float}, a {@link Long}, a {@link Double} or a {@link String}.
*/
- public LdcInsnNode(final Object cst) {
+ public LdcInsnNode(final Object value) {
super(Opcodes.LDC);
- this.cst = cst;
+ this.cst = value;
}
@Override
@@ -63,13 +63,13 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitLdcInsn(cst);
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitLdcInsn(cst);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
return new LdcInsnNode(cst).cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/LineNumberNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/LineNumberNode.java
index c88d2db..c30a95b 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/LineNumberNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/LineNumberNode.java
@@ -64,12 +64,12 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitLineNumber(line, start.getLabel());
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitLineNumber(line, start.getLabel());
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
- return new LineNumberNode(line, clone(start, labels));
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
+ return new LineNumberNode(line, clone(start, clonedLabels));
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java
index 761e6f5..a3c51ad 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableAnnotationNode.java
@@ -28,8 +28,6 @@
package org.objectweb.asm.tree;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.objectweb.asm.Label;
@@ -79,7 +77,7 @@
* this local variable (exclusive). This array must have the same size as the 'start' array.
* @param index the local variable's index in each range. This array must have the same size as
* the 'start' array.
- * @param desc the class descriptor of the annotation class.
+ * @param descriptor the class descriptor of the annotation class.
*/
public LocalVariableAnnotationNode(
int typeRef,
@@ -87,8 +85,8 @@
LabelNode[] start,
LabelNode[] end,
int[] index,
- String desc) {
- this(Opcodes.ASM6, typeRef, typePath, start, end, index, desc);
+ String descriptor) {
+ this(Opcodes.ASM6, typeRef, typePath, start, end, index, descriptor);
}
/**
@@ -106,7 +104,7 @@
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or
* static inner type within 'typeRef'. May be <tt>null</tt> if the annotation targets
* 'typeRef' as a whole.
- * @param desc the class descriptor of the annotation class.
+ * @param descriptor the class descriptor of the annotation class.
*/
public LocalVariableAnnotationNode(
int api,
@@ -115,33 +113,30 @@
LabelNode[] start,
LabelNode[] end,
int[] index,
- String desc) {
- super(api, typeRef, typePath, desc);
- this.start = new ArrayList<LabelNode>(start.length);
- this.start.addAll(Arrays.asList(start));
- this.end = new ArrayList<LabelNode>(end.length);
- this.end.addAll(Arrays.asList(end));
- this.index = new ArrayList<Integer>(index.length);
- for (int i : index) {
- this.index.add(i);
- }
+ String descriptor) {
+ super(api, typeRef, typePath, descriptor);
+ this.start = Util.asArrayList(start);
+ this.end = Util.asArrayList(end);
+ this.index = Util.asArrayList(index);
}
/**
* Makes the given visitor visit this type annotation.
*
- * @param mv the visitor that must visit this annotation.
+ * @param methodVisitor the visitor that must visit this annotation.
* @param visible <tt>true</tt> if the annotation is visible at runtime.
*/
- public void accept(final MethodVisitor mv, boolean visible) {
- Label[] start = new Label[this.start.size()];
- Label[] end = new Label[this.end.size()];
- int[] index = new int[this.index.size()];
- for (int i = 0; i < start.length; ++i) {
- start[i] = this.start.get(i).getLabel();
- end[i] = this.end.get(i).getLabel();
- index[i] = this.index.get(i);
+ public void accept(final MethodVisitor methodVisitor, boolean visible) {
+ Label[] startLabels = new Label[this.start.size()];
+ Label[] endLabels = new Label[this.end.size()];
+ int[] indices = new int[this.index.size()];
+ for (int i = 0, n = startLabels.length; i < n; ++i) {
+ startLabels[i] = this.start.get(i).getLabel();
+ endLabels[i] = this.end.get(i).getLabel();
+ indices[i] = this.index.get(i);
}
- accept(mv.visitLocalVariableAnnotation(typeRef, typePath, start, end, index, desc, visible));
+ accept(
+ methodVisitor.visitLocalVariableAnnotation(
+ typeRef, typePath, startLabels, endLabels, indices, desc, visible));
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableNode.java
index 7a09f0c..5579c5a 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/LocalVariableNode.java
@@ -58,7 +58,7 @@
* Constructs a new {@link LocalVariableNode}.
*
* @param name the name of a local variable.
- * @param desc the type descriptor of this local variable.
+ * @param descriptor the type descriptor of this local variable.
* @param signature the signature of this local variable. May be <tt>null</tt>.
* @param start the first instruction corresponding to the scope of this local variable
* (inclusive).
@@ -67,13 +67,13 @@
*/
public LocalVariableNode(
final String name,
- final String desc,
+ final String descriptor,
final String signature,
final LabelNode start,
final LabelNode end,
final int index) {
this.name = name;
- this.desc = desc;
+ this.desc = descriptor;
this.signature = signature;
this.start = start;
this.end = end;
@@ -83,9 +83,10 @@
/**
* Makes the given visitor visit this local variable declaration.
*
- * @param mv a method visitor.
+ * @param methodVisitor a method visitor.
*/
- public void accept(final MethodVisitor mv) {
- mv.visitLocalVariable(name, desc, signature, start.getLabel(), end.getLabel(), index);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitLocalVariable(
+ name, desc, signature, start.getLabel(), end.getLabel(), index);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/LookupSwitchInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/LookupSwitchInsnNode.java
index 059ba86..1dbc740 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/LookupSwitchInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/LookupSwitchInsnNode.java
@@ -27,8 +27,6 @@
// THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.tree;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -46,10 +44,10 @@
/** Beginning of the default handler block. */
public LabelNode dflt;
- /** The values of the keys. This list is a list of {@link Integer} objects. */
+ /** The values of the keys. */
public List<Integer> keys;
- /** Beginnings of the handler blocks. This list is a list of {@link LabelNode} objects. */
+ /** Beginnings of the handler blocks. */
public List<LabelNode> labels;
/**
@@ -63,16 +61,8 @@
public LookupSwitchInsnNode(final LabelNode dflt, final int[] keys, final LabelNode[] labels) {
super(Opcodes.LOOKUPSWITCH);
this.dflt = dflt;
- this.keys = new ArrayList<Integer>(keys == null ? 0 : keys.length);
- this.labels = new ArrayList<LabelNode>(labels == null ? 0 : labels.length);
- if (keys != null) {
- for (int i = 0; i < keys.length; ++i) {
- this.keys.add(keys[i]);
- }
- }
- if (labels != null) {
- this.labels.addAll(Arrays.asList(labels));
- }
+ this.keys = Util.asArrayList(keys);
+ this.labels = Util.asArrayList(labels);
}
@Override
@@ -81,23 +71,23 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- int[] keys = new int[this.keys.size()];
- for (int i = 0; i < keys.length; ++i) {
- keys[i] = this.keys.get(i).intValue();
+ public void accept(final MethodVisitor methodVisitor) {
+ int[] keysArray = new int[this.keys.size()];
+ for (int i = 0, n = keysArray.length; i < n; ++i) {
+ keysArray[i] = this.keys.get(i).intValue();
}
- Label[] labels = new Label[this.labels.size()];
- for (int i = 0; i < labels.length; ++i) {
- labels[i] = this.labels.get(i).getLabel();
+ Label[] labelsArray = new Label[this.labels.size()];
+ for (int i = 0, n = labelsArray.length; i < n; ++i) {
+ labelsArray[i] = this.labels.get(i).getLabel();
}
- mv.visitLookupSwitchInsn(dflt.getLabel(), keys, labels);
- acceptAnnotations(mv);
+ methodVisitor.visitLookupSwitchInsn(dflt.getLabel(), keysArray, labelsArray);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
LookupSwitchInsnNode clone =
- new LookupSwitchInsnNode(clone(dflt, labels), null, clone(this.labels, labels));
+ new LookupSwitchInsnNode(clone(dflt, clonedLabels), null, clone(labels, clonedLabels));
clone.keys.addAll(keys);
return clone.cloneAnnotations(this);
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/MethodInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/MethodInsnNode.java
index 66ef71a..afb1051 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/MethodInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/MethodInsnNode.java
@@ -42,7 +42,7 @@
/**
* The internal name of the method's owner class (see {@link
- * org.objectweb.asm.Type#getInternalName() getInternalName}).
+ * org.objectweb.asm.Type#getInternalName()}).
*/
public String owner;
@@ -52,7 +52,7 @@
/** The method's descriptor (see {@link org.objectweb.asm.Type}). */
public String desc;
- /** If the method's owner class if an interface. */
+ /** Whether the method's owner class if an interface. */
public boolean itf;
/**
@@ -61,14 +61,15 @@
* @param opcode the opcode of the type instruction to be constructed. This opcode must be
* INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.
* @param owner the internal name of the method's owner class (see {@link
- * org.objectweb.asm.Type#getInternalName() getInternalName}).
+ * org.objectweb.asm.Type#getInternalName()}).
* @param name the method's name.
- * @param desc the method's descriptor (see {@link org.objectweb.asm.Type}).
+ * @param descriptor the method's descriptor (see {@link org.objectweb.asm.Type}).
+ * @deprecated
*/
@Deprecated
public MethodInsnNode(
- final int opcode, final String owner, final String name, final String desc) {
- this(opcode, owner, name, desc, opcode == Opcodes.INVOKEINTERFACE);
+ final int opcode, final String owner, final String name, final String descriptor) {
+ this(opcode, owner, name, descriptor, opcode == Opcodes.INVOKEINTERFACE);
}
/**
@@ -77,22 +78,22 @@
* @param opcode the opcode of the type instruction to be constructed. This opcode must be
* INVOKEVIRTUAL, INVOKESPECIAL, INVOKESTATIC or INVOKEINTERFACE.
* @param owner the internal name of the method's owner class (see {@link
- * org.objectweb.asm.Type#getInternalName() getInternalName}).
+ * org.objectweb.asm.Type#getInternalName()}).
* @param name the method's name.
- * @param desc the method's descriptor (see {@link org.objectweb.asm.Type}).
- * @param itf if the method's owner class is an interface.
+ * @param descriptor the method's descriptor (see {@link org.objectweb.asm.Type}).
+ * @param isInterface if the method's owner class is an interface.
*/
public MethodInsnNode(
final int opcode,
final String owner,
final String name,
- final String desc,
- final boolean itf) {
+ final String descriptor,
+ final boolean isInterface) {
super(opcode);
this.owner = owner;
this.name = name;
- this.desc = desc;
- this.itf = itf;
+ this.desc = descriptor;
+ this.itf = isInterface;
}
/**
@@ -111,13 +112,13 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitMethodInsn(opcode, owner, name, desc, itf);
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitMethodInsn(opcode, owner, name, desc, itf);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
- return new MethodInsnNode(opcode, owner, name, desc, itf);
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
+ return new MethodInsnNode(opcode, owner, name, desc, itf).cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java
index 490ec60..00b7010 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/MethodNode.java
@@ -28,7 +28,6 @@
package org.objectweb.asm.tree;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import org.objectweb.asm.AnnotationVisitor;
@@ -63,43 +62,25 @@
/** The method's signature. May be <tt>null</tt>. */
public String signature;
- /**
- * The internal names of the method's exception classes (see {@link Type#getInternalName()
- * getInternalName}). This list is a list of {@link String} objects.
- */
+ /** The internal names of the method's exception classes (see {@link Type#getInternalName()}). */
public List<String> exceptions;
/** The method parameter info (access flags and name) */
public List<ParameterNode> parameters;
- /**
- * The runtime visible annotations of this method. This list is a list of {@link AnnotationNode}
- * objects. May be <tt>null</tt>.
- */
+ /** The runtime visible annotations of this method. May be <tt>null</tt>. */
public List<AnnotationNode> visibleAnnotations;
- /**
- * The runtime invisible annotations of this method. This list is a list of {@link AnnotationNode}
- * objects. May be <tt>null</tt>.
- */
+ /** The runtime invisible annotations of this method. May be <tt>null</tt>. */
public List<AnnotationNode> invisibleAnnotations;
- /**
- * The runtime visible type annotations of this method. This list is a list of {@link
- * TypeAnnotationNode} objects. May be <tt>null</tt>.
- */
+ /** The runtime visible type annotations of this method. May be <tt>null</tt>. */
public List<TypeAnnotationNode> visibleTypeAnnotations;
- /**
- * The runtime invisible type annotations of this method. This list is a list of {@link
- * TypeAnnotationNode} objects. May be <tt>null</tt>.
- */
+ /** The runtime invisible type annotations of this method. May be <tt>null</tt>. */
public List<TypeAnnotationNode> invisibleTypeAnnotations;
- /**
- * The non standard attributes of this method. This list is a list of {@link Attribute} objects.
- * May be <tt>null</tt>.
- */
+ /** The non standard attributes of this method. May be <tt>null</tt>. */
public List<Attribute> attrs;
/**
@@ -143,14 +124,10 @@
*/
public List<AnnotationNode>[] invisibleParameterAnnotations;
- /**
- * The instructions of this method. This list is a list of {@link AbstractInsnNode} objects.
- */
+ /** The instructions of this method. */
public InsnList instructions;
- /**
- * The try catch blocks of this method. This list is a list of {@link TryCatchBlockNode} objects.
- */
+ /** The try catch blocks of this method. */
public List<TryCatchBlockNode> tryCatchBlocks;
/** The maximum stack size of this method. */
@@ -159,25 +136,16 @@
/** The maximum number of local variables of this method. */
public int maxLocals;
- /**
- * The local variables of this method. This list is a list of {@link LocalVariableNode} objects.
- * May be <tt>null</tt>
- */
+ /** The local variables of this method. May be <tt>null</tt> */
public List<LocalVariableNode> localVariables;
- /**
- * The visible local variable annotations of this method. This list is a list of {@link
- * LocalVariableAnnotationNode} objects. May be <tt>null</tt>
- */
+ /** The visible local variable annotations of this method. May be <tt>null</tt> */
public List<LocalVariableAnnotationNode> visibleLocalVariableAnnotations;
- /**
- * The invisible local variable annotations of this method. This list is a list of {@link
- * LocalVariableAnnotationNode} objects. May be <tt>null</tt>
- */
+ /** The invisible local variable annotations of this method. May be <tt>null</tt> */
public List<LocalVariableAnnotationNode> invisibleLocalVariableAnnotations;
- /** If the accept method has been called on this object. */
+ /** Whether the accept method has been called on this object. */
private boolean visited;
/**
@@ -211,19 +179,19 @@
* @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.
- * @param desc the method's descriptor (see {@link Type}).
+ * @param descriptor the method's descriptor (see {@link Type}).
* @param signature the method's signature. May be <tt>null</tt>.
* @param exceptions the internal names of the method's exception classes (see {@link
- * Type#getInternalName() getInternalName}). May be <tt>null</tt>.
+ * Type#getInternalName()}). May be <tt>null</tt>.
* @throws IllegalStateException If a subclass calls this constructor.
*/
public MethodNode(
final int access,
final String name,
- final String desc,
+ final String descriptor,
final String signature,
final String[] exceptions) {
- this(Opcodes.ASM6, access, name, desc, signature, exceptions);
+ this(Opcodes.ASM6, access, name, descriptor, signature, exceptions);
if (getClass() != MethodNode.class) {
throw new IllegalStateException();
}
@@ -237,41 +205,37 @@
* @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.
- * @param desc the method's descriptor (see {@link Type}).
+ * @param descriptor the method's descriptor (see {@link Type}).
* @param signature the method's signature. May be <tt>null</tt>.
* @param exceptions the internal names of the method's exception classes (see {@link
- * Type#getInternalName() getInternalName}). May be <tt>null</tt>.
+ * Type#getInternalName()}). May be <tt>null</tt>.
*/
public MethodNode(
final int api,
final int access,
final String name,
- final String desc,
+ final String descriptor,
final String signature,
final String[] exceptions) {
super(api);
this.access = access;
this.name = name;
- this.desc = desc;
+ this.desc = descriptor;
this.signature = signature;
- this.exceptions = new ArrayList<String>(exceptions == null ? 0 : exceptions.length);
- boolean isAbstract = (access & Opcodes.ACC_ABSTRACT) != 0;
- if (!isAbstract) {
+ this.exceptions = Util.asArrayList(exceptions);
+ if ((access & Opcodes.ACC_ABSTRACT) == 0) {
this.localVariables = new ArrayList<LocalVariableNode>(5);
}
this.tryCatchBlocks = new ArrayList<TryCatchBlockNode>();
- if (exceptions != null) {
- this.exceptions.addAll(Arrays.asList(exceptions));
- }
this.instructions = new InsnList();
}
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
// Implementation of the MethodVisitor abstract class
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
@Override
- public void visitParameter(String name, int access) {
+ public void visitParameter(final String name, final int access) {
if (parameters == null) {
parameters = new ArrayList<ParameterNode>(5);
}
@@ -292,38 +256,38 @@
}
@Override
- public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) {
- AnnotationNode an = new AnnotationNode(desc);
+ public AnnotationVisitor visitAnnotation(final String descriptor, final boolean visible) {
+ AnnotationNode annotation = new AnnotationNode(descriptor);
if (visible) {
if (visibleAnnotations == null) {
visibleAnnotations = new ArrayList<AnnotationNode>(1);
}
- visibleAnnotations.add(an);
+ visibleAnnotations.add(annotation);
} else {
if (invisibleAnnotations == null) {
invisibleAnnotations = new ArrayList<AnnotationNode>(1);
}
- invisibleAnnotations.add(an);
+ invisibleAnnotations.add(annotation);
}
- return an;
+ return annotation;
}
@Override
public AnnotationVisitor visitTypeAnnotation(
- int typeRef, TypePath typePath, String desc, boolean visible) {
- TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc);
+ int typeRef, TypePath typePath, String descriptor, boolean visible) {
+ TypeAnnotationNode typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor);
if (visible) {
if (visibleTypeAnnotations == null) {
visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
- visibleTypeAnnotations.add(an);
+ visibleTypeAnnotations.add(typeAnnotation);
} else {
if (invisibleTypeAnnotations == null) {
invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
- invisibleTypeAnnotations.add(an);
+ invisibleTypeAnnotations.add(typeAnnotation);
}
- return an;
+ return typeAnnotation;
}
@Override
@@ -338,8 +302,8 @@
@Override
@SuppressWarnings("unchecked")
public AnnotationVisitor visitParameterAnnotation(
- final int parameter, final String desc, final boolean visible) {
- AnnotationNode an = new AnnotationNode(desc);
+ final int parameter, final String descriptor, final boolean visible) {
+ AnnotationNode annotation = new AnnotationNode(descriptor);
if (visible) {
if (visibleParameterAnnotations == null) {
int params = Type.getArgumentTypes(this.desc).length;
@@ -348,7 +312,7 @@
if (visibleParameterAnnotations[parameter] == null) {
visibleParameterAnnotations[parameter] = new ArrayList<AnnotationNode>(1);
}
- visibleParameterAnnotations[parameter].add(an);
+ visibleParameterAnnotations[parameter].add(annotation);
} else {
if (invisibleParameterAnnotations == null) {
int params = Type.getArgumentTypes(this.desc).length;
@@ -357,21 +321,23 @@
if (invisibleParameterAnnotations[parameter] == null) {
invisibleParameterAnnotations[parameter] = new ArrayList<AnnotationNode>(1);
}
- invisibleParameterAnnotations[parameter].add(an);
+ invisibleParameterAnnotations[parameter].add(annotation);
}
- return an;
+ return annotation;
}
@Override
- public void visitAttribute(final Attribute attr) {
+ public void visitAttribute(final Attribute attribute) {
if (attrs == null) {
attrs = new ArrayList<Attribute>(1);
}
- attrs.add(attr);
+ attrs.add(attribute);
}
@Override
- public void visitCode() {}
+ public void visitCode() {
+ // Nothing to do.
+ }
@Override
public void visitFrame(
@@ -411,32 +377,45 @@
@Override
public void visitFieldInsn(
- final int opcode, final String owner, final String name, final String desc) {
- instructions.add(new FieldInsnNode(opcode, owner, name, desc));
+ final int opcode, final String owner, final String name, final String descriptor) {
+ instructions.add(new FieldInsnNode(opcode, owner, name, descriptor));
}
+ /** @deprecated */
@Deprecated
@Override
- public void visitMethodInsn(int opcode, String owner, String name, String desc) {
+ public void visitMethodInsn(
+ final int opcode, final String owner, final String name, final String descriptor) {
if (api >= Opcodes.ASM5) {
- super.visitMethodInsn(opcode, owner, name, desc);
+ super.visitMethodInsn(opcode, owner, name, descriptor);
return;
}
- instructions.add(new MethodInsnNode(opcode, owner, name, desc));
+ instructions.add(new MethodInsnNode(opcode, owner, name, descriptor));
}
@Override
- public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
+ public void visitMethodInsn(
+ final int opcode,
+ final String owner,
+ final String name,
+ final String descriptor,
+ final boolean isInterface) {
if (api < Opcodes.ASM5) {
- super.visitMethodInsn(opcode, owner, name, desc, itf);
+ super.visitMethodInsn(opcode, owner, name, descriptor, isInterface);
return;
}
- instructions.add(new MethodInsnNode(opcode, owner, name, desc, itf));
+ instructions.add(new MethodInsnNode(opcode, owner, name, descriptor, isInterface));
}
@Override
- public void visitInvokeDynamicInsn(String name, String desc, Handle bsm, Object... bsmArgs) {
- instructions.add(new InvokeDynamicInsnNode(name, desc, bsm, bsmArgs));
+ public void visitInvokeDynamicInsn(
+ final String name,
+ final String descriptor,
+ final Handle bootstrapMethodHandle,
+ final Object... bootstrapMethodArguments) {
+ instructions.add(
+ new InvokeDynamicInsnNode(
+ name, descriptor, bootstrapMethodHandle, bootstrapMethodArguments));
}
@Override
@@ -450,8 +429,8 @@
}
@Override
- public void visitLdcInsn(final Object cst) {
- instructions.add(new LdcInsnNode(cst));
+ public void visitLdcInsn(final Object value) {
+ instructions.add(new LdcInsnNode(value));
}
@Override
@@ -471,33 +450,32 @@
}
@Override
- public void visitMultiANewArrayInsn(final String desc, final int dims) {
- instructions.add(new MultiANewArrayInsnNode(desc, dims));
+ public void visitMultiANewArrayInsn(final String descriptor, final int numDimensions) {
+ instructions.add(new MultiANewArrayInsnNode(descriptor, numDimensions));
}
@Override
public AnnotationVisitor visitInsnAnnotation(
- int typeRef, TypePath typePath, String desc, boolean visible) {
- // Finds the last real instruction, i.e. the instruction targeted by
- // this annotation.
- AbstractInsnNode insn = instructions.getLast();
- while (insn.getOpcode() == -1) {
- insn = insn.getPrevious();
+ final int typeRef, final TypePath typePath, final String descriptor, final boolean visible) {
+ // Find the last real instruction, i.e. the instruction targeted by this annotation.
+ AbstractInsnNode currentInsn = instructions.getLast();
+ while (currentInsn.getOpcode() == -1) {
+ currentInsn = currentInsn.getPrevious();
}
- // Adds the annotation to this instruction.
- TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc);
+ // Add the annotation to this instruction.
+ TypeAnnotationNode typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor);
if (visible) {
- if (insn.visibleTypeAnnotations == null) {
- insn.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
+ if (currentInsn.visibleTypeAnnotations == null) {
+ currentInsn.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
- insn.visibleTypeAnnotations.add(an);
+ currentInsn.visibleTypeAnnotations.add(typeAnnotation);
} else {
- if (insn.invisibleTypeAnnotations == null) {
- insn.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
+ if (currentInsn.invisibleTypeAnnotations == null) {
+ currentInsn.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
- insn.invisibleTypeAnnotations.add(an);
+ currentInsn.invisibleTypeAnnotations.add(typeAnnotation);
}
- return an;
+ return typeAnnotation;
}
@Override
@@ -509,60 +487,60 @@
@Override
public AnnotationVisitor visitTryCatchAnnotation(
- int typeRef, TypePath typePath, String desc, boolean visible) {
- TryCatchBlockNode tcb = tryCatchBlocks.get((typeRef & 0x00FFFF00) >> 8);
- TypeAnnotationNode an = new TypeAnnotationNode(typeRef, typePath, desc);
+ int typeRef, TypePath typePath, String descriptor, boolean visible) {
+ TryCatchBlockNode tryCatchBlock = tryCatchBlocks.get((typeRef & 0x00FFFF00) >> 8);
+ TypeAnnotationNode typeAnnotation = new TypeAnnotationNode(typeRef, typePath, descriptor);
if (visible) {
- if (tcb.visibleTypeAnnotations == null) {
- tcb.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
+ if (tryCatchBlock.visibleTypeAnnotations == null) {
+ tryCatchBlock.visibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
- tcb.visibleTypeAnnotations.add(an);
+ tryCatchBlock.visibleTypeAnnotations.add(typeAnnotation);
} else {
- if (tcb.invisibleTypeAnnotations == null) {
- tcb.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
+ if (tryCatchBlock.invisibleTypeAnnotations == null) {
+ tryCatchBlock.invisibleTypeAnnotations = new ArrayList<TypeAnnotationNode>(1);
}
- tcb.invisibleTypeAnnotations.add(an);
+ tryCatchBlock.invisibleTypeAnnotations.add(typeAnnotation);
}
- return an;
+ return typeAnnotation;
}
@Override
public void visitLocalVariable(
final String name,
- final String desc,
+ final String descriptor,
final String signature,
final Label start,
final Label end,
final int index) {
localVariables.add(
new LocalVariableNode(
- name, desc, signature, getLabelNode(start), getLabelNode(end), index));
+ name, descriptor, signature, getLabelNode(start), getLabelNode(end), index));
}
@Override
public AnnotationVisitor visitLocalVariableAnnotation(
- int typeRef,
- TypePath typePath,
- Label[] start,
- Label[] end,
- int[] index,
- String desc,
- boolean visible) {
- LocalVariableAnnotationNode an =
+ final int typeRef,
+ final TypePath typePath,
+ final Label[] start,
+ final Label[] end,
+ final int[] index,
+ final String descriptor,
+ final boolean visible) {
+ LocalVariableAnnotationNode localVariableAnnotation =
new LocalVariableAnnotationNode(
- typeRef, typePath, getLabelNodes(start), getLabelNodes(end), index, desc);
+ typeRef, typePath, getLabelNodes(start), getLabelNodes(end), index, descriptor);
if (visible) {
if (visibleLocalVariableAnnotations == null) {
visibleLocalVariableAnnotations = new ArrayList<LocalVariableAnnotationNode>(1);
}
- visibleLocalVariableAnnotations.add(an);
+ visibleLocalVariableAnnotations.add(localVariableAnnotation);
} else {
if (invisibleLocalVariableAnnotations == null) {
invisibleLocalVariableAnnotations = new ArrayList<LocalVariableAnnotationNode>(1);
}
- invisibleLocalVariableAnnotations.add(an);
+ invisibleLocalVariableAnnotations.add(localVariableAnnotation);
}
- return an;
+ return localVariableAnnotation;
}
@Override
@@ -577,97 +555,102 @@
}
@Override
- public void visitEnd() {}
+ public void visitEnd() {
+ // Nothing to do.
+ }
/**
* Returns the LabelNode corresponding to the given Label. Creates a new LabelNode if necessary.
* The default implementation of this method uses the {@link Label#info} field to store
* associations between labels and label nodes.
*
- * @param l a Label.
- * @return the LabelNode corresponding to l.
+ * @param label a Label.
+ * @return the LabelNode corresponding to label.
*/
- protected LabelNode getLabelNode(final Label l) {
- if (!(l.info instanceof LabelNode)) {
- l.info = new LabelNode();
+ protected LabelNode getLabelNode(final Label label) {
+ if (!(label.info instanceof LabelNode)) {
+ label.info = new LabelNode();
}
- return (LabelNode) l.info;
+ return (LabelNode) label.info;
}
- private LabelNode[] getLabelNodes(final Label[] l) {
- LabelNode[] nodes = new LabelNode[l.length];
- for (int i = 0; i < l.length; ++i) {
- nodes[i] = getLabelNode(l[i]);
+ private LabelNode[] getLabelNodes(final Label[] labels) {
+ LabelNode[] labelNodes = new LabelNode[labels.length];
+ for (int i = 0, n = labels.length; i < n; ++i) {
+ labelNodes[i] = getLabelNode(labels[i]);
}
- return nodes;
+ return labelNodes;
}
- private Object[] getLabelNodes(final Object[] objs) {
- Object[] nodes = new Object[objs.length];
- for (int i = 0; i < objs.length; ++i) {
- Object o = objs[i];
+ private Object[] getLabelNodes(final Object[] objects) {
+ Object[] labelNodes = new Object[objects.length];
+ for (int i = 0, n = objects.length; i < n; ++i) {
+ Object o = objects[i];
if (o instanceof Label) {
o = getLabelNode((Label) o);
}
- nodes[i] = o;
+ labelNodes[i] = o;
}
- return nodes;
+ return labelNodes;
}
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
// Accept method
- // ------------------------------------------------------------------------
+ // -----------------------------------------------------------------------------------------------
/**
- * Checks that this method node is compatible with the given ASM API version. This methods checks
- * that this node, and all its nodes recursively, do not contain elements that were introduced in
- * more recent versions of the ASM API than the given version.
+ * Checks that this method node is compatible with the given ASM API version. This method 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} or
* {@link Opcodes#ASM6}.
*/
public void check(final int api) {
if (api == Opcodes.ASM4) {
- if (parameters != null && parameters.size() > 0) {
- throw new RuntimeException();
+ if (parameters != null && !parameters.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
- if (visibleTypeAnnotations != null && visibleTypeAnnotations.size() > 0) {
- throw new RuntimeException();
+ if (visibleTypeAnnotations != null && !visibleTypeAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
- if (invisibleTypeAnnotations != null && invisibleTypeAnnotations.size() > 0) {
- throw new RuntimeException();
+ if (invisibleTypeAnnotations != null && !invisibleTypeAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
- int n = tryCatchBlocks == null ? 0 : tryCatchBlocks.size();
- for (int i = 0; i < n; ++i) {
- TryCatchBlockNode tcb = tryCatchBlocks.get(i);
- if (tcb.visibleTypeAnnotations != null && tcb.visibleTypeAnnotations.size() > 0) {
- throw new RuntimeException();
- }
- if (tcb.invisibleTypeAnnotations != null && tcb.invisibleTypeAnnotations.size() > 0) {
- throw new RuntimeException();
+ if (tryCatchBlocks != null) {
+ for (int i = tryCatchBlocks.size() - 1; i >= 0; --i) {
+ TryCatchBlockNode tryCatchBlock = tryCatchBlocks.get(i);
+ if (tryCatchBlock.visibleTypeAnnotations != null
+ && !tryCatchBlock.visibleTypeAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
+ }
+ if (tryCatchBlock.invisibleTypeAnnotations != null
+ && !tryCatchBlock.invisibleTypeAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
+ }
}
}
- for (int i = 0; i < instructions.size(); ++i) {
+ for (int i = instructions.size() - 1; i >= 0; --i) {
AbstractInsnNode insn = instructions.get(i);
- if (insn.visibleTypeAnnotations != null && insn.visibleTypeAnnotations.size() > 0) {
- throw new RuntimeException();
+ if (insn.visibleTypeAnnotations != null && !insn.visibleTypeAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
- if (insn.invisibleTypeAnnotations != null && insn.invisibleTypeAnnotations.size() > 0) {
- throw new RuntimeException();
+ if (insn.invisibleTypeAnnotations != null && !insn.invisibleTypeAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
if (insn instanceof MethodInsnNode) {
boolean itf = ((MethodInsnNode) insn).itf;
if (itf != (insn.opcode == Opcodes.INVOKEINTERFACE)) {
- throw new RuntimeException();
+ throw new UnsupportedClassVersionException();
}
}
}
- if (visibleLocalVariableAnnotations != null && visibleLocalVariableAnnotations.size() > 0) {
- throw new RuntimeException();
+ if (visibleLocalVariableAnnotations != null && !visibleLocalVariableAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
if (invisibleLocalVariableAnnotations != null
- && invisibleLocalVariableAnnotations.size() > 0) {
- throw new RuntimeException();
+ && !invisibleLocalVariableAnnotations.isEmpty()) {
+ throw new UnsupportedClassVersionException();
}
}
}
@@ -675,122 +658,138 @@
/**
* Makes the given class visitor visit this method.
*
- * @param cv a class visitor.
+ * @param classVisitor a class visitor.
*/
- public void accept(final ClassVisitor cv) {
- String[] exceptions = new String[this.exceptions.size()];
- this.exceptions.toArray(exceptions);
- MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
- if (mv != null) {
- accept(mv);
+ public void accept(final ClassVisitor classVisitor) {
+ String[] exceptionsArray = new String[this.exceptions.size()];
+ this.exceptions.toArray(exceptionsArray);
+ MethodVisitor methodVisitor =
+ classVisitor.visitMethod(access, name, desc, signature, exceptionsArray);
+ if (methodVisitor != null) {
+ accept(methodVisitor);
}
}
/**
* Makes the given method visitor visit this method.
*
- * @param mv a method visitor.
+ * @param methodVisitor a method visitor.
*/
- public void accept(final MethodVisitor mv) {
- // visits the method parameters
- int i, j, n;
- n = parameters == null ? 0 : parameters.size();
- for (i = 0; i < n; i++) {
- ParameterNode parameter = parameters.get(i);
- mv.visitParameter(parameter.name, parameter.access);
- }
- // visits the method attributes
- if (annotationDefault != null) {
- AnnotationVisitor av = mv.visitAnnotationDefault();
- AnnotationNode.accept(av, null, annotationDefault);
- if (av != null) {
- av.visitEnd();
+ public void accept(final MethodVisitor methodVisitor) {
+ // Visit the parameters.
+ if (parameters != null) {
+ for (int i = 0, n = parameters.size(); i < n; i++) {
+ ParameterNode parameter = parameters.get(i);
+ methodVisitor.visitParameter(parameter.name, parameter.access);
}
}
- n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
- for (i = 0; i < n; ++i) {
- AnnotationNode an = visibleAnnotations.get(i);
- an.accept(mv.visitAnnotation(an.desc, true));
+ // Visit the annotations.
+ if (annotationDefault != null) {
+ AnnotationVisitor annotationVisitor = methodVisitor.visitAnnotationDefault();
+ AnnotationNode.accept(annotationVisitor, null, annotationDefault);
+ if (annotationVisitor != null) {
+ annotationVisitor.visitEnd();
+ }
}
- n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
- for (i = 0; i < n; ++i) {
- AnnotationNode an = invisibleAnnotations.get(i);
- an.accept(mv.visitAnnotation(an.desc, false));
+ if (visibleAnnotations != null) {
+ for (int i = 0, n = visibleAnnotations.size(); i < n; ++i) {
+ AnnotationNode annotation = visibleAnnotations.get(i);
+ annotation.accept(methodVisitor.visitAnnotation(annotation.desc, true));
+ }
}
- n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size();
- for (i = 0; i < n; ++i) {
- TypeAnnotationNode an = visibleTypeAnnotations.get(i);
- an.accept(mv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, true));
+ if (invisibleAnnotations != null) {
+ for (int i = 0, n = invisibleAnnotations.size(); i < n; ++i) {
+ AnnotationNode annotation = invisibleAnnotations.get(i);
+ annotation.accept(methodVisitor.visitAnnotation(annotation.desc, false));
+ }
}
- n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations.size();
- for (i = 0; i < n; ++i) {
- TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
- an.accept(mv.visitTypeAnnotation(an.typeRef, an.typePath, an.desc, false));
+ if (visibleTypeAnnotations != null) {
+ for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode typeAnnotation = visibleTypeAnnotations.get(i);
+ typeAnnotation.accept(
+ methodVisitor.visitTypeAnnotation(
+ typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, true));
+ }
+ }
+ if (invisibleTypeAnnotations != null) {
+ for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode typeAnnotation = invisibleTypeAnnotations.get(i);
+ typeAnnotation.accept(
+ methodVisitor.visitTypeAnnotation(
+ typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, false));
+ }
}
if (visibleAnnotableParameterCount > 0) {
- mv.visitAnnotableParameterCount(visibleAnnotableParameterCount, true);
+ methodVisitor.visitAnnotableParameterCount(visibleAnnotableParameterCount, true);
}
- n = visibleParameterAnnotations == null ? 0 : visibleParameterAnnotations.length;
- for (i = 0; i < n; ++i) {
- List<?> l = visibleParameterAnnotations[i];
- if (l == null) {
- continue;
- }
- for (j = 0; j < l.size(); ++j) {
- AnnotationNode an = (AnnotationNode) l.get(j);
- an.accept(mv.visitParameterAnnotation(i, an.desc, true));
+ if (visibleParameterAnnotations != null) {
+ for (int i = 0, n = visibleParameterAnnotations.length; i < n; ++i) {
+ List<AnnotationNode> parameterAnnotations = visibleParameterAnnotations[i];
+ if (parameterAnnotations == null) {
+ continue;
+ }
+ for (int j = 0, m = parameterAnnotations.size(); j < m; ++j) {
+ AnnotationNode annotation = parameterAnnotations.get(j);
+ annotation.accept(methodVisitor.visitParameterAnnotation(i, annotation.desc, true));
+ }
}
}
if (invisibleAnnotableParameterCount > 0) {
- mv.visitAnnotableParameterCount(invisibleAnnotableParameterCount, false);
+ methodVisitor.visitAnnotableParameterCount(invisibleAnnotableParameterCount, false);
}
- n = invisibleParameterAnnotations == null ? 0 : invisibleParameterAnnotations.length;
- for (i = 0; i < n; ++i) {
- List<?> l = invisibleParameterAnnotations[i];
- if (l == null) {
- continue;
- }
- for (j = 0; j < l.size(); ++j) {
- AnnotationNode an = (AnnotationNode) l.get(j);
- an.accept(mv.visitParameterAnnotation(i, an.desc, false));
+ if (invisibleParameterAnnotations != null) {
+ for (int i = 0, n = invisibleParameterAnnotations.length; i < n; ++i) {
+ List<AnnotationNode> parameterAnnotations = invisibleParameterAnnotations[i];
+ if (parameterAnnotations == null) {
+ continue;
+ }
+ for (int j = 0, m = parameterAnnotations.size(); j < m; ++j) {
+ AnnotationNode annotation = parameterAnnotations.get(j);
+ annotation.accept(methodVisitor.visitParameterAnnotation(i, annotation.desc, false));
+ }
}
}
+ // Visit the non standard attributes.
if (visited) {
instructions.resetLabels();
}
- n = attrs == null ? 0 : attrs.size();
- for (i = 0; i < n; ++i) {
- mv.visitAttribute(attrs.get(i));
+ if (attrs != null) {
+ for (int i = 0, n = attrs.size(); i < n; ++i) {
+ methodVisitor.visitAttribute(attrs.get(i));
+ }
}
- // visits the method's code
+ // Visit the code.
if (instructions.size() > 0) {
- mv.visitCode();
- // visits try catch blocks
- n = tryCatchBlocks == null ? 0 : tryCatchBlocks.size();
- for (i = 0; i < n; ++i) {
- tryCatchBlocks.get(i).updateIndex(i);
- tryCatchBlocks.get(i).accept(mv);
+ methodVisitor.visitCode();
+ // Visits the try catch blocks.
+ if (tryCatchBlocks != null) {
+ for (int i = 0, n = tryCatchBlocks.size(); i < n; ++i) {
+ tryCatchBlocks.get(i).updateIndex(i);
+ tryCatchBlocks.get(i).accept(methodVisitor);
+ }
}
- // visits instructions
- instructions.accept(mv);
- // visits local variables
- n = localVariables == null ? 0 : localVariables.size();
- for (i = 0; i < n; ++i) {
- localVariables.get(i).accept(mv);
+ // Visit the instructions.
+ instructions.accept(methodVisitor);
+ // Visits the local variables.
+ if (localVariables != null) {
+ for (int i = 0, n = localVariables.size(); i < n; ++i) {
+ localVariables.get(i).accept(methodVisitor);
+ }
}
- // visits local variable annotations
- n = visibleLocalVariableAnnotations == null ? 0 : visibleLocalVariableAnnotations.size();
- for (i = 0; i < n; ++i) {
- visibleLocalVariableAnnotations.get(i).accept(mv, true);
+ // Visits the local variable annotations.
+ if (visibleLocalVariableAnnotations != null) {
+ for (int i = 0, n = visibleLocalVariableAnnotations.size(); i < n; ++i) {
+ visibleLocalVariableAnnotations.get(i).accept(methodVisitor, true);
+ }
}
- n = invisibleLocalVariableAnnotations == null ? 0 : invisibleLocalVariableAnnotations.size();
- for (i = 0; i < n; ++i) {
- invisibleLocalVariableAnnotations.get(i).accept(mv, false);
+ if (invisibleLocalVariableAnnotations != null) {
+ for (int i = 0, n = invisibleLocalVariableAnnotations.size(); i < n; ++i) {
+ invisibleLocalVariableAnnotations.get(i).accept(methodVisitor, false);
+ }
}
- // visits maxs
- mv.visitMaxs(maxStack, maxLocals);
+ methodVisitor.visitMaxs(maxStack, maxLocals);
visited = true;
}
- mv.visitEnd();
+ methodVisitor.visitEnd();
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleExportNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleExportNode.java
index 4e84fd7..ff9c98b 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleExportNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleExportNode.java
@@ -37,6 +37,7 @@
* @author Remi Forax
*/
public class ModuleExportNode {
+
/** The internal name of the exported package. */
public String packaze;
@@ -47,7 +48,7 @@
public int access;
/**
- * A list of modules that can access this exported package, specified with fully qualified names
+ * The list of modules that can access this exported package, specified with fully qualified names
* (using dots). May be <tt>null</tt>.
*/
public List<String> modules;
@@ -70,9 +71,10 @@
/**
* Makes the given module visitor visit this export declaration.
*
- * @param mv a module visitor.
+ * @param moduleVisitor a module visitor.
*/
- public void accept(final ModuleVisitor mv) {
- mv.visitExport(packaze, access, (modules == null) ? null : modules.toArray(new String[0]));
+ public void accept(final ModuleVisitor moduleVisitor) {
+ moduleVisitor.visitExport(
+ packaze, access, modules == null ? null : modules.toArray(new String[modules.size()]));
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java
index e74b90e..21e17bc 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleNode.java
@@ -40,55 +40,48 @@
* @author Remi Forax
*/
public class ModuleNode extends ModuleVisitor {
- /** The fully qualified name (using dots) of the module. */
+
+ /** The fully qualified name (using dots) of this module. */
public String name;
/**
- * Module access flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} and {@code ACC_MANDATED}.
+ * The module's access flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} and {@code
+ * ACC_MANDATED}.
*/
public int access;
- /** Version of the module. May be <tt>null</tt>. */
+ /** The version of this module. May be <tt>null</tt>. */
public String version;
- /** Name of the main class in internal form. May be <tt>null</tt>. */
+ /** The internal name of the main class of this module. May be <tt>null</tt>. */
public String mainClass;
- /**
- * A list of packages that are declared by the current module, specified with internal names. May
- * be <tt>null</tt>.
- */
+ /** The internal name of the packages declared by this module. May be <tt>null</tt>. */
public List<String> packages;
- /** A list of modules can are required by the current module. May be <tt>null</tt>. */
+ /** The dependencies of this module. May be <tt>null</tt>. */
public List<ModuleRequireNode> requires;
- /** A list of packages that are exported by the current module. May be <tt>null</tt>. */
+ /** The packages exported by this module. May be <tt>null</tt>. */
public List<ModuleExportNode> exports;
- /** A list of packages that are opened by the current module. May be <tt>null</tt>. */
+ /** The packages opened by this module. May be <tt>null</tt>. */
public List<ModuleOpenNode> opens;
- /**
- * A list of classes that are used as a service by the current module, specified with internal
- * names. May be <tt>null</tt>.
- */
+ /** The internal names of the services used by this module. May be <tt>null</tt>. */
public List<String> uses;
- /**
- * A list of services along with their implementations provided by the current module. May be
- * <tt>null</tt>.
- */
+ /** The services provided by this module. May be <tt>null</tt>. */
public List<ModuleProvideNode> provides;
/**
* Constructs a {@link ModuleNode}. <i>Subclasses must not use this constructor</i>. Instead, they
* must use the {@link #ModuleNode(int,String,int,String,List,List,List,List,List)} version.
*
- * @param name The fully qualified name (using dots) of the module.
- * @param access module flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} and {@code
+ * @param name the fully qualified name (using dots) of the module.
+ * @param access the module access flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} and {@code
* ACC_MANDATED}.
- * @param version module version or <tt>null</tt>.
+ * @param version the module version, or <tt>null</tt>.
* @throws IllegalStateException If a subclass calls this constructor.
*/
public ModuleNode(final String name, final int access, final String version) {
@@ -106,18 +99,15 @@
* Constructs a {@link ModuleNode}.
*
* @param api the ASM API version implemented by this visitor. Must be {@link Opcodes#ASM6}.
- * @param name The fully qualified name (using dots) of the module.
- * @param access module flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} and {@code
+ * @param name the fully qualified name (using dots) of the module.
+ * @param access the module access flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} and {@code
* ACC_MANDATED}.
- * @param version module version or <tt>null</tt>.
- * @param requires A list of modules can are required by the current module. May be <tt>null</tt>.
- * @param exports A list of packages that are exported by the current module. May be
- * <tt>null</tt>.
- * @param opens A list of packages that are opened by the current module. May be <tt>null</tt>.
- * @param uses A list of classes that are used as a service by the current module, specified with
- * internal names. May be <tt>null</tt>.
- * @param provides A list of services along with their implementations provided by the current
- * module. May be <tt>null</tt>.
+ * @param version the module version, or <tt>null</tt>.
+ * @param requires The dependencies of this module. May be <tt>null</tt>.
+ * @param exports The packages exported by this module. May be <tt>null</tt>.
+ * @param opens The packages opened by this module. May be <tt>null</tt>.
+ * @param uses The internal names of the services used by this module. May be <tt>null</tt>.
+ * @param provides The services provided by this module. May be <tt>null</tt>.
*/
public ModuleNode(
final int api,
@@ -141,12 +131,12 @@
}
@Override
- public void visitMainClass(String mainClass) {
+ public void visitMainClass(final String mainClass) {
this.mainClass = mainClass;
}
@Override
- public void visitPackage(String packaze) {
+ public void visitPackage(final String packaze) {
if (packages == null) {
packages = new ArrayList<String>(5);
}
@@ -154,7 +144,7 @@
}
@Override
- public void visitRequire(String module, int access, String version) {
+ public void visitRequire(final String module, final int access, final String version) {
if (requires == null) {
requires = new ArrayList<ModuleRequireNode>(5);
}
@@ -162,37 +152,23 @@
}
@Override
- public void visitExport(String packaze, int access, String... modules) {
+ public void visitExport(final String packaze, final int access, final String... modules) {
if (exports == null) {
exports = new ArrayList<ModuleExportNode>(5);
}
- List<String> moduleList = null;
- if (modules != null) {
- moduleList = new ArrayList<String>(modules.length);
- for (int i = 0; i < modules.length; i++) {
- moduleList.add(modules[i]);
- }
- }
- exports.add(new ModuleExportNode(packaze, access, moduleList));
+ exports.add(new ModuleExportNode(packaze, access, Util.asArrayList(modules)));
}
@Override
- public void visitOpen(String packaze, int access, String... modules) {
+ public void visitOpen(final String packaze, final int access, final String... modules) {
if (opens == null) {
opens = new ArrayList<ModuleOpenNode>(5);
}
- List<String> moduleList = null;
- if (modules != null) {
- moduleList = new ArrayList<String>(modules.length);
- for (int i = 0; i < modules.length; i++) {
- moduleList.add(modules[i]);
- }
- }
- opens.add(new ModuleOpenNode(packaze, access, moduleList));
+ opens.add(new ModuleOpenNode(packaze, access, Util.asArrayList(modules)));
}
@Override
- public void visitUse(String service) {
+ public void visitUse(final String service) {
if (uses == null) {
uses = new ArrayList<String>(5);
}
@@ -200,56 +176,54 @@
}
@Override
- public void visitProvide(String service, String... providers) {
+ public void visitProvide(final String service, final String... providers) {
if (provides == null) {
provides = new ArrayList<ModuleProvideNode>(5);
}
- ArrayList<String> providerList = new ArrayList<String>(providers.length);
- for (int i = 0; i < providers.length; i++) {
- providerList.add(providers[i]);
- }
- provides.add(new ModuleProvideNode(service, providerList));
+ provides.add(new ModuleProvideNode(service, Util.asArrayList(providers)));
}
@Override
- public void visitEnd() {}
+ public void visitEnd() {
+ // Nothing to do.
+ }
- public void accept(final ClassVisitor cv) {
- ModuleVisitor mv = cv.visitModule(name, access, version);
- if (mv == null) {
+ public void accept(final ClassVisitor classVisitor) {
+ ModuleVisitor moduleVisitor = classVisitor.visitModule(name, access, version);
+ if (moduleVisitor == null) {
return;
}
if (mainClass != null) {
- mv.visitMainClass(mainClass);
+ moduleVisitor.visitMainClass(mainClass);
}
if (packages != null) {
- for (int i = 0; i < packages.size(); i++) {
- mv.visitPackage(packages.get(i));
+ for (int i = 0, n = packages.size(); i < n; i++) {
+ moduleVisitor.visitPackage(packages.get(i));
}
}
if (requires != null) {
- for (int i = 0; i < requires.size(); i++) {
- requires.get(i).accept(mv);
+ for (int i = 0, n = requires.size(); i < n; i++) {
+ requires.get(i).accept(moduleVisitor);
}
}
if (exports != null) {
- for (int i = 0; i < exports.size(); i++) {
- exports.get(i).accept(mv);
+ for (int i = 0, n = exports.size(); i < n; i++) {
+ exports.get(i).accept(moduleVisitor);
}
}
if (opens != null) {
- for (int i = 0; i < opens.size(); i++) {
- opens.get(i).accept(mv);
+ for (int i = 0, n = opens.size(); i < n; i++) {
+ opens.get(i).accept(moduleVisitor);
}
}
if (uses != null) {
- for (int i = 0; i < uses.size(); i++) {
- mv.visitUse(uses.get(i));
+ for (int i = 0, n = uses.size(); i < n; i++) {
+ moduleVisitor.visitUse(uses.get(i));
}
}
if (provides != null) {
- for (int i = 0; i < provides.size(); i++) {
- provides.get(i).accept(mv);
+ for (int i = 0, n = provides.size(); i < n; i++) {
+ provides.get(i).accept(moduleVisitor);
}
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleOpenNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleOpenNode.java
index 76c31a6..fa07e7e 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleOpenNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleOpenNode.java
@@ -32,30 +32,35 @@
import org.objectweb.asm.ModuleVisitor;
/**
- * A node that represents an opened package with its name and the module that can access to it.
+ * A node that represents an opened package with its name and the module that can access it.
*
* @author Remi Forax
*/
public class ModuleOpenNode {
+
/** The internal name of the opened package. */
public String packaze;
/**
- * The access flags (see {@link org.objectweb.asm.Opcodes}). Valid values are {@code
- * ACC_SYNTHETIC} and {@code ACC_MANDATED}.
+ * The access flag of the opened package, valid values are among {@code ACC_SYNTHETIC} and {@code
+ * ACC_MANDATED}.
*/
public int access;
- /** A list of modules that can access to this exported package. May be <tt>null</tt>. */
+ /**
+ * The fully qualified names (using dots) of the modules that can use deep reflection to the
+ * classes of the open package, or <tt>null</tt>.
+ */
public List<String> modules;
/**
* Constructs a new {@link ModuleOpenNode}.
*
- * @param packaze the parameter's name.
- * @param access the module access flags, one or more of {@code ACC_SYNTHETIC} and {@code
- * ACC_MANDATED}.
- * @param modules a list of modules that can access to this open package.
+ * @param packaze the internal name of the opened package.
+ * @param access the access flag of the opened package, valid values are among {@code
+ * ACC_SYNTHETIC} and {@code ACC_MANDATED}.
+ * @param modules the fully qualified names (using dots) of the modules that can use deep
+ * reflection to the classes of the open package, or <tt>null</tt>.
*/
public ModuleOpenNode(final String packaze, final int access, final List<String> modules) {
this.packaze = packaze;
@@ -64,11 +69,12 @@
}
/**
- * Makes the given module visitor visit this open declaration.
+ * Makes the given module visitor visit this opened package.
*
- * @param mv a module visitor.
+ * @param moduleVisitor a module visitor.
*/
- public void accept(final ModuleVisitor mv) {
- mv.visitOpen(packaze, access, (modules == null) ? null : modules.toArray(new String[0]));
+ public void accept(final ModuleVisitor moduleVisitor) {
+ moduleVisitor.visitOpen(
+ packaze, access, modules == null ? null : modules.toArray(new String[modules.size()]));
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleProvideNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleProvideNode.java
index 04c3742..1f6af22 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleProvideNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleProvideNode.java
@@ -37,17 +37,19 @@
* @author Remi Forax
*/
public class ModuleProvideNode {
- /** The internal name of the provided service. */
+
+ /** The internal name of the service. */
public String service;
- /** The internal names of the service providers. */
+ /** The internal names of the implementations of the service (there is at least one provider). */
public List<String> providers;
/**
* Constructs a new {@link ModuleProvideNode}.
*
- * @param service the internal name of the provided service.
- * @param providers the internal names of service providers.
+ * @param service the internal name of the service.
+ * @param providers the internal names of the implementations of the service (there is at least
+ * one provider).
*/
public ModuleProvideNode(final String service, final List<String> providers) {
this.service = service;
@@ -57,9 +59,9 @@
/**
* Makes the given module visitor visit this require declaration.
*
- * @param mv a module visitor.
+ * @param moduleVisitor a module visitor.
*/
- public void accept(final ModuleVisitor mv) {
- mv.visitProvide(service, providers.toArray(new String[0]));
+ public void accept(final ModuleVisitor moduleVisitor) {
+ moduleVisitor.visitProvide(service, providers.toArray(new String[providers.size()]));
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleRequireNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleRequireNode.java
index 8224188..e5f3983 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleRequireNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ModuleRequireNode.java
@@ -35,27 +35,26 @@
* @author Remi Forax
*/
public class ModuleRequireNode {
- /** The fully qualified name (using dots) of the required module. */
+
+ /** The fully qualified name (using dots) of the dependence. */
public String module;
/**
- * The access flags (see {@link org.objectweb.asm.Opcodes}). Valid values are
- * <tt>ACC_TRANSITIVE</tt>, <tt>ACC_STATIC_PHASE</tt>, <tt>ACC_SYNTHETIC</tt> and
- * <tt>ACC_MANDATED</tt>.
+ * The access flag of the dependence among {@code ACC_TRANSITIVE}, {@code ACC_STATIC_PHASE},
+ * {@code ACC_SYNTHETIC} and {@code ACC_MANDATED}.
*/
public int access;
- /** Version at compile time of the required module or null. */
+ /** The module version at compile time, or <tt>null</tt>. */
public String version;
/**
* Constructs a new {@link ModuleRequireNode}.
*
- * @param module the fully qualified name (using dots) of the required module.
- * @param access The access flags. Valid values are <tt>ACC_TRANSITIVE</tt>,
- * <tt>ACC_STATIC_PHASE</tt>, <tt>ACC_SYNTHETIC</tt> and <tt>ACC_MANDATED</tt> (see {@link
- * org.objectweb.asm.Opcodes}).
- * @param version Version of the required module at compile time, null if not defined.
+ * @param module the fully qualified name (using dots) of the dependence.
+ * @param access the access flag of the dependence among {@code ACC_TRANSITIVE}, {@code
+ * ACC_STATIC_PHASE}, {@code ACC_SYNTHETIC} and {@code ACC_MANDATED}.
+ * @param version the module version at compile time, or <tt>null</tt>.
*/
public ModuleRequireNode(final String module, final int access, final String version) {
this.module = module;
@@ -66,9 +65,9 @@
/**
* Makes the given module visitor visit this require directive.
*
- * @param mv a module visitor.
+ * @param moduleVisitor a module visitor.
*/
- public void accept(final ModuleVisitor mv) {
- mv.visitRequire(module, access, version);
+ public void accept(final ModuleVisitor moduleVisitor) {
+ moduleVisitor.visitRequire(module, access, version);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/MultiANewArrayInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/MultiANewArrayInsnNode.java
index f87de4f..d5ce3ad 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/MultiANewArrayInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/MultiANewArrayInsnNode.java
@@ -48,13 +48,13 @@
/**
* Constructs a new {@link MultiANewArrayInsnNode}.
*
- * @param desc an array type descriptor (see {@link org.objectweb.asm.Type}).
- * @param dims number of dimensions of the array to allocate.
+ * @param descriptor an array type descriptor (see {@link org.objectweb.asm.Type}).
+ * @param numDimensions the number of dimensions of the array to allocate.
*/
- public MultiANewArrayInsnNode(final String desc, final int dims) {
+ public MultiANewArrayInsnNode(final String descriptor, final int numDimensions) {
super(Opcodes.MULTIANEWARRAY);
- this.desc = desc;
- this.dims = dims;
+ this.desc = descriptor;
+ this.dims = numDimensions;
}
@Override
@@ -63,13 +63,13 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitMultiANewArrayInsn(desc, dims);
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitMultiANewArrayInsn(desc, dims);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
return new MultiANewArrayInsnNode(desc, dims).cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/ParameterNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/ParameterNode.java
index 4889a34..333692a 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/ParameterNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/ParameterNode.java
@@ -30,11 +30,12 @@
import org.objectweb.asm.MethodVisitor;
/**
- * A node that represents a parameter access and name.
+ * A node that represents a parameter of a method.
*
* @author Remi Forax
*/
public class ParameterNode {
+
/** The parameter's name. */
public String name;
@@ -60,9 +61,9 @@
/**
* Makes the given visitor visit this parameter declaration.
*
- * @param mv a method visitor.
+ * @param methodVisitor a method visitor.
*/
- public void accept(final MethodVisitor mv) {
- mv.visitParameter(name, access);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitParameter(name, access);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/TableSwitchInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/TableSwitchInsnNode.java
index db16eda..7c1c719 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/TableSwitchInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/TableSwitchInsnNode.java
@@ -27,8 +27,6 @@
// THE POSSIBILITY OF SUCH DAMAGE.
package org.objectweb.asm.tree;
-import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.Map;
@@ -70,10 +68,7 @@
this.min = min;
this.max = max;
this.dflt = dflt;
- this.labels = new ArrayList<LabelNode>();
- if (labels != null) {
- this.labels.addAll(Arrays.asList(labels));
- }
+ this.labels = Util.asArrayList(labels);
}
@Override
@@ -82,18 +77,18 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- Label[] labels = new Label[this.labels.size()];
- for (int i = 0; i < labels.length; ++i) {
- labels[i] = this.labels.get(i).getLabel();
+ public void accept(final MethodVisitor methodVisitor) {
+ Label[] labelsArray = new Label[this.labels.size()];
+ for (int i = 0, n = labelsArray.length; i < n; ++i) {
+ labelsArray[i] = this.labels.get(i).getLabel();
}
- mv.visitTableSwitchInsn(min, max, dflt.getLabel(), labels);
- acceptAnnotations(mv);
+ methodVisitor.visitTableSwitchInsn(min, max, dflt.getLabel(), labelsArray);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
- return new TableSwitchInsnNode(min, max, clone(dflt, labels), clone(this.labels, labels))
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
+ return new TableSwitchInsnNode(min, max, clone(dflt, clonedLabels), clone(labels, clonedLabels))
.cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/TryCatchBlockNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/TryCatchBlockNode.java
index 1887cad..b82a912 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/TryCatchBlockNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/TryCatchBlockNode.java
@@ -38,41 +38,35 @@
*/
public class TryCatchBlockNode {
- /** Beginning of the exception handler's scope (inclusive). */
+ /** The beginning of the exception handler's scope (inclusive). */
public LabelNode start;
- /** End of the exception handler's scope (exclusive). */
+ /** The end of the exception handler's scope (exclusive). */
public LabelNode end;
- /** Beginning of the exception handler's code. */
+ /** The beginning of the exception handler's code. */
public LabelNode handler;
/**
- * Internal name of the type of exceptions handled by the handler. May be <tt>null</tt> to catch
- * any exceptions (for "finally" blocks).
+ * The internal name of the type of exceptions handled by the handler. May be <tt>null</tt> to
+ * catch any exceptions (for "finally" blocks).
*/
public String type;
- /**
- * The runtime visible type annotations on the exception handler type. This list is a list of
- * {@link TypeAnnotationNode} objects. May be <tt>null</tt>.
- */
+ /** The runtime visible type annotations on the exception handler type. May be <tt>null</tt>. */
public List<TypeAnnotationNode> visibleTypeAnnotations;
- /**
- * The runtime invisible type annotations on the exception handler type. This list is a list of
- * {@link TypeAnnotationNode} objects. May be <tt>null</tt>.
- */
+ /** The runtime invisible type annotations on the exception handler type. May be <tt>null</tt>. */
public List<TypeAnnotationNode> invisibleTypeAnnotations;
/**
* Constructs a new {@link TryCatchBlockNode}.
*
- * @param start beginning of the exception handler's scope (inclusive).
- * @param end end of the exception handler's scope (exclusive).
- * @param handler beginning of the exception handler's code.
- * @param type internal name of the type of exceptions handled by the handler, or <tt>null</tt> to
- * catch any exceptions (for "finally" blocks).
+ * @param start the beginning of the exception handler's scope (inclusive).
+ * @param end the end of the exception handler's scope (exclusive).
+ * @param handler the beginning of the exception handler's code.
+ * @param type the internal name of the type of exceptions handled by the handler, or
+ * <tt>null</tt> to catch any exceptions (for "finally" blocks).
*/
public TryCatchBlockNode(
final LabelNode start, final LabelNode end, final LabelNode handler, final String type) {
@@ -92,13 +86,13 @@
public void updateIndex(final int index) {
int newTypeRef = 0x42000000 | (index << 8);
if (visibleTypeAnnotations != null) {
- for (TypeAnnotationNode tan : visibleTypeAnnotations) {
- tan.typeRef = newTypeRef;
+ for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) {
+ visibleTypeAnnotations.get(i).typeRef = newTypeRef;
}
}
if (invisibleTypeAnnotations != null) {
- for (TypeAnnotationNode tan : invisibleTypeAnnotations) {
- tan.typeRef = newTypeRef;
+ for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) {
+ invisibleTypeAnnotations.get(i).typeRef = newTypeRef;
}
}
}
@@ -106,20 +100,26 @@
/**
* Makes the given visitor visit this try catch block.
*
- * @param mv a method visitor.
+ * @param methodVisitor a method visitor.
*/
- public void accept(final MethodVisitor mv) {
- mv.visitTryCatchBlock(
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitTryCatchBlock(
start.getLabel(), end.getLabel(), handler == null ? null : handler.getLabel(), type);
- int n = visibleTypeAnnotations == null ? 0 : visibleTypeAnnotations.size();
- for (int i = 0; i < n; ++i) {
- TypeAnnotationNode an = visibleTypeAnnotations.get(i);
- an.accept(mv.visitTryCatchAnnotation(an.typeRef, an.typePath, an.desc, true));
+ if (visibleTypeAnnotations != null) {
+ for (int i = 0, n = visibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode typeAnnotation = visibleTypeAnnotations.get(i);
+ typeAnnotation.accept(
+ methodVisitor.visitTryCatchAnnotation(
+ typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, true));
+ }
}
- n = invisibleTypeAnnotations == null ? 0 : invisibleTypeAnnotations.size();
- for (int i = 0; i < n; ++i) {
- TypeAnnotationNode an = invisibleTypeAnnotations.get(i);
- an.accept(mv.visitTryCatchAnnotation(an.typeRef, an.typePath, an.desc, false));
+ if (invisibleTypeAnnotations != null) {
+ for (int i = 0, n = invisibleTypeAnnotations.size(); i < n; ++i) {
+ TypeAnnotationNode typeAnnotation = invisibleTypeAnnotations.get(i);
+ typeAnnotation.accept(
+ methodVisitor.visitTryCatchAnnotation(
+ typeAnnotation.typeRef, typeAnnotation.typePath, typeAnnotation.desc, false));
+ }
}
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java
index f08889f..5feb40a 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/TypeAnnotationNode.java
@@ -32,7 +32,7 @@
import org.objectweb.asm.TypeReference;
/**
- * A node that represents a type annotationn.
+ * A node that represents a type annotation.
*
* @author Eric Bruneton
*/
@@ -56,11 +56,11 @@
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or
* static inner type within 'typeRef'. May be <tt>null</tt> if the annotation targets
* 'typeRef' as a whole.
- * @param desc the class descriptor of the annotation class.
+ * @param descriptor the class descriptor of the annotation class.
* @throws IllegalStateException If a subclass calls this constructor.
*/
- public TypeAnnotationNode(final int typeRef, final TypePath typePath, final String desc) {
- this(Opcodes.ASM6, typeRef, typePath, desc);
+ public TypeAnnotationNode(final int typeRef, final TypePath typePath, final String descriptor) {
+ this(Opcodes.ASM6, typeRef, typePath, descriptor);
if (getClass() != TypeAnnotationNode.class) {
throw new IllegalStateException();
}
@@ -75,11 +75,11 @@
* @param typePath the path to the annotated type argument, wildcard bound, array element type, or
* static inner type within 'typeRef'. May be <tt>null</tt> if the annotation targets
* 'typeRef' as a whole.
- * @param desc the class descriptor of the annotation class.
+ * @param descriptor the class descriptor of the annotation class.
*/
public TypeAnnotationNode(
- final int api, final int typeRef, final TypePath typePath, final String desc) {
- super(api, desc);
+ final int api, final int typeRef, final TypePath typePath, final String descriptor) {
+ super(api, descriptor);
this.typeRef = typeRef;
this.typePath = typePath;
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/TypeInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/TypeInsnNode.java
index cbca00f..7a0d8d9 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/TypeInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/TypeInsnNode.java
@@ -50,12 +50,12 @@
*
* @param opcode the opcode of the type instruction to be constructed. This opcode must be NEW,
* ANEWARRAY, CHECKCAST or INSTANCEOF.
- * @param desc the operand of the instruction to be constructed. This operand is an internal name
- * (see {@link org.objectweb.asm.Type}).
+ * @param descriptor the operand of the instruction to be constructed. This operand is an internal
+ * name (see {@link org.objectweb.asm.Type}).
*/
- public TypeInsnNode(final int opcode, final String desc) {
+ public TypeInsnNode(final int opcode, final String descriptor) {
super(opcode);
- this.desc = desc;
+ this.desc = descriptor;
}
/**
@@ -74,13 +74,13 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitTypeInsn(opcode, desc);
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitTypeInsn(opcode, desc);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
return new TypeInsnNode(opcode, desc).cloneAnnotations(this);
}
}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/UnsupportedClassVersionException.java b/asm-tree/src/main/java/org/objectweb/asm/tree/UnsupportedClassVersionException.java
new file mode 100644
index 0000000..ee3b92a
--- /dev/null
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/UnsupportedClassVersionException.java
@@ -0,0 +1,14 @@
+package org.objectweb.asm.tree;
+
+/**
+ * Exception thrown in {@link AnnotationNode#check}, {@link ClassNode#check}, {@link
+ * FieldNode#check} and {@link MethodNode#check} when these nodes (or their children, recursively)
+ * contain elements that were introduced in more recent versions of the ASM API than version passed
+ * to these methods.
+ *
+ * @author Eric Bruneton
+ */
+public class UnsupportedClassVersionException extends RuntimeException {
+
+ private static final long serialVersionUID = -3502347765891805831L;
+}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/Util.java b/asm-tree/src/main/java/org/objectweb/asm/tree/Util.java
new file mode 100644
index 0000000..46aa016
--- /dev/null
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/Util.java
@@ -0,0 +1,157 @@
+// ASM: a very small and fast Java bytecode manipulation framework
+// Copyright (c) 2000-2011 INRIA, France Telecom
+// All rights reserved.
+//
+// Redistribution and use in source and binary forms, with or without
+// modification, are permitted provided that the following conditions
+// are met:
+// 1. Redistributions of source code must retain the above copyright
+// notice, this list of conditions and the following disclaimer.
+// 2. Redistributions in binary form must reproduce the above copyright
+// notice, this list of conditions and the following disclaimer in the
+// documentation and/or other materials provided with the distribution.
+// 3. Neither the name of the copyright holders nor the names of its
+// contributors may be used to endorse or promote products derived from
+// this software without specific prior written permission.
+//
+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+// THE POSSIBILITY OF SUCH DAMAGE.
+package org.objectweb.asm.tree;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Utility methods to convert an array of primitive or object values to a mutable ArrayList, not
+ * baked by the array (unlike {@link Arrays#asList}).
+ *
+ * @author Eric Bruneton
+ */
+final class Util {
+
+ private Util() {}
+
+ static <T> List<T> asArrayList(final int length) {
+ List<T> list = new ArrayList<T>(length);
+ for (int i = 0; i < length; ++i) {
+ list.add(null);
+ }
+ return list;
+ }
+
+ static <T> List<T> asArrayList(final T[] array) {
+ if (array == null) {
+ return new ArrayList<T>();
+ }
+ ArrayList<T> list = new ArrayList<T>(array.length);
+ for (T t : array) {
+ list.add(t);
+ }
+ return list;
+ }
+
+ static List<Byte> asArrayList(final byte[] byteArray) {
+ if (byteArray == null) {
+ return new ArrayList<Byte>();
+ }
+ ArrayList<Byte> byteList = new ArrayList<Byte>(byteArray.length);
+ for (byte b : byteArray) {
+ byteList.add(b);
+ }
+ return byteList;
+ }
+
+ static List<Boolean> asArrayList(final boolean[] booleanArray) {
+ if (booleanArray == null) {
+ return new ArrayList<Boolean>();
+ }
+ ArrayList<Boolean> booleanList = new ArrayList<Boolean>(booleanArray.length);
+ for (boolean b : booleanArray) {
+ booleanList.add(b);
+ }
+ return booleanList;
+ }
+
+ static List<Short> asArrayList(final short[] shortArray) {
+ if (shortArray == null) {
+ return new ArrayList<Short>();
+ }
+ ArrayList<Short> shortList = new ArrayList<Short>(shortArray.length);
+ for (short s : shortArray) {
+ shortList.add(s);
+ }
+ return shortList;
+ }
+
+ static List<Character> asArrayList(final char[] charArray) {
+ if (charArray == null) {
+ return new ArrayList<Character>();
+ }
+ ArrayList<Character> charList = new ArrayList<Character>(charArray.length);
+ for (char c : charArray) {
+ charList.add(c);
+ }
+ return charList;
+ }
+
+ static List<Integer> asArrayList(final int[] intArray) {
+ if (intArray == null) {
+ return new ArrayList<Integer>();
+ }
+ ArrayList<Integer> intList = new ArrayList<Integer>(intArray.length);
+ for (int i : intArray) {
+ intList.add(i);
+ }
+ return intList;
+ }
+
+ static List<Float> asArrayList(final float[] floatArray) {
+ if (floatArray == null) {
+ return new ArrayList<Float>();
+ }
+ ArrayList<Float> floatList = new ArrayList<Float>(floatArray.length);
+ for (float f : floatArray) {
+ floatList.add(f);
+ }
+ return floatList;
+ }
+
+ static List<Long> asArrayList(final long[] longArray) {
+ if (longArray == null) {
+ return new ArrayList<Long>();
+ }
+ ArrayList<Long> longList = new ArrayList<Long>(longArray.length);
+ for (long l : longArray) {
+ longList.add(l);
+ }
+ return longList;
+ }
+
+ static List<Double> asArrayList(final double[] doubleArray) {
+ if (doubleArray == null) {
+ return new ArrayList<Double>();
+ }
+ ArrayList<Double> doubleList = new ArrayList<Double>(doubleArray.length);
+ for (double d : doubleArray) {
+ doubleList.add(d);
+ }
+ return doubleList;
+ }
+
+ static <T> List<T> asArrayList(final int length, final T[] array) {
+ List<T> list = new ArrayList<T>(length);
+ for (int i = 0; i < length; ++i) {
+ list.add(array[i]);
+ }
+ return list;
+ }
+}
diff --git a/asm-tree/src/main/java/org/objectweb/asm/tree/VarInsnNode.java b/asm-tree/src/main/java/org/objectweb/asm/tree/VarInsnNode.java
index 8df8e47..e18e0a4 100644
--- a/asm-tree/src/main/java/org/objectweb/asm/tree/VarInsnNode.java
+++ b/asm-tree/src/main/java/org/objectweb/asm/tree/VarInsnNode.java
@@ -71,13 +71,13 @@
}
@Override
- public void accept(final MethodVisitor mv) {
- mv.visitVarInsn(opcode, var);
- acceptAnnotations(mv);
+ public void accept(final MethodVisitor methodVisitor) {
+ methodVisitor.visitVarInsn(opcode, var);
+ acceptAnnotations(methodVisitor);
}
@Override
- public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> clonedLabels) {
return new VarInsnNode(opcode, var).cloneAnnotations(this);
}
}
diff --git a/asm/src/main/java/org/objectweb/asm/ClassVisitor.java b/asm/src/main/java/org/objectweb/asm/ClassVisitor.java
index 92f8831..17bc2a9 100644
--- a/asm/src/main/java/org/objectweb/asm/ClassVisitor.java
+++ b/asm/src/main/java/org/objectweb/asm/ClassVisitor.java
@@ -75,7 +75,8 @@
/**
* Visits the header of the class.
*
- * @param version the class version.
+ * @param version the class version. The minor version is stored in the 16 most significant bits,
+ * and the major version in the 16 least significant bits.
* @param access the class's access flags (see {@link Opcodes}). This parameter also indicates if
* the class is deprecated.
* @param name the internal name of the class (see {@link Type#getInternalName()
@@ -117,10 +118,10 @@
/**
* Visit the module corresponding to the class.
*
- * @param name The fully qualified name (using dots) of the module.
- * @param access module flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} and {@code
+ * @param name the fully qualified name (using dots) of the module.
+ * @param access the module access flags, among {@code ACC_OPEN}, {@code ACC_SYNTHETIC} and {@code
* ACC_MANDATED}.
- * @param version module version or <tt>null</tt>.
+ * @param version the module version, or <tt>null</tt>.
* @return a visitor to visit the module values, or <tt>null</tt> if this visitor is not
* interested in visiting this module.
*/
diff --git a/asm/src/main/java/org/objectweb/asm/MethodVisitor.java b/asm/src/main/java/org/objectweb/asm/MethodVisitor.java
index a475f9f..8e651b8 100644
--- a/asm/src/main/java/org/objectweb/asm/MethodVisitor.java
+++ b/asm/src/main/java/org/objectweb/asm/MethodVisitor.java
@@ -583,7 +583,7 @@
* Visits a MULTIANEWARRAY instruction.
*
* @param descriptor an array type descriptor (see {@link Type Type}).
- * @param numDimensions number of dimensions of the array to allocate.
+ * @param numDimensions the number of dimensions of the array to allocate.
*/
public void visitMultiANewArrayInsn(final String descriptor, final int numDimensions) {
if (mv != null) {
@@ -631,11 +631,11 @@
/**
* Visits a try catch block.
*
- * @param start beginning of the exception handler's scope (inclusive).
- * @param end end of the exception handler's scope (exclusive).
- * @param handler beginning of the exception handler's code.
- * @param type internal name of the type of exceptions handled by the handler, or <tt>null</tt> to
- * catch any exceptions (for "finally" blocks).
+ * @param start the beginning of the exception handler's scope (inclusive).
+ * @param end the end of the exception handler's scope (exclusive).
+ * @param handler the beginning of the exception handler's code.
+ * @param type the internal name of the type of exceptions handled by the handler, or
+ * <tt>null</tt> to catch any exceptions (for "finally" blocks).
* @throws IllegalArgumentException if one of the labels has already been visited by this visitor
* (by the {@link #visitLabel visitLabel} method).
*/
diff --git a/asm/src/main/java/org/objectweb/asm/ModuleVisitor.java b/asm/src/main/java/org/objectweb/asm/ModuleVisitor.java
index 459ae74..a1d0b38 100644
--- a/asm/src/main/java/org/objectweb/asm/ModuleVisitor.java
+++ b/asm/src/main/java/org/objectweb/asm/ModuleVisitor.java
@@ -96,8 +96,8 @@
* Visits a dependence of the current module.
*
* @param module the fully qualified name (using dots) of the dependence.
- * @param access the access flag of the dependence among ACC_TRANSITIVE, ACC_STATIC_PHASE,
- * ACC_SYNTHETIC and ACC_MANDATED.
+ * @param access the access flag of the dependence among {@code ACC_TRANSITIVE}, {@code
+ * ACC_STATIC_PHASE}, {@code ACC_SYNTHETIC} and {@code ACC_MANDATED}.
* @param version the module version at compile time, or <tt>null</tt>.
*/
public void visitRequire(final String module, final int access, final String version) {