Package net.bytebuddy.pool
Class TypePool.Default.LazyTypeDescription
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.pool.TypePool.Default.LazyTypeDescription
- 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
- Enclosing class:
TypePool.Default
protected static class TypePool.Default.LazyTypeDescription
extends TypeDescription.AbstractBase.OfSimpleType
A type description that looks up any referenced
ByteCodeElement or
AnnotationDescription by querying a type pool at lookup time.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classA token for representing collected data on an annotation.protected static classA token for representing collected data on a field.protected classA list of field tokens representing each entry as a field description.protected static interfaceA token that represents a generic Java type.private static classA lazy description of an annotation that looks up types from a type pool when required.private static classA proxy for a lazy annotation value.private classA lazy field description that only resolved type references when required.private classA lazy representation of a method that resolves references to types only on demand.protected static classA lazy list that represents all nest members of the represented type.private static classAn implementation of aPackageDescriptionthat only loads its annotations on requirement.private classA lazy description of a record component.protected static classA list that is constructingTypePool.Default.LazyTypeDescriptions.protected static classA token for representing collected data on a method.protected classA list of method tokens representing each entry as a method description.protected static classA token representing a record component.protected classA list of record component tokens representing each record component as a description.protected static classA representation of a generic type that is described by aTypePool.Default.LazyTypeDescription.GenericTypeToken.protected static interfaceA declaration context encapsulates information about whether a type was declared within another type or within a method of another type.Nested classes/interfaces inherited from class net.bytebuddy.description.type.TypeDescription.AbstractBase.OfSimpleType
TypeDescription.AbstractBase.OfSimpleType.WithDelegationNested classes/interfaces inherited from class net.bytebuddy.description.type.TypeDescription.AbstractBase
TypeDescription.AbstractBase.OfSimpleTypeNested classes/interfaces inherited from interface net.bytebuddy.description.annotation.AnnotationSource
AnnotationSource.Empty, AnnotationSource.ExplicitNested classes/interfaces inherited from interface net.bytebuddy.description.ByteCodeElement
ByteCodeElement.Member, 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.WithMandatoryDeclarationNested classes/interfaces inherited from interface net.bytebuddy.description.ModifierReviewable
ModifierReviewable.AbstractBase, ModifierReviewable.ForFieldDescription, ModifierReviewable.ForMethodDescription, ModifierReviewable.ForParameterDescription, ModifierReviewable.ForTypeDefinition, ModifierReviewable.OfAbstraction, ModifierReviewable.OfByteCodeElement, ModifierReviewable.OfEnumerationNested classes/interfaces inherited from interface net.bytebuddy.description.NamedElement
NamedElement.WithDescriptor, NamedElement.WithGenericName, NamedElement.WithOptionalName, NamedElement.WithRuntimeNameNested classes/interfaces inherited from interface net.bytebuddy.description.type.TypeDefinition
TypeDefinition.Sort, TypeDefinition.SuperClassIteratorNested classes/interfaces inherited from interface net.bytebuddy.description.type.TypeDescription
TypeDescription.AbstractBase, TypeDescription.ArrayProjection, TypeDescription.ForLoadedType, TypeDescription.ForPackageDescription, TypeDescription.Generic, TypeDescription.Latent, TypeDescription.LazyProxy, TypeDescription.SuperTypeLoadingNested classes/interfaces inherited from interface net.bytebuddy.description.TypeVariableSource
TypeVariableSource.AbstractBase, TypeVariableSource.Visitor<T> -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final intThe actual modifiers of this type.private final List<TypePool.Default.LazyTypeDescription.AnnotationToken> A list of tokens that represent the annotations of this type.private final booleantrueif this type is an anonymous type.private final ClassFileVersionThe type's class file version.A list of descriptors representing the types that are declared by this type.private final StringThe binary name of this type's declaring type ornullif no such type exists.private final List<TypePool.Default.LazyTypeDescription.FieldToken> A list of field tokens describing the field's of this type.private final StringThe type's generic signature as found in the class file ornullif the type is not generic.A mapping of type annotations for this type's interface types by their indices.The descriptor of this type's interfaces.private final List<TypePool.Default.LazyTypeDescription.MethodToken> A list of method tokens describing the method's of this type.private final intThe modifiers of this type.private final StringThe binary name of this type.private final StringThe binary name of the nest host ornullif no nest host was specified.A list of binary names of all specified nest members.private static final StringIndicates that a type does not exist and does therefore not have a name.A list of internal names of permitted subclasses.private final List<TypePool.Default.LazyTypeDescription.RecordComponentToken> A list of record component tokens describing the record components of this type.The resolution of this type's generic type.private final Map<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>> A mapping of the super class's annotation tokens.private final StringThe type's super type's descriptor ornullif this type does not define a super type.private final TypePool.Default.LazyTypeDescription.TypeContainmentA definition of this type's containment within another type or method.private final TypePoolThe type pool to be used for looking up linked types.A mapping of type annotations of the type variables' type annotations by their indices.private final Map<Integer, Map<Integer, Map<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>>>> A mapping of type annotations of the type variables' bounds' type annotations by their indices and each variable's index.Fields inherited from class net.bytebuddy.description.type.TypeDescription.AbstractBase
RAW_TYPESFields inherited from interface net.bytebuddy.description.ModifierReviewable
EMPTY_MASKFields inherited from interface net.bytebuddy.description.NamedElement
EMPTY_NAME, NO_NAMEFields inherited from interface net.bytebuddy.description.NamedElement.WithDescriptor
NON_GENERIC_SIGNATUREFields inherited from interface net.bytebuddy.description.type.TypeDefinition
RAW_TYPES_PROPERTYFields inherited from interface net.bytebuddy.description.type.TypeDescription
ARRAY_INTERFACES, CLASS, OBJECT, STRING, THROWABLE, UNDEFINED, VOIDFields inherited from interface net.bytebuddy.description.TypeVariableSource
UNDEFINED -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLazyTypeDescription(TypePool typePool, int actualModifiers, int modifiers, String name, String superClassInternalName, String[] interfaceInternalName, String genericSignature, TypePool.Default.LazyTypeDescription.TypeContainment typeContainment, String declaringTypeInternalName, List<String> declaredTypes, boolean anonymousType, String nestHostInternalName, List<String> nestMemberInternalNames, Map<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>> superClassAnnotationTokens, Map<Integer, Map<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>>> interfaceAnnotationTokens, Map<Integer, Map<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>>> typeVariableAnnotationTokens, Map<Integer, Map<Integer, Map<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>>>> typeVariableBoundsAnnotationTokens, List<TypePool.Default.LazyTypeDescription.AnnotationToken> annotationTokens, List<TypePool.Default.LazyTypeDescription.FieldToken> fieldTokens, List<TypePool.Default.LazyTypeDescription.MethodToken> methodTokens, List<TypePool.Default.LazyTypeDescription.RecordComponentToken> recordComponentTokens, List<String> permittedSubclasses, ClassFileVersion classFileVersion) Creates a new lazy type description. -
Method Summary
Modifier and TypeMethodDescriptionintgetActualModifiers(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.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 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.Methods inherited from class net.bytebuddy.description.type.TypeDescription.AbstractBase.OfSimpleType
getCanonicalName, getComponentType, getDescriptor, getSimpleName, getStackSize, isArray, isPrimitiveMethods 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, toSafeString, toStringMethods inherited from class net.bytebuddy.description.TypeVariableSource.AbstractBase
findExpectedVariable, findVariableMethods 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, isVolatileMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliteratorMethods inherited from interface net.bytebuddy.description.ModifierReviewable
getSyntheticState, isFinal, isSyntheticMethods inherited from interface net.bytebuddy.description.ModifierReviewable.ForTypeDefinition
getTypeManifestation, isAnnotation, isInterfaceMethods inherited from interface net.bytebuddy.description.ModifierReviewable.OfAbstraction
isAbstractMethods inherited from interface net.bytebuddy.description.ModifierReviewable.OfByteCodeElement
getOwnership, getVisibility, isDeprecated, isPackagePrivate, isPrivate, isProtected, isPublic, isStaticMethods inherited from interface net.bytebuddy.description.ModifierReviewable.OfEnumeration
getEnumerationState, isEnumMethods inherited from interface net.bytebuddy.description.TypeVariableSource
findExpectedVariable, findVariable
-
Field Details
-
NO_TYPE
Indicates that a type does not exist and does therefore not have a name. -
typePool
The type pool to be used for looking up linked types. -
actualModifiers
private final int actualModifiersThe actual modifiers of this type. -
modifiers
private final int modifiersThe modifiers of this type. -
name
The binary name of this type. -
superClassDescriptor
The type's super type's descriptor ornullif this type does not define a super type. -
genericSignature
The type's generic signature as found in the class file ornullif the type is not generic. -
signatureResolution
private final TypePool.Default.LazyTypeDescription.GenericTypeToken.Resolution.ForType signatureResolutionThe resolution of this type's generic type. -
interfaceTypeDescriptors
The descriptor of this type's interfaces. -
typeContainment
A definition of this type's containment within another type or method. -
declaringTypeName
The binary name of this type's declaring type ornullif no such type exists. -
declaredTypes
A list of descriptors representing the types that are declared by this type. -
anonymousType
private final boolean anonymousTypetrueif this type is an anonymous type. -
nestHost
The binary name of the nest host ornullif no nest host was specified. -
nestMembers
A list of binary names of all specified nest members. -
superClassAnnotationTokens
private final Map<String,List<TypePool.Default.LazyTypeDescription.AnnotationToken>> superClassAnnotationTokensA mapping of the super class's annotation tokens. -
interfaceAnnotationTokens
private final Map<Integer,Map<String, interfaceAnnotationTokensList<TypePool.Default.LazyTypeDescription.AnnotationToken>>> A mapping of type annotations for this type's interface types by their indices. -
typeVariableAnnotationTokens
private final Map<Integer,Map<String, typeVariableAnnotationTokensList<TypePool.Default.LazyTypeDescription.AnnotationToken>>> A mapping of type annotations of the type variables' type annotations by their indices. -
typeVariableBoundsAnnotationTokens
private final Map<Integer,Map<Integer, typeVariableBoundsAnnotationTokensMap<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>>>> A mapping of type annotations of the type variables' bounds' type annotations by their indices and each variable's index. -
annotationTokens
A list of tokens that represent the annotations of this type. -
fieldTokens
A list of field tokens describing the field's of this type. -
methodTokens
A list of method tokens describing the method's of this type. -
recordComponentTokens
A list of record component tokens describing the record components of this type. -
permittedSubclasses
A list of internal names of permitted subclasses. -
classFileVersion
The type's class file version.
-
-
Constructor Details
-
LazyTypeDescription
protected LazyTypeDescription(TypePool typePool, int actualModifiers, int modifiers, String name, @MaybeNull String superClassInternalName, @MaybeNull String[] interfaceInternalName, @MaybeNull String genericSignature, TypePool.Default.LazyTypeDescription.TypeContainment typeContainment, @MaybeNull String declaringTypeInternalName, List<String> declaredTypes, boolean anonymousType, @MaybeNull String nestHostInternalName, List<String> nestMemberInternalNames, Map<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>> superClassAnnotationTokens, Map<Integer, Map<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>>> interfaceAnnotationTokens, Map<Integer, Map<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>>> typeVariableAnnotationTokens, Map<Integer, Map<Integer, Map<String, List<TypePool.Default.LazyTypeDescription.AnnotationToken>>>> typeVariableBoundsAnnotationTokens, List<TypePool.Default.LazyTypeDescription.AnnotationToken> annotationTokens, List<TypePool.Default.LazyTypeDescription.FieldToken> fieldTokens, List<TypePool.Default.LazyTypeDescription.MethodToken> methodTokens, List<TypePool.Default.LazyTypeDescription.RecordComponentToken> recordComponentTokens, List<String> permittedSubclasses, ClassFileVersion classFileVersion) Creates a new lazy type description.- Parameters:
typePool- The type pool to be used for looking up linked types.actualModifiers- The actual modifiers of this type.modifiers- The modifiers of this type.name- The binary name of this type.superClassInternalName- The internal name of this type's super type ornullif no such super type is defined.interfaceInternalName- An array of this type's interfaces ornullif this type does not define any interfaces.genericSignature- The type's generic signature as found in the class file ornullif the type is not generic.typeContainment- A definition of this type's containment within another type or method.declaringTypeInternalName- The internal name of this type's declaring type ornullif no such type exists.declaredTypes- A list of descriptors representing the types that are declared by this type.anonymousType-trueif this type is an anonymous type.nestHostInternalName- The internal name of the nest host ornullif no nest host was specified.nestMemberInternalNames- A list of internal names of the nest members.superClassAnnotationTokens- A mapping of the super class's annotation tokens.interfaceAnnotationTokens- A mapping of type annotations for this type's interface types by their indices.typeVariableAnnotationTokens- A mapping of type annotations of the type variables' type annotations by their indices.typeVariableBoundsAnnotationTokens- A mapping of type annotations of the type variables' bounds' type annotations by their indices and each variable's index.annotationTokens- A list of tokens that represent the annotations of this type.fieldTokens- A list of field tokens describing the field's of this type.methodTokens- A list of method tokens describing the method's of this type.recordComponentTokens- A list of record component tokens describing the record components of this type.permittedSubclasses- A list of internal names of permitted subclasses.classFileVersion- The type's class file version.
-
-
Method Details
-
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.- 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.- Returns:
- The interfaces that this type implements.
-
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.- 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.- 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.- Returns:
- A list of types that are declared within this type.
-
isAnonymousType
public boolean isAnonymousType()Checks if this type description represents an anonymous type.- Returns:
trueif this type description represents an anonymous type.
-
isLocalType
public boolean isLocalType()Checks if this type description represents a local type.- Returns:
trueif this type description represents a local type.
-
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.- 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.- Returns:
- The methods that this type declares.
-
getPackage
Returns the package of the type described by this instance ornullif the described type is a primitive type or an array.- Returns:
- The package of the type described by this instance or
nullif the described type is a primitive type or an array.
-
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.- Returns:
- The binary ame of this byte code element as visible from within a running Java application.
-
getDeclaringType
Returns the declaring type of this instance.- Returns:
- The declaring type or
nullif no such type exists.
-
getModifiers
public int getModifiers()Returns the modifier that is described by this object.- Returns:
- The modifier that is described by this object.
-
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 asfinalas it is also done by the Java compiler.- Specified by:
getActualModifiersin interfaceTypeDescription- Overrides:
getActualModifiersin classTypeDescription.AbstractBase- Parameters:
superFlag-trueif 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.- 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.- Returns:
- A list of members of this nest group.
-
getDeclaredAnnotations
Returns a list of annotations that are declared by this instance.- Returns:
- A list of declared annotations.
-
getTypeVariables
Returns the type variables that are declared by this element.- Returns:
- The type variables that are declared by this element.
-
getGenericSignature
Description copied from class:TypeDescription.AbstractBaseReturns the generic signature of this byte code element. If this element does not reference generic types or references malformed generic types,nullis returned as a signature.- Specified by:
getGenericSignaturein interfaceNamedElement.WithDescriptor- Overrides:
getGenericSignaturein classTypeDescription.AbstractBase- Returns:
- The generic signature or
nullif this element is not generic.
-
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.- Returns:
- A list of record components that this type declares.
-
isRecord
public boolean isRecord()Checks if this type is a Java record.- 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.- Returns:
- The list of permitted subtypes or an empty list if this type is not sealed.
-
getClassFileVersion
Description copied from class:TypeDescription.AbstractBaseAttempts 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,nullis returned.- Specified by:
getClassFileVersionin interfaceTypeDescription- Overrides:
getClassFileVersionin classTypeDescription.AbstractBase- Returns:
- This type's class file version or
nullif it cannot be resolved.
-