Site Tools


Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing


7.5.55 invokespecial

Invoke instance method; special handling for superclass, private, and instance initialization method invocations






invokespecial = 140 (0x8c)


…, objectref, [arg1, [arg2 …]] → …


The unsigned indexbyte1 and indexbyte2 are used to construct an index into the constant pool of the current package ( Section 3.5, Frames), where the value of the index is (indexbyte1 , a class or interface initialization method. If the method is , an instance initialization method, then the method must only be invoked once on an uninitialized object, and before the first backward branch following the execution of the new instruction that allocated the object. Finally, if the resolved method is protected, and it is a member of a superclass of the current class, and the method is not declared in the same package as the current class, then the class of objectref must be either the current class or a subclass of the current class.

The resolved method includes the code for the method, an unsigned byte nargs that must not be zero, and the method's modifier information.

The objectref must be of type reference, and must be followed on the operand stack by nargs - 1 words of arguments, where the number of words of arguments and the type and order of the values they represent must be consistent with those of the selected instance method.

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 arguments are made the values of its first nargs words of 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 Card 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.

Runtime Exception

If objectref is null, the invokespecial instruction throws a NullPointerException.

javacard/jcvm/7.5.55_invokespecial.txt · Last modified: 2017/05/13 04:09 (external edit)