Top Description Fields Constructors Methods
com.sun.jmx.mbeanserver

pack-priv final Class SecureClassLoaderRepository

extends Object
implements ClassLoaderRepository
Class Inheritance
All Implemented Interfaces
javax.management.loading.ClassLoaderRepository
Imports
javax.management.loading.ClassLoaderRepository

Fix security hole in ClassLoaderRepository. This class wraps the actual ClassLoaderRepository implementation so that only the methods from javax.management.loading.ClassLoaderRepository can be accessed (read-only).
Since
1.5

Field Summary

Modifier and TypeField and Description
private final ClassLoaderRepository

Constructor Summary

AccessConstructor and Description
public
SecureClassLoaderRepository(ClassLoaderRepository
Unsecure ClassLoaderRepository implementation to wrap.
clr
)

Creates a new secure ClassLoaderRepository wrapping an unsecure implementation.

Method Summary

Modifier and TypeMethod and Description
public final Class<?>
loadClass(String
The name of the class to be loaded.
className
)

Implements javax.management.loading.ClassLoaderRepository.loadClass.

Load the given class name through the list of class loaders.

public final Class<?>
loadClassBefore(ClassLoader
The class loader at which to stop. May be null, in which case this method is equivalent to loadClass(className).
loader
,
String
The name of the class to be loaded.
className
)

Implements javax.management.loading.ClassLoaderRepository.loadClassBefore.

Load the given class name through the list of class loaders, stopping at the given one.

public final Class<?>
loadClassWithout(ClassLoader
The class loader to be excluded. May be null, in which case this method is equivalent to loadClass(className).
loader
,
String
The name of the class to be loaded.
className
)

Implements javax.management.loading.ClassLoaderRepository.loadClassWithout.

Load the given class name through the list of class loaders, excluding the given one.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clrback to summary
private final ClassLoaderRepository clr

Constructor Detail

SecureClassLoaderRepositoryback to summary
public SecureClassLoaderRepository(ClassLoaderRepository clr)

Creates a new secure ClassLoaderRepository wrapping an unsecure implementation.

Parameters
clr:ClassLoaderRepository

Unsecure ClassLoaderRepository implementation to wrap.

Method Detail

loadClassback to summary
public final Class<?> loadClass(String className) throws ClassNotFoundException

Implements javax.management.loading.ClassLoaderRepository.loadClass.

Doc from javax.management.loading.ClassLoaderRepository.loadClass.

Load the given class name through the list of class loaders. Each ClassLoader in turn from the ClassLoaderRepository is asked to load the class via its ClassLoader#loadClass(String) method. If it successfully returns a Class object, that is the result of this method. If it throws a ClassNotFoundException, the search continues with the next ClassLoader. If it throws another exception, the exception is propagated from this method. If the end of the list is reached, a ClassNotFoundException is thrown.

Parameters
className:String

The name of the class to be loaded.

Returns:Class<?>

the loaded class.

Exceptions
ClassNotFoundException:
The specified class could not be found.
loadClassBeforeback to summary
public final Class<?> loadClassBefore(ClassLoader loader, String className) throws ClassNotFoundException

Implements javax.management.loading.ClassLoaderRepository.loadClassBefore.

Doc from javax.management.loading.ClassLoaderRepository.loadClassBefore.

Load the given class name through the list of class loaders, stopping at the given one. Each ClassLoader in turn from the ClassLoaderRepository is asked to load the class via its ClassLoader#loadClass(String) method. If it successfully returns a Class object, that is the result of this method. If it throws a ClassNotFoundException, the search continues with the next ClassLoader. If it throws another exception, the exception is propagated from this method. If the search reaches stop or the end of the list, a ClassNotFoundException is thrown.

Typically this method is called from the loadClass method of stop, to consult loaders that appear before it in the ClassLoaderRepository. By stopping the search as soon as stop is reached, a potential deadlock with concurrent class loading is avoided.

Parameters
loader:ClassLoader

The class loader at which to stop. May be null, in which case this method is equivalent to loadClass(className).

className:String

The name of the class to be loaded.

Returns:Class<?>

the loaded class.

Exceptions
ClassNotFoundException:
The specified class could not be found.
loadClassWithoutback to summary
public final Class<?> loadClassWithout(ClassLoader loader, String className) throws ClassNotFoundException

Implements javax.management.loading.ClassLoaderRepository.loadClassWithout.

Doc from javax.management.loading.ClassLoaderRepository.loadClassWithout.

Load the given class name through the list of class loaders, excluding the given one. Each ClassLoader in turn from the ClassLoaderRepository, except exclude, is asked to load the class via its ClassLoader#loadClass(String) method. If it successfully returns a Class object, that is the result of this method. If it throws a ClassNotFoundException, the search continues with the next ClassLoader. If it throws another exception, the exception is propagated from this method. If the end of the list is reached, a ClassNotFoundException is thrown.

Be aware that if a ClassLoader in the ClassLoaderRepository calls this method from its loadClass method, it exposes itself to a deadlock if another ClassLoader in the ClassLoaderRepository does the same thing at the same time. The loadClassBefore method is recommended to avoid the risk of deadlock.

Parameters
loader:ClassLoader

The class loader to be excluded. May be null, in which case this method is equivalent to loadClass(className).

className:String

The name of the class to be loaded.

Returns:Class<?>

the loaded class.

Exceptions
ClassNotFoundException:
The specified class could not be found.