invokeinterface_quick

Invoke interface method

Bytecode

Type Description
u1 invokeinterface_quick opcode = 0xDA (218)
u2 id
u1 <nargs>
u1 guess

Stack ..., objectref, [arg1, [arg2 ...]] => ...

Description

The unsigned idbyte1 and idbyte2 are used to construct an identifier for the name and descriptor of the desired method, where the value of the identifier is (idbyte1 << 8) | idbyte2.

The nargs operand is an unsigned byte which must not be zero. The objectref must be of type reference and must be followed on the operands stack by nargs - 1 words of arguments. The method table of the class of the type of objectref is determined. If objectref is an array type, then the method table of class Object is used.

The unsigned guess is used to index into the method table. If there is a method at index guess, and if its identifier is identical to the constructed identifier, then that method is selected. Otherwise, the method table is searched for a method whose identifier is identical to the constructed identifier. If one is found, the current value of guess is overwritten by that index.

The result of the search is a method table entry, which includes a direct reference to the code for the interface method and the method's modifier information. The method table entry must be that of a public method.

If the method is synchronized, the monitor associated with objectref is acquired.

If the method is not native, the nargs - 1 words of arguments and objectref are popped from the operand stack. A new stack frame is created for the method being invoked, and objectref and the words of arguments are made the values of its first nargs local variables, with objectref in local variable 0, arg1 in local variable 1, and so on. The new stack frame is then made current, and the Java Virtual Machine pc is set to the opcode of the first instruction of the method to be invoked. Execution continues with the first instruction of the method.

If the method is native and the platform-dependent code that implements it has not yet been loaded and linked into the Java Virtual Machine, that is done. The nargs - 1 words of arguments and objectref are popped from the operand stack; the code that implements the method is invoked in an implementation-dependent manner.

Exceptions

NullPointerException - objectref is null

StackOverflowError - no more space in callstack for a new stack frame

Notes

The opcode of this instruction was originally invokeinterface. The initial value of guess is 0, the operand value supplied by invokeinterface. The identifiers being compared and stored in the invokeinterface_quick instruction encode a method name and descriptor as a 16-bit quantity that can be compared quickly. The details of the encoding are implementation-specific. The bytes of the identifier for the method being invoked, idbyte1 and idbyte2, replace the original constant pool index bytes. The identifier can be calculated when each method is loaded, or at run time. The value of the nargs operand is not modified.