Skip to content

ExtensionClassLoader ​

com.jsmacrosce.jsmacros.core.extensions.ExtensionClassLoader

Loads extension classes and resources from jar files on a URL search path.

Every archive this loader reads exists as a file first. The extension loader copies a nested archive, such as a dependency inside an extension jar, out of its container before adding it here, because a URLClassLoader cannot open an archive that is itself an entry of another archive.

The parent is the class loader that defined ExtensionClassLoader; class loading otherwise follows the inherited parent-first delegation model, so an extension always uses the core's own classes.

js
const Loader = Java.type("com.jsmacrosce.jsmacros.core.extensions.ExtensionClassLoader");  
const urls = Java.to([], "java.net.URL[]");  
const loader = new Loader(urls);  
try {
 loader.loadClass("java.lang.String");  
} finally {
 loader.close();  
}

Constructors ​

new ExtensionClassLoader ​

new ExtensionClassLoader(URL[] urls)#
Sets the initial URL search path and uses the loader that defined this class as parent.

Parameters:

  • urls: initial URLs; the array must not be null, but may be empty

Methods ​

addURL ​

addURL(URL url): void#
Appends a jar file to this loader's search path, for example an extension dependency that has already been extracted from its parent archive. A null URL and a URL that is already on the path are ignored.

Parameters:

  • url: URL to append; null is ignored