org.netbeans.insane.scanner
Class ScannerUtils

java.lang.Object
  extended by org.netbeans.insane.scanner.ScannerUtils

public final class ScannerUtils
extends java.lang.Object


Method Summary
static Filter compoundFilter(Filter[] parts)
          Creates a filter that will wrap and delegate to more filters, performing a logical and operation on their results
static Visitor compoundVisitor(Visitor[] parts)
          Creates a visitor that will wrap and delegate to more visitors during one scan
static java.util.Set interestingRoots()
           
static int recursiveSizeOf(java.util.Collection roots, Filter f)
           
static void scan(Filter f, Visitor v, java.util.Collection roots, boolean analyzeStaticData)
          Traverse the graph of objects reachable from roots Collection, notifying the Visitor.
static void scanExclusivelyInAWT(Filter f, Visitor v, java.util.Set roots)
          Traverse the graph of objects reachable from roots Collection, notifying the Visitor.
static int sizeOf(java.lang.Object o)
           
static Filter skipNonStrongReferencesFilter()
          A Filter factory that creates a Filter ignoring weak and soft references.
static Filter skipObjectsFilter(java.util.Collection except, boolean include)
          A Filter factory that creates a Filter ignoring given collection of objects and/or their outgoing references.
static Filter skipReferencesFilter(java.util.Collection except)
          A Filter factory that creates a Filter ignoring given references
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

compoundVisitor

public static Visitor compoundVisitor(Visitor[] parts)
Creates a visitor that will wrap and delegate to more visitors during one scan

Parameters:
parts - aray of Visitors to delegate to.
Returns:
a wrapper Visitor

compoundFilter

public static Filter compoundFilter(Filter[] parts)
Creates a filter that will wrap and delegate to more filters, performing a logical and operation on their results

Parameters:
parts - aray of Filters to delegate to.
Returns:
a wrapper Filter

skipObjectsFilter

public static Filter skipObjectsFilter(java.util.Collection except,
                                       boolean include)
A Filter factory that creates a Filter ignoring given collection of objects and/or their outgoing references.

Parameters:
except - a Collection of objects to be ignored
include - whether ignore the objects themselves (false) or only their outgoing references (true).
Returns:
the Filter implementation

skipReferencesFilter

public static Filter skipReferencesFilter(java.util.Collection except)
A Filter factory that creates a Filter ignoring given references

Parameters:
except - a Collection of Fields to be ignored.
Returns:
the Filter implementation

skipNonStrongReferencesFilter

public static Filter skipNonStrongReferencesFilter()
A Filter factory that creates a Filter ignoring weak and soft references.

Returns:
the Filter implementation

sizeOf

public static int sizeOf(java.lang.Object o)

recursiveSizeOf

public static int recursiveSizeOf(java.util.Collection roots,
                                  Filter f)
                           throws java.lang.Exception
Throws:
java.lang.Exception

scan

public static void scan(Filter f,
                        Visitor v,
                        java.util.Collection roots,
                        boolean analyzeStaticData)
                 throws java.lang.Exception
Traverse the graph of objects reachable from roots Collection, notifying the Visitor.

Parameters:
f - a Filter for excluding objects. null means accept all objects.
v - a Visitor to be notified on all found objects and references.
roots - a Collection of objects to be evaluated.
Throws:
java.lang.Exception

interestingRoots

public static java.util.Set interestingRoots()
Returns:
a set of objects that may be sufficient to transitively reference near all objects on the java heap.

scanExclusivelyInAWT

public static void scanExclusivelyInAWT(Filter f,
                                        Visitor v,
                                        java.util.Set roots)
                                 throws java.lang.Exception
Traverse the graph of objects reachable from roots Collection, notifying the Visitor. It performs the scan from inside AWT queue and tries to suspend other threads during the scan.

Parameters:
f - a Filter for excluding objects. null means accept all objects.
v - a Visitor to be notified on all found objects and references.
roots - a Collection of objects to be evaluated.
Throws:
java.lang.Exception