Contents | Prev | Next | Index | The JavaTM Virtual Machine Specification |
instanceof_quick | |
indexbyte1 | |
indexbyte2 |
Forms
instanceof_quick = 225 (0xe1)
Stack
..., objectref ..., result
Description
The objectref, which must be of type reference
, is popped from the operand stack. The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The class at that index of the constant pool must have already been successfully resolved and may be a class, array, or interface.
If objectref is not null
and is an instance of the resolved class, array, or interface, the instanceof_quick instruction pushes an int
result of 1 as an int on the operand stack. Otherwise, it pushes an int
result of 0.
The following rules are used to determine whether an objectref that is not null
is an instance of the resolved type: If S is the class of the object referred to by objectref and T is the resolved class, array, or instance type, instanceof_quick determines whether objectref is an instance of T as follows:
[]
, that is, an array of components of type SC, then:
Object
(§2.4.6).
[]
, that is, an array of components of type TC, then one of the following must be true:
Notes
The opcode of this instruction was originally instanceof. The operands of the instanceof instruction are not modified.
invokeinterface_quick invokeinterface_quick
Operation
Invoke interface method
invokeinterface_quick | |
idbyte1 | |
idbyte2 | |
nargs | |
guess |
Forms
invokeinterface_quick = 218 (0xda)
Stack
..., objectref, [arg1, [arg2 ...]] ...
Description
The unsigned idbyte1 and idbyte2 are used to construct an identifier for the name and descriptor (§4.3.3) 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 ((see Table 4.4, "Method access and modifier flags"). The method table entry must be that of a public
method.
invokeinterface_quick (cont.) invokeinterface_quick (cont.)
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.
Linking Exceptions
If no method matching the resolved name and descriptor can be found in the class of objectref, invokeinterface_quick throws an IncompatibleClassChangeError
.
Otherwise, if the selected method is a class (static
) method, the invokeinterface_quick instruction throws an IncompatibleClassChangeError
.
Otherwise, if the selected method is not public
, the in-vokeinterface_quick instruction throws an IllegalAccess-Error
.
Otherwise, if the selected method is abstract
, invoke-interface_quick throws an AbstractMethodError
.
Otherwise, if the selected method is native
and the code that implements the method cannot be loaded or linked, invoke-interface_quick throws an UnsatisfiedLinkError
.
invokeinterface_quick (cont.) invokeinterface_quick (cont.)
Runtime Exception
Otherwise, if objectref is null
, the invokeinterface_quick instruction throws a NullPointerException
.
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.
invokenonvirtual_quick invokenonvirtual_quick
Operation
Invoke an instance initialization method or a private method, dispatching based on compile-time type
invokenonvirtual_quick | |
indexbyte1 | |
indexbyte2 |
Forms
invokenonvirtual_quick = 215 (0xd7)
Stack
..., objectref, [arg1, [arg2 ...]] ...
Description
The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The constant pool item at the index must be a CONSTANT_Methodref
(§4.4.2) which must already have been resolved successfully. The constant pool entry representing the resolved method includes a direct reference to the code for the method, an unsigned byte nargs which must be greater than zero, and the method's modifier information (see Table 4.4, "Method access and modifier flags").
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
, 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.
invokenonvirtual_quick (cont.) invokenonvirtual_quick (cont.)
Runtime Exception
If objectref is null
, the invokenonvirtual_quick instruction throws a NullPointerException
.
Notes
The opcode of this instruction was originally invokespecial, and the method it invoked was determined dynamically to be either an instance initialization method <init>
or a private
method. The operands of the invokespecial instruction are not modified.
The difference between the invokenonvirtual_quick and the in-vokevirtual_quick_w instructions is that invokevirtual_quick_w invokes a method based on the actual (runtime) type of the object. The invokenonvirtual_quick instruction invokes an instance initialization method or private
method based on the compile-time type of the object.
invokesuper_quick invokesuper_quick
Operation
Invoke a superclass method, dispatching based on compile-time type
invokesuper_quick | |
indexbyte1 | |
indexbyte2 |
Forms
invokesuper_quick = 216 (0xd8)
Stack
..., objectref, [arg1, [arg2 ...]] ...
Description
The unsigned indexbyte1 and indexbyte2 are used to construct an index into the method table of the superclass of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The specified method table entry includes a direct reference to the code for the method, an unsigned byte nargs which must be greater than zero, and the method's modifier information (see Table 4.4, "Method access and modifier flags").
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
, 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.
invokesuper_quick (cont.) invokesuper_quick (cont.)
Runtime Exception
If objectref is null
, the invokesuper_quick instruction throws a NullPointerException
.
Notes
The opcode of this instruction was originally invokespecial, and the method it invoked was determined dynamically to be a method in a superclass of the current object. The operands of the invokespecial instruction are not modified.
The difference between the invokesuper_quick and the invokevirtual_quick_w instructions is that invokevirtual_quick_w invokes a method based on the class of the object. The invokesuper_quick instruction is used to invoke methods in a superclass of the current class.
The invokesuper_quick instruction was introduced in Sun's JDK 1.0.2 release to fix a bug in earlier versions of the Java Virtual Machine. Prior to that release, the invokespecial instruction (then named invokenonvirtual) would always be converted to the invokenonvirtual_quick instruction.
invokestatic_quick invokestatic_quick
Operation
Invoke a class (static) method
invokestatic_quick | |
indexbyte1 | |
indexbyte2 |
Forms
invokestatic_quick = 217 (0xd9)
Stack
..., [arg1, [arg2 ...]] ...
Description
The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the value of the index is (indexbyte1 << 8) | indexbyte2. The constant pool item at the index must be a CONSTANT_Methodref
(§4.4.2) which must already have been resolved successfully.
The constant pool entry representing the resolved method includes a direct reference to the code for the method, an unsigned byte nargs which may be zero, and the method's modifier information (see Table 4.4, "Method access and modifier flags").
If the method is synchronized
, the monitor associated with the current class is acquired.
If the method is not native
, the nargs words of arguments are popped from the operand stack. A new stack frame is created for the method being invoked, and the words of arguments are made the values of its first nargs local variables, with arg1 in local variable 0, arg2 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
, the nargs words of arguments are popped from the operand stack; the code that implements the method is invoked in an implementation-dependent manner.
Notes
The opcode of this instruction was originally invokestatic. The operands of the invokestatic instruction are not modified.
invokevirtual_quick invokevirtual_quick
Operation
Invoke instance method
invokevirtual_quick | |
index | |
nargs |
Forms
invokevirtual_quick = 214 (0xd6)
Stack
..., objectref, [arg1, [arg2 ...]] ...
Description
The objectref must be of type reference
and must reference a class instance. 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. The table entry at that index includes the method's code and its modifier information (see Table 4.4, "Method access and modifier flags").
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.
invokevirtual_quick (cont.) invokevirtual_quick (cont.)
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.
Linking Exception
If the specified method is native
and the code that implements the method cannot be loaded or linked, the invokevirtual_quick instruction throws an UnsatisfiedLinkError
.
Runtime Exception
Otherwise, if objectref is null
, the invokevirtual_quick instruction throws a NullPointerException
.
Notes
The opcode of this instruction was originally invokevirtual, with objectref not referring to an instance of java.lang.Object
and with operands determined dynamically to represent a method with a method table index of 255 or less. 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.
An invokevirtual instruction 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 invokevirtualobject_quick instruction. Any invokevirtual instruction with operands representing a constant pool index greater than 255 will be converted into an invokevirtual_quick_w instruction.
invokevirtual_quick_w invokevirtual_quick_w
Operation
Invoke instance method
invokevirtual_quick_w | |
indexbyte1 | |
indexbyte2 |
Forms
invokevirtual_quick_w = 226 (0xe2)
Stack
..., objectref, [arg1, [arg2 ...]] ...
Description
The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current class (§3.6), where the index is (indexbyte1 << 8) | indexbyte2. The constant pool item at the index must be a CONSTANT_Methodref
(§4.4.2) which must already have been resolved successfully. The constant pool entry representing the resolved method includes an unsigned index into the method table of the resolved class and an unsigned byte nargs which must not be zero.
The objectref must be of type reference
. The index is used as 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 (see Table 4.4, "Method access and modifier flags").
If the method is synchronized
, the monitor associated with objectref is acquired.
invokevirtual_quick_w (cont.) invokevirtual_quick_w (cont.)
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.
Linking Exception
If the specified method is native
and the code that implements the method cannot be loaded or linked, the invokevirtual_quick_w instruction throws an UnsatisfiedLinkError
.
Runtime Exception
Otherwise, if objectref is null
, the invokevirtual_quick_w instruction throws a NullPointerException
.
Notes
The opcode of this instruction was originally invokevirtual, with operands determined dynamically to represent a method with a method table index greater than 255. The operands of the invokevirtual instruction are not modified.
The invokevirtual_quick and invokevirtualobject_quick instructions only support a one-byte offset into the method table of objectref. The invokevirtual_quick_w instruction can be used to for invocations of methods that cannot be represented using invokevirtual_quick.
invokevirtualobject_quick invokevirtualobject_quick
Operation
Invoke instance method
invokevirtualobject_quick | |
index | |
nargs |
java.lang.Object
Forms
invokevirtualobject_quick = 219 (0xdb)
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 (see Table 4.4, "Method access and modifier flags").
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.
invokevirtualobject_quick (cont.) invokevirtualobject_quick (cont.)
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.
Linking Exception
If the specified method is native
and the code that implements the method cannot be loaded or linked, invokevirtual_quick throws an UnsatisfiedLinkError
.
Runtime Exception
Otherwise, if objectref is null
, the invokevirtualobject_quick instruction throws a NullPointerException
.
Notes
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.
Contents | Prev | Next | Index
Java Virtual Machine Specification (HTML generated by chsieh on March 13, 1997)
Copyright © 1996, 1997 Sun Microsystems, Inc.
All rights reserved
Please send any comments or corrections to doug.kramer@sun.com