- java.lang.Object
-
- java.lang.ClassLoader
-
- java.security.SecureClassLoader
-
- java.net.URLClassLoader
-
- org.arakhne.afc.vmutil.DynamicURLClassLoader
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
- Direct Known Subclasses:
DynamicURLClassLoader.FactoryDynamicURLClassLoader
public class DynamicURLClassLoader extends URLClassLoader
This class loader permits to load classes from a set of classpaths.- Version:
- 17.0 2020-01-04 14:41:35
- Author:
- Stéphane GALLAND
- Maven Group Id:
- org.arakhne.afc.core
- Maven Artifact Id:
- vmutils
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
DynamicURLClassLoader.FactoryDynamicURLClassLoader
This class loader permits to load classes from a set of classpaths.
-
Constructor Summary
Constructors Modifier Constructor Description protected
DynamicURLClassLoader(ClassLoader parent, URL... urls)
Constructs a new ClassPathClassLoader for the given URLs.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addURL(URL url)
Appends the specified URL to the list of URLs to search for classes and resources.void
addURLs(URL... urls)
Appends the specified URL to the list of URLs to search for classes and resources.static DynamicURLClassLoader
newInstance(ClassLoader parent, URL... urls)
Creates a new instance of DynamicURLClassLoader for the specified URLs and parent class loader.-
Methods inherited from class java.net.URLClassLoader
close, definePackage, findClass, findResource, findResources, getPermissions, getResourceAsStream, getURLs, newInstance, newInstance
-
Methods inherited from class java.security.SecureClassLoader
defineClass, defineClass
-
Methods inherited from class java.lang.ClassLoader
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findSystemClass, getClassLoadingLock, getDefinedPackage, getDefinedPackages, getName, getPackage, getPackages, getParent, getPlatformClassLoader, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, getUnnamedModule, isRegisteredAsParallelCapable, loadClass, loadClass, registerAsParallelCapable, resolveClass, resources, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
-
-
-
-
Constructor Detail
-
DynamicURLClassLoader
protected DynamicURLClassLoader(ClassLoader parent, URL... urls)
Constructs a new ClassPathClassLoader for the given URLs. The URLs will be searched in the order specified for classes and resources after first searching in the specified parent class loader. Any URL that ends with a '/' is assumed to refer to a directory. Otherwise, the URL is assumed to refer to a JAR file which will be downloaded and opened as needed.If there is a security manager, this method first calls the security manager's
checkCreateClassLoader
method to ensure creation of a class loader is allowed.- Parameters:
parent
- the parent class loader for delegationurls
- the URLs from which to load classes and resources- Throws:
SecurityException
- if a security manager exists and itscheckCreateClassLoader
method doesn't allow creation of a class loader.- See Also:
SecurityManager.checkCreateClassLoader()
-
-
Method Detail
-
addURL
public void addURL(URL url)
Appends the specified URL to the list of URLs to search for classes and resources.- Overrides:
addURL
in classURLClassLoader
- Parameters:
url
- the URL to be added to the search path of URLs
-
addURLs
public void addURLs(URL... urls)
Appends the specified URL to the list of URLs to search for classes and resources.- Parameters:
urls
- the URLs to be added to the search path of URLs
-
newInstance
@Pure public static DynamicURLClassLoader newInstance(ClassLoader parent, URL... urls)
Creates a new instance of DynamicURLClassLoader for the specified URLs and parent class loader. If a security manager is installed, theloadClass
method of the URLClassLoader returned by this method will invoke theSecurityManager.checkPackageAccess
method before loading the class.- Parameters:
parent
- the parent class loader for delegationurls
- the URLs to search for classes and resources- Returns:
- the resulting class loader
-
-