public interface DynamicType
DynamicType.Builder
or as the result of an
AuxiliaryType
.
Note that the
TypeDescription
s will represent their
unloaded forms and therefore differ from the loaded types, especially with regards to annotations.Modifier and Type | Interface and Description |
---|---|
static interface |
DynamicType.Builder<T>
A builder for creating a dynamic type.
|
static class |
DynamicType.Default
A default implementation of a dynamic type.
|
static interface |
DynamicType.Loaded<T>
A dynamic type that has been loaded into the running instance of the Java virtual machine.
|
static interface |
DynamicType.Unloaded<T>
A dynamic type that has not yet been loaded by a given
ClassLoader . |
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.
|
TypeDescription getTypeDescription()
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.
byte[] getBytes()
Map<TypeDescription,byte[]> getAuxiliaryTypes()
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.
Map<TypeDescription,byte[]> getAllTypes()
Map<TypeDescription,LoadedTypeInitializer> getLoadedTypeInitializers()
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.
boolean hasAliveLoadedTypeInitializers()
true
if this type requires explicit type initialization.Map<TypeDescription,File> saveIn(File folder) throws IOException
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.
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
.File inject(File sourceJar, File targetJar) throws IOException
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.File inject(File jar) throws IOException
jar
- The jar file to replace with an injected version.jar
file.IOException
- If an I/O exception occurs while injecting into the jar.File toJar(File file) throws IOException
file
must
exist prior to calling this method. The jar file is created with a simple manifest that only contains a version
number. No directory entries are added to the generated jar.file
- The target file to which the jar is written to.file
.IOException
- If an I/O exception occurs while writing the file.File toJar(File file, Manifest manifest) throws IOException
file
must
exist prior to calling this method. No directory entries are added to the generated jar.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–2020. All rights reserved.