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>
public abstract static class TypeWriter.Default<S> extends java.lang.Object implements TypeWriter<S>
A default implementation of aTypeWriter
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
TypeWriter.Default.ClassDumpAction
An action to write a class file to the dumping location.static class
TypeWriter.Default.ForCreation<U>
A type writer that creates a class file that is not based upon another, existing class.static class
TypeWriter.Default.ForInlining<U>
A type writer that inlines the created type into an existing class file.protected static class
TypeWriter.Default.FrameComputingClassWriter
A class writer that piggy-backs on Byte Buddy'sClassFileLocator
to avoid class loading or look-up errors when redefining a class.protected class
TypeWriter.Default.UnresolvedType
An unresolved type.protected static class
TypeWriter.Default.ValidatingClassVisitor
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
-
-
Field Summary
Fields Modifier and Type Field Description protected AnnotationRetention
annotationRetention
The annotation retention to apply.protected AnnotationValueFilter.Factory
annotationValueFilterFactory
The annotation value filter factory to apply.protected AsmVisitorWrapper
asmVisitorWrapper
The ASM visitor wrapper to apply onto the class writer.protected AuxiliaryType.NamingStrategy
auxiliaryTypeNamingStrategy
The naming strategy for auxiliary types to apply.protected java.util.List<? extends DynamicType>
auxiliaryTypes
The explicit auxiliary types to add to the created type.protected ClassFileVersion
classFileVersion
The class file specified by the user.protected TypeWriter.FieldPool
fieldPool
The field pool to use.protected FieldList<FieldDescription.InDefinedShape>
fields
The instrumented type's declared fields.protected Implementation.Context.Factory
implementationContextFactory
The implementation context factory to apply.protected MethodList<?>
instrumentedMethods
The instrumented methods relevant to this type creation.protected TypeDescription
instrumentedType
The instrumented type to be created.protected LoadedTypeInitializer
loadedTypeInitializer
The loaded type initializer to apply onto the created type after loading.protected MethodList<?>
methods
The instrumented type's methods that are declared or inherited.protected TypeAttributeAppender
typeAttributeAppender
The type attribute appender to apply onto the instrumented type.protected TypeInitializer
typeInitializer
The type initializer to include in the created type's type initializer.protected TypePool
typePool
The type pool to use for computing stack map frames, if required.protected TypeValidation
typeValidation
Determines if a type should be explicitly validated.-
Fields inherited from interface net.bytebuddy.dynamic.scaffold.TypeWriter
DUMP_PROPERTY
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Default(TypeDescription instrumentedType, ClassFileVersion classFileVersion, TypeWriter.FieldPool fieldPool, java.util.List<? extends DynamicType> auxiliaryTypes, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, MethodList<?> instrumentedMethods, LoadedTypeInitializer loadedTypeInitializer, TypeInitializer typeInitializer, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, TypePool typePool)
Creates a new default type writer.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract TypeWriter.Default.UnresolvedType
create(TypeInitializer typeInitializer)
Creates an unresolved version of the dynamic type.static <U> TypeWriter<U>
forCreation(MethodRegistry.Compiled methodRegistry, TypeWriter.FieldPool fieldPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, TypePool typePool)
Creates a type writer for creating a new type.static <U> TypeWriter<U>
forRebasing(MethodRegistry.Prepared methodRegistry, TypeWriter.FieldPool fieldPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, TypePool typePool, TypeDescription originalType, ClassFileLocator classFileLocator, MethodRebaseResolver methodRebaseResolver)
Creates a type writer for rebasing a type.static <U> TypeWriter<U>
forRedefinition(MethodRegistry.Prepared methodRegistry, TypeWriter.FieldPool fieldPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, TypePool typePool, TypeDescription originalType, ClassFileLocator classFileLocator)
Creates a type writer for redefining a type.DynamicType.Unloaded<S>
make(TypeResolutionStrategy.Resolved typeResolutionStrategy)
Creates the dynamic type that is described by this type writer.
-
-
-
Field Detail
-
instrumentedType
protected final TypeDescription instrumentedType
The instrumented type to be created.
-
classFileVersion
protected final ClassFileVersion classFileVersion
The class file specified by the user.
-
fieldPool
protected final TypeWriter.FieldPool fieldPool
The field pool to use.
-
auxiliaryTypes
protected final java.util.List<? extends DynamicType> auxiliaryTypes
The explicit auxiliary types to add to the created type.
-
fields
protected final FieldList<FieldDescription.InDefinedShape> fields
The instrumented type's declared fields.
-
methods
protected final MethodList<?> methods
The instrumented type's methods that are declared or inherited.
-
instrumentedMethods
protected final MethodList<?> instrumentedMethods
The instrumented methods relevant to this type creation.
-
loadedTypeInitializer
protected final LoadedTypeInitializer loadedTypeInitializer
The loaded type initializer to apply onto the created type after loading.
-
typeInitializer
protected final TypeInitializer typeInitializer
The type initializer to include in the created type's type initializer.
-
typeAttributeAppender
protected final TypeAttributeAppender typeAttributeAppender
The type attribute appender to apply onto the instrumented type.
-
asmVisitorWrapper
protected final AsmVisitorWrapper asmVisitorWrapper
The ASM visitor wrapper to apply onto the class writer.
-
annotationValueFilterFactory
protected final AnnotationValueFilter.Factory annotationValueFilterFactory
The annotation value filter factory to apply.
-
annotationRetention
protected final AnnotationRetention annotationRetention
The annotation retention to apply.
-
auxiliaryTypeNamingStrategy
protected final AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy
The naming strategy for auxiliary types to apply.
-
implementationContextFactory
protected final Implementation.Context.Factory implementationContextFactory
The implementation context factory to apply.
-
typeValidation
protected final TypeValidation typeValidation
Determines if a type should be explicitly validated.
-
typePool
protected final TypePool typePool
The type pool to use for computing stack map frames, if required.
-
-
Constructor Detail
-
Default
protected Default(TypeDescription instrumentedType, ClassFileVersion classFileVersion, TypeWriter.FieldPool fieldPool, java.util.List<? extends DynamicType> auxiliaryTypes, FieldList<FieldDescription.InDefinedShape> fields, MethodList<?> methods, MethodList<?> instrumentedMethods, LoadedTypeInitializer loadedTypeInitializer, TypeInitializer typeInitializer, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, 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.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.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.typePool
- The type pool to use for computing stack map frames, if required.
-
-
Method Detail
-
forCreation
public static <U> TypeWriter<U> forCreation(MethodRegistry.Compiled methodRegistry, TypeWriter.FieldPool fieldPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, 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.fieldPool
- The field 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.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, TypeWriter.FieldPool fieldPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, 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.fieldPool
- The field 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.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, TypeWriter.FieldPool fieldPool, TypeAttributeAppender typeAttributeAppender, AsmVisitorWrapper asmVisitorWrapper, ClassFileVersion classFileVersion, AnnotationValueFilter.Factory annotationValueFilterFactory, AnnotationRetention annotationRetention, AuxiliaryType.NamingStrategy auxiliaryTypeNamingStrategy, Implementation.Context.Factory implementationContextFactory, TypeValidation typeValidation, 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.fieldPool
- The field 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.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.
-
make
public DynamicType.Unloaded<S> make(TypeResolutionStrategy.Resolved typeResolutionStrategy)
Description copied from interface:TypeWriter
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.UnresolvedType create(TypeInitializer typeInitializer)
Creates an unresolved version of the dynamic type.- Parameters:
typeInitializer
- The type initializer to use.- Returns:
- An unresolved type.
-
-