Class InstrumentedType.Default
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.Default
- All Implemented Interfaces:
Iterable<TypeDefinition>, AnnotationSource, ByteCodeElement, DeclaredByType, ModifierReviewable, ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForModuleDescription, ModifierReviewable.ForModuleRequirement, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumeration, ModifierReviewable.OfMandatable, NamedElement, NamedElement.WithDescriptor, NamedElement.WithRuntimeName, TypeDefinition, TypeDescription, TypeVariableSource, InstrumentedType, InstrumentedType.WithFlexibleName
- Enclosing interface:
InstrumentedType
public static class InstrumentedType.Default
extends TypeDescription.AbstractBase.OfSimpleType
implements InstrumentedType.WithFlexibleName
A default implementation of an instrumented type.
-
Nested Class Summary
Nested classes/interfaces inherited from class TypeDescription.AbstractBase.OfSimpleType
TypeDescription.AbstractBase.OfSimpleType.WithDelegationNested classes/interfaces inherited from class TypeDescription.AbstractBase
TypeDescription.AbstractBase.OfSimpleTypeNested classes/interfaces inherited from interface AnnotationSource
AnnotationSource.Empty, AnnotationSource.ExplicitNested classes/interfaces inherited from interface ByteCodeElement
ByteCodeElement.Member, ByteCodeElement.Token<T>, ByteCodeElement.TypeDependant<T,S> Nested classes/interfaces inherited from interface DeclaredByType
DeclaredByType.WithMandatoryDeclarationNested classes/interfaces inherited from interface InstrumentedType
InstrumentedType.Default, InstrumentedType.Factory, InstrumentedType.Frozen, InstrumentedType.Prepareable, InstrumentedType.WithFlexibleNameNested classes/interfaces inherited from interface ModifierReviewable
ModifierReviewable.AbstractBase, ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForModuleDescription, ModifierReviewable.ForModuleRequirement, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumeration, ModifierReviewable.OfMandatableNested classes/interfaces inherited from interface NamedElement
NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeNameNested classes/interfaces inherited from interface TypeDefinition
TypeDefinition.Sort, TypeDefinition.SuperClassIteratorNested classes/interfaces inherited from interface TypeDescription
TypeDescription.AbstractBase, TypeDescription.ArrayProjection, TypeDescription.ForLoadedType, TypeDescription.ForPackageDescription, TypeDescription.Generic, TypeDescription.Latent, TypeDescription.LazyProxy, TypeDescription.SuperTypeLoadingNested classes/interfaces inherited from interface TypeVariableSource
TypeVariableSource.AbstractBase, TypeVariableSource.Visitor<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<? extends AnnotationDescription> A list of annotations of the annotated type.private final booleantrueif this type is an anonymous class.A mapping of auxiliary field names to their mapped values.private final List<? extends TypeDescription> A list of types that are declared by this type.private final TypeDescriptionThe declaring type of the instrumented type ornullif no such type exists.private final MethodDescription.InDefinedShapeThe enclosing method of the instrumented type ornullif no such type exists.private final TypeDescriptionThe enclosing type of the instrumented type ornullif no such type exists.private final List<? extends FieldDescription.Token> A list of field tokens describing the fields of the instrumented type.private final List<? extends TypeDescription.Generic> A list of interfaces of the instrumented type.A set containing all keywords of the Java programming language.private final LoadedTypeInitializerThe loaded type initializer of the instrumented type.private final booleantrueif this type is a local class.private final List<? extends MethodDescription.Token> A list of method tokens describing the methods of the instrumented type.private final intThe modifiers of the instrumented type.private final ModuleDescriptionThe module metadata that this type implies ornull.private final StringThe binary name of the instrumented type.private final TypeDescriptionThe nest host of this instrumented type or a description ofTargetTypeif this type is its own nest host.private final List<? extends TypeDescription> A list of all members of this types nest group excluding this type.private final List<? extends TypeDescription> A list of permitted subclasses ornullif this type is not sealed.private final booleantrueif this class is a record class.private final List<? extends RecordComponentDescription.Token> A list of record component tokens describing the record components of the instrumented type.private final TypeDescription.GenericThe generic super type of the instrumented type.private final TypeInitializerThe type initializer of the instrumented type.private final List<? extends TypeVariableToken> The instrumented type's type variables in their tokenized form.Fields inherited from class TypeDescription.AbstractBase
RAW_TYPESFields inherited from interface ModifierReviewable
EMPTY_MASKFields inherited from interface NamedElement
EMPTY_NAME, NO_NAMEFields inherited from interface NamedElement.WithDescriptor
NON_GENERIC_SIGNATUREFields inherited from interface TypeDefinition
RAW_TYPES_PROPERTYFields inherited from interface TypeDescription
ARRAY_INTERFACES, CLASS, OBJECT, STRING, THROWABLE, UNDEFINED, VOIDFields inherited from interface TypeVariableSource
UNDEFINED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDefault(String name, int modifiers, ModuleDescription moduleDescription, List<? extends TypeVariableToken> typeVariables, TypeDescription.Generic superClass, List<? extends TypeDescription.Generic> interfaceTypes, List<? extends FieldDescription.Token> fieldTokens, Map<String, Object> auxiliaryFieldValues, List<? extends MethodDescription.Token> methodTokens, List<? extends RecordComponentDescription.Token> recordComponentTokens, List<? extends AnnotationDescription> annotationDescriptions, TypeInitializer typeInitializer, LoadedTypeInitializer loadedTypeInitializer, TypeDescription declaringType, MethodDescription.InDefinedShape enclosingMethod, TypeDescription enclosingType, List<? extends TypeDescription> declaredTypes, List<? extends TypeDescription> permittedSubclasses, boolean anonymousClass, boolean localClass, boolean record, TypeDescription nestHost, List<? extends TypeDescription> nestMembers) Creates a new instrumented type. -
Method Summary
Modifier and TypeMethodDescriptionReturns 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 interfaces that this type implements.Returns theLoadedTypeInitializers that were registered for this instrumented type.intReturns 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 ornullif the described type is a primitive type or an array.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.booleanChecks if this type description represents an anonymous type.booleanChecks if this type description represents a local type.booleanisRecord()Checks if this type is a Java record.booleanisSealed()Returnstrueif this class is a sealed class that only permitts a specified range of subclasses.private static booleanisValidIdentifier(String identifier) Checks if a Java identifier is valid.private static booleanisValidIdentifier(String[] identifier) Checks if an array of identifiers is a valid compound Java identifier.private static booleanisValidMethodIdentifier(String identifier) Checks if an identifier is a valid "Unqualified Name" for a method, per JVMS 4.2.2.private static booleanisValidUnqualifiedNameIdentifier(String identifier) Checks if an identifier is a valid "Unqualified Name" for a field, a local variable or a formal parameter, per JVMS 4.2.2.static InstrumentedTypeof(String name, TypeDescription.Generic superClass, int modifiers) Creates a new instrumented type.static InstrumentedTypeof(String name, TypeDescription.Generic superClass, ModifierContributor.ForType... modifierContributor) Creates a new instrumented type.Returns a representation of a Java module that is represented by this type description, normally amodule-info.classfile.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.withModuleDescription(ModuleDescription moduleDescription) Creates a new instrumented type that defines the provided module metadata or no such metadata ifnullis provided.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 TypeDescription.AbstractBase.OfSimpleType
getCanonicalName, getComponentType, getDescriptor, getSimpleName, getStackSize, isArray, isPrimitiveMethods inherited from class TypeDescription.AbstractBase
accept, asBoxed, asErasure, asGenericType, asUnboxed, equals, getActualModifiers, getActualName, getClassFileVersion, getDefaultValue, getEnclosingSource, getGenericSignature, getInheritedAnnotations, getInnerClassCount, getInternalName, getLongSimpleName, getSort, getTypeName, hashCode, isAccessibleTo, isAnnotationReturnType, isAnnotationValue, isAnnotationValue, isAssignableFrom, isAssignableFrom, isAssignableTo, isAssignableTo, isCompileTimeConstant, isGenerified, isInferrable, isInHierarchyWith, isInHierarchyWith, isInnerClass, isInstance, isMemberType, isModuleType, isNestedClass, isNestHost, isNestMateOf, isNestMateOf, isPackageType, isPrimitiveWrapper, isSamePackage, isVisibleTo, iterator, represents, toSafeString, toStringMethods inherited from class TypeVariableSource.AbstractBase
findExpectedVariable, findVariableMethods inherited from class ModifierReviewable.AbstractBase
getEnumerationState, getFieldManifestation, getFieldPersistence, getMandate, getMethodManifestation, getMethodStrictness, getOpenness, getOwnership, getParameterManifestation, getProvisioningState, getRequiredPhase, getSynchronizationState, getSyntheticState, getTransitivity, getTypeManifestation, getVisibility, isAbstract, isAnnotation, isBridge, isDeprecated, isEnum, isFinal, isInterface, isMandated, isNative, isOpen, isPackagePrivate, isPrivate, isProtected, isPublic, isStatic, isStaticPhase, isStrict, isSynchronized, isSynthetic, isTransient, isTransitive, isVarArgs, isVolatileMethods inherited from interface ByteCodeElement
isAccessibleTo, isVisibleToMethods inherited from interface Iterable
forEach, iterator, spliteratorMethods inherited from interface ModifierReviewable
getSyntheticState, isFinal, isSyntheticMethods inherited from interface ModifierReviewable.ForTypeDefinition
getTypeManifestation, isAnnotation, isInterfaceMethods inherited from interface ModifierReviewable.OfAbstraction
isAbstractMethods inherited from interface ModifierReviewable.OfByteCodeElement
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStaticMethods inherited from interface ModifierReviewable.OfEnumeration
getEnumerationState, isEnumMethods inherited from interface NamedElement
getActualNameMethods inherited from interface NamedElement.WithDescriptor
getDescriptor, getGenericSignatureMethods inherited from interface NamedElement.WithRuntimeName
getInternalNameMethods inherited from interface TypeDefinition
asErasure, asGenericType, getSort, getStackSize, getTypeName, isArray, isPrimitive, representsMethods inherited from interface TypeDescription
asBoxed, asUnboxed, getActualModifiers, getCanonicalName, getClassFileVersion, getComponentType, getDefaultValue, getInheritedAnnotations, getInnerClassCount, getLongSimpleName, getSimpleName, isAnnotationReturnType, isAnnotationValue, isAnnotationValue, isAssignableFrom, isAssignableFrom, isAssignableTo, isAssignableTo, isCompileTimeConstant, isInHierarchyWith, isInHierarchyWith, isInnerClass, isInstance, isMemberType, isModuleType, isNestedClass, isNestHost, isNestMateOf, isNestMateOf, isPackageType, isPrimitiveWrapper, isSamePackageMethods inherited from interface TypeVariableSource
accept, findExpectedVariable, findVariable, getEnclosingSource, isGenerified, isInferrable
-
Field Details
-
KEYWORDS
-
name
The binary name of the instrumented type. -
modifiers
private final int modifiersThe modifiers of the instrumented type. -
superClass
The generic super type of the instrumented type. -
moduleDescription
The module metadata that this type implies ornull. -
typeVariables
The instrumented type's type variables in their tokenized form. -
interfaceTypes
A list of interfaces of the instrumented type. -
fieldTokens
A list of field tokens describing the fields of the instrumented type. -
auxiliaryFields
-
methodTokens
A list of method tokens describing the methods of the instrumented type. -
recordComponentTokens
A list of record component tokens describing the record components of the instrumented type. -
annotationDescriptions
A list of annotations of the annotated type. -
typeInitializer
The type initializer of the instrumented type. -
loadedTypeInitializer
The loaded type initializer of the instrumented type. -
declaringType
The declaring type of the instrumented type ornullif no such type exists. -
enclosingMethod
The enclosing method of the instrumented type ornullif no such type exists. -
enclosingType
The enclosing type of the instrumented type ornullif no such type exists. -
declaredTypes
A list of types that are declared by this type. -
permittedSubclasses
A list of permitted subclasses ornullif this type is not sealed. -
anonymousClass
private final boolean anonymousClasstrueif this type is an anonymous class. -
localClass
private final boolean localClasstrueif this type is a local class. -
record
private final boolean recordtrueif this class is a record class. -
nestHost
The nest host of this instrumented type or a description ofTargetTypeif this type is its own nest host. -
nestMembers
A list of all members of this types nest group excluding this type.
-
-
Constructor Details
-
Default
protected Default(String name, int modifiers, @MaybeNull ModuleDescription moduleDescription, List<? extends TypeVariableToken> typeVariables, @MaybeNull TypeDescription.Generic superClass, List<? extends TypeDescription.Generic> interfaceTypes, List<? extends FieldDescription.Token> fieldTokens, Map<String, Object> auxiliaryFieldValues, List<? extends MethodDescription.Token> methodTokens, List<? extends RecordComponentDescription.Token> recordComponentTokens, List<? extends AnnotationDescription> annotationDescriptions, TypeInitializer typeInitializer, LoadedTypeInitializer loadedTypeInitializer, @MaybeNull TypeDescription declaringType, @MaybeNull MethodDescription.InDefinedShape enclosingMethod, @MaybeNull TypeDescription enclosingType, List<? extends TypeDescription> declaredTypes, @MaybeNull List<? extends TypeDescription> permittedSubclasses, boolean anonymousClass, boolean localClass, boolean record, TypeDescription nestHost, List<? extends TypeDescription> nestMembers) Creates a new instrumented type.- Parameters:
name- The binary name of the instrumented type.modifiers- The modifiers of the instrumented type.moduleDescription- The module metadata that this type implies ornull.typeVariables- The instrumented type's type variables in their tokenized form.superClass- The generic super type of the instrumented type.interfaceTypes- A list of interfaces of the instrumented type.fieldTokens- A list of field tokens describing the fields of the instrumented type.auxiliaryFieldValues- A mapping of auxiliary field names to their mapped values.methodTokens- A list of method tokens describing the methods of the instrumented type.recordComponentTokens- A list of record component tokens describing the record components of the instrumented type.annotationDescriptions- A list of annotations of the annotated type.typeInitializer- The type initializer of the instrumented type.loadedTypeInitializer- The loaded type initializer of the instrumented type.declaringType- The declaring type of the instrumented type ornullif no such type exists.enclosingMethod- The enclosing method of the instrumented type ornullif no such type exists.enclosingType- The enclosing type of the instrumented type ornullif no such type exists.declaredTypes- A list of types that are declared by this type.permittedSubclasses- A list of permitted subclasses ornullif this type is not sealed.anonymousClass-trueif this type is an anonymous class.localClass-trueif this type is a local class.record-trueif this type is a record class.nestHost- The nest host of this instrumented type or a description ofTargetTypeif this type is its own nest host.nestMembers- A list of all members of this types nest group excluding this type.
-
-
Method Details
-
of
public static InstrumentedType of(String name, TypeDescription.Generic superClass, ModifierContributor.ForType... modifierContributor) Creates a new instrumented type.- Parameters:
name- The type's name.superClass- The type's super class.modifierContributor- The type's modifiers.- Returns:
- An appropriate instrumented type.
-
of
Creates a new instrumented type.- Parameters:
name- The type's name.superClass- The type's super class.modifiers- The type's modifiers.- Returns:
- An appropriate instrumented type.
-
withModifiers
Creates a new instrumented type with changed modifiers.- Specified by:
withModifiersin interfaceInstrumentedType- Specified by:
withModifiersin 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.
-
withField
Creates a new instrumented type that includes a new field.- Specified by:
withFieldin interfaceInstrumentedType- Specified by:
withFieldin 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:
withAuxiliaryFieldin interfaceInstrumentedType- Specified by:
withAuxiliaryFieldin 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:
withMethodin interfaceInstrumentedType- Specified by:
withMethodin 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:
withRecordComponentin interfaceInstrumentedType- Specified by:
withRecordComponentin 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.
-
withInterfaces
Creates a new instrumented type with the given interfaces implemented.- Specified by:
withInterfacesin interfaceInstrumentedType- Specified by:
withInterfacesin 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.
-
withAnnotations
public InstrumentedType.WithFlexibleName withAnnotations(List<? extends AnnotationDescription> annotationDescriptions) Creates a new instrumented type with the given annotations.- Specified by:
withAnnotationsin interfaceInstrumentedType- Specified by:
withAnnotationsin 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:
withNestHostin interfaceInstrumentedType- Specified by:
withNestHostin 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:
withNestMembersin interfaceInstrumentedType- Specified by:
withNestMembersin 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:
withEnclosingTypein interfaceInstrumentedType- Specified by:
withEnclosingTypein 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:
withEnclosingMethodin interfaceInstrumentedType- Specified by:
withEnclosingMethodin 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:
withDeclaringTypein interfaceInstrumentedType- Specified by:
withDeclaringTypein interfaceInstrumentedType.WithFlexibleName- Parameters:
declaringType- The type that declares the instrumented type ornullif 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:
withDeclaredTypesin interfaceInstrumentedType- Specified by:
withDeclaredTypesin 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:
withPermittedSubclassesin interfaceInstrumentedType- Specified by:
withPermittedSubclassesin interfaceInstrumentedType.WithFlexibleName- Parameters:
permittedSubclasses- A list of permitted subclasses to include ornullto unseal the type.- Returns:
- A new instrumented type that includes the supplied permitted subclasses or unseals the type.
-
withModuleDescription
public InstrumentedType.WithFlexibleName withModuleDescription(@MaybeNull ModuleDescription moduleDescription) Description copied from interface:InstrumentedType.WithFlexibleNameCreates a new instrumented type that defines the provided module metadata or no such metadata ifnullis provided.- Specified by:
withModuleDescriptionin interfaceInstrumentedType- Specified by:
withModuleDescriptionin interfaceInstrumentedType.WithFlexibleName- Parameters:
moduleDescription- The metadata to include ornull.- Returns:
- A new instrumented type that is equal to this instrumented type but with adjusted module metadata.
-
withTypeVariable
Creates a new instrumented type with the given type variable defined.- Specified by:
withTypeVariablein interfaceInstrumentedType- Specified by:
withTypeVariablein 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.
-
withName
Creates a new instrumented type with a changed name.- Specified by:
withNamein 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:
withTypeVariablesin 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.
-
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:
withLocalClassin interfaceInstrumentedType- Specified by:
withLocalClassin interfaceInstrumentedType.WithFlexibleName- Parameters:
localClass-trueif 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:
withAnonymousClassin interfaceInstrumentedType- Specified by:
withAnonymousClassin interfaceInstrumentedType.WithFlexibleName- Parameters:
anonymousClass-trueif 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:
withRecordin interfaceInstrumentedType- Specified by:
withRecordin interfaceInstrumentedType.WithFlexibleName- Parameters:
record-trueif 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:
withInitializerin interfaceInstrumentedType- Specified by:
withInitializerin 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:
withInitializerin interfaceInstrumentedType- Specified by:
withInitializerin 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.
-
getLoadedTypeInitializer
Returns theLoadedTypeInitializers that were registered for this instrumented type.- Specified by:
getLoadedTypeInitializerin interfaceInstrumentedType- Returns:
- The registered loaded type initializers for this instrumented type.
-
getTypeInitializer
Returns this instrumented type's type initializer.- Specified by:
getTypeInitializerin interfaceInstrumentedType- Returns:
- This instrumented type's type initializer.
-
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,nullis returned by this method.- Specified by:
getEnclosingMethodin interfaceTypeDescription- Returns:
- A description of the enclosing method of this type or
nullif there is no such method.
-
getEnclosingType
Returns a description of this type's enclosing type if any.- Specified by:
getEnclosingTypein interfaceTypeDescription- Returns:
- A description of the enclosing type of this type or
nullif there is no such type.
-
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:
getDeclaredTypesin interfaceTypeDescription- Returns:
- A list of types that are declared within this type.
-
isAnonymousType
public boolean isAnonymousType()Checks if this type description represents an anonymous type.- Specified by:
isAnonymousTypein interfaceTypeDescription- Returns:
trueif this type description represents an anonymous type.
-
isLocalType
public boolean isLocalType()Checks if this type description represents a local type.- Specified by:
isLocalTypein interfaceTypeDescription- Returns:
trueif this type description represents a local type.
-
getPackage
Returns the package of the type described by this instance ornullif the described type is a primitive type or an array.- Specified by:
getPackagein interfaceTypeDescription- Returns:
- The package of the type described by this instance or
nullif the described type is a primitive type or an array.
-
toModuleDescription
Returns a representation of a Java module that is represented by this type description, normally amodule-info.classfile. If there is no module meta-data attached to the current class,nullis returned.- Specified by:
toModuleDescriptionin interfaceTypeDescription- Returns:
- A description of the module information of this type or
nullif no such information is available.
-
getDeclaredAnnotations
Returns a list of annotations that are declared by this instance.- Specified by:
getDeclaredAnnotationsin interfaceAnnotationSource- Returns:
- A list of declared annotations.
-
getDeclaringType
Returns the declaring type of this instance.- Specified by:
getDeclaringTypein interfaceDeclaredByType- Specified by:
getDeclaringTypein interfaceTypeDescription- Returns:
- The declaring type or
nullif no such type exists.
-
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 theObjectclass do not define a super class wherenullis returned. Array types defineObjectas their direct super class.- Specified by:
getSuperClassin interfaceTypeDefinition- Returns:
- The super class of this type or
nullif 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:
getInterfacesin 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:
getDeclaredFieldsin interfaceTypeDefinition- Specified by:
getDeclaredFieldsin 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:
getDeclaredMethodsin interfaceTypeDefinition- Specified by:
getDeclaredMethodsin interfaceTypeDescription- Returns:
- The methods that this type declares.
-
getTypeVariables
Returns the type variables that are declared by this element.- Specified by:
getTypeVariablesin interfaceTypeVariableSource- Returns:
- The type variables that are declared by this element.
-
getModifiers
public int getModifiers()Returns the modifier that is described by this object.- Specified by:
getModifiersin interfaceModifierReviewable- Returns:
- The modifier that is described by this object.
-
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:
getNamein interfaceNamedElement.WithRuntimeName- Returns:
- The binary ame of this byte code element as visible from within a running Java application.
-
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:
getNestHostin 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:
getNestMembersin 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:
getRecordComponentsin interfaceTypeDefinition- Specified by:
getRecordComponentsin 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:
isRecordin interfaceTypeDefinition- Returns:
trueif this type is a Java record.
-
isSealed
public boolean isSealed()Description copied from class:TypeDescription.AbstractBaseReturnstrueif this class is a sealed class that only permitts a specified range of subclasses.- Specified by:
isSealedin interfaceTypeDescription- Overrides:
isSealedin classTypeDescription.AbstractBase- Returns:
trueif 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:
getPermittedSubtypesin interfaceTypeDescription- Returns:
- The list of permitted subtypes or an empty list if this type is not sealed.
-
validated
Validates the instrumented type to define a legal Java type.- Specified by:
validatedin interfaceInstrumentedType- Returns:
- This instrumented type as a non-modifiable type description.
-
isValidIdentifier
Checks if an array of identifiers is a valid compound Java identifier.- Parameters:
identifier- an array of potentially invalid Java identifiers.- Returns:
trueif all identifiers are valid and the array is not empty.
-
isValidIdentifier
Checks if a Java identifier is valid.- Parameters:
identifier- The identifier to check for validity.- Returns:
trueif the given identifier is valid.
-
isValidUnqualifiedNameIdentifier
Checks if an identifier is a valid "Unqualified Name" for a field, a local variable or a formal parameter, per JVMS 4.2.2.- Parameters:
identifier- The identifier to check for validity.- Returns:
trueif the given identifier is valid.
-
isValidMethodIdentifier
Checks if an identifier is a valid "Unqualified Name" for a method, per JVMS 4.2.2.- Parameters:
identifier- The identifier to check for validity.- Returns:
trueif the given identifier is valid.
-