diff --git a/com.ibm.wala.core/src/com/ibm/wala/cfg/AbstractCFG.java b/com.ibm.wala.core/src/com/ibm/wala/cfg/AbstractCFG.java index edf5ec8da..9d50b6e64 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/cfg/AbstractCFG.java +++ b/com.ibm.wala.core/src/com/ibm/wala/cfg/AbstractCFG.java @@ -634,7 +634,7 @@ public abstract class AbstractCFG implements ControlFlowGraph, Constants { return Iterator2Collection.toCollection(iterateNormalPredecessors(b)); } - public IntSet getPredNodeNumbers(IBasicBlock node) { + public IntSet getPredNodeNumbers(IBasicBlock node) throws UnimplementedError { Assertions.UNREACHABLE(); return null; } diff --git a/com.ibm.wala.core/src/com/ibm/wala/cfg/TwoExitCFG.java b/com.ibm.wala.core/src/com/ibm/wala/cfg/TwoExitCFG.java index beb301876..546bec775 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/cfg/TwoExitCFG.java +++ b/com.ibm.wala.core/src/com/ibm/wala/cfg/TwoExitCFG.java @@ -543,11 +543,11 @@ public class TwoExitCFG implements ControlFlowGraph { return new NumberedNodeIterator(s, this); } - public void removeIncomingEdges(IBasicBlock node) { + public void removeIncomingEdges(IBasicBlock node) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } - public void removeOutgoingEdges(IBasicBlock node) { + public void removeOutgoingEdges(IBasicBlock node) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/classLoader/SyntheticMethod.java b/com.ibm.wala.core/src/com/ibm/wala/classLoader/SyntheticMethod.java index 9dacbca16..39671fcfb 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/classLoader/SyntheticMethod.java +++ b/com.ibm.wala.core/src/com/ibm/wala/classLoader/SyntheticMethod.java @@ -152,7 +152,7 @@ public class SyntheticMethod implements IMethod { return new InducedCFG(getStatements(), this, Everywhere.EVERYWHERE); } - public BytecodeStream getBytecodeStream() { + public BytecodeStream getBytecodeStream() throws UnsupportedOperationException { throw new UnsupportedOperationException(); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/ExplodedSupergraph.java b/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/ExplodedSupergraph.java index 3fcd88970..583289f49 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/ExplodedSupergraph.java +++ b/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/ExplodedSupergraph.java @@ -217,7 +217,7 @@ public class ExplodedSupergraph implements Graph> { return count; } - public void addEdge(ExplodedSupergraphNode src, ExplodedSupergraphNode dst) { + public void addEdge(ExplodedSupergraphNode src, ExplodedSupergraphNode dst) throws UnsupportedOperationException { throw new UnsupportedOperationException(); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/PartiallyCollapsedSupergraph.java b/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/PartiallyCollapsedSupergraph.java index 4f4b69b1b..1c383c460 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/PartiallyCollapsedSupergraph.java +++ b/com.ibm.wala.core/src/com/ibm/wala/dataflow/IFDS/PartiallyCollapsedSupergraph.java @@ -264,8 +264,8 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph implemen throw new IllegalArgumentException( "(n instanceof com.ibm.wala.cfg.IBasicBlock) and (not ( n instanceof com.ibm.wala.ipa.cfg.BasicBlockInContext ) )"); } - if (n instanceof IBasicBlock) { - return partialIPFG.getCGNode((IBasicBlock) n); + if (n instanceof BasicBlockInContext) { + return partialIPFG.getCGNode((BasicBlockInContext) n); } else { return nodeManager.getProcOfCollapsedNode(n); } @@ -294,9 +294,8 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph implemen */ private void computeTransverseEdges() { // compute transverse edges that originate from basic blocks - for (Iterator it = partialIPFG.iterator(); it.hasNext();) { - IBasicBlock bb = (IBasicBlock) it.next(); - if (partialIPFG.hasCall((BasicBlockInContext) bb)) { + for (BasicBlockInContext bb: partialIPFG) { + if (partialIPFG.hasCall(bb)) { Set targets = partialIPFG.getCallTargets(bb); for (Iterator it2 = targets.iterator(); it2.hasNext();) { CGNode n = (CGNode) it2.next(); @@ -851,8 +850,8 @@ public class PartiallyCollapsedSupergraph extends AbstractGraph implemen * @see com.ibm.wala.dataflow.IFDS.ISupergraph#isReturn(java.lang.Object) */ public boolean isReturn(Object object) { - if (object instanceof IBasicBlock) { - return partialIPFG.isReturn(object); + if (object instanceof BasicBlockInContext) { + return partialIPFG.isReturn((BasicBlockInContext)object); } else { if (nodeManager.isCollapsedExit(object)) { CGNode node = getProcOf(object); diff --git a/com.ibm.wala.core/src/com/ibm/wala/demandpa/alg/SimpleDemandPointsTo.java b/com.ibm.wala.core/src/com/ibm/wala/demandpa/alg/SimpleDemandPointsTo.java index b04a198b9..1a2418525 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/demandpa/alg/SimpleDemandPointsTo.java +++ b/com.ibm.wala.core/src/com/ibm/wala/demandpa/alg/SimpleDemandPointsTo.java @@ -56,6 +56,7 @@ import com.ibm.wala.util.collections.FilterIterator; 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.traverse.SlowDFSDiscoverTimeIterator; /** @@ -74,7 +75,7 @@ public class SimpleDemandPointsTo extends AbstractDemandPointsTo { } @SuppressWarnings("unchecked") - public Collection getPointsTo(PointerKey pk) { + public Collection getPointsTo(PointerKey pk) throws UnimplementedError { Assertions._assert(pk instanceof LocalPointerKey, "we only handle locals"); LocalPointerKey lpk = (LocalPointerKey) pk; diff --git a/com.ibm.wala.core/src/com/ibm/wala/fixedpoint/impl/UnaryStatement.java b/com.ibm.wala.core/src/com/ibm/wala/fixedpoint/impl/UnaryStatement.java index 675a6b039..7d8e612eb 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/fixedpoint/impl/UnaryStatement.java +++ b/com.ibm.wala.core/src/com/ibm/wala/fixedpoint/impl/UnaryStatement.java @@ -158,7 +158,7 @@ public abstract class UnaryStatement extends AbstractStatement { return result; } - public IVariable[] getRHS() { + public IVariable[] getRHS() throws UnsupportedOperationException { // This should never be called ...use the more efficient getRightHandSide instead throw new UnsupportedOperationException(); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/OneCFABuilder.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/OneCFABuilder.java index 109658f71..142e20dc6 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/OneCFABuilder.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/OneCFABuilder.java @@ -31,7 +31,10 @@ import com.ibm.wala.ipa.cha.IClassHierarchy; public class OneCFABuilder extends CFABuilder { public static OneCFABuilder make(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache, - ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter, ReflectionSpecification reflect) { + ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter, ReflectionSpecification reflect) throws IllegalArgumentException { + if (options == null) { + throw new IllegalArgumentException("options == null"); + } return new OneCFABuilder(cha, options, cache, appContextSelector, appContextInterpreter, reflect); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ZeroXCFABuilder.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ZeroXCFABuilder.java index c4bb93b35..a24e027df 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ZeroXCFABuilder.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/propagation/cfa/ZeroXCFABuilder.java @@ -99,7 +99,10 @@ public class ZeroXCFABuilder extends CFABuilder { public static ZeroXCFABuilder make(IClassHierarchy cha, AnalysisOptions options, AnalysisCache cache, ContextSelector appContextSelector, SSAContextInterpreter appContextInterpreter, ReflectionSpecification reflect, - int instancePolicy) { + int instancePolicy) throws IllegalArgumentException { + if (options == null) { + throw new IllegalArgumentException("options == null"); + } return new ZeroXCFABuilder(cha, options, cache, appContextSelector, appContextInterpreter, reflect, instancePolicy); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/cfg/InterproceduralCFG.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/cfg/InterproceduralCFG.java index a22e3120c..0da54bab4 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/cfg/InterproceduralCFG.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/cfg/InterproceduralCFG.java @@ -526,32 +526,32 @@ public class InterproceduralCFG implements NumberedGraph { } BasicBlockInContext b = new BasicBlockInContext(N, bb); G.addNode(b); - if (hasCall(bb, cfg)) { + if (hasCall(b, cfg)) { hasCallVector.set(getNumber(b)); } } } /** - * @param B * @return the original CFG from whence B came + * @throws IllegalArgumentException if B == null */ - public ControlFlowGraph getCFG(IBasicBlock B) { - if (Assertions.verifyAssertions) { - Assertions._assert(B instanceof BasicBlockInContext); + public ControlFlowGraph getCFG(BasicBlockInContext B) throws IllegalArgumentException { + if (B == null) { + throw new IllegalArgumentException("B == null"); } return getCFG(getCGNode(B)); } /** - * @param B * @return the original CGNode from whence B came + * @throws IllegalArgumentException if B == null */ - public CGNode getCGNode(IBasicBlock B) { - if (Assertions.verifyAssertions) { - Assertions._assert(B instanceof BasicBlockInContext); + public CGNode getCGNode(BasicBlockInContext B) throws IllegalArgumentException { + if (B == null) { + throw new IllegalArgumentException("B == null"); } - return ((BasicBlockInContext) B).getNode(); + return B.getNode(); } /* @@ -662,10 +662,9 @@ public class InterproceduralCFG implements NumberedGraph { } /** - * @param B * @return true iff basic block B ends in a call instuction */ - private boolean hasCall(IBasicBlock B, ControlFlowGraph cfg) { + private boolean hasCall(BasicBlockInContext B, ControlFlowGraph cfg) { IInstruction[] statements = cfg.getInstructions(); int lastIndex = B.getLastInstructionIndex(); @@ -692,13 +691,10 @@ public class InterproceduralCFG implements NumberedGraph { * @throws IllegalArgumentException * if B is null */ - public Set getCallTargets(IBasicBlock B) { + public Set getCallTargets(BasicBlockInContext B) { if (B == null) { throw new IllegalArgumentException("B is null"); } - if (Assertions.verifyAssertions) { - Assertions._assert(B instanceof BasicBlockInContext); - } ControlFlowGraph cfg = getCFG(B); return getCallTargets(B, cfg, getCGNode(B)); } @@ -814,11 +810,10 @@ public class InterproceduralCFG implements NumberedGraph { } }; - public boolean isReturn(Object object) { - if (Assertions.verifyAssertions) { - Assertions._assert(object instanceof BasicBlockInContext); + public boolean isReturn(BasicBlockInContext bb) throws IllegalArgumentException { + if (bb == null) { + throw new IllegalArgumentException("bb == null"); } - BasicBlockInContext bb = (BasicBlockInContext) object; ControlFlowGraph cfg = getCFG(bb); for (Iterator it = cfg.getPredNodes(bb.getDelegate()); it.hasNext();) { IBasicBlock b = (IBasicBlock) it.next(); diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/HeapReachingDefs.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/HeapReachingDefs.java index 0fdf2a2aa..ea1a9915d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/HeapReachingDefs.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/HeapReachingDefs.java @@ -207,6 +207,7 @@ public class HeapReachingDefs { return result; } + @Override public String toString() { return delegate.toString(); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABuilder.java b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABuilder.java index 0eba2eb66..1411588c2 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABuilder.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ssa/SSABuilder.java @@ -58,7 +58,10 @@ import com.ibm.wala.util.intset.IntPair; public class SSABuilder extends AbstractIntStackMachine { public static SSABuilder make(ShrikeCTMethod method, SSACFG cfg, ShrikeCFG scfg, SSAInstruction[] instructions, - SymbolTable symbolTable, boolean buildLocalMap, boolean addPiNodes) { + SymbolTable symbolTable, boolean buildLocalMap, boolean addPiNodes) throws IllegalArgumentException { + if (scfg == null) { + throw new IllegalArgumentException("scfg == null"); + } return new SSABuilder(method, cfg, scfg, instructions, symbolTable, buildLocalMap, addPiNodes); } @@ -78,8 +81,8 @@ public class SSABuilder extends AbstractIntStackMachine { */ private final SSA2LocalMap localMap; - private SSABuilder(ShrikeCTMethod method, SSACFG cfg, ShrikeCFG scfg, SSAInstruction[] instructions, - SymbolTable symbolTable, boolean buildLocalMap, boolean addPiNodes) { + private SSABuilder(ShrikeCTMethod method, SSACFG cfg, ShrikeCFG scfg, SSAInstruction[] instructions, SymbolTable symbolTable, + boolean buildLocalMap, boolean addPiNodes) { super(scfg); localMap = buildLocalMap ? new SSA2LocalMap(scfg, instructions.length, cfg.getNumberOfNodes(), maxLocals) : null; init(new SymbolTableMeeter(symbolTable, cfg, instructions, scfg), new SymbolicPropagator(scfg, instructions, symbolTable, @@ -604,10 +607,10 @@ public class SSABuilder extends AbstractIntStackMachine { NewSiteReference ref = NewSiteReference.make(getCurrentProgramCounter(), t); if (t.isArrayType()) { int[] sizes = new int[t.getDimensionality()]; - for (int i = 0; i imp /* * @see com.ibm.wala.util.graph.EdgeManager#removeEdges(com.ibm.wala.util.graph.Node) */ - public void removeAllIncidentEdges(T node) { + public void removeAllIncidentEdges(T node) throws UnimplementedError { if (node == null) { throw new IllegalArgumentException("node is null"); } @@ -148,7 +148,7 @@ public class DelegatingNumberedEdgeManager imp /* * @see com.ibm.wala.util.graph.EdgeManager#removeEdges(com.ibm.wala.util.graph.Node) */ - public void removeIncomingEdges(T node) { + public void removeIncomingEdges(T node) throws UnimplementedError { if (node == null) { throw new IllegalArgumentException("node cannot be null"); } @@ -159,7 +159,7 @@ public class DelegatingNumberedEdgeManager imp /* * @see com.ibm.wala.util.graph.EdgeManager#removeEdges(com.ibm.wala.util.graph.Node) */ - public void removeOutgoingEdges(T node) { + public void removeOutgoingEdges(T node) throws UnimplementedError { if (node == null) { throw new IllegalArgumentException("node cannot be null"); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/graph/impl/SparseNumberedEdgeManager.java b/com.ibm.wala.core/src/com/ibm/wala/util/graph/impl/SparseNumberedEdgeManager.java index 9b2f2bb3d..c09b29521 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/graph/impl/SparseNumberedEdgeManager.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/graph/impl/SparseNumberedEdgeManager.java @@ -52,8 +52,12 @@ public final class SparseNumberedEdgeManager implements NumberedEdgeManager nodeManager, int normalCase, byte delegateImpl) { + public SparseNumberedEdgeManager(NumberedNodeManager nodeManager, int normalCase, byte delegateImpl) throws IllegalArgumentException { + if (normalCase < 0) { + throw new IllegalArgumentException("normalCase < 0"); + } this.nodeManager = nodeManager; if (normalCase == 0) { successors = new BasicNaturalRelation(defaultImpl, delegateImpl); diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/BasicNaturalRelation.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/BasicNaturalRelation.java index 1fb815b86..2219fb320 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/BasicNaturalRelation.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/BasicNaturalRelation.java @@ -74,11 +74,16 @@ public final class BasicNaturalRelation implements IBinaryNaturalRelation { * implemented with a SimpleIntVector, and the 2nd and 3rd are implemented * with TwoLevelIntVector * @throws IllegalArgumentException if implementation is null + * @throws IllegalArgumentException if implementation.length == 0 */ - public BasicNaturalRelation(byte[] implementation, byte vectorImpl) { + public BasicNaturalRelation(byte[] implementation, byte vectorImpl) throws IllegalArgumentException { + if (implementation == null) { throw new IllegalArgumentException("implementation is null"); } + if (implementation.length == 0) { + throw new IllegalArgumentException("implementation.length == 0"); + } smallStore = new IntVector[implementation.length]; for (int i = 0; i < implementation.length; i++) { switch (implementation[i]) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/BimodalMutableIntSet.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/BimodalMutableIntSet.java index 995212d4d..196d22b4b 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/BimodalMutableIntSet.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/BimodalMutableIntSet.java @@ -220,7 +220,7 @@ public class BimodalMutableIntSet implements MutableIntSet { return impl.max(); } - public static BimodalMutableIntSet makeCopy(IntSet B) throws IllegalArgumentException { + public static BimodalMutableIntSet makeCopy(IntSet B) throws UnimplementedError, IllegalArgumentException { if (B == null) { throw new IllegalArgumentException("B == null"); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/BimodalMutableIntSetFactory.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/BimodalMutableIntSetFactory.java index df870e1cb..c2b2cc32d 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/BimodalMutableIntSetFactory.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/BimodalMutableIntSetFactory.java @@ -10,6 +10,8 @@ *******************************************************************************/ package com.ibm.wala.util.intset; +import com.ibm.wala.util.debug.UnimplementedError; + /** * * An object that creates some bimodal mutable int sets. @@ -41,7 +43,7 @@ public class BimodalMutableIntSetFactory implements MutableIntSetFactory { /* * @see com.ibm.wala.util.intset.MutableIntSetFactory#make(com.ibm.wala.util.intset.IntSet) */ - public MutableIntSet makeCopy(IntSet x) throws IllegalArgumentException { + public MutableIntSet makeCopy(IntSet x) throws UnimplementedError, IllegalArgumentException { if (x == null) { throw new IllegalArgumentException("x == null"); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseLongSet.java b/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseLongSet.java index 84563c908..77d50858e 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseLongSet.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/intset/MutableSparseLongSet.java @@ -37,10 +37,12 @@ public final class MutableSparseLongSet extends SparseLongSet implements Mutable */ private final static int INITIAL_NONEMPTY_SIZE = 2; - /** - * @param set - */ - public MutableSparseLongSet(LongSet set) { + + public static MutableSparseLongSet make(LongSet set) { + return new MutableSparseLongSet(set); + } + + private MutableSparseLongSet(LongSet set) { super(); copySet(set); } 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 6b222ab88..6e45999cd 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 @@ -356,7 +356,7 @@ public class SparseLongSet implements LongSet { throw new IllegalArgumentException("that == null"); } if (that instanceof SparseLongSet) { - MutableSparseLongSet temp = new MutableSparseLongSet(this); + MutableSparseLongSet temp = MutableSparseLongSet.make(this); temp.intersectWith((SparseLongSet) that); return temp; } else {