diff --git a/com.ibm.wala.core/src/com/ibm/wala/demandpa/genericutil/ArraySet.java b/com.ibm.wala.core/src/com/ibm/wala/demandpa/genericutil/ArraySet.java index 08fc445ae..b6426bb3e 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/demandpa/genericutil/ArraySet.java +++ b/com.ibm.wala.core/src/com/ibm/wala/demandpa/genericutil/ArraySet.java @@ -55,6 +55,9 @@ public class ArraySet extends AbstractSet { private static final ArraySet EMPTY = new ArraySet(0, true) { @Override + /** + * @throws UnsupportedOperationException unconditionally + */ public boolean add(Object obj_) { throw new UnsupportedOperationException(); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/dynamic/JavaLauncher.java b/com.ibm.wala.core/src/com/ibm/wala/dynamic/JavaLauncher.java index 8358ca89c..0a53c45cf 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/dynamic/JavaLauncher.java +++ b/com.ibm.wala.core/src/com/ibm/wala/dynamic/JavaLauncher.java @@ -179,6 +179,7 @@ public class JavaLauncher extends Launcher { /** * Wait for the spawned process to terminate. + * @throws IllegalStateException if the process has not been started */ public void join() { if (stdOutDrain == null || stdErrDrain == null) { 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 b8a35341f..9c26d640f 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 @@ -133,6 +133,9 @@ public class PointsToMap { * record that a particular points-to-set has been unioned with another */ public void recordUnified(PointerKey key) { + if (key == null) { + throw new IllegalArgumentException("null key"); + } int i = findOrCreateIndex(key); pointsToSets.set(i, UNIFIED); } 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 63b16e91f..f8b0142c1 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 @@ -19,8 +19,8 @@ import com.ibm.wala.util.debug.Assertions; * By convention, symbol numbers start at 1 ... the "this" parameter will be symbol number 1 in a virtual method. */ public class SymbolTable { - - private final static int MAX_VALUE_NUMBER = Integer.MAX_VALUE/4; + + private final static int MAX_VALUE_NUMBER = Integer.MAX_VALUE / 4; /** * value numbers for parameters to this method @@ -88,9 +88,16 @@ public class SymbolTable { } } + /** + * set the default value for a value number. + * + * @throws IllegalStateException if that value number value is already assigned + */ public void setDefaultValue(int vn, final Object defaultValue) { try { - Assertions._assert(values[vn] == null); + if (values[vn] != null) { + throw new IllegalStateException("cannot set default value of vn " + vn); + } values[vn] = new Value() { public boolean isStringConstant() { @@ -185,7 +192,7 @@ public class SymbolTable { } } catch (ArrayIndexOutOfBoundsException e) { throw new IllegalArgumentException("invalid i: " + i); - } + } } 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 081111bab..971b0c134 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 @@ -51,8 +51,12 @@ public class IntSetUtil { * * @param set * @return a new MutableIntSet object with the same value as set - * @throws UnimplementedError if (not ( set instanceof com.ibm.wala.util.intset.SparseIntSet ) ) and (not ( set instanceof com.ibm.wala.util.intset.BitVectorIntSet ) ) and (not ( set instanceof com.ibm.wala.util.intset.BimodalMutableIntSet ) ) and (not ( set instanceof com.ibm.wala.util.intset.DebuggingMutableIntSet ) ) and (not ( set instanceof com.ibm.wala.util.intset.SemiSparseMutableIntSet ) ) and (not ( set instanceof com.ibm.wala.util.intset.MutableSharedBitVectorIntSet ) ) - * @throws IllegalArgumentException if set == null + * @throws UnimplementedError if (not ( set instanceof com.ibm.wala.util.intset.SparseIntSet ) ) and (not ( set instanceof + * com.ibm.wala.util.intset.BitVectorIntSet ) ) and (not ( set instanceof com.ibm.wala.util.intset.BimodalMutableIntSet + * ) ) and (not ( set instanceof com.ibm.wala.util.intset.DebuggingMutableIntSet ) ) and (not ( set instanceof + * com.ibm.wala.util.intset.SemiSparseMutableIntSet ) ) and (not ( set instanceof + * com.ibm.wala.util.intset.MutableSharedBitVectorIntSet ) ) + * @throws IllegalArgumentException if set == null */ public static MutableIntSet makeMutableCopy(IntSet set) throws IllegalArgumentException, UnimplementedError { if (set == null) { @@ -136,7 +140,7 @@ public class IntSetUtil { /** * Subtract two sets, i.e. a = a \ b. * - * @throws IllegalArgumentException if B == null + * @throws IllegalArgumentException if B == null */ public static MutableIntSet removeAll(MutableIntSet A, IntSet B) throws IllegalArgumentException { if (B == null) { @@ -175,8 +179,8 @@ public class IntSetUtil { if (low <= high && (low < 0 || high < 0)) { throw new IllegalArgumentException("can't search negative indices " + low + " " + high); } - if (high > data.length -1 ) { - high = data.length -1; + if (high > data.length - 1) { + high = data.length - 1; } if (low <= high) { int mid = (low + high) / 2; @@ -201,16 +205,18 @@ public class IntSetUtil { } /** - * @param defaultIntSetFactory - * The defaultIntSetFactory to set. + * @param defaultIntSetFactory The defaultIntSetFactory to set. */ public static void setDefaultIntSetFactory(MutableIntSetFactory defaultIntSetFactory) { + if (defaultIntSetFactory == null) { + throw new IllegalArgumentException("null defaultIntSetFactory"); + } IntSetUtil.defaultIntSetFactory = defaultIntSetFactory; } /** * @return a new sparse int set which adds j to s - * @throws IllegalArgumentException if s == null + * @throws IllegalArgumentException if s == null */ public static IntSet add(IntSet s, int j) throws IllegalArgumentException { if (s == null) { @@ -220,7 +226,7 @@ public class IntSetUtil { SparseIntSet sis = (SparseIntSet) s; return SparseIntSet.add(sis, j); } else { - // really slow. optimize as needed. + // really slow. optimize as needed. MutableSparseIntSet result = MutableSparseIntSet.make(s); result.add(j); return result; diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseIntSetFactory.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseIntSetFactory.java index 9a3ad614f..fc1cbd963 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseIntSetFactory.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseIntSetFactory.java @@ -22,7 +22,6 @@ import java.util.TreeSet; public class MutableSparseIntSetFactory implements MutableIntSetFactory { /** - * @param set * @throws IllegalArgumentException if set is null */ public MutableIntSet make(int[] set) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/OrdinalSet.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/OrdinalSet.java index 119f8e116..dcd68af9c 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/OrdinalSet.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/OrdinalSet.java @@ -182,6 +182,9 @@ public class OrdinalSet implements Iterable { if (c == null) { throw new IllegalArgumentException("c is null"); } + if (m == null) { + throw new IllegalArgumentException("m is null"); + } MutableSparseIntSet s = MutableSparseIntSet.makeEmpty(); for (Iterator it = c.iterator(); it.hasNext();) { int index = m.getMappedIndex(it.next()); diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/io/FileUtil.java b/com.ibm.wala.core/src/com/ibm/wala/util/io/FileUtil.java index eb6fc713b..4c5e82a0a 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/io/FileUtil.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/io/FileUtil.java @@ -161,10 +161,16 @@ public class FileUtil { return new FileOutputStream(f); } + /** + * read fully the contents of s and return a byte array holding the result + * @throws IOException + */ public static byte[] readBytes(InputStream s) throws IOException { - byte[] b; + if (s == null) { + throw new IllegalArgumentException("null s"); + } ByteArrayOutputStream out = new ByteArrayOutputStream(); - b = new byte[1024]; + byte[] b = new byte[1024]; int n = s.read(b); while (n != -1) { out.write(b, 0, n); diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/strings/Atom.java b/com.ibm.wala.core/src/com/ibm/wala/util/strings/Atom.java index ec51a5892..949c45062 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/strings/Atom.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/strings/Atom.java @@ -236,6 +236,7 @@ public final class Atom implements Serializable { * "[Ljava/lang/String;" or "[[I" * * @return dimensionality - something like "1" or "2" + * @throws IllegalStateException if this Atom does not represent an array */ public final int parseForArrayDimensionality() throws IllegalArgumentException { if (val.length == 0) { @@ -255,6 +256,8 @@ public final class Atom implements Serializable { /** * Return the innermost element type reference for an array + * + * @throws IllegalStateException if this Atom does not represent an array descriptor */ public final Atom parseForInnermostArrayElementDescriptor() throws IllegalArgumentException { if (val.length == 0) {