diff --git a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java index 40c997fb5..4e4336eb4 100644 --- a/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java +++ b/com.ibm.wala.core.tests/src/com/ibm/wala/core/tests/callGraph/CallGraphTest.java @@ -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 thisCG = com.ibm.wala.ipa.callgraph.impl.Util.squashCallGraph(thisAlgorithm, cg); + Graph 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 squashCallGraph(final String name, final CallGraph cg) { + if (cg == null) { + throw new IllegalArgumentException("cg is null"); + } + final Set nodes = HashSetFactory.make(); + for (Iterator nodesI = cg.iterator(); nodesI.hasNext();) { + nodes.add(((CGNode) nodesI.next()).getMethod().getReference()); + } + + return new Graph() { + @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 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 getPredNodes(MethodReference N) { + Set pred = HashSetFactory.make(10); + MethodReference methodReference = N; + for (Iterator 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 getSuccNodes(MethodReference N) { + Set succ = HashSetFactory.make(10); + MethodReference methodReference = N; + for (Iterator i = cg.getNodes(methodReference).iterator(); i.hasNext();) + for (Iterator 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 succNodes = getSuccNodes(src); succNodes.hasNext();) { + if (dst.equals(succNodes.next())) { + return true; + } + } + return false; + } + }; + } + } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ReflectiveForObjectSubtypesEntrypoint.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ReflectiveForObjectSubtypesEntrypoint.java index 7e6889f22..e34b3ffad 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ReflectiveForObjectSubtypesEntrypoint.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ReflectiveForObjectSubtypesEntrypoint.java @@ -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) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ReflectiveSubtypesEntrypoint.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ReflectiveSubtypesEntrypoint.java index a1e5e2e42..342a74f2b 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ReflectiveSubtypesEntrypoint.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/ReflectiveSubtypesEntrypoint.java @@ -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) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/SetOfClasses.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/SetOfClasses.java index f235d8dc1..18acad655 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/SetOfClasses.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/SetOfClasses.java @@ -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 iterator(IClassHierarchy hierarchy) { if (hierarchy == null) { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/UnresolvedReflectionWarning.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/UnresolvedReflectionWarning.java index b4d3b8585..d0727ffc1 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/UnresolvedReflectionWarning.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/UnresolvedReflectionWarning.java @@ -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 { diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java index 5193a2f10..e39a27749 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/callgraph/impl/Util.java @@ -78,6 +78,7 @@ public class Util { * @throws IllegalArgumentException if g1 is null * @throws IllegalArgumentException if g2 is null */ + @Deprecated public static boolean areEqual(Graph g1, Graph 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 boolean isSubset(Graph g1, Graph 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 computeDarkEntrypointNodes(final CallGraph cg, final Collection 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 squashCallGraph(final String name, final CallGraph cg) { - if (cg == null) { - throw new IllegalArgumentException("cg is null"); - } - final Set nodes = HashSetFactory.make(); - for (Iterator nodesI = cg.iterator(); nodesI.hasNext();) { - nodes.add(((CGNode) nodesI.next()).getMethod().getReference()); - } - - return new Graph() { - @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 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 getPredNodes(MethodReference N) { - Set pred = HashSetFactory.make(10); - MethodReference methodReference = N; - for (Iterator 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 getSuccNodes(MethodReference N) { - Set succ = HashSetFactory.make(10); - MethodReference methodReference = N; - for (Iterator i = cg.getNodes(methodReference).iterator(); i.hasNext();) - for (Iterator 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 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 void checkGraphSubset(Graph supG, Graph subG) { - if (supG == null) { throw new IllegalArgumentException("supG is null"); } diff --git a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/HeapExclusions.java b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/HeapExclusions.java index 2b4725f08..389245529 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/HeapExclusions.java +++ b/com.ibm.wala.core/src/com/ibm/wala/ipa/slicer/HeapExclusions.java @@ -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 { diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/config/FileOfClasses.java b/com.ibm.wala.core/src/com/ibm/wala/util/config/FileOfClasses.java index 4085d11c9..bd3e51dc3 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/config/FileOfClasses.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/config/FileOfClasses.java @@ -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 { diff --git a/com.ibm.wala.core/src/com/ibm/wala/util/graph/GraphUtil.java b/com.ibm.wala.core/src/com/ibm/wala/util/graph/GraphUtil.java index f3b569410..2bb8bcbcb 100644 --- a/com.ibm.wala.core/src/com/ibm/wala/util/graph/GraphUtil.java +++ b/com.ibm.wala.core/src/com/ibm/wala/util/graph/GraphUtil.java @@ -10,6 +10,7 @@ *******************************************************************************/ package com.ibm.wala.util.graph; + /** * Utility methods for graphs. */ @@ -28,4 +29,5 @@ public class GraphUtil { } return edgeCount; } + } diff --git a/com.ibm.wala.shrike/src/com/ibm/wala/annotations/Internal.java b/com.ibm.wala.shrike/src/com/ibm/wala/annotations/Internal.java index e100599a7..bb1e46220 100644 --- a/com.ibm.wala.shrike/src/com/ibm/wala/annotations/Internal.java +++ b/com.ibm.wala.shrike/src/com/ibm/wala/annotations/Internal.java @@ -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 { diff --git a/com.ibm.wala.shrike/src/com/ibm/wala/annotations/NonNull.java b/com.ibm.wala.shrike/src/com/ibm/wala/annotations/NonNull.java index 04e146e33..f468af9d3 100644 --- a/com.ibm.wala.shrike/src/com/ibm/wala/annotations/NonNull.java +++ b/com.ibm.wala.shrike/src/com/ibm/wala/annotations/NonNull.java @@ -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 {