Package net.bytebuddy.dynamic.scaffold
Class InstrumentedType.Frozen
java.lang.Object
net.bytebuddy.description.ModifierReviewable.AbstractBase
net.bytebuddy.description.TypeVariableSource.AbstractBase
net.bytebuddy.description.type.TypeDescription.AbstractBase
net.bytebuddy.description.type.TypeDescription.AbstractBase.OfSimpleType
net.bytebuddy.dynamic.scaffold.InstrumentedType.Frozen
- All Implemented Interfaces:
Iterable<TypeDefinition>
,AnnotationSource
,ByteCodeElement
,DeclaredByType
,ModifierReviewable
,ModifierReviewable.ForFieldDescription
,ModifierReviewable.ForMethodDescription
,ModifierReviewable.ForParameterDescription
,ModifierReviewable.ForTypeDefinition
,ModifierReviewable.OfAbstraction
,ModifierReviewable.OfByteCodeElement
,ModifierReviewable.OfEnumeration
,NamedElement
,NamedElement.WithDescriptor
,NamedElement.WithRuntimeName
,TypeDefinition
,TypeDescription
,TypeVariableSource
,InstrumentedType
,InstrumentedType.WithFlexibleName
- Enclosing interface:
- InstrumentedType
public static class InstrumentedType.Frozen
extends TypeDescription.AbstractBase.OfSimpleType
implements InstrumentedType.WithFlexibleName
A frozen representation of an instrumented type of which the structure must not be modified.
-
Nested Class Summary
Nested classes/interfaces inherited from class net.bytebuddy.description.type.TypeDescription.AbstractBase.OfSimpleType
TypeDescription.AbstractBase.OfSimpleType.WithDelegation
Nested classes/interfaces inherited from class net.bytebuddy.description.type.TypeDescription.AbstractBase
TypeDescription.AbstractBase.OfSimpleType
Nested classes/interfaces inherited from interface net.bytebuddy.description.annotation.AnnotationSource
AnnotationSource.Empty, AnnotationSource.Explicit
Nested classes/interfaces inherited from interface net.bytebuddy.description.ByteCodeElement
ByteCodeElement.Token<T extends ByteCodeElement.Token<T>>, ByteCodeElement.TypeDependant<T extends ByteCodeElement.TypeDependant<?,
S>, S extends ByteCodeElement.Token<S>> Nested classes/interfaces inherited from interface net.bytebuddy.description.DeclaredByType
DeclaredByType.WithMandatoryDeclaration
Nested classes/interfaces inherited from interface net.bytebuddy.dynamic.scaffold.InstrumentedType
InstrumentedType.Default, InstrumentedType.Factory, InstrumentedType.Frozen, InstrumentedType.Prepareable, InstrumentedType.WithFlexibleName
Nested classes/interfaces inherited from interface net.bytebuddy.description.ModifierReviewable
ModifierReviewable.AbstractBase, ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumeration
Nested classes/interfaces inherited from interface net.bytebuddy.description.NamedElement
NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeName
Nested classes/interfaces inherited from interface net.bytebuddy.description.type.TypeDefinition
TypeDefinition.Sort, TypeDefinition.SuperClassIterator
Nested classes/interfaces inherited from interface net.bytebuddy.description.type.TypeDescription
TypeDescription.AbstractBase, TypeDescription.ArrayProjection, TypeDescription.ForLoadedType, TypeDescription.ForPackageDescription, TypeDescription.Generic, TypeDescription.Latent, TypeDescription.SuperTypeLoading
Nested classes/interfaces inherited from interface net.bytebuddy.description.TypeVariableSource
TypeVariableSource.AbstractBase, TypeVariableSource.Visitor<T>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final LoadedTypeInitializer
The type's loaded type initializer.private final TypeDescription
The represented type description.Fields inherited from class net.bytebuddy.description.type.TypeDescription.AbstractBase
RAW_TYPES
Fields inherited from interface net.bytebuddy.description.ModifierReviewable
EMPTY_MASK
Fields inherited from interface net.bytebuddy.description.NamedElement
EMPTY_NAME, NO_NAME
Fields inherited from interface net.bytebuddy.description.NamedElement.WithDescriptor
NON_GENERIC_SIGNATURE
Fields inherited from interface net.bytebuddy.description.type.TypeDefinition
RAW_TYPES_PROPERTY
Fields inherited from interface net.bytebuddy.description.type.TypeDescription
ARRAY_INTERFACES, CLASS, OBJECT, STRING, THROWABLE, UNDEFINED, VOID
Fields inherited from interface net.bytebuddy.description.TypeVariableSource
UNDEFINED
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
Frozen
(TypeDescription typeDescription, LoadedTypeInitializer loadedTypeInitializer) Creates a new frozen representation of an instrumented type. -
Method Summary
Modifier and TypeMethodDescriptionint
getActualModifiers
(boolean superFlag) Returns the type's actual modifiers as present in the class file.Attempts to resolve the class file version of this type.Returns a list of annotations that are declared by this instance.Returns the fields that this type declares.Returns the methods that this type declares.Returns a list of types that are declared by this type.Returns the declaring type of this instance.Returns a description of the method that encloses this type.Returns a description of this type's enclosing type if any.Returns the generic signature of this byte code element.Returns the interfaces that this type implements.Returns theLoadedTypeInitializer
s that were registered for this instrumented type.int
Returns the modifier that is described by this object.getName()
Returns the binary name of this byte code element.Returns the nest host of this type.Returns a list of members that are part of a nesting group.Returns the package of the type described by this instance ornull
if the described type does not imply a package.Returns the list of permitted direct subclasses if this class is a sealed class.Returns the list of record components that are declared by this type.Returns the super class of this type.Returns this instrumented type's type initializer.Returns the type variables that are declared by this element.boolean
Checks if this type description represents an anonymous type.boolean
Checks if this type description represents a local type.boolean
isRecord()
Checks if this type is a Java record.boolean
isSealed()
Returnstrue
if this class is a sealed class that only permitts a specified range of subclasses.Validates the instrumented type to define a legal Java type.withAnnotations
(List<? extends AnnotationDescription> annotationDescriptions) Creates a new instrumented type with the given annotations.withAnonymousClass
(boolean anonymousClass) Creates a new instrumented type that indicates that it is defined as an anonymous class.withAuxiliaryField
(FieldDescription.Token token, Object value) Creates a new instrumented type that includes a new field.withDeclaredTypes
(TypeList declaredTypes) Creates a new instrumented type that indicates that it declared the supplied types.withDeclaringType
(TypeDescription declaringType) Creates a new instrumented type that is declared by the supplied type.withEnclosingMethod
(MethodDescription.InDefinedShape enclosingMethod) Creates a new instrumented type with the supplied enclosing method.withEnclosingType
(TypeDescription enclosingType) Creates a new instrumented type with the supplied enclosing type.withField
(FieldDescription.Token token) Creates a new instrumented type that includes a new field.withInitializer
(ByteCodeAppender byteCodeAppender) Creates a new instrumented type that executes the given initializer in the instrumented type's type initializer.withInitializer
(LoadedTypeInitializer loadedTypeInitializer) Creates a new instrumented type that includes the givenLoadedTypeInitializer
.withInterfaces
(TypeList.Generic interfaceTypes) Creates a new instrumented type with the given interfaces implemented.withLocalClass
(boolean localClass) Creates a new instrumented type that indicates that is defined as a local class.Creates a new instrumented type that includes a new method or constructor.withModifiers
(int modifiers) Creates a new instrumented type with changed modifiers.Creates a new instrumented type with a changed name.withNestHost
(TypeDescription nestHost) Creates a new instrumented type with the supplied nest host.withNestMembers
(TypeList nestMembers) Creates a new instrumented types with the supplied nest members added to this instrumented type.withPermittedSubclasses
(TypeList permittedSubclasses) Creates a new instrumented type that includes the supplied permitted subclasses or unseals the type.withRecord
(boolean record) Creates a new instrumented type that indicates that it defined as a record type.Creates a new instrumented type that includes a new record component.withTypeVariable
(TypeVariableToken typeVariable) Creates a new instrumented type with the given type variable defined.withTypeVariables
(ElementMatcher<? super TypeDescription.Generic> matcher, Transformer<TypeVariableToken> transformer) Applies a transformation onto all existing type variables of this instrumented type.Methods inherited from class net.bytebuddy.description.type.TypeDescription.AbstractBase.OfSimpleType
getCanonicalName, getComponentType, getDescriptor, getSimpleName, getStackSize, isArray, isPrimitive
Methods inherited from class net.bytebuddy.description.type.TypeDescription.AbstractBase
accept, asBoxed, asErasure, asGenericType, asUnboxed, equals, getActualName, getDefaultValue, getEnclosingSource, getInheritedAnnotations, getInnerClassCount, getInternalName, getLongSimpleName, getSort, getTypeName, hashCode, isAccessibleTo, isAnnotationReturnType, isAnnotationValue, isAnnotationValue, isAssignableFrom, isAssignableFrom, isAssignableTo, isAssignableTo, isCompileTimeConstant, isGenerified, isInferrable, isInHierarchyWith, isInHierarchyWith, isInnerClass, isInstance, isMemberType, isNestedClass, isNestHost, isNestMateOf, isNestMateOf, isPackageType, isPrimitiveWrapper, isSamePackage, isVisibleTo, iterator, represents, toString
Methods inherited from class net.bytebuddy.description.TypeVariableSource.AbstractBase
findExpectedVariable, findVariable
Methods inherited from class net.bytebuddy.description.ModifierReviewable.AbstractBase
getEnumerationState, getFieldManifestation, getFieldPersistence, getMethodManifestation, getMethodStrictness, getOwnership, getParameterManifestation, getProvisioningState, getSynchronizationState, getSyntheticState, getTypeManifestation, getVisibility, isAbstract, isAnnotation, isBridge, isDeprecated, isEnum, isFinal, isInterface, isMandated, isNative, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isStrict, isSynchronized, isSynthetic, isTransient, isVarArgs, isVolatile
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.bytebuddy.description.ByteCodeElement
isAccessibleTo, isVisibleTo
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface net.bytebuddy.description.ModifierReviewable
getSyntheticState, isFinal, isSynthetic
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.ForTypeDefinition
getTypeManifestation, isAnnotation, isInterface
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.OfAbstraction
isAbstract
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.OfByteCodeElement
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic
Methods inherited from interface net.bytebuddy.description.ModifierReviewable.OfEnumeration
getEnumerationState, isEnum
Methods inherited from interface net.bytebuddy.description.NamedElement
getActualName
Methods inherited from interface net.bytebuddy.description.NamedElement.WithDescriptor
getDescriptor
Methods inherited from interface net.bytebuddy.description.NamedElement.WithRuntimeName
getInternalName
Methods inherited from interface net.bytebuddy.description.type.TypeDefinition
asErasure, asGenericType, getSort, getStackSize, getTypeName, isArray, isPrimitive, represents
Methods inherited from interface net.bytebuddy.description.type.TypeDescription
asBoxed, asUnboxed, getCanonicalName, getComponentType, getDefaultValue, getInheritedAnnotations, getInnerClassCount, getLongSimpleName, getSimpleName, isAnnotationReturnType, isAnnotationValue, isAnnotationValue, isAssignableFrom, isAssignableFrom, isAssignableTo, isAssignableTo, isCompileTimeConstant, isInHierarchyWith, isInHierarchyWith, isInnerClass, isInstance, isMemberType, isNestedClass, isNestHost, isNestMateOf, isNestMateOf, isPackageType, isPrimitiveWrapper, isSamePackage
Methods inherited from interface net.bytebuddy.description.TypeVariableSource
accept, findExpectedVariable, findVariable, getEnclosingSource, isGenerified, isInferrable
-
Field Details
-
typeDescription
The represented type description. -
loadedTypeInitializer
The type's loaded type initializer.
-
-
Constructor Details
-
Frozen
Creates a new frozen representation of an instrumented type.- Parameters:
typeDescription
- The represented type description.loadedTypeInitializer
- The type's loaded type initializer.
-
-
Method Details
-
getDeclaredAnnotations
Returns a list of annotations that are declared by this instance.- Specified by:
getDeclaredAnnotations
in interfaceAnnotationSource
- Returns:
- A list of declared annotations.
-
getModifiers
public int getModifiers()Returns the modifier that is described by this object.- Specified by:
getModifiers
in interfaceModifierReviewable
- Returns:
- The modifier that is described by this object.
-
getTypeVariables
Returns the type variables that are declared by this element.- Specified by:
getTypeVariables
in interfaceTypeVariableSource
- Returns:
- The type variables that are declared by this element.
-
getName
Returns the binary name of this byte code element. If no well-defined internal name is known for this element, the actual name is returned.- Specified by:
getName
in interfaceNamedElement.WithRuntimeName
- Returns:
- The binary ame of this byte code element as visible from within a running Java application.
-
getSuperClass
Returns the super class of this type. A super type is only defined for non-generic types (TypeDefinition.Sort.NON_GENERIC
), parameterized types (TypeDefinition.Sort.PARAMETERIZED
) or generic array types (TypeDefinition.Sort.GENERIC_ARRAY
) types. Interface types and theObject
class do not define a super class wherenull
is returned. Array types defineObject
as their direct super class.- Specified by:
getSuperClass
in interfaceTypeDefinition
- Returns:
- The super class of this type or
null
if no super class exists for this type.
-
getInterfaces
Returns the interfaces that this type implements. A super type is only defined for non-generic types (TypeDefinition.Sort.NON_GENERIC
), parameterized types (TypeDefinition.Sort.PARAMETERIZED
) or generic array types (TypeDefinition.Sort.GENERIC_ARRAY
) types.- Specified by:
getInterfaces
in interfaceTypeDefinition
- Returns:
- The interfaces that this type implements.
-
getDeclaredFields
Returns the fields that this type declares. A super type is only defined for non-generic types (TypeDefinition.Sort.NON_GENERIC
), parameterized types (TypeDefinition.Sort.PARAMETERIZED
) or generic array types (TypeDefinition.Sort.GENERIC_ARRAY
) types. Generic array types never define fields and the returned list is always empty for such types.- Specified by:
getDeclaredFields
in interfaceTypeDefinition
- Specified by:
getDeclaredFields
in interfaceTypeDescription
- Returns:
- The fields that this type declares. A super type is only defined for non-generic types (
TypeDefinition.Sort.NON_GENERIC
), parameterized types (TypeDefinition.Sort.PARAMETERIZED
) or generic array types (TypeDefinition.Sort.GENERIC_ARRAY
) types. Generic array types never define methods and the returned list is always empty for such types.
-
getDeclaredMethods
Returns the methods that this type declares.- Specified by:
getDeclaredMethods
in interfaceTypeDefinition
- Specified by:
getDeclaredMethods
in interfaceTypeDescription
- Returns:
- The methods that this type declares.
-
isAnonymousType
public boolean isAnonymousType()Checks if this type description represents an anonymous type.- Specified by:
isAnonymousType
in interfaceTypeDescription
- Returns:
true
if this type description represents an anonymous type.
-
isLocalType
public boolean isLocalType()Checks if this type description represents a local type.- Specified by:
isLocalType
in interfaceTypeDescription
- Returns:
true
if this type description represents a local type.
-
getPackage
Returns the package of the type described by this instance ornull
if the described type does not imply a package.- Specified by:
getPackage
in interfaceTypeDescription
- Returns:
- The package of the type described by this instance or
null
if the described type does not imply a package.
-
getEnclosingType
Returns a description of this type's enclosing type if any.- Specified by:
getEnclosingType
in interfaceTypeDescription
- Returns:
- A description of the enclosing type of this type or
null
if there is no such type.
-
getDeclaringType
Returns the declaring type of this instance.- Specified by:
getDeclaringType
in interfaceDeclaredByType
- Specified by:
getDeclaringType
in interfaceTypeDescription
- Returns:
- The declaring type or
null
if no such type exists.
-
getDeclaredTypes
Returns a list of types that are declared by this type. This list does not normally include anonymous types but might include additional types if they are explicitly added to an instrumented type.- Specified by:
getDeclaredTypes
in interfaceTypeDescription
- Returns:
- A list of types that are declared within this type.
-
getEnclosingMethod
Returns a description of the method that encloses this type. If this method is not enclosed by any type or is enclosed by the type initializer,null
is returned by this method.- Specified by:
getEnclosingMethod
in interfaceTypeDescription
- Returns:
- A description of the enclosing method of this type or
null
if there is no such method.
-
getGenericSignature
Returns the generic signature of this byte code element. If this element does not reference generic types or references malformed generic types,null
is returned as a signature.- Specified by:
getGenericSignature
in interfaceNamedElement.WithDescriptor
- Overrides:
getGenericSignature
in classTypeDescription.AbstractBase
- Returns:
- The generic signature or
null
if this element is not generic.
-
getActualModifiers
public int getActualModifiers(boolean superFlag) Returns the type's actual modifiers as present in the class file. For example, a type cannot beprivate
. but it modifiers might reflect this property nevertheless if a class was defined as a private inner class. The returned modifiers take also into account if the type is marked asDeprecated
. Anonymous classes that are enclosed in a static method or the type initializer are additionally marked asfinal
as it is also done by the Java compiler.- Specified by:
getActualModifiers
in interfaceTypeDescription
- Overrides:
getActualModifiers
in classTypeDescription.AbstractBase
- Parameters:
superFlag
-true
if the modifier's super flag should be set.- Returns:
- The type's actual modifiers.
-
getNestHost
Returns the nest host of this type. For types prior to Java 11, this type is returned which is the default nest host.- Specified by:
getNestHost
in interfaceTypeDescription
- Returns:
- The nest host of this type.
-
getNestMembers
Returns a list of members that are part of a nesting group. Prior to Java 11, a list that only contains this type is returned which is the default nest group.- Specified by:
getNestMembers
in interfaceTypeDescription
- Returns:
- A list of members of this nest group.
-
getRecordComponents
Returns the list of record components that are declared by this type. If this type is not a record, the returned list is empty.- Specified by:
getRecordComponents
in interfaceTypeDefinition
- Specified by:
getRecordComponents
in interfaceTypeDescription
- Returns:
- A list of record components that this type declares.
-
isRecord
public boolean isRecord()Checks if this type is a Java record.- Specified by:
isRecord
in interfaceTypeDefinition
- Returns:
true
if this type is a Java record.
-
isSealed
public boolean isSealed()Description copied from class:TypeDescription.AbstractBase
Returnstrue
if this class is a sealed class that only permitts a specified range of subclasses.- Specified by:
isSealed
in interfaceTypeDescription
- Overrides:
isSealed
in classTypeDescription.AbstractBase
- Returns:
true
if this class is a sealed class that only permitts a specified range of subclasses.
-
getPermittedSubtypes
Returns the list of permitted direct subclasses if this class is a sealed class. Permitted subclasses might or might not be resolvable, where unresolvable subclasses might also be missing from the list. For returned types, methods that return the class's name will always be invokable without errors. If this type is not sealed, an empty list is returned. Note that an empty list might also be returned for a sealed type, if no type permitted subtype is resolvable.- Specified by:
getPermittedSubtypes
in interfaceTypeDescription
- Returns:
- The list of permitted subtypes or an empty list if this type is not sealed.
-
withField
Creates a new instrumented type that includes a new field.- Specified by:
withField
in interfaceInstrumentedType
- Specified by:
withField
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
token
- A token that represents the field's shape.- Returns:
- A new instrumented type that is equal to this instrumented type but with the additional field.
-
withAuxiliaryField
public InstrumentedType.WithFlexibleName withAuxiliaryField(FieldDescription.Token token, Object value) Creates a new instrumented type that includes a new field.- Specified by:
withAuxiliaryField
in interfaceInstrumentedType
- Specified by:
withAuxiliaryField
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
token
- A token that represents the field's shape.value
- The value that this assigned to this field.- Returns:
- A new instrumented type that is equal to this instrumented type but with the additional field.
-
withMethod
Creates a new instrumented type that includes a new method or constructor.- Specified by:
withMethod
in interfaceInstrumentedType
- Specified by:
withMethod
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
token
- A token that represents the method's shape.- Returns:
- A new instrumented type that is equal to this instrumented type but with the additional method.
-
withRecordComponent
public InstrumentedType.WithFlexibleName withRecordComponent(RecordComponentDescription.Token token) Creates a new instrumented type that includes a new record component.- Specified by:
withRecordComponent
in interfaceInstrumentedType
- Specified by:
withRecordComponent
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
token
- A token that represents the record component's shape.- Returns:
- A new instrumented type that is equal to this instrumented type but with the additional record component.
-
withModifiers
Creates a new instrumented type with changed modifiers.- Specified by:
withModifiers
in interfaceInstrumentedType
- Specified by:
withModifiers
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
modifiers
- The instrumented type's modifiers.- Returns:
- A new instrumented type that is equal to this instrumented type but with the given modifiers.
-
withInterfaces
Creates a new instrumented type with the given interfaces implemented.- Specified by:
withInterfaces
in interfaceInstrumentedType
- Specified by:
withInterfaces
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
interfaceTypes
- The interface types to implement.- Returns:
- A new instrumented type that is equal to this instrumented type but with the given interfaces implemented.
-
withTypeVariable
Creates a new instrumented type with the given type variable defined.- Specified by:
withTypeVariable
in interfaceInstrumentedType
- Specified by:
withTypeVariable
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
typeVariable
- The type variable to declare.- Returns:
- A new instrumented type that is equal to this instrumented type but with the given type variable declared.
-
withAnnotations
public InstrumentedType.WithFlexibleName withAnnotations(List<? extends AnnotationDescription> annotationDescriptions) Creates a new instrumented type with the given annotations.- Specified by:
withAnnotations
in interfaceInstrumentedType
- Specified by:
withAnnotations
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
annotationDescriptions
- The annotations to add to the instrumented type.- Returns:
- A new instrumented type that is equal to this instrumented type but annotated with the given annotations
-
withNestHost
Creates a new instrumented type with the supplied nest host. An instrumented type can be its own nest host. Setting a nest host removes all nest members from the instrumented type.- Specified by:
withNestHost
in interfaceInstrumentedType
- Specified by:
withNestHost
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
nestHost
- The nest host of the created instrumented type.- Returns:
- A new instrumented type with the supplied type as its nest host.
-
withNestMembers
Creates a new instrumented types with the supplied nest members added to this instrumented type. The instrumented type is defined as a nest host if this method is invoked. Any previous nest members are prepended to the supplied types.- Specified by:
withNestMembers
in interfaceInstrumentedType
- Specified by:
withNestMembers
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
nestMembers
- The nest members to add to the created instrumented type.- Returns:
- A new instrumented type that applies the supplied nest members.
-
withEnclosingType
public InstrumentedType.WithFlexibleName withEnclosingType(@MaybeNull TypeDescription enclosingType) Creates a new instrumented type with the supplied enclosing type.- Specified by:
withEnclosingType
in interfaceInstrumentedType
- Specified by:
withEnclosingType
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
enclosingType
- The type to define as the created instrumented type's enclosing type.- Returns:
- A new instrumented type with the supplied type as its enclosing type.
-
withEnclosingMethod
public InstrumentedType.WithFlexibleName withEnclosingMethod(MethodDescription.InDefinedShape enclosingMethod) Creates a new instrumented type with the supplied enclosing method.- Specified by:
withEnclosingMethod
in interfaceInstrumentedType
- Specified by:
withEnclosingMethod
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
enclosingMethod
- The method to define as the created instrumented type's enclosing method.- Returns:
- A new instrumented type with the supplied method as its enclosing method.
-
withDeclaringType
public InstrumentedType.WithFlexibleName withDeclaringType(@MaybeNull TypeDescription declaringType) Creates a new instrumented type that is declared by the supplied type.- Specified by:
withDeclaringType
in interfaceInstrumentedType
- Specified by:
withDeclaringType
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
declaringType
- The type that declares the instrumented type ornull
if no such type exists.- Returns:
- A new instrumented type that is declared by the instrumented type.
-
withDeclaredTypes
Creates a new instrumented type that indicates that it declared the supplied types.- Specified by:
withDeclaredTypes
in interfaceInstrumentedType
- Specified by:
withDeclaredTypes
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
declaredTypes
- The types to add to the created instrumented type as declared types.- Returns:
- A new instrumented type that indicates that it has declared the supplied types.
-
withPermittedSubclasses
public InstrumentedType.WithFlexibleName withPermittedSubclasses(@MaybeNull TypeList permittedSubclasses) Creates a new instrumented type that includes the supplied permitted subclasses or unseals the type.- Specified by:
withPermittedSubclasses
in interfaceInstrumentedType
- Specified by:
withPermittedSubclasses
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
permittedSubclasses
- A list of permitted subclasses to include ornull
to unseal the type.- Returns:
- A new instrumented type that includes the supplied permitted subclasses or unseals the type.
-
withLocalClass
Creates a new instrumented type that indicates that is defined as a local class. Setting this property resets the anonymous class property.- Specified by:
withLocalClass
in interfaceInstrumentedType
- Specified by:
withLocalClass
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
localClass
-true
if the instrumented type is supposed to be treated as a local class.- Returns:
- A new instrumented type that is treated as a local class.
-
withAnonymousClass
Creates a new instrumented type that indicates that it is defined as an anonymous class. Setting this property resets the local class property.- Specified by:
withAnonymousClass
in interfaceInstrumentedType
- Specified by:
withAnonymousClass
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
anonymousClass
-true
if the instrumented type is supposed to be treated as an anonymous class.- Returns:
- A new instrumented type that is treated as an anonymous class.
-
withRecord
Creates a new instrumented type that indicates that it defined as a record type. Setting this property to false removes all record components.- Specified by:
withRecord
in interfaceInstrumentedType
- Specified by:
withRecord
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
record
-true
if the instrumented type is supposed to be a record.- Returns:
- A new instrumented type that is defined as a record.
-
withInitializer
public InstrumentedType.WithFlexibleName withInitializer(LoadedTypeInitializer loadedTypeInitializer) Creates a new instrumented type that includes the givenLoadedTypeInitializer
.- Specified by:
withInitializer
in interfaceInstrumentedType
- Specified by:
withInitializer
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
loadedTypeInitializer
- The type initializer to include.- Returns:
- A new instrumented type that is equal to this instrumented type but with the additional type initializer.
-
withInitializer
Creates a new instrumented type that executes the given initializer in the instrumented type's type initializer.- Specified by:
withInitializer
in interfaceInstrumentedType
- Specified by:
withInitializer
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
byteCodeAppender
- The byte code to add to the type initializer.- Returns:
- A new instrumented type that is equal to this instrumented type but with the given stack manipulation attached to its type initializer.
-
withName
Creates a new instrumented type with a changed name.- Specified by:
withName
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
name
- The name of the instrumented type.- Returns:
- A new instrumented type that has the given name.
-
withTypeVariables
public InstrumentedType.WithFlexibleName withTypeVariables(ElementMatcher<? super TypeDescription.Generic> matcher, Transformer<TypeVariableToken> transformer) Applies a transformation onto all existing type variables of this instrumented type. A transformation is potentially unsafe and it is the responsibility of the supplier to return a valid type variable token from the transformer.- Specified by:
withTypeVariables
in interfaceInstrumentedType.WithFlexibleName
- Parameters:
matcher
- The matcher to decide what type variables to transform.transformer
- The transformer to apply on all matched type variables.- Returns:
- A new instrumented type with all matched type variables transformed.
-
getLoadedTypeInitializer
Returns theLoadedTypeInitializer
s that were registered for this instrumented type.- Specified by:
getLoadedTypeInitializer
in interfaceInstrumentedType
- Returns:
- The registered loaded type initializers for this instrumented type.
-
getTypeInitializer
Returns this instrumented type's type initializer.- Specified by:
getTypeInitializer
in interfaceInstrumentedType
- Returns:
- This instrumented type's type initializer.
-
getClassFileVersion
Description copied from class:TypeDescription.AbstractBase
Attempts to resolve the class file version of this type. If this description is not based on a class file or if the class file version cannot be resolved,null
is returned.- Specified by:
getClassFileVersion
in interfaceTypeDescription
- Overrides:
getClassFileVersion
in classTypeDescription.AbstractBase
- Returns:
- This type's class file version or
null
if it cannot be resolved.
-
validated
Validates the instrumented type to define a legal Java type.- Specified by:
validated
in interfaceInstrumentedType
- Returns:
- This instrumented type as a non-modifiable type description.
-