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

public sealed Interface InvokeInstruction

extends Instruction
permits BoundInvokeInterfaceInstruction, BoundInvokeInstruction, UnboundInvokeInstruction
Known Direct Implementers
jdk.internal.classfile.impl.AbstractInstruction.BoundInvokeInstruction, jdk.internal.classfile.impl.AbstractInstruction.BoundInvokeInterfaceInstruction, jdk.internal.classfile.impl.AbstractInstruction.UnboundInvokeInstruction
Imports
java.lang.classfile.CodeBuilder, .CodeElement, .CodeModel, .Instruction, .Opcode, .TypeKind, java.lang.classfile.constantpool.ClassEntry, .InterfaceMethodRefEntry, .MemberRefEntry, .MethodRefEntry, .NameAndTypeEntry, .Utf8Entry, java.lang.constant.MethodTypeDesc, jdk.internal.classfile.impl.AbstractInstruction, .TemporaryConstantPool, .Util

Models a method invocation instruction in the code array of a Code attribute, other than invokedynamic. Corresponding opcodes have a kind of Opcode.Kind#INVOKE. Delivered as a CodeElement when traversing the elements of a CodeModel.

A method invocation instruction is composite:

InvokeInstruction( Opcode opcode, MethodRefEntry | InterfaceMethodRefEntry method) )
InvokeInstruction(
    Opcode opcode,
    MethodRefEntry | InterfaceMethodRefEntry method)
)
where method must be an InterfaceMethodRefEntry for invokeinterface opcode, and must be a MethodRefEntry for invokevirtual opcode. invokestatic and invokespecial can have either type of entry for method.
Since
24
See Also
Opcode.Kind#INVOKE, CodeBuilder::invoke

Method Summary

Modifier and TypeMethod and Description
public int

Returns:

the count value of an invokeinterface instruction, or 0 for other instructions
count
()

Returns the count value of an invokeinterface instruction, or 0 for other instructions.

public boolean

Returns:

whether the class or interface holding the method is an interface
isInterface
()

Returns whether the class or interface holding the method is an interface.

public MemberRefEntry

Returns:

the MethodRefEntry or InterfaceMethodRefEntry constant described by this instruction
method
()

Returns the MethodRefEntry or InterfaceMethodRefEntry constant described by this instruction.

public default Utf8Entry

Returns:

the name of the method
name
()

Returns the name of the method.

public static InvokeInstruction

Returns:

an invocation instruction
of
(Opcode
the opcode for the specific type of invocation instruction, which must be of kind Opcode.Kind#INVOKE
op
,
MemberRefEntry
a constant pool entry describing the method
method
)

Returns an invocation instruction.

public static InvokeInstruction

Returns:

an invocation instruction
of
(Opcode
the opcode for the specific type of invocation instruction, which must be of kind Opcode.Kind#INVOKE
op
,
ClassEntry
the class holding the method
owner
,
Utf8Entry
the name of the method
name
,
Utf8Entry
the method descriptor
type
,
boolean
whether the class holding the method is an interface
isInterface
)

Returns an invocation instruction.

public static InvokeInstruction

Returns:

an invocation instruction
of
(Opcode
the opcode for the specific type of invocation instruction, which must be of kind Opcode.Kind#INVOKE
op
,
ClassEntry
the class holding the method
owner
,
NameAndTypeEntry
the name and type of the method
nameAndType
,
boolean
whether the class holding the method is an interface
isInterface
)

Returns an invocation instruction.

public default ClassEntry

Returns:

the class or interface holding the method
owner
()

Returns the class or interface holding the method.

public default Utf8Entry

Returns:

the method descriptor string of the method
type
()

Returns the method descriptor string of the method.

public default MethodTypeDesc

Returns:

a symbolic descriptor for the method type
typeSymbol
()

Returns a symbolic descriptor for the method type.

Inherited from java.lang.classfile.Instruction:
opcodesizeInBytes

Method Detail

countback to summary
public int count()

Returns the count value of an invokeinterface instruction, or 0 for other instructions.

For an invokeinterface instruction, this value must be equivalent to the sum of slot sizes of all arguments plus one, which is equal to the number of operand stack depth consumed by this interface method invocation instruction.

Returns:int

the count value of an invokeinterface instruction, or 0 for other instructions

Java Virtual Machine Specification
6.5.invokeinterface invokeinterface
isInterfaceback to summary
public boolean isInterface()

Returns whether the class or interface holding the method is an interface.

Returns:boolean

whether the class or interface holding the method is an interface

methodback to summary
public MemberRefEntry method()

Returns the MethodRefEntry or InterfaceMethodRefEntry constant described by this instruction.

Returns:MemberRefEntry

the MethodRefEntry or InterfaceMethodRefEntry constant described by this instruction

nameback to summary
public default Utf8Entry name()

Returns the name of the method.

Returns:Utf8Entry

the name of the method

ofback to summary
public static InvokeInstruction of(Opcode op, MemberRefEntry method)

Returns an invocation instruction.

Parameters
op:Opcode

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

method:MemberRefEntry

a constant pool entry describing the method

Returns:InvokeInstruction

an invocation instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#INVOKE
ofback to summary
public static InvokeInstruction of(Opcode op, ClassEntry owner, Utf8Entry name, Utf8Entry type, boolean isInterface)

Returns an invocation instruction.

Parameters
op:Opcode

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

owner:ClassEntry

the class holding the method

name:Utf8Entry

the name of the method

type:Utf8Entry

the method descriptor

isInterface:boolean

whether the class holding the method is an interface

Returns:InvokeInstruction

an invocation instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#INVOKE
ofback to summary
public static InvokeInstruction of(Opcode op, ClassEntry owner, NameAndTypeEntry nameAndType, boolean isInterface)

Returns an invocation instruction.

Parameters
op:Opcode

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

owner:ClassEntry

the class holding the method

nameAndType:NameAndTypeEntry

the name and type of the method

isInterface:boolean

whether the class holding the method is an interface

Returns:InvokeInstruction

an invocation instruction

Exceptions
IllegalArgumentException:
if the opcode kind is not Opcode.Kind#INVOKE
ownerback to summary
public default ClassEntry owner()

Returns the class or interface holding the method.

Returns:ClassEntry

the class or interface holding the method

typeback to summary
public default Utf8Entry type()

Returns the method descriptor string of the method.

API Note

A symbolic descriptor for the type of the method is available through typeSymbol().

Returns:Utf8Entry

the method descriptor string of the method

typeSymbolback to summary
public default MethodTypeDesc typeSymbol()

Returns a symbolic descriptor for the method type.

Returns:MethodTypeDesc

a symbolic descriptor for the method type