more documentation and IllegalArgumentExceptions
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3315 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
f9aa9e6d96
commit
c095615761
|
@ -55,6 +55,9 @@ public class ArraySet<T> extends AbstractSet<T> {
|
|||
|
||||
private static final ArraySet EMPTY = new ArraySet<Object>(0, true) {
|
||||
@Override
|
||||
/**
|
||||
* @throws UnsupportedOperationException unconditionally
|
||||
*/
|
||||
public boolean add(Object obj_) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -182,6 +182,9 @@ public class OrdinalSet<T> implements Iterable<T> {
|
|||
if (c == null) {
|
||||
throw new IllegalArgumentException("c is null");
|
||||
}
|
||||
if (m == null) {
|
||||
throw new IllegalArgumentException("m is null");
|
||||
}
|
||||
MutableSparseIntSet s = MutableSparseIntSet.makeEmpty();
|
||||
for (Iterator<T> it = c.iterator(); it.hasNext();) {
|
||||
int index = m.getMappedIndex(it.next());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue