comments and deprecate some unused code

git-svn-id: https://wala.svn.sourceforge.net/svnroot/wala/trunk@3522 f5eafffb-2e1d-0410-98e4-8ec43c5233c4
This commit is contained in:
sjfink 2009-04-22 19:11:18 +00:00
parent 814bc5d6f1
commit 3fb8781d9d
11 changed files with 183 additions and 173 deletions

View File

@ -37,6 +37,7 @@ import com.ibm.wala.ssa.ISSABasicBlock;
import com.ibm.wala.types.Descriptor;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.util.collections.HashSetFactory;
import com.ibm.wala.util.debug.Assertions;
import com.ibm.wala.util.graph.Graph;
import com.ibm.wala.util.graph.GraphIntegrity;
import com.ibm.wala.util.graph.GraphIntegrity.UnsoundGraphException;
@ -351,7 +352,7 @@ public class CallGraphTest extends WalaTestCase {
System.err.println(thisAlgorithm + " methods reached: " + callGraphMethods.size());
System.err.println(CallGraphStats.getStats(cg));
Graph<MethodReference> thisCG = com.ibm.wala.ipa.callgraph.impl.Util.squashCallGraph(thisAlgorithm, cg);
Graph<MethodReference> thisCG = squashCallGraph(thisAlgorithm, cg);
if (superCG != null) {
com.ibm.wala.ipa.callgraph.impl.Util.checkGraphSubset(superCG, thisCG);
@ -373,4 +374,158 @@ public class CallGraphTest extends WalaTestCase {
return thisCG;
}
/**
* @param name
* @param cg
* @return a graph whose nodes are MethodReferences, and whose edges represent calls between MethodReferences
* @throws IllegalArgumentException if cg is null
*/
public static Graph<MethodReference> squashCallGraph(final String name, final CallGraph cg) {
if (cg == null) {
throw new IllegalArgumentException("cg is null");
}
final Set<MethodReference> nodes = HashSetFactory.make();
for (Iterator<CGNode> nodesI = cg.iterator(); nodesI.hasNext();) {
nodes.add(((CGNode) nodesI.next()).getMethod().getReference());
}
return new Graph<MethodReference>() {
@Override
public String toString() {
StringBuffer result = new StringBuffer();
result.append("squashed " + name + " call graph\n");
result.append("Original graph:");
result.append(cg.toString());
return result.toString();
}
/*
* @see com.ibm.wala.util.graph.NodeManager#iterateNodes()
*/
public Iterator<MethodReference> iterator() {
return nodes.iterator();
}
/*
* @see com.ibm.wala.util.graph.NodeManager#containsNode(java.lang.Object)
*/
public boolean containsNode(MethodReference N) {
return nodes.contains(N);
}
/*
* @see com.ibm.wala.util.graph.NodeManager#getNumberOfNodes()
*/
public int getNumberOfNodes() {
return nodes.size();
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#getPredNodes(java.lang.Object)
*/
public Iterator<MethodReference> getPredNodes(MethodReference N) {
Set<MethodReference> pred = HashSetFactory.make(10);
MethodReference methodReference = N;
for (Iterator<CGNode> i = cg.getNodes(methodReference).iterator(); i.hasNext();)
for (Iterator<? extends CGNode> ps = cg.getPredNodes(i.next()); ps.hasNext();)
pred.add(((CGNode) ps.next()).getMethod().getReference());
return pred.iterator();
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#getPredNodeCount(java.lang.Object)
*/
public int getPredNodeCount(MethodReference N) {
int count = 0;
for (Iterator<? extends MethodReference> ps = getPredNodes(N); ps.hasNext(); count++, ps.next())
;
return count;
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#getSuccNodes(java.lang.Object)
*/
public Iterator<MethodReference> getSuccNodes(MethodReference N) {
Set<MethodReference> succ = HashSetFactory.make(10);
MethodReference methodReference = N;
for (Iterator<? extends CGNode> i = cg.getNodes(methodReference).iterator(); i.hasNext();)
for (Iterator<? extends CGNode> ps = cg.getSuccNodes(i.next()); ps.hasNext();)
succ.add(((CGNode) ps.next()).getMethod().getReference());
return succ.iterator();
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#getSuccNodeCount(java.lang.Object)
*/
public int getSuccNodeCount(MethodReference N) {
int count = 0;
for (Iterator<MethodReference> ps = getSuccNodes(N); ps.hasNext(); count++, ps.next())
;
return count;
}
/*
* @see com.ibm.wala.util.graph.NodeManager#addNode(java.lang.Object)
*/
public void addNode(MethodReference n) {
Assertions.UNREACHABLE();
}
/*
* @see com.ibm.wala.util.graph.NodeManager#removeNode(java.lang.Object)
*/
public void removeNode(MethodReference n) {
Assertions.UNREACHABLE();
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#addEdge(java.lang.Object, java.lang.Object)
*/
public void addEdge(MethodReference src, MethodReference dst) {
Assertions.UNREACHABLE();
}
public void removeEdge(MethodReference src, MethodReference dst) {
Assertions.UNREACHABLE();
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#removeAllIncidentEdges(java.lang.Object)
*/
public void removeAllIncidentEdges(MethodReference node) {
Assertions.UNREACHABLE();
}
/*
* @see com.ibm.wala.util.graph.Graph#removeNodeAndEdges(java.lang.Object)
*/
public void removeNodeAndEdges(MethodReference N) {
Assertions.UNREACHABLE();
}
public void removeIncomingEdges(MethodReference node) {
// TODO Auto-generated method stubMethodReference
Assertions.UNREACHABLE();
}
public void removeOutgoingEdges(MethodReference node) {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
}
public boolean hasEdge(MethodReference src, MethodReference dst) {
for (Iterator<MethodReference> succNodes = getSuccNodes(src); succNodes.hasNext();) {
if (dst.equals(succNodes.next())) {
return true;
}
}
return false;
}
};
}
}

View File

@ -15,6 +15,11 @@ import com.ibm.wala.ipa.cha.IClassHierarchy;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeReference;
/**
* SJF: This is not used in my workspace. Is it dead?
* Deprecating for now.
*/
@Deprecated
public class ReflectiveForObjectSubtypesEntrypoint extends ReflectiveSubtypesEntrypoint {
public ReflectiveForObjectSubtypesEntrypoint(MethodReference method, IClassHierarchy cha) {

View File

@ -17,6 +17,11 @@ import com.ibm.wala.shrikeBT.IInvokeInstruction;
import com.ibm.wala.types.MethodReference;
import com.ibm.wala.types.TypeReference;
/**
* SJF: This is not used in my workspace. Is it dead?
* Deprecating for now.
*/
@Deprecated
abstract public class ReflectiveSubtypesEntrypoint extends SubtypesEntrypoint {
public ReflectiveSubtypesEntrypoint(MethodReference method, IClassHierarchy cha) {

View File

@ -13,6 +13,7 @@ package com.ibm.wala.ipa.callgraph.impl;
import java.io.Serializable;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.ipa.cha.IClassHierarchy;
@ -20,6 +21,9 @@ import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.collections.HashSetFactory;
/**
* Logically, a set of {@link IClass}.
*
* TODO: why does this not extend {@link Set}? Is there a good reason anymore?
*/
public abstract class SetOfClasses implements Serializable {
@ -28,11 +32,9 @@ public abstract class SetOfClasses implements Serializable {
public abstract boolean contains(TypeReference klass);
/**
* Iterate all classes in the given hierarchy that this set
* contains.
* @param hierarchy
* @return Iterator of IClass
* @throws IllegalArgumentException if hierarchy is null
* Iterate all classes in the given hierarchy that this set contains.
*
* @throws IllegalArgumentException if hierarchy is null
*/
public Iterator<IClass> iterator(IClassHierarchy hierarchy) {
if (hierarchy == null) {

View File

@ -10,9 +10,13 @@
*******************************************************************************/
package com.ibm.wala.ipa.callgraph.impl;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.ipa.callgraph.CGNode;
import com.ibm.wala.util.warnings.MethodWarning;
/**
* A warning about a failure to resolve reflection relating to a particular {@link IMethod}.
*/
public class UnresolvedReflectionWarning extends MethodWarning {
public UnresolvedReflectionWarning(CGNode node) throws NullPointerException {

View File

@ -78,6 +78,7 @@ public class Util {
* @throws IllegalArgumentException if g1 is null
* @throws IllegalArgumentException if g2 is null
*/
@Deprecated
public static <T> boolean areEqual(Graph<T> g1, Graph<T> g2) {
if (g2 == null) {
throw new IllegalArgumentException("g2 is null");
@ -113,6 +114,7 @@ public class Util {
* @throws IllegalArgumentException if g1 is null
* @throws IllegalArgumentException if g2 is null
*/
@Deprecated
public static <T> boolean isSubset(Graph<T> g1, Graph<T> g2) {
if (g2 == null) {
throw new IllegalArgumentException("g2 is null");
@ -181,6 +183,7 @@ public class Util {
* @return the Set of CGNodes in the call graph that are reachable without traversing any entrypoint node
* @throws IllegalArgumentException if cg is null
*/
@Deprecated
public static Collection<CGNode> computeDarkEntrypointNodes(final CallGraph cg, final Collection<CGNode> entrypoints) {
if (cg == null) {
@ -321,160 +324,7 @@ public class Util {
};
}
/**
* @param name
* @param cg
* @return a graph whose nodes are MethodReferences, and whose edges represent calls between MethodReferences
* @throws IllegalArgumentException if cg is null
*/
public static Graph<MethodReference> squashCallGraph(final String name, final CallGraph cg) {
if (cg == null) {
throw new IllegalArgumentException("cg is null");
}
final Set<MethodReference> nodes = HashSetFactory.make();
for (Iterator nodesI = cg.iterator(); nodesI.hasNext();) {
nodes.add(((CGNode) nodesI.next()).getMethod().getReference());
}
return new Graph<MethodReference>() {
@Override
public String toString() {
StringBuffer result = new StringBuffer();
result.append("squashed " + name + " call graph\n");
result.append("Original graph:");
result.append(cg.toString());
return result.toString();
}
/*
* @see com.ibm.wala.util.graph.NodeManager#iterateNodes()
*/
public Iterator<MethodReference> iterator() {
return nodes.iterator();
}
/*
* @see com.ibm.wala.util.graph.NodeManager#containsNode(java.lang.Object)
*/
public boolean containsNode(MethodReference N) {
return nodes.contains(N);
}
/*
* @see com.ibm.wala.util.graph.NodeManager#getNumberOfNodes()
*/
public int getNumberOfNodes() {
return nodes.size();
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#getPredNodes(java.lang.Object)
*/
public Iterator<MethodReference> getPredNodes(MethodReference N) {
Set<MethodReference> pred = HashSetFactory.make(10);
MethodReference methodReference = N;
for (Iterator<CGNode> i = cg.getNodes(methodReference).iterator(); i.hasNext();)
for (Iterator ps = cg.getPredNodes(i.next()); ps.hasNext();)
pred.add(((CGNode) ps.next()).getMethod().getReference());
return pred.iterator();
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#getPredNodeCount(java.lang.Object)
*/
public int getPredNodeCount(MethodReference N) {
int count = 0;
for (Iterator ps = getPredNodes(N); ps.hasNext(); count++, ps.next())
;
return count;
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#getSuccNodes(java.lang.Object)
*/
public Iterator<MethodReference> getSuccNodes(MethodReference N) {
Set<MethodReference> succ = HashSetFactory.make(10);
MethodReference methodReference = N;
for (Iterator<? extends CGNode> i = cg.getNodes(methodReference).iterator(); i.hasNext();)
for (Iterator<? extends CGNode> ps = cg.getSuccNodes(i.next()); ps.hasNext();)
succ.add(((CGNode) ps.next()).getMethod().getReference());
return succ.iterator();
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#getSuccNodeCount(java.lang.Object)
*/
public int getSuccNodeCount(MethodReference N) {
int count = 0;
for (Iterator ps = getSuccNodes(N); ps.hasNext(); count++, ps.next())
;
return count;
}
/*
* @see com.ibm.wala.util.graph.NodeManager#addNode(java.lang.Object)
*/
public void addNode(MethodReference n) {
Assertions.UNREACHABLE();
}
/*
* @see com.ibm.wala.util.graph.NodeManager#removeNode(java.lang.Object)
*/
public void removeNode(MethodReference n) {
Assertions.UNREACHABLE();
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#addEdge(java.lang.Object, java.lang.Object)
*/
public void addEdge(MethodReference src, MethodReference dst) {
Assertions.UNREACHABLE();
}
public void removeEdge(MethodReference src, MethodReference dst) {
Assertions.UNREACHABLE();
}
/*
* @see com.ibm.wala.util.graph.EdgeManager#removeAllIncidentEdges(java.lang.Object)
*/
public void removeAllIncidentEdges(MethodReference node) {
Assertions.UNREACHABLE();
}
/*
* @see com.ibm.wala.util.graph.Graph#removeNodeAndEdges(java.lang.Object)
*/
public void removeNodeAndEdges(MethodReference N) {
Assertions.UNREACHABLE();
}
public void removeIncomingEdges(MethodReference node) {
// TODO Auto-generated method stubMethodReference
Assertions.UNREACHABLE();
}
public void removeOutgoingEdges(MethodReference node) {
// TODO Auto-generated method stub
Assertions.UNREACHABLE();
}
public boolean hasEdge(MethodReference src, MethodReference dst) {
for (Iterator<MethodReference> succNodes = getSuccNodes(src); succNodes.hasNext();) {
if (dst.equals(succNodes.next())) {
return true;
}
}
return false;
}
};
}
/**
* create a set holding the contents of an {@link Iterator}
*/
@ -496,7 +346,6 @@ public class Util {
* @throws IllegalArgumentException if supG is null
*/
public static <T> void checkGraphSubset(Graph<T> supG, Graph<T> subG) {
if (supG == null) {
throw new IllegalArgumentException("supG is null");
}

View File

@ -24,9 +24,6 @@ import com.ibm.wala.util.debug.Assertions;
/**
* heap locations that should be excluded from data dependence during slicing
*
* @author sjfink
*
*/
public class HeapExclusions {

View File

@ -25,10 +25,7 @@ import com.ibm.wala.ipa.callgraph.impl.SetOfClasses;
import com.ibm.wala.types.TypeReference;
/**
*
* An object which represents a set of classes read from a text file.
*
* @author sfink
*/
public class FileOfClasses extends SetOfClasses implements Serializable {

View File

@ -10,6 +10,7 @@
*******************************************************************************/
package com.ibm.wala.util.graph;
/**
* Utility methods for graphs.
*/
@ -28,4 +29,5 @@ public class GraphUtil {
}
return edgeCount;
}
}

View File

@ -18,9 +18,6 @@ package com.ibm.wala.annotations;
* This annotation is placed in the shrike project just so it's
* at the top of the WALA project dependency hierarchy. It doesn't have
* anything to do with shrike.
*
* @author sjfink
*
*/
public @interface Internal {

View File

@ -12,9 +12,6 @@ package com.ibm.wala.annotations;
/**
* An annotation which indicates a Java element should not be null.
*
* @author sjfink
*
*/
public @interface NonNull {