public class ClassLoaderByteArrayInjector extends Object
ClassLoader
.
Note that the injector is only able to load classes in a linear manner. Thus, classes that refer to other classes which are not yet loaded cannot be injected but will result in a
NoClassDefFoundError
. This becomes
a problem when classes refer to each other using cyclic references. This injector can further not be applied to the
bootstrap class loader which is usually represented by a null
value and can therefore not be accessed by
reflection.Constructor and Description |
---|
ClassLoaderByteArrayInjector(ClassLoader classLoader)
Creates a new injector for the given
ClassLoader . |
Modifier and Type | Method and Description |
---|---|
Class<?> |
inject(String name,
byte[] binaryRepresentation)
Explicitly loads a
Class by reflective access into the represented class loader. |
public ClassLoaderByteArrayInjector(ClassLoader classLoader)
ClassLoader
.classLoader
- The ClassLoader
into which new class definitions are to be injected.public Class<?> inject(String name, byte[] binaryRepresentation)
Class
by reflective access into the represented class loader.name
- The fully qualified name of the Class
to be loaded.binaryRepresentation
- The type's binary representation.Copyright © 2014. All rights reserved.