Site Tools


Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing


7.5.76 putfield_<t>_this

Set field in current object


putfieldthis index Forms putfield_a_this = 181 (0xb5) putfield_b_this = 182 (0xb6) putfield_s_this = 183 (0xb7) putfield_i_this = 184 (0xb8) Stack …, value → … OR …, value.word1, value.word2 → … Description The currently executing method must be an instance method that was invoked using the invokevirtual, invokeinterface or invokespecial instruction. The local variable at index 0 must contain a reference objectref to the currently executing method's this parameter. The unsigned index is used as an index into the constant pool of the current package ( Section 3.5, Frames). The constant pool item at the index must be of type CONSTANT_InstanceFieldref ( Section 6.7.2, CONSTANT_InstanceFieldref, CONSTANT_VirtualMethodref, and CONSTANT_SuperMethodref), a reference to a class and a field token. The class of objectref must not be an array. If the field is protected, and it is a member of a superclass of the current class, and the field 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. If the field is final, it must be declared in the current class. The item must resolve to a field with a type that matches t, as follows: *a field must be of type reference *b field must be of type byte or type boolean *s field must be of type short *i field must be of type int value must be of a type that is assignment compatible with the field descriptor (t) type. The width of a field in a class instance is determined by the field type specified in the instruction. The item is resolved, determining the field offset<SUP>[11]</SUP>. The value is popped from the operand stack. If the field is of type byte or type boolean, the value is truncated to a byte. The field at the offset from the start of the object referenced by objectref is set to the value. Runtime Exception If objectref is null, the putfieldthis instruction throws a NullPointerException.


In some circumstances, the putfield__this instruction may throw a SecurityException if the current context ( Section 3.4, Contexts) is not the owning context ( Section 3.4, Contexts) of the object referenced by objectref. The exact circumstances when the exception will be thrown are specified in Chapter 6 of the Runtime Environment Specification, Java Card Platform, Version 2.2.2.

If a virtual machine does not support the int data type, the putfield_i_this instruction will not be available.

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