Package org.codehaus.commons.compiler.util.reflect

# Class ByteArrayClassLoader

java.lang.Object
java.lang.ClassLoader
org.codehaus.commons.compiler.util.reflect.ByteArrayClassLoader

public class ByteArrayClassLoader extends ClassLoader
This `ClassLoader` allows for the loading of a set of Java classes provided in class file format.

## Constructor Summary

Constructors
Constructor
Description
`ByteArrayClassLoader(Map<String,byte[]> classes)`
The given `Map` of classes must not be modified afterwards.
`ByteArrayClassLoader(Map<String,byte[]> classes, ClassLoader parent)`

## Method Summary

Modifier and Type
Method
Description
`protected Class<?>`
`findClass(String name)`
Implements `ClassLoader.findClass(String)`.
`InputStream`
`getResourceAsStream(String name)`
`void`
`setResources(Map<String,byte[]> resources)`

### Methods inherited from class java.lang.ClassLoader

`clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResource, findResources, 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`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### ByteArrayClassLoader

public ByteArrayClassLoader(Map<String,byte[]> classes)
The given `Map` of classes must not be modified afterwards.

Parameters:
  `classes` - String className => byte[] data, or String classFileName => byte[] data

### ByteArrayClassLoader

public ByteArrayClassLoader(Map<String,byte[]> classes, ClassLoader parent)

Parameters:
  `classes` - `String className` => `byte[] data`, or `String classFileName` => `byte[] data`

## Method Details

### setResources

public void setResources(Map<String,byte[]> resources)

### findClass

protected Class<?> findClass(@Nullable String name) throws ClassNotFoundException
Implements `ClassLoader.findClass(String)`.

Notice that, although nowhere documented, no more than one thread at a time calls this method, because `ClassLoader.loadClass(java.lang.String)` is `synchronized`.

Overrides:
  `findClass` in class `ClassLoader`
Throws:
  `ClassNotFoundException`

### getResourceAsStream

public InputStream getResourceAsStream(String name)

Overrides:
  `getResourceAsStream` in class `ClassLoader`