public static class DynamicType.Default extends Object implements DynamicType
| Modifier and Type | Class and Description |
|---|---|
protected static class |
DynamicType.Default.Loaded<T>
A default implementation of a loaded dynamic type.
|
static class |
DynamicType.Default.Unloaded<T>
A default implementation of an unloaded dynamic type.
|
DynamicType.Builder<T>, DynamicType.Default| Modifier and Type | Field and Description |
|---|---|
protected List<? extends DynamicType> |
auxiliaryTypes
A list of auxiliary types for this dynamic type.
|
protected byte[] |
binaryRepresentation
The byte array representing this dynamic type.
|
protected LoadedTypeInitializer |
loadedTypeInitializer
The loaded type initializer for this dynamic type.
|
protected TypeDescription |
typeDescription
A type description of this dynamic type.
|
| Constructor and Description |
|---|
Default(TypeDescription typeDescription,
byte[] binaryRepresentation,
LoadedTypeInitializer loadedTypeInitializer,
List<? extends DynamicType> auxiliaryTypes)
Creates a new dynamic type.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other) |
Map<TypeDescription,byte[]> |
getAllTypes()
Returns all types that are implied by this dynamic type.
|
byte[] |
getBytes()
Returns a byte array representing this dynamic type.
|
Map<TypeDescription,LoadedTypeInitializer> |
getLoadedTypeInitializers()
Returns a map of all loaded type initializers for the main type and all auxiliary types, if any.
|
Map<TypeDescription,byte[]> |
getRawAuxiliaryTypes()
Returns a map of all auxiliary types that are required for making use of the main type.
|
TypeDescription |
getTypeDescription()
Returns a description of this dynamic type.
|
boolean |
hasAliveLoadedTypeInitializers()
Checks if a dynamic type requires some form of explicit type initialization, either for itself or for one
of its auxiliary types, if any.
|
int |
hashCode() |
File |
inject(File jar)
Injects the types of this dynamic type into a given jar file.
|
File |
inject(File sourceJar,
File targetJar)
Injects the types of this dynamic type into a given jar file.
|
Map<TypeDescription,File> |
saveIn(File folder)
Saves a dynamic type in a given folder using the Java class file format while respecting the naming conventions
for saving compiled Java classes.
|
File |
toJar(File file,
Manifest manifest)
Saves the contents of this dynamic type inside a jar file.
|
String |
toString() |
protected final TypeDescription typeDescription
protected final byte[] binaryRepresentation
protected final LoadedTypeInitializer loadedTypeInitializer
protected final List<? extends DynamicType> auxiliaryTypes
public Default(TypeDescription typeDescription, byte[] binaryRepresentation, LoadedTypeInitializer loadedTypeInitializer, List<? extends DynamicType> auxiliaryTypes)
typeDescription - A description of this dynamic type.binaryRepresentation - A byte array containing the binary representation of this dynamic type.loadedTypeInitializer - The loaded type initializer of this dynamic type.auxiliaryTypes - The auxiliary type required for this dynamic type.public TypeDescription getTypeDescription()
DynamicTypeReturns a description of this dynamic type.
Note: This description will most likely differ from the binary representation of this type. Normally, annotations and intercepted methods are not added to this type description.
getTypeDescription in interface DynamicTypepublic Map<TypeDescription,byte[]> getAllTypes()
DynamicTypegetAllTypes in interface DynamicTypepublic Map<TypeDescription,LoadedTypeInitializer> getLoadedTypeInitializers()
DynamicTypeReturns a map of all loaded type initializers for the main type and all auxiliary types, if any.
Note: The type descriptions will most likely differ from the binary representation of this type. Normally, annotations and intercepted methods are not added to the type descriptions of auxiliary types.
getLoadedTypeInitializers in interface DynamicTypepublic boolean hasAliveLoadedTypeInitializers()
DynamicTypehasAliveLoadedTypeInitializers in interface DynamicTypetrue if this type requires explicit type initialization.public byte[] getBytes()
DynamicTypegetBytes in interface DynamicTypepublic Map<TypeDescription,byte[]> getRawAuxiliaryTypes()
DynamicTypeReturns a map of all auxiliary types that are required for making use of the main type.
Note: The type descriptions will most likely differ from the binary representation of this type. Normally, annotations and intercepted methods are not added to the type descriptions of auxiliary types.
getRawAuxiliaryTypes in interface DynamicTypepublic Map<TypeDescription,File> saveIn(File folder) throws IOException
DynamicType
Saves a dynamic type in a given folder using the Java class file format while respecting the naming conventions
for saving compiled Java classes. All auxiliary types, if any, are saved in the same directory. The resulting
folder structure will resemble the structure that is required for Java run times, i.e. each folder representing
a segment of the package name. If the specified folder does not yet exist, it is created during the
call of this method.
Note: The type descriptions will most likely differ from the binary representation of this type. Normally, annotations and intercepted methods are not added to the type descriptions of auxiliary types.
saveIn in interface DynamicTypefolder - The base target folder for storing this dynamic type and its auxiliary types, if any.folder.IOException - Thrown if the underlying file operations cause an IOException.public File inject(File sourceJar, File targetJar) throws IOException
DynamicTypetarget file's folder must exist prior to calling this method. The
file itself is overwritten or created depending on its prior existence.inject in interface DynamicTypesourceJar - The original jar file.targetJar - The source jar file with the injected contents.target jar file.IOException - If an IO exception occurs while injecting from the source into the target.public File inject(File jar) throws IOException
DynamicTypeinject in interface DynamicTypejar - The jar file to replace with an injected version.jar file.IOException - If an IO exception occurs while injecting into the jar.public File toJar(File file, Manifest manifest) throws IOException
DynamicTypefile must
exist prior to calling this method.toJar in interface DynamicTypefile - The target file to which the jar is written to.manifest - The manifest of the created jar.file.IOException - If an IO exception occurs while writing the file.Copyright © 2014. All rights reserved.