===== 6.10 Static Field Component ===== The Static Field Component contains all of the information required to create and initialize an image of all of the static fields defined in this package, referred to as the static field image. Offsets to particular static fields are offsets into the static field image, not the Static Field Component. Final static fields of primitive types are not represented in the static field image. Instead these compile-time constants must be placed in line in Java Card technology-based instructions ("Java Card instructions"). The Static Field Component includes all information required to initialize classes. In the Java virtual machine a class is initialized by executing its ************ method. In the Java Card virtual machine the functionality of ************ methods is represented in the Static Field Component as array initialization data and non-default values of primitive types data. [[2.2.4.6_Class Initialization| Section 2.2.4.6, Class Initialization]] contains a description of the subset of ************ functionality supported in the Java Card virtual machine. The Static Field Component does not reference any other component in this CAP file. The Constant Pool Component ([[6.7_Constant Pool Component| Section 6.7, Constant Pool Component]]), Export Component ([[6.12_Export Component| Section 6.12, Export Component]]), Descriptor Component ([[6.13_Descriptor Component| Section 6.13, Descriptor Component]]), and Debug Component ([[6.14_Debug Component| Section 6.14, Debug Component]]) reference fields in the static field image defined by the Static Field Component. The ordering constraints, or segments, associated with a static field image are shown in [[6._The_CAP_File_Format| TABLE 6-14]]. Reference types occur first in the image. Arrays initialized through Java **** methods occur first within the set of reference types. Primitive types occur last in the image, and primitive types initialized to non-default values occur last within the set of primitive types. category segment content **reference** types 1 arrays of primitive types initialized by **** methods 2 **reference** types initialized to **null,** including arrays primitive types 3 primitive types initialized to default values 4 primitive types initialized to non-default values The number of bytes used to represent each field type in the static field image is shown in the following table. Type Bytes boolean 1 byte 1 short 2 int 4 reference, including arrays 2 The **static_field_component** structure is defined as: The items in the **static_field_component** structure are as follows: **tag** The **tag** item has the value **COMPONENT_StaticField** (8). **size** The ******size****** item indicates the number of bytes in the **static_field_component** structure, excluding the **tag** and ******size****** items. The value of the ******size****** item must be greater than zero. **image_size** The **image_size** item indicates the number of bytes required to represent the static fields defined in this package, excluding final static fields of primitive types. This value is the number of bytes in the static field image. The number of bytes required to represent each field type is shown in [[6._The_CAP_File_Format| TABLE 6-15]]. The value of the **image_size** item does not include the number of bytes require to represent the initial values of array instances enumerated in the Static Field Component. The value of the **image_size** is defined as: **reference_count** The **reference_count** item indicates the number of reference type static fields defined in this package. This is the number of fields represented in segments 1 and 2 of the static field image as described in [[6._The_CAP_File_Format| TABLE 6-14]]. The value of the **reference_count** item may be 0 if no reference type fields are defined in this package. Otherwise it must be equal to the number of reference type fields defined. **array_init_count** The ****array_init**_count** item indicates the number of elements in the **array_init** array. This is the number of fields represented in segment 1 of the static field image as described in [[6._The_CAP_File_Format| TABLE 6-14]]. It represents the number of arrays initialized in all of the **** methods in this package. If this CAP file defines a library package the value of **array_init_count** must be zero. **array_init[]** The **array_init** item represents an array of **array_init**_info structures that specify the initial array values of static fields of arrays of primitive types. These initial values are indicated in Java **** methods. The **array_init**_info structure is defined as: The items in the **array_init_info** structure are defined as follows: ** type** The **type** item indicates the **type** of the primitive array. Valid values are shown in the following table. Type Value boolean 2 byte 3 short 4 int 5 ** count** The **count** item indicates the number of bytes in the values array. It does not represent the number of elements in the static field array (referred to as **//length//** in the Java programming language), since the values array is an array of bytes and the static field array may be a non-byte type. The Java programming language **//length//** of the static field array is equal to the **count** item divided by the number of bytes required to represent the static field type ([[6._The_CAP_File_Format| TABLE 6-15]]) indicated by the type item. ** values** The ****values**** item represents a byte array containing the initial ****values**** of the static field array. The number of entries in the ****values**** array is equal to the size in bytes of the **type** indicated by the **type** item. The size in bytes of each **type** is shown in [[6._The_CAP_File_Format| TABLE 6-15]]. **default_value_count** The **default_value_count** item indicates the number of bytes required to initialize the set of static fields represented in segment 3 of the static field image as described in [[6._The_CAP_File_Format| TABLE 6-14]]. These static fields are primitive types initialized to default values. The number of bytes required to initialize each static field type is equal to the size in bytes of the type as shown in [[6._The_CAP_File_Format| TABLE 6-15]]. **non_default_value_count** The **non_default_value_count** item represents the number bytes in the **non_default_values** array. This value is equal to the number of bytes in segment 4 of the static field image as described in [[6._The_CAP_File_Format| TABLE 6-14]]. These static fields are primitive types initialized to non-default values. **non_default_values[]** The ****non_default_values**** item represents an array of bytes of non-default initial values. This is the exact image of segment 4 of the static field image as described in [[6._The_CAP_File_Format| TABLE 6-14]]. The number of entries in the ****non_default_values**** array for each static field type is equal to the size in bytes of the type as shown in [[6._The_CAP_File_Format| TABLE 6-15]]. The value of a **boolean** type is **1** to represent true and **0** to represent false.