![]() ![]() ![]() ![]() |
This chapter describes the Java Card CAP
(converted applet) file format. Each CAP
file contains all of the classes and interfaces defined in one Java package. Java Card Converters must be capable of producing CAP
files that conform to the specification provided in this chapter.
A CAP
file consists of a stream of 8-bit bytes. All 16-bit and 32-bit quantities are constructed by reading in two and four consecutive 8-bit bytes, respectively. Multibyte data items are always stored in big-endian order, where the high-order bytes come first. The first bit read of an 8-bit quantity is considered the high bit.
This chapter defines its own set of data types representing Java Card CAP
file data: the types u1, and u2 represent an unsigned one-, and two-byte quantities, respectively. Some u1 types are represented as bitfield structures, consisting of arrays of bits. The zeroeth bit in each bit array represents the most significant bit, or high bit.
The Java Card CAP
file format is presented using pseudo structures written in a C-like structure notation. To avoid confusion with the fields of Java Card virtual machine classes and class instances, the contents of the structures describing the Java Card CAP
file format are referred to as items. Unlike the fields of a C structure, successive items are stored in the Java Card platform file sequentially, without padding or alignment.
Variable-sized tables, consisting of variable-sized items, are used in several CAP
file data structures. Although we will use C-like array syntax to refer to table items, the fact that tables are streams of variable-sized structures means that it is not possible to directly translate a table index into a byte offset into the table.
A data structure referred to as an array consists of items equal in size.
Some items in the structures of the CAP
file format are describe using a C-like union notation. The bytes contained in a union structure have one of the two formats. Selection of the two formats is based on the value of the high bit of the structure.
A Java Card CAP
file consists of a set of components. Each component describes a set of elements in the Java package defined, or an aspect of the CAP
file. A complete CAP
file must contain all of the required components specified in this chapter. Three components are optional: the Applet Component (Section 6.5 "Applet Component”), Export Component (Section 6.12 "Export Component”), and Debug Component (Section 6.14 "Debug Component”). The Applet Component is included only if one or more Applets are defined in the package. The Export Component is included only if classes in other packages may import elements in the package defined. The Debug Component contains all of the data necessary for debugging a package.
The content of each component defined in a CAP
file must conform to the corresponding format specified in this chapter. All components have the following general format:
Each component begins with a 1-byte tag
indicating the kind of component. Valid tags and their values are listed in TABLE 19. The size
item indicates the number of bytes in the info array of the component, not including the tag
and size
items.
The content and format of the info
array varies with the type of component.
Sun may define additional components in future versions of this Java Card virtual machine specification. It is guaranteed that additional components will have tag values between 13 and 127, inclusive.
Each CAP
file component is represented as a single file. The component file names are enumerated in TABLE 20. These names are not case sensitive.
All CAP
file components are stored in a JAR file. As described in Section 4.1.3 "JAR File Container”, the path to the CAP
file component files in a JAR file consists of a directory called javacard
that is in a subdirectory representing the package’s directory. For example, the CAP
file component files of the package javacard.framework
are located in the subdirectory javacard/framework/javacard
. Other files, including other CAP
files, may also reside in a JAR file that contains CAP
file component files.
The JAR file format provides a vehicle suitable for the distribution of CAP
file components. It is not intended or required that the JAR file format be used as the load file format for loading CAP
file components onto a Java Card technology-enabled device. See Section 6.2 "Installation” for more information.
The name of a JAR file containing CAP
file components is not defined as part of this specification. The naming convention used by the Sun Microsystems, Inc. Java Card Converter Tool is to append .cap
to the simple (i.e. not fully qualified) package name. For example, the CAP
file produced for the package com.sun.javacard.JavaLoyalty
would be named JavaLoyalty.cap
.
Java Card CAP
files are permitted to contain new, or custom, components. All new components not defined as part of this specification must not affect the semantics of the specified components, and Java Card virtual machines must be able to accept CAP
files that do not contain new components. Java Card virtual machine implementations are required to silently ignore components they do not recognize.
New components are identified in two ways: they are assigned both an ISO 7816-5 AID (Section 4.2 "AID-based Naming”) and a tag value. Valid tag values are between 128 and 255, inclusive. Both of these identifiers are recorded in the custom_component
item of the Directory Component (Section 6.4 "Directory Component”).
The new component must conform to the general component format defined in this chapter, with a tag
value, a size
value indicating the number of bytes in the component (excluding the tag
and size
items), and an info
item containing the content of the new component.
A new component file is stored in a JAR file, following the same restrictions as those specified in Section 4.1.3 "JAR File Container”. That is, the file containing the new component must be located in the <package_directory>/javacard
subdirectory of the JAR file and must have the extension .cap
.
Installing a CAP
file components onto a Java Card technology-enabled device entails communication between a Java Card technology-enabled terminal and that device. While it is beyond the scope of this specification to define a load file format or installation protocol between a terminal and a device, the CAP
file component order shown in TABLE 21 is a reference load order suitable for an implementation with a simple memory management model on a limited memory device.1
The component type COMPONENT_Debug
is not intended for download to the device. It is intended to be used off-card in conjunction with a suitably instrumented Java Card virtual machine.
The Header Component contains general information about this CAP
file and the package it defines. It is described by the following variable-length structure:
header_component {
u1 tag
u2 size
u4 magic
u1 minor_version
u1 major_version
u1 flags
package_info package
package_name_info package_name
}
The items in the header_component
structure are as follows:
The tag
item has the value COMPONENT_Header
(1).
The size
item indicates the number of bytes in the header_component
structure, excluding the tag
and size
items. The value of the size
item must be greater than zero.
The magic
item supplies the magic number identifying the Java Card CAP
file format; it has the value 0xDECAFFED.
The minor_version
and major_version
items are the minor and major version numbers of this CAP
file. Together, a major and a minor version number determine the version of the CAP
file format. If a CAP
file has the major version number of M and minor version number of m, the version of the CAP
file’s format is M.m.
A change in the major version number indicates a major incompatibility change, one that requires a fundamentally different Java Card virutal machine. A Java Card virtual machine is not required to support CAP
files with different major version numbers. A Java Card virtual machine is required to support CAP
files having a given major version number and all valid minor version numbers in the range 0 through some particular minor_version
where a valid minor version number is a minor version number that has been defined in a version of the Java Card Virtual Machine Specification.
In this specification, the major version of the CAP
file format has the value 2 and the minor version has the value 2. Only Sun Microsystems, Inc. may define the meaning and values of new CAP
file format versions.
The flags
item is a mask of modifiers that apply to this package. The flags
modifiers are shown in the following table.
The ACC_INT
flag has the value of one if the Java int
type is used in this package. The int
type is used if one or more of the following is present:
int
,int
array,int
,int
array,int
,int
array,int
, or int
array.
Otherwise the ACC_INT
flag has the value of 0.
The ACC_EXPORT
flag has the value of one if an Export Component (Section 6.12 "Export Component”) is included in this CAP
file. Otherwise it has the value of 0.
The ACC_APPLET
flag has the value of one if an Applet Component (Section 6.5 "Applet Component”) is included in this CAP
file. Otherwise it has the value of 0.
All other bits in the flags
item not defined in TABLE 22 are reserved for future use. Their values must be zero.
The package
item describes the package defined in this CAP
file. It is represented as a package_info
structure:
The items in the package_info
structure are as follows:
The minor_version
and major_version
items are the minor and major version numbers of this package. These values uniquely identify the particular implementation of this package and indicate the binary compatibility between packages. See Section 4.5 "Package Versions” for a description of assigning and using package version numbers.
The AID_length
item represents the number of bytes in the AID
item. Valid values are between 5 and 16, inclusive.
The AID
item represents the Java Card platform name of the package. See ISO 7816-5 for the definition of an AID (Section 4.2 "AID-based Naming”).
The package_name
item describes the name of the package defined in this CAP
file. It is represented as a package_name_info[]
structure:
The items in the package_name_info[]
structure are as follows:
The name_length
item is the number of bytes used in the name
item to represent the name of this package in UTF-8 format. The value of this item may be zero if and only if the package does not define any remote interfaces or remote classes.
The name[]
item is a variable length representation of the fully qualified name of this package in UTF-8 format. The fully qualified name is represented in internal form as described in The Java™ Virtual Machine Specification (Section 4.2).
The Directory Component lists the size of each of the components defined in this CAP
file. When an optional component is not included, such as the Applet Component (Section 6.5 "Applet Component”), Export Component (Section 6.12 "Export Component”), or Debug Component (Section 6.14 "Debug Component”), it is represented in the Directory Component with size equal to zero. The Directory Component also includes entries for new (or custom) components.
The Directory Component is described by the following variable-length structure:
directory_component {
u1 tag
u2 size
u2 component_sizes[12]
static_field_size_info static_field_size
u1 import_count
u1 applet_count
u1 custom_count
custom_component_info custom_components[custom_count]
}
The items in the directory_component
structure are as follows:
The tag
item has the value COMPONENT_Directory
(2).
The size
item indicates the number of bytes in the directory_component
structure, excluding the tag
and size
items. The value of the size
item must be greater than zero.
The component_sizes
item is an array representing the number of bytes in each of the components in this CAP
file. All of the 12 components defined in this chapter are represented in the component_sizes
array. The value of an index into the array is equal to the value of the tag of the component represented at that entry, minus 1.
The value in each entry in the component_sizes
array is the same as the size
item in the corresponding component. It represents the number of bytes in the component, excluding the tag
and size
items.
The value of an entry in the component_sizes
array is zero for components not included in this CAP
file. Components that may not be included are the Applet Component (Section 6.5 "Applet Component”), the Export Component (Section 6.12 "Export Component”), and the Debug Component (Section 6.14 "Debug Component”). For all other components the value is greater than zero.
The static_field_size
item is a static_field_size_info
structure. The structure is defined as:
The items in the static_field_size_info
structure are the following:
The image_size
item has the same value as the image_size
item in the Static Field Component (Section 6.10 "Static Field Component”). It represents the total number of bytes in the static
fields defined in this package, excluding final static
fields of primitive types.
The array_init_count
item has the same value as the array_init_count
item in the Static Field Component (Section 6.10 "Static Field Component”). It represents the number of arrays initialized in all of the <clinit>
methods in this package.
The array_init_size
item represents the sum of the count
items in the array_init
table item of the Static Field Component (Section 6.10 "Static Field Component”). It is the total number of bytes in all of the arrays initialized in all of the <clinit>
methods in this package.
The import_count
item indicates the number of packages imported by classes and interfaces in this package. This item has the same value as the count
item in the Import Component (Section 6.6 "Import Component”).
The applet_count
item indicates the number of applets defined in this package. If an Applet Component (Section 6.5 "Applet Component”) is not included in this CAP
file, the value of the applet_count
item is zero. Otherwise the value of the applet_count
item is the same as the value of the count
item in the Applet Component (Section 6.5 "Applet Component”).
The custom_count
item indicates the number of entries in the custom_components
table. Valid values are between 0 and 127, inclusive.
The custom_components
item is a table of variable-length custom_component_info
structures. Each new component defined in this CAP
file must be represented in the table. These components are not defined in this standard.
The custom_component_info
structure is defined as:
The items in entries of the custom_component_info
structure are:
The component_tag
item represents the tag of the component. Valid values are between 128 and 255, inclusive.
The size
item represents the number of bytes in the component, excluding the tag
and size
items.
The AID_length
item represents the number of bytes in the AID
item. Valid values are between 5 and 16, inclusive.
The AID
item represents the Java Card platform name of the component. See ISO 7816-5 for the definition of an AID (Section 4.2 "AID-based Naming”).
Each component is assigned an AID conforming to the ISO 7816-5 standard. Beyond that, there are no constraints on the value of an AID of a custom component.
The Applet Component contains an entry for each of the applets defined in this package. Applets are defined by implementing a non-abstract subclass, direct or indirect, of the javacard.framework.Applet
class.2 If no applets are defined, this component must not be present in this CAP
file.
The Applet Component is described by the following variable-length structure:
applet_component {
u1 tag
u2 size
u1 count
{ u1 AID_length
u1 AID[AID_length]
u2 install_method_offset
} applets[count]
}
The items in the applet_component
structure are as follows:
The tag
item has the value COMPONENT_Applet
(3).
The size
item indicates the number of bytes in the applet_component
structure, excluding the tag
and size
items. The value of the size
item must be greater than zero.
The count
item indicates the number of applets defined in this package. The value of the count
item must be greater than zero.
The applets
item represents a table of variable-length structures each describing an applet defined in this package.
The items in each entry of the applets
table are defined as follows:
The AID_length
item represents the number of bytes in the AID
item. Valid values are between 5 and 16, inclusive.
The AID
item represents the Java Card platform name of the applet.
Each applet is assigned an AID conforming to the ISO 7816-5 standard (Section 4.2 "AID-based Naming”). The RID (first 5 bytes) of all of the applet AIDs must have the same value. In addition, the RID of each applet AIDs must have the same value as the RID of the package defined in this CAP
file.
The value of the install_method_offset
item must be a 16-bit offset into the info
item of the Method Component (Section 6.9 "Method Component”). The item at that offset must be a method_info
structure that represents the static install(byte[],short,byte)
method of the applet.3 The install(byte[],short,byte)
method must be defined in a class that extends the javacard.framework.applet
class, directly or indirectly. The install(byte[],short,byte)
method is called to initialize the applet.
The Import Component lists the set of packages imported by the classes in this package. It does not include an entry for the package defined in this CAP
file. The Import Component is represented by the following structure:
The items in the import_component
structure are as follows:
The tag
item has the value COMPONENT_Import
(4).
The size
item indicates the number of bytes in the import_component
structure, excluding the tag
and size
items. The value of the size
item must be greater than zero.
The count
item indicates the number of items in the packages
table. The value of the count
item must be between 0 and 128, inclusive.
The packages
item represents a table of variable-length package_info
structures as defined for package
under Section 6.3 "Header Component”. The table contains an entry for each of the packages referenced in the CAP
file, not including the package defined.
The major and minor version numbers specified in the package_info
structure are equal to the major and minor versions specified in the imported package’s export
file. See Section 4.5 "Package Versions” for a description of assigning and using package version numbers.
Components of this CAP
file refer to an imported package by using a index in this packages
table. The index is called a package token (Section 4.3.7.1 "Package”).
The Constant Pool Component contains an entry for each of the classes, methods, and fields referenced by elements in the Method Conponent (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:
The tag
item has the value COMPONENT_ConstantPool
(5).
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.
The count
item represents the number entries in the constant_pool[]
array. Valid values are between 0 and 65535, inclusive.
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.
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.4 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.
The CONSTANT_Classref_info
structure is used to represent a reference to a class or an interface. The class or interface may be defined in this package or in an imported package.
CONSTANT_Classref_info {
u1 tag
union {
u2 internal_class_ref
{ u1 package_token
u1 class_token
} external_class_ref
} class_ref
u1 padding
}
The items in the CONSTANT_Classref_info
structure are the following:
The tag
item has the value CONSTANT_Classref
(1).
The class_ref
item represents a reference to a class or interface. If the class or interface is defined in this package the structure represents an internal_class_ref
and the high bit of the structure is zero. If the class or interface is defined in another package the structure represents an external_class_ref
and the high bit of the structure is one.
The internal_class_ref
structure represents a 16-bit offset into the info
item of the Class Component (Section 6.8 "Class Component”) to an interface_info
or class_info
structure. The interface_info
or class_info
structure must represent the referenced class or interface.
The value of the internal_class_ref
item must be between 0 and 32767, inclusive, making the high bit equal to zero.
The external_class_ref
structure represents a reference to a class or interface defined in an imported package. The high bit of this structure is one.
The package_token
item represents a package token (Section 4.3.7.1 "Package”) defined in the Import Component (Section 6.6 "Import Component”) of this CAP
file. The value of this token must be a valid index into the packages
table item of the import_component
structure. The package represented at that index must be the imported package.
The value of the package token must be between 0 and 127, inclusive.
The high bit of the package_token
item is equal to one.
The class_token
item represents the token of the class or interface (Section 4.3.7.2 "Classes and Interfaces”) of the referenced class or interface. It has the value of the class token of the class as defined in the Export
file of the imported package.
The padding
item has the value zero. It is present to make the size of a CONSTANT_Classref_info
structure the same as all other constants in the constant_pool[]
array.
References to instance fields, and virtual methods are represented by similar structures:
The items in these structures are as follows:
The tag item of a CONSTANT_InstanceFieldref_info
structure has the value CONSTANT_InstanceFieldref
(2).
The tag item of a CONSTANT_VirtualMethodref_info
structure has the value CONSTANT_VirtualMethodref
(3).
The tag item of a CONSTANT_SuperMethodref_info
structure has the value CONSTANT_SuperMethodref
(4).
The class
item represents the class associated with the referenced instance field, virtual method, or super
method invocation. It is a class_ref
structure (Section 6.7.1 "CONSTANT_Classref”). If the referenced class is defined in this package the high bit is equal to zero. If the reference class is defined in an imported package the high bit of this structure is equal to one.
The class referenced in the CONSTANT_InstanceField_info
structure must be the class that contains the declaration of the instance field.
The class referenced in the CONSTANT_VirtualMethodref_info
structure must be a class that contains a declaration or definition of the virtual method.
The class referenced in the CONSTANT_SuperMethodref_info
structure must be the class that defines the method that contains the Java language-level super
invocation.
The token
item in the CONSTANT_InstanceFieldref_info
structure represents an instance field token (Section 4.3.7.5 "Instance Fields”) of the referenced field. The value of the instance field token is defined within the scope of the class indicated by the class
item.
The token
item of the CONSTANT_VirtualMethodref_info
structure represents the virtual method token (Section 4.3.7.6 "Virtual Methods”) of the referenced method. The virtual method token is defined within the scope of the hierarchy of the class indicated by the class
item. If the referenced method is public
or protected
the high bit of the token
item is zero. If the referenced method is package-visible the high bit of the token
item is one. In this case the class
item must represent a reference to a class defined in this package.
The token
item of the CONSTANT_SuperMethodref_info
structure represents the virtual method token (Section 4.3.7.6 "Virtual Methods”) of the referenced method. Unlike in the CONSTANT_VirtualMethodref_info structure, the virtual method token is defined within the scope of the hierarchy of the superclass of the class indicated by the class
item. If the referenced method is public
or protected
the high bit of the token
item is zero. If the referenced method is package-visible the high bit of the token
item is one. In the latter case the class
item must represent a reference to a class defined in this package and at least one superclass of the class that contains a definition of the virtual method must also be defined in this package.
References to static fields and methods are represented by similar structures:
CONSTANT_StaticFieldref_info {
u1 tag
union {
{ u1 padding
u2 offset
} internal_ref
{ u1 package_token
u1 class_token
u1 token
} external_ref
} static_field_ref
}
CONSTANT_StaticMethodref_info {
u1 tag
union {
{ u1 padding
u2 offset
} internal_ref
{ u1 package_token
u1 class_token
u1 token
} external_ref
} static_method_ref
}
The items in these structures are as follows:
The tag
item of a CONSTANT_StaticFieldref_info
structure has the value CONSTANT_StaticFieldref
(5).
The tag
item of a CONSTANT_StaticMethodref_info
structure has the value CONSTANT_StaticMethodref
(6).
The static_field_ref
and static_method_ref
item represents a reference to a static
field or static
method, respectively. Static method references include references to static
methods, constructors, and private
virtual methods.
If the referenced item is defined in this package the structure represents an internal_ref
and the high bit of the structure is zero. If the referenced item is defined in another package the structure represents an external_ref
and the high bit of the structure is one.
The internal_ref
item represents a reference to a static
field or method defined in this package. The items in the structure are:
The padding
item is equal to 0.
The offset
item of a CONSTANT_StaticFieldref_info
structure represents a 16-bit offset into the Static Field Image defined by the Static Field component (Section 6.10 "Static Field Component”) to this static field.
The offset
item of a CONSTANT_StaticMethodref_info
structure represents a 16-bit offset into the info
item of the Method Component (Section 6.9 "Method Component”) to a method_info
structure. The method_info
structure must represent the referenced method.
The external_ref
item represents a reference to a static field or method defined in an imported package. The items in the structure are:
The package_token
item represents a package token (Section 4.3.7.1 "Package”) defined in the Import Component (Section 6.6 "Import Component”) of this CAP
file. The value of this token must be a valid index into the packages
table item of the import_component
structure. The package represented at that index must be the imported package.
The value of the package token must be between 0 and 127, inclusive.
The high bit of the package_token
item is equal to one.
The class_token
item represents the token (Section 4.3.7.2 "Classes and Interfaces”) of the class of the referenced class. It has the value of the class token of the class as defined in the Export
file of the imported package.
The class indicated by the class_token
item must define the referenced field or method.
The token
item of a CONSTANT_StaticFieldref_info
structure represents a static field token (Section 4.3.7.3 "Static Fields”) as defined in the Export
file of the imported package. It has the value of the token of the referenced field.
The token
item of a CONSTANT_StaticMethodref_info
structure represents a static method token (Section 4.3.7.4 "Static Methods and Constructors”) as defined in the Export
file of the imported package. It has the value of the token of the referenced method.
The Class Component describes each of the classes and interfaces defined in this package. It does not contain complete access information and content details for each class and interface. Instead, the information included is limited to that required to execute operations associated with a particular class or interface, without performing verification. Complete details regarding the classes and interfaces defined in this package are included in the Descriptor Component (Section 6.13 "Descriptor Component”).
The information included in the Class Component for each interface is sufficient to uniquely identify the interface and to test whether or not a cast to that interface is valid.
The information included in the Class Component for each class is sufficient to resolve operations associated with instances of a class. The operations include creating an instance, testing whether or not a cast of the instance is valid, dispatching virtual method invocations, and dispatching interface method invocations. Also included is sufficient information to locate instance fields of type reference
, including arrays.
The classes represented in the Class Component reference other entries in the Class Component in the form of superclass, superinterface and implemented interface references. When a superclass, superinterface or implemented interface is defined in an imported package the Import Component is used in the representation of the reference.
The classes represented in the Class Component also contain references to virtual methods defined in the Method Component (Section 6.9 "Method Component”) of this CAP
file. References to virtual methods defined in imported packages are not explicitly described. Instead such methods are located through a superclass within the hierarchy of the class, where the superclass is defined in the same imported package as the virtual method.
The Constant Pool Component (Section 6.7 "Constant Pool Component”), Export Component (Section 6.12 "Export Component”), Descriptor Component (Section 6.13 "Descriptor Component”) and Debug Component (Section 6.14 "Debug Component”) reference classes and interfaces defined in the Class Component. No other CAP
file components reference the Class Component.
The Class Component is represented by the following structure:
class_component {
u1 tag
u2 size
u2 signature_pool_length
type_descriptor signature_pool[]
interface_info interfaces[]
class_info classes[]
}
The items in the class_component
structure are as follows:
The tag
item has the value COMPONENT_Class
(6).
The size
item indicates the number of bytes in the class_component
structure, excluding the tag
and size
items. The value of the size
item must be greater than zero.
The signature_pool_length
item indicates the number of bytes in the signature_pool[]
item. The value of the signature_pool_length
item must be zero if the package does not define any remote interfaces or remote classes.
The signature_pool[]
item represents a list of variable-length type_descriptor
structures. These descriptors represent the signatures of the remote methods.
The interfaces
item represents an array of interface_info
structures. Each interface defined in this package is represented in the array. The entries are ordered based on hierarchy such that a superinterface has a lower index than any of its subinterfaces.
The classes
item represents a table of variable-length class_info
structures. Each class defined in this package is represented in the array. The entries are ordered based on hierarchy such that a superclass has a lower index than any of its subclasses.
The type_descriptor
structure represents the type of a field or the signature of a method.
The type_descriptor
structure contains the following elements:
The nibble_count
value represents the number of nibbles required to describe the type encoded in the type
array.
The type
array contains an encoded description of the type, composed of individual nibbles. If the nibble_count
item is an odd number, the last nibble in the type
array must be 0x0. The values of the type descriptor nibbles are defined in the following table.
Class reference
types are described using the reference
nibble 0x6, followed by a 2-byte (4-nibble) class_ref
structure. The class_ref
structure is defined as part of the CONSTANT_Classref_info
structure (Section 6.7.1 "CONSTANT_Classref”). For example, a field of type reference
to p1.c1
in a CAP
file defining package p0
is described as:
Nibble
|
Value
|
Description
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0
|
0x6
|
reference
|
||||||||||||
1
|
<p1>
|
package token
(high bit on) |
||||||||||||
2
|
||||||||||||||
3
|
<c1>
|
class token
|
||||||||||||
4
|
||||||||||||||
5
|
0x0
|
padding
|
||||||||||||
The following are examples of the array types:
Nibble
|
Value
|
Description
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0
|
0xE
|
array of
reference
|
||||||||||||
1
|
<p1>
|
package token
(high bit on) |
||||||||||||
2
|
||||||||||||||
3
|
<c1>
|
class token
|
||||||||||||
4
|
||||||||||||||
5
|
0x0
|
padding
|
||||||||||||
Method signatures are encoded in the same way, with the return type of the method encoded at the end of the sequence of nibbles. The return type is encoded in as many nibbles as required to represent it. For example:
Nibble
|
Value
|
Description
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0
|
0x6
|
reference
|
||||||||||||
1
|
<p1>
|
package token
(high bit on) |
||||||||||||
2
|
||||||||||||||
3
|
<c1>
|
class token
|
||||||||||||
4
|
||||||||||||||
5
|
0x4
|
short
|
||||||||||||
The interface_info
and class_info
structures represent interfaces and classes, respectively. The two are differentiated by the value of the high bit in the structures. They are defined as follows:
interface_info {
u1 bitfield {
bit[4] flags
bit[4] interface_count
}
class_ref superinterfaces[interface_count]
interface_name_info interface_name
5}
class_info {
u1 bitfield {
bit[4] flags
bit[4] interface_count
}
class_ref super_class_ref
u1 declared_instance_size
u1 first_reference_token
u1 reference_count
u1 public_method_table_base
u1 public_method_table_count
u1 package_method_table_base
u1 package_method_table_count
u2 public_virtual_method_table[public_method_table_count]
u2 package_virtual_method_table[package_method_table_count]
implemented_interface_info interfaces[interface_count]
remote_interface_info remote_interfaces
6
}
The flags
item is a mask of modifiers used to describe this interface or class. Valid values are shown in the following table:
Name
|
Value
|
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ACC_INTERFACE
|
0x8
|
|||||||||||||
ACC_SHAREABLE
|
0x4
|
|||||||||||||
ACC_REMOTE
|
0x2
|
|||||||||||||
The ACC_INTERFACE
flag indicates whether this interface_info
or class_info
structure represents an interface or a class. The value must be one if it represents an interface_info
structure and zero if a class_info
structure.
The ACC_SHAREABLE
flag in an interface_info
structure indicates whether this interface is shareable. The value of this flag must be one if and only if the interface is javacard.framework.Shareable
interface or extends that interface directly or indirectly.
The ACC_SHAREABLE
flag in a class_info
structure indicates whether this class is shareable.7 The value of this flag must be one if and only if this class or any of its superclasses implements an interface that is shareable.
The ACC_REMOTE
flag indicates whether this class or interface is remote. The value of this flag must be one if and only if the class or interface satisfies the requirements defined in Section 2.2.6.1 "Remote Classes and Remote Interfaces”.
All other flag values are reserved. Their values must be zero.
The interface_count
item of the interface_info
structure indicates the number of entries in the superinterfaces[]
table item. The value represents the number of direct and indirect superinterfaces of this interface. Indirect superinterfaces are the set of superinterfaces of the direct superinterfaces. Valid values are between 0 and 14, inclusive.
The interface_count
item of the class_info
structure indicates the number of entries in the interfaces
table item. The value represents the number of interfaces implemented by this class, including superinterfaces of those interfaces and potentially interfaces implemented by superclasses of this class. Valid values are between 0 and 15, inclusive.
The superinterfaces[]
item of the interface_info
structure is an array of class_ref
structures representing the superinterfaces of this interface. The class_ref
structure is defined as part of the CONSTANT_Classref_info
structure (Section 6.7.1 "CONSTANT_Classref”). This array is empty if this interface has no superinterfaces. Both direct and indirect superinterfaces are represented in the array. Class Object
is not included.
The interface_name[]
item represents interface name information required if the interface is remote. The interface_name[]
item is defined by a interface_name_info
structure. If the value of the ACC_REMOTE
flag is zero, the structure is defined as:
If the value of the ACC_REMOTE
flag is one, the structure is defined as:
The values in the interface_name_info
structure are defined as follows:
The interface_name_length
item is the number of bytes in interface_name[]
item.
The interface_name[]
item is a variable length representation of the name of this interface in UTF-8 format.
The super_class_ref
item of the class_info
structure is a class_ref
structure representing the superclass of this class. The class_ref
structure is defined as part of the CONSTANT_Classref_info
structure (Section 6.7.1 "CONSTANT_Classref”).
The super_class_ref
item has the value of 0xFFFF only if this class does not have a superclass. Otherwise the value of the super_class_ref
item is limited only by the constraints of the class_ref
structure.
The declared_instance_size
item of the class_info
structure represents the number of 16-bit cells required to represent the instance fields declared by this class. It does not include instance fields declared by superclasses of this class.
Instance fields of type int
are represented in two 16-bit cells, while all other field types are represented in one 16-bit cell.
The first_reference_token
item of the class_info
structure represents the instance field token (Section 4.3.7.5 "Instance Fields”) value of the first reference
type instance field defined by this class. It does not include instance fields defined by superclasses of this class.
If this class does not define any reference
type instance fields, the value of the first_reference_token
is 0xFF. Otherwise the value of the first_reference_token
item must be within the range of the set of instance field tokens of this class.
The reference_count
item of the class_info
structure represents the number of reference
type instance field defined by this class. It does not include reference
type instance fields defined by superclasses of this class.
Valid values of the reference_count
item are between 0 and the maximum number of instance fields defined by this class.
The public_method_table_base
item of the class_info
structure is equal to the virtual method token value (Section 4.3.7.6 "Virtual Methods”) of the first method in the public_virtual_method_table[]
array. If the public_virtual_method_table[]
array is empty, the value of the public_method_table_base
item is equal to the public_method_table_base
item of the class_info
structure of this class’ superclass plus the public_method_table_count
item of the class_info
structure of this class’ superclass. If this class has no superclass and the public_virtual_method_table[]
array is empty, the value of the public_method_table_base
item is zero.
The public_method_table_count
item of the class_info
structure indicates the number of entries in the public_virtual_method_table[]
array.
If this class does not define any public
or protected
override methods, the minimum valid value of public_method_table_count
item is the number of public
and protected
virtual methods declared by this class. If this class defines one or more public
or protected
override methods, the minimum valid value of public_method_table_count
item is the value of the largest public
or protected
virtual method token, minus the value of the smallest public
or protected
virtual override method token, plus one.
The maximum valid value of the public_method_table_count
item is the value of the largest public or protected virtual method token, plus one.
Any value for the public_method_table_count
item between the minimum and maximum specified here is valid. However, the value must correspond to the number of entries in the public_virtual_method_table[]
array.
The package_method_table_base
item of the class_info
structure is equal to the virtual method token value (Section 4.3.7.6 "Virtual Methods”) of the first entry in the package_virtual_method_table[]
array. If the package_virtual_method_table[]
array is empty, the value of the package_method_table_base
item is equal to the package_method_table_base
item of the class_info structure of this class’ superclass plus the package_method_table_count
item of the class_info
structure of this class’ superclass. If this class has no superclass or inherits from a class defined in another package and the package_virtual_method_table[]
array is empty, the value of the package_method_table_base
item is zero.
The package_method_table_count
item of the class_info
structure indicates the number of entries in the package_virtual_method_table[]
array.
If this class does not define any override methods, the minimum valid value of package_method_table_count
item is the number of package visible virtual methods declared by this class. If this class defines one or more package visible override methods, the minimum valid value of package_method_table_count
item is the value of the largest package visible virtual method token, minus the value of the smallest package visible virtual override method token, plus one.
The maximum valid value of the package_method_table_count
item is the value of the largest package visible method token, plus one.
Any value for the package_method_table_count
item between the minimum and maximum specified here are valid. However, the value must correspond to the number of entries in the package_virtual_method_table[]
.
The public_virtual_method_table[]
item of the class_info
structure represents an array of public and protected virtual methods. These methods can be invoked on an instance of this class. The public_virtual_method_table[]
array includes methods declared or defined by this class. It may also include methods declared or defined by any or all of its superclasses. The value of an index into this table must be equal to the value of the virtual method token of the indicated method, minus the value of the public_method_table_base
item.
Entries in the public_virtual_method_table[]
array that represent methods defined or declared in this package contain offsets into the info
item of the Method Component (Section 6.9 "Method Component”) to the method_info
structure representing the method. Entries that represent methods defined or declared in an imported package contain the value 0xFFFF.
Entries for methods that are declared abstract are represented in the public_virtual_method_table[]
array in the same way as non-abstract methods.
The package_virtual_method_table[]
item of the class_info
structure represents an array of package-visible virtual methods. These methods can be invoked on an instance of this class. The package_virtual_method_table[]
array includes methods declared or defined by this class. It may also include methods declared or defined by any or all of its superclasses that are defined in this package. The value of an index into this table must be equal to the value of the virtual method token of the indicated method & 0x7F, minus the value of the package_method_table_base
item.
All entries in the package_virtual_method_table[]
array represent methods defined or declared in this package. They contain offsets into the info
item of the Method Component (Section 6.9 "Method Component”) to the method_info
structure representing the method.
Entries for methods that are declared abstract, not including those defined by interfaces, are represented in the package_virtual_method_table[]
array in the same way as non-abstract methods.
The interfaces
item of the class_info
structure represents a table of variable-length implemented_interface_info
structures. The table must contain an entry for each of the implemented interfaces indicated in the declaration of this class and each of the interfaces in the hierarchies of those interfaces. Interfaces that occur more than once are represented by a single entry. Interfaces implemented by superclasses of this class may optionally be represented.
Given the declarations below, the number of entries for class c0 is 1 and the entry in the interfaces
array is i0. The minimum number of entries for class c1 is 3 and the entries in the interfaces
array are i1, i2, and i3. The entries for class c1 may also include interface i0, which is implemented by the superclass of c1.
interface i0 {}
interface i1 {}
interface i2 extends i1 {}
interface i3 {}
class c0 implements i0 {}
class c1 extends c0 implements i2, i3 {}
remote_interfaces
The remote_interfaces
item represents information required if this class or any of its super classes implements a remote interface. This item must be omitted if the ACC_REMOTE
flag has a value of zero. The remote_interfaces
item is defined by a remote_interface_info
structure.
The implemented_interface_info
structure is defined as follows:
The items in the implemented_interface_info
structure are defined as follows:
The interface
item has the form of a class_ref
structure. The class_ref
structure is defined as part of the CONSTANT_Classref_info
structure (Section 6.7.1 "CONSTANT_Classref”). The interface_info
structure referenced by the interface
item represents an interface implemented by this class.
The count
item indicates the number of entries in the index[]
array.
The index[]
item is an array that maps declarations of interface methods to implementations of those methods in this class. It is a representation of the set of methods declared by the interface and its superinterfaces.
Entries in the index
array must be ordered such that the interface method token value (Section 4.3.7.7 "Interface Methods”) of the interface method is equal to the index into the array. The interface method token value is assigned to the method within the scope of the interface definition, not within the scope of this class.
The values in the index[]
array represent the virtual method tokens (Section 4.3.7.6 "Virtual Methods”) of the implementations of the interface methods. The virtual method token values are defined within the scope of the hierarchy of this class.
If the value of the ACC_REMOTE
flag is zero, this structure is defined as:
If the value of the ACC_REMOTE
flag is one, this structure is defined as:
remote_interface_info {
u1 remote_methods_count
remote_method_info remote_methods[remote_methods_count]
u1 hash_modifier_length
u1 hash_modifier[hash_modifier_length]
u1 class_name_length
u1 class_name[class_name_length]
u1 remote_interfaces_count
class_ref remote_interfaces[remote_interfaces_count]
}
The remote_interface_info structure is defined as:
The remote_methods_count
item indicates the number of entries in the remote_methods
array.
The remote_methods
item of the class_info
structure is an array of remote_method_info
structures that maps each remote method available in the class to its hash code and its type definition in the signature_pool[]
. The methods are listed in numerically ascending order of hash values.
The remote_method_info
structure is defined as follows:
The items in the remote_method_info
structure are defined as follows:
The remote_method_hash
item contains a two-byte hash value for the method. The hash value is computed from the simple (not fully qualified) name of the method concatenated with its method descriptor. The representation of the method descriptor is the same as in a Java class file. See the specification described in Java™ Virtual Machine Specification (§4.3.3).
The hash value uniquely identifies the method within the class.
The hash code is defined as the first two bytes of the SHA-1
message digest function performed on the hash_modifier[]
item described below followed by the name of the method followed by the method descriptor representation in UTF-8 format. Rare hash collisions are averted automatically during package conversion by adjusting the anti-collision string.
The signature_offset
item contains an offset into the info item of the Class Component to the variable-length type descriptor structure inside the signature_pool[]
item. This structure represents the signature of the remote method.
The virtual_method_token
item is the virtual method token of the remote method in this class.
The hash_modifier_length
item is the number of bytes in the following hash_modifier
item. The value of this item must be zero if an anti-collision string is not required.
The hash_modifier[]
item is a variable length representation of the anti-collision string in UTF-8 format.
The class_name_length
item is the number of bytes used in the class_name[]
item.
The class_name[]
item is a variable length representation of the name of this class in UTF-8 format.
The remote_interfaces_count
item is the number of interfaces listed in the following remote_interfaces[]
item.
The remote_interfaces[]
item is a variable length array of class_ref
items. It represents the remote interfaces implemented by this class. The remote interfaces listed in this array, together with their superinterfaces must be the complete set of remote interfaces implemented by this class and all its superclasses.
Each entry has the form of a class_ref
structure. Each class_ref
structure must reference an interface_info
structure representing a remote interface implemented by this class.
The entries in the remote_interfaces[]
array must be ordered such that all remote interfaces from the same package are listed consecutively.
The Method Component describes each of the methods declared in this package, excluding <clinit>
methods and interface method declarations. Abstract methods defined by classes (not interfaces) are included. The exception handlers associated with each method are also described.
The Method Component does not contain complete access information and descriptive details for each method. Instead, the information is optimized for size and therefore limited to that required to execute each method without performing verification. Complete details regarding the methods defined in this package are included in the Descriptor Component (Section 6.13 "Descriptor Component”). Among other information, the Descriptor Component contains the location and number of bytecodes for each method in the Method Component. This information can be used to parse the methods in the Method Component.
Instructions and exception handler catch types in the Method Component reference entries in the Constant Pool Component (Section 6.7 "Constant Pool Component”). No other CAP
file components, including the Method Component, are referenced by the elements in the Method Component.
The Applet Component (Section 6.5 "Applet Component”), Constant Pool Component (Section 6.7 "Constant Pool Component”), Class Component (Section 6.8 "Class Component”), Export Component (Section 6.12 "Export Component”), Descriptor Component (Section 6.13 "Descriptor Component”), and Debug Component (Section 6.14 "Debug Component”) reference methods defined in the Method Component. The Reference Location Component (Section 6.11 "Reference Location Component”) references all constant pool indices contained in the Method Component. No other CAP
file components reference the Method Component.
The Method Component is represented by the following structure:
method_component {
u1 tag
u2 size
u1 handler_count
exception_handler_info exception_handlers[handler_count]
method_info methods[]
}
The items in the method_component
structure are as follows:
The tag
item has the value COMPONENT_Method
(7).
The size
item indicates the number of bytes in the method_component
structure, excluding the tag
and size
items. The value of the size
item must be greater than zero.
The handler_count
item represents the number of entries in the exception_handlers
array. Valid values are between 0 and 255, inclusive.
The exception_handlers
item represents an array of 8-byte exception_handler_info
structures. Each exception_handler_info
structure represents a catch
or finally
block defined in a method of this package.
Entries in the exception_handlers
array are sorted in ascending order by the the offset to the handler of the exception handler. Smaller offset values occur first in the array. This ordering constraint ensures that the first match found when searching for an exception handler is the correct match.
There are two consequences of this ordering constraint. First, a handler that is nested with the active range (try
block) of another handler occurs first in the array. Second, when multiple handlers are associated with the same active range, they are ordered as they occur in a method. This is consistent with the ordering constraints defined for Java class
files. An example is shown below.
try {
...
try {
...
} catch (NullPointerException e) { // first
...
}
...
} catch (Exception e) { // second
...
} finally { // third
...
}
...
try {
...
} catch (SecurityException e) { // fourth
...
}
methods[]
The methods
item represents a table of variable-length method_info
structures. Each entry represents a method declared in a class of this package. <clinit>
methods and interface method declaration are not included; all other methods, including non-interface abstract methods, are.
The exception_handler_info
structure is defined as follows:
exception_handler_info {
u2 start_offset
u2 bitfield {bit[1] stop_bit
bit[15] active_length
}
u2 handler_offset
u2 catch_type_index
}
The items in the exception_handler_info
structure are as follows:
The start_offset
and active_length
pair indicate the active range (try
block) an exception handler. The start_offset
item indicates the beginning of the active range while the active_length
item indicates the number of bytes contained in the active range.
end_offset
is defined as start_offset
plus active_length
.
The start_offset
item and end_offset
are byte offsets into the info
item of the Method Component. The value of the start_offset
must be a valid offset into a bytecodes
array of a method_info
structure to an opcode of an instruction. The value of the end_offset
either must be a valid offset into a bytecodes
array of the same method_info
structure to an opcode of an instruction, or must be equal to the method’s bytecode count, the length of the bytecodes
array of the method_info
structure. The value of the start_offset
must be less than the value of the end_offset
.
The start_offset
is inclusive and the end_offset
is exclusive; that is, the exception handler must be active while the execution address is within the interval [start_offset, end_offset
).
The stop_bit
item indicates whether the active range (try
block) of this exception handler is contained within or is equal to the active range of any succeeding exception_handler_info
structures in this exception_handlers
array. At the Java source level, this indicates whether an active range is nested within another, or has at least one succeeding exception handler associated with the same range. The latter occurs when there is at least one succeeding catch
block or a finally
block.
The stop_bit
item is equal to 1 if the active range does not intersect with a succeeding exception handler’s active range, and this exception handler is the last handler applicable to the active range. It is equal to 0 if the active range is contained within the active range of another exception handler, or there is at least one succeeding handler applicable to the same active range.
The stop_bit
provides an optimization to be used during the interpretation of the athrow bytecode. As the interpreter searches for an appropriate exception handler, it may terminate the search of the exception handlers in this Method Component under the following conditions:
end_offset
of this exception handler, andstop_bit
of this exception handler is equal to 1.When these conditions are satisfied it is guaranteed that none of the succeeding exception handlers in this Method Component will contain an active range appropriate for the current exception.
In CODE EXAMPLE 1, the stop_bit
item is set for both the third and fourth handlers.
The handler_offset
item represents a byte offset into the info
item of the Method Component. It indicates the start of the exception handler. At the Java source level, this is equivalent to the beginning of a catch
or finally
block. The value of the item must be a valid offset into a bytecodes
array of a method_info
structure to an opcode of an instruction, and must be less than the value of the method’s bytecode count.
If the value of the catch_type_index
item is non-zero, it must be a valid index into the constant_pool[]
array of the Constant Pool Component (Section 6.7 "Constant Pool Component”). The constant_pool[]
entry at that index must be a CONSTANT_Classref_info
structure, representing the class of the exception caught by this exception_handlers
array entry.
If the exception_handlers
table entry represents a finally block, the value of the catch_type_index
item is zero. In this case the exception handler is called for all exceptions that are thrown within the start_offset
and end_offset
range.
The order of constants in the constant pool is constrained such that all entries referenced by catch_type_index
items that represent catch
block (not finally
blocks) are located at non-zero entries.
The method_info
structure is defined as follows:
The items in the method_info
structure are as follows:
The method_header
item represents either a method_header_info
or an extended_method_header_info
structure:
method_header_info {
u1 bitfield {
bit[4] flags
bit[4] max_stack
}
u1 bitfield {
bit[4] nargs
bit[4] max_locals
}
}
extended_method_header_info {
u1 bitfield {
bit[4] flags
bit[4] padding
}
u1 max_stack
u1 nargs
u1 max_locals
}
The items of the method_header_info
and extended_method_header_info
structures are as follows:
The flags
item is a mask of modifiers defined for this method. Valid flag values are shown in the following table.
The value of the ACC_EXTENDED
flag must be one if the method_header
is represented by an extended_method_header_info
structure. Otherwise the value must be zero.
The value of the ACC_ABSTRACT
flag must be one if this method is defined as abstract. In this case the bytecodes
array must be empty. If this method is not abstract the value of the ACC_ABSTRACT
flag must be zero.
All other flag values are reserved. Their values must be zero.
The padding
item has the value of zero. This item is only defined for the extended_method_header_info
structure.
The max_stack
item indicates the maximum number of 16-bit cells required on the operand stack during execution of this method.
Stack entries of type int
are represented in two 16-bit cells, while all others are represented in one 16-bit cell.
The nargs
item indicates the number of 16-bit cells required to represent the parameters passed to this method, including the this
pointer if this method is a virtual method.
Parameters of type int
are represented in two 16-bit cells, while all others are represented in one 16-bit cell.
The max_locals
item indicates the number of 16-bit cells required to represent the local variables declared by this method, not including the parameters passed to this method on invocation.8
Local variables of type int
are represented in two 16-bit cells, while all others are represented in one 16-bit cell. If an entry in the local variables array of the stack frame is reused to store more than one local variable (e.g. local variables from separate scopes), the number of cells required for storage is two if one or more of the local variables is of type int
.
The bytecodes
item represents an array of Java Card bytecodes that implement this method. Valid instructions are defined in Chapter 7, "Java Card Virtual Machine Instruction Set.” The impdep1 and impdep2 bytecodes can not be present in the bytecodes
array item.
If this method is abstract the bytecodes
item must contain zero elements.
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 <clinit>
method. In the Java Card virtual machine the functionality of <clinit>
methods is represented in the Static Field Component as array initialization data and non-default values of primitive types data. Section 2.2.4.6 "Class Initialization” contains a description of the subset of <clinit>
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 (Section 6.7 "Constant Pool Component”), Export Component (Section 6.12 "Export Component”), Descriptor Component (Section 6.13 "Descriptor Component”), and 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 TABLE 32. Reference
types occur first in the image. Arrays initialized through Java <clinit>
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.
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:
static_field_component {
u1 tag
u2 size
u2 image_size
u2 reference_count
u2 array_init_count
array_init_info array_init[array_init_count]
u2 default_value_count
u2 non_default_value_count
u1 non_default_values[non_default_values_count]
}
The items in the static_field_component
structure are as follows:
The tag
item has the value COMPONENT_StaticField
(8).
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.
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 TABLE 33.
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:
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 TABLE 32.
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.
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 TABLE 32. It represents the number of arrays initialized in all of the <clinit>
methods in this package.
If this CAP
file defines a library package the value of array_init_count
must be zero.
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 <clinit>
methods. The array_init_info
structure is defined as:
The items in the array_init_info
structure are defined as follows:
The type
item indicates the type of the primitive array. Valid values are shown in the following table.
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 Java), since the values
array is an array of bytes and the static field array may be a non-byte type. The Java 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 (TABLE 33) indicated by the type
item.
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 TABLE 33.
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 TABLE 32. 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 TABLE 33.
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 TABLE 32. These static fields are primitive types initialized to 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 TABLE 32. 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 TABLE 33.
The value of a boolean
type is 1 to represent true and 0 to represent false.
The Reference Location Component represents lists of offsets into the info
item of the Method Component (Section 6.9 "Method Component”) to items that contain indices into the constant_pool[]
array of the Constant Pool Component (Section 6.7 "Constant Pool Component”). This includes all constant pool index operands of instructions, and all non-zero catch_type_index
items of the exception_handlers
array. The catch_type_index
items that have the value of 0 are not included since they represent finally
blocks instead of particular exception classes.
Some of the constant pool indices are represented in one-byte values while others are represented in two-byte values. Operands of getfield_T
and putfield_T
instructions are one-byte constant pool indices. All other indices in a Method Component are two-byte values.
The Reference Location Component is not referenced by any other component in this CAP
file.
The Reference Location Component structure is defined as:
reference_location_component {
u1 tag
u2 size
u2 byte_index_count
u1 offsets_to_byte_indices[byte_index_count]
u2 byte2_index_count
u1 offsets_to_byte2_indices[byte2_index_count]
}
The items of the reference_location_component
structure are as follows:
The tag item has the value COMPONENT_ReferenceLocation
(9).
The size
item indicates the number of bytes in the reference_location_component
structure, excluding the tag
and size
items. The value of the size
item must be greater than zero.
The byte_index_count
item represents the number of elements in the offsets_to_byte_indices
array.
The offsets_to_byte_indices
item represents an array of 1-byte jump offsets into the info
item of the Method Component to each 1-byte constant_pool[]
array index. Each entry represents the number of bytes (or distance) between the current index to the next. If the distance is greater than or equal to 255 then there are n entries equal to 255 in the array, where n is equal to the distance divided by 255. The nth entry of 255 is followed by an entry containing the value of the distance modulo 255.
An example of the jump offsets in an offsets_to_byte_indices
array is shown in the following table.
Instruction
|
Offset to Operand
|
Jump Offset
|
||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
getfield_a 0
|
10
|
10
|
||||||||||||
putfield_b 2
|
65
|
55
|
||||||||||||
|
|
255
|
||||||||||||
|
|
255
|
||||||||||||
getfield_s 1
|
580
|
5
|
||||||||||||
|
|
255
|
||||||||||||
putfield_a 0
|
835
|
0
|
||||||||||||
getfield_i 3
|
843
|
8
|
||||||||||||
All 1-byte constant_pool[]
array indices in the Method Component must be represented in offsets_to_byte_indices
array.
The byte2_index_count
item represents the number of elements in the offsets_to_byte2_indices
array.
The offsets_to_byte2_indices
item represents an array of 1-byte jump offsets into the info item of the Method Component to each 2-byte constant_pool[]
array index. Each entry represents the number of bytes (or distance) between the current index to the next. If the distance is greater than or equal to 255 then there are n entries equal to 255 in the array, where n is equal to the distance divided by 255. The nth entry of 255 is followed by an entry containing the value of the distance modulo 255.
An example of the jump offsets in an offsets_to_byte_indices
array is shown in TABLE 35. The same example applies to the offsets_to_byte2_indices
array if the instructions are changed to those with 2-byte constant_pool[]
array indices.
All 2-byte constant_pool[]
array indices in the Method Component must be represented in offsets_to_byte2_indices
array, including those represented in catch_type_index
items of the exception_handler_info
array.
The Export Component lists all static elements in this package that may be imported by classes in other packages. Instance fields and virtual methods are not represented in the Export Component.
If this CAP
file does not include an Applet Component (Section 6.5 "Applet Component”), the Export Component contains an entry for each public
class and public
interface defined in this package. Furthermore, for each public
class there is an entry for each public
or protected static
field defined in that class, for each public
or protected static
method defined in that class, and for each public
or protected constructor defined in that class. Final static
fields of primitive types (compile-time constants) are not included.
If this CAP
file includes an Applet Component (Section 6.5 "Applet Component”), the Export Component includes entries only for all public
interfaces that are shareable.9 An interface is shareable if and only if it is the javacard.framework.Shareable
interface or implements (directly or indirectly) that interface.
Elements in the Export 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”). No other component in this CAP
file references the Export Component.
The Export Component is represented by the following structure:
export_component {
u1 tag
u2 size
u1 class_count
class_export_info {
u2 class_offset
u1 static_field_count
u1 static_method_count
u2 static_field_offsets[static_field_count]
u2 static_method_offsets[static_method_count]
} class_exports[class_count]
}
The items of the export_component
structure are as follows:
The tag
item has the value COMPONENT_Export
(10).
The size
item indicates the number of bytes in the export_component
structure, excluding the tag
and size
items. The value of the size
item must be greater than zero.
The class_count
item represents the number of entries in the class_exports
table. The value of the class_count
item must be greater than zero.
The class_exports
item represents a variable-length table of class_export_info
structures. If this package is a library package, the table contains an entry for each of the public
classes and public
interfaces defined in this package. If this package is an applet package, the table contains an entry for each of the public
shareable interfaces defined in this package.
An index into the table to a particular class or interface is equal to the token value of that class or interface (Section 4.3.7.2 "Classes and Interfaces”). The token value is published in the Export
file (Section 5.7 "Classes and Interfaces”) of this package.
The items in the class_export_info
structure are:
The class_offset
item represents a byte offset into the info
item of the Class Component (Section 6.8 "Class Component”). If this package defines a library package, the item at that offset must be either an interface_info
or a class_info
structure. The interface_info
or class_info
structure at that offset must represent the exported class or interface.
If this package defines an applet package, the item at the class_offset
in the info
item of the Class Component must be an interface_info
structure. The interface_info
structure at that offset must represent the exported, shareable interface. In particular, the ACC_SHAREABLE
flag of the interface_info
structure must be equal to 1.
The static_field_count
item represents the number of elements in the static_field_offsets
array. This value indicates the number of public
and protected static
fields defined in this class, excluding final
static
fields of primitive types.
If the class_offset
item represents an offset to an interface_info
structure, the value of the static_field_count
item must be zero.
The static_method_count
item represents the number of elements in the static_method_offsets
array. This value indicates the number of public
and protected static
methods and constructors defined in this class.
If the class_offset
item represents an offset to an interface_info
structure, the value of the static_method_count
item must be zero.
The static_field_offsets
item represents an array of 2-byte offsets into the static field image defined by the Static Field Component (Section 6.10 "Static Field Component”). Each offset must be to the beginning of the representation of the exported static field.
An index into the static_field_offsets
array must be equal to the token value of the field represented by that entry. The token value is published in the Export
file (Section 5.9 "Methods”) of this package.
The static_method_offsets
item represents a table of 2-byte offsets into the info
item of the Method Component (Section 6.9 "Method Component”). Each offset must be to the beginning of a method_info
structure. The method_info
structure must represent the exported static method or constructor.
An index into the static_method_offsets
array must be equal to the token value of the method represented by that entry.
The Descriptor Component provides sufficient information to parse and verify all elements of the CAP
file. It references, and therefore describes, elements in the Constant Pool Component (Section 6.7 "Constant Pool Component”), Class Component (Section 6.8 "Class Component”), Method Component (Section 6.9 "Method Component”), and Static Field Component (Section 6.10 "Static Field Component”). No components in the CAP
file reference the Descriptor Component.
The Descriptor Component is represented by the following structure:
descriptor_component {
u1 tag
u2 size
u1 class_count
class_descriptor_info classes[class_count]
type_descriptor_info types
}
The items of the descriptor_component
structure are as follows:
The tag
item has the value COMPONENT_Descriptor
(11).
The size
item indicates the number of bytes in the descriptor_component
structure, excluding the tag
and size
items. The value of the size
item must be greater than zero.
The class_count
item represents the number of entries in the classes
table.
The classes
item represents a table of variable-length class_descriptor_info
structures. Each class and interface defined in this package is represented in the table.
The types
item represents a type_descriptor_info
structure. This structure lists the set of field types and method signatures of the fields and methods defined or referenced in this package. Those referenced are enumerated in the Constant Pool Component.
The class_descriptor_info
structure is used to describe a class or interface defined in this package:
class_descriptor_info {
u1 token
u1 access_flags
class_ref this_class_ref
u1 interface_count
u2 field_count
u2 method_count
class_ref interfaces [interface_count]
field_descriptor_info fields[field_count]
method_descriptor_info methods[method_count]
}
The items of the class_descriptor_info
structure are as follows:
The token
item represents the class token (Section 4.3.7.2 "Classes and Interfaces”) of this class or interface. If this class or interface is package-visible it does not have a token assigned. In this case the value of the token
item must be 0xFF.
The access_flags
item is a mask of modifiers used to describe the access permission to and properties of this class or interface. The access_flags
modifiers for classes and interfaces are shown in the following table.
Name
|
Value
|
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ACC_PUBLIC
|
0x01
|
|||||||||||||
ACC_FINAL
|
0x10
|
|||||||||||||
ACC_INTERFACE
|
0x40
|
|||||||||||||
ACC_ABSTRACT
|
0x80
|
|||||||||||||
The class access and modifier flags defined in the table above are a subset of those defined for classes and interfaces in a Java class
file. They have the same meaning, and are set under the same conditions, as the corresponding flags in a Java class
file.
All other flag values are reserved. Their values must be zero.
The this_class_ref
item is a class_ref
structure indicating the location of the class_info
structure in the Class Component (Section 6.8 "Class Component”). The class_ref
structure is defined as part of the CONSTANT_Classref_info
structure (Section 6.7.1 "CONSTANT_Classref”).
The interface_count
item represents the number of entries in the interfaces
array. For an interface, interface_count
is always set to zero.
The field_count
item represents the number of entries in the fields
array. If this class_descriptor_info
structure represents an interface, the value of the field_count
item is equal to zero.
Static
final
fields of primitive types are not represented as fields in a CAP
file, but instead these compile-time constants are placed inline in bytecode sequences. The field_count
item does not include static final field of primitive types defined by this class.
The method_count
item represents the number of entries in the methods
array.
The interfaces
item represents an array of interfaces implemented by this class. The elements in the array are class_ref
structures indicating the location of the interface_info
structure in the Class Component (Section 6.8 "Class Component”). The class_ref
structure is defined as part of the CONSTANT_Classref_info
structure (Section 6.7.1 "CONSTANT_Classref”).
The fields
item represents an array of field_descriptor_info
structures. Each field declared by this class is represented in the array, except static
final
fields of primitive types. Inherited fields are not included in the array.
The methods
item represents an array of method_descriptor_info
structures. Each method declared or defined by this class or interface is represented in the array. For a class, inherited methods are not included in the array. For an interface, inherited methods are included in the array.
The field_descriptor_info
structure is used to describe a field defined in this package:
field_descriptor_info {
u1 token
u1 access_flags
union {
static_field_ref static_field
{
class_ref class
u1 token
} instance_field
} field_ref
union {
u2 primitive_type
u2 reference_type
} type
}
The items of the field_descriptor_info
structure are as follows:
The token
item represents the token of this field. If this field is private or package-visible static field it does not have a token assigned. In this case the value of the token
item must be 0xFF.
The access_flags
item is a mask of modifiers used to describe the access permission to and properties of this field. The access_flags
modifiers for fields are shown in the following table.
Name
|
Value
|
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ACC_PUBLIC
|
0x01
|
|||||||||||||
ACC_PRIVATE
|
0x02
|
|||||||||||||
ACC_PROTECTED
|
0x04
|
|||||||||||||
ACC_STATIC
|
0x08
|
|||||||||||||
ACC_FINAL
|
0x10
|
|||||||||||||
The field access and modifier flags defined in the table above are a subset of those defined for fields in a Java class
file. They have the same meaning, and are set under the same conditions, as the corresponding flags in a Java class
file.
All other flag values are reserved. Their values must be zero.
The field_ref
item represents a reference to this field. If the ACC_STATIC
flag is equal to 1, this item represents a static_field_ref
as defined in the CONSTANT_StaticFieldref
structure (Section 6.7.3 "CONSTANT_StaticFieldref and CONSTANT_StaticMethodref”).
If the ACC_STATIC
flag is equal to 0, this item represents a reference to an instance field. It contains a class_ref
item and an instance field token
item. These items are defined in the same manner as in the CONSTANT_InstanceFieldref
structure (Section 6.7.2 "CONSTANT_InstanceFieldref, CONSTANT_VirtualMethodref, and CONSTANT_SuperMethodref”).
The type
item indicates the type of this field. directly or indirectly. If this field is a primitive type (boolean
, byte
, short
, or int
) the high bit of this item is equal to 1, otherwise the high bit of this item is equal to 0.
The primitive_type
item represents the type of this field using the values in the table below. As noted above, the high bit of the primitive_type
item is equal to 1.
Data Type
|
Value
|
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
boolean
|
0x0002
|
|||||||||||||
byte
|
0x0003
|
|||||||||||||
short
|
0x0004
|
|||||||||||||
int
|
0x0005
|
|||||||||||||
The reference_type
item represents a 15-bit offset into the type_descriptor_info
structure. The item at the offset must represent the reference
type of this field. As noted above, the high bit of the reference_type
item is equal to 0.
The method_descriptor_info
structure is used to describe a method defined in this package. This structure contains sufficient information to locate and parse the methods in the Method Component, while the Method Component does not.
method_descriptor_info {
u1 token
u1 access_flags
u2 method_offset
u2 type_offset
u2 bytecode_count
u2 exception_handler_count
u2 exception_handler_index
}
The items of the method_descriptor_info
structure are as follows:
The token
item represents the static method token (Section 4.3.7.4 "Static Methods and Constructors”) or virtual method token (Section 4.3.7.6 "Virtual Methods”) or interface method token (Section 4.3.7.7 "Interface Methods”) of this method. If this method is a private or package-visible static method, a private or package-visible constructor, or a private virtual method it does not have a token assigned. In this case the value of the token
item must be 0xFF.
The access_flags
item is a mask of modifiers used to describe the access permission to and properties of this method. The access_flags
modifiers for methods are shown in the following table.
Name
|
Value
|
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ACC_PUBLIC
|
0x01
|
|||||||||||||
ACC_PRIVATE
|
0x02
|
|||||||||||||
ACC_PROTECTED
|
0x04
|
|||||||||||||
ACC_STATIC
|
0x08
|
|||||||||||||
ACC_FINAL
|
0x10
|
|||||||||||||
ACC_ABSTRACT
|
0x40
|
|||||||||||||
ACC_INIT
|
0x80
|
|||||||||||||
The method access and modifier flags defined in the table above, except the ACC_INIT
flag, are a subset of those defined for methods in a Java class
file. They have the same meaning, and are set under the same conditions, as the corresponding flags in a Java class
file.
The ACC_INIT
flag is set if the method descriptor identifies a constructor methods. In Java a constructor method is recognized by its name, <init>
, but in Java Card systems, the name is replaced by a token. As in the Java verifier, these methods require special checks by the verifier for the Java Card platform (“Java Card verifier”).
All other flag values are reserved. Their values must be zero.
If the class_descriptor_info
structure that contains this method_descriptor_info
structure represents a class, the method_offset
item represents a byte offset into the info
item of the Method Component (Section 6.9 "Method Component”). The element at that offset must be the beginning of a method_info
structure. The method_info
structure must represent this method.
If the class_descriptor_info
structure that contains this method_descriptor_info
structure represents an interface, the value of the method_offset
item must be zero.
The type_offset
item must be a valid offset into the type_descriptor_info
structure. The type described at that offset represents the signature of this method.
The bytecode_count
item represents the number of bytecodes in this method. The value is equal to the length of the bytecodes
array item in the method_info
structure in the method component (Section 6.9 "Method Component”) of this method.
The exception_handler_count
item represents the number of exception handlers implemented by this method.
The exception_handler_index
item represents the index to the first exception_handlers
table entry in the method component (Section 6.9 "Method Component”) implemented by this method. Succeeding exception_handlers
table entries, up to the value of the exception_handler_count
item, are also exception handlers implemented by this method.
The value of the exception_handler_index
item is 0 if the value of the exception_handler_count
item is 0.
The type_descriptor_info
structure represents the types of fields and signatures of methods defined in this package:
type_descriptor_info {
u2 constant_pool_count
u2 constant_pool_types[constant_pool_count]
type_descriptor type_desc[]
}
The type_descriptor_info
structure contains the following elements:
The constant_pool_count
item represents the number of entries in the constant_pool_types
array. This value is equal to the number of entries in the constant_pool
array of the Constant Pool Component (Section 6.7 "Constant Pool Component”).
The constant_pool_types
item is an array that describes the types of the fields and methods referenced in the Constant Pool Component. This item has the same number of entries as the constant_pool[]
array of the Constant Pool Component, and each entry describes the type of the corresponding entry in the constant_pool[]
array.
If the corresponding constant_pool[]
array entry represents a class or interface reference, it does not have an associated type. In this case the value of the entry in the constant_pool_types
array item is 0xFFFF.
If the corresponding constant_pool[]
array entry represents a field or method, the value of the entry in the constant_pool_types
array is an offset into the type_descriptor_info
structure. The element at that offset must describe the type of the field or the signature of the method.
The type_desc
item represents a table of variable-length type_descriptor
structures. These descriptors represent the types of fields and signatures of methods. For a description of the type_descriptor
structure, see section Section 6.8.1 "type_descriptor”.
This section specifies the format for the Debug Component. The Debug Component contains all the metadata necessary for debugging a package on a suitably instrumented Java Card virtual machine. It is not required for executing Java Card programs in a non-debug environment.
The Debug Component references 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”). No components reference the Debug Component.
The Debug Component is represented by the following structure:
debug_component {
u1 tag
u2 size
u2 string_count
utf8_info strings_table[string_count]
u2 package_name_index
u2 class_count
class_debug_info classes[class_count]
}
The items in the debug_component
structure are defined as follows:
The tag item has the value COMPONENT_Debug
(12).
The number of bytes in the component, excluding the tag
and size
items. The value of size
must be greater than zero.
The number of strings in the strings_table[]
table.
A table of all the strings used in this component. Various items that occur through this component represent unsigned two-byte indices into this table.
Each entry in the table is a utf8_info
structure. A utf8_info
structure is represented by the following structure:
The items in the utf8_info
structure are defined as follows:
The number of bytes in the string.
The bytes of the string in UTF-8 format.
Contains an index into the strings_table[]
item. The strings_table[]
item entry referenced by this index must contain the fully-qualified name of the package in this CAP
file.
The number of classes in the classes table.
Contains a single class_debug_info[]
structure for each class in this package.
The class_debug_info
structure contains all of the debugging information for a class or interface. It also contains tables of debugging information for all its classes’ fields and methods.
class_debug_info {
u2 name_index
u2 access_flags
u2 location
u2 superclass_name_index
u2 source_file_index
u1 interface_count
u2 field_count
u2 method_count
u2 interface_names_indexes[interface_count]
field_debug_info fields[field_count]
method_debug_info methods[method_count]
}
The items in the class_debug_info
structure are defined as follows:
Contains an index into the strings_table[]
item of the debug_component
structure. The strings_table[]
entry at the indexed location must be the fully-qualified name of this class.
A two-byte mask of modifiers that apply to this class. The modifiers are:
Modifier
|
Value
|
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ACC_PUBLIC
|
0x0001
|
|||||||||||||
ACC_FINAL
|
0x0010
|
|||||||||||||
ACC_REMOTE
|
0x0020
|
|||||||||||||
ACC_INTERFACE
|
0x0200
|
|||||||||||||
ACC_ABSTRACT
|
0x0400
|
|||||||||||||
ACC_SHAREABLE
|
0x0800
|
|||||||||||||
The ACC_SHAREABLE
flag indicates whether this class or interface is shareable.10 A class is shareable if it implements (directly or indirectly) the javacard.framework.Shareable
interface. An interface is shareable if it is or extends (directly or indirectly) the javacard.framework.Shareable
interface.
The ACC_REMOTE
flag indicates whether this class or interface is remote. The value of this flag must be one if and only if the class or interface satisfies the requirements defined in Section 2.2.6.1 "Remote Classes and Remote Interfaces”.
All other class access and modifier flags are defined in the same way and with the same restrictions as described in The Java‘ Virtual Machine Specification.
The byte offset of the class_info
or interface_info
record for this class or interface into the info
item of the Class Component (Section 6.8 "Class Component”).
Contains an index into the strings_table[]
item of the debug_component
structure. The strings_table[]
entry at the indexed location must be the fully-qualified name of the superclass of this class or the string “null
” if the class has no superclass.
Contains the index into the strings_table[]
item of the debug_component
structure. The strings_table[]
entry at the indexed location must be the name of the source file in which this class is defined.
The number of indexes in the interface_names_indexes[]
table.
The number of field_debug_info
structures in the fields[]
table.
The number of method_debug_info
structures in the methods[]
table.
Contains the indexes into the strings_table[]
item of the debug_component
structure. The strings_table[]
entry at each indexed location must be the name of an interface implemented by this class. There must be an index value present for every interface implemented by this class, including interfaces implemented by superclasses of this class and superinterfaces of the implemented interfaces.
If ACC_INTERFACE
is set, the strings_table[]
entry at each indexed location must be the name of a super interface directly or indirectly extended by this interface. There must be an index value present for every super interface directly or indirectly extended by this interface.
Contains field_debug_info
structures for all the fields declared by this class, including static
final
fields of primitive types. Inherited fields are not included in this array.
Contains method_debug_info
structures for all the methods declared or defined in this class. Inherited methods are not included in this array.
The field_debug_info
structure describes a field in a class. It can describe either an instance field, a static field, or a constant (primitive final static) field. The contents
union will have the form of a token_var
if the field is an instance field, a location_var
if it is a static field, or a const_value
if it is a constant.
The field_debug_info
structure is defined as follows:
field_debug_info {
u2 name_index
u2 descriptor_index
u2 access_flags
union {
{
u1 pad1
u1 pad2
u1 pad3
u1 token
} token_var
{
u2 pad
u2 location
} location_var
u4 const_value
} contents
}
The items in the field_debug_info
structure are defined as follows:
Contains an index into the strings_table[]
item of the debug_component
structure. The strings_table[]
entry at the indexed location must be the simple (i.e. not fully-qualified) name of the field (for example, “applets
”).
Contains an index into the strings_table[]
item of the debug_component
structure. The strings_table[]
entry at the indexed location must be the type of the field. Class types are fully-qualified (for example, “[Ljavacard/framework/Applet;
”).
A two-byte mask of modifiers that apply to this field.
Modifier
|
Value
|
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ACC_PUBLIC
|
0x0001
|
|||||||||||||
ACC_PRIVATE
|
0x0002
|
|||||||||||||
ACC_PROTECTED
|
0x0004
|
|||||||||||||
ACC_STATIC
|
0x0008
|
|||||||||||||
ACC_FINAL
|
0x0010
|
|||||||||||||
The above field access and modifier flags are defined in the same way and with the same restrictions as described in Java™ Virtual Machine Specification.
A field_debug_info
structure can describe an instance field, a static field, or a static final field (a constant). Constants can be either primitive data or arrays of primitive data. Depending on the kind of field described, the contents
item is interpreted in different ways. The kind and type of the field can be determined by examining the field’s descriptor and access flags.
If the field is an instance field, this value is the instance field token of the field. The pad1
, pad2
, and pad3
items are padding only; their values should be ignored.
If the field is a non-final static field or a final static field with an array type (a constant array), this value is the byte offset of the location for this field in the static field image defined by the Static Field Component (Section 6.10 "Static Field Component”). The pad
item is padding only; its value should be ignored.
If the field is a final static field of type byte
, boolean
, short
, or int
, this value is interpreted as a signed 32-bit constant.
The method_debug_info
structure describes a method of a class. It can describe methods that are either virtual or non-virtual (static or initialization methods). The structure is defined as follows:
method_debug_info {
u2 name_index
u2 descriptor_index
u2 access_flags
u2 location
u1 header_size
u2 body_size
u2 variable_count
u2 line_count
variable_info variable_table[variable_count]
line_info line_table[line_count]
}
The items in the method_debug_info
structure are defined as follows:
Contains an index into the strings_table[]
item of the debug_component
structure. The strings_table[]
entry at the indexed location must be the simple (i.e. not fully-qualified) name of the method (e.g. “lookupAID
”).
Contains an index into the strings_table[]
item of the debug_component
structure. The strings_table[]
entry at the indexed location must be the argument and return types of the method (i.e. the signature without the method name). Class types are fully-qualified (for example, “([BSB)Ljavacard/framework/AID;
”)
A two-byte mask of modifiers that apply to this method.
Modifier
|
Value
|
|||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
ACC_PUBLIC
|
0x0001
|
|||||||||||||
ACC_PRIVATE
|
0x0002
|
|||||||||||||
ACC_PROTECTED
|
0x0004
|
|||||||||||||
ACC_STATIC
|
0x0008
|
|||||||||||||
ACC_FINAL
|
0x0010
|
|||||||||||||
ACC_NATIVE
|
0x0100
|
|||||||||||||
ACC_ABSTRACT
|
0x0400
|
|||||||||||||
The ACC_NATIVE
flag is only valid for methods of a package located in the card mask. It cannot be used for methods contained in a CAP
file.
All other method access and modifier flags are defined in the same way and with the same restrictions as described in The Java‘ Virtual Machine Specification.
A byte offset of the method_info
structure for this method into the info
item of the Method Component (Section 6.9 "Method Component”). Abstract methods have a location of zero.
The size in bytes of the header of the method. Abstract methods have a header_size
of zero.
The size in bytes of the body of the method, not including the method header. Abstract methods have a body_size
of zero.
The number of variable_info
entries in the variable_table[]
item. Abstract methods have a variable_count
of zero.
The number of line_info
entries in the line_table[]
item. Abstract methods have a line_count
of zero.
Contains the variable_info
structures for all variables in this method.
The variable_info
structure describes a single local variable of a method. It indicates the index into the local variables of the current frame at which the local variable can be found, as well as the name and type of the variable. It also indicates the range of bytecodes within which the variable has a value.
The items in the variable_info
structure are defined as follows:
The index of the variable in the local stack frame, as used in load and store bytecodes. If the variable at index
is of type int
, it occupies both index
and index + 1
.
Contains an index into the strings_table[]
item of the debug_component
structure. The strings_table[]
entry at the indexed location must be the name of the local variable. (e.g. “applets
”).
Contains an index into the strings_table[]
item of the debug_component
structure. The strings_table[]
entry at the indexed location must be the type of the local variable. Class types are fully-qualified (e.g. “[Ljavacard/framework/Applet;
”).
The index of the first bytecode in which the variable is in-scope and valid.
Number of bytecodes in which the variable is in-scope and valid. The value of start_pc + length
will be either the index of the next bytecode after the valid range, or the first index beyond the end of the bytecode array.
Contains the line_info
structures that map bytecode instructions of this method to lines in the class’s source file.
Each line_info
item represents a mapping of a range of bytecode instructions to a particular line in the source file that contains the method. The range of instructions is from start_pc
to end_pc
, inclusive. start_pc
and end_pc
represent a zero-based byte offset within the method. The source_line
is the one-based line number in the source file. The structure is defined as follows:
The items in the line_info
structure are defined as follows:
The byte offset of the first bytecode in the range of instructions.
The byte offset of the last operand of the last bytecode in the range of instructions.
Line number in the source file.
install(byte[],short,byte)
method of
an applet are imposed by the Runtime Environment Specification for the Java
Card™ Platform, Version 2.2.1. CONSTANT_StaticMethodref
when the method referenced is a constructor or a private instance method. In
these cases the method invoked is fully known when the CAP file is created.
In the cases of virtual method and super method references, the method invoked
is dependent upon an instance of a class and its hierarchy, both of which may
be partially unknown when the CAP file is created. interface_name[]
item is required if the value of ACC_REMOTE
is one. This item must be omitted otherwise. See the description of this field
for more information. remote_interfaces
item is required if the value of ACC_REMOTE
is one. This item must be omitted otherwise. See the description of this field
for more information. ACC_SHAREABLE
flag to implement
the firewall restrictions defined by the Runtime Environment Specification
for the Java Card™ Platform, Version 2.2.1. max_locals
item includes both the local variables declared by the method and the parameters
passed to the method. ACC_SHAREABLE
flag is defined to enable Java Card virtual machines
to implement the firewall restrictions defined by the Runtime Environment
Specification for the Java Card™ Platform, Version 2.2.1.
![]() ![]() ![]() ![]() |
Virtual Machine Specification for the Java Card Platform Specification, 2.2.1 |
Copyright © 2003 Sun Microsystems, Inc. All rights reserved.