diff --git a/com.ibm.wala.core/src/com/ibm/wala/cfg/ControlFlowGraph.java b/com.ibm.wala.core/src/com/ibm/wala/cfg/ControlFlowGraph.java index 56c0317cb..9a53c5fa0 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/cfg/ControlFlowGraph.java +++ b/com.ibm.wala.core/src/com/ibm/wala/cfg/ControlFlowGraph.java @@ -19,9 +19,6 @@ import com.ibm.wala.util.intset.BitVector; /** * An interface that is common to the Shrike and SSA CFG implementations. - * - * @author cahoon - * @author sfink */ public interface ControlFlowGraph> extends NumberedGraph { @@ -41,8 +38,7 @@ public interface ControlFlowGraph> extends NumberedG public BitVector getCatchBlocks(); /** - * @param index - * an instruction index + * @param index an instruction index * @return the basic block which contains this instruction. */ public T getBlockForInstruction(int index); @@ -54,10 +50,9 @@ public interface ControlFlowGraph> extends NumberedG /** * TODO: move this into IR? - * @param index - * an instruction index - * @return the program counter (bytecode index) corresponding to that - * instruction + * + * @param index an instruction index + * @return the program counter (bytecode index) corresponding to that instruction */ public int getProgramCounter(int index); @@ -67,30 +62,26 @@ public interface ControlFlowGraph> extends NumberedG public IMethod getMethod(); /** - * The order of blocks returned must indicate the exception-handling scope. - * So the first block is the first candidate catch block, and so on. - * With this invariant one can compute the exceptional control flow for - * a given exception type. + * The order of blocks returned must indicate the exception-handling scope. So the first block is the first candidate catch block, + * and so on. With this invariant one can compute the exceptional control flow for a given exception type. * - * @return the basic blocks which may be reached from b via exceptional - * control flow + * @return the basic blocks which may be reached from b via exceptional control flow */ public List getExceptionalSuccessors(T b); /** * The order of blocks returned should be arbitrary but deterministic. + * * @param b - * @return the basic blocks which may be reached from b via normal control - * flow + * @return the basic blocks which may be reached from b via normal control flow */ public Collection getNormalSuccessors(T b); - + /** * The order of blocks returned should be arbitrary but deterministic. * * @param b - * @return the basic blocks from which b may be reached via exceptional - * control flow + * @return the basic blocks from which b may be reached via exceptional control flow */ public Collection getExceptionalPredecessors(T b); @@ -98,8 +89,7 @@ public interface ControlFlowGraph> extends NumberedG * The order of blocks returned should be arbitrary but deterministic. * * @param b - * @return the basic blocks from which b may be reached via normal - * control flow + * @return the basic blocks from which b may be reached via normal control flow */ public Collection getNormalPredecessors(T b); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/eclipse/AbstractJavaAnalysisAction.java b/com.ibm.wala.core/src/com/ibm/wala/eclipse/AbstractJavaAnalysisAction.java index 9871b2407..43040f798 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/eclipse/AbstractJavaAnalysisAction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/eclipse/AbstractJavaAnalysisAction.java @@ -62,6 +62,9 @@ public abstract class AbstractJavaAnalysisAction implements IObjectActionDelegat } public static AnalysisScope computeScope(IStructuredSelection selection, boolean includeSource) throws IOException { + if (selection == null) { + throw new IllegalArgumentException("null selection"); + } Collection projectPaths = new LinkedList(); for (Iterator it = selection.iterator(); it.hasNext();) { Object object = it.next(); diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/AnalysisScope.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/AnalysisScope.java index faae5d1ce..e5f5153c2 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/AnalysisScope.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/AnalysisScope.java @@ -349,6 +349,9 @@ public class AnalysisScope { * Utility function. Useful when parsing input. */ public MethodReference findMethod(Atom loader, String klass, Atom name, ImmutableByteArray desc) { + if (desc == null) { + throw new IllegalArgumentException("null desc"); + } ClassLoaderReference clr = getLoader(loader); Descriptor ddesc = Descriptor.findOrCreate(languages.get(clr.getLanguage()), desc); TypeReference type = TypeReference.findOrCreate(clr, TypeName.string2TypeName(klass)); diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointsToMap.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointsToMap.java index 6ee8e8081..a63d90dc0 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointsToMap.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointsToMap.java @@ -145,6 +145,9 @@ public class PointsToMap { * points-to-sets are the primordial assignments from which the transitive closure flows. */ public void recordTransitiveRoot(PointerKey key) { + if (key == null) { + throw new IllegalArgumentException("null key"); + } int i = findOrCreateIndex(key); transitiveRoots.set(i); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/properties/WalaProperties.java b/com.ibm.wala.core/src/com/ibm/wala/properties/WalaProperties.java index d1a631cb1..dafedbcae 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/properties/WalaProperties.java +++ b/com.ibm.wala.core/src/com/ibm/wala/properties/WalaProperties.java @@ -113,6 +113,9 @@ public final class WalaProperties { if (loader == null) { throw new IllegalArgumentException("loader is null"); } + if (fileName == null) { + throw new IllegalArgumentException("null fileName"); + } final InputStream propertyStream = loader.getResourceAsStream(fileName); if (propertyStream == null) { throw new IOException("property_file_unreadable " + fileName); diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/graph/AbstractNumberedGraph.java b/com.ibm.wala.core/src/com/ibm/wala/util/graph/AbstractNumberedGraph.java index 1631a8c0a..5d41024d8 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/graph/AbstractNumberedGraph.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/graph/AbstractNumberedGraph.java @@ -16,11 +16,8 @@ import com.ibm.wala.util.graph.impl.NumberedNodeIterator; import com.ibm.wala.util.intset.IntSet; /** - * * Basic functionality for a graph that delegates node and edge management, and * tracks node numbers - * - * @author sfink */ public abstract class AbstractNumberedGraph extends AbstractGraph implements NumberedGraph { diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/graph/impl/DelegatingNumberedNodeManager.java b/com.ibm.wala.core/src/com/ibm/wala/util/graph/impl/DelegatingNumberedNodeManager.java index 567705a4b..736f4e562 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/graph/impl/DelegatingNumberedNodeManager.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/graph/impl/DelegatingNumberedNodeManager.java @@ -163,6 +163,9 @@ public class DelegatingNumberedNodeManager implements } INodeWithNumber N = n; int number = N.getGraphNodeId(); + if (number == -1) { + throw new IllegalArgumentException("Cannot remove node, not in graph"); + } if (nodes[number] != null) { nodes[number] = null; numberOfNodes--; diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BFSIterator.java b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BFSIterator.java index cbb19803c..bcc296398 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BFSIterator.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BFSIterator.java @@ -77,6 +77,9 @@ public class BFSIterator implements Iterator { if (G == null) { throw new IllegalArgumentException("G is null"); } + if (nodes == null) { + throw new IllegalArgumentException("nodes is null"); + } init(G, nodes); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BFSPathFinder.java b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BFSPathFinder.java index 85e6fce10..4ce134994 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BFSPathFinder.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BFSPathFinder.java @@ -26,14 +26,12 @@ import com.ibm.wala.util.debug.Trace; import com.ibm.wala.util.graph.Graph; /** - * This class searches breadth-first for node that matches some criteria. If - * found, it reports a path to the first node found. + * This class searches breadth-first for node that matches some criteria. If found, it reports a path to the first node found. * - * This class follows the outNodes of the graph nodes to define the graph, but - * this behavior can be changed by overriding the getConnected method. + * This class follows the outNodes of the graph nodes to define the graph, but this behavior can be changed by overriding the + * getConnected method. * - * TODO: if finding many paths, use a dynamic programming algorithm instead of - * calling this repeatedly. + * TODO: if finding many paths, use a dynamic programming algorithm instead of calling this repeatedly. * * @author Stephen Fink */ @@ -57,28 +55,27 @@ public class BFSPathFinder { final private Iterator roots; /** - * Construct a breadth-first enumerator starting with a particular node in a - * directed graph. + * Construct a breadth-first enumerator starting with a particular node in a directed graph. * - * @param G - * the graph whose nodes to enumerate + * @param G the graph whose nodes to enumerate */ public BFSPathFinder(Graph G, T N, Filter f) { if (G == null) { throw new IllegalArgumentException("G is null"); } + if (f == null) { + throw new IllegalArgumentException("null f"); + } this.G = G; this.roots = new NonNullSingletonIterator(N); this.filter = f; } /** - * Construct a breadth-first enumerator starting with a particular node in a - * directed graph. + * Construct a breadth-first enumerator starting with a particular node in a directed graph. * - * @param G - * the graph whose nodes to enumerate - * @throws IllegalArgumentException if G is null + * @param G the graph whose nodes to enumerate + * @throws IllegalArgumentException if G is null */ public BFSPathFinder(Graph G, T src, final T target) throws IllegalArgumentException { if (G == null) { @@ -97,11 +94,9 @@ public class BFSPathFinder { } /** - * Construct a breadth-first enumerator starting with a particular node in a - * directed graph. + * Construct a breadth-first enumerator starting with a particular node in a directed graph. * - * @param G - * the graph whose nodes to enumerate + * @param G the graph whose nodes to enumerate */ public BFSPathFinder(Graph G, T src, Iterator targets) { if (targets == null) { @@ -123,11 +118,9 @@ public class BFSPathFinder { } /** - * Construct a breadth-first enumerator starting with any of a set of nodes in - * a directed graph. + * Construct a breadth-first enumerator starting with any of a set of nodes in a directed graph. * - * @param G - * the graph whose nodes to enumerate + * @param G the graph whose nodes to enumerate */ public BFSPathFinder(Graph G, Iterator sources, final T target) { if (G == null) { @@ -146,11 +139,10 @@ public class BFSPathFinder { } /** - * Construct a breadth-first enumerator across the (possibly improper) subset - * of nodes reachable from the nodes in the given enumeration. + * Construct a breadth-first enumerator across the (possibly improper) subset of nodes reachable from the nodes in the given + * enumeration. * - * @param nodes - * the set of nodes from which to start searching + * @param nodes the set of nodes from which to start searching */ public BFSPathFinder(Graph G, Iterator nodes, Filter f) { this.G = G; @@ -165,8 +157,8 @@ public class BFSPathFinder { } /** - * @return a List of nodes that specifies the first path found from a root to - * a node accepted by the filter. Returns null if no path found. + * @return a List of nodes that specifies the first path found from a root to a node accepted by the filter. Returns null if no + * path found. */ public List find() { @@ -199,8 +191,7 @@ public class BFSPathFinder { } /** - * @return a List which represents a path in the breadth-first search to Q[i]. - * Q holds the nodes visited during the BFS, in order. + * @return a List which represents a path in the breadth-first search to Q[i]. Q holds the nodes visited during the BFS, in order. */ private List makePath(T node, Map history) { ArrayList result = new ArrayList(); @@ -220,8 +211,7 @@ public class BFSPathFinder { /** * get the out edges of a given node * - * @param n - * the node of which to get the out edges + * @param n the node of which to get the out edges * @return the out edges * */ diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BoundedBFSIterator.java b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BoundedBFSIterator.java index a4f438da9..9eef8ae0e 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BoundedBFSIterator.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/BoundedBFSIterator.java @@ -93,6 +93,9 @@ public class BoundedBFSIterator implements Iterator { if (G == null) { throw new IllegalArgumentException("G is null"); } + if (k < 0) { + throw new IllegalArgumentException("invalid k: " + k); + } this.k = k; boundary = new int[k]; init(G, nodes); diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/DFS.java b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/DFS.java index 4c1ed8821..dbf34a5ab 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/DFS.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/DFS.java @@ -74,24 +74,6 @@ public class DFS { return result; } - // need to comment this out to avoid ambiguous type failure from javac - // /** - // * Perform a DFS starting with a particular node and return the set of all - // * nodes visited. - // * - // * @param G - // * the graph containing n - // * @param n - // * @return Set - // */ - // public static Set getReachableNodes(Graph G, T n) { - // HashSet result = HashSetFactory.make(); - // Iterator dfs = iterateFinishTime(G, new NonNullSingletonIterator(n)); - // while (dfs.hasNext()) { - // result.add(dfs.next()); - // } - // return result; - // } /** * Perform a DFS and return the set of all nodes visited. @@ -200,7 +182,7 @@ public class DFS { } /** - * @param G + * @param G a graph * @return iterator of nodes of G in order of DFS finish time * @throws IllegalArgumentException if G == null */ @@ -216,30 +198,18 @@ public class DFS { } /** - * @param G + * @param G a graph * @param ie roots of traversal, in order to visit in outermost loop of DFS * @return iterator of nodes of G in order of DFS finish time */ public static DFSFinishTimeIterator iterateFinishTime(Graph G, Iterator ie) { + if (ie == null) { + throw new IllegalArgumentException("null ie"); + } if (G instanceof NumberedGraph) { return new NumberedDFSFinishTimeIterator((NumberedGraph) G, ie); } else { return new SlowDFSFinishTimeIterator(G, ie); } } - - // need to comment out to avoid ambiguous type error from javac - // /** - // * @param G - // * @param n - // * @return iterator of nodes of G in order of DFS finish time - // */ - // public static DFSFinishTimeIterator iterateFinishTime(Graph G, T - // n) { - // if (G instanceof NumberedGraph) { - // return new NumberedDFSFinishTimeIterator((NumberedGraph) G, n); - // } else { - // return new SlowDFSFinishTimeIterator(G, n); - // } - // } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/SlowDFSDiscoverTimeIterator.java b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/SlowDFSDiscoverTimeIterator.java index 6ab59d83d..0b985f502 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/SlowDFSDiscoverTimeIterator.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/graph/traverse/SlowDFSDiscoverTimeIterator.java @@ -60,6 +60,9 @@ public class SlowDFSDiscoverTimeIterator extends GraphDFSDiscoverTimeIterator * @param nodes the set of nodes from which to start searching */ public SlowDFSDiscoverTimeIterator(Graph G, Iterator nodes) { + if (nodes == null) { + throw new IllegalArgumentException("null nodes"); + } init(G, nodes); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/BitVectorIntSet.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/BitVectorIntSet.java index 014c1c1fc..babe06a0c 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/BitVectorIntSet.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/BitVectorIntSet.java @@ -219,6 +219,9 @@ public final class BitVectorIntSet implements MutableIntSet { * @see com.ibm.wala.util.intset.IntSet#foreach(com.ibm.wala.util.intset.IntSetAction) */ public void foreach(IntSetAction action) { + if (action == null) { + throw new IllegalArgumentException("null action"); + } int nextBit = bitVector.nextSetBit(0); populationCount = (populationCount == UNDEFINED) ? bitVector.populationCount() : populationCount; for (int i = 0; i < populationCount; i++) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntSet.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntSet.java index d460d1814..232e78817 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntSet.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntSet.java @@ -11,10 +11,7 @@ package com.ibm.wala.util.intset; /** - * * Set of integers; not necessary mutable TODO: extract a smaller interface? - * - * @author sfink */ public interface IntSet { @@ -60,15 +57,11 @@ public interface IntSet { /** * Invoke an action on each element of the Set - * - * @param action */ public void foreach(IntSetAction action); /** * Invoke an action on each element of the Set, excluding elements of Set X - * - * @param action */ public void foreachExcluding(IntSet X, IntSetAction action); diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntegerUnionFind.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntegerUnionFind.java index 0d4ffaa35..0dddc8e83 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntegerUnionFind.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntegerUnionFind.java @@ -36,10 +36,10 @@ public class IntegerUnionFind { } /** - * @param size + * @param size initial size of the tables */ public IntegerUnionFind(int size) { - if (size + 1 < 0) { + if (size < 0) { throw new IllegalArgumentException("illegal size: " + size); } parent = new int[size + 1]; diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/SparseLongSet.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/SparseLongSet.java index 89164ff62..af957643f 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/SparseLongSet.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/SparseLongSet.java @@ -414,7 +414,7 @@ public class SparseLongSet implements LongSet { if (elements == null) { throw new IllegalStateException("Illegal to ask max() on an empty int set"); } - return elements[size - 1]; + return (size > 0) ? elements[size - 1] : -1; } /** diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/io/FileProvider.java b/com.ibm.wala.core/src/com/ibm/wala/util/io/FileProvider.java index 6fe5e2609..486174160 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/io/FileProvider.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/io/FileProvider.java @@ -95,6 +95,9 @@ public class FileProvider { } public static URL getResource(String fileName, ClassLoader loader) throws IOException { + if (fileName == null) { + throw new IllegalArgumentException("null fileName"); + } if (CorePlugin.getDefault() == null && loader == null) { throw new IllegalArgumentException("null loader"); } @@ -215,6 +218,9 @@ public class FileProvider { if (loader == null) { throw new IllegalArgumentException("null loader"); } + if (fileName == null) { + throw new IllegalArgumentException("null fileName"); + } URL url = loader.getResource(fileName); if (DEBUG_LEVEL > 0) { Trace.println("FileProvider got url: " + url + " for " + fileName);