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

Implementations define a type, either as a TypeDescription or as a TypeDescription.Generic.
  • Field Details

    • RAW_TYPES_PROPERTY

      static final String RAW_TYPES_PROPERTY

      If this property is set to true, non-generic TypeDefinitions do no longer resolve their referenced generic types when traversing type hierarchies. Setting this property can cause unexpected side effects such as ClassCastExceptions 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 an IllegalStateException 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 the Object class do not define a super class where null is returned. Array types define Object 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

      @MaybeNull TypeDefinition getComponentType()

      Returns the component type of this type.

      Only non-generic types (TypeDefinition.Sort.NON_GENERIC) and generic array types TypeDefinition.Sort.GENERIC_ARRAY) define a component type. For other types, an IllegalStateException 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

      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 their Object.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 an IllegalStateException 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

      boolean represents(Type type)
      Checks if the type described by this instance represents type.
      Parameters:
      type - The type of interest.
      Returns:
      true if the type described by this instance represents type.