@HashCodeAndEqualsPlugin.Enhance 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 |
---|---|
Map<TypeDescription,byte[]> |
getAllTypes()
Returns all types that are implied by this dynamic type.
|
Map<TypeDescription,byte[]> |
getAuxiliaryTypes()
Returns a map of all auxiliary types that are required for making use of the main 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.
|
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.
|
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)
Saves the contents of this dynamic type inside a jar file.
|
File |
toJar(File file,
Manifest manifest)
Saves the contents of this dynamic type inside a jar file.
|
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. The array must not be modified.loadedTypeInitializer
- The loaded type initializer of this dynamic type.auxiliaryTypes
- The auxiliary type required for this dynamic type.public TypeDescription getTypeDescription()
DynamicType
Returns 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 DynamicType
public Map<TypeDescription,byte[]> getAllTypes()
DynamicType
getAllTypes
in interface DynamicType
public Map<TypeDescription,LoadedTypeInitializer> getLoadedTypeInitializers()
DynamicType
Returns 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 DynamicType
public boolean hasAliveLoadedTypeInitializers()
DynamicType
hasAliveLoadedTypeInitializers
in interface DynamicType
true
if this type requires explicit type initialization.public byte[] getBytes()
DynamicType
getBytes
in interface DynamicType
public Map<TypeDescription,byte[]> getAuxiliaryTypes()
DynamicType
Returns 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.
getAuxiliaryTypes
in interface DynamicType
public 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 DynamicType
folder
- 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
DynamicType
target
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 DynamicType
sourceJar
- The original jar file.targetJar
- The source
jar file with the injected contents.target
jar file.IOException
- If an I/O exception occurs while injecting from the source into the target.public File inject(File jar) throws IOException
DynamicType
inject
in interface DynamicType
jar
- The jar file to replace with an injected version.jar
file.IOException
- If an I/O exception occurs while injecting into the jar.public File toJar(File file) throws IOException
DynamicType
file
must
exist prior to calling this method. The jar file is created with a simple manifest that only contains a version
number.toJar
in interface DynamicType
file
- The target file to which the jar is written to.file
.IOException
- If an I/O exception occurs while writing the file.public File toJar(File file, Manifest manifest) throws IOException
DynamicType
file
must
exist prior to calling this method.toJar
in interface DynamicType
file
- The target file to which the jar is written to.manifest
- The manifest of the created jar.file
.IOException
- If an I/O exception occurs while writing the file.Copyright © 2014–2018. All rights reserved.