more argument checking
git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@1163 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
parent
637bdaf379
commit
42e43625cd
|
@ -188,6 +188,9 @@ public class FactoryBypassInterpreter implements RTAContextInterpreter, SSAConte
|
||||||
* com.ibm.wala.util.warnings.WarningSet)
|
* com.ibm.wala.util.warnings.WarningSet)
|
||||||
*/
|
*/
|
||||||
public int getNumberOfStatements(CGNode node, WarningSet warnings) {
|
public int getNumberOfStatements(CGNode node, WarningSet warnings) {
|
||||||
|
if (node == null) {
|
||||||
|
throw new IllegalArgumentException("node is null");
|
||||||
|
}
|
||||||
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
||||||
return m.allInstructions.size();
|
return m.allInstructions.size();
|
||||||
}
|
}
|
||||||
|
@ -654,6 +657,9 @@ public class FactoryBypassInterpreter implements RTAContextInterpreter, SSAConte
|
||||||
* com.ibm.wala.util.warnings.WarningSet)
|
* com.ibm.wala.util.warnings.WarningSet)
|
||||||
*/
|
*/
|
||||||
public Iterator iterateFieldsRead(CGNode node, WarningSet warnings) {
|
public Iterator iterateFieldsRead(CGNode node, WarningSet warnings) {
|
||||||
|
if (node == null) {
|
||||||
|
throw new IllegalArgumentException("node is null");
|
||||||
|
}
|
||||||
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
||||||
try {
|
try {
|
||||||
return CodeScanner.iterateFieldsRead(m, warnings);
|
return CodeScanner.iterateFieldsRead(m, warnings);
|
||||||
|
@ -671,6 +677,9 @@ public class FactoryBypassInterpreter implements RTAContextInterpreter, SSAConte
|
||||||
* com.ibm.wala.util.warnings.WarningSet)
|
* com.ibm.wala.util.warnings.WarningSet)
|
||||||
*/
|
*/
|
||||||
public Iterator iterateFieldsWritten(CGNode node, WarningSet warnings) {
|
public Iterator iterateFieldsWritten(CGNode node, WarningSet warnings) {
|
||||||
|
if (node == null) {
|
||||||
|
throw new IllegalArgumentException("node is null");
|
||||||
|
}
|
||||||
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
||||||
try {
|
try {
|
||||||
return CodeScanner.iterateFieldsWritten(m, warnings);
|
return CodeScanner.iterateFieldsWritten(m, warnings);
|
||||||
|
@ -706,6 +715,9 @@ public class FactoryBypassInterpreter implements RTAContextInterpreter, SSAConte
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasObjectArrayLoad(CGNode node, WarningSet warnings) {
|
public boolean hasObjectArrayLoad(CGNode node, WarningSet warnings) {
|
||||||
|
if (node == null) {
|
||||||
|
throw new IllegalArgumentException("node is null");
|
||||||
|
}
|
||||||
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
||||||
try {
|
try {
|
||||||
return CodeScanner.hasObjectArrayLoad(m, warnings);
|
return CodeScanner.hasObjectArrayLoad(m, warnings);
|
||||||
|
@ -717,6 +729,9 @@ public class FactoryBypassInterpreter implements RTAContextInterpreter, SSAConte
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasObjectArrayStore(CGNode node, WarningSet warnings) {
|
public boolean hasObjectArrayStore(CGNode node, WarningSet warnings) {
|
||||||
|
if (node == null) {
|
||||||
|
throw new IllegalArgumentException("node is null");
|
||||||
|
}
|
||||||
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
||||||
try {
|
try {
|
||||||
return CodeScanner.hasObjectArrayStore(m, warnings);
|
return CodeScanner.hasObjectArrayStore(m, warnings);
|
||||||
|
@ -728,6 +743,9 @@ public class FactoryBypassInterpreter implements RTAContextInterpreter, SSAConte
|
||||||
}
|
}
|
||||||
|
|
||||||
public Iterator iterateCastTypes(CGNode node, WarningSet warnings) {
|
public Iterator iterateCastTypes(CGNode node, WarningSet warnings) {
|
||||||
|
if (node == null) {
|
||||||
|
throw new IllegalArgumentException("node is null");
|
||||||
|
}
|
||||||
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
SpecializedFactoryMethod m = findOrCreateSpecializedFactoryMethod(node);
|
||||||
try {
|
try {
|
||||||
return CodeScanner.iterateCastTypes(m, warnings);
|
return CodeScanner.iterateCastTypes(m, warnings);
|
||||||
|
|
|
@ -112,6 +112,9 @@ public class EclipseProjectPath {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static EclipseProjectPath make(IPath workspaceRootPath, IJavaProject project) {
|
public static EclipseProjectPath make(IPath workspaceRootPath, IJavaProject project) {
|
||||||
|
if (workspaceRootPath == null) {
|
||||||
|
throw new IllegalArgumentException("workspaceRootPath is null");
|
||||||
|
}
|
||||||
return new EclipseProjectPath(workspaceRootPath, project);
|
return new EclipseProjectPath(workspaceRootPath, project);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,11 +51,17 @@ import com.ibm.wala.util.debug.Assertions;
|
||||||
public class JdtUtil {
|
public class JdtUtil {
|
||||||
|
|
||||||
public static String getFilePath(IJavaElement javaElt) {
|
public static String getFilePath(IJavaElement javaElt) {
|
||||||
|
if (javaElt == null) {
|
||||||
|
throw new IllegalArgumentException("javaElt is null");
|
||||||
|
}
|
||||||
String filePath = javaElt.getPath().toString();
|
String filePath = javaElt.getPath().toString();
|
||||||
return filePath;
|
return filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getPackageName(ICompilationUnit cu) {
|
public static String getPackageName(ICompilationUnit cu) {
|
||||||
|
if (cu == null) {
|
||||||
|
throw new IllegalArgumentException("cu is null");
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
IPackageDeclaration[] pkgDecl = cu.getPackageDeclarations();
|
IPackageDeclaration[] pkgDecl = cu.getPackageDeclarations();
|
||||||
|
|
||||||
|
@ -72,6 +78,9 @@ public class JdtUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getFullyQualifiedClassName(IType type) {
|
public static String getFullyQualifiedClassName(IType type) {
|
||||||
|
if (type == null) {
|
||||||
|
throw new IllegalArgumentException("type is null");
|
||||||
|
}
|
||||||
ICompilationUnit cu = (ICompilationUnit) type.getParent();
|
ICompilationUnit cu = (ICompilationUnit) type.getParent();
|
||||||
String packageName = getPackageName(cu);
|
String packageName = getPackageName(cu);
|
||||||
String className = type.getElementName();
|
String className = type.getElementName();
|
||||||
|
@ -112,8 +121,12 @@ public class JdtUtil {
|
||||||
*
|
*
|
||||||
* @param javaElt
|
* @param javaElt
|
||||||
* @return
|
* @return
|
||||||
|
* @throws IllegalArgumentException if javaElt is null
|
||||||
*/
|
*/
|
||||||
public static String getJdtHandleString(IJavaElement javaElt) {
|
public static String getJdtHandleString(IJavaElement javaElt) {
|
||||||
|
if (javaElt == null) {
|
||||||
|
throw new IllegalArgumentException("javaElt is null");
|
||||||
|
}
|
||||||
return javaElt.getHandleIdentifier();
|
return javaElt.getHandleIdentifier();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,6 +147,9 @@ public class JdtUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IJavaProject getProject(IJavaElement javaElt) {
|
public static IJavaProject getProject(IJavaElement javaElt) {
|
||||||
|
if (javaElt == null) {
|
||||||
|
throw new IllegalArgumentException("javaElt is null");
|
||||||
|
}
|
||||||
IJavaProject javaProject = javaElt.getJavaProject();
|
IJavaProject javaProject = javaElt.getJavaProject();
|
||||||
return javaProject;
|
return javaProject;
|
||||||
}
|
}
|
||||||
|
@ -156,6 +172,9 @@ public class JdtUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IJavaProject getJavaProject(IFile appJar) {
|
public static IJavaProject getJavaProject(IFile appJar) {
|
||||||
|
if (appJar == null) {
|
||||||
|
throw new IllegalArgumentException("appJar is null");
|
||||||
|
}
|
||||||
String projectName = appJar.getProject().getName();
|
String projectName = appJar.getProject().getName();
|
||||||
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
IJavaModel javaModel = JavaCore.create(workspaceRoot);
|
IJavaModel javaModel = JavaCore.create(workspaceRoot);
|
||||||
|
|
|
@ -114,6 +114,9 @@ public class ETypeHierarchyWrapper {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ETypeHierarchyWrapper loadFromFile(String fileName) throws FileNotFoundException {
|
public static ETypeHierarchyWrapper loadFromFile(String fileName) throws FileNotFoundException {
|
||||||
|
if (fileName == null) {
|
||||||
|
throw new IllegalArgumentException("fileName is null");
|
||||||
|
}
|
||||||
System.err.println("eload..");
|
System.err.println("eload..");
|
||||||
ETypeHierarchy t = eloadFromFile(fileName);
|
ETypeHierarchy t = eloadFromFile(fileName);
|
||||||
Assertions.productionAssertion(t != null);
|
Assertions.productionAssertion(t != null);
|
||||||
|
|
|
@ -259,8 +259,12 @@ public abstract class BasicCallGraph extends AbstractNumberedGraph<CGNode> imple
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Dump this callgraph to the specified file in dotty(1) format.
|
* Dump this callgraph to the specified file in dotty(1) format.
|
||||||
|
* @throws IllegalArgumentException if filename is null
|
||||||
*/
|
*/
|
||||||
public void dump(String filename) {
|
public void dump(String filename) {
|
||||||
|
if (filename == null) {
|
||||||
|
throw new IllegalArgumentException("filename is null");
|
||||||
|
}
|
||||||
File file = new File(filename);
|
File file = new File(filename);
|
||||||
try {
|
try {
|
||||||
PrintWriter out = new PrintWriter(new FileOutputStream(file));
|
PrintWriter out = new PrintWriter(new FileOutputStream(file));
|
||||||
|
|
|
@ -15,8 +15,10 @@ public abstract class AbstractFieldPointerKey extends AbstractPointerKey impleme
|
||||||
final protected InstanceKey instance;
|
final protected InstanceKey instance;
|
||||||
|
|
||||||
protected AbstractFieldPointerKey(InstanceKey container) {
|
protected AbstractFieldPointerKey(InstanceKey container) {
|
||||||
|
if (container == null) {
|
||||||
|
throw new IllegalArgumentException("container is null");
|
||||||
|
}
|
||||||
this.instance = container;
|
this.instance = container;
|
||||||
assert container != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public InstanceKey getInstanceKey() {
|
public InstanceKey getInstanceKey() {
|
||||||
|
|
|
@ -175,9 +175,9 @@ public abstract class SSAPropagationCallGraphBuilder extends PropagationCallGrap
|
||||||
private final boolean usePreTransitiveSolver;
|
private final boolean usePreTransitiveSolver;
|
||||||
|
|
||||||
protected SSAPropagationCallGraphBuilder(ClassHierarchy cha, WarningSet warnings, AnalysisOptions options,
|
protected SSAPropagationCallGraphBuilder(ClassHierarchy cha, WarningSet warnings, AnalysisOptions options,
|
||||||
PointerKeyFactory pointerKeyFactory, boolean preTransitive) {
|
PointerKeyFactory pointerKeyFactory) {
|
||||||
super(cha, warnings, options, pointerKeyFactory);
|
super(cha, warnings, options, pointerKeyFactory);
|
||||||
this.usePreTransitiveSolver = preTransitive;
|
this.usePreTransitiveSolver = options.usePreTransitiveSolver();
|
||||||
}
|
}
|
||||||
|
|
||||||
public SSAContextInterpreter getCFAContextInterpreter() {
|
public SSAContextInterpreter getCFAContextInterpreter() {
|
||||||
|
|
|
@ -33,7 +33,7 @@ public abstract class CFABuilder extends SSAPropagationCallGraphBuilder {
|
||||||
* @throws NullPointerException if options is null
|
* @throws NullPointerException if options is null
|
||||||
*/
|
*/
|
||||||
public CFABuilder(ClassHierarchy cha, WarningSet warnings, AnalysisOptions options) throws NullPointerException {
|
public CFABuilder(ClassHierarchy cha, WarningSet warnings, AnalysisOptions options) throws NullPointerException {
|
||||||
super(cha, warnings, options, new CFAPointerKeys(), options.usePreTransitiveSolver());
|
super(cha, warnings, options, new CFAPointerKeys());
|
||||||
}
|
}
|
||||||
|
|
||||||
public SSAContextInterpreter makeDefaultContextInterpreters(SSAContextInterpreter appContextInterpreter, AnalysisOptions options,
|
public SSAContextInterpreter makeDefaultContextInterpreters(SSAContextInterpreter appContextInterpreter, AnalysisOptions options,
|
||||||
|
|
|
@ -70,6 +70,9 @@ public class DefaultRTAInterpreter implements RTAContextInterpreter {
|
||||||
* @see com.ibm.wala.ipa.rta.RTAContextInterpreter#getAllocatedTypes(com.ibm.wala.classLoader.IMethod, com.ibm.detox.ipa.callgraph.Context, com.ibm.wala.util.warnings.WarningSet)
|
* @see com.ibm.wala.ipa.rta.RTAContextInterpreter#getAllocatedTypes(com.ibm.wala.classLoader.IMethod, com.ibm.detox.ipa.callgraph.Context, com.ibm.wala.util.warnings.WarningSet)
|
||||||
*/
|
*/
|
||||||
public Iterator<NewSiteReference> iterateNewSites(CGNode node, WarningSet warnings) {
|
public Iterator<NewSiteReference> iterateNewSites(CGNode node, WarningSet warnings) {
|
||||||
|
if (node == null) {
|
||||||
|
throw new IllegalArgumentException("node is null");
|
||||||
|
}
|
||||||
return getNodeInterpreter(node).iterateNewSites(node,warnings);
|
return getNodeInterpreter(node).iterateNewSites(node,warnings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,6 +100,9 @@ public class DefaultRTAInterpreter implements RTAContextInterpreter {
|
||||||
* @see com.ibm.wala.ipa.callgraph.propagation.xta.XTAContextInterpreter#iterateFieldsWritten(com.ibm.wala.ipa.callgraph.CGNode, com.ibm.wala.util.warnings.WarningSet)
|
* @see com.ibm.wala.ipa.callgraph.propagation.xta.XTAContextInterpreter#iterateFieldsWritten(com.ibm.wala.ipa.callgraph.CGNode, com.ibm.wala.util.warnings.WarningSet)
|
||||||
*/
|
*/
|
||||||
public Iterator iterateFieldsWritten(CGNode node, WarningSet warnings) {
|
public Iterator iterateFieldsWritten(CGNode node, WarningSet warnings) {
|
||||||
|
if (node == null) {
|
||||||
|
throw new IllegalArgumentException("node is null");
|
||||||
|
}
|
||||||
return getNodeInterpreter(node).iterateFieldsWritten(node, warnings);
|
return getNodeInterpreter(node).iterateFieldsWritten(node, warnings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,8 +57,9 @@ public class TypeBasedPointerAnalysis extends AbstractPointerAnalysis {
|
||||||
/**
|
/**
|
||||||
* @param klasses
|
* @param klasses
|
||||||
* Collection<IClass>
|
* Collection<IClass>
|
||||||
|
* @throws AssertionError if klasses is null
|
||||||
*/
|
*/
|
||||||
public TypeBasedPointerAnalysis(AnalysisOptions options, Collection<IClass> klasses, CallGraph cg) {
|
public TypeBasedPointerAnalysis(AnalysisOptions options, Collection<IClass> klasses, CallGraph cg) throws AssertionError {
|
||||||
super(cg, makeInstanceKeys(klasses));
|
super(cg, makeInstanceKeys(klasses));
|
||||||
this.klasses = klasses;
|
this.klasses = klasses;
|
||||||
heapModel = new TypeBasedHeapModel(options, klasses, cg);
|
heapModel = new TypeBasedHeapModel(options, klasses, cg);
|
||||||
|
@ -69,6 +70,7 @@ public class TypeBasedPointerAnalysis extends AbstractPointerAnalysis {
|
||||||
* Collection<IClass>
|
* Collection<IClass>
|
||||||
*/
|
*/
|
||||||
private static MutableMapping<InstanceKey> makeInstanceKeys(Collection<IClass> c) {
|
private static MutableMapping<InstanceKey> makeInstanceKeys(Collection<IClass> c) {
|
||||||
|
assert c != null;
|
||||||
MutableMapping<InstanceKey> result = new MutableMapping<InstanceKey>();
|
MutableMapping<InstanceKey> result = new MutableMapping<InstanceKey>();
|
||||||
for (Iterator<IClass> it = c.iterator(); it.hasNext();) {
|
for (Iterator<IClass> it = c.iterator(); it.hasNext();) {
|
||||||
IClass klass = it.next();
|
IClass klass = it.next();
|
||||||
|
|
|
@ -39,9 +39,10 @@ public class SyntheticIR extends IR {
|
||||||
* a Map giving information on constant values for the symbol table
|
* a Map giving information on constant values for the symbol table
|
||||||
* @param warnings
|
* @param warnings
|
||||||
* an object to track analysis warnings with
|
* an object to track analysis warnings with
|
||||||
|
* @throws AssertionError if method is null
|
||||||
*/
|
*/
|
||||||
public SyntheticIR(IMethod method, Context context, AbstractCFG cfg, SSAInstruction[] instructions, SSAOptions options,
|
public SyntheticIR(IMethod method, Context context, AbstractCFG cfg, SSAInstruction[] instructions, SSAOptions options,
|
||||||
Map<Integer, ConstantValue> constants, WarningSet warnings) {
|
Map<Integer, ConstantValue> constants, WarningSet warnings) throws AssertionError {
|
||||||
super(method, instructions, makeSymbolTable(method, instructions, constants), new SSACFG(method, cfg, instructions, warnings),
|
super(method, instructions, makeSymbolTable(method, instructions, constants), new SSACFG(method, cfg, instructions, warnings),
|
||||||
options);
|
options);
|
||||||
|
|
||||||
|
@ -55,6 +56,7 @@ public class SyntheticIR extends IR {
|
||||||
* Map: valune number (Integer) -> ConstantValue
|
* Map: valune number (Integer) -> ConstantValue
|
||||||
*/
|
*/
|
||||||
private static SymbolTable makeSymbolTable(IMethod method, SSAInstruction[] instructions, Map<Integer, ConstantValue> constants) {
|
private static SymbolTable makeSymbolTable(IMethod method, SSAInstruction[] instructions, Map<Integer, ConstantValue> constants) {
|
||||||
|
assert method != null;
|
||||||
SymbolTable symbolTable = new SymbolTable(method.getNumberOfParameters());
|
SymbolTable symbolTable = new SymbolTable(method.getNumberOfParameters());
|
||||||
|
|
||||||
// simulate allocation of value numbers
|
// simulate allocation of value numbers
|
||||||
|
|
|
@ -134,6 +134,9 @@ public class DelegatingNumberedEdgeManager<T extends INodeWithNumberedEdges> imp
|
||||||
* @see com.ibm.wala.util.graph.EdgeManager#getSuccNodeCount(com.ibm.wala.util.graph.Node)
|
* @see com.ibm.wala.util.graph.EdgeManager#getSuccNodeCount(com.ibm.wala.util.graph.Node)
|
||||||
*/
|
*/
|
||||||
public int getSuccNodeCount(T N) {
|
public int getSuccNodeCount(T N) {
|
||||||
|
if (N == null) {
|
||||||
|
throw new IllegalArgumentException("N is null");
|
||||||
|
}
|
||||||
INodeWithNumberedEdges en = (INodeWithNumberedEdges) N;
|
INodeWithNumberedEdges en = (INodeWithNumberedEdges) N;
|
||||||
return en.getSuccNumbers().size();
|
return en.getSuccNumbers().size();
|
||||||
}
|
}
|
||||||
|
@ -145,6 +148,9 @@ public class DelegatingNumberedEdgeManager<T extends INodeWithNumberedEdges> imp
|
||||||
* com.ibm.wala.util.graph.Node)
|
* com.ibm.wala.util.graph.Node)
|
||||||
*/
|
*/
|
||||||
public void addEdge(T src, T dst) {
|
public void addEdge(T src, T dst) {
|
||||||
|
if (dst == null) {
|
||||||
|
throw new IllegalArgumentException("dst is null");
|
||||||
|
}
|
||||||
src.addSucc(dst.getGraphNodeId());
|
src.addSucc(dst.getGraphNodeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +164,9 @@ public class DelegatingNumberedEdgeManager<T extends INodeWithNumberedEdges> imp
|
||||||
* @see com.ibm.wala.util.graph.EdgeManager#removeEdges(com.ibm.wala.util.graph.Node)
|
* @see com.ibm.wala.util.graph.EdgeManager#removeEdges(com.ibm.wala.util.graph.Node)
|
||||||
*/
|
*/
|
||||||
public void removeAllIncidentEdges(T node) {
|
public void removeAllIncidentEdges(T node) {
|
||||||
|
if (node == null) {
|
||||||
|
throw new IllegalArgumentException("node is null");
|
||||||
|
}
|
||||||
INodeWithNumberedEdges n = (INodeWithNumberedEdges) node;
|
INodeWithNumberedEdges n = (INodeWithNumberedEdges) node;
|
||||||
n.removeAllIncidentEdges();
|
n.removeAllIncidentEdges();
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,8 +73,12 @@ public class BoundedBFSIterator<T> implements Iterator<T> {
|
||||||
*
|
*
|
||||||
* @param G
|
* @param G
|
||||||
* the graph whose nodes to enumerate
|
* the graph whose nodes to enumerate
|
||||||
|
* @throws IllegalArgumentException if G is null
|
||||||
*/
|
*/
|
||||||
public BoundedBFSIterator(Graph<T> G, T N, int k) {
|
public BoundedBFSIterator(Graph<T> G, T N, int k) {
|
||||||
|
if (G == null) {
|
||||||
|
throw new IllegalArgumentException("G is null");
|
||||||
|
}
|
||||||
this.k = k;
|
this.k = k;
|
||||||
boundary = new int[k];
|
boundary = new int[k];
|
||||||
init(G, new NonNullSingletonIterator<T>(N));
|
init(G, new NonNullSingletonIterator<T>(N));
|
||||||
|
@ -88,8 +92,12 @@ public class BoundedBFSIterator<T> implements Iterator<T> {
|
||||||
* the graph whose nodes to enumerate
|
* the graph whose nodes to enumerate
|
||||||
* @param nodes
|
* @param nodes
|
||||||
* the set of nodes from which to start searching
|
* the set of nodes from which to start searching
|
||||||
|
* @throws IllegalArgumentException if G is null
|
||||||
*/
|
*/
|
||||||
public BoundedBFSIterator(Graph<T> G, Iterator <? extends T> nodes, int k) {
|
public BoundedBFSIterator(Graph<T> G, Iterator <? extends T> nodes, int k) {
|
||||||
|
if (G == null) {
|
||||||
|
throw new IllegalArgumentException("G is null");
|
||||||
|
}
|
||||||
this.k = k;
|
this.k = k;
|
||||||
boundary = new int[k];
|
boundary = new int[k];
|
||||||
init(G, nodes);
|
init(G, nodes);
|
||||||
|
|
|
@ -67,6 +67,9 @@ public class SparseIntSet implements IntSet {
|
||||||
* @param backingArray
|
* @param backingArray
|
||||||
*/
|
*/
|
||||||
protected SparseIntSet(int[] backingArray) {
|
protected SparseIntSet(int[] backingArray) {
|
||||||
|
if (backingArray == null) {
|
||||||
|
throw new IllegalArgumentException("backingArray is null");
|
||||||
|
}
|
||||||
elements = backingArray;
|
elements = backingArray;
|
||||||
this.size = backingArray.length;
|
this.size = backingArray.length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,9 @@ public class SparseLongSet implements LongSet {
|
||||||
* @param backingArray
|
* @param backingArray
|
||||||
*/
|
*/
|
||||||
protected SparseLongSet(long[] backingArray) {
|
protected SparseLongSet(long[] backingArray) {
|
||||||
|
if (backingArray == null) {
|
||||||
|
throw new IllegalArgumentException("backingArray is null");
|
||||||
|
}
|
||||||
elements = backingArray;
|
elements = backingArray;
|
||||||
this.size = backingArray.length;
|
this.size = backingArray.length;
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,8 +33,12 @@ public class FileUtil {
|
||||||
* List all the files in a directory that match a regular expression
|
* List all the files in a directory that match a regular expression
|
||||||
*
|
*
|
||||||
* @param recurse recurse to subdirectories?
|
* @param recurse recurse to subdirectories?
|
||||||
|
* @throws IllegalArgumentException if dir is null
|
||||||
*/
|
*/
|
||||||
public static Collection<File> listFiles(String dir, String regex, boolean recurse) {
|
public static Collection<File> listFiles(String dir, String regex, boolean recurse) {
|
||||||
|
if (dir == null) {
|
||||||
|
throw new IllegalArgumentException("dir is null");
|
||||||
|
}
|
||||||
File d = new File(dir);
|
File d = new File(dir);
|
||||||
Pattern p = null;
|
Pattern p = null;
|
||||||
if (regex != null) {
|
if (regex != null) {
|
||||||
|
|
|
@ -58,9 +58,13 @@ public class StringTable extends Table<String> implements Cloneable {
|
||||||
* read from a direct (native) text file
|
* read from a direct (native) text file
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
* @throws FileNotFoundException
|
* @throws FileNotFoundException
|
||||||
|
* @throws IllegalArgumentException if fileName is null
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static StringTable readFromDirectTextFile(String fileName) throws FileNotFoundException, IOException{
|
public static StringTable readFromDirectTextFile(String fileName) throws FileNotFoundException, IOException{
|
||||||
|
if (fileName == null) {
|
||||||
|
throw new IllegalArgumentException("fileName is null");
|
||||||
|
}
|
||||||
File f = new File(fileName);
|
File f = new File(fileName);
|
||||||
return readFromTextFile(f);
|
return readFromTextFile(f);
|
||||||
}
|
}
|
||||||
|
@ -109,8 +113,12 @@ public class StringTable extends Table<String> implements Cloneable {
|
||||||
* @param s
|
* @param s
|
||||||
* a stream containing a table in text format, whitespace delimited
|
* a stream containing a table in text format, whitespace delimited
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
|
* @throws IllegalArgumentException if s is null
|
||||||
*/
|
*/
|
||||||
public static StringTable readFromStream(InputStream s) throws IOException {
|
public static StringTable readFromStream(InputStream s) throws IOException {
|
||||||
|
if (s == null) {
|
||||||
|
throw new IllegalArgumentException("s is null");
|
||||||
|
}
|
||||||
StringTable result = new StringTable();
|
StringTable result = new StringTable();
|
||||||
|
|
||||||
LineNumberReader reader = new LineNumberReader(new InputStreamReader(s));
|
LineNumberReader reader = new LineNumberReader(new InputStreamReader(s));
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class ResolutionFailure extends MethodWarning {
|
||||||
this.ref = ref;
|
this.ref = ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResolutionFailure(CGNode node, Object ref) {
|
private ResolutionFailure(CGNode node, Object ref) {
|
||||||
this(node, ref, null);
|
this(node, ref, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ public class ResolutionFailure extends MethodWarning {
|
||||||
if (node == null) {
|
if (node == null) {
|
||||||
throw new IllegalArgumentException("node cannot be null");
|
throw new IllegalArgumentException("node cannot be null");
|
||||||
}
|
}
|
||||||
return new ResolutionFailure(node, ref);
|
return make(node, ref);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ResolutionFailure create(CGNode node, Object ref, String msg) throws IllegalArgumentException {
|
public static ResolutionFailure create(CGNode node, Object ref, String msg) throws IllegalArgumentException {
|
||||||
|
@ -64,6 +64,13 @@ public class ResolutionFailure extends MethodWarning {
|
||||||
return new ResolutionFailure(node, ref, msg);
|
return new ResolutionFailure(node, ref, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ResolutionFailure make(CGNode node, Object ref) {
|
||||||
|
if (node == null) {
|
||||||
|
throw new IllegalArgumentException("node is null");
|
||||||
|
}
|
||||||
|
return new ResolutionFailure(node, ref);
|
||||||
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see java.lang.Object#equals(java.lang.Object)
|
* @see java.lang.Object#equals(java.lang.Object)
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue