Class Classes.ClassLoaderBuilder<B extends Classes.ClassLoaderBuilder<B>>
- Enclosing class:
- Classes
URLClassLoader.-
Method Summary
Modifier and TypeMethodDescriptionabstract URLClassLoaderbuild()setCustomLookupNativeLibraries(String... nativeLibraries) abstract BsetCustomLookupNativeLibraries(Predicate<String> libraries) Set a predicate that specifies for which native libraries we should use a custom lookup for the binary as documented inNativeLibraries.setCustomLookupNativeLibraries(Pattern nativeLibraries) abstract BsetDirectLoadClasses(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.setDirectLoadClasses(Pattern classes) abstract BsetParent(ClassLoader parent) Set parent of new class loader.setParentAndUrls(URLClassLoader parent) Set anURLClassLoaderas parent and its URLs fromURLClassLoader.getURLs()as sources for new class loader.abstract BSet sources for classes of new class loader just like forURLClassLoader(this orsetUrls(URL...)are required).abstract BSet sources for classes of new class loader just like forURLClassLoader(this orsetUrls(Iterable)are required).
-
Method Details
-
setParent
Set parent of new class loader. If not set the default delegation parent class loader will be used (likeURLClassLoader(URL[]). -
setUrls
Set sources for classes of new class loader just like forURLClassLoader(this orsetUrls(URL...)are required). -
setUrls
Set sources for classes of new class loader just like forURLClassLoader(this orsetUrls(Iterable)are required). -
setParentAndUrls
Set anURLClassLoaderas parent and its URLs fromURLClassLoader.getURLs()as sources for new class loader. -
setDirectLoadClasses
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.
-
setDirectLoadClasses
-
setCustomLookupNativeLibraries
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
-
setCustomLookupNativeLibraries
-
build
-