javax.tools.diagnostics.runtime.java
Interface JavaClassLoader


public interface JavaClassLoader

Represents an internal ClassLoader structure within a Java Virtual Machine instance. For most ClassLoaders there is a corresponding ClassLoader instance within with JavaRuntime. For primordial class loaders such as the bootstrap class loader, there may or may not be a corresponding ClassLoader instance.

Since Java does not define any strict inheritance structure between class loaders, there are no APIs for inspecting 'child' or 'parent' class loaders. This information may be inferred by inspecting the corresponding ClassLoader instance:

pseudo javacode example

                JavaClassLoader  loader;
                JavaObject instance=loader.getObject();
                String classLoaderName=instance.getJavaClass().getName();
 
 

See Also:
ClassLoader

Method Summary
 boolean equals(java.lang.Object obj)
           
 JavaClass findClass(java.lang.String name)
           Find a class by name within this class loader.
 java.util.List<JavaClass> getCachedClasses()
           When a ClassLoader successfully delegates a findClass() request to another ClassLoader, the result of the delegation must be cached within the internal structure so that the Java Virtual Machine does not make repeated requests for the same class.
 java.util.List<JavaClass> getDefinedClasses()
           Get the set of classes which are defined in this JavaClassLoader.
 JavaObject getObject()
          Get the ClassLoader instance (represented by a JavaObject associated with this class loader.
 int hashCode()
           
 

Method Detail

getDefinedClasses

java.util.List<JavaClass> getDefinedClasses()

Get the set of classes which are defined in this JavaClassLoader. Calling the JavaClass.getClassLoader() method on objects returned in this list will return this JavaClassLoader

The returned list follows the standard semantics for javax.tools.diagnostics collections.

The returned value is never null but can be an empty list.

Returns:
an list of classes which are defined in this JavaClassLoader
See Also:
JavaClass

getCachedClasses

java.util.List<JavaClass> getCachedClasses()

When a ClassLoader successfully delegates a findClass() request to another ClassLoader, the result of the delegation must be cached within the internal structure so that the Java Virtual Machine does not make repeated requests for the same class.

The contents of the returned list is a superset of that returned by getDefinedClasses()

The returned list follows the standard semantics for javax.tools.diagnostics collections.

The returned value is never null but can be an empty list.

Returns:
a list of classes which are defined in this JavaClassLoader or which were found by delegation to other JavaClassLoaders
See Also:
JavaClass

findClass

JavaClass findClass(java.lang.String name)
                    throws CorruptDataException

Find a class by name within this class loader. The class may have been defined in this class loader, or this class loader may have delegated the load to another class loader and cached the result.

The form of the name presented to this method should be as follows

 [ packagenamepart / ... ] (classname ) [ $innerclassname ...]
 

Examples

Parameters:
name - of the class to find. Packages should be separated by '/' instead of '.'
Returns:
the JavaClass instance, or null if it is not found
Throws:
CorruptDataException - if the underlying data is in an unexpected state

getObject

JavaObject getObject()
                     throws CorruptDataException
Get the ClassLoader instance (represented by a JavaObject associated with this class loader. If there is no associated class loader, for example the system class loader , then null will be returned. Further examination of the returned object is implementation specific.

Returns:
a JavaObject representing the ClassLoader instance
Throws:
CorruptDataException - if the underlying data is in an unexpected state
See Also:
JavaObject, ClassLoader

equals

boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object
Parameters:
obj -
Returns:
True if the given object refers to the same Java Class Loader in the image

hashCode

int hashCode()
Overrides:
hashCode in class java.lang.Object


Copyright © 2010. All Rights Reserved.