summaryrefslogtreecommitdiffstats
path: root/bcel-builder/verifier-src
diff options
context:
space:
mode:
authoraclement <aclement>2009-09-09 19:56:20 +0000
committeraclement <aclement>2009-09-09 19:56:20 +0000
commit0a395eb90a627aa707ea289ec42a5dc242d9716d (patch)
tree89a7e5dafed6c158a159cd94cbeee8c5be2da52b /bcel-builder/verifier-src
parent1931657e1b26dbef861bb8e330ef9ae6e282f241 (diff)
downloadaspectj-0a395eb90a627aa707ea289ec42a5dc242d9716d.tar.gz
aspectj-0a395eb90a627aa707ea289ec42a5dc242d9716d.zip
Java5 upgrades
Diffstat (limited to 'bcel-builder/verifier-src')
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java4
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/PassVerifier.java6
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/Verifier.java18
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactory.java14
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java9
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/IntList.java6
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java10
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java22
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java30
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java15
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java6
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java12
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java40
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java65
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELFactory.java10
-rw-r--r--bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/InstructionFinder.java22
16 files changed, 146 insertions, 143 deletions
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java
index 2e77bd2a4..3130e6667 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/DescendingVisitor.java
@@ -105,13 +105,13 @@ import org.aspectj.apache.bcel.classfile.annotation.RuntimeVisibleParameterAnnot
* class supplies the traversal strategy, other classes can make use
* of it.
*
- * @version $Id: DescendingVisitor.java,v 1.2 2008/05/28 23:53:00 aclement Exp $
+ * @version $Id: DescendingVisitor.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
public class DescendingVisitor implements ClassVisitor {
private JavaClass clazz;
private ClassVisitor visitor;
- private Stack stack = new Stack();
+ private Stack<Object> stack = new Stack<Object>();
/** @return container of current entitity, i.e., predecessor during traversal
*/
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/PassVerifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/PassVerifier.java
index 236b618e2..20aa49963 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/PassVerifier.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/PassVerifier.java
@@ -77,7 +77,7 @@ import java.util.ArrayList;
* That means, if you really want a new verification run of a certain
* pass you must use a new instance of a given PassVerifier.
*
- * @version $Id: PassVerifier.java,v 1.2 2008/05/28 23:53:00 aclement Exp $
+ * @version $Id: PassVerifier.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see org.aspectj.apache.bcel.verifier.Verifier
* @see #verify()
@@ -85,7 +85,7 @@ import java.util.ArrayList;
public abstract class PassVerifier{
/** The (warning) messages. */
- private ArrayList messages = new ArrayList(); //Type of elements: String
+ private ArrayList<String> messages = new ArrayList<String>(); //Type of elements: String
/** The VerificationResult cache. */
private VerificationResult verificationResult = null;
@@ -136,7 +136,7 @@ public abstract class PassVerifier{
verify(); // create messages if not already done (cached!)
String[] ret = new String[messages.size()];
for (int i=0; i<messages.size(); i++){
- ret[i] = (String) messages.get(i);
+ ret[i] = messages.get(i);
}
return ret;
}
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/Verifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/Verifier.java
index 25ce76c0b..150a07ec5 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/Verifier.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/Verifier.java
@@ -75,7 +75,7 @@ import org.aspectj.apache.bcel.verifier.structurals.Pass3bVerifier;
* A Verifier creates PassVerifier instances to perform the actual verification.
* Verifier instances are usually generated by the VerifierFactory.
*
- * @version $Id: Verifier.java,v 1.2 2008/05/28 23:53:01 aclement Exp $
+ * @version $Id: Verifier.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see org.aspectj.apache.bcel.verifier.VerifierFactory
* @see org.aspectj.apache.bcel.verifier.PassVerifier
@@ -91,9 +91,9 @@ public class Verifier{
/** A Pass2Verifier for this Verifier instance. */
private Pass2Verifier p2v;
/** The Pass3aVerifiers for this Verifier instance. Key: Interned string specifying the method number. */
- private HashMap p3avs = new HashMap();
+ private HashMap<String, Pass3aVerifier> p3avs = new HashMap<String, Pass3aVerifier>();
/** The Pass3bVerifiers for this Verifier instance. Key: Interned string specifying the method number. */
- private HashMap p3bvs = new HashMap();
+ private HashMap<String, Pass3bVerifier> p3bvs = new HashMap<String, Pass3bVerifier>();
/** Returns the VerificationResult for the given pass. */
public VerificationResult doPass1(){
@@ -115,7 +115,7 @@ public class Verifier{
public VerificationResult doPass3a(int method_no){
String key = Integer.toString(method_no);
Pass3aVerifier p3av;
- p3av = (Pass3aVerifier) (p3avs.get(key));
+ p3av = (p3avs.get(key));
if (p3avs.get(key) == null){
p3av = new Pass3aVerifier(this, method_no);
p3avs.put(key, p3av);
@@ -127,7 +127,7 @@ public class Verifier{
public VerificationResult doPass3b(int method_no){
String key = Integer.toString(method_no);
Pass3bVerifier p3bv;
- p3bv = (Pass3bVerifier) (p3bvs.get(key));
+ p3bv = (p3bvs.get(key));
if (p3bvs.get(key) == null){
p3bv = new Pass3bVerifier(this, method_no);
p3bvs.put(key, p3bv);
@@ -189,9 +189,9 @@ public class Verifier{
messages.add("Pass 2: "+p2m[i]);
}
}
- Iterator p3as = p3avs.values().iterator();
+ Iterator<Pass3aVerifier> p3as = p3avs.values().iterator();
while (p3as.hasNext()){
- Pass3aVerifier pv = (Pass3aVerifier) p3as.next();
+ Pass3aVerifier pv = p3as.next();
String[] p3am = pv.getMessages();
int meth = pv.getMethodNo();
for (int i=0; i<p3am.length; i++){
@@ -203,9 +203,9 @@ public class Verifier{
"'): "+p3am[i]);
}
}
- Iterator p3bs = p3bvs.values().iterator();
+ Iterator<Pass3bVerifier> p3bs = p3bvs.values().iterator();
while (p3bs.hasNext()){
- Pass3bVerifier pv = (Pass3bVerifier) p3bs.next();
+ Pass3bVerifier pv = p3bs.next();
String[] p3bm = pv.getMessages();
int meth = pv.getMethodNo();
for (int i=0; i<p3bm.length; i++){
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactory.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactory.java
index 9f45c39f8..9fab69b1f 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactory.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactory.java
@@ -64,7 +64,7 @@ import java.util.Vector;
* operate on. That means, for every class (represented by a unique fully qualified
* class name) there is exactly one Verifier.
*
- * @version $Id: VerifierFactory.java,v 1.2 2008/05/28 23:53:00 aclement Exp $
+ * @version $Id: VerifierFactory.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see org.aspectj.apache.bcel.verifier.Verifier
*/
@@ -73,12 +73,12 @@ public class VerifierFactory{
/**
* The HashMap that holds the data about the already-constructed Verifier instances.
*/
- private static HashMap hashMap = new HashMap();
+ private static HashMap<String, Verifier> hashMap = new HashMap<String, Verifier>();
/**
* The VerifierFactoryObserver instances that observe the VerifierFactory.
*/
- private static Vector observers = new Vector();
+ private static Vector<VerifierFactoryObserver> observers = new Vector<VerifierFactoryObserver>();
/**
* The VerifierFactory is not instantiable.
@@ -93,7 +93,7 @@ public class VerifierFactory{
public static Verifier getVerifier(String fully_qualified_classname){
// fully_qualified_classname = fully_qualified_classname;
- Verifier v = (Verifier) (hashMap.get(fully_qualified_classname));
+ Verifier v = (hashMap.get(fully_qualified_classname));
if (v==null){
v = new Verifier(fully_qualified_classname);
hashMap.put(fully_qualified_classname, v);
@@ -108,9 +108,9 @@ public class VerifierFactory{
*/
private static void notify(String fully_qualified_classname){
// notify the observers
- Iterator i = observers.iterator();
+ Iterator<VerifierFactoryObserver> i = observers.iterator();
while (i.hasNext()){
- VerifierFactoryObserver vfo = (VerifierFactoryObserver) i.next();
+ VerifierFactoryObserver vfo = i.next();
vfo.update(fully_qualified_classname);
}
}
@@ -124,7 +124,7 @@ public class VerifierFactory{
*/
public static Verifier[] getVerifiers(){
Verifier[] vs = new Verifier[hashMap.values().size()];
- return (Verifier[]) (hashMap.values().toArray(vs)); // Because vs is big enough, vs is used to store the values into and returned!
+ return (hashMap.values().toArray(vs)); // Because vs is big enough, vs is used to store the values into and returned!
}
/**
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java
index 1808a6fca..485223e04 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/VerifierFactoryListModel.java
@@ -54,18 +54,19 @@ package org.aspectj.apache.bcel.verifier;
* <http://www.apache.org/>.
*/
import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
/**
* This class implements an adapter; it implements both a Swing ListModel and
* a VerifierFactoryObserver.
*
- * @version $Id: VerifierFactoryListModel.java,v 1.2 2008/05/28 23:53:01 aclement Exp $
+ * @version $Id: VerifierFactoryListModel.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author Enver Haase
*/
public class VerifierFactoryListModel implements org.aspectj.apache.bcel.verifier.VerifierFactoryObserver, javax.swing.ListModel{
- private java.util.ArrayList listeners = new java.util.ArrayList();
+ private java.util.ArrayList<ListDataListener> listeners = new java.util.ArrayList<ListDataListener>();
- private java.util.TreeSet cache = new java.util.TreeSet();
+ private java.util.TreeSet<String> cache = new java.util.TreeSet<String>();
public VerifierFactoryListModel() {
VerifierFactory.attach(this);
@@ -84,7 +85,7 @@ public class VerifierFactoryListModel implements org.aspectj.apache.bcel.verifie
for (int i=0; i<size; i++){
ListDataEvent e = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, 0, num_of_verifiers-1);
- ((javax.swing.event.ListDataListener) (listeners.get(i))).contentsChanged(e);
+ (listeners.get(i)).contentsChanged(e);
}
}
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/IntList.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/IntList.java
index 1b6d4567e..f7656ef7b 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/IntList.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/IntList.java
@@ -59,15 +59,15 @@ import java.util.ArrayList;
/**
* A small utility class representing a set of basic int values.
*
- * @version $Id: IntList.java,v 1.2 2008/05/28 23:52:53 aclement Exp $
+ * @version $Id: IntList.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class IntList{
/** The int are stored as Integer objects here. */
- private ArrayList theList;
+ private ArrayList<Integer> theList;
/** This constructor creates an empty list. */
IntList(){
- theList = new ArrayList();
+ theList = new ArrayList<Integer>();
}
/** Adds an element to the list. */
void add(int i){
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java
index 2d4e8ec98..ce92b19c5 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/LocalVariableInfo.java
@@ -64,15 +64,15 @@ import java.util.Hashtable;
* a given slot (== index). This information
* often changes in course of byte code offsets.
*
- * @version $Id: LocalVariableInfo.java,v 1.2 2008/05/28 23:52:54 aclement Exp $
+ * @version $Id: LocalVariableInfo.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class LocalVariableInfo{
/** The types database. KEY: String representing the offset integer. */
- private Hashtable types = new Hashtable();
+ private Hashtable<String, Type> types = new Hashtable<String, Type>();
/** The names database. KEY: String representing the offset integer. */
- private Hashtable names = new Hashtable();
+ private Hashtable<String, String> names = new Hashtable<String, String>();
/**
* Adds a name of a local variable and a certain slot to our 'names'
@@ -98,7 +98,7 @@ public class LocalVariableInfo{
* variable slot at the given bytecode offset.
*/
public Type getType(int offset){
- return (Type) types.get(Integer.toString(offset));
+ return types.get(Integer.toString(offset));
}
/**
* Returns the name of the local variable that uses this local
@@ -109,7 +109,7 @@ public class LocalVariableInfo{
* variable slot at the given bytecode offset.
*/
public String getName(int offset){
- return (String) (names.get(Integer.toString(offset)));
+ return (names.get(Integer.toString(offset)));
}
/**
* Adds some information about this local variable (slot).
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java
index a0740d279..f6b15dbb1 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/statics/Pass2Verifier.java
@@ -111,7 +111,7 @@ import org.aspectj.apache.bcel.verifier.exc.LocalVariableInfoInconsistentExcepti
* More detailed information is to be found at the do_verify()
* method's documentation.
*
- * @version $Id: Pass2Verifier.java,v 1.3 2008/08/28 00:02:14 aclement Exp $
+ * @version $Id: Pass2Verifier.java,v 1.4 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see #do_verify()
*/
@@ -214,7 +214,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants{
* @throws ClassConstraintException otherwise.
*/
private void every_class_has_an_accessible_superclass(){
- HashSet hs = new HashSet(); // save class names to detect circular inheritance
+ HashSet<String> hs = new HashSet<String>(); // save class names to detect circular inheritance
JavaClass jc = Repository.lookupClass(myOwner.getClassName());
int supidx = -1;
@@ -258,7 +258,7 @@ public final class Pass2Verifier extends PassVerifier implements Constants{
* @see #every_class_has_an_accessible_superclass()
*/
private void final_methods_are_not_overridden(){
- HashMap hashmap = new HashMap();
+ HashMap<String, String> hashmap = new HashMap<String, String>();
JavaClass jc = Repository.lookupClass(myOwner.getClassName());
int supidx = -1;
@@ -319,11 +319,11 @@ public final class Pass2Verifier extends PassVerifier implements Constants{
private Class CONST_Methodref;
private Class CONST_InterfaceMethodref;
*/
- private Class CONST_String;
- private Class CONST_Integer;
- private Class CONST_Float;
- private Class CONST_Long;
- private Class CONST_Double;
+ private Class<ConstantString> CONST_String;
+ private Class<ConstantInteger> CONST_Integer;
+ private Class<ConstantFloat> CONST_Float;
+ private Class<ConstantLong> CONST_Long;
+ private Class<ConstantDouble> CONST_Double;
private Class CONST_NameAndType;
private Class CONST_Utf8;
@@ -332,9 +332,9 @@ public final class Pass2Verifier extends PassVerifier implements Constants{
private final int cplen; // == cp.getLength() -- to save computing power.
private DescendingVisitor carrier;
- private HashSet field_names = new HashSet();
- private HashSet field_names_and_desc = new HashSet();
- private HashSet method_names_and_desc = new HashSet();
+ private HashSet<String> field_names = new HashSet<String>();
+ private HashSet<String> field_names_and_desc = new HashSet<String>();
+ private HashSet<String> method_names_and_desc = new HashSet<String>();
private CPESSC_Visitor(JavaClass _jc){
jc = _jc;
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java
index 7c2fdcc7b..c5a54fde7 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ControlFlowGraph.java
@@ -72,7 +72,7 @@ import org.aspectj.apache.bcel.verifier.exc.StructuralCodeConstraintException;
/**
* This class represents a control flow graph of a method.
*
- * @version $Id: ControlFlowGraph.java,v 1.3 2008/08/28 00:02:13 aclement Exp $
+ * @version $Id: ControlFlowGraph.java,v 1.4 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class ControlFlowGraph {
@@ -98,18 +98,18 @@ public class ControlFlowGraph {
/**
* The 'incoming' execution Frames.
*/
- private final HashMap inFrames; // key: the last-executed JSR
+ private final HashMap<InstructionContextImpl, Frame> inFrames; // key: the last-executed JSR
/**
* The 'outgoing' execution Frames.
*/
- private final HashMap outFrames; // key: the last-executed JSR
+ private final HashMap<InstructionContextImpl, Frame> outFrames; // key: the last-executed JSR
/**
* The 'execution predecessors' - a list of type InstructionContext of those instances that have been execute()d before in
* that order.
*/
- private ArrayList executionPredecessors = null; // Type: InstructionContext
+ private ArrayList<InstructionContext> executionPredecessors = null; // Type: InstructionContext
/**
* Creates an InstructionHandleImpl object from an InstructionHandle. Creation of one per InstructionHandle suffices. Don't
@@ -121,8 +121,8 @@ public class ControlFlowGraph {
}
instruction = inst;
- inFrames = new java.util.HashMap();
- outFrames = new java.util.HashMap();
+ inFrames = new java.util.HashMap<InstructionContextImpl, Frame>();
+ outFrames = new java.util.HashMap<InstructionContextImpl, Frame>();
}
/* Satisfies InstructionContext.getTag(). */
@@ -145,14 +145,14 @@ public class ControlFlowGraph {
/**
* Returns a clone of the "outgoing" frame situation with respect to the given ExecutionChain.
*/
- public Frame getOutFrame(ArrayList execChain) {
+ public Frame getOutFrame(ArrayList<InstructionContext> execChain) {
executionPredecessors = execChain;
Frame org;
InstructionContext jsr = lastExecutionJSR();
- org = (Frame) outFrames.get(jsr);
+ org = outFrames.get(jsr);
if (org == null) {
throw new AssertionViolatedException("outFrame not set! This:\n" + this + "\nExecutionChain: "
@@ -170,9 +170,9 @@ public class ControlFlowGraph {
*
* @return true - if and only if the "outgoing" frame situation changed from the one before execute()ing.
*/
- public boolean execute(Frame inFrame, ArrayList execPreds, InstConstraintVisitor icv, ExecutionVisitor ev) {
+ public boolean execute(Frame inFrame, ArrayList<InstructionContext> execPreds, InstConstraintVisitor icv, ExecutionVisitor ev) {
- executionPredecessors = (ArrayList) execPreds.clone();
+ executionPredecessors = (ArrayList<InstructionContext>) execPreds.clone();
// sanity check
if (lastExecutionJSR() == null && subroutines.subroutineOf(getInstruction()) != subroutines.getTopLevel()) {
@@ -182,7 +182,7 @@ public class ControlFlowGraph {
throw new AssertionViolatedException("Huh?! Am I '" + this + "' part of a subroutine or not?");
}
- Frame inF = (Frame) inFrames.get(lastExecutionJSR());
+ Frame inF = inFrames.get(lastExecutionJSR());
if (inF == null) {// no incoming frame was set, so set it.
inFrames.put(lastExecutionJSR(), inFrame);
inF = inFrame;
@@ -242,7 +242,7 @@ public class ControlFlowGraph {
*/
private boolean mergeInFrames(Frame inFrame) {
// TODO: Can be performance-improved.
- Frame inF = (Frame) inFrames.get(lastExecutionJSR());
+ Frame inF = inFrames.get(lastExecutionJSR());
OperandStack oldstack = inF.getStack().getClone();
LocalVariables oldlocals = inF.getLocals().getClone();
try {
@@ -399,7 +399,7 @@ public class ControlFlowGraph {
private final ExceptionHandlers exceptionhandlers;
/** All InstructionContext instances of this ControlFlowGraph. */
- private final Hashtable instructionContexts = new Hashtable(); // keys: InstructionHandle, values: InstructionContextImpl
+ private final Hashtable<InstructionHandle, InstructionContextImpl> instructionContexts = new Hashtable<InstructionHandle, InstructionContextImpl>(); // keys: InstructionHandle, values: InstructionContextImpl
/**
* A Control Flow Graph.
@@ -420,7 +420,7 @@ public class ControlFlowGraph {
* Returns the InstructionContext of a given instruction.
*/
public InstructionContext contextOf(InstructionHandle inst) {
- InstructionContext ic = (InstructionContext) instructionContexts.get(inst);
+ InstructionContext ic = instructionContexts.get(inst);
if (ic == null) {
throw new AssertionViolatedException("InstructionContext requested for an InstructionHandle that's not known!");
}
@@ -444,7 +444,7 @@ public class ControlFlowGraph {
*/
public InstructionContext[] getInstructionContexts() {
InstructionContext[] ret = new InstructionContext[instructionContexts.values().size()];
- return (InstructionContext[]) instructionContexts.values().toArray(ret);
+ return instructionContexts.values().toArray(ret);
}
/**
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java
index 69e904af0..40abf8f7c 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/ExceptionHandlers.java
@@ -55,13 +55,14 @@ package org.aspectj.apache.bcel.verifier.structurals;
*/
import org.aspectj.apache.bcel.generic.*;
+
import java.util.HashSet;
import java.util.Hashtable;
/**
* This class allows easy access to ExceptionHandler objects.
*
- * @version $Id: ExceptionHandlers.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
+ * @version $Id: ExceptionHandlers.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class ExceptionHandlers{
@@ -69,21 +70,21 @@ public class ExceptionHandlers{
* The ExceptionHandler instances.
* Key: InstructionHandle objects, Values: HashSet<ExceptionHandler> instances.
*/
- private Hashtable exceptionhandlers;
+ private Hashtable<InstructionHandle, HashSet<ExceptionHandler>> exceptionhandlers;
/**
* Constructor. Creates a new ExceptionHandlers instance.
*/
public ExceptionHandlers(MethodGen mg){
- exceptionhandlers = new Hashtable();
+ exceptionhandlers = new Hashtable<InstructionHandle, HashSet<ExceptionHandler>>();
CodeExceptionGen[] cegs = mg.getExceptionHandlers();
for (int i=0; i<cegs.length; i++){
ExceptionHandler eh = new ExceptionHandler(cegs[i].getCatchType(), cegs[i].getHandlerPC());
for (InstructionHandle ih=cegs[i].getStartPC(); ih != cegs[i].getEndPC().getNext(); ih=ih.getNext()){
- HashSet hs;
- hs = (HashSet) exceptionhandlers.get(ih);
+ HashSet<ExceptionHandler> hs;
+ hs = exceptionhandlers.get(ih);
if (hs == null){
- hs = new HashSet();
+ hs = new HashSet<ExceptionHandler>();
exceptionhandlers.put(ih, hs);
}
hs.add(eh);
@@ -96,7 +97,7 @@ public class ExceptionHandlers{
* handlers that protect the instruction ih.
*/
public ExceptionHandler[] getExceptionHandlers(InstructionHandle ih){
- HashSet hs = (HashSet) exceptionhandlers.get(ih);
+ HashSet hs = exceptionhandlers.get(ih);
if (hs == null) return new ExceptionHandler[0];
else{
ExceptionHandler[] ret = new ExceptionHandler[hs.size()];
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java
index eb366d7ea..2127579f3 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/InstructionContext.java
@@ -63,7 +63,7 @@ import org.aspectj.apache.bcel.generic.InstructionHandle;
* to information like control flow successors and
* such.
*
- * @version $Id: InstructionContext.java,v 1.2 2008/05/28 23:53:03 aclement Exp $
+ * @version $Id: InstructionContext.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public interface InstructionContext{
@@ -109,7 +109,7 @@ public interface InstructionContext{
* @return true - if and only if the "outgoing" frame situation
* changed from the one before execute()ing.
*/
- boolean execute(Frame inFrame, ArrayList executionPredecessors, InstConstraintVisitor icv, ExecutionVisitor ev);
+ boolean execute(Frame inFrame, ArrayList<InstructionContext> executionPredecessors, InstConstraintVisitor icv, ExecutionVisitor ev);
/**
* This method returns the outgoing execution frame situation;
@@ -118,7 +118,7 @@ public interface InstructionContext{
*
* @see #execute(Frame, ArrayList, InstConstraintVisitor, ExecutionVisitor)
*/
- Frame getOutFrame(ArrayList executionPredecessors);
+ Frame getOutFrame(ArrayList<InstructionContext> executionPredecessors);
/**
* Returns the InstructionHandle this InstructionContext is wrapped around.
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java
index 6b7b7b0df..7559f5c6a 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/OperandStack.java
@@ -63,13 +63,13 @@ import java.util.*;
* [It's used an an operand stack substitute.]
* Elements of this stack are org.aspectj.apache.bcel.generic.Type objects.
*
- * @version $Id: OperandStack.java,v 1.2 2008/05/28 23:53:02 aclement Exp $
+ * @version $Id: OperandStack.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
*/
public class OperandStack{
/** We hold the stack information here. */
- private ArrayList stack = new ArrayList();
+ private ArrayList<Type> stack = new ArrayList<Type>();
/** The maximum number of stack slots this OperandStack instance may hold. */
private int maxStack;
@@ -96,7 +96,7 @@ public class OperandStack{
*/
protected Object clone(){
OperandStack newstack = new OperandStack(this.maxStack);
- newstack.stack = (ArrayList) this.stack.clone();
+ newstack.stack = (ArrayList<Type>) this.stack.clone();
return newstack;
}
@@ -104,7 +104,7 @@ public class OperandStack{
* Clears the stack.
*/
public void clear(){
- stack = new ArrayList();
+ stack = new ArrayList<Type>();
}
/**
@@ -153,14 +153,14 @@ public class OperandStack{
* iff i==0 the top element is returned. The element is not popped off the stack!
*/
public Type peek(int i){
- return (Type) stack.get(size()-i-1);
+ return stack.get(size()-i-1);
}
/**
* Returns the element on top of the stack. The element is popped off the stack.
*/
public Type pop(){
- Type e = (Type) stack.remove(size()-1);
+ Type e = stack.remove(size()-1);
return e;
}
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java
index 224de27c9..efbefb000 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Pass3bVerifier.java
@@ -85,7 +85,7 @@ import org.aspectj.apache.bcel.verifier.exc.VerifierConstraintViolatedException;
* More detailed information is to be found at the do_verify() method's
* documentation.
*
- * @version $Id: Pass3bVerifier.java,v 1.2 2008/05/28 23:53:03 aclement Exp $
+ * @version $Id: Pass3bVerifier.java,v 1.3 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see #do_verify()
*/
@@ -109,9 +109,9 @@ public final class Pass3bVerifier extends PassVerifier{
* we have about its symbolic execution predecessors.
*/
private static final class InstructionContextQueue{
- private Vector ics = new Vector(); // Type: InstructionContext
- private Vector ecs = new Vector(); // Type: ArrayList (of InstructionContext)
- public void add(InstructionContext ic, ArrayList executionChain){
+ private Vector<InstructionContext> ics = new Vector<InstructionContext>(); // Type: InstructionContext
+ private Vector<ArrayList<InstructionContext>> ecs = new Vector<ArrayList<InstructionContext>>(); // Type: ArrayList (of InstructionContext)
+ public void add(InstructionContext ic, ArrayList<InstructionContext> executionChain){
ics.add(ic);
ecs.add(executionChain);
}
@@ -126,10 +126,10 @@ public final class Pass3bVerifier extends PassVerifier{
ecs.remove(i);
}
public InstructionContext getIC(int i){
- return (InstructionContext) ics.get(i);
+ return ics.get(i);
}
- public ArrayList getEC(int i){
- return (ArrayList) ecs.get(i);
+ public ArrayList<InstructionContext> getEC(int i){
+ return ecs.get(i);
}
public int size(){
return ics.size();
@@ -166,14 +166,14 @@ public final class Pass3bVerifier extends PassVerifier{
final Random random = new Random();
InstructionContextQueue icq = new InstructionContextQueue();
- start.execute(vanillaFrame, new ArrayList(), icv, ev); // new ArrayList() <=> no Instruction was executed before
+ start.execute(vanillaFrame, new ArrayList<InstructionContext>(), icv, ev); // new ArrayList() <=> no Instruction was executed before
// => Top-Level routine (no jsr call before)
- icq.add(start, new ArrayList());
+ icq.add(start, new ArrayList<InstructionContext>());
// LOOP!
while (!icq.isEmpty()){
InstructionContext u;
- ArrayList ec;
+ ArrayList<InstructionContext> ec;
if (!DEBUG){
int r = random.nextInt(icq.size());
u = icq.getIC(r);
@@ -186,8 +186,8 @@ public final class Pass3bVerifier extends PassVerifier{
icq.remove(0);
}
- ArrayList oldchain = (ArrayList) (ec.clone());
- ArrayList newchain = (ArrayList) (ec.clone());
+ ArrayList<InstructionContext> oldchain = (ArrayList<InstructionContext>) (ec.clone());
+ ArrayList<InstructionContext> newchain = (ArrayList<InstructionContext>) (ec.clone());
newchain.add(u);
if ((u.getInstruction().getInstruction()) instanceof RET){
@@ -206,16 +206,16 @@ public final class Pass3bVerifier extends PassVerifier{
throw new AssertionViolatedException("More RET than JSR in execution chain?!");
}
//System.err.println("+"+oldchain.get(ss));
- if (((InstructionContext) oldchain.get(ss)).getInstruction().getInstruction().isJsrInstruction()) {
+ if (oldchain.get(ss).getInstruction().getInstruction().isJsrInstruction()) {
if (skip_jsr == 0){
- lastJSR = (InstructionContext) oldchain.get(ss);
+ lastJSR = oldchain.get(ss);
break;
}
else{
skip_jsr--;
}
}
- if (((InstructionContext) oldchain.get(ss)).getInstruction().getInstruction() instanceof RET){
+ if (oldchain.get(ss).getInstruction().getInstruction() instanceof RET){
skip_jsr++;
}
}
@@ -228,7 +228,7 @@ public final class Pass3bVerifier extends PassVerifier{
}
if (theSuccessor.execute(u.getOutFrame(oldchain), newchain, icv, ev)){
- icq.add(theSuccessor, (ArrayList) newchain.clone());
+ icq.add(theSuccessor, (ArrayList<InstructionContext>) newchain.clone());
}
}
else{// "not a ret"
@@ -238,7 +238,7 @@ public final class Pass3bVerifier extends PassVerifier{
for (int s=0; s<succs.length; s++){
InstructionContext v = succs[s];
if (v.execute(u.getOutFrame(oldchain), newchain, icv, ev)){
- icq.add(v, (ArrayList) newchain.clone());
+ icq.add(v, (ArrayList<InstructionContext>) newchain.clone());
}
}
}// end "not a ret"
@@ -258,8 +258,8 @@ public final class Pass3bVerifier extends PassVerifier{
// by using an empty chain for the exception handlers.
//if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack (u.getOutFrame().getStack().maxStack(), (exc_hds[s].getExceptionType()==null? Type.THROWABLE : exc_hds[s].getExceptionType())) ), newchain), icv, ev){
//icq.add(v, (ArrayList) newchain.clone());
- if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack (u.getOutFrame(oldchain).getStack().maxStack(), (exc_hds[s].getExceptionType()==null? Type.THROWABLE : exc_hds[s].getExceptionType())) ), new ArrayList(), icv, ev)){
- icq.add(v, new ArrayList());
+ if (v.execute(new Frame(u.getOutFrame(oldchain).getLocals(), new OperandStack (u.getOutFrame(oldchain).getStack().maxStack(), (exc_hds[s].getExceptionType()==null? Type.THROWABLE : exc_hds[s].getExceptionType())) ), new ArrayList<InstructionContext>(), icv, ev)){
+ icq.add(v, new ArrayList<InstructionContext>());
}
}
@@ -269,7 +269,7 @@ public final class Pass3bVerifier extends PassVerifier{
do{
if ((ih.getInstruction().isReturnInstruction()) && (!(cfg.isDead(ih)))) {
InstructionContext ic = cfg.contextOf(ih);
- Frame f = ic.getOutFrame(new ArrayList()); // TODO: This is buggy, we check only the top-level return instructions this way. Maybe some maniac returns from a method when in a subroutine?
+ Frame f = ic.getOutFrame(new ArrayList<InstructionContext>()); // TODO: This is buggy, we check only the top-level return instructions this way. Maybe some maniac returns from a method when in a subroutine?
LocalVariables lvs = f.getLocals();
for (int i=0; i<lvs.maxLocals(); i++){
if (lvs.get(i) instanceof UninitializedObjectType){
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java
index b83d6fc97..53f170c26 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/structurals/Subroutines.java
@@ -58,6 +58,7 @@ import org.aspectj.apache.bcel.Constants;
import org.aspectj.apache.bcel.generic.*;
import org.aspectj.apache.bcel.verifier.exc.*;
import java.awt.Color;
+import java.io.Serializable;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashSet;
@@ -84,7 +85,7 @@ import java.util.Iterator;
*
* TODO: refer to the paper.
*
- * @version $Id: Subroutines.java,v 1.3 2008/08/28 00:02:13 aclement Exp $
+ * @version $Id: Subroutines.java,v 1.4 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.inf.fu-berlin.de/~ehaase"/>Enver Haase</A>
* @see #getTopLevel()
*/
@@ -109,7 +110,7 @@ public class Subroutines{
private int localVariable = UNSET;
/** The instructions that belong to this subroutine. */
- private HashSet instructions = new HashSet(); // Elements: InstructionHandle
+ private HashSet<Serializable> instructions = new HashSet<Serializable>(); // Elements: InstructionHandle
/*
* Refer to the Subroutine interface for documentation.
@@ -122,7 +123,7 @@ public class Subroutines{
* The JSR or JSR_W instructions that define this
* subroutine by targeting it.
*/
- private HashSet theJSRs = new HashSet();
+ private HashSet<InstructionHandle> theJSRs = new HashSet<InstructionHandle>();
/**
* The RET instruction that leaves this subroutine.
@@ -164,7 +165,7 @@ public class Subroutines{
if (localVariable == UNSET){
throw new AssertionViolatedException("setLeavingRET() called for top-level 'subroutine' or forgot to set local variable first.");
}
- Iterator iter = instructions.iterator();
+ Iterator<Serializable> iter = instructions.iterator();
InstructionHandle ret = null;
while(iter.hasNext()){
InstructionHandle actual = (InstructionHandle) iter.next();
@@ -194,7 +195,7 @@ public class Subroutines{
throw new AssertionViolatedException("getLeavingRET() called on top level pseudo-subroutine.");
}
InstructionHandle[] jsrs = new InstructionHandle[theJSRs.size()];
- return (InstructionHandle[]) (theJSRs.toArray(jsrs));
+ return (theJSRs.toArray(jsrs));
}
/**
@@ -233,7 +234,7 @@ public class Subroutines{
*/
public InstructionHandle[] getInstructions(){
InstructionHandle[] ret = new InstructionHandle[instructions.size()];
- return (InstructionHandle[]) instructions.toArray(ret);
+ return instructions.toArray(ret);
}
/*
@@ -250,18 +251,18 @@ public class Subroutines{
/* Satisfies Subroutine.getRecursivelyAccessedLocalsIndices(). */
public int[] getRecursivelyAccessedLocalsIndices(){
- HashSet s = new HashSet();
+ HashSet<Integer> s = new HashSet<Integer>();
int[] lvs = getAccessedLocalsIndices();
for (int j=0; j<lvs.length; j++){
s.add(new Integer(lvs[j]));
}
_getRecursivelyAccessedLocalsIndicesHelper(s, this.subSubs());
int[] ret = new int[s.size()];
- Iterator i = s.iterator();
+ Iterator<Integer> i = s.iterator();
int j=-1;
while (i.hasNext()){
j++;
- ret[j] = ((Integer) i.next()).intValue();
+ ret[j] = i.next().intValue();
}
return ret;
}
@@ -270,7 +271,7 @@ public class Subroutines{
* A recursive helper method for getRecursivelyAccessedLocalsIndices().
* @see #getRecursivelyAccessedLocalsIndices()
*/
- private void _getRecursivelyAccessedLocalsIndicesHelper(HashSet s, Subroutine[] subs){
+ private void _getRecursivelyAccessedLocalsIndicesHelper(HashSet<Integer> s, Subroutine[] subs){
for (int i=0; i<subs.length; i++){
int[] lvs = subs[i].getAccessedLocalsIndices();
for (int j=0; j<lvs.length; j++){
@@ -287,11 +288,11 @@ public class Subroutines{
*/
public int[] getAccessedLocalsIndices(){
//TODO: Implement caching.
- HashSet acc = new HashSet();
+ HashSet<Serializable> acc = new HashSet<Serializable>();
if (theRET == null && this != TOPLEVEL){
throw new AssertionViolatedException("This subroutine object must be built up completely before calculating accessed locals.");
}
- Iterator i = instructions.iterator();
+ Iterator<Serializable> i = instructions.iterator();
while (i.hasNext()){
InstructionHandle ih = (InstructionHandle) i.next();
// RET is not a LocalVariableInstruction in the current version of BCEL.
@@ -327,9 +328,9 @@ public class Subroutines{
* Satisfies Subroutine.subSubs().
*/
public Subroutine[] subSubs(){
- HashSet h = new HashSet();
+ HashSet<Subroutine> h = new HashSet<Subroutine>();
- Iterator i = instructions.iterator();
+ Iterator<Serializable> i = instructions.iterator();
while (i.hasNext()){
Instruction inst = ((InstructionHandle) i.next()).getInstruction();
if (inst.isJsrInstruction()){
@@ -338,7 +339,7 @@ public class Subroutines{
}
}
Subroutine[] ret = new Subroutine[h.size()];
- return (Subroutine[]) h.toArray(ret);
+ return h.toArray(ret);
}
/*
@@ -369,7 +370,7 @@ public class Subroutines{
* Key: InstructionHandle of the leader of the subroutine.
* Elements: SubroutineImpl objects.
*/
- private Hashtable subroutines = new Hashtable();
+ private Hashtable<InstructionHandle, Subroutine> subroutines = new Hashtable<InstructionHandle, Subroutine>();
/**
* This is referring to a special subroutine, namely the
@@ -393,7 +394,7 @@ public class Subroutines{
TOPLEVEL = new SubroutineImpl();
// Calculate "real" subroutines.
- HashSet sub_leaders = new HashSet(); // Elements: InstructionHandle
+ HashSet<InstructionHandle> sub_leaders = new HashSet<InstructionHandle>(); // Elements: InstructionHandle
InstructionHandle ih = all[0];
for (int i=0; i<all.length; i++){
Instruction inst = all[i].getInstruction();
@@ -403,10 +404,10 @@ public class Subroutines{
}
// Build up the database.
- Iterator iter = sub_leaders.iterator();
+ Iterator<InstructionHandle> iter = sub_leaders.iterator();
while (iter.hasNext()){
SubroutineImpl sr = new SubroutineImpl();
- InstructionHandle astore = (InstructionHandle) (iter.next());
+ InstructionHandle astore = (iter.next());
sr.setLocalVariable( ( (astore.getInstruction())).getIndex() );
subroutines.put(astore, sr);
}
@@ -430,21 +431,21 @@ public class Subroutines{
// Now do a BFS from every subroutine leader to find all the
// instructions that belong to a subroutine.
- HashSet instructions_assigned = new HashSet(); // we don't want to assign an instruction to two or more Subroutine objects.
+ HashSet<InstructionHandle> instructions_assigned = new HashSet<InstructionHandle>(); // we don't want to assign an instruction to two or more Subroutine objects.
- Hashtable colors = new Hashtable(); //Graph colouring. Key: InstructionHandle, Value: java.awt.Color .
+ Hashtable<InstructionHandle, Color> colors = new Hashtable<InstructionHandle, Color>(); //Graph colouring. Key: InstructionHandle, Value: java.awt.Color .
iter = sub_leaders.iterator();
while (iter.hasNext()){
// Do some BFS with "actual" as the root of the graph.
- InstructionHandle actual = (InstructionHandle) (iter.next());
+ InstructionHandle actual = (iter.next());
// Init colors
for (int i=0; i<all.length; i++){
colors.put(all[i], Color.white);
}
colors.put(actual, Color.gray);
// Init Queue
- ArrayList Q = new ArrayList();
+ ArrayList<InstructionHandle> Q = new ArrayList<InstructionHandle>();
Q.add(actual); // add(Obj) adds to the end, remove(0) removes from the start.
/* BFS ALGORITHM MODIFICATION: Start out with multiple "root" nodes, as exception handlers are starting points of top-level code, too. [why top-level? TODO: Refer to the special JustIce notion of subroutines.]*/
@@ -458,10 +459,10 @@ public class Subroutines{
// Loop until Queue is empty
while (Q.size() != 0){
- InstructionHandle u = (InstructionHandle) Q.remove(0);
+ InstructionHandle u = Q.remove(0);
InstructionHandle[] successors = getSuccessors(u);
for (int i=0; i<successors.length; i++){
- if (((Color) colors.get(successors[i])) == Color.white){
+ if (colors.get(successors[i]) == Color.white){
colors.put(successors[i], Color.gray);
Q.add(successors[i]);
}
@@ -490,9 +491,9 @@ public class Subroutines{
for (int i=0; i<handlers.length; i++){
InstructionHandle _protected = handlers[i].getStartPC();
while (_protected != handlers[i].getEndPC().getNext()){// Note the inclusive/inclusive notation of "generic API" exception handlers!
- Enumeration subs = subroutines.elements();
+ Enumeration<Subroutine> subs = subroutines.elements();
while (subs.hasMoreElements()){
- Subroutine sub = (Subroutine) subs.nextElement();
+ Subroutine sub = subs.nextElement();
if (sub != subroutines.get(all[0])){ // We don't want to forbid top-level exception handlers.
if (sub.contains(_protected)){
throw new StructuralCodeConstraintException("Subroutine instruction '"+_protected+"' is protected by an exception handler, '"+handlers[i]+"'. This is forbidden by the JustIce verifier due to its clear definition of subroutines.");
@@ -509,7 +510,7 @@ public class Subroutines{
// This includes that subroutines may not call themselves
// recursively, even not through intermediate calls to other
// subroutines.
- noRecursiveCalls(getTopLevel(), new HashSet());
+ noRecursiveCalls(getTopLevel(), new HashSet<Integer>());
}
@@ -524,7 +525,7 @@ public class Subroutines{
*
* @throws StructuralCodeConstraintException if the above constraint is not satisfied.
*/
- private void noRecursiveCalls(Subroutine sub, HashSet set){
+ private void noRecursiveCalls(Subroutine sub, HashSet<Integer> set){
Subroutine[] subs = sub.subSubs();
for (int i=0; i<subs.length; i++){
@@ -551,7 +552,7 @@ public class Subroutines{
* @see #getTopLevel()
*/
public Subroutine getSubroutine(InstructionHandle leader){
- Subroutine ret = (Subroutine) subroutines.get(leader);
+ Subroutine ret = subroutines.get(leader);
if (ret == null){
throw new AssertionViolatedException("Subroutine requested for an InstructionHandle that is not a leader of a subroutine.");
@@ -576,9 +577,9 @@ public class Subroutines{
* @see #getTopLevel()
*/
public Subroutine subroutineOf(InstructionHandle any){
- Iterator i = subroutines.values().iterator();
+ Iterator<Subroutine> i = subroutines.values().iterator();
while (i.hasNext()){
- Subroutine s = (Subroutine) i.next();
+ Subroutine s = i.next();
if (s.contains(any)) return s;
}
System.err.println("DEBUG: Please verify '"+any+"' lies in dead code.");
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELFactory.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELFactory.java
index 4f1ae7e8b..5aa954588 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELFactory.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/BCELFactory.java
@@ -85,7 +85,7 @@ import org.aspectj.apache.bcel.verifier.InstructionWalker;
* Factory creates il.append() statements, and sets instruction targets. A helper class for BCELifier.
*
* @see BCELifier
- * @version $Id: BCELFactory.java,v 1.4 2008/08/28 00:02:14 aclement Exp $
+ * @version $Id: BCELFactory.java,v 1.5 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="mailto:markus.dahm@berlin.de">M. Dahm</A>
*/
class BCELFactory extends org.aspectj.apache.bcel.verifier.EmptyInstVisitor {
@@ -99,7 +99,7 @@ class BCELFactory extends org.aspectj.apache.bcel.verifier.EmptyInstVisitor {
_out = out;
}
- private final HashMap branch_map = new HashMap(); // Map<Instruction, InstructionHandle>
+ private final HashMap<Instruction, InstructionHandle> branch_map = new HashMap<Instruction, InstructionHandle>(); // Map<Instruction, InstructionHandle>
public void start() {
if (!_mg.isAbstract() && !_mg.isNative()) {
@@ -258,7 +258,7 @@ class BCELFactory extends org.aspectj.apache.bcel.verifier.EmptyInstVisitor {
}
// Memorize BranchInstructions that need an update
- private final ArrayList branches = new ArrayList();
+ private final ArrayList<InstructionBranch> branches = new ArrayList<InstructionBranch>();
public void visitBranchInstruction(InstructionBranch bi) {
BranchHandle bh = (BranchHandle) branch_map.get(bi);
@@ -320,8 +320,8 @@ class BCELFactory extends org.aspectj.apache.bcel.verifier.EmptyInstVisitor {
}
private void updateBranchTargets() {
- for (Iterator i = branches.iterator(); i.hasNext();) {
- InstructionBranch bi = (InstructionBranch) i.next();
+ for (Iterator<InstructionBranch> i = branches.iterator(); i.hasNext();) {
+ InstructionBranch bi = i.next();
BranchHandle bh = (BranchHandle) branch_map.get(bi);
int pos = bh.getPosition();
String name = bi.getName() + "_" + pos;
diff --git a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/InstructionFinder.java b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/InstructionFinder.java
index 58ce3c1ef..ba1f752c1 100644
--- a/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/InstructionFinder.java
+++ b/bcel-builder/verifier-src/org/aspectj/apache/bcel/verifier/util/InstructionFinder.java
@@ -81,7 +81,7 @@ import org.apache.regexp.*;
...
}
</pre>
- * @version $Id: InstructionFinder.java,v 1.3 2008/08/28 00:02:14 aclement Exp $
+ * @version $Id: InstructionFinder.java,v 1.4 2009/09/09 19:56:20 aclement Exp $
* @author <A HREF="http://www.berlin.de/~markus.dahm/">M. Dahm</A>
* @see Instruction
* @see InstructionList
@@ -90,7 +90,7 @@ public class InstructionFinder {
private static final int OFFSET = 32767; // char + OFFSET is outside of LATIN-1
private static final int NO_OPCODES = 256; // Potential number, some are not used
- private static final HashMap map = new HashMap(); // Map<String,Pattern>
+ private static final HashMap<String, String> map = new HashMap<String, String>(); // Map<String,Pattern>
private InstructionList il;
private String il_string; // instruction list as string
@@ -126,7 +126,7 @@ public class InstructionFinder {
* @return encoded string for a pattern such as "BranchInstruction".
*/
private static final String mapName(String pattern) {
- String result = (String)map.get(pattern);
+ String result = map.get(pattern);
if(result != null)
return result;
@@ -212,7 +212,7 @@ public class InstructionFinder {
* @return iterator of matches where e.nextElement() returns an array of instruction handles
* describing the matched area
*/
- public final Iterator search(String pattern, InstructionHandle from,
+ public final Iterator<InstructionHandle[]> search(String pattern, InstructionHandle from,
CodeConstraint constraint)
{
String search = compilePattern(pattern);
@@ -230,7 +230,7 @@ public class InstructionFinder {
" not found in instruction list.");
try {
RE regex = new RE(search);
- ArrayList matches = new ArrayList();
+ ArrayList<InstructionHandle[]> matches = new ArrayList<InstructionHandle[]>();
while(start < il_string.length() && regex.match(il_string, start)) {
int startExpr = regex.getParenStart(0);
@@ -260,7 +260,7 @@ public class InstructionFinder {
* returns an array of instruction handles describing the matched
* area
*/
- public final Iterator search(String pattern) {
+ public final Iterator<InstructionHandle[]> search(String pattern) {
return search(pattern, il.getStart(), null);
}
@@ -272,7 +272,7 @@ public class InstructionFinder {
* @return iterator of matches where e.nextElement() returns an array of instruction handles
* describing the matched area
*/
- public final Iterator search(String pattern, InstructionHandle from) {
+ public final Iterator<InstructionHandle[]> search(String pattern, InstructionHandle from) {
return search(pattern, from, null);
}
@@ -284,7 +284,7 @@ public class InstructionFinder {
* @param constraint constraints to be checked on matching code
* @return instruction handle or `null' if the match failed
*/
- public final Iterator search(String pattern, CodeConstraint constraint) {
+ public final Iterator<InstructionHandle[]> search(String pattern, CodeConstraint constraint) {
return search(pattern, il.getStart(), constraint);
}
@@ -373,9 +373,9 @@ public class InstructionFinder {
// Compile strings
- for(Iterator i = map.keySet().iterator(); i.hasNext(); ) {
- String key = (String)i.next();
- String value = (String)map.get(key);
+ for(Iterator<String> i = map.keySet().iterator(); i.hasNext(); ) {
+ String key = i.next();
+ String value = map.get(key);
char ch = value.charAt(1); // Omit already precompiled patterns
if(ch < OFFSET) {