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

public sealed Interface DiscontinuedInstruction

extends Instruction
permits JsrInstruction, RetInstruction
Known Direct Subinterfaces
java.lang.classfile.instruction.DiscontinuedInstruction.JsrInstruction, java.lang.classfile.instruction.DiscontinuedInstruction.RetInstruction
Imports
java.lang.classfile.*, java.lang.classfile.attribute.StackMapTableAttribute, jdk.internal.classfile.impl.AbstractInstruction, .BytecodeHelpers, .Util

Marker interface for instruction discontinued from the code array of a Code attribute. Delivered as a CodeElement when traversing the elements of a CodeModel.

API Note

While most instructions have convenience factory methods in CodeBuilder, discontinued instructions can only be supplied to code builders explicitly with CodeBuilder::with to discourage their use.

Since
24
Java Virtual Machine Specification
4.9.1 Static Constraints

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
DiscontinuedInstruction.JsrInstruction

Models jump subroutine instructions discontinued from the code array of a Code attribute since class file major version 51 (JVMS 4.9.1).

public static interface
DiscontinuedInstruction.RetInstruction

Models return from subroutine instructions discontinued from the code array of a Code attribute since class file major version 51 (JVMS 4.9.1).

Method Summary

Inherited from java.lang.classfile.Instruction:
opcodesizeInBytes
java.lang.classfile.instruction back to summary

public sealed Interface DiscontinuedInstruction.JsrInstruction

extends DiscontinuedInstruction
permits BoundJsrInstruction, UnboundJsrInstruction
Known Direct Implementers
jdk.internal.classfile.impl.AbstractInstruction.BoundJsrInstruction, jdk.internal.classfile.impl.AbstractInstruction.UnboundJsrInstruction

Models jump subroutine instructions discontinued from the code array of a Code attribute since class file major version 51 (JVMS 4.9.1). Corresponding opcodes have a kind of Opcode.Kind#DISCONTINUED_JSR. Delivered as a CodeElement when traversing the elements of a CodeModel.

A jump subroutine instruction is composite:

JsrInstruction(Label target)
JsrInstruction(Label target)

Due to physical restrictions, jsr instructions cannot encode labels too far away in the list of code elements. In such cases, the ClassFile.ShortJumpsOption controls how an invalid jsr instruction model is written by a CodeBuilder.

Jump subroutine instructions push a returnAddress value to the operand stack, and astore series of instructions can then store this value to a local variable slot.

API Note

Jump subroutine instructions are discontinued to enforce verification by type checking (JVMS 4.10.1) using the StackMapTable attribute.

Since
24
See Also
Opcode.Kind#DISCONTINUED_JSR, StackMapTableAttribute

Method Summary

Modifier and TypeMethod and Description
public static DiscontinuedInstruction.JsrInstruction

Returns:

a jump subroutine instruction
of
(Opcode
the opcode for the specific type of jump subroutine instruction, which must be of kind Opcode.Kind#DISCONTINUED_JSR
op
,
Label
target label of the subroutine
target
)

Returns a jump subroutine instruction.

public static DiscontinuedInstruction.JsrInstruction

Returns:

a jump subroutine instruction
of
(Label
target label of the subroutine
target
)

Returns a jump subroutine instruction.

public Label

Returns:

the target of the jump subroutine instruction
target
()

Returns the target of the jump subroutine instruction.

Method Detail

ofback to summary
public static DiscontinuedInstruction.JsrInstruction of(Opcode op, Label target)

Returns a jump subroutine instruction.

API Note

The explicit op argument allows creating jsr_w instructions to avoid short jumps.

Parameters
op:Opcode

the opcode for the specific type of jump subroutine instruction, which must be of kind Opcode.Kind#DISCONTINUED_JSR

target:Label

target label of the subroutine

Returns:DiscontinuedInstruction.JsrInstruction

a jump subroutine instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#DISCONTINUED_JSR.
ofback to summary
public static DiscontinuedInstruction.JsrInstruction of(Label target)

Returns a jump subroutine instruction.

Parameters
target:Label

target label of the subroutine

Returns:DiscontinuedInstruction.JsrInstruction

a jump subroutine instruction

targetback to summary
public Label target()

Returns the target of the jump subroutine instruction.

Returns:Label

the target of the jump subroutine instruction

java.lang.classfile.instruction back to summary

public sealed Interface DiscontinuedInstruction.RetInstruction

extends DiscontinuedInstruction
permits BoundRetInstruction, UnboundRetInstruction
Known Direct Implementers
jdk.internal.classfile.impl.AbstractInstruction.BoundRetInstruction, jdk.internal.classfile.impl.AbstractInstruction.UnboundRetInstruction

Models return from subroutine instructions discontinued from the code array of a Code attribute since class file major version 51 (JVMS 4.9.1). Corresponding opcodes have a kind of Opcode.Kind#DISCONTINUED_RET. Delivered as a CodeElement when traversing the elements of a CodeModel.

A return from subroutine instruction is composite:

RetInstruction(int slot)
RetInstruction(int slot)
where slot must be u2.

astore series of instructions store a returnAddress value to a local variable slot, making the slot usable by a return from subroutine instruction.

API Note

Return from subroutine instructions are discontinued to enforce verification by type checking (JVMS 4.10.1) using the StackMapTable attribute.

Since
24
Java Virtual Machine Specification
6.5.ret ret
See Also
Opcode.Kind#DISCONTINUED_RET, StackMapTableAttribute

Method Summary

Modifier and TypeMethod and Description
public static DiscontinuedInstruction.RetInstruction

Returns:

a return from subroutine instruction
of
(Opcode
the opcode for the specific type of return from subroutine instruction, which must be of kind Opcode.Kind#DISCONTINUED_RET
op
,
int
the local variable slot to load return address from
slot
)

Returns a return from subroutine instruction.

public static DiscontinuedInstruction.RetInstruction

Returns:

a return from subroutine instruction
of
(int
the local variable slot to load return address from
slot
)

Returns a return from subroutine instruction.

public int

Returns:

the local variable slot with return address
slot
()

Returns the local variable slot with return address.

Method Detail

ofback to summary
public static DiscontinuedInstruction.RetInstruction of(Opcode op, int slot)

Returns a return from subroutine instruction.

slot must be u1 for ret, or u2 for wide ret.

API Note

The explicit op argument allows creating wide ret instructions with slot in the range of regular ret instructions.

Parameters
op:Opcode

the opcode for the specific type of return from subroutine instruction, which must be of kind Opcode.Kind#DISCONTINUED_RET

slot:int

the local variable slot to load return address from

Returns:DiscontinuedInstruction.RetInstruction

a return from subroutine instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#DISCONTINUED_RET or if slot is out of range
ofback to summary
public static DiscontinuedInstruction.RetInstruction of(int slot)

Returns a return from subroutine instruction.

slot must be u2.

Parameters
slot:int

the local variable slot to load return address from

Returns:DiscontinuedInstruction.RetInstruction

a return from subroutine instruction

Exceptions
IllegalArgumentException:
if slot is not u2
slotback to summary
public int slot()

Returns the local variable slot with return address. It is a u2 value.

Returns:int

the local variable slot with return address