Enum Class TypeKind

java.lang.Object
java.lang.Enum<TypeKindPREVIEW>
java.lang.classfile.TypeKind
All Implemented Interfaces:
Serializable, Comparable<TypeKindPREVIEW>, Constable

public enum TypeKind extends Enum<TypeKindPREVIEW>
TypeKind is a preview API of the Java platform.
Programs can only use TypeKind when preview features are enabled.
Preview features may be removed in a future release, or upgraded to permanent features of the Java platform.
Describes the data types Java Virtual Machine operates on. This omits returnAddress (JVMS 2.3.3), which is only used by discontinued jsrPREVIEW and retPREVIEW instructions, and includes void (JVMS 4.3.3), which appears as a method return type.

Computational Type

In the class file format, local variables (JVMS 2.6.1), and the operand stack (JVMS 2.6.2) of the Java Virtual Machine, boolean, byte, char, short types do not exist and are represented by the int computational type. int, float, reference, returnAddress, long, and doule are the computational types of the Java Virtual Machine.
See Java Virtual Machine Specification:
2.2 Data Types
2.11.1 Types and the Java Virtual Machine
Since:
22
  • Enum Constant Details

  • Method Details

    • values

      public static TypeKindPREVIEW[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static TypeKindPREVIEW valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • upperBound

      public ClassDesc upperBound()
      Returns the most specific upper bound field descriptor that can store any value of this type. This is the primitive class descriptor for primitive types and void and Object descriptor for reference.
      Returns:
      the most specific upper bound field descriptor that can store any value of this type
    • newarrayCode

      public int newarrayCode()
      Returns the code used by the newarrayPREVIEW instruction to create an array of this component type, or -1 if this type is not supported by newarray.
      Returns:
      the code used by the newarrayPREVIEW instruction to create an array of this component type, or -1 if this type is not supported by newarray
      See Java Virtual Machine Specification:
      6.5.newarray newarray
      Since:
      23
    • slotSize

      public int slotSize()
      Returns the number of local variable index or operand stack depth consumed by this type. This is also the category of this type for instructions operating on the operand stack without regard to type (JVMS 2.11.1), such as popPREVIEW versus pop2PREVIEW.
      Returns:
      the number of local variable index or operand stack depth consumed by this type
      See Java Virtual Machine Specification:
      2.6.1 Local Variables
      2.6.2 Operand Stacks
    • asLoadable

      public TypeKindPREVIEW asLoadable()
      Returns the computational type for this type, or void for void.
      Returns:
      the computational type for this type, or void for void
    • fromNewarrayCode

      public static TypeKindPREVIEW fromNewarrayCode(int newarrayCode)
      Returns the component type described by the array code used as an operand to newarrayPREVIEW.
      Parameters:
      newarrayCode - the operand of the newarray instruction
      Returns:
      the component type described by the array code used as an operand to newarrayPREVIEW
      Throws:
      IllegalArgumentException - if the code is invalid
      See Java Virtual Machine Specification:
      6.5.newarray newarray
      Since:
      23
    • fromDescriptor

      public static TypeKindPREVIEW fromDescriptor(CharSequence s)
      Returns the type associated with the specified field descriptor.
      Parameters:
      s - the field descriptor
      Returns:
      the type associated with the specified field descriptor
      Throws:
      IllegalArgumentException - only if the descriptor is not valid
    • from

      public static TypeKindPREVIEW from(TypeDescriptor.OfField<?> descriptor)
      Returns the type associated with the specified field descriptor.
      Parameters:
      descriptor - the field descriptor
      Returns:
      the type associated with the specified field descriptor