APIdia Launch Partner
Top Description Fields Constructors Methods
java.lang.classfile

public final Enum TypeKind

extends Enum<TypeKind>
Class Inheritance
Imports
java.lang.classfile.instruction.DiscontinuedInstruction, .LoadInstruction, .NewPrimitiveArrayInstruction, .StoreInstruction, java.lang.constant.ClassDesc, .ConstantDescs, java.lang.invoke.TypeDescriptor, jdk.internal.vm.annotation.Stable

Describes the data types Java Virtual Machine operates on. This omits returnAddress (JVMS 2.3.3) and includes void (JVMS 4.3.3), which appears as a method return type.

The returnAddress type is only used by discontinued jump subroutine and return from subroutine instructions. Jump subroutine instructions push returnAddress to the operand stack; astore instructions store returnAddress from the operand stack to local variables; return from subroutine instructions load returnAddress from local variables.

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.
Since
24
Java Virtual Machine Specification
2.2 Data Types, 2.11.1 Types and the Java Virtual Machine

Field Summary

Modifier and TypeField and Description
public static final TypeKind
BOOLEAN

The primitive type boolean.

public static final TypeKind
BYTE

The primitive type byte.

public static final TypeKind
CHAR

The primitive type char.

public static final TypeKind
DOUBLE

The primitive type double.

public static final TypeKind
FLOAT

The primitive type float.

public static final TypeKind
INT

The primitive type int.

public static final TypeKind
LONG

The primitive type long.

private final int
public static final TypeKind
REFERENCE

A reference type.

public static final TypeKind
SHORT

The primitive type short.

private final int
private ClassDesc
public static final TypeKind
VOID

The void type, for absence of a value.

Constructor Summary

AccessConstructor and Description
private
TypeKind(int slots, int newarrayCode)

Method Summary

Modifier and TypeMethod and Description
public TypeKind

Returns:

the computational type for this type, or void for void
asLoadable
()

Returns the computational type for this type, or void for void.

private ClassDesc
public static TypeKind

Returns:

the type associated with the specified field descriptor
from
(TypeDescriptor.OfField<?>
the field descriptor
descriptor
)

Returns the type associated with the specified field descriptor.

public static TypeKind

Returns:

the type associated with the specified field descriptor
fromDescriptor
(CharSequence
the field descriptor
s
)

Returns the type associated with the specified field descriptor.

public static TypeKind

Returns:

the component type described by the array code used as an operand to newarray
fromNewarrayCode
(int
the operand of the newarray instruction
newarrayCode
)

Returns the component type described by the array code used as an operand to newarray.

public int

Returns:

the code used by the newarray instruction to create an array of this component type, or -1 if this type is not supported by newarray
newarrayCode
()

Returns the code used by the newarray instruction to create an array of this component type, or -1 if this type is not supported by newarray.

public int

Returns:

the number of local variable index or operand stack depth consumed by this type
slotSize
()

Returns the number of local variable index or operand stack depth consumed by this type.

public ClassDesc

Returns:

the most specific upper bound field descriptor that can store any value of this type
upperBound
()

Returns the most specific upper bound field descriptor that can store any value of this type.

public static TypeKind
public static TypeKind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

BOOLEANback to summary
public static final TypeKind BOOLEAN

The primitive type boolean. Its computational type is int. 0 represents false, and 1 represents true. It is zero-extended to an int when loaded onto the operand stack and narrowed by taking the bitwise AND with 1 when stored.

Java Virtual Machine Specification
2.3.4 The boolean Type
BYTEback to summary
public static final TypeKind BYTE

The primitive type byte. Its computational type is int. It is sign-extended to an int when loaded onto the operand stack and truncated when stored.

CHARback to summary
public static final TypeKind CHAR

The primitive type char. Its computational type is int. It is zero-extended to an int when loaded onto the operand stack and truncated when stored.

DOUBLEback to summary
public static final TypeKind DOUBLE

The primitive type double. It is of category 2. All NaN values of double may or may not be collapsed into a single "canonical" NaN value in loading and storing.

FLOATback to summary
public static final TypeKind FLOAT

The primitive type float. All NaN values of float may or may not be collapsed into a single "canonical" NaN value in loading and storing.

INTback to summary
public static final TypeKind INT

The primitive type int.

LONGback to summary
public static final TypeKind LONG

The primitive type long. It is of category 2.

newarrayCodeback to summary
private final int newarrayCode
REFERENCEback to summary
public static final TypeKind REFERENCE

A reference type.

Java Virtual Machine Specification
2.4 Reference Types and Values
SHORTback to summary
public static final TypeKind SHORT

The primitive type short. Its computational type is int. It is sign-extended to an int when loaded onto the operand stack and truncated when stored.

slotsback to summary
private final int slots
upperBoundback to summary
private ClassDesc upperBound
Annotations
@Stable
VOIDback to summary
public static final TypeKind VOID

The void type, for absence of a value. While this is not a data type, this can be a method return type indicating no change in operand stack depth.

Java Virtual Machine Specification
4.3.3 Method Descriptors

Constructor Detail

TypeKindback to summary
private TypeKind(int slots, int newarrayCode)

Method Detail

asLoadableback to summary
public TypeKind asLoadable()

Returns the computational type for this type, or void for void.

Returns:TypeKind

the computational type for this type, or void for void

See Also
LoadInstruction, StoreInstruction
fetchUpperBoundback to summary
private ClassDesc fetchUpperBound()
fromback to summary
public static TypeKind from(TypeDescriptor.OfField<?> descriptor)

Returns the type associated with the specified field descriptor.

Parameters
descriptor:TypeDescriptor.OfField<?>

the field descriptor

Returns:TypeKind

the type associated with the specified field descriptor

fromDescriptorback to summary
public static TypeKind fromDescriptor(CharSequence s)

Returns the type associated with the specified field descriptor.

Parameters
s:CharSequence

the field descriptor

Returns:TypeKind

the type associated with the specified field descriptor

Exceptions
IllegalArgumentException:
only if the descriptor is not valid
fromNewarrayCodeback to summary
public static TypeKind fromNewarrayCode(int newarrayCode)

Returns the component type described by the array code used as an operand to newarray.

Parameters
newarrayCode:int

the operand of the newarray instruction

Returns:TypeKind

the component type described by the array code used as an operand to newarray

Exceptions
IllegalArgumentException:
if the code is invalid
Java Virtual Machine Specification
6.5.newarray newarray
See Also
NewPrimitiveArrayInstruction, newarrayCode()
newarrayCodeback to summary
public int newarrayCode()

Returns the code used by the newarray instruction to create an array of this component type, or -1 if this type is not supported by newarray.

Returns:int

the code used by the newarray instruction to create an array of this component type, or -1 if this type is not supported by newarray

Java Virtual Machine Specification
6.5.newarray newarray
See Also
NewPrimitiveArrayInstruction, fromNewarrayCode(int)
slotSizeback to summary
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 pop versus pop2.

Returns:int

the number of local variable index or operand stack depth consumed by this type

Java Virtual Machine Specification
2.6.1 Local Variables, 2.6.2 Operand Stacks
upperBoundback to summary
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:ClassDesc

the most specific upper bound field descriptor that can store any value of this type

valueOfback to summary
public static TypeKind valueOf(String name)
valuesback to summary
public static TypeKind[] values()