You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by hl...@apache.org on 2012/05/30 21:20:36 UTC
[10/17] TAP5-1852: Upgrade Plastic to use ASM 4.0 - Remove unused
utility classes
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/MethodNode.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/MethodNode.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/MethodNode.java
index f8b1f28..d2d461c 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/MethodNode.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/MethodNode.java
@@ -1,6 +1,7 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
+ * Copyright (c) 2011 Google
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,27 +30,22 @@
*/
package org.apache.tapestry5.internal.plastic.asm.tree;
-import org.apache.tapestry5.internal.plastic.asm.AnnotationVisitor;
-import org.apache.tapestry5.internal.plastic.asm.Attribute;
-import org.apache.tapestry5.internal.plastic.asm.ClassVisitor;
-import org.apache.tapestry5.internal.plastic.asm.Label;
-import org.apache.tapestry5.internal.plastic.asm.MethodVisitor;
-import org.apache.tapestry5.internal.plastic.asm.Opcodes;
-import org.apache.tapestry5.internal.plastic.asm.Type;
+import org.apache.tapestry5.internal.plastic.asm.*;
-import java.util.List;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
/**
* A node that represents a method.
- *
+ *
* @author Eric Bruneton
*/
-public class MethodNode extends MemberNode implements MethodVisitor {
+public class MethodNode extends MethodVisitor
+{
/**
- * The method's access flags (see {@link Opcodes}). This field also
+ * The method's access flags (see {@link org.apache.tapestry5.internal.plastic.asm.Opcodes}). This field also
* indicates if the method is synthetic and/or deprecated.
*/
public int access;
@@ -60,7 +56,7 @@ public class MethodNode extends MemberNode implements MethodVisitor {
public String name;
/**
- * The method's descriptor (see {@link Type}).
+ * The method's descriptor (see {@link org.apache.tapestry5.internal.plastic.asm.Type}).
*/
public String desc;
@@ -71,16 +67,42 @@ public class MethodNode extends MemberNode implements MethodVisitor {
/**
* The internal names of the method's exception classes (see
- * {@link Type#getInternalName() getInternalName}). This list is a list of
+ * {@link org.apache.tapestry5.internal.plastic.asm.Type#getInternalName() getInternalName}). This list is a list of
* {@link String} objects.
*/
- public List exceptions;
+ public List<String> exceptions;
+
+ /**
+ * The runtime visible annotations of this method. This list is a list of
+ * {@link AnnotationNode} objects. May be <tt>null</tt>.
+ *
+ * @associates AnnotationNode
+ * @label visible
+ */
+ 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>.
+ *
+ * @associates AnnotationNode
+ * @label invisible
+ */
+ public List<AnnotationNode> invisibleAnnotations;
+
+ /**
+ * The non standard attributes of this method. This list is a list of
+ * {@link org.apache.tapestry5.internal.plastic.asm.Attribute} objects. May be <tt>null</tt>.
+ *
+ * @associates Attribute
+ */
+ public List<Attribute> attrs;
/**
* The default value of this annotation interface method. This field must be
* a {@link Byte}, {@link Boolean}, {@link Character}, {@link Short},
* {@link Integer}, {@link Long}, {@link Float}, {@link Double},
- * {@link String} or {@link Type}, or an two elements String array (for
+ * {@link String} or {@link org.apache.tapestry5.internal.plastic.asm.Type}, or an two elements String array (for
* enumeration values), a {@link AnnotationNode}, or a {@link List} of
* values of one of the preceding types. May be <tt>null</tt>.
*/
@@ -89,26 +111,26 @@ public class MethodNode extends MemberNode implements MethodVisitor {
/**
* The runtime visible parameter annotations of this method. These lists are
* lists of {@link AnnotationNode} objects. May be <tt>null</tt>.
- *
- * @associates org.objectweb.asm.tree.AnnotationNode
+ *
+ * @associates AnnotationNode
* @label invisible parameters
*/
- public List[] visibleParameterAnnotations;
+ public List<AnnotationNode>[] visibleParameterAnnotations;
/**
* The runtime invisible parameter annotations of this method. These lists
* are lists of {@link AnnotationNode} objects. May be <tt>null</tt>.
- *
- * @associates org.objectweb.asm.tree.AnnotationNode
+ *
+ * @associates AnnotationNode
* @label visible parameters
*/
- public List[] invisibleParameterAnnotations;
+ public List<AnnotationNode>[] invisibleParameterAnnotations;
/**
* The instructions of this method. This list is a list of
* {@link AbstractInsnNode} objects.
- *
- * @associates org.objectweb.asm.tree.AbstractInsnNode
+ *
+ * @associates AbstractInsnNode
* @label instructions
*/
public InsnList instructions;
@@ -116,10 +138,10 @@ public class MethodNode extends MemberNode implements MethodVisitor {
/**
* The try catch blocks of this method. This list is a list of
* {@link TryCatchBlockNode} objects.
- *
- * @associates org.objectweb.asm.tree.TryCatchBlockNode
+ *
+ * @associates TryCatchBlockNode
*/
- public List tryCatchBlocks;
+ public List<TryCatchBlockNode> tryCatchBlocks;
/**
* The maximum stack size of this method.
@@ -134,62 +156,111 @@ public class MethodNode extends MemberNode implements MethodVisitor {
/**
* The local variables of this method. This list is a list of
* {@link LocalVariableNode} objects. May be <tt>null</tt>
- *
- * @associates org.objectweb.asm.tree.LocalVariableNode
+ *
+ * @associates LocalVariableNode
*/
- public List localVariables;
+ public List<LocalVariableNode> localVariables;
/**
- * Constructs an unitialized {@link MethodNode}.
+ * If the accept method has been called on this object.
+ */
+ private boolean visited;
+
+ /**
+ * Constructs an uninitialized {@link MethodNode}. <i>Subclasses must not
+ * use this constructor</i>. Instead, they must use the
+ * {@link #MethodNode(int)} version.
*/
public MethodNode() {
+ this(Opcodes.ASM4);
+ }
+
+ /**
+ * Constructs an uninitialized {@link MethodNode}.
+ *
+ * @param api the ASM API version implemented by this visitor. Must be one
+ * of {@link Opcodes#ASM4}.
+ */
+ public MethodNode(final int api) {
+ super(api);
this.instructions = new InsnList();
}
-
+
+ /**
+ * Constructs a new {@link MethodNode}. <i>Subclasses must not use this
+ * constructor</i>. Instead, they must use the
+ * {@link #MethodNode(int, int, String, String, String, String[])} version.
+ *
+ * @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 org.apache.tapestry5.internal.plastic.asm.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 org.apache.tapestry5.internal.plastic.asm.Type#getInternalName() getInternalName}). May be
+ * <tt>null</tt>.
+ */
+ public MethodNode(
+ final int access,
+ final String name,
+ final String desc,
+ final String signature,
+ final String[] exceptions)
+ {
+ this(Opcodes.ASM4, access, name, desc, signature, exceptions);
+ }
+
/**
* Constructs a new {@link MethodNode}.
- *
+ *
+ * @param api the ASM API version implemented by this visitor. Must be one
+ * of {@link Opcodes#ASM4}.
* @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 desc the method's descriptor (see {@link org.apache.tapestry5.internal.plastic.asm.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
+ * (see {@link org.apache.tapestry5.internal.plastic.asm.Type#getInternalName() getInternalName}). May be
* <tt>null</tt>.
*/
public MethodNode(
+ final int api,
final int access,
final String name,
final String desc,
final String signature,
final String[] exceptions)
{
- this();
+ super(api);
this.access = access;
this.name = name;
this.desc = desc;
this.signature = signature;
- this.exceptions = new ArrayList(exceptions == null
+ this.exceptions = new ArrayList<String>(exceptions == null
? 0
: exceptions.length);
boolean isAbstract = (access & Opcodes.ACC_ABSTRACT) != 0;
if (!isAbstract) {
- this.localVariables = new ArrayList(5);
+ this.localVariables = new ArrayList<LocalVariableNode>(5);
}
- this.tryCatchBlocks = new ArrayList();
+ this.tryCatchBlocks = new ArrayList<TryCatchBlockNode>();
if (exceptions != null) {
this.exceptions.addAll(Arrays.asList(exceptions));
}
+ this.instructions = new InsnList();
}
// ------------------------------------------------------------------------
- // Implementation of the MethodVisitor interface
+ // Implementation of the MethodVisitor abstract class
// ------------------------------------------------------------------------
+ @Override
public AnnotationVisitor visitAnnotationDefault() {
- return new AnnotationNode(new ArrayList(0) {
+ return new AnnotationNode(new ArrayList<Object>(0) {
+ @Override
public boolean add(final Object o) {
annotationDefault = o;
return super.add(o);
@@ -197,6 +268,27 @@ public class MethodNode extends MemberNode implements MethodVisitor {
});
}
+ @Override
+ public AnnotationVisitor visitAnnotation(
+ final String desc,
+ final boolean visible)
+ {
+ AnnotationNode an = new AnnotationNode(desc);
+ if (visible) {
+ if (visibleAnnotations == null) {
+ visibleAnnotations = new ArrayList<AnnotationNode>(1);
+ }
+ visibleAnnotations.add(an);
+ } else {
+ if (invisibleAnnotations == null) {
+ invisibleAnnotations = new ArrayList<AnnotationNode>(1);
+ }
+ invisibleAnnotations.add(an);
+ }
+ return an;
+ }
+
+ @Override
public AnnotationVisitor visitParameterAnnotation(
final int parameter,
final String desc,
@@ -206,28 +298,38 @@ public class MethodNode extends MemberNode implements MethodVisitor {
if (visible) {
if (visibleParameterAnnotations == null) {
int params = Type.getArgumentTypes(this.desc).length;
- visibleParameterAnnotations = new List[params];
+ visibleParameterAnnotations = (List<AnnotationNode>[])new List<?>[params];
}
if (visibleParameterAnnotations[parameter] == null) {
- visibleParameterAnnotations[parameter] = new ArrayList(1);
+ visibleParameterAnnotations[parameter] = new ArrayList<AnnotationNode>(1);
}
visibleParameterAnnotations[parameter].add(an);
} else {
if (invisibleParameterAnnotations == null) {
int params = Type.getArgumentTypes(this.desc).length;
- invisibleParameterAnnotations = new List[params];
+ invisibleParameterAnnotations = (List<AnnotationNode>[])new List<?>[params];
}
if (invisibleParameterAnnotations[parameter] == null) {
- invisibleParameterAnnotations[parameter] = new ArrayList(1);
+ invisibleParameterAnnotations[parameter] = new ArrayList<AnnotationNode>(1);
}
invisibleParameterAnnotations[parameter].add(an);
}
return an;
}
+ @Override
+ public void visitAttribute(final Attribute attr) {
+ if (attrs == null) {
+ attrs = new ArrayList<Attribute>(1);
+ }
+ attrs.add(attr);
+ }
+
+ @Override
public void visitCode() {
}
+ @Override
public void visitFrame(
final int type,
final int nLocal,
@@ -242,22 +344,27 @@ public class MethodNode extends MemberNode implements MethodVisitor {
: getLabelNodes(stack)));
}
+ @Override
public void visitInsn(final int opcode) {
instructions.add(new InsnNode(opcode));
}
+ @Override
public void visitIntInsn(final int opcode, final int operand) {
instructions.add(new IntInsnNode(opcode, operand));
}
+ @Override
public void visitVarInsn(final int opcode, final int var) {
instructions.add(new VarInsnNode(opcode, var));
}
+ @Override
public void visitTypeInsn(final int opcode, final String type) {
instructions.add(new TypeInsnNode(opcode, type));
}
+ @Override
public void visitFieldInsn(
final int opcode,
final String owner,
@@ -267,6 +374,7 @@ public class MethodNode extends MemberNode implements MethodVisitor {
instructions.add(new FieldInsnNode(opcode, owner, name, desc));
}
+ @Override
public void visitMethodInsn(
final int opcode,
final String owner,
@@ -276,27 +384,42 @@ public class MethodNode extends MemberNode implements MethodVisitor {
instructions.add(new MethodInsnNode(opcode, owner, name, desc));
}
+ @Override
+ public void visitInvokeDynamicInsn(
+ String name,
+ String desc,
+ Handle bsm,
+ Object... bsmArgs)
+ {
+ instructions.add(new InvokeDynamicInsnNode(name, desc, bsm, bsmArgs));
+ }
+
+ @Override
public void visitJumpInsn(final int opcode, final Label label) {
instructions.add(new JumpInsnNode(opcode, getLabelNode(label)));
}
+ @Override
public void visitLabel(final Label label) {
instructions.add(getLabelNode(label));
}
+ @Override
public void visitLdcInsn(final Object cst) {
instructions.add(new LdcInsnNode(cst));
}
+ @Override
public void visitIincInsn(final int var, final int increment) {
instructions.add(new IincInsnNode(var, increment));
}
+ @Override
public void visitTableSwitchInsn(
final int min,
final int max,
final Label dflt,
- final Label[] labels)
+ final Label... labels)
{
instructions.add(new TableSwitchInsnNode(min,
max,
@@ -304,6 +427,7 @@ public class MethodNode extends MemberNode implements MethodVisitor {
getLabelNodes(labels)));
}
+ @Override
public void visitLookupSwitchInsn(
final Label dflt,
final int[] keys,
@@ -314,10 +438,12 @@ public class MethodNode extends MemberNode implements MethodVisitor {
getLabelNodes(labels)));
}
+ @Override
public void visitMultiANewArrayInsn(final String desc, final int dims) {
instructions.add(new MultiANewArrayInsnNode(desc, dims));
}
+ @Override
public void visitTryCatchBlock(
final Label start,
final Label end,
@@ -330,6 +456,7 @@ public class MethodNode extends MemberNode implements MethodVisitor {
type));
}
+ @Override
public void visitLocalVariable(
final String name,
final String desc,
@@ -346,24 +473,30 @@ public class MethodNode extends MemberNode implements MethodVisitor {
index));
}
+ @Override
public void visitLineNumber(final int line, final Label start) {
instructions.add(new LineNumberNode(line, getLabelNode(start)));
}
+ @Override
public void visitMaxs(final int maxStack, final int maxLocals) {
this.maxStack = maxStack;
this.maxLocals = maxLocals;
}
+ @Override
+ public void visitEnd() {
+ }
+
/**
- * Returns the LabelNode corresponding to the given Label. Creates a new
+ * 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.
- */
+ */
protected LabelNode getLabelNode(final Label l) {
if (!(l.info instanceof LabelNode)) {
l.info = new LabelNode(l);
@@ -396,8 +529,20 @@ public class MethodNode extends MemberNode implements MethodVisitor {
// ------------------------------------------------------------------------
/**
+ * 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.
+ *
+ * @param api an ASM API version. Must be one of {@link Opcodes#ASM4}.
+ */
+ public void check(final int api) {
+ // nothing to do
+ }
+
+ /**
* Makes the given class visitor visit this method.
- *
+ *
* @param cv a class visitor.
*/
public void accept(final ClassVisitor cv) {
@@ -415,7 +560,7 @@ public class MethodNode extends MemberNode implements MethodVisitor {
/**
* Makes the given method visitor visit this method.
- *
+ *
* @param mv a method visitor.
*/
public void accept(final MethodVisitor mv) {
@@ -430,19 +575,19 @@ public class MethodNode extends MemberNode implements MethodVisitor {
}
n = visibleAnnotations == null ? 0 : visibleAnnotations.size();
for (i = 0; i < n; ++i) {
- AnnotationNode an = (AnnotationNode) visibleAnnotations.get(i);
+ AnnotationNode an = visibleAnnotations.get(i);
an.accept(mv.visitAnnotation(an.desc, true));
}
n = invisibleAnnotations == null ? 0 : invisibleAnnotations.size();
for (i = 0; i < n; ++i) {
- AnnotationNode an = (AnnotationNode) invisibleAnnotations.get(i);
+ AnnotationNode an = invisibleAnnotations.get(i);
an.accept(mv.visitAnnotation(an.desc, false));
}
n = visibleParameterAnnotations == null
? 0
: visibleParameterAnnotations.length;
for (i = 0; i < n; ++i) {
- List l = visibleParameterAnnotations[i];
+ List<?> l = visibleParameterAnnotations[i];
if (l == null) {
continue;
}
@@ -455,7 +600,7 @@ public class MethodNode extends MemberNode implements MethodVisitor {
? 0
: invisibleParameterAnnotations.length;
for (i = 0; i < n; ++i) {
- List l = invisibleParameterAnnotations[i];
+ List<?> l = invisibleParameterAnnotations[i];
if (l == null) {
continue;
}
@@ -464,9 +609,12 @@ public class MethodNode extends MemberNode implements MethodVisitor {
an.accept(mv.visitParameterAnnotation(i, an.desc, false));
}
}
+ if (visited) {
+ instructions.resetLabels();
+ }
n = attrs == null ? 0 : attrs.size();
for (i = 0; i < n; ++i) {
- mv.visitAttribute((Attribute) attrs.get(i));
+ mv.visitAttribute(attrs.get(i));
}
// visits the method's code
if (instructions.size() > 0) {
@@ -474,17 +622,18 @@ public class MethodNode extends MemberNode implements MethodVisitor {
// visits try catch blocks
n = tryCatchBlocks == null ? 0 : tryCatchBlocks.size();
for (i = 0; i < n; ++i) {
- ((TryCatchBlockNode) tryCatchBlocks.get(i)).accept(mv);
+ tryCatchBlocks.get(i).accept(mv);
}
// visits instructions
instructions.accept(mv);
// visits local variables
n = localVariables == null ? 0 : localVariables.size();
for (i = 0; i < n; ++i) {
- ((LocalVariableNode) localVariables.get(i)).accept(mv);
+ localVariables.get(i).accept(mv);
}
// visits maxs
mv.visitMaxs(maxStack, maxLocals);
+ visited = true;
}
mv.visitEnd();
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/MultiANewArrayInsnNode.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/MultiANewArrayInsnNode.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/MultiANewArrayInsnNode.java
index 113794c..d27837d 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/MultiANewArrayInsnNode.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/MultiANewArrayInsnNode.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,14 +29,14 @@
*/
package org.apache.tapestry5.internal.plastic.asm.tree;
-import java.util.Map;
-
import org.apache.tapestry5.internal.plastic.asm.MethodVisitor;
import org.apache.tapestry5.internal.plastic.asm.Opcodes;
+import java.util.Map;
+
/**
* A node that represents a MULTIANEWARRAY instruction.
- *
+ *
* @author Eric Bruneton
*/
public class MultiANewArrayInsnNode extends AbstractInsnNode {
@@ -53,7 +53,7 @@ public class MultiANewArrayInsnNode extends AbstractInsnNode {
/**
* Constructs a new {@link MultiANewArrayInsnNode}.
- *
+ *
* @param desc an array type descriptor (see {@link org.apache.tapestry5.internal.plastic.asm.Type}).
* @param dims number of dimensions of the array to allocate.
*/
@@ -63,15 +63,18 @@ public class MultiANewArrayInsnNode extends AbstractInsnNode {
this.dims = dims;
}
+ @Override
public int getType() {
return MULTIANEWARRAY_INSN;
}
+ @Override
public void accept(final MethodVisitor mv) {
mv.visitMultiANewArrayInsn(desc, dims);
}
- public AbstractInsnNode clone(final Map labels) {
+ @Override
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
return new MultiANewArrayInsnNode(desc, dims);
}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TableSwitchInsnNode.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TableSwitchInsnNode.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TableSwitchInsnNode.java
index 382288f..17ad4ec 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TableSwitchInsnNode.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TableSwitchInsnNode.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -40,7 +40,7 @@ import java.util.Map;
/**
* A node that represents a TABLESWITCH instruction.
- *
+ *
* @author Eric Bruneton
*/
public class TableSwitchInsnNode extends AbstractInsnNode {
@@ -64,11 +64,11 @@ public class TableSwitchInsnNode extends AbstractInsnNode {
* Beginnings of the handler blocks. This list is a list of
* {@link LabelNode} objects.
*/
- public List labels;
+ public List<LabelNode> labels;
/**
* Constructs a new {@link TableSwitchInsnNode}.
- *
+ *
* @param min the minimum key value.
* @param max the maximum key value.
* @param dflt beginning of the default handler block.
@@ -79,31 +79,34 @@ public class TableSwitchInsnNode extends AbstractInsnNode {
final int min,
final int max,
final LabelNode dflt,
- final LabelNode[] labels)
+ final LabelNode... labels)
{
super(Opcodes.TABLESWITCH);
this.min = min;
this.max = max;
this.dflt = dflt;
- this.labels = new ArrayList();
+ this.labels = new ArrayList<LabelNode>();
if (labels != null) {
this.labels.addAll(Arrays.asList(labels));
}
}
+ @Override
public int getType() {
return TABLESWITCH_INSN;
}
+ @Override
public void accept(final MethodVisitor mv) {
Label[] labels = new Label[this.labels.size()];
for (int i = 0; i < labels.length; ++i) {
- labels[i] = ((LabelNode) this.labels.get(i)).getLabel();
+ labels[i] = this.labels.get(i).getLabel();
}
mv.visitTableSwitchInsn(min, max, dflt.getLabel(), labels);
}
- public AbstractInsnNode clone(final Map labels) {
+ @Override
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
return new TableSwitchInsnNode(min,
max,
clone(dflt, labels),
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TryCatchBlockNode.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TryCatchBlockNode.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TryCatchBlockNode.java
index 62288ed..52ea45f 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TryCatchBlockNode.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TryCatchBlockNode.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -33,7 +33,7 @@ import org.apache.tapestry5.internal.plastic.asm.MethodVisitor;
/**
* A node that represents a try catch block.
- *
+ *
* @author Eric Bruneton
*/
public class TryCatchBlockNode {
@@ -61,7 +61,7 @@ public class TryCatchBlockNode {
/**
* 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.
@@ -83,7 +83,7 @@ public class TryCatchBlockNode {
/**
* Makes the given visitor visit this try catch block.
- *
+ *
* @param mv a method visitor.
*/
public void accept(final MethodVisitor mv) {
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TypeInsnNode.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TypeInsnNode.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TypeInsnNode.java
index 4bf4c43..e5bc30e 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TypeInsnNode.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/TypeInsnNode.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+ * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,14 +29,14 @@
*/
package org.apache.tapestry5.internal.plastic.asm.tree;
-import java.util.Map;
-
import org.apache.tapestry5.internal.plastic.asm.MethodVisitor;
+import java.util.Map;
+
/**
* A node that represents a type instruction. A type instruction is an
* instruction that takes a type descriptor as parameter.
- *
+ *
* @author Eric Bruneton
*/
public class TypeInsnNode extends AbstractInsnNode {
@@ -49,7 +49,7 @@ public class TypeInsnNode extends AbstractInsnNode {
/**
* Constructs a new {@link TypeInsnNode}.
- *
+ *
* @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
@@ -62,7 +62,7 @@ public class TypeInsnNode extends AbstractInsnNode {
/**
* Sets the opcode of this instruction.
- *
+ *
* @param opcode the new instruction opcode. This opcode must be NEW,
* ANEWARRAY, CHECKCAST or INSTANCEOF.
*/
@@ -70,15 +70,18 @@ public class TypeInsnNode extends AbstractInsnNode {
this.opcode = opcode;
}
+ @Override
public int getType() {
return TYPE_INSN;
}
+ @Override
public void accept(final MethodVisitor mv) {
mv.visitTypeInsn(opcode, desc);
}
- public AbstractInsnNode clone(final Map labels) {
+ @Override
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
return new TypeInsnNode(opcode, desc);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/VarInsnNode.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/VarInsnNode.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/VarInsnNode.java
index cddd163..3819d31 100644
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/VarInsnNode.java
+++ b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/VarInsnNode.java
@@ -1,6 +1,6 @@
/***
* ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 INRIA, France Telecom
+` * Copyright (c) 2000-2011 INRIA, France Telecom
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -29,15 +29,15 @@
*/
package org.apache.tapestry5.internal.plastic.asm.tree;
-import java.util.Map;
-
import org.apache.tapestry5.internal.plastic.asm.MethodVisitor;
+import java.util.Map;
+
/**
* A node that represents a local variable instruction. A local variable
* instruction is an instruction that loads or stores the value of a local
* variable.
- *
+ *
* @author Eric Bruneton
*/
public class VarInsnNode extends AbstractInsnNode {
@@ -50,7 +50,7 @@ public class VarInsnNode extends AbstractInsnNode {
/**
* Constructs a new {@link VarInsnNode}.
- *
+ *
* @param opcode the opcode of the local variable instruction to be
* constructed. This opcode must be ILOAD, LLOAD, FLOAD, DLOAD,
* ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE or RET.
@@ -64,7 +64,7 @@ public class VarInsnNode extends AbstractInsnNode {
/**
* Sets the opcode of this instruction.
- *
+ *
* @param opcode the new instruction opcode. This opcode must be ILOAD,
* LLOAD, FLOAD, DLOAD, ALOAD, ISTORE, LSTORE, FSTORE, DSTORE, ASTORE
* or RET.
@@ -73,15 +73,18 @@ public class VarInsnNode extends AbstractInsnNode {
this.opcode = opcode;
}
+ @Override
public int getType() {
return VAR_INSN;
}
+ @Override
public void accept(final MethodVisitor mv) {
mv.visitVarInsn(opcode, var);
}
- public AbstractInsnNode clone(final Map labels) {
+ @Override
+ public AbstractInsnNode clone(final Map<LabelNode, LabelNode> labels) {
return new VarInsnNode(opcode, var);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/Analyzer.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/Analyzer.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/Analyzer.java
deleted file mode 100644
index 47590d7..0000000
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/Analyzer.java
+++ /dev/null
@@ -1,523 +0,0 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 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.apache.tapestry5.internal.plastic.asm.tree.analysis;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.apache.tapestry5.internal.plastic.asm.Opcodes;
-import org.apache.tapestry5.internal.plastic.asm.Type;
-import org.apache.tapestry5.internal.plastic.asm.tree.AbstractInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.IincInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.InsnList;
-import org.apache.tapestry5.internal.plastic.asm.tree.JumpInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.LabelNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.LookupSwitchInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.MethodNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.TableSwitchInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.TryCatchBlockNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.VarInsnNode;
-
-/**
- * A semantic bytecode analyzer. <i>This class does not fully check that JSR and
- * RET instructions are valid.</i>
- *
- * @author Eric Bruneton
- */
-public class Analyzer implements Opcodes {
-
- private final Interpreter interpreter;
-
- private int n;
-
- private InsnList insns;
-
- private List[] handlers;
-
- private Frame[] frames;
-
- private Subroutine[] subroutines;
-
- private boolean[] queued;
-
- private int[] queue;
-
- private int top;
-
- /**
- * Constructs a new {@link Analyzer}.
- *
- * @param interpreter the interpreter to be used to symbolically interpret
- * the bytecode instructions.
- */
- public Analyzer(final Interpreter interpreter) {
- this.interpreter = interpreter;
- }
-
- /**
- * Analyzes the given method.
- *
- * @param owner the internal name of the class to which the method belongs.
- * @param m the method to be analyzed.
- * @return the symbolic state of the execution stack frame at each bytecode
- * instruction of the method. The size of the returned array is
- * equal to the number of instructions (and labels) of the method. A
- * given frame is <tt>null</tt> if and only if the corresponding
- * instruction cannot be reached (dead code).
- * @throws AnalyzerException if a problem occurs during the analysis.
- */
- public Frame[] analyze(final String owner, final MethodNode m)
- throws AnalyzerException
- {
- if ((m.access & (ACC_ABSTRACT | ACC_NATIVE)) != 0) {
- frames = new Frame[0];
- return frames;
- }
- n = m.instructions.size();
- insns = m.instructions;
- handlers = new List[n];
- frames = new Frame[n];
- subroutines = new Subroutine[n];
- queued = new boolean[n];
- queue = new int[n];
- top = 0;
-
- // computes exception handlers for each instruction
- for (int i = 0; i < m.tryCatchBlocks.size(); ++i) {
- TryCatchBlockNode tcb = (TryCatchBlockNode) m.tryCatchBlocks.get(i);
- int begin = insns.indexOf(tcb.start);
- int end = insns.indexOf(tcb.end);
- for (int j = begin; j < end; ++j) {
- List insnHandlers = handlers[j];
- if (insnHandlers == null) {
- insnHandlers = new ArrayList();
- handlers[j] = insnHandlers;
- }
- insnHandlers.add(tcb);
- }
- }
-
- // computes the subroutine for each instruction:
- Subroutine main = new Subroutine(null, m.maxLocals, null);
- List subroutineCalls = new ArrayList();
- Map subroutineHeads = new HashMap();
- findSubroutine(0, main, subroutineCalls);
- while (!subroutineCalls.isEmpty()) {
- JumpInsnNode jsr = (JumpInsnNode) subroutineCalls.remove(0);
- Subroutine sub = (Subroutine) subroutineHeads.get(jsr.label);
- if (sub == null) {
- sub = new Subroutine(jsr.label, m.maxLocals, jsr);
- subroutineHeads.put(jsr.label, sub);
- findSubroutine(insns.indexOf(jsr.label), sub, subroutineCalls);
- } else {
- sub.callers.add(jsr);
- }
- }
- for (int i = 0; i < n; ++i) {
- if (subroutines[i] != null && subroutines[i].start == null) {
- subroutines[i] = null;
- }
- }
-
- // initializes the data structures for the control flow analysis
- Frame current = newFrame(m.maxLocals, m.maxStack);
- Frame handler = newFrame(m.maxLocals, m.maxStack);
- current.setReturn(interpreter.newValue(Type.getReturnType(m.desc)));
- Type[] args = Type.getArgumentTypes(m.desc);
- int local = 0;
- if ((m.access & ACC_STATIC) == 0) {
- Type ctype = Type.getObjectType(owner);
- current.setLocal(local++, interpreter.newValue(ctype));
- }
- for (int i = 0; i < args.length; ++i) {
- current.setLocal(local++, interpreter.newValue(args[i]));
- if (args[i].getSize() == 2) {
- current.setLocal(local++, interpreter.newValue(null));
- }
- }
- while (local < m.maxLocals) {
- current.setLocal(local++, interpreter.newValue(null));
- }
- merge(0, current, null);
-
- init(owner, m);
-
- // control flow analysis
- while (top > 0) {
- int insn = queue[--top];
- Frame f = frames[insn];
- Subroutine subroutine = subroutines[insn];
- queued[insn] = false;
-
- AbstractInsnNode insnNode = null;
- try {
- insnNode = m.instructions.get(insn);
- int insnOpcode = insnNode.getOpcode();
- int insnType = insnNode.getType();
-
- if (insnType == AbstractInsnNode.LABEL
- || insnType == AbstractInsnNode.LINE
- || insnType == AbstractInsnNode.FRAME)
- {
- merge(insn + 1, f, subroutine);
- newControlFlowEdge(insn, insn + 1);
- } else {
- current.init(f).execute(insnNode, interpreter);
- subroutine = subroutine == null ? null : subroutine.copy();
-
- if (insnNode instanceof JumpInsnNode) {
- JumpInsnNode j = (JumpInsnNode) insnNode;
- if (insnOpcode != GOTO && insnOpcode != JSR) {
- merge(insn + 1, current, subroutine);
- newControlFlowEdge(insn, insn + 1);
- }
- int jump = insns.indexOf(j.label);
- if (insnOpcode == JSR) {
- merge(jump, current, new Subroutine(j.label,
- m.maxLocals,
- j));
- } else {
- merge(jump, current, subroutine);
- }
- newControlFlowEdge(insn, jump);
- } else if (insnNode instanceof LookupSwitchInsnNode) {
- LookupSwitchInsnNode lsi = (LookupSwitchInsnNode) insnNode;
- int jump = insns.indexOf(lsi.dflt);
- merge(jump, current, subroutine);
- newControlFlowEdge(insn, jump);
- for (int j = 0; j < lsi.labels.size(); ++j) {
- LabelNode label = (LabelNode) lsi.labels.get(j);
- jump = insns.indexOf(label);
- merge(jump, current, subroutine);
- newControlFlowEdge(insn, jump);
- }
- } else if (insnNode instanceof TableSwitchInsnNode) {
- TableSwitchInsnNode tsi = (TableSwitchInsnNode) insnNode;
- int jump = insns.indexOf(tsi.dflt);
- merge(jump, current, subroutine);
- newControlFlowEdge(insn, jump);
- for (int j = 0; j < tsi.labels.size(); ++j) {
- LabelNode label = (LabelNode) tsi.labels.get(j);
- jump = insns.indexOf(label);
- merge(jump, current, subroutine);
- newControlFlowEdge(insn, jump);
- }
- } else if (insnOpcode == RET) {
- if (subroutine == null) {
- throw new AnalyzerException(insnNode, "RET instruction outside of a sub routine");
- }
- for (int i = 0; i < subroutine.callers.size(); ++i) {
- Object caller = subroutine.callers.get(i);
- int call = insns.indexOf((AbstractInsnNode) caller);
- if (frames[call] != null) {
- merge(call + 1,
- frames[call],
- current,
- subroutines[call],
- subroutine.access);
- newControlFlowEdge(insn, call + 1);
- }
- }
- } else if (insnOpcode != ATHROW
- && (insnOpcode < IRETURN || insnOpcode > RETURN))
- {
- if (subroutine != null) {
- if (insnNode instanceof VarInsnNode) {
- int var = ((VarInsnNode) insnNode).var;
- subroutine.access[var] = true;
- if (insnOpcode == LLOAD || insnOpcode == DLOAD
- || insnOpcode == LSTORE
- || insnOpcode == DSTORE)
- {
- subroutine.access[var + 1] = true;
- }
- } else if (insnNode instanceof IincInsnNode) {
- int var = ((IincInsnNode) insnNode).var;
- subroutine.access[var] = true;
- }
- }
- merge(insn + 1, current, subroutine);
- newControlFlowEdge(insn, insn + 1);
- }
- }
-
- List insnHandlers = handlers[insn];
- if (insnHandlers != null) {
- for (int i = 0; i < insnHandlers.size(); ++i) {
- TryCatchBlockNode tcb = (TryCatchBlockNode) insnHandlers.get(i);
- Type type;
- if (tcb.type == null) {
- type = Type.getObjectType("java/lang/Throwable");
- } else {
- type = Type.getObjectType(tcb.type);
- }
- int jump = insns.indexOf(tcb.handler);
- if (newControlFlowExceptionEdge(insn, jump)) {
- handler.init(f);
- handler.clearStack();
- handler.push(interpreter.newValue(type));
- merge(jump, handler, subroutine);
- }
- }
- }
- } catch (AnalyzerException e) {
- throw new AnalyzerException(e.node, "Error at instruction " + insn
- + ": " + e.getMessage(), e);
- } catch (Exception e) {
- throw new AnalyzerException(insnNode, "Error at instruction " + insn
- + ": " + e.getMessage(), e);
- }
- }
-
- return frames;
- }
-
- private void findSubroutine(int insn, final Subroutine sub, final List calls)
- throws AnalyzerException
- {
- while (true) {
- if (insn < 0 || insn >= n) {
- throw new AnalyzerException(null, "Execution can fall off end of the code");
- }
- if (subroutines[insn] != null) {
- return;
- }
- subroutines[insn] = sub.copy();
- AbstractInsnNode node = insns.get(insn);
-
- // calls findSubroutine recursively on normal successors
- if (node instanceof JumpInsnNode) {
- if (node.getOpcode() == JSR) {
- // do not follow a JSR, it leads to another subroutine!
- calls.add(node);
- } else {
- JumpInsnNode jnode = (JumpInsnNode) node;
- findSubroutine(insns.indexOf(jnode.label), sub, calls);
- }
- } else if (node instanceof TableSwitchInsnNode) {
- TableSwitchInsnNode tsnode = (TableSwitchInsnNode) node;
- findSubroutine(insns.indexOf(tsnode.dflt), sub, calls);
- for (int i = tsnode.labels.size() - 1; i >= 0; --i) {
- LabelNode l = (LabelNode) tsnode.labels.get(i);
- findSubroutine(insns.indexOf(l), sub, calls);
- }
- } else if (node instanceof LookupSwitchInsnNode) {
- LookupSwitchInsnNode lsnode = (LookupSwitchInsnNode) node;
- findSubroutine(insns.indexOf(lsnode.dflt), sub, calls);
- for (int i = lsnode.labels.size() - 1; i >= 0; --i) {
- LabelNode l = (LabelNode) lsnode.labels.get(i);
- findSubroutine(insns.indexOf(l), sub, calls);
- }
- }
-
- // calls findSubroutine recursively on exception handler successors
- List insnHandlers = handlers[insn];
- if (insnHandlers != null) {
- for (int i = 0; i < insnHandlers.size(); ++i) {
- TryCatchBlockNode tcb = (TryCatchBlockNode) insnHandlers.get(i);
- findSubroutine(insns.indexOf(tcb.handler), sub, calls);
- }
- }
-
- // if insn does not falls through to the next instruction, return.
- switch (node.getOpcode()) {
- case GOTO:
- case RET:
- case TABLESWITCH:
- case LOOKUPSWITCH:
- case IRETURN:
- case LRETURN:
- case FRETURN:
- case DRETURN:
- case ARETURN:
- case RETURN:
- case ATHROW:
- return;
- }
- insn++;
- }
- }
-
- /**
- * Returns the symbolic stack frame for each instruction of the last
- * recently analyzed method.
- *
- * @return the symbolic state of the execution stack frame at each bytecode
- * instruction of the method. The size of the returned array is
- * equal to the number of instructions (and labels) of the method. A
- * given frame is <tt>null</tt> if the corresponding instruction
- * cannot be reached, or if an error occured during the analysis of
- * the method.
- */
- public Frame[] getFrames() {
- return frames;
- }
-
- /**
- * Returns the exception handlers for the given instruction.
- *
- * @param insn the index of an instruction of the last recently analyzed
- * method.
- * @return a list of {@link TryCatchBlockNode} objects.
- */
- public List getHandlers(final int insn) {
- return handlers[insn];
- }
-
- /**
- * Initializes this analyzer. This method is called just before the
- * execution of control flow analysis loop in #analyze. The default
- * implementation of this method does nothing.
- *
- * @param owner the internal name of the class to which the method belongs.
- * @param m the method to be analyzed.
- * @throws AnalyzerException if a problem occurs.
- */
- protected void init(String owner, MethodNode m) throws AnalyzerException {
- }
-
- /**
- * Constructs a new frame with the given size.
- *
- * @param nLocals the maximum number of local variables of the frame.
- * @param nStack the maximum stack size of the frame.
- * @return the created frame.
- */
- protected Frame newFrame(final int nLocals, final int nStack) {
- return new Frame(nLocals, nStack);
- }
-
- /**
- * Constructs a new frame that is identical to the given frame.
- *
- * @param src a frame.
- * @return the created frame.
- */
- protected Frame newFrame(final Frame src) {
- return new Frame(src);
- }
-
- /**
- * Creates a control flow graph edge. The default implementation of this
- * method does nothing. It can be overriden in order to construct the
- * control flow graph of a method (this method is called by the
- * {@link #analyze analyze} method during its visit of the method's code).
- *
- * @param insn an instruction index.
- * @param successor index of a successor instruction.
- */
- protected void newControlFlowEdge(final int insn, final int successor) {
- }
-
- /**
- * Creates a control flow graph edge corresponding to an exception handler.
- * The default implementation of this method does nothing. It can be
- * overriden in order to construct the control flow graph of a method (this
- * method is called by the {@link #analyze analyze} method during its visit
- * of the method's code).
- *
- * @param insn an instruction index.
- * @param successor index of a successor instruction.
- * @return true if this edge must be considered in the data flow analysis
- * performed by this analyzer, or false otherwise. The default
- * implementation of this method always returns true.
- */
- protected boolean newControlFlowExceptionEdge(
- final int insn,
- final int successor)
- {
- return true;
- }
-
- // -------------------------------------------------------------------------
-
- private void merge(
- final int insn,
- final Frame frame,
- final Subroutine subroutine) throws AnalyzerException
- {
- Frame oldFrame = frames[insn];
- Subroutine oldSubroutine = subroutines[insn];
- boolean changes;
-
- if (oldFrame == null) {
- frames[insn] = newFrame(frame);
- changes = true;
- } else {
- changes = oldFrame.merge(frame, interpreter);
- }
-
- if (oldSubroutine == null) {
- if (subroutine != null) {
- subroutines[insn] = subroutine.copy();
- changes = true;
- }
- } else {
- if (subroutine != null) {
- changes |= oldSubroutine.merge(subroutine);
- }
- }
- if (changes && !queued[insn]) {
- queued[insn] = true;
- queue[top++] = insn;
- }
- }
-
- private void merge(
- final int insn,
- final Frame beforeJSR,
- final Frame afterRET,
- final Subroutine subroutineBeforeJSR,
- final boolean[] access) throws AnalyzerException
- {
- Frame oldFrame = frames[insn];
- Subroutine oldSubroutine = subroutines[insn];
- boolean changes;
-
- afterRET.merge(beforeJSR, access);
-
- if (oldFrame == null) {
- frames[insn] = newFrame(afterRET);
- changes = true;
- } else {
- changes = oldFrame.merge(afterRET, access);
- }
-
- if (oldSubroutine != null && subroutineBeforeJSR != null) {
- changes |= oldSubroutine.merge(subroutineBeforeJSR);
- }
- if (changes && !queued[insn]) {
- queued[insn] = true;
- queue[top++] = insn;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/AnalyzerException.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/AnalyzerException.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/AnalyzerException.java
deleted file mode 100644
index c591018..0000000
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/AnalyzerException.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 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.apache.tapestry5.internal.plastic.asm.tree.analysis;
-
-import org.apache.tapestry5.internal.plastic.asm.tree.AbstractInsnNode;
-
-/**
- * Thrown if a problem occurs during the analysis of a method.
- *
- * @author Bing Ran
- * @author Eric Bruneton
- */
-public class AnalyzerException extends Exception {
-
- public final AbstractInsnNode node;
-
- public AnalyzerException(final AbstractInsnNode node, final String msg) {
- super(msg);
- this.node = node;
- }
-
- public AnalyzerException(final AbstractInsnNode node, final String msg, final Throwable exception) {
- super(msg, exception);
- this.node = node;
- }
-
- public AnalyzerException(
- final AbstractInsnNode node,
- final String msg,
- final Object expected,
- final Value encountered)
- {
- super((msg == null ? "Expected " : msg + ": expected ") + expected
- + ", but found " + encountered);
- this.node = node;
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/BasicInterpreter.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/BasicInterpreter.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/BasicInterpreter.java
deleted file mode 100644
index 26f6749..0000000
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/BasicInterpreter.java
+++ /dev/null
@@ -1,330 +0,0 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 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.apache.tapestry5.internal.plastic.asm.tree.analysis;
-
-import java.util.List;
-
-import org.apache.tapestry5.internal.plastic.asm.Opcodes;
-import org.apache.tapestry5.internal.plastic.asm.Type;
-import org.apache.tapestry5.internal.plastic.asm.tree.AbstractInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.FieldInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.IntInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.LdcInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.MethodInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.MultiANewArrayInsnNode;
-import org.apache.tapestry5.internal.plastic.asm.tree.TypeInsnNode;
-
-/**
- * An {@link Interpreter} for {@link BasicValue} values.
- *
- * @author Eric Bruneton
- * @author Bing Ran
- */
-public class BasicInterpreter implements Opcodes, Interpreter {
-
- public Value newValue(final Type type) {
- if (type == null) {
- return BasicValue.UNINITIALIZED_VALUE;
- }
- switch (type.getSort()) {
- case Type.VOID:
- return null;
- case Type.BOOLEAN:
- case Type.CHAR:
- case Type.BYTE:
- case Type.SHORT:
- case Type.INT:
- return BasicValue.INT_VALUE;
- case Type.FLOAT:
- return BasicValue.FLOAT_VALUE;
- case Type.LONG:
- return BasicValue.LONG_VALUE;
- case Type.DOUBLE:
- return BasicValue.DOUBLE_VALUE;
- case Type.ARRAY:
- case Type.OBJECT:
- return BasicValue.REFERENCE_VALUE;
- default:
- throw new Error("Internal error");
- }
- }
-
- public Value newOperation(final AbstractInsnNode insn)
- throws AnalyzerException
- {
- switch (insn.getOpcode()) {
- case ACONST_NULL:
- return newValue(Type.getObjectType("null"));
- case ICONST_M1:
- case ICONST_0:
- case ICONST_1:
- case ICONST_2:
- case ICONST_3:
- case ICONST_4:
- case ICONST_5:
- return BasicValue.INT_VALUE;
- case LCONST_0:
- case LCONST_1:
- return BasicValue.LONG_VALUE;
- case FCONST_0:
- case FCONST_1:
- case FCONST_2:
- return BasicValue.FLOAT_VALUE;
- case DCONST_0:
- case DCONST_1:
- return BasicValue.DOUBLE_VALUE;
- case BIPUSH:
- case SIPUSH:
- return BasicValue.INT_VALUE;
- case LDC:
- Object cst = ((LdcInsnNode) insn).cst;
- if (cst instanceof Integer) {
- return BasicValue.INT_VALUE;
- } else if (cst instanceof Float) {
- return BasicValue.FLOAT_VALUE;
- } else if (cst instanceof Long) {
- return BasicValue.LONG_VALUE;
- } else if (cst instanceof Double) {
- return BasicValue.DOUBLE_VALUE;
- } else if (cst instanceof Type) {
- return newValue(Type.getObjectType("java/lang/Class"));
- } else {
- return newValue(Type.getType(cst.getClass()));
- }
- case JSR:
- return BasicValue.RETURNADDRESS_VALUE;
- case GETSTATIC:
- return newValue(Type.getType(((FieldInsnNode) insn).desc));
- case NEW:
- return newValue(Type.getObjectType(((TypeInsnNode) insn).desc));
- default:
- throw new Error("Internal error.");
- }
- }
-
- public Value copyOperation(final AbstractInsnNode insn, final Value value)
- throws AnalyzerException
- {
- return value;
- }
-
- public Value unaryOperation(final AbstractInsnNode insn, final Value value)
- throws AnalyzerException
- {
- switch (insn.getOpcode()) {
- case INEG:
- case IINC:
- case L2I:
- case F2I:
- case D2I:
- case I2B:
- case I2C:
- case I2S:
- return BasicValue.INT_VALUE;
- case FNEG:
- case I2F:
- case L2F:
- case D2F:
- return BasicValue.FLOAT_VALUE;
- case LNEG:
- case I2L:
- case F2L:
- case D2L:
- return BasicValue.LONG_VALUE;
- case DNEG:
- case I2D:
- case L2D:
- case F2D:
- return BasicValue.DOUBLE_VALUE;
- case IFEQ:
- case IFNE:
- case IFLT:
- case IFGE:
- case IFGT:
- case IFLE:
- case TABLESWITCH:
- case LOOKUPSWITCH:
- case IRETURN:
- case LRETURN:
- case FRETURN:
- case DRETURN:
- case ARETURN:
- case PUTSTATIC:
- return null;
- case GETFIELD:
- return newValue(Type.getType(((FieldInsnNode) insn).desc));
- case NEWARRAY:
- switch (((IntInsnNode) insn).operand) {
- case T_BOOLEAN:
- return newValue(Type.getType("[Z"));
- case T_CHAR:
- return newValue(Type.getType("[C"));
- case T_BYTE:
- return newValue(Type.getType("[B"));
- case T_SHORT:
- return newValue(Type.getType("[S"));
- case T_INT:
- return newValue(Type.getType("[I"));
- case T_FLOAT:
- return newValue(Type.getType("[F"));
- case T_DOUBLE:
- return newValue(Type.getType("[D"));
- case T_LONG:
- return newValue(Type.getType("[J"));
- default:
- throw new AnalyzerException(insn, "Invalid array type");
- }
- case ANEWARRAY:
- String desc = ((TypeInsnNode) insn).desc;
- return newValue(Type.getType("[" + Type.getObjectType(desc)));
- case ARRAYLENGTH:
- return BasicValue.INT_VALUE;
- case ATHROW:
- return null;
- case CHECKCAST:
- desc = ((TypeInsnNode) insn).desc;
- return newValue(Type.getObjectType(desc));
- case INSTANCEOF:
- return BasicValue.INT_VALUE;
- case MONITORENTER:
- case MONITOREXIT:
- case IFNULL:
- case IFNONNULL:
- return null;
- default:
- throw new Error("Internal error.");
- }
- }
-
- public Value binaryOperation(
- final AbstractInsnNode insn,
- final Value value1,
- final Value value2) throws AnalyzerException
- {
- switch (insn.getOpcode()) {
- case IALOAD:
- case BALOAD:
- case CALOAD:
- case SALOAD:
- case IADD:
- case ISUB:
- case IMUL:
- case IDIV:
- case IREM:
- case ISHL:
- case ISHR:
- case IUSHR:
- case IAND:
- case IOR:
- case IXOR:
- return BasicValue.INT_VALUE;
- case FALOAD:
- case FADD:
- case FSUB:
- case FMUL:
- case FDIV:
- case FREM:
- return BasicValue.FLOAT_VALUE;
- case LALOAD:
- case LADD:
- case LSUB:
- case LMUL:
- case LDIV:
- case LREM:
- case LSHL:
- case LSHR:
- case LUSHR:
- case LAND:
- case LOR:
- case LXOR:
- return BasicValue.LONG_VALUE;
- case DALOAD:
- case DADD:
- case DSUB:
- case DMUL:
- case DDIV:
- case DREM:
- return BasicValue.DOUBLE_VALUE;
- case AALOAD:
- return BasicValue.REFERENCE_VALUE;
- case LCMP:
- case FCMPL:
- case FCMPG:
- case DCMPL:
- case DCMPG:
- return BasicValue.INT_VALUE;
- case IF_ICMPEQ:
- case IF_ICMPNE:
- case IF_ICMPLT:
- case IF_ICMPGE:
- case IF_ICMPGT:
- case IF_ICMPLE:
- case IF_ACMPEQ:
- case IF_ACMPNE:
- case PUTFIELD:
- return null;
- default:
- throw new Error("Internal error.");
- }
- }
-
- public Value ternaryOperation(
- final AbstractInsnNode insn,
- final Value value1,
- final Value value2,
- final Value value3) throws AnalyzerException
- {
- return null;
- }
-
- public Value naryOperation(final AbstractInsnNode insn, final List values)
- throws AnalyzerException
- {
- if (insn.getOpcode() == MULTIANEWARRAY) {
- return newValue(Type.getType(((MultiANewArrayInsnNode) insn).desc));
- } else {
- return newValue(Type.getReturnType(((MethodInsnNode) insn).desc));
- }
- }
-
- public void returnOperation(
- final AbstractInsnNode insn,
- final Value value,
- final Value expected) throws AnalyzerException
- {
- }
-
- public Value merge(final Value v, final Value w) {
- if (!v.equals(w)) {
- return BasicValue.UNINITIALIZED_VALUE;
- }
- return v;
- }
-}
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/d6e5f413/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/BasicValue.java
----------------------------------------------------------------------
diff --git a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/BasicValue.java b/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/BasicValue.java
deleted file mode 100644
index c436cb0..0000000
--- a/plastic/src/external/java/org/apache/tapestry5/internal/plastic/asm/tree/analysis/BasicValue.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/***
- * ASM: a very small and fast Java bytecode manipulation framework
- * Copyright (c) 2000-2007 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.apache.tapestry5.internal.plastic.asm.tree.analysis;
-
-import org.apache.tapestry5.internal.plastic.asm.Type;
-
-/**
- * A {@link Value} that is represented by its type in a seven types type system.
- * This type system distinguishes the UNINITIALZED, INT, FLOAT, LONG, DOUBLE,
- * REFERENCE and RETURNADDRESS types.
- *
- * @author Eric Bruneton
- */
-public class BasicValue implements Value {
-
- public static final Value UNINITIALIZED_VALUE = new BasicValue(null);
-
- public static final Value INT_VALUE = new BasicValue(Type.INT_TYPE);
-
- public static final Value FLOAT_VALUE = new BasicValue(Type.FLOAT_TYPE);
-
- public static final Value LONG_VALUE = new BasicValue(Type.LONG_TYPE);
-
- public static final Value DOUBLE_VALUE = new BasicValue(Type.DOUBLE_TYPE);
-
- public static final Value REFERENCE_VALUE = new BasicValue(Type.getObjectType("java/lang/Object"));
-
- public static final Value RETURNADDRESS_VALUE = new BasicValue(Type.VOID_TYPE);
-
- private final Type type;
-
- public BasicValue(final Type type) {
- this.type = type;
- }
-
- public Type getType() {
- return type;
- }
-
- public int getSize() {
- return type == Type.LONG_TYPE || type == Type.DOUBLE_TYPE ? 2 : 1;
- }
-
- public boolean isReference() {
- return type != null
- && (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY);
- }
-
- public boolean equals(final Object value) {
- if (value == this) {
- return true;
- } else if (value instanceof BasicValue) {
- if (type == null) {
- return ((BasicValue) value).type == null;
- } else {
- return type.equals(((BasicValue) value).type);
- }
- } else {
- return false;
- }
- }
-
- public int hashCode() {
- return type == null ? 0 : type.hashCode();
- }
-
- public String toString() {
- if (this == UNINITIALIZED_VALUE) {
- return ".";
- } else if (this == RETURNADDRESS_VALUE) {
- return "A";
- } else if (this == REFERENCE_VALUE) {
- return "R";
- } else {
- return type.getDescriptor();
- }
- }
-}