Package net.bytebuddy.dynamic.scaffold
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:
java.lang.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.Default extends TypeDescription.AbstractBase.OfSimpleType implements InstrumentedType.WithFlexibleName
A default implementation of an instrumented type.
-
-
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.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
Fields Modifier and Type Field Description private java.util.List<? extends AnnotationDescription>annotationDescriptionsA list of annotations of the annotated type.private booleananonymousClasstrueif this type is a anonymous class.private java.util.List<? extends TypeDescription>declaredTypesA list of types that are declared by this type.private TypeDescriptiondeclaringTypeThe declaring type of the instrumented type ornullif no such type exists.private MethodDescription.InDefinedShapeenclosingMethodThe enclosing method of the instrumented type ornullif no such type exists.private TypeDescriptionenclosingTypeThe enclosing type of the instrumented type ornullif no such type exists.private java.util.List<? extends FieldDescription.Token>fieldTokensA list of field tokens describing the fields of the instrumented type.private java.util.List<? extends TypeDescription.Generic>interfaceTypesA list of interfaces of the instrumented type.private static java.util.Set<java.lang.String>KEYWORDSA set containing all keywords of the Java programming language.private LoadedTypeInitializerloadedTypeInitializerThe loaded type initializer of the instrumented type.private booleanlocalClasstrueif this type is a local class.private java.util.List<? extends MethodDescription.Token>methodTokensA list of method tokens describing the methods of the instrumented type.private intmodifiersThe modifiers of the instrumented type.private java.lang.StringnameThe binary name of the instrumented type.private TypeDescriptionnestHostThe nest host of this instrumented type or a description ofTargetTypeif this type is its own nest host.private java.util.List<? extends TypeDescription>nestMembersA list of all members of this types nest group excluding this type.private java.util.List<? extends TypeDescription>permittedSubclassesA list of permitted subclasses.private booleanrecordtrueif this class is a record class.private java.util.List<? extends RecordComponentDescription.Token>recordComponentTokensA list of record component tokens describing the record components of the instrumented type.private TypeDescription.GenericsuperClassThe generic super type of the instrumented type.private TypeInitializertypeInitializerThe type initializer of the instrumented type.private java.util.List<? extends TypeVariableToken>typeVariablesThe instrumented type's type variables in their tokenized form.-
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
Constructors Modifier Constructor Description protectedDefault(java.lang.String name, int modifiers, TypeDescription.Generic superClass, java.util.List<? extends TypeVariableToken> typeVariables, java.util.List<? extends TypeDescription.Generic> interfaceTypes, java.util.List<? extends FieldDescription.Token> fieldTokens, java.util.List<? extends MethodDescription.Token> methodTokens, java.util.List<? extends RecordComponentDescription.Token> recordComponentTokens, java.util.List<? extends AnnotationDescription> annotationDescriptions, TypeInitializer typeInitializer, LoadedTypeInitializer loadedTypeInitializer, TypeDescription declaringType, MethodDescription.InDefinedShape enclosingMethod, TypeDescription enclosingType, java.util.List<? extends TypeDescription> declaredTypes, java.util.List<? extends TypeDescription> permittedSubclasses, boolean anonymousClass, boolean localClass, boolean record, TypeDescription nestHost, java.util.List<? extends TypeDescription> nestMembers)Creates a new instrumented type.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AnnotationListgetDeclaredAnnotations()Returns a list of annotations that are declared by this instance.FieldList<FieldDescription.InDefinedShape>getDeclaredFields()Returns the fields that this type declares.MethodList<MethodDescription.InDefinedShape>getDeclaredMethods()Returns the methods that this type declares.TypeListgetDeclaredTypes()Returns a list of types that are declared by this type.TypeDescriptiongetDeclaringType()Returns the declaring type of this instance.MethodDescription.InDefinedShapegetEnclosingMethod()Returns a description of the method that encloses this type.TypeDescriptiongetEnclosingType()Returns a description of this type's enclosing type if any.TypeList.GenericgetInterfaces()Returns the interfaces that this type implements.LoadedTypeInitializergetLoadedTypeInitializer()Returns theLoadedTypeInitializers that were registered for this instrumented type.intgetModifiers()Returns the modifier that is described by this object.java.lang.StringgetName()Returns the internalName of this byte code element.TypeDescriptiongetNestHost()Returns the nest host of this type.TypeListgetNestMembers()Returns a list of members that are part of a nesting group.PackageDescriptiongetPackage()Returns the package of the type described by this instance ornullif the described type does not imply a package.TypeListgetPermittedSubclasses()Returns the list of permitted subclasses if this class is a sealed class or an empty list if this class is not sealed.RecordComponentList<RecordComponentDescription.InDefinedShape>getRecordComponents()Returns the list of record components that are declared by this type.TypeDescription.GenericgetSuperClass()Returns the super class of this type.TypeInitializergetTypeInitializer()Returns this instrumented type's type initializer.TypeList.GenericgetTypeVariables()Returns the type variables that are declared by this element.booleanisAnonymousType()Checks if this type description represents an anonymous type.booleanisLocalType()Checks if this type description represents a local type.booleanisRecord()Checks if this type is a Java record.private static booleanisValidIdentifier(java.lang.String identifier)Checks if a Java identifier is valid.private static booleanisValidIdentifier(java.lang.String[] identifier)Checks if an array of identifiers is a valid compound Java identifier.static InstrumentedTypeof(java.lang.String name, TypeDescription.Generic superClass, int modifiers)Creates a new instrumented type.static InstrumentedTypeof(java.lang.String name, TypeDescription.Generic superClass, ModifierContributor.ForType... modifierContributor)Creates a new instrumented type.TypeDescriptionvalidated()Validates the instrumented type to define a legal Java type.InstrumentedType.WithFlexibleNamewithAnnotations(java.util.List<? extends AnnotationDescription> annotationDescriptions)Creates a new instrumented type with the given annotations.InstrumentedType.WithFlexibleNamewithAnonymousClass(boolean anonymousClass)Creates a new instrumented type that indicates that it is defined as an anonymous class.InstrumentedType.WithFlexibleNamewithDeclaredTypes(TypeList declaredTypes)Creates a new instrumented type that indicates that it declared the supplied types.InstrumentedType.WithFlexibleNamewithDeclaringType(TypeDescription declaringType)Creates a new instrumented type that is declared by the supplied type..InstrumentedType.WithFlexibleNamewithEnclosingMethod(MethodDescription.InDefinedShape enclosingMethod)Creates a new instrumented type with the supplied enclosing method.InstrumentedType.WithFlexibleNamewithEnclosingType(TypeDescription enclosingType)Creates a new instrumented type with the supplied enclosing type.InstrumentedType.WithFlexibleNamewithField(FieldDescription.Token token)Creates a new instrumented type that includes a new field.InstrumentedType.WithFlexibleNamewithInitializer(ByteCodeAppender byteCodeAppender)Creates a new instrumented type that executes the given initializer in the instrumented type's type initializer.InstrumentedType.WithFlexibleNamewithInitializer(LoadedTypeInitializer loadedTypeInitializer)Creates a new instrumented type that includes the givenLoadedTypeInitializer.InstrumentedType.WithFlexibleNamewithInterfaces(TypeList.Generic interfaceTypes)Creates a new instrumented type with the given interfaces implemented.InstrumentedType.WithFlexibleNamewithLocalClass(boolean localClass)Creates a new instrumented type that indicates that is defined as a local class.InstrumentedType.WithFlexibleNamewithMethod(MethodDescription.Token token)Creates a new instrumented type that includes a new method or constructor.InstrumentedType.WithFlexibleNamewithModifiers(int modifiers)Creates a new instrumented type with changed modifiers.InstrumentedType.WithFlexibleNamewithName(java.lang.String name)Creates a new instrumented type with a changed name.InstrumentedType.WithFlexibleNamewithNestHost(TypeDescription nestHost)Creates a new instrumented type with the supplied nest host.InstrumentedType.WithFlexibleNamewithNestMembers(TypeList nestMembers)Creates a new instrumented types with the supplied nest members added to this instrumented type.InstrumentedType.WithFlexibleNamewithPermittedSubclasses(TypeList permittedSubclasses)Creates a new instrumented type that includes the supplied permitted subclasses.InstrumentedType.WithFlexibleNamewithRecord(boolean record)Creates a new instrumented type that indicates that it defined as a record type.InstrumentedType.WithFlexibleNamewithRecordComponent(RecordComponentDescription.Token token)Creates a new instrumented type that includes a new record component.InstrumentedType.WithFlexibleNamewithSealed(boolean sealed)Creates a new instrumented type that indicates that it defined as a sealed type.InstrumentedType.WithFlexibleNamewithTypeVariable(TypeVariableToken typeVariable)Creates a new instrumented type with the given type variable defined.InstrumentedType.WithFlexibleNamewithTypeVariables(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, getActualModifiers, getActualName, getDefaultValue, getEnclosingSource, getGenericSignature, getInheritedAnnotations, getInnerClassCount, getInternalName, 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, isSealed, isVisibleTo, iterator, represents, toString
-
Methods inherited from class net.bytebuddy.description.TypeVariableSource.AbstractBase
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 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, getGenericSignature
-
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, getActualModifiers, getCanonicalName, getComponentType, getDefaultValue, getInheritedAnnotations, getInnerClassCount, getSimpleName, isAnnotationReturnType, isAnnotationValue, isAnnotationValue, isAssignableFrom, isAssignableFrom, isAssignableTo, isAssignableTo, isCompileTimeConstant, isInHierarchyWith, isInHierarchyWith, isInnerClass, isInstance, isMemberType, isNestedClass, isNestHost, isNestMateOf, isNestMateOf, isPackageType, isPrimitiveWrapper, isSamePackage, isSealed
-
Methods inherited from interface net.bytebuddy.description.TypeVariableSource
accept, findVariable, getEnclosingSource, isGenerified, isInferrable
-
-
-
-
Field Detail
-
KEYWORDS
private static final java.util.Set<java.lang.String> KEYWORDS
A set containing all keywords of the Java programming language.
-
name
private final java.lang.String name
The binary name of the instrumented type.
-
modifiers
private final int modifiers
The modifiers of the instrumented type.
-
superClass
private final TypeDescription.Generic superClass
The generic super type of the instrumented type.
-
typeVariables
private final java.util.List<? extends TypeVariableToken> typeVariables
The instrumented type's type variables in their tokenized form.
-
interfaceTypes
private final java.util.List<? extends TypeDescription.Generic> interfaceTypes
A list of interfaces of the instrumented type.
-
fieldTokens
private final java.util.List<? extends FieldDescription.Token> fieldTokens
A list of field tokens describing the fields of the instrumented type.
-
methodTokens
private final java.util.List<? extends MethodDescription.Token> methodTokens
A list of method tokens describing the methods of the instrumented type.
-
recordComponentTokens
private final java.util.List<? extends RecordComponentDescription.Token> recordComponentTokens
A list of record component tokens describing the record components of the instrumented type.
-
annotationDescriptions
private final java.util.List<? extends AnnotationDescription> annotationDescriptions
A list of annotations of the annotated type.
-
typeInitializer
private final TypeInitializer typeInitializer
The type initializer of the instrumented type.
-
loadedTypeInitializer
private final LoadedTypeInitializer loadedTypeInitializer
The loaded type initializer of the instrumented type.
-
declaringType
private final TypeDescription declaringType
The declaring type of the instrumented type ornullif no such type exists.
-
enclosingMethod
private final MethodDescription.InDefinedShape enclosingMethod
The enclosing method of the instrumented type ornullif no such type exists.
-
enclosingType
private final TypeDescription enclosingType
The enclosing type of the instrumented type ornullif no such type exists.
-
declaredTypes
private final java.util.List<? extends TypeDescription> declaredTypes
A list of types that are declared by this type.
-
permittedSubclasses
private final java.util.List<? extends TypeDescription> permittedSubclasses
A list of permitted subclasses.
-
anonymousClass
private final boolean anonymousClass
trueif this type is a anonymous class.
-
localClass
private final boolean localClass
trueif this type is a local class.
-
record
private final boolean record
trueif this class is a record class.
-
nestHost
private final TypeDescription nestHost
The nest host of this instrumented type or a description ofTargetTypeif this type is its own nest host.
-
nestMembers
private final java.util.List<? extends TypeDescription> nestMembers
A list of all members of this types nest group excluding this type.
-
-
Constructor Detail
-
Default
protected Default(java.lang.String name, int modifiers, TypeDescription.Generic superClass, java.util.List<? extends TypeVariableToken> typeVariables, java.util.List<? extends TypeDescription.Generic> interfaceTypes, java.util.List<? extends FieldDescription.Token> fieldTokens, java.util.List<? extends MethodDescription.Token> methodTokens, java.util.List<? extends RecordComponentDescription.Token> recordComponentTokens, java.util.List<? extends AnnotationDescription> annotationDescriptions, TypeInitializer typeInitializer, LoadedTypeInitializer loadedTypeInitializer, TypeDescription declaringType, MethodDescription.InDefinedShape enclosingMethod, TypeDescription enclosingType, java.util.List<? extends TypeDescription> declaredTypes, java.util.List<? extends TypeDescription> permittedSubclasses, boolean anonymousClass, boolean localClass, boolean record, TypeDescription nestHost, java.util.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.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.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.anonymousClass-trueif this type is a 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 Detail
-
of
public static InstrumentedType of(java.lang.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
public static InstrumentedType of(java.lang.String name, TypeDescription.Generic superClass, int modifiers)
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
public InstrumentedType.WithFlexibleName withModifiers(int modifiers)
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
public InstrumentedType.WithFlexibleName withField(FieldDescription.Token token)
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.
-
withMethod
public InstrumentedType.WithFlexibleName withMethod(MethodDescription.Token token)
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
public InstrumentedType.WithFlexibleName withInterfaces(TypeList.Generic interfaceTypes)
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(java.util.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
public InstrumentedType.WithFlexibleName withNestHost(TypeDescription nestHost)
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
public InstrumentedType.WithFlexibleName withNestMembers(TypeList nestMembers)
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(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(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.- Returns:
- A new instrumented type that is declared by the instrumented type.
-
withDeclaredTypes
public InstrumentedType.WithFlexibleName withDeclaredTypes(TypeList declaredTypes)
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(TypeList permittedSubclasses)
Creates a new instrumented type that includes the supplied permitted subclasses.- Specified by:
withPermittedSubclassesin interfaceInstrumentedType- Specified by:
withPermittedSubclassesin interfaceInstrumentedType.WithFlexibleName- Parameters:
permittedSubclasses- A list of permitted subclasses to include.- Returns:
- A new instrumented type that includes the supplied permitted subclasses.
-
withTypeVariable
public InstrumentedType.WithFlexibleName withTypeVariable(TypeVariableToken typeVariable)
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
public InstrumentedType.WithFlexibleName withName(java.lang.String name)
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
public InstrumentedType.WithFlexibleName withLocalClass(boolean localClass)
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
public InstrumentedType.WithFlexibleName withAnonymousClass(boolean anonymousClass)
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
public InstrumentedType.WithFlexibleName withRecord(boolean record)
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.
-
withSealed
public InstrumentedType.WithFlexibleName withSealed(boolean sealed)
Creates a new instrumented type that indicates that it defined as a sealed type.- Specified by:
withSealedin interfaceInstrumentedType- Specified by:
withSealedin interfaceInstrumentedType.WithFlexibleName- Parameters:
sealed-trueif the instrumented type is supposed to be sealed.- Returns:
- A new instrumented type that is defined as a sealed type if any permitted subclasses are set.
-
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
public InstrumentedType.WithFlexibleName withInitializer(ByteCodeAppender byteCodeAppender)
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
public LoadedTypeInitializer 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
public TypeInitializer getTypeInitializer()
Returns this instrumented type's type initializer.- Specified by:
getTypeInitializerin interfaceInstrumentedType- Returns:
- This instrumented type's type initializer.
-
getEnclosingMethod
public MethodDescription.InDefinedShape 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
public TypeDescription 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
public TypeList 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
public PackageDescription getPackage()
Returns the package of the type described by this instance ornullif the described type does not imply a package.- Specified by:
getPackagein interfaceTypeDescription- Returns:
- The package of the type described by this instance or
nullif the described type does not imply a package.
-
getDeclaredAnnotations
public AnnotationList getDeclaredAnnotations()
Returns a list of annotations that are declared by this instance.- Specified by:
getDeclaredAnnotationsin interfaceAnnotationSource- Returns:
- A list of declared annotations.
-
getDeclaringType
public TypeDescription 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
public TypeDescription.Generic 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
public TypeList.Generic 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
public FieldList<FieldDescription.InDefinedShape> 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
public MethodList<MethodDescription.InDefinedShape> getDeclaredMethods()
Returns the methods that this type declares.- Specified by:
getDeclaredMethodsin interfaceTypeDefinition- Specified by:
getDeclaredMethodsin interfaceTypeDescription- Returns:
- The methods that this type declares.
-
getTypeVariables
public TypeList.Generic 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
public java.lang.String getName()
Returns the internalName of this byte code element.- Specified by:
getNamein interfaceNamedElement.WithRuntimeName- Returns:
- The internalName of this byte code element as visible from within a running Java application.
-
getNestHost
public TypeDescription 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
public TypeList 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
public RecordComponentList<RecordComponentDescription.InDefinedShape> 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.
-
getPermittedSubclasses
public TypeList getPermittedSubclasses()
Returns the list of permitted subclasses if this class is a sealed class or an empty list if this class is not sealed.- Specified by:
getPermittedSubclassesin interfaceTypeDescription- Returns:
- The list of permitted subclasses if this class is a sealed class or an empty list if this class is not sealed.
-
validated
public TypeDescription 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
private static boolean isValidIdentifier(java.lang.String[] identifier)
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
private static boolean isValidIdentifier(java.lang.String identifier)
Checks if a Java identifier is valid.- Parameters:
identifier- The identifier to check for validity.- Returns:
trueif the given identifier is valid.
-
-