Interface TypeDefinition
-
- All Superinterfaces:
java.lang.Iterable<TypeDefinition>,ModifierReviewable,ModifierReviewable.ForTypeDefinition,ModifierReviewable.OfAbstraction,ModifierReviewable.OfByteCodeElement,ModifierReviewable.OfEnumeration,NamedElement
- All Known Subinterfaces:
InstrumentedType,InstrumentedType.WithFlexibleName,TypeDescription,TypeDescription.Generic
- All Known Implementing Classes:
InstrumentedType.Default,InstrumentedType.Frozen,TypeDescription.AbstractBase,TypeDescription.AbstractBase.OfSimpleType,TypeDescription.AbstractBase.OfSimpleType.WithDelegation,TypeDescription.ArrayProjection,TypeDescription.ForLoadedType,TypeDescription.ForLoadedType.ClassDescriptionTypeList.InternalNameLazyType,TypeDescription.ForPackageDescription,TypeDescription.Generic.AbstractBase,TypeDescription.Generic.LazyProjection,TypeDescription.Generic.LazyProjection.ForLoadedFieldType,TypeDescription.Generic.LazyProjection.ForLoadedReturnType,TypeDescription.Generic.LazyProjection.ForLoadedSuperClass,TypeDescription.Generic.LazyProjection.OfConstructorParameter,TypeDescription.Generic.LazyProjection.OfMethodParameter,TypeDescription.Generic.LazyProjection.OfRecordComponent,TypeDescription.Generic.LazyProjection.WithEagerNavigation,TypeDescription.Generic.LazyProjection.WithEagerNavigation.OfAnnotatedElement,TypeDescription.Generic.LazyProjection.WithLazyNavigation,TypeDescription.Generic.LazyProjection.WithLazyNavigation.LazyInterfaceType,TypeDescription.Generic.LazyProjection.WithLazyNavigation.LazySuperClass,TypeDescription.Generic.LazyProjection.WithLazyNavigation.OfAnnotatedElement,TypeDescription.Generic.LazyProjection.WithResolvedErasure,TypeDescription.Generic.OfGenericArray,TypeDescription.Generic.OfGenericArray.ForLoadedType,TypeDescription.Generic.OfGenericArray.Latent,TypeDescription.Generic.OfNonGenericType,TypeDescription.Generic.OfNonGenericType.ForErasure,TypeDescription.Generic.OfNonGenericType.ForLoadedType,TypeDescription.Generic.OfNonGenericType.ForReifiedErasure,TypeDescription.Generic.OfNonGenericType.Latent,TypeDescription.Generic.OfParameterizedType,TypeDescription.Generic.OfParameterizedType.ForGenerifiedErasure,TypeDescription.Generic.OfParameterizedType.ForLoadedType,TypeDescription.Generic.OfParameterizedType.ForReifiedType,TypeDescription.Generic.OfParameterizedType.Latent,TypeDescription.Generic.OfTypeVariable,TypeDescription.Generic.OfTypeVariable.ForLoadedType,TypeDescription.Generic.OfTypeVariable.Symbolic,TypeDescription.Generic.OfTypeVariable.WithAnnotationOverlay,TypeDescription.Generic.OfWildcardType,TypeDescription.Generic.OfWildcardType.ForLoadedType,TypeDescription.Generic.OfWildcardType.Latent,TypeDescription.Generic.Visitor.AnnotationStripper.NonAnnotatedTypeVariable,TypeDescription.Generic.Visitor.Substitutor.ForTypeVariableBinding.RetainedMethodTypeVariable,TypeDescription.Latent,TypeDescription.SuperTypeLoading,TypeDescription.SuperTypeLoading.ClassLoadingTypeProjection,TypeList.Generic.ForDetachedTypes.OfTypeVariables.AttachedTypeVariable,TypeList.Generic.OfConstructorExceptionTypes.TypeProjection,TypeList.Generic.OfLoadedInterfaceTypes.TypeProjection,TypeList.Generic.OfMethodExceptionTypes.TypeProjection,TypePool.Default.LazyTypeDescription,TypePool.Default.LazyTypeDescription.GenericTypeToken.ForGenericArray.LazyGenericArray,TypePool.Default.LazyTypeDescription.GenericTypeToken.ForLowerBoundWildcard.LazyLowerBoundWildcard,TypePool.Default.LazyTypeDescription.GenericTypeToken.ForParameterizedType.LazyParameterizedType,TypePool.Default.LazyTypeDescription.GenericTypeToken.ForParameterizedType.Nested.LazyParameterizedType,TypePool.Default.LazyTypeDescription.GenericTypeToken.ForPrimitiveType.LazyPrimitiveType,TypePool.Default.LazyTypeDescription.GenericTypeToken.ForTypeVariable.AnnotatedTypeVariable,TypePool.Default.LazyTypeDescription.GenericTypeToken.ForTypeVariable.Formal.LazyTypeVariable,TypePool.Default.LazyTypeDescription.GenericTypeToken.ForTypeVariable.UnresolvedTypeVariable,TypePool.Default.LazyTypeDescription.GenericTypeToken.ForUnboundWildcard.LazyUnboundWildcard,TypePool.Default.LazyTypeDescription.GenericTypeToken.ForUpperBoundWildcard.LazyUpperBoundWildcard,TypePool.Default.LazyTypeDescription.GenericTypeToken.Resolution.Raw.RawAnnotatedType,TypePool.Default.LazyTypeDescription.LazyMethodDescription.LazyNonGenericReceiverType,TypePool.Default.LazyTypeDescription.LazyMethodDescription.LazyParameterizedReceiverType,TypePool.Default.LazyTypeDescription.LazyMethodDescription.LazyParameterizedReceiverType.TypeArgumentList.AnnotatedTypeVariable,TypePool.Default.LazyTypeDescription.TokenizedGenericType,TypePool.Default.LazyTypeDescription.TokenizedGenericType.Malformed,TypePool.Default.WithLazyResolution.LazyTypeDescription,TypePool.LazyFacade.LazyTypeDescription
public interface TypeDefinition extends NamedElement, ModifierReviewable.ForTypeDefinition, java.lang.Iterable<TypeDefinition>
Implementations define a type, either as aTypeDescriptionor as aTypeDescription.Generic.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classTypeDefinition.SortRepresents aTypeDescription.Generic's form.static classTypeDefinition.SuperClassIteratorAn iterator that iterates over a type's class hierarchy.-
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
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringRAW_TYPES_PROPERTYIf this property is set totrue, non-genericTypeDefinitions do no longer resolve their referenced generic types when traversing type hierarchies.-
Fields inherited from interface net.bytebuddy.description.ModifierReviewable
EMPTY_MASK
-
Fields inherited from interface net.bytebuddy.description.NamedElement
EMPTY_NAME, NO_NAME
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description TypeDescriptionasErasure()Returns the erasure of this type.TypeDescription.GenericasGenericType()Returns this type definition as a generic type.TypeDefinitiongetComponentType()Returns the component type of this type.FieldList<?>getDeclaredFields()Returns the fields that this type declares.MethodList<?>getDeclaredMethods()Returns the methods that this type declares.TypeList.GenericgetInterfaces()Returns the interfaces that this type implements.RecordComponentList<?>getRecordComponents()Returns the list of record components that are declared by this type.TypeDefinition.SortgetSort()Returns the sort of the generic type this instance represents.StackSizegetStackSize()Returns the size of the type described by this instance.TypeDescription.GenericgetSuperClass()Returns the super class of this type.java.lang.StringgetTypeName()Returns the name of the type.booleanisArray()Checks if the type described by this entity is an array.booleanisPrimitive()Checks if the type described by this entity is a primitive type.booleanisRecord()Checks if this type is a Java record.booleanrepresents(java.lang.reflect.Type type)Checks if the type described by this instance representstype.-
Methods inherited from interface net.bytebuddy.description.ModifierReviewable
getModifiers, 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
-
-
-
-
Field Detail
-
RAW_TYPES_PROPERTY
static final java.lang.String RAW_TYPES_PROPERTY
If this property is set to
true, non-genericTypeDefinitions do no longer resolve their referenced generic types when traversing type hierarchies. Setting this property can cause unexpected side effects such asClassCastExceptions from overridden methods as type variables are resolved to their erasures where a method might return that is unexpected by the callee. Setting this property also makes type annotations unavailable using such type navigation.Setting this property can be useful if generic type information is not required in order to avoid bugs in implementations of the JVM where processing generic types can cause segmentation faults. Byte Buddy will undertake a best effort to retain the generic type information and information about type annotations within the redefined types' class files. Typically, this property can be meaningful in combination with a Java agent that only changes byte code without changing a class type's structure.
- See Also:
- Constant Field Values
-
-
Method Detail
-
asGenericType
TypeDescription.Generic asGenericType()
Returns this type definition as a generic type.- Returns:
- This type definition represented as a generic type.
-
asErasure
TypeDescription asErasure()
Returns the erasure of this type. Wildcard types (TypeDefinition.Sort.WILDCARD) do not have a well-defined erasure and cause anIllegalStateExceptionto be thrown.- Returns:
- The erasure of this type.
-
getSuperClass
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.- Returns:
- The super class of this type or
nullif no super class exists for this type.
-
getInterfaces
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.- Returns:
- The interfaces that this type implements.
-
getDeclaredFields
FieldList<?> 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
MethodList<?> getDeclaredMethods()
Returns the methods that this type declares.- Returns:
- The methods that this type declares.
-
getComponentType
TypeDefinition getComponentType()
Returns the component type of this type.
Only non-generic types (
TypeDefinition.Sort.NON_GENERIC) and generic array typesTypeDefinition.Sort.GENERIC_ARRAY) define a component type. For other types, anIllegalStateExceptionis thrown.- Returns:
- The component type of this type or
nullif this type does not represent an array type.
-
getRecordComponents
RecordComponentList<?> 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.
-
getSort
TypeDefinition.Sort getSort()
Returns the sort of the generic type this instance represents.- Returns:
- The sort of the generic type.
-
getTypeName
java.lang.String getTypeName()
Returns the name of the type. For generic types, this name is theirObject.toString()representations. For a non-generic type, it is the fully qualified binary name of the type.- Returns:
- The name of this type.
-
getStackSize
StackSize getStackSize()
Returns the size of the type described by this instance. Wildcard types (TypeDefinition.Sort.WILDCARDdo not have a well-defined a stack size and cause anIllegalStateExceptionto be thrown.- Returns:
- The size of the type described by this instance.
-
isArray
boolean isArray()
Checks if the type described by this entity is an array.- Returns:
trueif this type description represents an array.
-
isRecord
boolean isRecord()
Checks if this type is a Java record.- Returns:
trueif this type is a Java record.
-
isPrimitive
boolean isPrimitive()
Checks if the type described by this entity is a primitive type.- Returns:
trueif this type description represents a primitive type.
-
represents
boolean represents(java.lang.reflect.Type type)
Checks if the type described by this instance representstype.- Parameters:
type- The type of interest.- Returns:
trueif the type described by this instance representstype.
-
-