Package net.bytebuddy.dynamic.scaffold
Class TypeWriter.Default<S>
java.lang.Object
net.bytebuddy.dynamic.scaffold.TypeWriter.Default<S>
- Type Parameters:
S
- The best known loaded type for the dynamically created type.
- All Implemented Interfaces:
TypeWriter<S>
- Direct Known Subclasses:
TypeWriter.Default.ForCreation
,TypeWriter.Default.ForInlining
- Enclosing interface:
TypeWriter<T>
A default implementation of a
TypeWriter
.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static class
An action to write a class file to the dumping location.static class
A type writer that creates a class file that is not based upon another, existing class.static class
A type writer that inlines the created type into an existing class file.protected static class
A key to represent a unique signature.protected class
An unresolved type.protected static class
A class validator that validates that a class only defines members that are appropriate for the sort of the generated class.Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.scaffold.TypeWriter
TypeWriter.Default<S>, TypeWriter.FieldPool, TypeWriter.MethodPool, TypeWriter.RecordComponentPool
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AnnotationRetention
The annotation retention to apply.protected final AnnotationValueFilter.Factory
The annotation value filter factory to apply.protected final AsmVisitorWrapper
The ASM visitor wrapper to apply onto the class writer.protected final AuxiliaryType.NamingStrategy
The naming strategy for auxiliary types to apply.protected final List
<? extends DynamicType> The explicit auxiliary types to add to the created type.protected final ClassFileVersion
The class file specified by the user.protected final AsmClassReader.Factory
The class reader factory to use.protected final AsmClassWriter.Factory
The class writer factory to use.protected static final String
A folder for dumping class files ornull
if no dump should be generated.protected final TypeWriter.FieldPool
The field pool to use.protected final FieldList
<FieldDescription.InDefinedShape> The instrumented type's declared fields.protected final Implementation.Context.Factory
The implementation context factory to apply.protected final MethodList
<?> The instrumented methods relevant to this type creation.protected final TypeDescription
The instrumented type to be created.protected final LoadedTypeInitializer
The loaded type initializer to apply onto the created type after loading.protected final MethodList
<?> The instrumented type's methods that are declared or inherited.private static final String
Indicates an empty reference in a class file which is expressed bynull
.protected final TypeWriter.RecordComponentPool
The record component pool to use.protected final RecordComponentList
<RecordComponentDescription.InDefinedShape> The instrumented type's record components.protected final TypeAttributeAppender
The type attribute appender to apply onto the instrumented type.protected final TypeInitializer
The type initializer to include in the created type's type initializer.protected final TypePool
The type pool to use for computing stack map frames, if required.protected final TypeValidation
Determines if a type should be explicitly validated.Fields inherited from interface net.bytebuddy.dynamic.scaffold.TypeWriter
DUMP_PROPERTY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Default
(TypeDescription instrumentedType, ClassFileVersion classFileVersion, TypeWriter.FieldPool fieldPool, TypeWriter.RecordComponentPool recordComponentPool, List<? extends DynamicType> auxiliaryTypes, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, MethodList<?> instrumentedMethods, RecordComponentList<RecordComponentDescription.InDefinedShape> recordComponents, LoadedTypeInitializer loadedTypeInitializer, TypeInitializer typeInitializer, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, AsmClassReader.Factory classReaderFactory, AsmClassWriter.Factory classWriterFactory, TypePool typePool) Creates a new default type writer. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract TypeWriter.Default<S>.UnresolvedType
create
(TypeInitializer typeInitializer, TypeWriter.Default.ClassDumpAction.Dispatcher dispatcher) Creates an unresolved version of the dynamic type.private static <T> T
doPrivileged
(PrivilegedAction<T> action) A proxy forjava.security.AccessController#doPrivileged
that is activated if available.private static <T> T
doPrivileged
(PrivilegedExceptionAction<T> action) A proxy forjava.security.AccessController#doPrivileged
that is activated if available.static <U> TypeWriter
<U> forCreation
(MethodRegistry.Compiled methodRegistry, List<? extends DynamicType> auxiliaryTypes, TypeWriter.FieldPool fieldPool, TypeWriter.RecordComponentPool recordComponentPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, AsmClassReader.Factory classReaderFactory, AsmClassWriter.Factory classWriterFactory, TypePool typePool) Creates a type writer for creating a new type.static <U> TypeWriter
<U> forDecoration
(TypeDescription instrumentedType, ClassFileVersion classFileVersion, List<? extends DynamicType> auxiliaryTypes, List<? extends MethodDescription> methods, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, AsmClassReader.Factory classReaderFactory, AsmClassWriter.Factory classWriterFactory, TypePool typePool, ClassFileLocator classFileLocator) Creates a type writer for decorating a type.static <U> TypeWriter
<U> forRebasing
(MethodRegistry.Prepared methodRegistry, List<? extends DynamicType> auxiliaryTypes, TypeWriter.FieldPool fieldPool, TypeWriter.RecordComponentPool recordComponentPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, AsmClassReader.Factory classReaderFactory, AsmClassWriter.Factory classWriterFactory, TypePool typePool, TypeDescription originalType, ClassFileLocator classFileLocator, MethodRebaseResolver methodRebaseResolver) Creates a type writer for rebasing a type.static <U> TypeWriter
<U> forRedefinition
(MethodRegistry.Prepared methodRegistry, List<? extends DynamicType> auxiliaryTypes, TypeWriter.FieldPool fieldPool, TypeWriter.RecordComponentPool recordComponentPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, AsmClassReader.Factory classReaderFactory, AsmClassWriter.Factory classWriterFactory, TypePool typePool, TypeDescription originalType, ClassFileLocator classFileLocator) Creates a type writer for redefining a type.make
(TypeResolutionStrategy.Resolved typeResolutionStrategy) Creates the dynamic type that is described by this type writer.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.bytebuddy.dynamic.scaffold.TypeWriter
wrap
-
Field Details
-
NO_REFERENCE
Indicates an empty reference in a class file which is expressed bynull
. -
DUMP_FOLDER
A folder for dumping class files ornull
if no dump should be generated. -
instrumentedType
The instrumented type to be created. -
classFileVersion
The class file specified by the user. -
fieldPool
The field pool to use. -
recordComponentPool
The record component pool to use. -
auxiliaryTypes
The explicit auxiliary types to add to the created type. -
fields
The instrumented type's declared fields. -
methods
The instrumented type's methods that are declared or inherited. -
instrumentedMethods
The instrumented methods relevant to this type creation. -
recordComponents
The instrumented type's record components. -
loadedTypeInitializer
The loaded type initializer to apply onto the created type after loading. -
typeInitializer
The type initializer to include in the created type's type initializer. -
typeAttributeAppender
The type attribute appender to apply onto the instrumented type. -
asmVisitorWrapper
The ASM visitor wrapper to apply onto the class writer. -
annotationValueFilterFactory
The annotation value filter factory to apply. -
annotationRetention
The annotation retention to apply. -
auxiliaryTypeNamingStrategy
The naming strategy for auxiliary types to apply. -
implementationContextFactory
The implementation context factory to apply. -
typeValidation
Determines if a type should be explicitly validated. -
classReaderFactory
The class reader factory to use. -
classWriterFactory
The class writer factory to use. -
typePool
The type pool to use for computing stack map frames, if required.
-
-
Constructor Details
-
Default
protected Default(TypeDescription instrumentedType, ClassFileVersion classFileVersion, TypeWriter.FieldPool fieldPool, TypeWriter.RecordComponentPool recordComponentPool, List<? extends DynamicType> auxiliaryTypes, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, MethodList<?> instrumentedMethods, RecordComponentList<RecordComponentDescription.InDefinedShape> recordComponents, LoadedTypeInitializer loadedTypeInitializer, TypeInitializer typeInitializer, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, AsmClassReader.Factory classReaderFactory, AsmClassWriter.Factory classWriterFactory, TypePool typePool) Creates a new default type writer.- Parameters:
instrumentedType
- The instrumented type to be created.classFileVersion
- The class file specified by the user.fieldPool
- The field pool to use.recordComponentPool
- The record component pool to use.auxiliaryTypes
- The explicit auxiliary types to add to the created type.fields
- The instrumented type's declared fields.methods
- The instrumented type's declared and virtually inherited methods.instrumentedMethods
- The instrumented methods relevant to this type creation.recordComponents
- The instrumented type's record components.loadedTypeInitializer
- The loaded type initializer to apply onto the created type after loading.typeInitializer
- The type initializer to include in the created type's type initializer.typeAttributeAppender
- The type attribute appender to apply onto the instrumented type.asmVisitorWrapper
- The ASM visitor wrapper to apply onto the class writer.annotationValueFilterFactory
- The annotation value filter factory to apply.annotationRetention
- The annotation retention to apply.auxiliaryTypeNamingStrategy
- The naming strategy for auxiliary types to apply.implementationContextFactory
- The implementation context factory to apply.typeValidation
- Determines if a type should be explicitly validated.classReaderFactory
- The class reader factory to use.classWriterFactory
- The class writer factory to use.typePool
- The type pool to use for computing stack map frames, if required.
-
-
Method Details
-
doPrivileged
A proxy forjava.security.AccessController#doPrivileged
that is activated if available.- Type Parameters:
T
- The type of the action's resolved value.- Parameters:
action
- The action to execute from a privileged context.- Returns:
- The action's resolved value.
-
doPrivileged
A proxy forjava.security.AccessController#doPrivileged
that is activated if available.- Type Parameters:
T
- The type of the action's resolved value.- Parameters:
action
- The action to execute from a privileged context.- Returns:
- The action's resolved value.
- Throws:
Exception
- If an exception occurs.
-
forCreation
public static <U> TypeWriter<U> forCreation(MethodRegistry.Compiled methodRegistry, List<? extends DynamicType> auxiliaryTypes, TypeWriter.FieldPool fieldPool, TypeWriter.RecordComponentPool recordComponentPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, AsmClassReader.Factory classReaderFactory, AsmClassWriter.Factory classWriterFactory, TypePool typePool) Creates a type writer for creating a new type.- Type Parameters:
U
- A loaded type that the instrumented type guarantees to subclass.- Parameters:
methodRegistry
- The compiled method registry to use.auxiliaryTypes
- A list of explicitly required auxiliary types.fieldPool
- The field pool to use.recordComponentPool
- The record component pool to use.typeAttributeAppender
- The type attribute appender to apply onto the instrumented type.asmVisitorWrapper
- The ASM visitor wrapper to apply onto the class writer.classFileVersion
- The class file version to use when no explicit class file version is applied.annotationValueFilterFactory
- The annotation value filter factory to apply.annotationRetention
- The annotation retention to apply.auxiliaryTypeNamingStrategy
- The naming strategy for auxiliary types to apply.implementationContextFactory
- The implementation context factory to apply.typeValidation
- Determines if a type should be explicitly validated.classReaderFactory
- The class reader factory to use.classWriterFactory
- The class writer factory to use.typePool
- The type pool to use for computing stack map frames, if required.- Returns:
- A suitable type writer.
-
forRedefinition
public static <U> TypeWriter<U> forRedefinition(MethodRegistry.Prepared methodRegistry, List<? extends DynamicType> auxiliaryTypes, TypeWriter.FieldPool fieldPool, TypeWriter.RecordComponentPool recordComponentPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, AsmClassReader.Factory classReaderFactory, AsmClassWriter.Factory classWriterFactory, TypePool typePool, TypeDescription originalType, ClassFileLocator classFileLocator) Creates a type writer for redefining a type.- Type Parameters:
U
- A loaded type that the instrumented type guarantees to subclass.- Parameters:
methodRegistry
- The compiled method registry to use.auxiliaryTypes
- A list of explicitly required auxiliary types.fieldPool
- The field pool to use.recordComponentPool
- The record component pool to use.typeAttributeAppender
- The type attribute appender to apply onto the instrumented type.asmVisitorWrapper
- The ASM visitor wrapper to apply onto the class writer.classFileVersion
- The class file version to use when no explicit class file version is applied.annotationValueFilterFactory
- The annotation value filter factory to apply.annotationRetention
- The annotation retention to apply.auxiliaryTypeNamingStrategy
- The naming strategy for auxiliary types to apply.implementationContextFactory
- The implementation context factory to apply.typeValidation
- Determines if a type should be explicitly validated.classReaderFactory
- The class reader factory to use.classWriterFactory
- The class writer factory to use.typePool
- The type pool to use for computing stack map frames, if required.originalType
- The original type that is being redefined or rebased.classFileLocator
- The class file locator for locating the original type's class file.- Returns:
- A suitable type writer.
-
forRebasing
public static <U> TypeWriter<U> forRebasing(MethodRegistry.Prepared methodRegistry, List<? extends DynamicType> auxiliaryTypes, TypeWriter.FieldPool fieldPool, TypeWriter.RecordComponentPool recordComponentPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, AsmClassReader.Factory classReaderFactory, AsmClassWriter.Factory classWriterFactory, TypePool typePool, TypeDescription originalType, ClassFileLocator classFileLocator, MethodRebaseResolver methodRebaseResolver) Creates a type writer for rebasing a type.- Type Parameters:
U
- A loaded type that the instrumented type guarantees to subclass.- Parameters:
methodRegistry
- The compiled method registry to use.auxiliaryTypes
- A list of explicitly required auxiliary types.fieldPool
- The field pool to use.recordComponentPool
- The record component pool to use.typeAttributeAppender
- The type attribute appender to apply onto the instrumented type.asmVisitorWrapper
- The ASM visitor wrapper to apply onto the class writer.classFileVersion
- The class file version to use when no explicit class file version is applied.annotationValueFilterFactory
- The annotation value filter factory to apply.annotationRetention
- The annotation retention to apply.auxiliaryTypeNamingStrategy
- The naming strategy for auxiliary types to apply.implementationContextFactory
- The implementation context factory to apply.typeValidation
- Determines if a type should be explicitly validated.classReaderFactory
- The class reader factory to use.classWriterFactory
- The class writer factory to use.typePool
- The type pool to use for computing stack map frames, if required.originalType
- The original type that is being redefined or rebased.classFileLocator
- The class file locator for locating the original type's class file.methodRebaseResolver
- The method rebase resolver to use for rebasing names.- Returns:
- A suitable type writer.
-
forDecoration
public static <U> TypeWriter<U> forDecoration(TypeDescription instrumentedType, ClassFileVersion classFileVersion, List<? extends DynamicType> auxiliaryTypes, List<? extends MethodDescription> methods, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, AsmClassReader.Factory classReaderFactory, AsmClassWriter.Factory classWriterFactory, TypePool typePool, ClassFileLocator classFileLocator) Creates a type writer for decorating a type.- Type Parameters:
U
- A loaded type that the instrumented type guarantees to subclass.- Parameters:
instrumentedType
- The instrumented type.classFileVersion
- The class file version to use when no explicit class file version is applied.auxiliaryTypes
- A list of explicitly required auxiliary types.methods
- The methods to instrument.typeAttributeAppender
- The type attribute appender to apply onto the instrumented type.asmVisitorWrapper
- The ASM visitor wrapper to apply onto the class writer.annotationValueFilterFactory
- The annotation value filter factory to apply.annotationRetention
- The annotation retention to apply.auxiliaryTypeNamingStrategy
- The naming strategy for auxiliary types to apply.implementationContextFactory
- The implementation context factory to apply.typeValidation
- Determines if a type should be explicitly validated.classReaderFactory
- The class reader factory to use.classWriterFactory
- The class writer factory to use.typePool
- The type pool to use for computing stack map frames, if required.classFileLocator
- The class file locator for locating the original type's class file.- Returns:
- A suitable type writer.
-
make
Creates the dynamic type that is described by this type writer.- Specified by:
make
in interfaceTypeWriter<S>
- Parameters:
typeResolutionStrategy
- The type resolution strategy to use.- Returns:
- An unloaded dynamic type that describes the created type.
-
create
protected abstract TypeWriter.Default<S>.UnresolvedType create(TypeInitializer typeInitializer, TypeWriter.Default.ClassDumpAction.Dispatcher dispatcher) Creates an unresolved version of the dynamic type.- Parameters:
typeInitializer
- The type initializer to use.dispatcher
- A dispatcher for dumping class files.- Returns:
- An unresolved type.
-