Interface TypeDefinition

    • Field Detail

      • RAW_TYPES_PROPERTY

        static final java.lang.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:
        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 an IllegalStateException to be thrown.
        Returns:
        The erasure of this type.
      • getDeclaredMethods

        MethodList<?> getDeclaredMethods()
        Returns the methods that this type declares.
        Returns:
        The methods that this type declares.
      • 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 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​(java.lang.reflect.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.