diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectionContextSelector.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectionContextSelector.java index 756f0ad77..f845055b0 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectionContextSelector.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/reflection/ReflectionContextSelector.java @@ -27,9 +27,13 @@ import com.ibm.wala.ipa.callgraph.propagation.InstanceKey; public class ReflectionContextSelector { public static ContextSelector createReflectionContextSelector(AnalysisOptions options) { + + if (options == null) { + throw new IllegalArgumentException("null options"); + } + // start with a dummy ContextSelector result = new ContextSelector() { - public Context getCalleeTarget(CGNode caller, CallSiteReference site, IMethod callee, InstanceKey receiver) { return null; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/analysis/typeInference/SetType.java b/com.ibm.wala.core/src/com/ibm/wala/analysis/typeInference/SetType.java index 323de75f8..98daea38c 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/analysis/typeInference/SetType.java +++ b/com.ibm.wala.core/src/com/ibm/wala/analysis/typeInference/SetType.java @@ -19,12 +19,8 @@ import com.ibm.wala.util.debug.Assertions; import com.ibm.wala.util.debug.UnimplementedError; /** - * * Abstraction of a set of PointTypes. These are immutable. TODO: fix for * efficiency if needed. - * - * @author sfink - * */ public class SetType extends TypeAbstraction { @@ -42,6 +38,9 @@ public class SetType extends TypeAbstraction { types = HashSetFactory.make(points.length); int h = 0; for (int i = 0; i < points.length; i++) { + if (points[i] == null) { + throw new IllegalArgumentException("points[" + i + "] is null"); + } TypeReference T = points[i].getType().getReference(); h ^= T.hashCode(); types.add(T); diff --git a/com.ibm.wala.core/src/com/ibm/wala/dataflow/graph/BitVectorUnionConstant.java b/com.ibm.wala.core/src/com/ibm/wala/dataflow/graph/BitVectorUnionConstant.java index ed6712bcd..fbe9c8da4 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/dataflow/graph/BitVectorUnionConstant.java +++ b/com.ibm.wala.core/src/com/ibm/wala/dataflow/graph/BitVectorUnionConstant.java @@ -12,7 +12,6 @@ package com.ibm.wala.dataflow.graph; import com.ibm.wala.fixedpoint.impl.UnaryOperator; import com.ibm.wala.fixpoint.BitVectorVariable; -import com.ibm.wala.util.debug.Assertions; /** @@ -22,8 +21,8 @@ public class BitVectorUnionConstant extends UnaryOperator { private final int c; public BitVectorUnionConstant(int c) { - if (Assertions.verifyAssertions) { - Assertions._assert(c >= 0); + if (c < 0) { + throw new IllegalArgumentException("Invalid c: " + c); } this.c = c; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/demandpa/alg/ThisFilteringHeapModel.java b/com.ibm.wala.core/src/com/ibm/wala/demandpa/alg/ThisFilteringHeapModel.java index d55277bc7..c3b71f089 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/demandpa/alg/ThisFilteringHeapModel.java +++ b/com.ibm.wala.core/src/com/ibm/wala/demandpa/alg/ThisFilteringHeapModel.java @@ -124,6 +124,9 @@ import com.ibm.wala.util.debug.Assertions; } public ThisFilteringHeapModel(HeapModel delegate, IClassHierarchy cha) { + if (delegate == null) { + throw new IllegalArgumentException("delegate null"); + } this.delegate = delegate; this.cha = cha; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/escape/TrivialMethodEscape.java b/com.ibm.wala.core/src/com/ibm/wala/escape/TrivialMethodEscape.java index a065a6b50..707c91f14 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/escape/TrivialMethodEscape.java +++ b/com.ibm.wala.core/src/com/ibm/wala/escape/TrivialMethodEscape.java @@ -58,6 +58,9 @@ public class TrivialMethodEscape implements IMethodEscapeAnalysis, INodeEscapeAn public boolean mayEscape(MethodReference allocMethod, int allocPC, MethodReference m) throws WalaException { + if (allocMethod == null) { + throw new IllegalArgumentException("null allocMethod"); + } // nodes:= set of call graph nodes representing method m Set nodes = cg.getNodes(m); if (nodes.size() == 0) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/fixedpoint/impl/GeneralStatement.java b/com.ibm.wala.core/src/com/ibm/wala/fixedpoint/impl/GeneralStatement.java index 03793e9f4..c08f980e6 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/fixedpoint/impl/GeneralStatement.java +++ b/com.ibm.wala.core/src/com/ibm/wala/fixedpoint/impl/GeneralStatement.java @@ -71,6 +71,9 @@ public class GeneralStatement extends AbstractStatement operator) { super(); + if (operator == null) { + throw new IllegalArgumentException("null operator"); + } this.operator = operator; this.lhs = lhs; this.rhs = null; diff --git a/com.ibm.wala.core/src/com/ibm/wala/fixpoint/BitVectorVariable.java b/com.ibm.wala.core/src/com/ibm/wala/fixpoint/BitVectorVariable.java index 876b19a64..91c9b0819 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/fixpoint/BitVectorVariable.java +++ b/com.ibm.wala.core/src/com/ibm/wala/fixpoint/BitVectorVariable.java @@ -66,6 +66,9 @@ public class BitVectorVariable extends AbstractVariable { } public boolean sameValue(BitVectorVariable other) { + if (other == null) { + throw new IllegalArgumentException("null other"); + } if (V == null) { return (other.V == null); } else { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java index bc87de3be..b333d75f2 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java @@ -52,8 +52,6 @@ import com.ibm.wala.util.graph.traverse.SlowDFSDiscoverTimeIterator; import com.ibm.wala.util.strings.Atom; /** - * @author sfink - * */ public class Util { /** @@ -498,7 +496,13 @@ public class Util { }; } + /** + * create a set holding the contents of an {@link Iterator} + */ public static Set setify(Iterator x) { + if (x == null) { + throw new IllegalArgumentException("Null x"); + } Set y = HashSetFactory.make(); while (x.hasNext()) { y.add(x.next()); diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/LocalPointerKey.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/LocalPointerKey.java index 5ddbeff82..6257b286d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/LocalPointerKey.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/LocalPointerKey.java @@ -28,6 +28,9 @@ public class LocalPointerKey extends AbstractLocalPointerKey { if (valueNumber <= 0) { throw new IllegalArgumentException("illegal valueNumber: " + valueNumber); } + if (node == null) { + throw new IllegalArgumentException("null node"); + } } @Override diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointerAnalysisImpl.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointerAnalysisImpl.java index bf8c47213..a179d9300 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointerAnalysisImpl.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointerAnalysisImpl.java @@ -82,10 +82,9 @@ public class PointerAnalysisImpl extends AbstractPointerAnalysis { this.pointerKeys = pointerKeys; this.iKeyFactory = iKeyFactory; this.pointsToMap = pointsToMap; - if (Assertions.verifyAssertions) { - Assertions._assert(iKeyFactory != null); + if (iKeyFactory == null) { + throw new IllegalArgumentException("null iKeyFactory"); } - H = makeHeapModel(); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointerKeyComparator.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointerKeyComparator.java index f7c85c6e0..df0f50e63 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointerKeyComparator.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/PointerKeyComparator.java @@ -25,6 +25,9 @@ public class PointerKeyComparator implements Comparator { private final IClassHierarchy cha; public PointerKeyComparator(IClassHierarchy cha) { + if (cha == null) { + throw new IllegalArgumentException("null cha"); + } this.cha = cha; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ContainerContextSelector.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ContainerContextSelector.java index ddd966f28..4476d0f68 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ContainerContextSelector.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ContainerContextSelector.java @@ -84,8 +84,8 @@ public class ContainerContextSelector implements ContextSelector { public ContainerContextSelector(IClassHierarchy cha, ZeroXInstanceKeys delegate) { this.cha = cha; this.delegate = delegate; - if (Assertions.verifyAssertions) { - Assertions._assert(delegate != null); + if (delegate == null) { + throw new IllegalArgumentException("null delegate"); } } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/DefaultPointerKeyFactory.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/DefaultPointerKeyFactory.java index 29046465b..0da2d30ad 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/DefaultPointerKeyFactory.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/DefaultPointerKeyFactory.java @@ -61,8 +61,8 @@ public class DefaultPointerKeyFactory implements PointerKeyFactory { } public PointerKey getPointerKeyForStaticField(IField f) { - if (Assertions.verifyAssertions) { - Assertions._assert(f != null, "null f"); + if (f == null) { + throw new IllegalArgumentException("null f"); } return new StaticFieldKey(f); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ZeroXInstanceKeys.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ZeroXInstanceKeys.java index 5f15287be..b2fb519f8 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ZeroXInstanceKeys.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ZeroXInstanceKeys.java @@ -319,8 +319,11 @@ public class ZeroXInstanceKeys implements InstanceKeyFactory { || C.getReference().equals(JavaLangStringBuilder) || C.getReference().equals(JavaLangAbstractStringBuilder); } - public static boolean isThrowable(IClass C) { - return C.getClassHierarchy().isSubclassOf(C, C.getClassHierarchy().lookupClass(TypeReference.JavaLangThrowable)); + public static boolean isThrowable(IClass c) { + if (c == null) { + throw new IllegalArgumentException("null c"); + } + return c.getClassHierarchy().isSubclassOf(c, c.getClassHierarchy().lookupClass(TypeReference.JavaLangThrowable)); } public boolean isStackTraceElement(IClass C) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/modref/DelegatingExtendedHeapModel.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/modref/DelegatingExtendedHeapModel.java index 07cbba9a0..a063328f8 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/modref/DelegatingExtendedHeapModel.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/modref/DelegatingExtendedHeapModel.java @@ -26,13 +26,15 @@ import com.ibm.wala.types.TypeReference; /** * An implementation of {@link ExtendedHeapModel} based on a * normal {@link HeapModel} - * */ public class DelegatingExtendedHeapModel implements ExtendedHeapModel { private final HeapModel h; public DelegatingExtendedHeapModel(HeapModel h) { + if (h == null) { + throw new IllegalArgumentException("null h"); + } this.h = h; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/thin/CISlicer.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/thin/CISlicer.java index 9d4b2f192..07e820698 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/thin/CISlicer.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/thin/CISlicer.java @@ -104,6 +104,9 @@ public class CISlicer { * Compute the set of pointer keys each statement refs */ public static Map> scanForRef(SDG sdg, PointerAnalysis pa) { + if (sdg == null) { + throw new IllegalArgumentException("null sdg"); + } return scanForRef(sdg, pa, ModRef.make()); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/SyntheticIR.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/SyntheticIR.java index 33bb1f350..8d1062868 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/SyntheticIR.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/summaries/SyntheticIR.java @@ -31,8 +31,8 @@ public class SyntheticIR extends IR { private final static boolean PARANOID = true; /** - * Create an SSA form, induced over a list of instructions provided externally. This entrypoint is often used for, - * e.g., native method models + * Create an SSA form, induced over a list of instructions provided externally. This entrypoint is often used for, e.g., native + * method models * * @param method the method to construct SSA form for * @param context the governing context @@ -72,7 +72,9 @@ public class SyntheticIR extends IR { */ private static SymbolTable makeSymbolTable(IMethod method, SSAInstruction[] instructions, Map constants, AbstractCFG cfg) { - assert method != null; + if (method == null) { + throw new IllegalArgumentException("null method"); + } SymbolTable symbolTable = new SymbolTable(method.getNumberOfParameters()); // simulate allocation of value numbers @@ -82,13 +84,12 @@ public class SyntheticIR extends IR { updateForInstruction(constants, symbolTable, s); } } - + /** - * In InducedCFGs, we have nulled out phi instructions from the instruction array ... so go back and - * retrieve them now. + * In InducedCFGs, we have nulled out phi instructions from the instruction array ... so go back and retrieve them now. */ if (cfg instanceof InducedCFG) { - InducedCFG icfg = (InducedCFG)cfg; + InducedCFG icfg = (InducedCFG) cfg; for (SSAPhiInstruction phi : icfg.getAllPhiInstructions()) { updateForInstruction(constants, symbolTable, phi); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/model/java/lang/reflect/Array.java b/com.ibm.wala.core/src/com/ibm/wala/model/java/lang/reflect/Array.java index 6a63a15d0..97be0641c 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/model/java/lang/reflect/Array.java +++ b/com.ibm.wala.core/src/com/ibm/wala/model/java/lang/reflect/Array.java @@ -21,7 +21,6 @@ public class Array { */ public static Object get(Object array, int index) throws IllegalArgumentException, ArrayIndexOutOfBoundsException { - if (!array.getClass().isArray()) { throw new IllegalArgumentException(); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/NullTestPiPolicy.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/NullTestPiPolicy.java index 6b6641ef4..6b7b1252a 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/NullTestPiPolicy.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/NullTestPiPolicy.java @@ -40,6 +40,9 @@ public class NullTestPiPolicy implements SSAPiNodePolicy { if (symbolTable == null) { throw new IllegalArgumentException("null symbolTable"); } + if (cond == null) { + throw new IllegalArgumentException("null cond"); + } if (symbolTable.isNullConstant(cond.getUse(1))) { return Pair.make(cond.getUse(0), cond); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLoadInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLoadInstruction.java index febe2bc8a..d5d2225cc 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLoadInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayLoadInstruction.java @@ -13,14 +13,10 @@ package com.ibm.wala.ssa; import java.util.Collection; import com.ibm.wala.types.TypeReference; -import com.ibm.wala.util.debug.Assertions; import com.ibm.wala.util.shrike.Exceptions; /** * SSA instruction representing an array load. - * - * @author sfink - * */ public class SSAArrayLoadInstruction extends SSAArrayReferenceInstruction { private final int result; @@ -76,8 +72,8 @@ public class SSAArrayLoadInstruction extends SSAArrayReferenceInstruction { @Override public int getDef(int i) { - if (Assertions.verifyAssertions) { - Assertions._assert(i == 0); + if (i != 0) { + throw new IllegalArgumentException("illegal i: " + i); } return result; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayReferenceInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayReferenceInstruction.java index 650d6d633..efba88075 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayReferenceInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayReferenceInstruction.java @@ -29,6 +29,9 @@ public abstract class SSAArrayReferenceInstruction extends SSAInstruction { this.arrayref = arrayref; this.index = index; this.elementType = elementType; + if (elementType == null) { + throw new IllegalArgumentException("null elementType"); + } } /* diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayStoreInstruction.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayStoreInstruction.java index b441e151d..fca490b0a 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayStoreInstruction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSAArrayStoreInstruction.java @@ -16,8 +16,6 @@ import com.ibm.wala.types.TypeReference; import com.ibm.wala.util.shrike.Exceptions; /** - * @author sfink - * */ public class SSAArrayStoreInstruction extends SSAArrayReferenceInstruction { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SymbolTable.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SymbolTable.java index 5a40116b1..c35315c02 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SymbolTable.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SymbolTable.java @@ -197,6 +197,9 @@ public class SymbolTable { } public boolean isOne(int v) { + if (v < 0) { + throw new IllegalArgumentException("Illegal v: " + v); + } return (values[v] instanceof ConstantValue) && ((ConstantValue) values[v]).isOneConstant(); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/types/Descriptor.java b/com.ibm.wala.core/src/com/ibm/wala/types/Descriptor.java index 41177a61c..df1a84146 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/types/Descriptor.java +++ b/com.ibm.wala.core/src/com/ibm/wala/types/Descriptor.java @@ -44,6 +44,9 @@ public final class Descriptor { * @return the canonical representative for this descriptor value */ public static Descriptor findOrCreate(TypeName[] parameters, TypeName returnType) { + if (returnType == null) { + throw new IllegalArgumentException("null returnType"); + } if (parameters != null && parameters.length == 0) { parameters = null; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/types/Selector.java b/com.ibm.wala.core/src/com/ibm/wala/types/Selector.java index 45a116c29..0d81df3ce 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/types/Selector.java +++ b/com.ibm.wala.core/src/com/ibm/wala/types/Selector.java @@ -27,11 +27,15 @@ public final class Selector { if (selectorStr == null) { throw new IllegalArgumentException("null selectorStr"); } - String methodName = selectorStr.substring(0, selectorStr.indexOf('(')); - String desc = selectorStr.substring(selectorStr.indexOf('(')); - return new Selector(Atom.findOrCreateUnicodeAtom(methodName), Descriptor.findOrCreateUTF8(desc)); - + try { + String methodName = selectorStr.substring(0, selectorStr.indexOf('(')); + String desc = selectorStr.substring(selectorStr.indexOf('(')); + return new Selector(Atom.findOrCreateUnicodeAtom(methodName), Descriptor.findOrCreateUTF8(desc)); + } catch (StringIndexOutOfBoundsException e) { + throw new IllegalArgumentException("invalid selectorStr: " + selectorStr); + } } + public Selector(Atom name, Descriptor descriptor) { this.name = name; this.descriptor = descriptor; diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/collections/Filtersection.java b/com.ibm.wala.core/src/com/ibm/wala/util/collections/Filtersection.java index 017a265e7..69331ed3b 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/collections/Filtersection.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/collections/Filtersection.java @@ -13,10 +13,7 @@ package com.ibm.wala.util.collections; import com.ibm.wala.annotations.NonNull; /** - * * intersection of two filters - * - * @author sfink */ public class Filtersection implements Filter { @@ -27,6 +24,12 @@ public class Filtersection implements Filter { public Filtersection(Filter a, Filter b) { this.a = a; this.b = b; + if (a == null) { + throw new IllegalArgumentException("null a"); + } + if (b == null) { + throw new IllegalArgumentException("null b"); + } } public boolean accepts(T o) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/collections/HashMapFactory.java b/com.ibm.wala.core/src/com/ibm/wala/util/collections/HashMapFactory.java index d0524bb26..0f0e94a0a 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/collections/HashMapFactory.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/collections/HashMapFactory.java @@ -52,6 +52,9 @@ public class HashMapFactory { * @return A ParanoidHashMap if DEBUG = true, a LinkedHashMap otherwise */ public static HashMap make(Map t) { + if (t == null) { + throw new IllegalArgumentException("null t"); + } if (HashSetFactory.DEBUG) { return new ParanoidHashMap(t); } else { diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/collections/TwoLevelVector.java b/com.ibm.wala.core/src/com/ibm/wala/util/collections/TwoLevelVector.java index a8d3401a9..bcb254dcd 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/collections/TwoLevelVector.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/collections/TwoLevelVector.java @@ -68,6 +68,9 @@ public class TwoLevelVector implements IVector { * @see com.ibm.wala.util.intset.IntVector#set(int, int) */ public void set(int x, T value) { + if (x < 0) { + throw new IllegalArgumentException("illegal x: " + x); + } int page = getPageNumber(x); IVector v = findOrCreatePage(page); int localX = toLocalIndex(x, page); diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/config/AnalysisScopeReader.java b/com.ibm.wala.core/src/com/ibm/wala/util/config/AnalysisScopeReader.java index 9357cf76c..3a4426b1d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/config/AnalysisScopeReader.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/config/AnalysisScopeReader.java @@ -85,6 +85,9 @@ public class AnalysisScopeReader { } public static void processScopeDefLine(AnalysisScope scope, ClassLoader javaLoader, String line) throws IOException { + if (line == null) { + throw new IllegalArgumentException("null line"); + } StringTokenizer toks = new StringTokenizer(line, "\n,"); if (!toks.hasMoreTokens()) { return; diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/FixedSizeBitVector.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/FixedSizeBitVector.java index dc0905f6b..01d08b58f 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/FixedSizeBitVector.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/FixedSizeBitVector.java @@ -91,6 +91,9 @@ public final class FixedSizeBitVector implements Cloneable, java.io.Serializable * @param bit the bit to be cleared */ public void clear(int bit) { + if (bit < 0) { + throw new IllegalArgumentException("illegal bit: " + bit); + } int shiftBits = bit & LOW_MASK; bits[subscript(bit)] &= ~(1 << shiftBits); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntSetUtil.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntSetUtil.java index 7f79340e6..081111bab 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntSetUtil.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/IntSetUtil.java @@ -117,6 +117,12 @@ public class IntSetUtil { if (factory == null) { throw new IllegalArgumentException("null factory"); } + if (A == null) { + throw new IllegalArgumentException("null A"); + } + if (B == null) { + throw new IllegalArgumentException("null B"); + } if (A instanceof SparseIntSet && B instanceof SparseIntSet) { return SparseIntSet.diff((SparseIntSet) A, (SparseIntSet) B); } else if (A instanceof SemiSparseMutableIntSet && B instanceof SemiSparseMutableIntSet) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseIntSet.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseIntSet.java index 956945c06..677859c22 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseIntSet.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseIntSet.java @@ -423,6 +423,9 @@ public class MutableSparseIntSet extends SparseIntSet implements MutableIntSet { } public > void removeAll(T v) { + if (v == null) { + throw new IllegalArgumentException("null v"); + } int ai = 0; for (int i = 0; i < size; i++) { if (!v.get(elements[i])) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/SparseIntSet.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/SparseIntSet.java index d7954f209..4cdeee93d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/SparseIntSet.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/SparseIntSet.java @@ -138,6 +138,9 @@ public class SparseIntSet implements IntSet { } public final int elementAt(int idx) throws NoSuchElementException { + if (idx < 0) { + throw new IllegalArgumentException("invalid idx: " + idx); + } if (elements == null || idx >= size) { throw new NoSuchElementException("Index: " + idx); } 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 aa2f9f542..aa8488559 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 @@ -386,6 +386,9 @@ public class SparseLongSet implements LongSet { } public void foreach(LongSetAction action) { + if (action == null) { + throw new IllegalArgumentException("null action"); + } for (int i = 0; i < size; i++) action.act(elements[i]); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/io/CommandLine.java b/com.ibm.wala.core/src/com/ibm/wala/util/io/CommandLine.java index d385786ee..bc24d7156 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/io/CommandLine.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/io/CommandLine.java @@ -33,6 +33,10 @@ public class CommandLine { } Properties result = new Properties(); for (int i = 0; i < args.length; i++) { + if (args[i] == null) { + // skip it + continue; + } String key = parseForKey(args[i]); if (key != null) { if (args[i].contains("=")) { 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 b7e869d04..e0dd091b6 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 (CorePlugin.getDefault() == null && loader == null) { + throw new IllegalArgumentException("null loader"); + } return (CorePlugin.getDefault() == null) ? loader.getResource(fileName) : FileLocator.find(CorePlugin.getDefault().getBundle(), new Path(fileName), null); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/strings/ImmutableByteArray.java b/com.ibm.wala.core/src/com/ibm/wala/util/strings/ImmutableByteArray.java index e0507bd28..59867d003 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/strings/ImmutableByteArray.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/strings/ImmutableByteArray.java @@ -10,13 +10,8 @@ *******************************************************************************/ package com.ibm.wala.util.strings; -import com.ibm.wala.util.debug.Assertions; - /** - * * A read-only byte array. - * - * @author sfink */ public final class ImmutableByteArray { @@ -34,10 +29,10 @@ public final class ImmutableByteArray { if (b == null) { throw new IllegalArgumentException("b is null"); } - this.b = new byte[length]; - if (Assertions.verifyAssertions) { - Assertions._assert(b.length >= start + length, "illegal"); + if (start < 0) { + throw new IllegalArgumentException("invalid start: " + start); } + this.b = new byte[length]; System.arraycopy(b, start, this.b, 0, length); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/viz/GVUtil.java b/com.ibm.wala.core/src/com/ibm/wala/viz/GVUtil.java index f98fc75fc..ff2aec517 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/viz/GVUtil.java +++ b/com.ibm.wala.core/src/com/ibm/wala/viz/GVUtil.java @@ -27,6 +27,9 @@ public class GVUtil { if (gvExe == null) { throw new IllegalArgumentException("null gvExe"); } + if (psFile == null) { + throw new IllegalArgumentException("null psFile"); + } final GSViewLauncher gv = new GSViewLauncher(); gv.setGvExe(gvExe); gv.setPsfile(psFile); diff --git a/com.ibm.wala.core/src/com/ibm/wala/viz/ViewIFDSLocalAction.java b/com.ibm.wala.core/src/com/ibm/wala/viz/ViewIFDSLocalAction.java index 6526980ea..2900ba6f9 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/viz/ViewIFDSLocalAction.java +++ b/com.ibm.wala.core/src/com/ibm/wala/viz/ViewIFDSLocalAction.java @@ -85,6 +85,9 @@ public class ViewIFDSLocalAction extends Action { public ViewIFDSLocalAction(SWTTreeViewer viewer, TabulationResult result, String psFile, String dotFile, String dotExe, String gvExe) { + if (result == null) { + throw new IllegalArgumentException("null result"); + } this.viewer = viewer; this.supergraph = result.getProblem().getSupergraph(); this.psFile = psFile;