Enum Class TypeKind

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

public enumTypeKindextendsEnum<TypeKind>
Describes the data types Java Virtual Machine operates on. This omitsreturnAddress (JVMS2.3.3) and includesvoid (JVMS4.3.3), which appears as a method return type.

ThereturnAddress type is only used by discontinuedjump subroutine andreturn from subroutineinstructions. Jump subroutine instructions pushreturnAddress to theoperand stack;astore instructions storereturnAddress from the operand stack to local variables; return fromsubroutine instructions loadreturnAddress from local variables.

Computational Type

In theclass file format, local variables (JVMS2.6.1),and the operand stack (JVMS2.6.2) of the Java Virtual Machine,boolean,byte,char,short types do not exist and arerepresented by theint computational type.int,float,reference,returnAddress,long, anddouleare the computational types of the Java Virtual Machine.
SeeJava Virtual Machine Specification:
2.2 Data Types
2.11.1 Types and the Java Virtual Machine
Since:
24
  • Enum Constant Details

    • BOOLEAN

      public static final TypeKind BOOLEAN
      The primitive typeboolean. Itscomputational type isint.0 representsfalse,and1 representstrue. It is zero-extended to anintwhen loaded onto the operand stack and narrowed by taking the bitwise ANDwith1 when stored.
      SeeJava Virtual Machine Specification:
      2.3.4 Theboolean Type
    • BYTE

      public static final TypeKind BYTE
      The primitive typebyte. Itscomputational type isint. It is sign-extended to anint when loaded onto the operand stack and truncated whenstored.
    • CHAR

      public static final TypeKind CHAR
      The primitive typechar. Itscomputational type isint. It is zero-extended to anint when loaded onto the operand stack and truncated whenstored.
    • SHORT

      public static final TypeKind SHORT
      The primitive typeshort. Itscomputational type isint. It is sign-extended to anint when loaded onto the operand stack and truncated whenstored.
    • INT

      public static final TypeKind INT
      The primitive typeint.
    • LONG

      public static final TypeKind LONG
      The primitive typelong. It is ofcategory 2.
    • FLOAT

      public static final TypeKind FLOAT
      The primitive typefloat. All NaN values offloat may ormay not be collapsed into a single"canonical" NaNvalue in loading and storing.
    • DOUBLE

      public static final TypeKind DOUBLE
      The primitive typedouble. It is ofcategory 2. All NaN values ofdouble may or may not becollapsed into a single"canonical" NaN valuein loading and storing.
    • REFERENCE

      public static final TypeKind REFERENCE
      A reference type.
      SeeJava Virtual Machine Specification:
      2.4 Reference Types and Values
    • VOID

      public static final TypeKind VOID
      Thevoid type, for absence of a value. While this is not a data type,this can be a method return type indicating no change inoperand stack depth.
      SeeJava Virtual Machine Specification:
      4.3.3 Method Descriptors
  • Method Details

    • values

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

      public static TypeKind valueOf(String name)
      Returns the enum constant of this class with the specified name.The string must matchexactly an identifier used to declare anenum 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 valueof this type. This is the primitive class descriptor for primitive types andvoid andObject descriptor forreference.
      Returns:
      the most specific upper bound field descriptor that can store any valueof this type
    • newarrayCode

      public int newarrayCode()
      Returns the code used by thenewarray instruction to create an arrayof this component type, or-1 if this type is not supported bynewarray.
      Returns:
      the code used by thenewarray instruction to create an arrayof this component type, or-1 if this type is not supported bynewarray
      SeeJava Virtual Machine Specification:
      6.5.newarraynewarray
      See Also:
    • 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 withoutregard to type (JVMS2.11.1), such aspop versuspop2.
      Returns:
      the number of local variable index or operand stack depth consumed by this type
      SeeJava Virtual Machine Specification:
      2.6.1 Local Variables
      2.6.2 Operand Stacks
    • asLoadable

      public TypeKind asLoadable()
      Returns thecomputational type for this type, orvoidforvoid.
      Returns:
      thecomputational type for this type, orvoidforvoid
      See Also:
    • fromNewarrayCode

      public static TypeKind fromNewarrayCode(int newarrayCode)
      Returns the component type described by the array code used as an operand tonewarray.
      Parameters:
      newarrayCode - the operand of thenewarray instruction
      Returns:
      the component type described by the array code used as an operand tonewarray
      Throws:
      IllegalArgumentException - if the code is invalid
      SeeJava Virtual Machine Specification:
      6.5.newarraynewarray
      See Also:
    • fromDescriptor

      public static TypeKind 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 TypeKind 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