Interface TypeDefinition
- All Superinterfaces:
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
,JavaType.LatentTypeWithSimpleName
,TypeDescription.AbstractBase
,TypeDescription.AbstractBase.OfSimpleType
,TypeDescription.AbstractBase.OfSimpleType.WithDelegation
,TypeDescription.ArrayProjection
,TypeDescription.ForLoadedType
,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
TypeDescription
or as a TypeDescription.Generic
.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enum
Represents aTypeDescription.Generic
's form.static class
An 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
FieldsModifier and TypeFieldDescriptionstatic final String
If this property is set totrue
, non-genericTypeDefinition
s 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
Modifier and TypeMethodDescriptionReturns the erasure of this type.Returns this type definition as a generic type.Returns the component type of this type.FieldList
<?> Returns the fields that this type declares.MethodList
<?> Returns the methods that this type declares.Returns the interfaces that this type implements.Returns the list of record components that are declared by this type.getSort()
Returns the sort of the generic type this instance represents.Returns the size of the type described by this instance.Returns the super class of this type.Returns the name of the type.boolean
isArray()
Checks if the type described by this entity is an array.boolean
Checks if the type described by this entity is a primitive type.boolean
isRecord()
Checks if this type is a Java record.boolean
represents
(Type type) Checks if the type described by this instance representstype
.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
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 Details
-
RAW_TYPES_PROPERTY
If this property is set to
true
, non-genericTypeDefinition
s do no longer resolve their referenced generic types when traversing type hierarchies. Setting this property can cause unexpected side effects such asClassCastException
s 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:
-
-
Method Details
-
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 anIllegalStateException
to be thrown.- Returns:
- The erasure of this type.
-
getSuperClass
Returns the super class of this type. A super type is only defined for non-generic types (TypeDefinition.Sort.NON_GENERIC
), parameterized types (TypeDefinition.Sort.PARAMETERIZED
) or generic array types (TypeDefinition.Sort.GENERIC_ARRAY
) types. Interface types and theObject
class do not define a super class wherenull
is returned. Array types defineObject
as their direct super class.- Returns:
- The super class of this type or
null
if 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
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, anIllegalStateException
is thrown.- Returns:
- The component type of this type or
null
if 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
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.WILDCARD
do not have a well-defined a stack size and cause anIllegalStateException
to 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:
true
if this type description represents an array.
-
isRecord
boolean isRecord()Checks if this type is a Java record.- Returns:
true
if this type is a Java record.
-
isPrimitive
boolean isPrimitive()Checks if the type described by this entity is a primitive type.- Returns:
true
if this type description represents a primitive type.
-
represents
Checks if the type described by this instance representstype
.- Parameters:
type
- The type of interest.- Returns:
true
if the type described by this instance representstype
.
-