public abstract class InjectionClassLoader extends ClassLoader
An injection class loader allows for the injection of a class after the class loader was created. Injection is only possible if this class loader is not sealed.
Important: Not sealing a class loader allows to break package encapsulation for anybody getting hold of a reference to this class loader.
Modifier and Type | Class and Description |
---|---|
static class |
InjectionClassLoader.Strategy
A class loading strategy for adding a type to an injection class loader.
|
Modifier | Constructor and Description |
---|---|
protected |
InjectionClassLoader(ClassLoader parent,
boolean sealed)
Creates a new injection class loader.
|
Modifier and Type | Method and Description |
---|---|
Class<?> |
defineClass(String name,
byte[] binaryRepresentation)
Defines a new type to be loaded by this class loader.
|
Map<String,Class<?>> |
defineClasses(Map<String,byte[]> typeDefinitions)
Defines a group of types to be loaded by this class loader.
|
protected abstract Map<String,Class<?>> |
doDefineClasses(Map<String,byte[]> typeDefinitions)
Defines a group of types to be loaded by this class loader.
|
boolean |
isSealed()
Returns
true if this class loader is sealed. |
clearAssertionStatus, defineClass, defineClass, defineClass, defineClass, definePackage, findClass, findLibrary, findLoadedClass, findResource, findResources, findSystemClass, getClassLoadingLock, getPackage, getPackages, getParent, getResource, getResourceAsStream, getResources, getSystemClassLoader, getSystemResource, getSystemResourceAsStream, getSystemResources, loadClass, loadClass, registerAsParallelCapable, resolveClass, setClassAssertionStatus, setDefaultAssertionStatus, setPackageAssertionStatus, setSigners
protected InjectionClassLoader(ClassLoader parent, boolean sealed)
parent
- The class loader's parent.sealed
- Indicates if this class loader is sealed, i.e. forbids runtime injection.public boolean isSealed()
true
if this class loader is sealed.true
if this class loader is sealed.public Class<?> defineClass(String name, byte[] binaryRepresentation) throws ClassNotFoundException
name
- The name of the type.binaryRepresentation
- The type's binary representation.ClassNotFoundException
- If the class could not be loaded.public Map<String,Class<?>> defineClasses(Map<String,byte[]> typeDefinitions) throws ClassNotFoundException
IllegalStateException
is thrown.typeDefinitions
- The types binary representations.ClassNotFoundException
- If the class could not be loaded.protected abstract Map<String,Class<?>> doDefineClasses(Map<String,byte[]> typeDefinitions) throws ClassNotFoundException
typeDefinitions
- The types binary representations.ClassNotFoundException
- If the class could not be loaded.Copyright © 2014–2021. All rights reserved.