public class ByteArrayClassLoader extends ClassLoader
ClassLoader
that is capable of loading explicitly defined classes. The class loader will free
any binary resources once a class that is defined by its binary data is loaded. This class loader is thread safe since
the class loading mechanics are only called from synchronized context.Modifier and Type | Class and Description |
---|---|
static class |
ByteArrayClassLoader.ChildFirst
A
ByteArrayClassLoader which applies child-first semantics for the
given type definitions. |
static class |
ByteArrayClassLoader.PersistenceHandler
A persistence handler decides on weather the byte array that represents a loaded class is exposed by
the
ClassLoader.getResourceAsStream(String) method. |
Modifier and Type | Field and Description |
---|---|
protected AccessControlContext |
accessControlContext
The access control context of this class loader's instantiation.
|
protected ByteArrayClassLoader.PersistenceHandler |
persistenceHandler
The persistence handler of this class loader.
|
protected ProtectionDomain |
protectionDomain
The protection domain to apply.
|
protected Map<String,byte[]> |
typeDefinitions
A mutable map of type names mapped to their binary representation.
|
Constructor and Description |
---|
ByteArrayClassLoader(ClassLoader parent,
Map<String,byte[]> typeDefinitions,
ProtectionDomain protectionDomain,
ByteArrayClassLoader.PersistenceHandler persistenceHandler)
Creates a new class loader for a given definition of classes.
|
Modifier and Type | Method and Description |
---|---|
protected Class<?> |
findClass(String name) |
InputStream |
getResourceAsStream(String name) |
static Map<TypeDescription,Class<?>> |
load(ClassLoader classLoader,
Map<TypeDescription,byte[]> types,
ProtectionDomain protectionDomain,
ByteArrayClassLoader.PersistenceHandler persistenceHandler,
boolean childFirst)
Loads a given set of class descriptions and their binary representations.
|
static ClassLoader |
of(ClassLoader parent,
Map<TypeDescription,byte[]> typeDefinitions,
ProtectionDomain protectionDomain,
ByteArrayClassLoader.PersistenceHandler persistenceHandler,
boolean childFirst)
Creates a new class loader for a given definition of classes.
|
String |
toString() |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
protected final Map<String,byte[]> typeDefinitions
protected final ByteArrayClassLoader.PersistenceHandler persistenceHandler
protected final ProtectionDomain protectionDomain
null
when referencing the default protection domain.protected final AccessControlContext accessControlContext
public ByteArrayClassLoader(ClassLoader parent, Map<String,byte[]> typeDefinitions, ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler)
parent
- The ClassLoader
that is the parent of this class loader.typeDefinitions
- A map of fully qualified class names pointing to their binary representations.protectionDomain
- The protection domain to apply where null
references an implicit
protection domain.persistenceHandler
- The persistence handler of this class loader.public static ClassLoader of(ClassLoader parent, Map<TypeDescription,byte[]> typeDefinitions, ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, boolean childFirst)
parent
- The ClassLoader
that is the parent of this class loader.typeDefinitions
- A map of type descriptions pointing to their binary representations.protectionDomain
- The protection domain to apply where null
references an implicit
protection domain.persistenceHandler
- The persistence handler to be used by the created class loader.childFirst
- true
if the class loader should apply child first semantics when loading
the typeDefinitions
.public static Map<TypeDescription,Class<?>> load(ClassLoader classLoader, Map<TypeDescription,byte[]> types, ProtectionDomain protectionDomain, ByteArrayClassLoader.PersistenceHandler persistenceHandler, boolean childFirst)
classLoader
- The parent class loader.types
- The raw types to load.protectionDomain
- The protection domain to apply where null
references an implicit
protection domain.persistenceHandler
- The persistence handler of the created class loader.childFirst
- true
true
if the created class loader should apply child-first
semantics when loading the types
.protected Class<?> findClass(String name) throws ClassNotFoundException
findClass
in class ClassLoader
ClassNotFoundException
public InputStream getResourceAsStream(String name)
getResourceAsStream
in class ClassLoader
Copyright © 2014–2015. All rights reserved.