APIdia Launch Partner
Top Description Methods
java.lang.classfile.instruction

public sealed Interface ConvertInstruction

extends Instruction
permits UnboundConvertInstruction
Known Direct Implementers
jdk.internal.classfile.impl.AbstractInstruction.UnboundConvertInstruction
Imports
java.lang.classfile.CodeBuilder, .CodeElement, .CodeModel, .Instruction, .Opcode, .TypeKind, jdk.internal.classfile.impl.AbstractInstruction, .BytecodeHelpers, .Util

Models a primitive conversion instruction in the code array of a Code attribute, such as i2l. Corresponding opcodes have a kind of Opcode.Kind#CONVERT. Delivered as a CodeElement when traversing the elements of a CodeModel.

A primitive conversion instruction is composite:

ConvertInstruction( TypeKind fromType, TypeKind toType )
ConvertInstruction(
    TypeKind fromType,
    TypeKind toType
)
where these conversions are valid:
Since
24
See Also
Opcode.Kind#CONVERT, CodeBuilder::conversion

Method Summary

Modifier and TypeMethod and Description
public TypeKind

Returns:

the source type to convert from
fromType
()

Returns the source type to convert from.

public static ConvertInstruction

Returns:

a conversion instruction
of
(TypeKind
the type to convert from
fromType
,
TypeKind
the type to convert to
toType
)

Returns a conversion instruction.

public static ConvertInstruction

Returns:

a conversion instruction
of
(Opcode
the opcode for the specific type of conversion instruction, which must be of kind Opcode.Kind#CONVERT
op
)

Returns a conversion instruction.

public TypeKind

Returns:

the destination type to convert to
toType
()

Returns the destination type to convert to.

Inherited from java.lang.classfile.Instruction:
opcodesizeInBytes

Method Detail

fromTypeback to summary
public TypeKind fromType()

Returns the source type to convert from.

Returns:TypeKind

the source type to convert from

ofback to summary
public static ConvertInstruction of(TypeKind fromType, TypeKind toType)

Returns a conversion instruction. Valid conversions are:

  • Between int, long, float, and double, where fromType != toType;
  • From int to byte, char, and short.
Parameters
fromType:TypeKind

the type to convert from

toType:TypeKind

the type to convert to

Returns:ConvertInstruction

a conversion instruction

Exceptions
IllegalArgumentException:
if this is not a valid conversion
ofback to summary
public static ConvertInstruction of(Opcode op)

Returns a conversion instruction.

Parameters
op:Opcode

the opcode for the specific type of conversion instruction, which must be of kind Opcode.Kind#CONVERT

Returns:ConvertInstruction

a conversion instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#CONVERT.
toTypeback to summary
public TypeKind toType()

Returns the destination type to convert to.

Returns:TypeKind

the destination type to convert to