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

public sealed Interface BranchInstruction

extends Instruction
permits BoundBranchInstruction, UnboundBranchInstruction
Known Direct Implementers
jdk.internal.classfile.impl.AbstractInstruction.BoundBranchInstruction, jdk.internal.classfile.impl.AbstractInstruction.UnboundBranchInstruction
Imports
java.lang.classfile.*, jdk.internal.classfile.impl.AbstractInstruction, .Util

Models a branching instruction (conditional or unconditional) in the code array of a Code attribute. Corresponding opcodes have a kind of Opcode.Kind#BRANCH. Delivered as a CodeElement when traversing the elements of a CodeModel.

A branch instruction is composite:

BranchInstruction( Opcode opcode, Label target )
BranchInstruction(
    Opcode opcode,
    Label target
)

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

Since
24
See Also
Opcode.Kind#BRANCH, CodeBuilder::branch, ClassFile.ShortJumpsOption

Method Summary

Modifier and TypeMethod and Description
public static BranchInstruction

Returns:

a branch instruction
of
(Opcode
the opcode for the specific type of branch instruction, which must be of kind Opcode.Kind#BRANCH
op
,
Label
the target of the branch
target
)

Returns a branch instruction.

public Label

Returns:

the branch target of this instruction
target
()

Returns the branch target of this instruction.

Inherited from java.lang.classfile.Instruction:
opcodesizeInBytes

Method Detail

ofback to summary
public static BranchInstruction of(Opcode op, Label target)

Returns a branch instruction.

Parameters
op:Opcode

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

target:Label

the target of the branch

Returns:BranchInstruction

a branch instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#BRANCH
targetback to summary
public Label target()

Returns the branch target of this instruction.

Returns:Label

the branch target of this instruction