(framework);
try {
solver.solve(null);
} catch (CancelException e) {
diff --git a/src/main/java/com/ibm/wala/examples/drivers/BoundedJSCallGraphDriver.java b/src/main/java/com/ibm/wala/examples/drivers/BoundedJSCallGraphDriver.java
index 25d290c2..035cc1af 100644
--- a/src/main/java/com/ibm/wala/examples/drivers/BoundedJSCallGraphDriver.java
+++ b/src/main/java/com/ibm/wala/examples/drivers/BoundedJSCallGraphDriver.java
@@ -9,28 +9,26 @@
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.NullProgressMonitor;
import com.ibm.wala.util.WalaException;
-
import java.io.IOException;
-import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
public class BoundedJSCallGraphDriver {
- /**
- * Driver for building indirection-bounded approximate call graphs.
- *
- * Usage: BoundedJSCallGraphDriver script_directory bound
- */
- public static void main(String[] args)
- throws IllegalArgumentException, IOException, CancelException, WalaException {
- Path scriptDir = Paths.get(args[0]);
- int bound = Integer.parseInt(args[1]);
- FieldBasedCGUtil f = new FieldBasedCGUtil(new CAstRhinoTranslatorFactory());
- FieldBasedCallGraphBuilder.CallGraphResult results =
- f.buildScriptDirBoundedCG(scriptDir, new NullProgressMonitor(), false, bound);
- CallGraph CG = results.getCallGraph();
- System.out.println(CallGraphStats.getStats(CG));
- System.out.println((new CallGraph2JSON()).serialize(CG));
- }
+ /**
+ * Driver for building indirection-bounded approximate call graphs.
+ *
+ * Usage: BoundedJSCallGraphDriver script_directory bound
+ */
+ public static void main(String[] args)
+ throws IllegalArgumentException, IOException, CancelException, WalaException {
+ Path scriptDir = Paths.get(args[0]);
+ int bound = Integer.parseInt(args[1]);
+ FieldBasedCGUtil f = new FieldBasedCGUtil(new CAstRhinoTranslatorFactory());
+ FieldBasedCallGraphBuilder.CallGraphResult results =
+ f.buildScriptDirBoundedCG(scriptDir, new NullProgressMonitor(), false, bound);
+ CallGraph CG = results.getCallGraph();
+ System.out.println(CallGraphStats.getStats(CG));
+ System.out.println((new CallGraph2JSON()).serialize(CG));
+ }
}
diff --git a/src/main/java/com/ibm/wala/examples/drivers/CSReachingDefsDriver.java b/src/main/java/com/ibm/wala/examples/drivers/CSReachingDefsDriver.java
index ae366d8f..fec1d82f 100644
--- a/src/main/java/com/ibm/wala/examples/drivers/CSReachingDefsDriver.java
+++ b/src/main/java/com/ibm/wala/examples/drivers/CSReachingDefsDriver.java
@@ -1,8 +1,5 @@
package com.ibm.wala.examples.drivers;
-import java.io.IOException;
-import java.util.Properties;
-
import com.ibm.wala.core.util.config.AnalysisScopeReader;
import com.ibm.wala.core.util.warnings.Warnings;
import com.ibm.wala.dataflow.IFDS.ISupergraph;
@@ -28,64 +25,69 @@
import com.ibm.wala.ssa.analysis.IExplodedBasicBlock;
import com.ibm.wala.util.collections.Pair;
import com.ibm.wala.util.io.CommandLine;
+import java.io.IOException;
+import java.util.Properties;
-
-/**
- * Driver for running {@link ContextSensitiveReachingDefs}
- *
- */
+/** Driver for running {@link ContextSensitiveReachingDefs} */
public class CSReachingDefsDriver {
- /**
- * Usage: CSReachingDefsDriver -scopeFile file_path -mainClass class_name
- *
- * Uses main() method of class_name as entrypoint.
- *
- * @throws IOException
- * @throws ClassHierarchyException
- * @throws CallGraphBuilderCancelException
- * @throws IllegalArgumentException
- */
- public static void main(String[] args) throws IOException, ClassHierarchyException, IllegalArgumentException, CallGraphBuilderCancelException {
- long start = System.currentTimeMillis();
- Properties p = CommandLine.parse(args);
- String scopeFile = p.getProperty("scopeFile");
- if (scopeFile == null) {
- throw new IllegalArgumentException("must specify scope file");
- }
- String mainClass = p.getProperty("mainClass");
- if (mainClass == null) {
- throw new IllegalArgumentException("must specify main class");
- }
- AnalysisScope scope = AnalysisScopeReader.instance.readJavaScope(scopeFile, null, CSReachingDefsDriver.class.getClassLoader());
- ExampleUtil.addDefaultExclusions(scope);
- IClassHierarchy cha = ClassHierarchyFactory.make(scope);
- System.out.println(cha.getNumberOfClasses() + " classes");
- System.out.println(Warnings.asString());
- Warnings.clear();
- AnalysisOptions options = new AnalysisOptions();
- Iterable entrypoints = Util.makeMainEntrypoints(cha, mainClass);
- options.setEntrypoints(entrypoints);
- // you can dial down reflection handling if you like
- options.setReflectionOptions(ReflectionOptions.NONE);
- AnalysisCache cache = new AnalysisCacheImpl();
- // other builders can be constructed with different Util methods
- CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha);
-// CallGraphBuilder builder = Util.makeNCFABuilder(2, options, cache, cha, scope);
-// CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
- System.out.println("building call graph...");
- CallGraph cg = builder.makeCallGraph(options, null);
-// System.out.println(cg);
- long end = System.currentTimeMillis();
- System.out.println("done");
- System.out.println("took " + (end-start) + "ms");
- System.out.println(CallGraphStats.getStats(cg));
-
- ContextSensitiveReachingDefs reachingDefs = new ContextSensitiveReachingDefs(cg, cache);
- TabulationResult, CGNode, Pair> result = reachingDefs.analyze();
- ISupergraph, CGNode> supergraph = reachingDefs.getSupergraph();
+ /**
+ * Usage: CSReachingDefsDriver -scopeFile file_path -mainClass class_name
+ *
+ * Uses main() method of class_name as entrypoint.
+ *
+ * @throws IOException
+ * @throws ClassHierarchyException
+ * @throws CallGraphBuilderCancelException
+ * @throws IllegalArgumentException
+ */
+ public static void main(String[] args)
+ throws IOException,
+ ClassHierarchyException,
+ IllegalArgumentException,
+ CallGraphBuilderCancelException {
+ long start = System.currentTimeMillis();
+ Properties p = CommandLine.parse(args);
+ String scopeFile = p.getProperty("scopeFile");
+ if (scopeFile == null) {
+ throw new IllegalArgumentException("must specify scope file");
+ }
+ String mainClass = p.getProperty("mainClass");
+ if (mainClass == null) {
+ throw new IllegalArgumentException("must specify main class");
+ }
+ AnalysisScope scope =
+ AnalysisScopeReader.instance.readJavaScope(
+ scopeFile, null, CSReachingDefsDriver.class.getClassLoader());
+ ExampleUtil.addDefaultExclusions(scope);
+ IClassHierarchy cha = ClassHierarchyFactory.make(scope);
+ System.out.println(cha.getNumberOfClasses() + " classes");
+ System.out.println(Warnings.asString());
+ Warnings.clear();
+ AnalysisOptions options = new AnalysisOptions();
+ Iterable entrypoints = Util.makeMainEntrypoints(cha, mainClass);
+ options.setEntrypoints(entrypoints);
+ // you can dial down reflection handling if you like
+ options.setReflectionOptions(ReflectionOptions.NONE);
+ AnalysisCache cache = new AnalysisCacheImpl();
+ // other builders can be constructed with different Util methods
+ CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha);
+ // CallGraphBuilder builder = Util.makeNCFABuilder(2, options, cache, cha, scope);
+ // CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
+ System.out.println("building call graph...");
+ CallGraph cg = builder.makeCallGraph(options, null);
+ // System.out.println(cg);
+ long end = System.currentTimeMillis();
+ System.out.println("done");
+ System.out.println("took " + (end - start) + "ms");
+ System.out.println(CallGraphStats.getStats(cg));
- // TODO print out some analysis results
- }
+ ContextSensitiveReachingDefs reachingDefs = new ContextSensitiveReachingDefs(cg, cache);
+ TabulationResult, CGNode, Pair>
+ result = reachingDefs.analyze();
+ ISupergraph, CGNode> supergraph =
+ reachingDefs.getSupergraph();
+ // TODO print out some analysis results
+ }
}
diff --git a/src/main/java/com/ibm/wala/examples/drivers/ConstructAllIRs.java b/src/main/java/com/ibm/wala/examples/drivers/ConstructAllIRs.java
index ea76055d..34cdc8ba 100644
--- a/src/main/java/com/ibm/wala/examples/drivers/ConstructAllIRs.java
+++ b/src/main/java/com/ibm/wala/examples/drivers/ConstructAllIRs.java
@@ -10,8 +10,6 @@
*******************************************************************************/
package com.ibm.wala.examples.drivers;
-import java.io.IOException;
-
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.classLoader.IMethod;
import com.ibm.wala.core.util.config.AnalysisScopeReader;
@@ -25,31 +23,26 @@
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.ipa.cha.ClassHierarchyFactory;
import com.ibm.wala.util.perf.Stopwatch;
+import java.io.IOException;
/**
- * An analysis skeleton that simply constructs IRs for all methods in a class hierarchy. Illustrates the use of
- * {@link ReferenceCleanser} to improve running time / reduce memory usage.
+ * An analysis skeleton that simply constructs IRs for all methods in a class hierarchy. Illustrates
+ * the use of {@link ReferenceCleanser} to improve running time / reduce memory usage.
*/
public class ConstructAllIRs {
- /**
- * Should we periodically clear out soft reference caches in an attempt to help the GC?
- */
- private final static boolean PERIODIC_WIPE_SOFT_CACHES = true;
+ /** Should we periodically clear out soft reference caches in an attempt to help the GC? */
+ private static final boolean PERIODIC_WIPE_SOFT_CACHES = true;
- /**
- * Interval which defines the period to clear soft reference caches
- */
- private final static int WIPE_SOFT_CACHE_INTERVAL = 2500;
+ /** Interval which defines the period to clear soft reference caches */
+ private static final int WIPE_SOFT_CACHE_INTERVAL = 2500;
- /**
- * Counter for wiping soft caches
- */
+ /** Counter for wiping soft caches */
private static int wipeCount = 0;
/**
* First command-line argument should be location of scope file for application to analyze
- *
+ *
* @throws IOException
* @throws ClassHierarchyException
*/
@@ -59,14 +52,17 @@ public static void main(String[] args) throws IOException, ClassHierarchyExcepti
// measure running time
Stopwatch s = new Stopwatch();
s.start();
- AnalysisScope scope = AnalysisScopeReader.instance.readJavaScope(scopeFile, null, ConstructAllIRs.class.getClassLoader());
+ AnalysisScope scope =
+ AnalysisScopeReader.instance.readJavaScope(
+ scopeFile, null, ConstructAllIRs.class.getClassLoader());
// build a type hierarchy
System.out.print("building class hierarchy...");
ClassHierarchy cha = ClassHierarchyFactory.make(scope);
System.out.println("done");
- // register class hierarchy and AnalysisCache with the reference cleanser, so that their soft references are appropriately wiped
+ // register class hierarchy and AnalysisCache with the reference cleanser, so that their soft
+ // references are appropriately wiped
ReferenceCleanser.registerClassHierarchy(cha);
AnalysisOptions options = new AnalysisOptions();
IAnalysisCacheView cache = new AnalysisCacheImpl(options.getSSAOptions());
@@ -83,7 +79,6 @@ public static void main(String[] args) throws IOException, ClassHierarchyExcepti
System.out.println("done");
s.stop();
System.out.println("RUNNING TIME: " + s.getElapsedMillis());
-
}
private static void wipeSoftCaches() {
@@ -95,5 +90,4 @@ private static void wipeSoftCaches() {
}
}
}
-
-}
\ No newline at end of file
+}
diff --git a/src/main/java/com/ibm/wala/examples/drivers/DemandPointsToDriver.java b/src/main/java/com/ibm/wala/examples/drivers/DemandPointsToDriver.java
index 447465e5..04abf7d8 100644
--- a/src/main/java/com/ibm/wala/examples/drivers/DemandPointsToDriver.java
+++ b/src/main/java/com/ibm/wala/examples/drivers/DemandPointsToDriver.java
@@ -31,7 +31,6 @@
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.collections.Pair;
-
import java.io.IOException;
import java.util.Collection;
import java.util.Iterator;
diff --git a/src/main/java/com/ibm/wala/examples/drivers/FieldBasedJSCallGraphDriver.java b/src/main/java/com/ibm/wala/examples/drivers/FieldBasedJSCallGraphDriver.java
index 0e93afc9..6c914df9 100644
--- a/src/main/java/com/ibm/wala/examples/drivers/FieldBasedJSCallGraphDriver.java
+++ b/src/main/java/com/ibm/wala/examples/drivers/FieldBasedJSCallGraphDriver.java
@@ -8,7 +8,6 @@
import com.ibm.wala.ipa.callgraph.CallGraphStats;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.WalaException;
-
import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
diff --git a/src/main/java/com/ibm/wala/examples/drivers/JSCallGraphDriver.java b/src/main/java/com/ibm/wala/examples/drivers/JSCallGraphDriver.java
index 2c1e7b70..4671e49a 100644
--- a/src/main/java/com/ibm/wala/examples/drivers/JSCallGraphDriver.java
+++ b/src/main/java/com/ibm/wala/examples/drivers/JSCallGraphDriver.java
@@ -1,9 +1,5 @@
package com.ibm.wala.examples.drivers;
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
import com.ibm.wala.cast.js.ipa.callgraph.JSCallGraphUtil;
import com.ibm.wala.cast.js.translator.CAstRhinoTranslatorFactory;
import com.ibm.wala.cast.js.util.JSCallGraphBuilderUtil;
@@ -11,23 +7,28 @@
import com.ibm.wala.ipa.callgraph.CallGraphStats;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.WalaException;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
public class JSCallGraphDriver {
- /**
- * Usage: JSCallGraphDriver path_to_js_file
- * @param args
- * @throws WalaException
- * @throws CancelException
- * @throws IOException
- * @throws IllegalArgumentException
- */
- public static void main(String[] args) throws IllegalArgumentException, IOException, CancelException, WalaException {
- Path path = Paths.get(args[0]);
- JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
- CallGraph CG = JSCallGraphBuilderUtil.makeScriptCG(
- path.getParent().toString(), path.getFileName().toString());
- System.out.println(CallGraphStats.getStats(CG));
- }
-
+ /**
+ * Usage: JSCallGraphDriver path_to_js_file
+ *
+ * @param args
+ * @throws WalaException
+ * @throws CancelException
+ * @throws IOException
+ * @throws IllegalArgumentException
+ */
+ public static void main(String[] args)
+ throws IllegalArgumentException, IOException, CancelException, WalaException {
+ Path path = Paths.get(args[0]);
+ JSCallGraphUtil.setTranslatorFactory(new CAstRhinoTranslatorFactory());
+ CallGraph CG =
+ JSCallGraphBuilderUtil.makeScriptCG(
+ path.getParent().toString(), path.getFileName().toString());
+ System.out.println(CallGraphStats.getStats(CG));
+ }
}
diff --git a/src/main/java/com/ibm/wala/examples/drivers/PDFTypeHierarchy.java b/src/main/java/com/ibm/wala/examples/drivers/PDFTypeHierarchy.java
index 49ee85d5..7aab9fce 100644
--- a/src/main/java/com/ibm/wala/examples/drivers/PDFTypeHierarchy.java
+++ b/src/main/java/com/ibm/wala/examples/drivers/PDFTypeHierarchy.java
@@ -10,11 +10,6 @@
*******************************************************************************/
package com.ibm.wala.examples.drivers;
-import java.io.File;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.function.Predicate;
-
import com.ibm.wala.classLoader.IClass;
import com.ibm.wala.core.util.config.AnalysisScopeReader;
import com.ibm.wala.core.viz.PDFViewUtil;
@@ -30,18 +25,20 @@
import com.ibm.wala.util.graph.GraphSlicer;
import com.ibm.wala.util.graph.impl.SlowSparseNumberedGraph;
import com.ibm.wala.util.viz.DotUtil;
+import java.io.File;
+import java.io.IOException;
+import java.util.Collection;
+import java.util.function.Predicate;
/**
- *
- * This simple example WALA application builds a TypeHierarchy and fires off
- * ghostview to viz a DOT representation.
- *
+ * This simple example WALA application builds a TypeHierarchy and fires off ghostview to viz a DOT
+ * representation.
+ *
* @author sfink
*/
public class PDFTypeHierarchy {
// This example takes one command-line argument, so args[1] should be the "-classpath" parameter
- final static int CLASSPATH_INDEX = 1;
-
+ static final int CLASSPATH_INDEX = 1;
public static void main(String[] args) throws IOException {
run(args);
@@ -51,7 +48,8 @@ public static Process run(String[] args) throws IOException {
try {
validateCommandLine(args);
String classpath = args[CLASSPATH_INDEX];
- AnalysisScope scope = AnalysisScopeReader.instance.makeJavaBinaryAnalysisScope(classpath, null);
+ AnalysisScope scope =
+ AnalysisScopeReader.instance.makeJavaBinaryAnalysisScope(classpath, null);
ExampleUtil.addDefaultExclusions(scope);
// invoke WALA to build a class hierarchy
@@ -78,20 +76,19 @@ public static Graph pruneGraph(Graph g, Predicate f) {
Collection slice = GraphSlicer.slice(g, f);
return GraphSlicer.prune(g, new CollectionFilter<>(slice));
}
-
- /**
- * Restrict g to nodes from the Application loader
- */
+
+ /** Restrict g to nodes from the Application loader */
public static Graph pruneForAppLoader(Graph g) throws WalaException {
- Predicate f = c -> (c.getClassLoader().getReference().equals(ClassLoaderReference.Application));
+ Predicate f =
+ c -> (c.getClassLoader().getReference().equals(ClassLoaderReference.Application));
return pruneGraph(g, f);
}
-
+
/**
* Validate that the command-line arguments obey the expected usage.
- *
- * Usage: args[0] : "-classpath" args[1] : String, a ";"-delimited class path
- *
+ *
+ * Usage: args[0] : "-classpath" args[1] : String, a ";"-delimited class path
+ *
* @throws UnsupportedOperationException if command-line is malformed.
*/
public static void validateCommandLine(String[] args) {
@@ -99,12 +96,14 @@ public static void validateCommandLine(String[] args) {
throw new UnsupportedOperationException("must have at least 2 command-line arguments");
}
if (!args[0].equals("-classpath")) {
- throw new UnsupportedOperationException("invalid command-line, args[0] should be -classpath, but is " + args[0]);
+ throw new UnsupportedOperationException(
+ "invalid command-line, args[0] should be -classpath, but is " + args[0]);
}
}
-
+
/**
- * Return a view of an {@link IClassHierarchy} as a {@link Graph}, with edges from classes to immediate subtypes
+ * Return a view of an {@link IClassHierarchy} as a {@link Graph}, with edges from classes to
+ * immediate subtypes
*/
public static Graph typeHierarchy2Graph(IClassHierarchy cha) throws WalaException {
Graph result = SlowSparseNumberedGraph.make();
@@ -122,5 +121,5 @@ public static Graph typeHierarchy2Graph(IClassHierarchy cha) throws Wala
}
}
return result;
- }
+ }
}
diff --git a/src/main/java/com/ibm/wala/examples/drivers/PrintTypeHierarchy.java b/src/main/java/com/ibm/wala/examples/drivers/PrintTypeHierarchy.java
index aa321094..ef3d1097 100644
--- a/src/main/java/com/ibm/wala/examples/drivers/PrintTypeHierarchy.java
+++ b/src/main/java/com/ibm/wala/examples/drivers/PrintTypeHierarchy.java
@@ -15,12 +15,9 @@
import com.ibm.wala.ipa.cha.ClassHierarchy;
import com.ibm.wala.ipa.cha.ClassHierarchyException;
import com.ibm.wala.ipa.cha.ClassHierarchyFactory;
-
import java.io.IOException;
-/**
- * Simple WALA driver to build and print out a {@link ClassHierarchy}.
- */
+/** Simple WALA driver to build and print out a {@link ClassHierarchy}. */
public class PrintTypeHierarchy {
public static void main(String[] args) throws IOException, ClassHierarchyException {
diff --git a/src/main/java/com/ibm/wala/examples/drivers/ScopeFileCallGraph.java b/src/main/java/com/ibm/wala/examples/drivers/ScopeFileCallGraph.java
index 998b2705..2ed17dbe 100644
--- a/src/main/java/com/ibm/wala/examples/drivers/ScopeFileCallGraph.java
+++ b/src/main/java/com/ibm/wala/examples/drivers/ScopeFileCallGraph.java
@@ -24,7 +24,6 @@
import com.ibm.wala.ipa.callgraph.CallGraphBuilder;
import com.ibm.wala.ipa.callgraph.CallGraphStats;
import com.ibm.wala.ipa.callgraph.Entrypoint;
-import com.ibm.wala.ipa.callgraph.cha.CHACallGraph;
import com.ibm.wala.ipa.callgraph.impl.DefaultEntrypoint;
import com.ibm.wala.ipa.callgraph.impl.Util;
import com.ibm.wala.ipa.callgraph.propagation.InstanceKey;
@@ -35,32 +34,30 @@
import com.ibm.wala.types.TypeReference;
import com.ibm.wala.util.CancelException;
import com.ibm.wala.util.io.CommandLine;
-
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Properties;
/**
- * Driver that constructs a call graph for an application specified via a scope file.
- * Useful for getting some code to copy-paste.
+ * Driver that constructs a call graph for an application specified via a scope file. Useful for
+ * getting some code to copy-paste.
*/
public class ScopeFileCallGraph {
/**
- * Usage: ScopeFileCallGraph -scopeFile file_path [-entryClass class_name |
- * -mainClass class_name]
- *
- * If given -mainClass, uses main() method of class_name as entrypoint. If
- * given -entryClass, uses all public methods of class_name.
- *
+ * Usage: ScopeFileCallGraph -scopeFile file_path [-entryClass class_name | -mainClass class_name]
+ *
+ * If given -mainClass, uses main() method of class_name as entrypoint. If given -entryClass,
+ * uses all public methods of class_name.
+ *
* @throws IOException
* @throws ClassHierarchyException
* @throws CancelException
* @throws IllegalArgumentException
*/
- public static void main(String[] args) throws IOException, ClassHierarchyException, IllegalArgumentException,
- CancelException {
+ public static void main(String[] args)
+ throws IOException, ClassHierarchyException, IllegalArgumentException, CancelException {
long start = System.currentTimeMillis();
Properties p = CommandLine.parse(args);
String scopeFile = p.getProperty("scopeFile");
@@ -69,7 +66,9 @@ public static void main(String[] args) throws IOException, ClassHierarchyExcepti
if (mainClass != null && entryClass != null) {
throw new IllegalArgumentException("only specify one of mainClass or entryClass");
}
- AnalysisScope scope = AnalysisScopeReader.instance.readJavaScope(scopeFile, null, ScopeFileCallGraph.class.getClassLoader());
+ AnalysisScope scope =
+ AnalysisScopeReader.instance.readJavaScope(
+ scopeFile, null, ScopeFileCallGraph.class.getClassLoader());
// set exclusions. we use these exclusions as standard for handling JDK 8
ExampleUtil.addDefaultExclusions(scope);
IClassHierarchy cha = ClassHierarchyFactory.make(scope);
@@ -77,34 +76,43 @@ public static void main(String[] args) throws IOException, ClassHierarchyExcepti
System.out.println(Warnings.asString());
Warnings.clear();
AnalysisOptions options = new AnalysisOptions();
- Iterable entrypoints = entryClass != null ? makePublicEntrypoints(cha, entryClass) : Util.makeMainEntrypoints(cha, mainClass);
+ Iterable entrypoints =
+ entryClass != null
+ ? makePublicEntrypoints(cha, entryClass)
+ : Util.makeMainEntrypoints(cha, mainClass);
options.setEntrypoints(entrypoints);
// For a CHA call graph
-// CHACallGraph CG = new CHACallGraph(cha);
-// CG.init(entrypoints);
+ // CHACallGraph CG = new CHACallGraph(cha);
+ // CG.init(entrypoints);
// For other call graphs
// you can dial down reflection handling if you like
-// options.setReflectionOptions(ReflectionOptions.NONE);
+ // options.setReflectionOptions(ReflectionOptions.NONE);
AnalysisCache cache = new AnalysisCacheImpl();
// other builders can be constructed with different Util methods
- CallGraphBuilder builder = Util.makeZeroOneContainerCFABuilder(options, cache, cha);
-// CallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options, cache, cha);
-// CallGraphBuilder builder = Util.makeNCFABuilder(2, options, cache, cha, scope);
-// CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
-// CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
+ CallGraphBuilder builder =
+ Util.makeZeroOneContainerCFABuilder(options, cache, cha);
+ // CallGraphBuilder builder = Util.makeZeroCFABuilder(Language.JAVA, options,
+ // cache, cha);
+ // CallGraphBuilder builder = Util.makeNCFABuilder(2, options, cache, cha, scope);
+ // CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
+ // CallGraphBuilder builder = Util.makeVanillaNCFABuilder(2, options, cache, cha, scope);
System.out.println("building call graph...");
CallGraph cg = builder.makeCallGraph(options, null);
long end = System.currentTimeMillis();
System.out.println("done");
- System.out.println("took " + (end-start) + "ms");
+ System.out.println("took " + (end - start) + "ms");
System.out.println(CallGraphStats.getStats(cg));
}
- private static Iterable makePublicEntrypoints(IClassHierarchy cha, String entryClass) {
+ private static Iterable makePublicEntrypoints(
+ IClassHierarchy cha, String entryClass) {
Collection result = new ArrayList<>();
- IClass klass = cha.lookupClass(TypeReference.findOrCreate(ClassLoaderReference.Application,
- StringStuff.deployment2CanonicalTypeString(entryClass)));
+ IClass klass =
+ cha.lookupClass(
+ TypeReference.findOrCreate(
+ ClassLoaderReference.Application,
+ StringStuff.deployment2CanonicalTypeString(entryClass)));
for (IMethod m : klass.getDeclaredMethods()) {
if (m.isPublic()) {
result.add(new DefaultEntrypoint(m, cha));
diff --git a/src/main/java/com/ibm/wala/examples/drivers/SourceDirCallGraph.java b/src/main/java/com/ibm/wala/examples/drivers/SourceDirCallGraph.java
index 7aaf4f42..7dd7855e 100644
--- a/src/main/java/com/ibm/wala/examples/drivers/SourceDirCallGraph.java
+++ b/src/main/java/com/ibm/wala/examples/drivers/SourceDirCallGraph.java
@@ -26,7 +26,6 @@
import com.ibm.wala.ssa.SymbolTable;
import com.ibm.wala.types.ClassLoaderReference;
import com.ibm.wala.util.io.CommandLine;
-
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
@@ -53,7 +52,9 @@ public interface Processor {
* Example args: -sourceDir /tmp/srcTest -mainClass LFoo
*/
public static void main(String[] args)
- throws ClassHierarchyException, IllegalArgumentException, CallGraphBuilderCancelException,
+ throws ClassHierarchyException,
+ IllegalArgumentException,
+ CallGraphBuilderCancelException,
IOException {
System.out.println(Arrays.toString(args));
new SourceDirCallGraph()
@@ -71,7 +72,9 @@ protected ClassLoaderFactory getLoaderFactory(AnalysisScope scope) {
}
public void doit(String[] args, Processor processor)
- throws ClassHierarchyException, IllegalArgumentException, CallGraphBuilderCancelException,
+ throws ClassHierarchyException,
+ IllegalArgumentException,
+ CallGraphBuilderCancelException,
IOException {
long start = System.currentTimeMillis();
Properties p = CommandLine.parse(args);
diff --git a/src/main/java/com/ibm/wala/examples/util/ExampleUtil.java b/src/main/java/com/ibm/wala/examples/util/ExampleUtil.java
index ca4c9d4d..5ac891e0 100644
--- a/src/main/java/com/ibm/wala/examples/util/ExampleUtil.java
+++ b/src/main/java/com/ibm/wala/examples/util/ExampleUtil.java
@@ -1,32 +1,33 @@
package com.ibm.wala.examples.util;
+import com.ibm.wala.ipa.callgraph.AnalysisScope;
+import com.ibm.wala.util.config.FileOfClasses;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
-import com.ibm.wala.ipa.callgraph.AnalysisScope;
-import com.ibm.wala.util.config.FileOfClasses;
-
public class ExampleUtil {
- // more aggressive exclusions to avoid library blowup
- // in interprocedural tests
- private static final String EXCLUSIONS = "java\\/awt\\/.*\n" +
- "javax\\/swing\\/.*\n" +
- "sun\\/awt\\/.*\n" +
- "sun\\/swing\\/.*\n" +
- "com\\/sun\\/.*\n" +
- "sun\\/.*\n" +
- "org\\/netbeans\\/.*\n" +
- "org\\/openide\\/.*\n" +
- "com\\/ibm\\/crypto\\/.*\n" +
- "com\\/ibm\\/security\\/.*\n" +
- "org\\/apache\\/xerces\\/.*\n" +
- "java\\/security\\/.*\n" +
- "";
+ // more aggressive exclusions to avoid library blowup
+ // in interprocedural tests
+ private static final String EXCLUSIONS =
+ "java\\/awt\\/.*\n"
+ + "javax\\/swing\\/.*\n"
+ + "sun\\/awt\\/.*\n"
+ + "sun\\/swing\\/.*\n"
+ + "com\\/sun\\/.*\n"
+ + "sun\\/.*\n"
+ + "org\\/netbeans\\/.*\n"
+ + "org\\/openide\\/.*\n"
+ + "com\\/ibm\\/crypto\\/.*\n"
+ + "com\\/ibm\\/security\\/.*\n"
+ + "org\\/apache\\/xerces\\/.*\n"
+ + "java\\/security\\/.*\n"
+ + "";
- public static void addDefaultExclusions(AnalysisScope scope) throws UnsupportedEncodingException, IOException {
- scope.setExclusions(new FileOfClasses(new ByteArrayInputStream(ExampleUtil.EXCLUSIONS.getBytes("UTF-8"))));
+ public static void addDefaultExclusions(AnalysisScope scope)
+ throws UnsupportedEncodingException, IOException {
+ scope.setExclusions(
+ new FileOfClasses(new ByteArrayInputStream(ExampleUtil.EXCLUSIONS.getBytes("UTF-8"))));
}
-
}