cleanups for illegal arguments and unsupported operations

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1635 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2007-08-20 20:16:43 +00:00
parent 2b1cffddfd
commit a013bb006e
41 changed files with 265 additions and 301 deletions

View File

@ -30,6 +30,7 @@ import com.ibm.wala.util.IntFunction;
import com.ibm.wala.util.IntMapIterator;
import com.ibm.wala.util.collections.EmptyIterator;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.graph.AbstractNumberedGraph;
import com.ibm.wala.util.graph.EdgeManager;
import com.ibm.wala.util.graph.NodeManager;
@ -440,11 +441,11 @@ public class BasicHeapGraph extends HeapGraph {
/*
* @see com.ibm.wala.util.graph.NodeManager#remove(com.ibm.wala.util.graph.Node)
*/
public void removeNode(Object n) {
public void removeNode(Object n) throws UnimplementedError {
Assertions.UNREACHABLE();
}
public void addEdge(Object from, Object to) {
public void addEdge(Object from, Object to) throws UnimplementedError {
Assertions.UNREACHABLE();
}
@ -452,7 +453,7 @@ public class BasicHeapGraph extends HeapGraph {
Assertions.UNREACHABLE();
}
public boolean hasEdge(Object from, Object to) {
public boolean hasEdge(Object from, Object to) throws UnimplementedError {
Assertions.UNREACHABLE();
return false;
}
@ -495,23 +496,19 @@ public class BasicHeapGraph extends HeapGraph {
}
public void removeIncomingEdges(Object node) {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
}
public void removeOutgoingEdges(Object node) {
// TODO Auto-generated method stub
public void removeOutgoingEdges(Object node) throws UnimplementedError {
Assertions.UNREACHABLE();
}
public IntSet getSuccNodeNumbers(Object node) {
// TODO Auto-generated method stub
public IntSet getSuccNodeNumbers(Object node) throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}
public IntSet getPredNodeNumbers(Object node) {
// TODO Auto-generated method stub
public IntSet getPredNodeNumbers(Object node) throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}

View File

@ -14,10 +14,8 @@ package com.ibm.wala.analysis.typeInference;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.ipa.callgraph.ContextItem;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.debug.Assertions;
/**
*
* Abstraction of a Java type. These are immutable.
*
* @author sfink
@ -77,8 +75,7 @@ public abstract class TypeAbstraction implements ContextItem {
* TODO: probably should get rid of it.
*/
public IClass getType() {
Assertions.UNREACHABLE("getType not implemented for " + getClass());
return null;
throw new UnsupportedOperationException("getType not implemented for " + getClass());
}
}

View File

@ -26,6 +26,7 @@ import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.collections.Iterator2Collection;
import com.ibm.wala.util.collections.NonNullSingletonIterator;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.graph.impl.DelegatingNumberedNodeManager;
import com.ibm.wala.util.graph.impl.NumberedNodeIterator;
import com.ibm.wala.util.graph.impl.SparseNumberedEdgeManager;
@ -413,11 +414,7 @@ public abstract class AbstractCFG implements ControlFlowGraph, Constants {
return nodeManager.iterator();
}
/**
* @param src
* @param dst
*/
public void addEdge(IBasicBlock src, IBasicBlock dst) {
public void addEdge(IBasicBlock src, IBasicBlock dst) throws UnimplementedError {
Assertions.UNREACHABLE("Don't call me .. use addNormalEdge or addExceptionalEdge");
}
@ -501,14 +498,14 @@ public abstract class AbstractCFG implements ControlFlowGraph, Constants {
/*
* @see com.ibm.wala.util.graph.Graph#removeNode(com.ibm.wala.util.graph.Node)
*/
public void removeNodeAndEdges(IBasicBlock N) {
public void removeNodeAndEdges(IBasicBlock N) throws UnimplementedError {
Assertions.UNREACHABLE();
}
/*
* @see com.ibm.wala.util.graph.NodeManager#remove(com.ibm.wala.util.graph.Node)
*/
public void removeNode(IBasicBlock n) {
public void removeNode(IBasicBlock n) throws UnimplementedError {
Assertions.UNREACHABLE();
}
@ -570,7 +567,7 @@ public abstract class AbstractCFG implements ControlFlowGraph, Constants {
/*
* @see com.ibm.wala.util.graph.EdgeManager#removeEdges(java.lang.Object)
*/
public void removeAllIncidentEdges(IBasicBlock node) {
public void removeAllIncidentEdges(IBasicBlock node) throws UnimplementedError {
Assertions.UNREACHABLE();
}
@ -602,12 +599,10 @@ public abstract class AbstractCFG implements ControlFlowGraph, Constants {
}
public void removeIncomingEdges(IBasicBlock node) {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
}
public void removeOutgoingEdges(IBasicBlock node) {
// TODO Auto-generated method stub
public void removeOutgoingEdges(IBasicBlock node) throws UnimplementedError {
Assertions.UNREACHABLE();
}

View File

@ -161,7 +161,7 @@ public class TwoExitCFG implements ControlFlowGraph {
* @see com.ibm.wala.util.graph.Graph#removeNodeAndEdges(java.lang.Object)
*/
public void removeNodeAndEdges(IBasicBlock N) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public int getNumber(IBasicBlock N) {
@ -308,26 +308,22 @@ public class TwoExitCFG implements ControlFlowGraph {
* java.lang.Object)
*/
public void addEdge(IBasicBlock src, IBasicBlock dst) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public void removeEdge(IBasicBlock src, IBasicBlock dst) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public boolean hasEdge(IBasicBlock src, IBasicBlock dst) {
Assertions.UNREACHABLE();
return false;
throw new UnsupportedOperationException();
}
public void removeAllIncidentEdges(IBasicBlock node) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
/**
* @author sfink
*
* An additional basic block to model exceptional exits
*/
public final class ExceptionalExitBlock implements ISSABasicBlock {

View File

@ -20,6 +20,7 @@ import java.util.Iterator;
import com.ibm.wala.util.collections.NonNullSingletonIterator;
import com.ibm.wala.util.config.FileProvider;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
public abstract class AbstractURLModule implements Module, ModuleEntry {
@ -59,7 +60,7 @@ public abstract class AbstractURLModule implements Module, ModuleEntry {
return false;
}
public Module asModule() {
public Module asModule() throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}

View File

@ -24,6 +24,7 @@ import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.Atom;
import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
/**
* Implementation of IClass for array classes.
@ -213,7 +214,7 @@ public class ArrayClass implements IClass, Constants {
/*
* @see com.ibm.wala.classLoader.IClass#getDeclaredStaticFields()
*/
public Collection<IField> getDeclaredStaticFields() {
public Collection<IField> getDeclaredStaticFields() throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}
@ -262,7 +263,7 @@ public class ArrayClass implements IClass, Constants {
/*
* @see com.ibm.wala.classLoader.IClass#getDirectInterfaces()
*/
public Collection<IClass> getDirectInterfaces() {
public Collection<IClass> getDirectInterfaces() throws UnimplementedError {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
return null;
@ -281,7 +282,7 @@ public class ArrayClass implements IClass, Constants {
/*
* @see com.ibm.wala.classLoader.IClass#getAllInstanceFields()
*/
public Collection<IField> getAllInstanceFields() throws ClassHierarchyException {
public Collection<IField> getAllInstanceFields() throws UnimplementedError, ClassHierarchyException {
Assertions.UNREACHABLE();
return null;
}
@ -289,7 +290,7 @@ public class ArrayClass implements IClass, Constants {
/*
* @see com.ibm.wala.classLoader.IClass#getAllStaticFields()
*/
public Collection<IField> getAllStaticFields() throws ClassHierarchyException {
public Collection<IField> getAllStaticFields() throws UnimplementedError, ClassHierarchyException {
Assertions.UNREACHABLE();
return null;
}
@ -297,7 +298,7 @@ public class ArrayClass implements IClass, Constants {
/*
* @see com.ibm.wala.classLoader.IClass#getAllMethods()
*/
public Collection<IMethod> getAllMethods() throws ClassHierarchyException {
public Collection<IMethod> getAllMethods() throws UnimplementedError, ClassHierarchyException {
Assertions.UNREACHABLE();
return null;
}
@ -305,7 +306,7 @@ public class ArrayClass implements IClass, Constants {
/*
* @see com.ibm.wala.classLoader.IClass#getAllFields()
*/
public Collection<IField> getAllFields() throws ClassHierarchyException {
public Collection<IField> getAllFields() throws UnimplementedError, ClassHierarchyException {
Assertions.UNREACHABLE();
return null;
}

View File

@ -162,16 +162,14 @@ public class SyntheticMethod implements IMethod {
* @see com.ibm.wala.classLoader.IMethod#getMaxLocals()
*/
public int getMaxLocals() {
Assertions.UNREACHABLE();
return 0;
throw new UnsupportedOperationException();
}
/**
* @see com.ibm.wala.classLoader.IMethod#getMaxStackHeight()
*/
public int getMaxStackHeight() {
Assertions.UNREACHABLE();
return 0;
throw new UnsupportedOperationException();
}
/**

View File

@ -42,7 +42,7 @@ public class ExplodedSupergraph<T> implements Graph<ExplodedSupergraphNode<T>> {
}
public void removeNodeAndEdges(ExplodedSupergraphNode N) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public Iterator<ExplodedSupergraphNode<T>> iterator() {
@ -56,13 +56,12 @@ public class ExplodedSupergraph<T> implements Graph<ExplodedSupergraphNode<T>> {
}
public void addNode(ExplodedSupergraphNode n) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public void removeNode(ExplodedSupergraphNode n) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public boolean containsNode(ExplodedSupergraphNode N) {

View File

@ -38,6 +38,7 @@ import com.ibm.wala.util.collections.MapUtil;
import com.ibm.wala.util.collections.NonNullSingletonIterator;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.Trace;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.graph.AbstractGraph;
import com.ibm.wala.util.graph.GraphIntegrity;
import com.ibm.wala.util.graph.NumberedEdgeManager;
@ -255,13 +256,12 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
}
}
public CGNode getProcOf(Object n) {
public CGNode getProcOf(Object n) throws IllegalArgumentException {
if (!(n instanceof com.ibm.wala.ipa.cfg.BasicBlockInContext) && n instanceof com.ibm.wala.cfg.IBasicBlock) {
throw new IllegalArgumentException(
"(n instanceof com.ibm.wala.cfg.IBasicBlock) and (not ( n instanceof com.ibm.wala.ipa.cfg.BasicBlockInContext ) )");
}
if (n instanceof IBasicBlock) {
if (Assertions.verifyAssertions) {
if (!(n instanceof BasicBlockInContext)) {
Assertions.UNREACHABLE(n.getClass().toString());
}
}
return partialIPFG.getCGNode((IBasicBlock) n);
} else {
return nodeManager.getProcOfCollapsedNode(n);
@ -941,8 +941,7 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
return nodeManager.getNumber(N);
}
public Object getNode(int number) {
// TODO Auto-generated method stub
public Object getNode(int number) throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}
@ -952,7 +951,6 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph<Object> implemen
}
public Iterator<Object> iterateNodes(IntSet s) {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
return null;
}

View File

@ -1105,21 +1105,18 @@ public class TabulationSolver<T, P> {
}
/**
* @param n2
* @param d2
* @param n1
* @return set of d1 s.t. (n1,d1) -> (n2,d2) is recorded as a summary edge, or
* null if none found
*/
public IntSet getSummarySources(T n2, int d2, T n1) {
Assertions.UNREACHABLE("not currently supported. be careful");
LocalSummaryEdges summaries = summaryEdges.get(supergraph.getProcOf(n1));
if (summaries == null) {
return null;
}
int num1 = supergraph.getLocalBlockNumber(n1);
int num2 = supergraph.getLocalBlockNumber(n2);
return summaries.getInvertedSummaryEdgesForTarget(num1, num2, d2);
throw new UnsupportedOperationException("not currently supported. be careful");
// LocalSummaryEdges summaries = summaryEdges.get(supergraph.getProcOf(n1));
// if (summaries == null) {
// return null;
// }
// int num1 = supergraph.getLocalBlockNumber(n1);
// int num2 = supergraph.getLocalBlockNumber(n2);
// return summaries.getInvertedSummaryEdgesForTarget(num1, num2, d2);
}
public TabulationProblem<T,P> getProblem() {

View File

@ -295,8 +295,10 @@ public class DemandRefinementPointsTo extends AbstractDemandPointsTo {
stateMachine = stateMachineFactory.make();
}
public Pair<PointsToResult, Collection<InstanceKey>> getPointsTo(PointerKey pk, Predicate<Collection<InstanceKey>> p2setPred) {
Assertions._assert(pk instanceof LocalPointerKey, "only locals for now");
public Pair<PointsToResult, Collection<InstanceKey>> getPointsTo(PointerKey pk, Predicate<Collection<InstanceKey>> p2setPred) throws IllegalArgumentException {
if (!(pk instanceof com.ibm.wala.ipa.callgraph.propagation.LocalPointerKey)) {
throw new IllegalArgumentException("only locals for now");
}
LocalPointerKey queriedPk = (LocalPointerKey) pk;
if (DEBUG) {
Trace.println("answering query for " + pk);

View File

@ -65,6 +65,7 @@ import com.ibm.wala.ssa.IR;
import com.ibm.wala.ssa.SSAAbstractInvokeInstruction;
import com.ibm.wala.ssa.SSAInvokeInstruction;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
/**
* Simple field-based points-to analysis using {@link DemandPointerFlowGraph}.
@ -79,7 +80,7 @@ public class TestNewGraphPointsTo extends AbstractDemandPointsTo {
super(cg, model, fam, cha, options);
}
public Collection<InstanceKey> getPointsTo(PointerKey pk) {
public Collection<InstanceKey> getPointsTo(PointerKey pk) throws UnimplementedError {
Assertions._assert(pk instanceof LocalPointerKey, "we only handle locals");
LocalPointerKey queriedPk = (LocalPointerKey) pk;

View File

@ -49,7 +49,10 @@ public class ReturnLabel extends CallLabel {
return new ReturnLabel(callSite);
}
public void visit(IFlowLabelVisitor v, Object dst) {
public void visit(IFlowLabelVisitor v, Object dst) throws IllegalArgumentException {
if (v == null) {
throw new IllegalArgumentException("v == null");
}
v.visitReturn(this, dst);
}

View File

@ -186,8 +186,6 @@ public class SimpleDemandPointerFlowGraph extends SlowSparseNumberedGraph<Object
}
/*
* (non-Javadoc)
*
* @see com.ibm.capa.util.graph.AbstractNumberedGraph#getPredNodeNumbers(java.lang.Object)
*/
@Override
@ -201,23 +199,17 @@ public class SimpleDemandPointerFlowGraph extends SlowSparseNumberedGraph<Object
}
/*
* (non-Javadoc)
*
* @see com.ibm.capa.util.graph.AbstractNumberedGraph#getSuccNodeNumbers(java.lang.Object)
*/
@Override
public IntSet getSuccNodeNumbers(Object node) {
if (node instanceof StaticFieldKey) {
Assertions.UNREACHABLE();
return null;
} else {
return super.getSuccNodeNumbers(node);
public IntSet getSuccNodeNumbers(Object node) throws IllegalArgumentException {
if (node instanceof com.ibm.wala.ipa.callgraph.propagation.StaticFieldKey) {
throw new IllegalArgumentException("node instanceof com.ibm.wala.ipa.callgraph.propagation.StaticFieldKey");
}
return super.getSuccNodeNumbers(node);
}
/*
* (non-Javadoc)
*
* @see com.ibm.capa.util.graph.AbstractGraph#getPredNodeCount(java.lang.Object)
*/
@Override
@ -231,23 +223,17 @@ public class SimpleDemandPointerFlowGraph extends SlowSparseNumberedGraph<Object
}
/*
* (non-Javadoc)
*
* @see com.ibm.capa.util.graph.AbstractGraph#getPredNodes(java.lang.Object)
*/
@Override
public Iterator<? extends Object> getPredNodes(Object N) {
if (N instanceof StaticFieldKey) {
Assertions.UNREACHABLE();
return null;
} else {
return super.getPredNodes(N);
public Iterator<? extends Object> getPredNodes(Object N) throws IllegalArgumentException {
if (N instanceof com.ibm.wala.ipa.callgraph.propagation.StaticFieldKey) {
throw new IllegalArgumentException("N instanceof com.ibm.wala.ipa.callgraph.propagation.StaticFieldKey");
}
return super.getPredNodes(N);
}
/*
* (non-Javadoc)
*
* @see com.ibm.capa.util.graph.AbstractGraph#getSuccNodeCount(java.lang.Object)
*/
@Override

View File

@ -59,8 +59,12 @@ public class Util {
/** The empty {@link BitSet}. */
public static final BitSet EMPTY_BITSET = new BitSet();
/** Convert an int[] to a {@link String} for printing */
public static String str(int[] ints) {
/** Convert an int[] to a {@link String} for printing
* @throws IllegalArgumentException if ints == null*/
public static String str(int[] ints) throws IllegalArgumentException {
if (ints == null) {
throw new IllegalArgumentException("ints == null");
}
StringBuffer s = new StringBuffer();
s.append("[");
for (int i = 0; i < ints.length; i++) {
@ -93,8 +97,12 @@ public class Util {
return s.toString();
}
/** Get a {@link String} representation of a {@link Throwable}. */
public static String str(Throwable thrown) {
/** Get a {@link String} representation of a {@link Throwable}.
* @throws IllegalArgumentException if thrown == null*/
public static String str(Throwable thrown) throws IllegalArgumentException {
if (thrown == null) {
throw new IllegalArgumentException("thrown == null");
}
// create a memory buffer to which to dump the trace
ByteArrayOutputStream traceDump = new ByteArrayOutputStream();
PrintWriter w = new PrintWriter(traceDump);
@ -107,9 +115,9 @@ public class Util {
* Test whether <em>some</em> element of the given {@link Collection}
* satisfies the given {@link Predicate}.
*/
public static <T> boolean forSome(Collection<T> c_, Predicate<T> p_) {
for (T t : c_) {
if (p_.test(t)) {
public static <T> boolean forSome(Collection<T> c, Predicate<T> p) {
for (T t : c) {
if (p.test(t)) {
return true;
}
}

View File

@ -44,6 +44,7 @@ import com.ibm.wala.types.FieldReference;
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.Atom;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
/**
* Pseudo-field modelling the contents of an array of reference type. Only for
@ -63,59 +64,43 @@ public class ArrayContents implements IField {
private ArrayContents() {
}
public TypeReference getFieldTypeReference() {
if (Assertions.verifyAssertions) {
Assertions.UNREACHABLE();
}
public TypeReference getFieldTypeReference() throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}
public boolean isFinal() {
if (Assertions.verifyAssertions) {
Assertions.UNREACHABLE();
}
public boolean isFinal() throws UnimplementedError {
Assertions.UNREACHABLE();
return false;
}
public boolean isPrivate() {
if (Assertions.verifyAssertions) {
Assertions.UNREACHABLE();
}
public boolean isPrivate() throws UnimplementedError {
Assertions.UNREACHABLE();
return false;
}
public boolean isProtected() {
if (Assertions.verifyAssertions) {
Assertions.UNREACHABLE();
}
public boolean isProtected() throws UnimplementedError {
Assertions.UNREACHABLE();
return false;
}
public boolean isPublic() {
if (Assertions.verifyAssertions) {
Assertions.UNREACHABLE();
}
public boolean isPublic() throws UnimplementedError {
Assertions.UNREACHABLE();
return false;
}
public boolean isStatic() {
if (Assertions.verifyAssertions) {
Assertions.UNREACHABLE();
}
public boolean isStatic() throws UnimplementedError {
Assertions.UNREACHABLE();
return false;
}
public IClass getDeclaringClass() {
if (Assertions.verifyAssertions) {
Assertions.UNREACHABLE();
}
Assertions.UNREACHABLE();
return null;
}
public Atom getName() {
if (Assertions.verifyAssertions) {
Assertions.UNREACHABLE();
}
Assertions.UNREACHABLE();
return null;
}
@ -125,12 +110,10 @@ public class ArrayContents implements IField {
}
public boolean isVolatile() {
// TODO Auto-generated method stub
return false;
}
public ClassHierarchy getClassHierarchy() {
// TODO Auto-generated method stub
public ClassHierarchy getClassHierarchy() throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}

View File

@ -90,8 +90,6 @@ public class PointerParamValueNumIterator implements Iterator<Integer> {
}
/*
* (non-Javadoc)
*
* @see java.util.Iterator#hasNext()
*/
public boolean hasNext() {
@ -99,8 +97,6 @@ public class PointerParamValueNumIterator implements Iterator<Integer> {
}
/*
* (non-Javadoc)
*
* @see java.util.Iterator#next()
*/
public Integer next() {
@ -113,11 +109,9 @@ public class PointerParamValueNumIterator implements Iterator<Integer> {
}
/*
* (non-Javadoc)
*
* @see java.util.Iterator#remove()
*/
public void remove() {
public void remove() throws UnsupportedOperationException {
throw new UnsupportedOperationException();
}

View File

@ -78,7 +78,10 @@ public class FILiveObjectAnalysis implements ILiveObjectAnalysis {
this.expensiveIntraproceduralAnalysis = expensiveIntraproceduralAnalysis;
}
public boolean mayBeLive(CGNode allocMethod, int allocPC, CGNode m, int instructionIndex) throws WalaException {
public boolean mayBeLive(CGNode allocMethod, int allocPC, CGNode m, int instructionIndex) throws IllegalArgumentException, WalaException {
if (allocMethod == null) {
throw new IllegalArgumentException("allocMethod == null");
}
NewSiteReference site = TrivialMethodEscape.findAlloc(allocMethod, allocPC);
InstanceKey ik = heapGraph.getHeapModel().getInstanceKeyForAllocation(allocMethod, site);
return mayBeLive(ik, m, instructionIndex);

View File

@ -13,7 +13,6 @@ package com.ibm.wala.fixedpoint.impl;
import com.ibm.wala.fixpoint.FixedPointConstants;
import com.ibm.wala.fixpoint.IVariable;
import com.ibm.wala.util.debug.Assertions;
/**
*
@ -25,9 +24,7 @@ public abstract class NullaryOperator extends AbstractOperator implements FixedP
@Override
public byte evaluate(IVariable lhs, IVariable[] rhs) {
// don't call this
Assertions.UNREACHABLE();
return 0;
throw new UnsupportedOperationException();
}
/**
* Evaluate this equation, setting a new value for the

View File

@ -11,8 +11,6 @@
package com.ibm.wala.fixedpoint.impl;
import com.ibm.wala.fixpoint.IVariable;
import com.ibm.wala.util.debug.Assertions;
/**
* Represents a single step, restricted to a nullary
@ -102,7 +100,6 @@ public abstract class NullaryStatement extends AbstractStatement {
}
public IVariable[] getRHS() {
Assertions.UNREACHABLE();
return null;
throw new UnsupportedOperationException();
}
}

View File

@ -35,9 +35,12 @@ public class ArgumentTypeEntrypoint extends Entrypoint {
private final IClassHierarchy cha;
/**
* @param method
* @throws IllegalArgumentException if method == null
*/
protected TypeReference[][] makeParameterTypes(IMethod method) {
protected TypeReference[][] makeParameterTypes(IMethod method) throws IllegalArgumentException {
if (method == null) {
throw new IllegalArgumentException("method == null");
}
TypeReference[][] result = new TypeReference[method.getNumberOfParameters()][];
for (int i = 0; i < result.length; i++) {
TypeReference t = method.getParameterType(i);
@ -91,10 +94,6 @@ public class ArgumentTypeEntrypoint extends Entrypoint {
return null;
}
/**
* @param method
* @param cha
*/
public ArgumentTypeEntrypoint(IMethod method, IClassHierarchy cha) {
super(method);
this.cha = cha;

View File

@ -29,6 +29,7 @@ import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.collections.NonNullSingletonIterator;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.Trace;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.graph.AbstractNumberedGraph;
import com.ibm.wala.util.graph.NodeManager;
import com.ibm.wala.util.graph.impl.DelegatingNumberedNodeManager;
@ -242,7 +243,7 @@ public abstract class BasicCallGraph extends AbstractNumberedGraph<CGNode> imple
}
@Override
public void removeNodeAndEdges(CGNode N) {
public void removeNodeAndEdges(CGNode N) throws UnimplementedError {
Assertions.UNREACHABLE();
}

View File

@ -98,45 +98,35 @@ public class FakeRootClass extends SyntheticClass {
* @see com.ibm.wala.classLoader.IClass#getModifiers()
*/
public int getModifiers() {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
return 0;
throw new UnsupportedOperationException();
}
/*
* @see com.ibm.wala.classLoader.IClass#getSuperclass()
*/
public IClass getSuperclass() {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
return null;
throw new UnsupportedOperationException();
}
/*
* @see com.ibm.wala.classLoader.IClass#getAllImplementedInterfaces()
*/
public Collection<IClass> getAllImplementedInterfaces() {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
return null;
throw new UnsupportedOperationException();
}
/*
* @see com.ibm.wala.classLoader.IClass#getAllAncestorInterfaces()
*/
public Collection<IClass> getAllAncestorInterfaces() {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
return null;
throw new UnsupportedOperationException();
}
/*
* @see com.ibm.wala.classLoader.IClass#getMethod(com.ibm.wala.classLoader.Selector)
*/
public IMethod getMethod(Selector selector) {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
return null;
throw new UnsupportedOperationException();
}
/*
@ -163,18 +153,14 @@ public class FakeRootClass extends SyntheticClass {
* @see com.ibm.wala.classLoader.IClass#getDeclaredMethods()
*/
public Collection<IMethod> getDeclaredMethods() {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
return null;
throw new UnsupportedOperationException();
}
/*
* @see com.ibm.wala.classLoader.IClass#getDeclaredInstanceFields()
*/
public Collection<IField> getDeclaredInstanceFields() {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
return null;
throw new UnsupportedOperationException();
}
/*

View File

@ -82,10 +82,6 @@ public class PartialCallGraph extends DelegatingGraph<CGNode> implements CallGra
return result;
}
public void dump(String filename) {
Assertions.UNREACHABLE();
}
public IClassHierarchy getClassHierarchy() {
return cg.getClassHierarchy();
}

View File

@ -32,6 +32,7 @@ import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.collections.SmallMap;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.Trace;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.graph.AbstractNumberedGraph;
import com.ibm.wala.util.graph.EdgeManager;
import com.ibm.wala.util.graph.Graph;
@ -837,7 +838,7 @@ public class PropagationGraph implements IFixedPointSystem {
return delegateGraph.containsNode(v);
}
public void addStatement(IFixedPointStatement statement) {
public void addStatement(IFixedPointStatement statement) throws UnimplementedError {
if (statement instanceof UnaryStatement) {
addStatement((UnaryStatement) statement);
} else if (statement instanceof GeneralStatement) {
@ -849,7 +850,7 @@ public class PropagationGraph implements IFixedPointSystem {
/**
* A graph of just the variables in the system. v1 -> v2 iff there exists an
* Assingment equation e s.t. e uses v1 and e defs v2.
* assignment equation e s.t. e uses v1 and e defs v2.
*
*/
public NumberedGraph<IVariable> getAssignmentGraph() {

View File

@ -42,6 +42,7 @@ import com.ibm.wala.util.collections.FilterIterator;
import com.ibm.wala.util.collections.HashMapFactory;
import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
/**
*
@ -194,12 +195,12 @@ public class TypeBasedHeapModel implements HeapModel {
return iKeyFactory.getClassHierarchy();
}
public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) {
public InstanceKey getInstanceKeyForAllocation(CGNode node, NewSiteReference allocation) throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}
public InstanceKey getInstanceKeyForMultiNewArray(CGNode node, NewSiteReference allocation, int dim) {
public InstanceKey getInstanceKeyForMultiNewArray(CGNode node, NewSiteReference allocation, int dim) throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}
@ -213,12 +214,12 @@ public class TypeBasedHeapModel implements HeapModel {
return null;
}
public InstanceKey getInstanceKeyForPEI(CGNode node, ProgramCounter instr, TypeReference type) {
public InstanceKey getInstanceKeyForPEI(CGNode node, ProgramCounter instr, TypeReference type) throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}
public InstanceKey getInstanceKeyForClassObject(TypeReference type) {
public InstanceKey getInstanceKeyForClassObject(TypeReference type) throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}

View File

@ -33,6 +33,7 @@ import com.ibm.wala.util.collections.FilterIterator;
import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.Trace;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.graph.GraphIntegrity;
import com.ibm.wala.util.graph.NumberedGraph;
import com.ibm.wala.util.graph.GraphIntegrity.UnsoundGraphException;
@ -92,7 +93,7 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* nodes in the call graph.
*
* @param CG
* the call graph
* the call graph
*/
public InterproceduralCFG(CallGraph CG) {
this(CG, IndiscriminateFilter.singleton(), false);
@ -102,10 +103,10 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* Build an Interprocedural CFG from a call graph.
*
* @param CG
* the call graph
* the call graph
* @param relevant
* a filter which accepts those call graph nodes which should be
* included in the I-CFG. Other nodes are ignored.
* a filter which accepts those call graph nodes which should be
* included in the I-CFG. Other nodes are ignored.
*/
public InterproceduralCFG(CallGraph CG, Filter relevant, boolean partitionExits) {
@ -190,7 +191,8 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
/**
* @param n
* @return the cfg for n, or null if none found
* @throws IllegalArgumentException if n == null
* @throws IllegalArgumentException
* if n == null
*/
public ControlFlowGraph getCFG(CGNode n) throws IllegalArgumentException {
if (n == null) {
@ -235,13 +237,13 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* Add edges to the IPCFG for the incoming edges incident on a basic block bb
*
* @param n
* a call graph node
* a call graph node
* @param cfg
* the CFG for n
* the CFG for n
* @param instrs
* the instructions for node n
* the instructions for node n
* @param bb
* a basic block in the CFG
* a basic block in the CFG
*/
private void addEdgesToNonEntryBlock(CGNode n, ControlFlowGraph cfg, IInstruction[] instrs, IBasicBlock bb) {
@ -364,9 +366,9 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* the caller
*
* @param returnBlock
* the return site for a call
* the return site for a call
* @param targetCFG
* the called method
* the called method
*/
private void addEdgesFromExceptionalExitToReturn(CGNode caller, IBasicBlock returnBlock, CGNode target, TwoExitCFG targetCFG) {
IBasicBlock texit = targetCFG.getExceptionalExit();
@ -383,11 +385,11 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
/**
* @param cfg
* the governing cfg
* the governing cfg
* @param ret
* a return site for the call
* a return site for the call
* @param call
* a basic block that ends in a call
* a basic block that ends in a call
* @return true iff bb is reached from pb by exceptional control flow
*/
private boolean representsExceptionalReturn(ControlFlowGraph cfg, IBasicBlock ret, IBasicBlock call) {
@ -404,9 +406,9 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* caller
*
* @param returnBlock
* the return site for a call
* the return site for a call
* @param targetCFG
* the called method
* the called method
*/
private void addEdgesFromNormalExitToReturn(CGNode caller, IBasicBlock returnBlock, CGNode target, TwoExitCFG targetCFG) {
IBasicBlock texit = targetCFG.getNormalExit();
@ -423,7 +425,7 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
/**
* @param cfg
* the governing cfg
* the governing cfg
* @return true iff bb is reached from pb by a normal return flow
*/
private boolean representsNormalReturn(ControlFlowGraph cfg, IBasicBlock ret, IBasicBlock call) {
@ -440,9 +442,9 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* caller
*
* @param returnBlock
* the return site for a call
* the return site for a call
* @param targetCFG
* the called method
* the called method
*/
private void addEdgesFromExitToReturn(CGNode caller, IBasicBlock returnBlock, CGNode target, ControlFlowGraph targetCFG) {
IBasicBlock texit = targetCFG.exit();
@ -461,9 +463,9 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* Add the incoming edges to the entry() block for a call graph node.
*
* @param n
* a node in the call graph
* a node in the call graph
* @param bb
* the entry() block for n
* the entry() block for n
*/
private void addEdgesToEntryBlock(CGNode n, IBasicBlock bb) {
@ -514,7 +516,7 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* hasCallVector
*
* @param cfg
* a control-flow graph
* a control-flow graph
*/
private void addNodeForEachBasicBlock(ControlFlowGraph cfg, CGNode N) {
for (Iterator bbs = cfg.iterator(); bbs.hasNext();) {
@ -577,16 +579,14 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* @see com.ibm.wala.util.graph.NodeManager#addNode(com.ibm.wala.util.graph.Node)
*/
public void addNode(BasicBlockInContext n) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
/*
* @see com.ibm.wala.util.graph.NodeManager#removeNode(com.ibm.wala.util.graph.Node)
*/
public void removeNode(BasicBlockInContext n) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
/*
@ -622,11 +622,11 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* com.ibm.wala.util.graph.Node)
*/
public void addEdge(BasicBlockInContext src, BasicBlockInContext dst) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public void removeEdge(BasicBlockInContext src, BasicBlockInContext dst) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
/*
@ -691,7 +691,7 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
* @return the set of CGNodes that B may call, according to the governing call
* graph.
* @throws IllegalArgumentException
* if B is null
* if B is null
*/
public Set<CGNode> getCallTargets(IBasicBlock B) {
if (B == null) {
@ -713,8 +713,8 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
IInvokeInstruction call = (IInvokeInstruction) statements[B.getLastInstructionIndex()];
int pc = cfg.getProgramCounter(B.getLastInstructionIndex());
CallSiteReference site = makeCallSiteReference(B.getMethod().getDeclaringClass().getClassLoader().getReference(), pc, call);
HashSet<CGNode> result = HashSetFactory.make(cg.getNumberOfTargets(Bnode,site));
for (Iterator<CGNode> it = cg.getPossibleTargets(Bnode,site).iterator(); it.hasNext();) {
HashSet<CGNode> result = HashSetFactory.make(cg.getNumberOfTargets(Bnode, site));
for (Iterator<CGNode> it = cg.getPossibleTargets(Bnode, site).iterator(); it.hasNext();) {
CGNode target = it.next();
result.add(target);
}
@ -722,15 +722,11 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
}
public void removeIncomingEdges(BasicBlockInContext node) {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public void removeOutgoingEdges(BasicBlockInContext node) {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public boolean hasEdge(BasicBlockInContext src, BasicBlockInContext dst) {
@ -741,8 +737,7 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
return G.getNumber(N);
}
public BasicBlockInContext getNode(int number) {
// TODO Auto-generated method stub
public BasicBlockInContext getNode(int number) throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}
@ -772,10 +767,10 @@ public class InterproceduralCFG implements NumberedGraph<BasicBlockInContext> {
/**
* @param bb
* node in the IPCFG that ends in a call
* node in the IPCFG that ends in a call
* @return the nodes that are return sites for this call.
* @throws IllegalArgumentException
* if bb is null
* if bb is null
*/
public Iterator<BasicBlockInContext> getReturnSites(BasicBlockInContext bb) {
if (bb == null) {

View File

@ -57,6 +57,7 @@ import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.collections.Iterator2Collection;
import com.ibm.wala.util.collections.MapUtil;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
import com.ibm.wala.util.intset.BitVectorIntSet;
import com.ibm.wala.util.intset.OrdinalSet;
@ -983,7 +984,7 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
}
@Override
public int getSuccNodeCount(Statement N) {
public int getSuccNodeCount(Statement N) throws UnimplementedError {
Assertions.UNREACHABLE();
return super.getSuccNodeCount(N);
}
@ -997,7 +998,7 @@ public class PDG extends SlowSparseNumberedGraph<Statement> {
}
@Override
public boolean hasEdge(Statement src, Statement dst) {
public boolean hasEdge(Statement src, Statement dst) throws UnimplementedError {
Assertions.UNREACHABLE();
return super.hasEdge(src, dst);
}

View File

@ -44,11 +44,11 @@ public class SDGView implements ISDG {
}
public void addEdge(Statement src, Statement dst) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public void addNode(Statement n) {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public boolean containsNode(Statement N) {
@ -139,33 +139,27 @@ public class SDGView implements ISDG {
}
public void removeAllIncidentEdges(Statement node) {
Assertions.UNREACHABLE();
delegate.removeAllIncidentEdges(node);
throw new UnsupportedOperationException();
}
public void removeEdge(Statement src, Statement dst) {
Assertions.UNREACHABLE();
delegate.removeEdge(src, dst);
throw new UnsupportedOperationException();
}
public void removeIncomingEdges(Statement node) {
Assertions.UNREACHABLE();
delegate.removeIncomingEdges(node);
throw new UnsupportedOperationException();
}
public void removeNode(Statement n) {
Assertions.UNREACHABLE();
delegate.removeNode(n);
throw new UnsupportedOperationException();
}
public void removeNodeAndEdges(Statement N) {
Assertions.UNREACHABLE();
delegate.removeNodeAndEdges(N);
throw new UnsupportedOperationException();
}
public void removeOutgoingEdges(Statement node) {
Assertions.UNREACHABLE();
delegate.removeOutgoingEdges(node);
throw new UnsupportedOperationException();
}
public ControlDependenceOptions getCOptions() {

View File

@ -26,6 +26,7 @@ import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.Atom;
import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
/**
*
@ -197,8 +198,7 @@ public class BypassSyntheticClass extends SyntheticClass {
/*
* @see com.ibm.wala.classLoader.IClass#getModifiers()
*/
public int getModifiers() {
// TODO Auto-generated method stub
public int getModifiers() throws UnimplementedError {
Assertions.UNREACHABLE();
return 0;
}

View File

@ -37,6 +37,7 @@ import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.collections.Iterator2Collection;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.Trace;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.graph.impl.NumberedNodeIterator;
import com.ibm.wala.util.intset.BitVector;
import com.ibm.wala.util.intset.IntSet;
@ -1016,13 +1017,11 @@ public class SSACFG implements ControlFlowGraph {
}
public void removeIncomingEdges(IBasicBlock node) {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public void removeOutgoingEdges(IBasicBlock node) {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public boolean hasEdge(IBasicBlock src, IBasicBlock dst) {
@ -1037,8 +1036,7 @@ public class SSACFG implements ControlFlowGraph {
return cfg.getSuccNodeNumbers(n);
}
public IntSet getPredNodeNumbers(IBasicBlock node) {
// TODO Auto-generated method stub
public IntSet getPredNodeNumbers(IBasicBlock node) throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}

View File

@ -32,6 +32,7 @@ import com.ibm.wala.util.collections.EmptyIterator;
import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.collections.NonNullSingletonIterator;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.intset.BitVector;
import com.ibm.wala.util.intset.IntSet;
import com.ibm.wala.util.intset.MutableSparseIntSet;
@ -152,7 +153,7 @@ public class ExplodedControlFlowGraph implements ControlFlowGraph {
return ir.getInstructions();
}
public IMethod getMethod() {
public IMethod getMethod() throws UnimplementedError {
Assertions.UNREACHABLE();
return null;
}
@ -310,23 +311,20 @@ public class ExplodedControlFlowGraph implements ControlFlowGraph {
}
public void removeAllIncidentEdges(IBasicBlock node) throws UnsupportedOperationException {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public void removeEdge(IBasicBlock src, IBasicBlock dst) throws UnsupportedOperationException {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public void removeIncomingEdges(IBasicBlock node) throws UnsupportedOperationException {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public void removeOutgoingEdges(IBasicBlock node) throws UnsupportedOperationException {
Assertions.UNREACHABLE();
throw new UnsupportedOperationException();
}
public int getMaxNumber() {

View File

@ -36,7 +36,7 @@ public class MapIterator<X,Y> implements Iterator<Y> {
return i.hasNext();
}
public void remove() {
public void remove() throws UnsupportedOperationException {
throw new java.lang.UnsupportedOperationException();
}

View File

@ -12,8 +12,6 @@ package com.ibm.wala.util.collections;
import java.util.Iterator;
import com.ibm.wala.util.debug.Assertions;
/**
*
* A 2-level iterator. has not been tested yet!
@ -43,8 +41,8 @@ public abstract class ComposedIterator<O,I> implements Iterator<I> {
public abstract Iterator<? extends I> makeInner(O outer);
public void remove() {
Assertions.UNREACHABLE();
public void remove() throws UnsupportedOperationException{
throw new UnsupportedOperationException();
}
public boolean hasNext() {

View File

@ -11,6 +11,7 @@
package com.ibm.wala.util.collections;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
import com.ibm.wala.util.intset.IntIterator;
/**
@ -50,7 +51,7 @@ public class CompoundIntIterator implements IntIterator {
}
@Override
public int hashCode() {
public int hashCode() throws UnimplementedError {
Assertions.UNREACHABLE("define a custom hash code to avoid non-determinism");
return 0;
}

View File

@ -31,7 +31,10 @@ public class Iterator2Collection<T> implements Collection<T> {
}
}
public static <T> Iterator2Collection<T> toCollection(Iterator<? extends T> i) {
public static <T> Iterator2Collection<T> toCollection(Iterator<? extends T> i) throws IllegalArgumentException {
if (i == null) {
throw new IllegalArgumentException("i == null");
}
return new Iterator2Collection<T>(i);
}

View File

@ -29,8 +29,12 @@ public class ReverseIterator<T> implements Iterator<T> {
/**
* @param other
* the iterator to reverse
* @throws IllegalArgumentException if other == null
*/
public ReverseIterator(Iterator<T> other) {
public ReverseIterator(Iterator<T> other) throws IllegalArgumentException {
if (other == null) {
throw new IllegalArgumentException("other == null");
}
while (other.hasNext()) {
list.add(other.next());
}

View File

@ -11,6 +11,7 @@
package com.ibm.wala.util.intset;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
/**
*
@ -145,7 +146,7 @@ public class BimodalMutableIntSet implements MutableIntSet {
/*
* @see com.ibm.wala.util.intset.MutableIntSet#intersectWith(com.ibm.wala.util.intset.IntSet)
*/
public void intersectWith(IntSet set) {
public void intersectWith(IntSet set) throws UnimplementedError {
if (set instanceof BimodalMutableIntSet) {
BimodalMutableIntSet that = (BimodalMutableIntSet) set;
impl.intersectWith(that.impl);

View File

@ -10,14 +10,17 @@
*******************************************************************************/
package com.ibm.wala.util.intset;
public final class FixedSizeBitVector
implements Cloneable, java.io.Serializable {
public final class FixedSizeBitVector implements Cloneable, java.io.Serializable {
public static final long serialVersionUID = 33181877746462822L;
private final static int LOG_BITS_PER_UNIT = 5;
private final static int MASK = 0xffffffff;
private final static int LOW_MASK = 0x1f;
private int bits[];
final private int nbits;
/**
@ -29,18 +32,24 @@ public final class FixedSizeBitVector
/**
* Creates an empty string with the specified size.
* @param nbits the size of the string
*
* @param nbits
* the size of the string
*/
public FixedSizeBitVector(int nbits) {
// subscript(nbits) is the length of the array needed to
// hold nbits
// subscript(nbits) is the length of the array needed to
// hold nbits
bits = new int[subscript(nbits) + 1];
this.nbits = nbits;
}
/**
* Creates a copy of a Bit String
* @param s the string to copy
* @throws IllegalArgumentException if s is null
*
* @param s
* the string to copy
* @throws IllegalArgumentException
* if s is null
*/
public FixedSizeBitVector(FixedSizeBitVector s) {
if (s == null) {
@ -62,7 +71,9 @@ public final class FixedSizeBitVector
/**
* Sets a bit.
* @param bit the bit to be set
*
* @param bit
* the bit to be set
*/
public void set(int bit) {
int shiftBits = bit & LOW_MASK;
@ -80,7 +91,9 @@ public final class FixedSizeBitVector
/**
* Clears a bit.
* @param bit the bit to be cleared
*
* @param bit
* the bit to be cleared
*/
public void clear(int bit) {
int shiftBits = bit & LOW_MASK;
@ -89,7 +102,9 @@ public final class FixedSizeBitVector
/**
* Gets a bit.
* @param bit the bit to be gotten
*
* @param bit
* the bit to be gotten
*/
public boolean get(int bit) {
int shiftBits = bit & LOW_MASK;
@ -105,6 +120,7 @@ public final class FixedSizeBitVector
bits[i] ^= MASK;
}
}
/**
* Return the NOT of a bit string
*/
@ -116,7 +132,9 @@ public final class FixedSizeBitVector
/**
* Logically ANDs this bit set with the specified set of bits.
* @param set the bit set to be ANDed with
*
* @param set
* the bit set to be ANDed with
*/
public void and(FixedSizeBitVector set) {
if (this == set) {
@ -127,12 +145,11 @@ public final class FixedSizeBitVector
bits[i] &= set.bits[i];
}
}
/**
* Return a new bit string as the AND of two others.
*/
public static FixedSizeBitVector and(
FixedSizeBitVector b1,
FixedSizeBitVector b2) {
public static FixedSizeBitVector and(FixedSizeBitVector b1, FixedSizeBitVector b2) {
FixedSizeBitVector b = new FixedSizeBitVector(b1);
b.and(b2);
return b;
@ -140,7 +157,9 @@ public final class FixedSizeBitVector
/**
* Logically ORs this bit set with the specified set of bits.
* @param set the bit set to be ORed with
*
* @param set
* the bit set to be ORed with
*/
public void or(FixedSizeBitVector set) {
if (this == set) { // should help alias analysis
@ -151,12 +170,11 @@ public final class FixedSizeBitVector
bits[i] |= set.bits[i];
}
}
/**
* Return a new FixedSizeBitVector as the OR of two others
*/
public static FixedSizeBitVector or(
FixedSizeBitVector b1,
FixedSizeBitVector b2) {
public static FixedSizeBitVector or(FixedSizeBitVector b1, FixedSizeBitVector b2) {
FixedSizeBitVector b = new FixedSizeBitVector(b1);
b.or(b2);
return b;
@ -164,8 +182,11 @@ public final class FixedSizeBitVector
/**
* Logically XORs this bit set with the specified set of bits.
* @param set the bit set to be XORed with
* @throws IllegalArgumentException if set is null
*
* @param set
* the bit set to be XORed with
* @throws IllegalArgumentException
* if set is null
*/
public void xor(FixedSizeBitVector set) {
if (set == null) {
@ -179,7 +200,9 @@ public final class FixedSizeBitVector
/**
* Check if the intersection of the two sets is empty
* @param other the set to check intersection with
*
* @param other
* the set to check intersection with
*/
public boolean intersectionEmpty(FixedSizeBitVector other) {
int n = bits.length;
@ -192,8 +215,11 @@ public final class FixedSizeBitVector
/**
* Copies the values of the bits in the specified set into this set.
* @param set the bit set to copy the bits from
* @throws IllegalArgumentException if set is null
*
* @param set
* the bit set to copy the bits from
* @throws IllegalArgumentException
* if set is null
*/
public void copyBits(FixedSizeBitVector set) {
if (set == null) {
@ -229,8 +255,8 @@ public final class FixedSizeBitVector
}
/**
* Calculates and returns the set's size in bits.
* The maximum element in the set is the size - 1st element.
* Calculates and returns the set's size in bits. The maximum element in the
* set is the size - 1st element.
*/
public int length() {
return bits.length << LOG_BITS_PER_UNIT;
@ -238,7 +264,9 @@ public final class FixedSizeBitVector
/**
* Compares this object against the specified object.
* @param obj the object to compare with
*
* @param obj
* the object to compare with
* @return true if the objects are the same; false otherwise.
*/
@Override
@ -295,7 +323,7 @@ public final class FixedSizeBitVector
StringBuffer buffer = new StringBuffer();
boolean needSeparator = false;
buffer.append('{');
// int limit = length();
// int limit = length();
int limit = this.nbits;
for (int i = 0; i < limit; i++) {
if (get(i)) {

View File

@ -11,6 +11,7 @@
package com.ibm.wala.util.intset;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.debug.UnimplementedError;
/**
* A sparse ordered, mutable duplicate-free, fully-encapsulated set of longs.
@ -146,8 +147,9 @@ public final class MutableSparseLongSet extends SparseLongSet implements Mutable
}
/**
* @throws UnimplementedError if not ( that instanceof com.ibm.wala.util.intset.SparseLongSet )
*/
public void copySet(LongSet that) {
public void copySet(LongSet that) throws UnimplementedError {
if (that instanceof SparseLongSet) {
SparseLongSet set = (SparseLongSet) that;
if (set.elements != null) {
@ -255,8 +257,9 @@ public final class MutableSparseLongSet extends SparseLongSet implements Mutable
* Add all elements from another int set.
*
* @return true iff this set changes
* @throws UnimplementedError if not ( set instanceof com.ibm.wala.util.intset.SparseLongSet )
*/
public boolean addAll(LongSet set) {
public boolean addAll(LongSet set) throws UnimplementedError {
if (set instanceof SparseLongSet) {
return addAll((SparseLongSet) set);
} else {

View File

@ -497,7 +497,10 @@ public class SparseIntSet implements IntSet {
}
}
public boolean containsAny(SparseIntSet set) {
public boolean containsAny(SparseIntSet set) throws IllegalArgumentException {
if (set == null) {
throw new IllegalArgumentException("set == null");
}
int i = 0;
for (int j = 0; j < set.size; j++) {
int x = set.elements[j];