# 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](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/net/URLClassLoader.html) 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 {#com.jsmacrosce.jsmacros.core.extensions.ExtensionClassLoader_constructor-URL[]-}

```js
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 {#com.jsmacrosce.jsmacros.core.extensions.ExtensionClassLoader_addURL-URL-}

```js
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
