Site Tools


Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcvm:7.5.22_getfield_t_w

7.5.22 getfield_<t>_w

Fetch field from object (wide index)

Format

getfieldw indexbyte1 indexbyte2 Forms getfield_a_w = 169 (0xa9) getfield_b_w = 170 (0xaa) getfield_s_w = 171 (0xab) getfield_i_w = 172 (0xac) Stack …, objectref → …, value OR …, objectref → …, value.word1, value.word2 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 package ( Section 3.5, Frames), where the value of the index is (indexbyte1 « 8) | indexbyte2. 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 item must resolve to a field of type reference. 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. 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 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>[7]</SUP>. The value at that offset into the class instance referenced by objectref is fetched. If the value is of type byte or type boolean, it is sign-extended to a short. The value is pushed onto the operand stack. Runtime Exception If objectref is null, the getfieldw instruction throws a NullPointerException.

Notes

In some circumstances, the getfield__w 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 getfield_i_w instruction will not be available.

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