@HashCodeAndEqualsPlugin.Enhance public abstract static class DynamicType.AbstractBase extends Object implements DynamicType
DynamicType.AbstractBase, DynamicType.Builder<T>, DynamicType.Default, DynamicType.Loaded<T>, DynamicType.Unloaded<T>
ClassFileLocator.Compound, ClassFileLocator.Filtering, ClassFileLocator.ForClassLoader, ClassFileLocator.ForFolder, ClassFileLocator.ForInstrumentation, ClassFileLocator.ForJarFile, ClassFileLocator.ForModule, ClassFileLocator.ForModuleFile, ClassFileLocator.ForUrl, ClassFileLocator.MultiReleaseAware, ClassFileLocator.NoOp, ClassFileLocator.PackageDiscriminating, ClassFileLocator.Resolution, ClassFileLocator.Simple
META_INF_VERSIONS
Constructor and Description |
---|
AbstractBase() |
Modifier and Type | Method and Description |
---|---|
void |
close() |
Set<TypeDescription> |
getAllTypeDescriptions()
Returns a set of all types that are represented by this dynamic type.
|
Map<TypeDescription,byte[]> |
getAllTypes()
Returns all types that are implied by this dynamic type.
|
Set<TypeDescription> |
getAuxiliaryTypeDescriptions()
Returns a set of all auxiliary types that are represented 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.
|
Map<TypeDescription,LoadedTypeInitializer> |
getLoadedTypeInitializers()
Returns a map of all loaded type initializers for the main type and all auxiliary types, if any.
|
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.
|
ClassFileLocator.Resolution |
locate(String name)
Locates the class file for a given type and returns the binary data of the class 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getAuxiliaries, getBytes, getLoadedTypeInitializer, getTypeDescription
public ClassFileLocator.Resolution locate(String name) throws IOException
locate
in interface ClassFileLocator
name
- The name of the type to locate a class file representation for.IOException
- If reading a class file causes an error.public void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in interface DynamicType
public Set<TypeDescription> getAuxiliaryTypeDescriptions()
getAuxiliaryTypeDescriptions
in interface DynamicType
public Set<TypeDescription> getAllTypeDescriptions()
getAllTypeDescriptions
in interface DynamicType
public Map<TypeDescription,byte[]> getAllTypes()
getAllTypes
in interface DynamicType
public 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.
getLoadedTypeInitializers
in interface DynamicType
public boolean hasAliveLoadedTypeInitializers()
hasAliveLoadedTypeInitializers
in interface DynamicType
true
if this type requires explicit type initialization.public 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.
getAuxiliaryTypes
in interface DynamicType
public 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.
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
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
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
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.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
file
must
exist prior to calling this method. No directory entries are added to the generated jar.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–2025. All rights reserved.