classpathhelper
Class ClassDetail

java.lang.Object
  extended byclasspathhelper.ContentDetail
      extended byclasspathhelper.ClassDetail

public class ClassDetail
extends ContentDetail

Class that extends on the idea of a meta class such as Class. This meta class ads additional information such as dependent classes, blocked or obscurring classes, as well as unavailable classes that are required but not visible on the classpath.

Usage

ClassDetail objects are created by CGClassLoader and can be obtained via CGClassLoader.getClassDetail(String).

A given instance of a detail object can be used to obtain static information about the class, without needing to load the java.lang.Class object.

Implementation Notes

This class internally synchronizes using the class loader's mutex object.

Since:
1.0
Author:
bharris

Field Summary
 
Fields inherited from class classpathhelper.ContentDetail
description
 
Constructor Summary
ClassDetail(CGClassLoader theClassLoader, ClassDescription theDescription)
          Creates a ClassDetail, typically called by CGClassLoader.
 
Method Summary
 void addDependency(ClassDescription theClassname)
          Used during construction to build up the dependencies of this detail object.
 void clearCache()
          Method that clears any cached values within this object.
 void dump()
          Dumps a description of this object to standard out.
 java.lang.Class getClassObject()
          Method that gets the associated class object.
 ClassDescription[] getDependentsThatWontLoad()
          This method builds off the concept of getNotFoundDependentClasses() however this method also recursively searches all dependents looking for unresolved references.
 ClassDescription[] getDependsOnByLocation(java.lang.String location)
          Gets the class names that the associated class depends on given the specified location.
 ClassDescription[] getDependsOnClasses()
           
 java.lang.String[] getDependsOnLocations()
          Returns the list of locations (such as jar files or directories) that this class requires.
 ContentDescription getDescription()
          The description of this content.
 java.lang.String getName()
           
 ClassDescription[] getNotFoundDependentClasses()
          Method that finds the classes this class depends on that cannot be resolved on the current classpath.
 ContentDescription[] getReferredToBy(CGClassLoader startingClassLoader)
          Method for retrieving the classes that refer to this class.
protected  java.util.Set getReferredToByCache()
          Retrieves the cache that stores class names of the classes that refer to this class.
 ContentDescription[] getReferredToByLocation(CGClassLoader startingClassLoader, java.lang.String locationDescription)
          Method for retrieving the classes that refer to this class from the supplied location.
 java.lang.String[] getReferredToByLocations(CGClassLoader startingClassLoader)
          Method that retrieves the locations that have classes that refer to this class.
protected  ClassDescription[] innerDependentsThatWontLoad(java.util.Set endRecursion)
          Internal method used by getDependentsThatWontLoad() to search children for unresolved references.
 boolean isInterface()
          Flag indicating whether or not the Class associated with this detail object is an interface.
protected  void setIsInterface(boolean isit)
          Method used by CGClassLoader to indicate whether or not this class is an interface.
protected  void setReferredToByCache(java.util.Set cache)
          Sets the cache that will store the class names of classes that refer to this class.
 java.lang.String toString()
           
 
Methods inherited from class classpathhelper.ContentDetail
addBlockedLocation, getAllLocations, getBlockedLocations, getBlockedLocationsWithDifferentByteCode, getChecksum, getClassLoader, getLocation, getPath, setChecksum, setLocation, setPath
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassDetail

public ClassDetail(CGClassLoader theClassLoader,
                   ClassDescription theDescription)
Creates a ClassDetail, typically called by CGClassLoader.

Parameters:
theClassLoader - The classloader that this class was loaded by.
theDescription - The corresponding description
Since:
1.1
Method Detail

clearCache

public void clearCache()
Method that clears any cached values within this object.

Since:
1.0

getName

public java.lang.String getName()
Returns:
The class name of the class this detail object represents.
Since:
1.0

isInterface

public boolean isInterface()
Flag indicating whether or not the Class associated with this detail object is an interface.

Returns:
true if the associated class is an interface otherwise false.
Since:
1.0

addDependency

public void addDependency(ClassDescription theClassname)
Used during construction to build up the dependencies of this detail object.

Parameters:
theClassname - The description of the dependent class.
Since:
1.0

getClassObject

public java.lang.Class getClassObject()
                               throws java.lang.ClassNotFoundException
Method that gets the associated class object.

Returns:
A class object that corresponds to the Class that this detail object is associated with.
Throws:
java.lang.ClassNotFoundException - If the class cannot be found or cannot be loaded.
Since:
1.0

getDependsOnClasses

public ClassDescription[] getDependsOnClasses()
Returns:
The classes this class depends on.
Since:
An array of ClassDescription objects corresponding to the classes this class depends on., 1.1

getDependsOnLocations

public java.lang.String[] getDependsOnLocations()
Returns the list of locations (such as jar files or directories) that this class requires. This is similar to getDependsOnClasses() except that its reporting the locations of those classes (as opposed to the actual class names).

Returns:
A String array of location description that contain classes that this class depends on.
Since:
1.0

getDependsOnByLocation

public ClassDescription[] getDependsOnByLocation(java.lang.String location)

Gets the class names that the associated class depends on given the specified location.

As an example this might be all the classes the associated class depends on within a certain jar

.

This method will not include blocked classes.

Parameters:
location - The classpath location, to look for dependent classes on.
Returns:
An array of class descriptions, that reside in the jar.
Since:
1.1

getNotFoundDependentClasses

public ClassDescription[] getNotFoundDependentClasses()
Method that finds the classes this class depends on that cannot be resolved on the current classpath.

Returns:
An array of class descriptions corresponding to classes that are not available on the classpath.
Since:
1.1

getDependentsThatWontLoad

public ClassDescription[] getDependentsThatWontLoad()
This method builds off the concept of getNotFoundDependentClasses() however this method also recursively searches all dependents looking for unresolved references. The returned array is the direct dependents that will not load because of an unresolved reference somewhere in their dependency chain.

Returns:
An array of ClassDescription objects that refer to direct dependents that will not load due to unresolved references in the classpath.
Since:
1.1

getReferredToBy

public ContentDescription[] getReferredToBy(CGClassLoader startingClassLoader)
Method for retrieving the classes that refer to this class. This method is expensive because it requires that all classes on the classpath get loaded to determine which classes reference which. Also, because parent class loaders are unaware of how many descendent classloaders they have, this method requires that a root class loader get passed in which is the (potentially descendent) class loader that will be the starting point for determine where to start loading all classes.

Parameters:
startingClassLoader - The root class loader or the descedent most classloader ot calculate references from.
Returns:
An array of content descriptions corresponding to objects that refer to this class.
Since:
1.0

getReferredToByLocations

public java.lang.String[] getReferredToByLocations(CGClassLoader startingClassLoader)
Method that retrieves the locations that have classes that refer to this class. This method is expensive because it requires that all classes on the classpath get loaded to determine which classes reference which. Also, because parent class loaders are unaware of how many descendent classloaders they have, this method requires that a root class loader get passed in which is the (potentially descendent) class loader that will be the starting point for determine where to start loading all classes.

Parameters:
startingClassLoader - The root class loader or the descedent most classloader ot calculate references from.
Returns:
An array of locations containing classes that refer to this class.
Since:
1.0

getReferredToByLocation

public ContentDescription[] getReferredToByLocation(CGClassLoader startingClassLoader,
                                                    java.lang.String locationDescription)

Method for retrieving the classes that refer to this class from the supplied location.

This method is expensive because it requires that all classes on the classpath get loaded to determine which classes reference which. Also, because parent class loaders are unaware of how many descendent classloaders they have, this method requires that a root class loader get passed in which is the (potentially descendent) class loader that will be the starting point for determine where to start loading all classes.

Parameters:
startingClassLoader - The root class loader or the descedent most classloader ot calculate references from.
locationDescription - The location to return classes from.
Returns:
An array of content descriptions corresponding to entities that refer to this class from the specified location.
Since:
1.0

dump

public void dump()
Dumps a description of this object to standard out.

Since:
1.0

getReferredToByCache

protected java.util.Set getReferredToByCache()
Retrieves the cache that stores class names of the classes that refer to this class.

Returns:
A set of class names (strings).
Since:
1.0

setReferredToByCache

protected void setReferredToByCache(java.util.Set cache)
Sets the cache that will store the class names of classes that refer to this class. This method is typically called by CGClassLoader because CGClassLoader actually initiates this cache prior to the detail object getting created. This means the the cache passed into this method is often already populated with some values.

Parameters:
cache - A set of class names.
Since:
1.0

setIsInterface

protected void setIsInterface(boolean isit)
Method used by CGClassLoader to indicate whether or not this class is an interface.

Parameters:
isit - true if the associated class is an interface, otherwise false.
Since:
1.0

innerDependentsThatWontLoad

protected ClassDescription[] innerDependentsThatWontLoad(java.util.Set endRecursion)
Internal method used by getDependentsThatWontLoad() to search children for unresolved references.

Parameters:
endRecursion - The set of classes already searched, this set is used to prevent circular dependencies.
Returns:
A list of the classes that won't load, minus any classes listed in endRecursion.
Since:
1.1

getDescription

public ContentDescription getDescription()
Description copied from class: ContentDetail
The description of this content.

Overrides:
getDescription in class ContentDetail
Returns:
The description associated with this detail.

toString

public java.lang.String toString()