Invoke instance method of class java.lang.Object
Bytecode
Type | Description |
u1 | invokevirtual opcode = 0xDB (219) |
u1 | index |
u1 | nargs |
Stack ..., objectref, [arg1, [arg2 ...]] => ...
Description
The objectref must be of type reference
. The index operand
is an unsigned byte, and the nargs operand is an unsigned byte which must not be
zero. The index is an index into the method table of the class of the type of objectref.
If the objectref is an array type, then the method table of class Object
is used. The table entry at that index includes the method's code and its modifier
information.
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.
NullPointerException - objectref is null
The opcode of this instruction was originally invokevirtual, and it referred to
a method of the class java.lang.Object
determined dynamically to have a
method table index of 255 or less. The invokevirtualobject_quick instruction is
specifically for the benefit of arrays.
When the constant pool entry referenced by an invokevirtual instruction is resolved, a one-byte index for the method it references is generated. That index replaces the first operand byte of the original invokevirtual instruction. The second operand byte of the invokevirtual instruction is replaced by nargs, the number of argument words expected by the method.
The invokevirtualobject_quick instruction only supports a one-byte index into the method table of objectref. Objects with large numbers of methods may not be able to have all their methods referenced with _quick variants. It is always correct, if less efficient, to re-fuse to convert an instance of an invokevirtual instruction to invokevirtualobject_quick.
An invokevirtual instruction not referring to an instance
of java.lang.Object
and with operands representing a constant pool index of
255 or less will instead be converted into an invokevirtual_quick instruction. Any invokevirtual
instruction with operands representing a constant pool index greater than 255 will be
converted into an invokevirtual_quick_w instruction.