com.ibm.wala.ipa.callgraph.impl
Class Util

java.lang.Object
  extended by com.ibm.wala.ipa.callgraph.impl.Util

public class Util
extends java.lang.Object


Constructor Summary
Util()
           
 
Method Summary
static void addBypassLogic(AnalysisOptions options, AnalysisScope scope, java.lang.ClassLoader cl, java.lang.String xmlFile, ClassHierarchy cha)
          Modify an options object to include bypass logic as specified by a an XML file.
static void addDefaultBypassLogic(AnalysisOptions options, AnalysisScope scope, java.lang.ClassLoader cl, ClassHierarchy cha)
           
static void addDefaultSelectors(AnalysisOptions options, ClassHierarchy cha, WarningSet warn)
          Set up an AnalysisOptions object with default selectors, corresponding to class hierarchy lookup
static
<T> boolean
areEqual(Graph<T> g1, Graph<T> g2)
          Not terribly efficient
static
<T> void
checkGraphSubset(Graph<T> supG, Graph<T> subG)
           
static java.util.Collection<CGNode> computeDarkEntrypointNodes(CallGraph cg, java.util.Collection<CGNode> entrypoints)
           
static
<T> boolean
isSubset(Graph<T> g1, Graph<T> g2)
          Is g1 a subset of g2? Not terribly efficient
static java.lang.Iterable<Entrypoint> makeMainEntrypoints(AnalysisScope scope, ClassHierarchy cha)
           
static java.lang.Iterable<Entrypoint> makeMainEntrypoints(AnalysisScope scope, ClassHierarchy cha, java.lang.String className)
           
static java.lang.Iterable<Entrypoint> makeMainEntrypoints(AnalysisScope scope, ClassHierarchy cha, java.lang.String[] classNames)
           
static java.lang.Iterable<Entrypoint> makeMainEntrypoints(ClassLoaderReference clr, ClassHierarchy cha)
           
static java.lang.Iterable<Entrypoint> makeMainEntrypoints(ClassLoaderReference loaderRef, ClassHierarchy cha, java.lang.String[] classNames)
           
static CallGraphBuilder makeOneCFABuilder(AnalysisOptions options, ClassHierarchy cha, java.lang.ClassLoader cl, AnalysisScope scope, WarningSet warnings)
           
static CallGraphBuilder makeRTABuilder(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings)
           
static CFABuilder makeVanillaZeroOneCFABuilder(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings)
           
static CFABuilder makeVanillaZeroOneCFABuilder(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings, ContextSelector customSelector, SSAContextInterpreter customInterpreter)
           
static CFABuilder makeVanillaZeroOneContainerCFABuilder(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings)
           
static CFABuilder makeZeroCFABuilder(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings)
           
static CFABuilder makeZeroCFABuilder(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings, ContextSelector customSelector, SSAContextInterpreter customInterpreter)
           
static CFABuilder makeZeroContainerCFABuilder(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings)
           
static CFABuilder makeZeroOneCFABuilder(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings)
           
static CFABuilder makeZeroOneCFABuilder(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings, ContextSelector customSelector, SSAContextInterpreter customInterpreter)
           
static CFABuilder makeZeroOneContainerCFABuilder(AnalysisOptions options, ClassHierarchy cha, AnalysisScope scope, WarningSet warnings)
           
static
<T> java.util.Set<T>
setify(java.util.Iterator<? extends T> x)
           
static Graph<MethodReference> squashCallGraph(java.lang.String name, CallGraph cg)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

addDefaultSelectors

public static void addDefaultSelectors(AnalysisOptions options,
                                       ClassHierarchy cha,
                                       WarningSet warn)
Set up an AnalysisOptions object with default selectors, corresponding to class hierarchy lookup

Parameters:
options -
cha -
warn -
Throws:
java.lang.IllegalArgumentException - if options is null

areEqual

public static <T> boolean areEqual(Graph<T> g1,
                                   Graph<T> g2)
Not terribly efficient

Throws:
java.lang.IllegalArgumentException - if g1 is null
java.lang.IllegalArgumentException - if g2 is null

isSubset

public static <T> boolean isSubset(Graph<T> g1,
                                   Graph<T> g2)
Is g1 a subset of g2? Not terribly efficient

Throws:
java.lang.IllegalArgumentException - if g1 is null
java.lang.IllegalArgumentException - if g2 is null

addBypassLogic

public static void addBypassLogic(AnalysisOptions options,
                                  AnalysisScope scope,
                                  java.lang.ClassLoader cl,
                                  java.lang.String xmlFile,
                                  ClassHierarchy cha)
                           throws java.lang.IllegalArgumentException
Modify an options object to include bypass logic as specified by a an XML file.

Throws:
java.lang.IllegalArgumentException - if scope is null
java.lang.IllegalArgumentException - if cl is null
java.lang.IllegalArgumentException - if options is null
java.lang.IllegalArgumentException - if scope is null

computeDarkEntrypointNodes

public static java.util.Collection<CGNode> computeDarkEntrypointNodes(CallGraph cg,
                                                                      java.util.Collection<CGNode> entrypoints)
Returns:
the Set of CGNodes in the call graph that are reachable without traversing any entrypoint node
Throws:
java.lang.IllegalArgumentException - if cg is null

makeMainEntrypoints

public static java.lang.Iterable<Entrypoint> makeMainEntrypoints(AnalysisScope scope,
                                                                 ClassHierarchy cha)
Parameters:
scope -
cha -
Returns:
set of all eligible Main classes in the class hierarchy
Throws:
java.lang.IllegalArgumentException - if scope is null

makeMainEntrypoints

public static java.lang.Iterable<Entrypoint> makeMainEntrypoints(ClassLoaderReference clr,
                                                                 ClassHierarchy cha)

makeMainEntrypoints

public static java.lang.Iterable<Entrypoint> makeMainEntrypoints(AnalysisScope scope,
                                                                 ClassHierarchy cha,
                                                                 java.lang.String className)
Returns:
Entrypoints object for a Main J2SE class

makeMainEntrypoints

public static java.lang.Iterable<Entrypoint> makeMainEntrypoints(AnalysisScope scope,
                                                                 ClassHierarchy cha,
                                                                 java.lang.String[] classNames)

makeMainEntrypoints

public static java.lang.Iterable<Entrypoint> makeMainEntrypoints(ClassLoaderReference loaderRef,
                                                                 ClassHierarchy cha,
                                                                 java.lang.String[] classNames)
Returns:
Entryponts for a set of J2SE Main classes

squashCallGraph

public static Graph<MethodReference> squashCallGraph(java.lang.String name,
                                                     CallGraph cg)
Parameters:
name -
cg -
Returns:
a graph whose nodes are MethodReferences, and whose edges represent calls between MethodReferences
Throws:
java.lang.IllegalArgumentException - if cg is null

setify

public static <T> java.util.Set<T> setify(java.util.Iterator<? extends T> x)

checkGraphSubset

public static <T> void checkGraphSubset(Graph<T> supG,
                                        Graph<T> subG)
Parameters:
supG -
subG -
Throws:
java.lang.IllegalArgumentException - if subG is null
java.lang.IllegalArgumentException - if supG is null

makeRTABuilder

public static CallGraphBuilder makeRTABuilder(AnalysisOptions options,
                                              ClassHierarchy cha,
                                              AnalysisScope scope,
                                              WarningSet warnings)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
Returns:
an RTA Call Graph builder.

makeZeroCFABuilder

public static CFABuilder makeZeroCFABuilder(AnalysisOptions options,
                                            ClassHierarchy cha,
                                            AnalysisScope scope,
                                            WarningSet warnings)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
Returns:
a 0-CFA Call Graph Builder.

makeZeroCFABuilder

public static CFABuilder makeZeroCFABuilder(AnalysisOptions options,
                                            ClassHierarchy cha,
                                            AnalysisScope scope,
                                            WarningSet warnings,
                                            ContextSelector customSelector,
                                            SSAContextInterpreter customInterpreter)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
customSelector - user-defined context selector, or null if none
customInterpreter - user-defined context interpreter, or null if none
Returns:
a 0-CFA Call Graph Builder.
Throws:
java.lang.IllegalArgumentException - if options is null

makeOneCFABuilder

public static CallGraphBuilder makeOneCFABuilder(AnalysisOptions options,
                                                 ClassHierarchy cha,
                                                 java.lang.ClassLoader cl,
                                                 AnalysisScope scope,
                                                 WarningSet warnings)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
cl - classloader that can find WALA resources
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
Returns:
a 1-CFA Call Graph Builder.
Throws:
java.lang.IllegalArgumentException - if options is null

makeZeroOneCFABuilder

public static CFABuilder makeZeroOneCFABuilder(AnalysisOptions options,
                                               ClassHierarchy cha,
                                               AnalysisScope scope,
                                               WarningSet warnings)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
Returns:
a 0-1-CFA Call Graph Builder. This version uses the DEDUCED_PLUS_STRINGSTUFF policy to avoid disambiguating uninteresting types.

makeVanillaZeroOneCFABuilder

public static CFABuilder makeVanillaZeroOneCFABuilder(AnalysisOptions options,
                                                      ClassHierarchy cha,
                                                      AnalysisScope scope,
                                                      WarningSet warnings,
                                                      ContextSelector customSelector,
                                                      SSAContextInterpreter customInterpreter)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
customSelector - user-defined context selector, or null if none
customInterpreter - user-defined context interpreter, or null if none
Returns:
a 0-1-CFA Call Graph Builder.
Throws:
java.lang.IllegalArgumentException - if options is null

makeVanillaZeroOneCFABuilder

public static CFABuilder makeVanillaZeroOneCFABuilder(AnalysisOptions options,
                                                      ClassHierarchy cha,
                                                      AnalysisScope scope,
                                                      WarningSet warnings)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
Returns:
a 0-1-CFA Call Graph Builder. This version uses the DEDUCED_PLUS_STRINGSTUFF policy to avoid disambiguating uninteresting types.

makeZeroOneCFABuilder

public static CFABuilder makeZeroOneCFABuilder(AnalysisOptions options,
                                               ClassHierarchy cha,
                                               AnalysisScope scope,
                                               WarningSet warnings,
                                               ContextSelector customSelector,
                                               SSAContextInterpreter customInterpreter)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
customSelector - user-defined context selector, or null if none
customInterpreter - user-defined context interpreter, or null if none
Returns:
a 0-1-CFA Call Graph Builder.
Throws:
java.lang.IllegalArgumentException - if options is null

makeZeroContainerCFABuilder

public static CFABuilder makeZeroContainerCFABuilder(AnalysisOptions options,
                                                     ClassHierarchy cha,
                                                     AnalysisScope scope,
                                                     WarningSet warnings)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
cl - classloader that can find WALA resources
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
Returns:
a 0-CFA Call Graph Builder augmented with extra logic for containers
Throws:
java.lang.IllegalArgumentException - if options is null

makeZeroOneContainerCFABuilder

public static CFABuilder makeZeroOneContainerCFABuilder(AnalysisOptions options,
                                                        ClassHierarchy cha,
                                                        AnalysisScope scope,
                                                        WarningSet warnings)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
cl - classloader that can find WALA resources
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
Returns:
a 0-1-CFA Call Graph Builder augmented with extra logic for containers
Throws:
java.lang.IllegalArgumentException - if options is null

makeVanillaZeroOneContainerCFABuilder

public static CFABuilder makeVanillaZeroOneContainerCFABuilder(AnalysisOptions options,
                                                               ClassHierarchy cha,
                                                               AnalysisScope scope,
                                                               WarningSet warnings)
Parameters:
options - options that govern call graph construction
cha - governing class hierarchy
cl - classloader that can find WALA resources
scope - representation of the analysis scope
warnings - an object which tracks analysis warnings
Returns:
a 0-1-CFA Call Graph Builder augmented with extra logic for containers
Throws:
java.lang.IllegalArgumentException - if options is null

addDefaultBypassLogic

public static void addDefaultBypassLogic(AnalysisOptions options,
                                         AnalysisScope scope,
                                         java.lang.ClassLoader cl,
                                         ClassHierarchy cha)