saker.build Documentation TaskDoc JavaDoc Packages
public class FilteringClassLoader extends ClassLoader
ClassLoader implementation that only provides access for a given set of class names from its parent.

An instance of this classloader is constructed with a parent delegate and a set of allowed class names. When a class finding request is made, it is checked that the allowed class names contain the requested class name. If so, the parent classloader will be asked to load the class with the specific name. If not, a ClassNotFoundException will be thrown.

This classloader can be used to limit the available classes from the specified parent classloader. Unlike ParentExclusiveClassLoader, this classloader doesn't limit the loaded classes to the parent, only that they are accessible through the parent.

public FilteringClassLoader(ClassLoader parent, Set<String> allowedClassNames) throws NullPointerException
Creates a new instance with the given parent and allowed class names.
parentThe parent classloader to filter.
allowedClassNamesThe names of the allowed classes.
NullPointerExceptionIf any of the arguments are null.
protected Class<?> findClass(String name) throws ClassNotFoundException
Overridden from: ClassLoader
Finds the class with the specified binary name. This method should be overridden by class loader implementations that follow the delegation model for loading classes, and will be invoked by the loadClass method after checking the parent class loader for the requested class. The default implementation throws a ClassNotFoundException.
nameThe binary name of the class
The resulting Class object
ClassNotFoundExceptionIf the class could not be found
1.2