com.ibm.dtfj.analyzer.helpers.objectwrapper
Class ClassFinder

java.lang.Object
  extended by TranslatableAnalyzer
      extended by com.ibm.dtfj.analyzer.base.SimpleAnalyzerBean
          extended by com.ibm.dtfj.analyzer.helpers.objectwrapper.ClassFinder
All Implemented Interfaces:
IAnalyzerBase, IReport, IWrapper

public class ClassFinder
extends SimpleAnalyzerBean

Find all the java.lang.Class objects associated with a particular class in the Java runtime
Print and count all the classes within the Java runtime
Given an instance of java.lang.Class, determine which class it defines.

Note that this analyzer is based on scanning through all the classloaders. In various JVM implementations, there may be some classes, in particular array classes, that are not normally found on the list of classloaders. These classes cannot be found by this analyzer.


Constructor Summary
ClassFinder()
          Null constructor for use as JavaBean
 
Method Summary
 java.util.Set findAllSubClasses(java.lang.String clsname)
          Find all the subclasses (direct and indirect, i.e. subclasses of subclasses) of the given class, or all the sub-interfaces and implementations of the given interface.
 java.util.Set findAllSubClassesByObjectID(com.ibm.dtfj.image.ImagePointer id)
          Find all the subclasses (direct and indirect, i.e. subclasses of subclasses) of the given class, or all the sub-interfaces and implementations of the given interface.
 com.ibm.dtfj.java.JavaClass findClassByClassID(com.ibm.dtfj.image.ImagePointer clsid)
          Given the class ID (address) of a JavaClass, find the corresponding JavaClass
 com.ibm.dtfj.java.JavaClass findClassByObjectID(com.ibm.dtfj.image.ImagePointer id)
          Given the object ID (address) of a JavaObject that happens to be an instance of java.lang.Class, find the corresponding class (JavaClass) that this object represents.
 java.util.Set findClasses(java.lang.String clsname)
          Find all the class objects for a given class or interface name
 java.util.Set findDirectSubClasses(java.lang.String clsname)
          Find all the direct subclasses of the given class, or all the sub-interfaces and implementations of the given interface.
 java.util.Set findDirectSubClassesByObjectID(com.ibm.dtfj.image.ImagePointer id)
          Find all the direct subclasses of the given class, or all the sub-interfaces and implementations of the given interface.
 int getCachingPriority()
          Force caching of this analyzer
 int getCountClasses()
           
static ClassFinder getInstance(IAnalyzerContext context, com.ibm.dtfj.java.JavaRuntime parent)
          Find the ClassFinder bean instance associated with a given parent JavaRuntime (create it if necessary)
 java.lang.String getShortDescription()
          Return a short description of the analyser purpose.
 java.lang.String getVersion()
          Get version information for this analyser.
 boolean isPrimaryAnalyzer()
          Some Analyzers are designed to perform analysis tasks and others are designed to perform supporting tasks such as wrapping a DTFJ object and providing extra information.
 void printOneClass(IAnalysisReport out, java.lang.String clsname)
          Print all the class objects for a given class name, as a segment of a report
 IAnalysisReport produceReport()
          Generate a report which will be encapsulated in the IAnalysisReport object for later use by some formatter.
 void setParent(java.lang.Object parent)
          Set the parent JavaRuntime underlying this analyzer bean.
 
Methods inherited from class com.ibm.dtfj.analyzer.base.SimpleAnalyzerBean
allocateReport, allocateReportOptions, allocateSecondaryReport, getCategories, getContext, getIdentityString, getInstance, getLogger, getLongDescription, getName, getNextValidObject, getParent, getReportExtensionHelper, getResourceBundleName, printEmbeddedReport, printEmbeddedReport, printEmbeddedReportWithOptions, printEmbeddedReportWithOptions, printReportInfoHeader, recordInternalExceptionStatic, setContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ClassFinder

public ClassFinder()
Null constructor for use as JavaBean

Method Detail

getVersion

public java.lang.String getVersion()
Description copied from interface: IAnalyzerBase
Get version information for this analyser.

Specified by:
getVersion in interface IAnalyzerBase
Overrides:
getVersion in class SimpleAnalyzerBean
Returns:
- a String containing the version information
See Also:
IAnalyzerBase.getVersion()

getShortDescription

public java.lang.String getShortDescription()
Description copied from interface: IAnalyzerBase
Return a short description of the analyser purpose. This will be printed prior to running the analyser.

Specified by:
getShortDescription in interface IAnalyzerBase
Overrides:
getShortDescription in class SimpleAnalyzerBean
Returns:
- the short description
See Also:
IAnalyzerBase.getShortDescription()

isPrimaryAnalyzer

public boolean isPrimaryAnalyzer()
Description copied from interface: IAnalyzerBase
Some Analyzers are designed to perform analysis tasks and others are designed to perform supporting tasks such as wrapping a DTFJ object and providing extra information. At the end of an analysis run we would like to summarise the analyzers which have been run but we also want to avoid having a huge list. Hence we only choose to list analyzers which are designated 'primary' and typically are doing some specific analysis rather that providing a service to other analyzers.

Specified by:
isPrimaryAnalyzer in interface IAnalyzerBase
Overrides:
isPrimaryAnalyzer in class SimpleAnalyzerBean
Returns:
true if this is a primary analyzer, false otherwise
See Also:
IAnalyzerBase.isPrimaryAnalyzer()

getInstance

public static ClassFinder getInstance(IAnalyzerContext context,
                                      com.ibm.dtfj.java.JavaRuntime parent)
Find the ClassFinder bean instance associated with a given parent JavaRuntime (create it if necessary)

Parameters:
context - the AnalyzerContext in which to locate this bean instance
parent - the parent JavaRuntime underlying this analyzer bean
Returns:
the desired ClassFinder analyzer bean

setParent

public void setParent(java.lang.Object parent)
Set the parent JavaRuntime underlying this analyzer bean.

Specified by:
setParent in interface IWrapper
Overrides:
setParent in class SimpleAnalyzerBean
Parameters:
parent - The parent object to set. Must be of type JavaRuntime. compatible with the type of analyzer bean that receives it
See Also:
IWrapper.setParent(java.lang.Object)

getCachingPriority

public int getCachingPriority()
Force caching of this analyzer

Specified by:
getCachingPriority in interface IAnalyzerBase
Overrides:
getCachingPriority in class SimpleAnalyzerBean
Returns:
the caching priority, as a number between 0 and 10
See Also:
SimpleAnalyzerBean.getCachingPriority()

findClasses

public java.util.Set findClasses(java.lang.String clsname)
                          throws com.ibm.dtfj.image.DTFJException
Find all the class objects for a given class or interface name

Parameters:
clsname - the class or interface name for which we want to find class objects
Returns:
a Set containing all the JavaClass objects found
Throws:
com.ibm.dtfj.image.DTFJException

findDirectSubClasses

public java.util.Set findDirectSubClasses(java.lang.String clsname)
                                   throws com.ibm.dtfj.image.DTFJException
Find all the direct subclasses of the given class, or all the sub-interfaces and implementations of the given interface.

Parameters:
clsname - the name of the class for which we want to find subclasses
Returns:
a Set containing JavaClass objects for every direct subclass of the given class
Throws:
com.ibm.dtfj.image.DTFJException

findAllSubClasses

public java.util.Set findAllSubClasses(java.lang.String clsname)
                                throws com.ibm.dtfj.image.DTFJException
Find all the subclasses (direct and indirect, i.e. subclasses of subclasses) of the given class, or all the sub-interfaces and implementations of the given interface.

Parameters:
clsname - the name of the class or interface for which we want to find subclasses
Returns:
a Set containing JavaClass objects for every subclass of the given class
Throws:
com.ibm.dtfj.image.DTFJException

printOneClass

public void printOneClass(IAnalysisReport out,
                          java.lang.String clsname)
Print all the class objects for a given class name, as a segment of a report

Parameters:
out - a AnalysisReport object to which to write the output
clsname - the class name for which we want to find class objects

findClassByObjectID

public com.ibm.dtfj.java.JavaClass findClassByObjectID(com.ibm.dtfj.image.ImagePointer id)
                                                throws com.ibm.dtfj.image.DTFJException
Given the object ID (address) of a JavaObject that happens to be an instance of java.lang.Class, find the corresponding class (JavaClass) that this object represents.

Parameters:
id - object ID of a JavaObject that is an instance of java.lang.Class
Returns:
the corresponding JavaClass, or null if not found
Throws:
com.ibm.dtfj.image.DTFJException

findClassByClassID

public com.ibm.dtfj.java.JavaClass findClassByClassID(com.ibm.dtfj.image.ImagePointer clsid)
                                               throws com.ibm.dtfj.image.DTFJException
Given the class ID (address) of a JavaClass, find the corresponding JavaClass

Parameters:
clsid - class ID of a JavaClass
Returns:
the corresponding JavaClass, or null if not found
Throws:
com.ibm.dtfj.image.DTFJException

findDirectSubClassesByObjectID

public java.util.Set findDirectSubClassesByObjectID(com.ibm.dtfj.image.ImagePointer id)
                                             throws com.ibm.dtfj.image.DTFJException
Find all the direct subclasses of the given class, or all the sub-interfaces and implementations of the given interface.

Parameters:
id - ID of a JavaObject that is an instance of java.lang.Class from which we want the subclasses
Returns:
a Set containing JavaClass objects for every direct subclass of the given class
Throws:
com.ibm.dtfj.image.DTFJException

findAllSubClassesByObjectID

public java.util.Set findAllSubClassesByObjectID(com.ibm.dtfj.image.ImagePointer id)
                                          throws com.ibm.dtfj.image.DTFJException
Find all the subclasses (direct and indirect, i.e. subclasses of subclasses) of the given class, or all the sub-interfaces and implementations of the given interface.

Parameters:
id - ID of a JavaObject that is an instance of java.lang.Class from which we want the subclasses
Returns:
a Set containing JavaClass objects for every subclass of the given class
Throws:
com.ibm.dtfj.image.DTFJException

getCountClasses

public int getCountClasses()
                    throws com.ibm.dtfj.image.DTFJException
Returns:
Returns the total number of classes known in this runtime.
Throws:
com.ibm.dtfj.image.DTFJException

produceReport

public IAnalysisReport produceReport()
Description copied from interface: IReport
Generate a report which will be encapsulated in the IAnalysisReport object for later use by some formatter.

Specified by:
produceReport in interface IReport
Overrides:
produceReport in class SimpleAnalyzerBean
Returns:
- the generic report object which will be given to some formatter
See Also:
IReport.produceReport()


© Copyright IBM Corp. 2007, 2008 All Rights Reserved. US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.