Site Tools


Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcvm:5.8_fields

5.8 Fields

Each field is described by a variable-length field_info structure. The format of this structure is:

The items of the field_info structure are as follows:

token

The token item is the token assigned to this field. There are three scopes for field tokens: final static fields of primitive types (compile-time constants), all other static fields, and instance fields.

If this field is a compile-time constant, the value of the token item is 0xFF. Compile-time constants are represented in export files, but are not assigned token values suitable for late binding. Instead Java Card Converters must replace bytecodes that reference final static fields with bytecodes that load the constant value of the field.<SUP>[4]</SUP>

If this field is static, but is not a compile-time constant, the token item represents a static field token ( Section 4.3.7.3, Static Fields).

If this field is an instance field, the token item represents an instance field token ( Section 4.3.7.5, Instance Fields).

access_flags

The value of the access_flags item is a mask of modifiers used with fields. The access_flags modifiers are shown in the following table.

Name

Value

Meaning

Used By

ACC_PUBLIC

0x0001

Is public; may be accessed from outside its package.

Any field

ACC_PROTECTED

0x0004

Is protected; may be accessed within subclasses.

Class field

Instance field

ACC_STATIC

0x0008

Is static.

Class field

Interface field

ACC_FINAL

0x0010

Is final; no further overriding or assignment after initialization.

Any field

Field access and modifier flags are defined in the same way and with the same restrictions as described in The Java Virtual Machine Specification.

Since all fields represented in an export file are either public or protected, exactly one of the ACC_PUBLIC or ACC_PROTECTED flag must be set.

The Java Card virtual machine reserves all other flag values. Their values must be zero.

name_index

The value of the name_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Utf8_info ( Section 5.6.4, CONSTANT_Utf8) structure representing a valid Java field name stored as a simple (not fully qualified) name, that is, as a Java identifier.

descriptor_index

The value of the descriptor_index item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Utf8_info ( Section 5.6.4, CONSTANT_Utf8) structure representing a valid Java field descriptor.

Representation of a field descriptor in an export file is the same as in a Java class file. See the specification described in The Java Virtual Machine Specification (&#167;4.3.2).

If this field is a reference-type, the class referenced must be a public class.

attributes_count

The value of the attributes_count item indicates the number of additional attributes of this field. The only field_info attribute currently defined is the ConstantValue attribute ( Section 5.**1****0**.**1**, **ConstantValue** Attribute). For static final fields of primitive types, the value must be 1; that is, when both the ACC_STATIC and ACC_FINAL bits in the flags item are set an attribute must be present. For all other fields the value of the attributes_count item must be 0.

attributes[]

The only attribute defined for the attributes table of a field_info structure by this specification is the ConstantValue attribute ( Section 5.10.1, ConstantValue Attribute). This must be defined for static final fields of primitive types (boolean, byte, short, and int).

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