Site Tools

Sidebar

Smart Card Solution

User Manual

JavaCard API Samples

Java Card Specification

Knowledge Sharing

javacard:jcvm:6.7_constant_pool_component

6.7 Constant Pool Component

The Constant Pool Component contains an entry for each of the classes, methods, and fields referenced by elements in the Method Component ( Section 6.9, Method Component) of this CAP file. The referencing elements in the Method Component may be instructions in the methods or exception handler catch types in the exception handler table.

Entries in the Constant Pool Component reference elements in the Class Component ( Section 6.8, Class Component), Method Component ( Section 6.9, Method Component), and Static Field Component ( Section 6.10, Static Field Component). The Import Component ( Section 6.6, Import Component) is also accessed using a package token ( Section 4.3.7.1, Package) to describe references to classes, methods and fields defined in imported packages. Entries in the Constant Pool Component do not reference other entries internal to itself.

The Constant Pool Component is described by the following structure:

The items in the constant_pool_component structure are as follows:

tag

The tag item has the value COMPONENT_ConstantPool (5).

size

The size item indicates the number of bytes in the constant_pool_component structure, excluding the tag and size items. The value of the size item must be greater than zero.

count

The count item represents the number entries in the constant_pool[] array. Valid values are between 0 and 65535, inclusive.

constant_pool[]

The constant_pool[] item represents an array of cp_info structures:

Each item in the constant_pool[] array is a 4-byte structure. Each structure must begin with a 1-byte tag indicating the kind of cp_info entry. The content and format of the 3-byte info array varies with the value of the tag. The valid tags and their values are listed in the following table.

Constant Type

Tag

CONSTANT_Classref

1

CONSTANT_InstanceFieldref

2

CONSTANT_VirtualMethodref

3

CONSTANT_SuperMethodref

4

CONSTANT_StaticFieldref

5

CONSTANT_StaticMethodref

6

Java Card platform constant types (“Java Card constant types”) are more specific than those in Java class files. The categories indicate not only the type of the item referenced, but also the manner in which it is referenced.

For example, in the Java constant pool there is one constant type for method references, while in the Java Card platform constant pool (“Java Card constant pool”) there are three constant types for method references: one for virtual method invocations using the invokevirtual bytecode, one for super method invocations using the invokespecial bytecode, and one for static method invocations using either the invokestatic or invokespecial bytecode.<SUP>[4]</SUP> The additional information provided by a constant type in Java Card technologies simplifies resolution of references.

There are no ordering constraints on constant pool entries. It is recommended, however, that CONSTANT_InstanceFieldref ( Section 6.7.2, **CONSTANT_InstanceFieldref**, CONSTANT_VirtualMethodref, and CONSTANT_SuperMethodref) constants occur early in the array to permit using getfield_T and putfield_T bytecodes instead of getfield_T_w and putfield_T_w bytecodes. The former have 1-byte constant pool index parameters while the latter have 2-byte constant pool index parameters.

The first entry in the constant pool can not be an exception handler class that is referenced by a catch_type_index of an exception_handler_info structure. In such a case the value of the catch_type_index would be equal to 0, but the value of 0 in a catch_type_index is reserved to indicate an exception_handler_info structure that describes a finally block.

javacard/jcvm/6.7_constant_pool_component.txt · Last modified: 2017/05/13 04:10 (external edit)