Class Classes.ClassLoaderBuilder<B extends Classes.ClassLoaderBuilder<B>>
- java.lang.Object
-
- org.sosy_lab.common.Classes.ClassLoaderBuilder<B>
-
- Enclosing class:
- Classes
public abstract static class Classes.ClassLoaderBuilder<B extends Classes.ClassLoaderBuilder<B>> extends Object
A builder for class loaders with more features thanURLClassLoader
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract URLClassLoader
build()
B
setCustomLookupNativeLibraries(String... nativeLibraries)
abstract B
setCustomLookupNativeLibraries(Predicate<String> libraries)
Set a predicate that specifies for which native libraries we should use a custom lookup for the binary as documented inNativeLibraries
.B
setCustomLookupNativeLibraries(Pattern nativeLibraries)
abstract B
setDirectLoadClasses(Predicate<String> classes)
Set a predicate that specifies which classes are forced to be loaded by the new class loader and not its parent, even if the latter could load them.B
setDirectLoadClasses(Pattern classes)
abstract B
setParent(ClassLoader parent)
Set parent of new class loader.B
setParentAndUrls(URLClassLoader parent)
Set anURLClassLoader
as parent and its URLs fromURLClassLoader.getURLs()
as sources for new class loader.abstract B
setUrls(Iterable<URL> urls)
Set sources for classes of new class loader just like forURLClassLoader
(this orsetUrls(URL...)
are required).abstract B
setUrls(URL... urls)
Set sources for classes of new class loader just like forURLClassLoader
(this orsetUrls(Iterable)
are required).
-
-
-
Method Detail
-
setParent
@CanIgnoreReturnValue public abstract B setParent(ClassLoader parent)
Set parent of new class loader. If not set the default delegation parent class loader will be used (likeURLClassLoader(URL[])
.
-
setUrls
@CanIgnoreReturnValue public abstract B setUrls(Iterable<URL> urls)
Set sources for classes of new class loader just like forURLClassLoader
(this orsetUrls(URL...)
are required).
-
setUrls
@CanIgnoreReturnValue public abstract B setUrls(URL... urls)
Set sources for classes of new class loader just like forURLClassLoader
(this orsetUrls(Iterable)
are required).
-
setParentAndUrls
@CanIgnoreReturnValue public B setParentAndUrls(URLClassLoader parent)
Set anURLClassLoader
as parent and its URLs fromURLClassLoader.getURLs()
as sources for new class loader.
-
setDirectLoadClasses
@CanIgnoreReturnValue public abstract B setDirectLoadClasses(Predicate<String> classes)
Set a predicate that specifies which classes are forced to be loaded by the new class loader and not its parent, even if the latter could load them.The predicate should match the fully-qualified class name. The default is to not match any classes.
Normally class loaders follow the parent-first strategy, so they never load classes which their parent could also load. The new class loader follows the child-first strategy for a specific set of classes (as specified by this predicate) and the parent-first strategy for the rest.
This feature can be used if you want to load a component with its own class loader (so that it can be garbage collected independently, for example), but the parent class loader also sees the classes.
-
setCustomLookupNativeLibraries
@CanIgnoreReturnValue public abstract B setCustomLookupNativeLibraries(Predicate<String> libraries)
Set a predicate that specifies for which native libraries we should use a custom lookup for the binary as documented inNativeLibraries
.The predicate should match the library name as given to
System.loadLibrary(String)
. The default is to not match any libraries.Note that this is only effective if the new class loader is actually the one that is asked to load the new library. Because Java's class loaders follow the parent-first strategy, it is easy to end up with a parent class loader loading the library, if the parent can see the class(es) that do the loading. In this case, use
setDirectLoadClasses(Predicate)
to ensure the new class loader loads all relevant classes itself.
-
setCustomLookupNativeLibraries
@CanIgnoreReturnValue public B setCustomLookupNativeLibraries(Pattern nativeLibraries)
-
setCustomLookupNativeLibraries
@CanIgnoreReturnValue public B setCustomLookupNativeLibraries(String... nativeLibraries)
-
build
@CheckReturnValue public abstract URLClassLoader build()
-
-