(JavaCard)JavaCard222VM Spec(JavaCard 2.2.2 虚拟机规范-中英文对照,第五章)

来源:互联网 发布:linux设置ftp用户目录 编辑:程序博客网 时间:2024/06/08 19:37


The Export File Format
Export文件格式

 

This chapter describes the export file format. Compliant Java Card Converters must
be capable of producing and consuming all export files that conform to the
specification provided in this chapter.
这章描述了export文件的格式。一个完善的java卡converter必须能产生这章规定导出文件。

 

An export 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.
导出文件包含8比特的字节流。所以的16-bit和32-bit的单元都是通过读两个和四个字节组成的。所有的多字节都是大端次序,高字节先读。

 

This chapter defines its own set of data types representing Java Card export file
data: the types u1, u2, and u4 represent an unsigned one-, two-, and four-byte
quantities, respectively.
这章定义了java卡导出文件子集的数据类型定义。类型u1,u2,和u4分别由无符号的一个,两个和四个字节组成。

 

The Java Card export 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 export 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.
java卡导出文件格式是使用C结构体风格的伪码实现的。为避免和java卡虚拟机的类和类实例混淆,描述java卡导出文件格式的内容是基于对象的。和C结构体不同,连续的对象在java卡平台中连续存储,没有填充和对齐。

 

Variable-sized tables, consisting of variable-sized items, are used in several export
file structures. Although we will use C-like array syntax to refer to table items, the
fact that tables are streams of varying-sized structures means that it is not possible to
directly translate a table index into a byte offset into the table.
在若干导出文件的结构里使用到了由变长的对象组成的变长的表。
尽管我们将使用C风格的数组语法来标识表对象,实际上变长结构的表不可能直接把表下表翻译成表中的字节偏移。

 

In a data structure that is referred to as an array, the elements are equal in size.
在映射成数组的数据结构,元素的大小相同。

 

5.1 Export File Name
5.1 导出文件名

 

As described in Section 4.1.1, “Export File Format” on page 4-2, the name of a export
file must be the last portion of the package specification followed by the extension
‘.exp’. For example, the name of the export file of the javacard.framework
package must be framework.exp. Operating systems that impose limitations on file
name lengths may transform an export file’s name according to its conventions.
在4.1.1章描述的一样,导出文件名必须是包名称的最后一部分加上.exp后缀。举个例子,包javacard.framework的导出文件名必须是framework.exp。如果操作系统有长度限制,则会根据其规则自动转化。

 

5.2 Containment in a JAR File
5.2 包含在JAR文件中

As described in Section 4.1.3, “JAR File Container” on page 4-2, Java Card CAP files
are contained in a JAR file. If an export file is also stored in a JAR file, it must also be
located in a directory called javacard that is a subdirectory of the package’s
directory. For example, the framework.exp file would be located in the
subdirectory javacard/framework/javacard
在4.1.3中描述的一样,如果导出文件也被存储在JAR文件中,它必须存放于包名对应目录下面的javacard目录下。举个例子,framework.exp必须存在javacard/framework/javacard下。

 

5.3 Ownership
5.3 所有权

 

An export file is owned by the entity that owns the package it represents. The
owner of a package defines the API of that package, and may or may not provide all
implementations of that package. All implementations, however, must conform to
the definition provided in the export file provided by the owner.
A particular example of export file ownership is the Java Card API packages. Sun
Microsystems, Inc. defines these packages. Sun Microsystems, Inc. also provides the
export files for these packages. All implementations of the Java Card API packages
must conform to the definitions provided by Sun Microsystems, Inc., and comply
with the token assignments provided in these export files.
导出文件由提供包实现的实体拥有。包的所有者定义了这个包的API,并且可以提供或者不提供这个包的所有实现。所有的实现也必须和导出文件中的定义相符。
一个关于java卡导出文件的具体例子是java卡API包。sun公司定义了这些包,sun公司也提供了这些包的export文件。所有java卡API包的实现必须遵守sun公司的定义,并且遵从这些导出文件的令牌组织。

 

5.4 Hierarchies Represented
5.4 层次关系

 

Classes and interfaces represented in an export file include public elements defined
within their respective hierarchies. For example, instead of indicating the immediate
superclass or superinterface, all public superclasses or superinterfaces are listed.
This design concept is applied not only to superclasses or superinterfaces, but also to
virtual methods and implemented interfaces.
导出文件中的类和接口包含定义在他们各自层次下的公有元素。举个例子,列出所有的父类和父接口来替代标明直接父类。这种设计理念不止在父类或者父接口处使用,也是用在虚方法和声明接口处。

 

5.5 Export File
5.5 导出文件

 

An export file is defined by the following structure:
一个导出文件使用如下的结构定义:

ExportFile {
u4 magic
u1 minor_version
u1 major_version
u2 constant_pool_count
cp_info constant_pool[constant_pool_count]
u2 this_package
u1 export_class_count
class_info classes[export_class_count]
}

The items in the ExportFile structure are as follows:
Export结构里面的对象的结构如下:

magic
The magic item contains the magic number identifying the ExportFile format;
it has the value 0x00FACADE.
魔术码
魔术码包含了魔术字来标识Export文件,它的值是0x00FACADE

 

minor_version, major_version
The minor_version and major_version items are the minor and major
version numbers of this export file. Together, a major and a minor version
number determine the version of the export file format. If an export file has the
major version number of M and minor version number of m, the version of the
export 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 virtual machine. A Java
Card virtual machine is not required to support export files with different major
version numbers. A Java Card virtual machine is required to support export 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.
次要版本,主要版本
minor_version和major_version对象是导出文件的版本号。主要版本和次要版本一起决定了导出文件的版本。如果一个导出文件拥有一个主要版本号M,和一个次要版本号m,那么导出文件的版本号是M.m。
主版本号的修改对应着一个主要的不兼容的修改,在java虚拟机上有根本的不同。java卡虚拟机不要求支持不同主版本号的导出文件。java卡虚拟机要求支持拥有给定的主版本号和所有可能的0-特定值次要版本号的导出文件。

In this specification, the major version of the export 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 export file format versions.
在这个规范里,导出文件的主版本号格式的值是2,次版本号的值是2.只有sun公司可以在新的导出文件中定义新的含义和值。

 

constant_pool_count
The constant_pool_count item is a non-zero, positive value that indicates the
number of constants in the constant pool.
常量池个数
常量池个数是一个非零的正数,用来表示常量池内常量的个数。

 

constant_pool[]
The constant_pool is a table of variable-length structures representing various
string constants, class names, field names and other constants referred to within
the ExportFile structure.
Each of the constant_pool table entries, including entry zero, is a variable-
length structure whose format is indicated by its first “tag” byte.
There are no ordering constrains on entries in the constant_pool table.
常量池
常量池是一个一个由变长串常量,类名,属性名和其它导出文件里面使用的常量组成的变长结构表。
每个常量池表的入口,包括0入口,都是一个第一个字符是“标签”的变长结构体。
常量池的入口没有次序限制。

 

this_package
The value of this_package must be a valid index into the constant_pool
table. The constant_pool entry at that index must be a
CONSTANT_Package_info (Section 5.6.1, “CONSTANT_Package” on page 5-5)
structure representing the package defined by this ExportFile.
本包
this_package这个值必须是一个指向常量池的有效索引。对应的入口必须是一个复合导出文件规定的COSTANT_Package_Info结构。

 

export_class_count
The value of the export_class_count item gives the number of elements in the
classes table.
导出类的个数
export_class_count的值给出了classes表中的元素数目。

 

classes[]
Each value of the classes table is a variable-length class_info structure
(Section 5.7, “Classes and Interfaces” on page 5-8) giving the description of a
publicly accessible class or interface declared in this package. If the ACC_LIBRARY
flag item in the CONSTANT_Package_info (Section 5.6.1,
“CONSTANT_Package” on page 5-5) structure indicated by the this_package item
is set, the classes table has an entry for each public class and interface declared in
this package. If the ACC_LIBRARY flag item is not set, the classes table has an
entry for each public shareable interface declared in this package.

每个类表的值是一个变长的class_info结构,用以描述本包中公有访问权限的类和接口。如果this_package指向的CONSTANT_Package_info中存在ACC_LIBRARY标志,包中的每个公有的类和接口都在classes里面拥有入库哦,否则classes表里面为每个公有的共享接口提供入口。

 

5.6 Constant Pool
5.6 常量池

 

All constant_pool table entries have the following general format:
所有的常量池表入口都遵从如下一般格式。
cp_info {
u1 tag
u1 info[]
}

Each item in the constant_pool must begin with a 1-byte tag indicating the kind
of cp_info entry. The content of the info array varies with the value of tag. The
valid tags and their values are listed in TABLE 5-1. Each tag byte must be followed by
two or more bytes giving information about the specific constant. The format of the
additional information varies with the tag value.
在常量池的每个对象都以一个字节的标签来表示后边cp_info入口的类型。info数组的内容根据标签的不同而不同。有效的标签和他们的值在TABLE 5-1中列举。每个标签字节必须被两个或者更多提供特定常量的字符跟随。结构根据标签不同而不同。
TABLE 5-1  Export File Constant Pool Tags

Constant Type      Value
CONSTANT_Package     13
CONSTANT_Classref    7
CONSTANT_Integer     3
CONSTANT_Utf8      1

5.6.1 CONSTANT_Package
5.6.1 包常量

The CONSTANT_Package_info structure is used to represent a package:
包常量信息结构用来描述一个包

The items of the CONSTANT_Package_info structure are the following:
包常量信息结构如下:

CONSTANT_Package_info {
u1 tag
u1 flags
u2 name_index
u1 minor_version
u1 major_version
u1 aid_length
u1 aid[aid_length]

}

tag
The tag item has the value of CONSTANT_Package (13).
标签
包常量的标签是 13

flags
The flags item is a mask of modifiers that apply to this package. The flags
modifiers are shown in the following table.
标记
标记对象用来标识包的使用,标记有如下的值

TABLE 5-2  Export File Package Flags
Flags       Value
ACC_LIBRARY    0x01

The ACC_LIBRARY flag has the value of one if this package does not define and
declare any applets. In this case it is called a library package. Otherwise
ACC_LIBRARY has the value of zero.
If the package is not a library package this export file can only contain shareable
interfaces.
1 A shareable interface is either the
javacard.framework.Shareable interface or an interface that extends the
javacard.framework.Shareable interface.
All other flag values are reserved. Their values must be zero.
如果包不定义和声明任何应用,ACC_LIBRARY标志的值为1。否则ACC_LIBRARY的值是0。
如果包不是库包,导出文件只包含共享接口,共享接口或者是 javacard.framework.Shareable接口,或者是继承于这个接口。
Flag的其它值保留,它们的值必须是0。

name_index
The value of the name_index item must be a valid index into the
constant_pool table. The constant_pool entry at that index must be a
CONSTANT_Utf8_info (Section 5.6.4, “CONSTANT_Utf8” on page 5-7) structure
representing a valid Java package name.
As in Java class files, ASCII periods (‘.’) that normally separate the identifiers in a
package name are replaced by ASCII forward slashes (‘/’). For example, the
package name javacard.framework is represented in a CONSTANT_Utf8_info
structure as javacard/framework.
名子下标
name_index的值必须是一个指向常量池的索引。对应索引对应的入口必须是一个CONSTANT_Utf8结构来描述一个有效的java包名
在java类文件中,用来分隔包名的'.'被’/'替换。举例,包名javacard.framework用常量串来表示是:javacard/framework

minor_version, major_version
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” on page 4-13 for a description of
assigning and using package version numbers.
次要版本,主要版本
次要版本和主要版本项代表了包的主要版本和次要版本。这个值唯一的表示了包的特定实现和包的兼容性。4.5章,“包版本”具体的讲述了包版本号的分配。

aid_length
The value of the aid_length item gives the number of bytes in the aid array.
Valid values are between 5 and 16, inclusive.
AID长度
aid_length的值给出了aid数组的个数。有效的值是5和16之间。

aid[]
The aid array contains the ISO AID of this package (Section 4.2, “AID-based
Naming” on page 4-3).
AID
aid数组包含了这个包的AID数据。

5.6.2 CONSTANT_Classref
5.6.2 类描述常量

The CONSTANT_Classref_info structure is used to represent a class or interface:
类描述常量结构用来描述一个类或者接口。
CONSTANT_Classref_info {
u1 tag
u2 name_index
}

The items of the CONSTANT_Classref_info structure are the following:
类描述常量的结构如下:

tag
The tag item has the value of CONSTANT_Classref (7).
标签
类描述常量的标签是7。

name_index
The value of the name_index item must be a valid index into the
constant_pool table. The constant_pool entry at that index must be a
CONSTANT_Utf8_info (Section 5.6.4, “CONSTANT_Utf8” on page 5-7) structure
representing a valid fully qualified Java class or interface name. This name is fully
qualified since it may represent a class or interface defined in a package other
than the one described in the export file.
As in Java class files, ASCII periods (‘.’) that normally separate the identifiers in a
class or interface name are replaced by ASCII forward slashes (‘/’). For example,
the interface name javacard.framework.Shareable is represented in a
CONSTANT_Utf8_info structure as javacard/framework/Shareable.
名称索引
name_index的值必须是一个指向常量池的索引。对应索引对应的入口必须是一个CONSTANT_Utf8结构来描述一个有效的java类名或者接口名。
在java类文件中,用来分隔包名的'.'被’/'替换。举例,接口名javacard.framework.Shareable用常量串来表示是:javacard/framework/Shareable

5.6.3 CONSTANT_Integer
5.6.3 常量整数
The CONSTANT_Integer_info structure is used to represent four-byte numeric (int)
constants:
常量整数结构是用来描述一个4字节的常数。

The items of the CONSTANT_Integer_info structure are the following:
常量整数结构如下:
CONSTANT_Integer_info {
u1 tag
u4 bytes
}

tag
The tag item has the value of CONSTANT_Integer (3).
标签
常量整数的标签值是3.

bytes
The bytes item of the CONSTANT_Integer_info structure contains the value of
the int constant. The bytes of the value are stored in big-endian (high byte first)
order.
The value of a boolean type is 1 to represent true and 0 to represent false.
数据
常数信息结构中的bytes对象包含了int常数的值。值的是按大端存储到字节中(高字节在前)。

5.6.4 CONSTANT_Utf8
5.6.4 常量串

The CONSTANT_Utf8_info structure is used to represent constant string values.
UTF-8 strings are encoded in the same way as described in The Java Virtual Machine
Specification (§ 4.4.7).
常量串结构用来描述一个常量字符串。常量串和java虚拟机规范中的编码一致。

The CONSTANT_Utf8_info structure is:
常量串的结构如下:

CONSTANT_Utf8_info {
u1 tag
u2 length
u1 bytes[length]
}

tag
The tag item has the value of CONSTANT_Utf8 (1).
标签
常量串的标签值是1。

length
The value of the length item gives the number of bytes in the bytes array (not
the length of the resulting string). The strings in the CONSTANT_Utf8_info
structure are not null-terminated.
长度
length对象给出了bytes数组的长度。在常量串中的串没有结束符。

bytes[]
The bytes array contains the bytes of the string. No byte may have the value
(byte)0 or (byte)0xF0-(byte)0xFF.
字节
bytes数组包含了字符串的字节,不能有值为0,或者0xF0-0xFF的值。

5.7 Classes and Interfaces
5.7 类和接口

Each class and interface is described by a variable-length class_info structure.
The format of this structure is:
每个类和接口都被一个边长的class_info结构描述,结构如下:

class_info {
u1 token
u2 access_flags
u2 name_index
u2 export_supers_count
u2 supers[export_supers_count]
u1 export_interfaces_count
u2 interfaces[export_interfaces_count]
u2 export_fields_count
field_info fields[export_fields_count]
u2 export_methods_count
method_info methods[export_methods_count]
}

The items of the class_info structure are as follows:
类信息对象的结构如下:

token
The value of the token item is the class token (Section 4.3.7.2, “Classes and
Interfaces” on page 4-8) assigned to this class or interface.
标签
标签对象的值是分配给这个类或者接口的类令牌。

access_flags
The value of the access_flags item is a mask of modifiers used with class and
interface declarations. The access_flags modifiers are shown in the following
table.
访问标志
access_flags用来标识类和接口的生命,access_flags的标识如下:

TABLE 5-3  Export File Class Access and Modifier Flags

Name        Value     Meaning           Used By
ACC_PUBLIC     0x0001     Is public;may be       Class, interface
                accessed from outside
                its package

ACC_FINAL     0x0010     Is final; no subclasses   Class
                allowed.

ACC_INTERFACE   0x0200     Is an interface       Interface

ACC_ABSTRACT    0x0400     Is abstract; may not     Class, interface
                be instantiated

ACC_SHAREABLE   0x0800     Is shareable; may be     Class, interface
                shared between Java
                Card applets.

ACC_REMOTE     0x1000     Is remote; may be      Class,interface
                accessed by Java Card
                RMI

The ACC_SHAREABLE flag indicates whether this class or interface is shareable.
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.
ACC_SHAREABLE标识标示这个类或者接口是否是shareable的。一个类只有在它实现了(间接或者直接)javacard.framework.Shareable接口才是shareable类。一个接口只有继承于(直接或者间接)javacard.framework.Shareable接口才是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”
on page 2-12.
ACC_REMOTE标志标示是否这个类或者接口是远程的,在类或者方法满足了第2.2.6.1章的定义这个值才被置真

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.
其它所有的类访问标识和java虚拟机规范定义的一致。

Since all classes and interfaces represented in an export file are public, the
ACC_PUBLIC flag must always be set.
All other flag values are reserved. Their values must be zero.
因为在export文件中的所有类和接口都是公有的,ACC_PUBLIC标志一定被置上。
其它所有的标识值都保留,设置为0。

name_index
The value of the name_index item must be a valid index into the
constant_pool table. The constant_pool entry at that index must be a
CONSTANT_Classref_info (Section 5.6.2, “CONSTANT_Classref” on page 5-6)
structure representing a valid, fully qualified Java class or interface name.
名称索引
name_index的值必须是一个指向常量池的索引。对应索引对应的入口必须是一个CONSTANT_Utf8结构来描述一个有效的java类名或者接口名。

export_supers_count
The value of the export_supers_count item indicates the number of entries in
the supers array.

导出父类数目
export_supers_count对象标识了supers数组的个数。

supers[]
父类

The supers array contains an entry for each public superclass of this class or
interface. It does not include package visible superclasses.
For a class, each value in the supers array must be a valid index into the
constant_pool table. The constant_pool entry at each value must be a
CONSTANT_Classref_info structure (Section 5.6.2, “CONSTANT_Classref” on
page 5-6) representing a valid, fully-qualified Java class name. Entries in the
supers array can occur in any order.
For an interface, the supers array contains a single value representing a valid
index into the constant_pool table. The constant_pool entry must be a
CONSTANT_Classref_info structure (Section 5.6.2, “CONSTANT_Classref” on
page 5-6) representing the fully-qualified name of the java.lang.Object class.
supers数组包含了这个类的所有公有的父类或者接口。不包含包可见的父类。
对一个类来说,supers数组的每个值都指向常量池表。对应的表入口都是CONSTANT_Classref,提供了一个有效的java类名。supers数组里面的入口可以以任何顺序来组织。
对一个接口来说,supers数组的只有唯一的一个值指向常量池,对应的表入口的CONSTANT_Classref的名字是java.lang.Object。

export_interfaces_count
The value of the export_interfaces_count item indicates the number of
entries in the interfaces array.
导出接口数目
export_interface_count对象标识了interface数组的个数。

interfaces[]
接口

If this class_info structure describes a class, the interfaces array contains an
entry for each public interface implemented by this class. It does not include
package-visible interfaces. It does include all public superinterfaces in the
hierarchies of public interfaces implemented by this class.
If this class_info structure describes an interface, the interfaces array
contains an entry for each public interface extended by this interface. It does not
include package visible interfaces. It does include all public superinterfaces in the
hierarchies of public interfaces extended by this interface.
Each value in the interfaces array must be a valid index into the
constant_pool table. The constant_pool entry at each value must be a
CONSTANT_Classref_info structure (Section 5.6.2, “CONSTANT_Classref” on
page 5-6) representing a valid, fully-qualified Java interface name. Entries in the
interfaces array can occur in any order.
如果class_info结构描述了一个类,interface数组包含这个类实现的所有公有接口。不包含包可见的接口。包含这个类实现的接口的所有父接口。
如果class_info结构描述了一个接口,interface数组包含这个接口的所有父接口。不包含包可见的接口。包含这个接口的所有父接口
interface数组里面的每个值都指向常量池的下表,每个入口都是CONSTANT_Classref_info结构。提供一个有效的接口名。interface数组里面的入口可以以任何顺序来组织。

export_fields_count
导出属性个数
The value of the export_fields_count item gives the number of entries in the
fields table.
export_fields_count的值给出了fields表的入口个数。

fields[]
属性

Each value in the fields table is a variable-length field_info (Section 5.8,
“Fields” on page 5-11) structure. The field_info contains an entry for each
publicly accessible field, both class variables and instance variables, declared by
this class or interface. It does not include items representing fields that are
inherited from superclasses or superinterfaces.
fields表中的每个值都是一个边长的field_info结构(见5.8)。field_info为每个类和成员的外部可见的属性提供了一个入口。不包含从父和父接口继承的属性。

export_methods_count
导出方法数
The value of the export_methods_count item gives the number of entries in
the methods table.
export_method_count的值给出了methods表的入口个数

methods[]
方法
Each value in the methods table is a method_info (Section 5.9, “Methods” on
page 5-13) structure. The method_info structure contains an entry for each
publicly accessible class (static or constructor) method defined by this class, and
each publicly accessible instance method defined by this class or its superclasses,
or defined by this interface or its super-interfaces.
method表中的每个值都是一个method_info结构。method_info结构为类中提供的每个外部可见的静态方法,每个本类和其父类定义的的实例方法,或者接口及其父接口定义的实例方法都提供了入口。


5.8 Fields
5.8 属性

Each field is described by a variable-length field_info structure. The format of
this structure is:
每个field都被定义成一个变长的field_info结构。结构如下:
field_info {
u1 token
u2 access_flags
u2 name_index
u2 descriptor_index
u2 attributes_count
attribute_info attributes[attributes_count]
}

The items of the field_info structure are as follows:
fields_info对象的结构如下:

token
令牌

The token item is the token assigned to this field. There are three scopes for field
tokens: final static fields of primitive types (compile-time constants), all
other static fields, and instance fields.
令牌对象是非配给这个属性的令牌值,对属性令牌有三种范围:基本类型的静态常量,其它的静态属性,以及实例属性。

If this field is a compile-time constant, the value of the token item is 0xFF.
Compile-time constants are represented in export files, but are not assigned token
values suitable for late binding. Instead Java Card Converters must replace
bytecodes that reference final static fields with bytecodes that load the
constant value of the field.
If this field is static, but is not a compile-time constant, the token item
represents a static field token (Section 4.3.7.3, “Static Fields” on page 4-8).
If this field is an instance field, the token item represents an instance field token
(Section 4.3.7.5, “Instance Fields” on page 4-9).
如果这个属性是一个编译期常量,令牌的值是0xFF。编译期常量在导出文件中出现,但是不为后期的绑定提供令牌。作为替代java卡converter将直接导入静态常量的值到字节码中。
如果这个属性是静态的,但不是一个编译期常量,令牌对象提供一个静态属性令牌。
如果这个属性是实例的,令牌对象提供一个实例令牌。

access_flags
The value of the access_flags item is a mask of modifiers used with fields. The
access_flags modifiers are shown in the following table.
访问标识
access_flags对象用来标识属性的访问条件。

TABLE 5-4  Export File Field Access and Modifier Flags
Name          Value     Meaning           Used By
ACC_PUBLIC       0x0001     Is public; may be      Any field
                  accessed from outside its
                  package.

ACC_PROTECTED     0x0004     Is protected; may be     Class field Instance field
                  accessed within
                  subclasses.

ACC_STATIC       0x0008     Is static.          Class field Interface field

ACC_FINAL       0x0010     Is final; no further     Any field
                  overriding or assignment
                  after initialization.

Field access and modifier flags are defined in the same way and with the same
restrictions as described in The Java Virtual Machine Specification.
Since all fields represented in an export file are either public or protected, exactly
one of the ACC_PUBLIC or ACC_PROTECTED flag must be set.
The Java Card virtual machine reserves all other flag values. Their values must be
zero.
属性访问标识和java虚拟机规范中定义的一致。
因为在导出文件中的所有属性都是public或者protected的,事实上ACC_PUBLIC和ACC_PROTECTED标识二居其一。
java卡虚拟机保留剩余的所有标识,他们的值必须设置为0.

name_index
名字索引

The value of the name_index item must be a valid index into the
constant_pool table. The constant_pool entry at that index must be a
CONSTANT_Utf8_info (Section 5.6.4, “CONSTANT_Utf8” on page 5-7) structure
representing a valid Java field name stored as a simple (not fully qualified) name,
that is, as a Java identifier.
name_index的值必须是一个指向常量池的索引。对应索引对应的入口必须是一个CONSTANT_Utf8结构来描述一个有效的属性名。属性名存的是一个简单名字,而不是全名。

descriptor_index
描述符索引

The value of the descriptor_index item must be a valid index into the
constant_pool table. The constant_pool entry at that index must be a
CONSTANT_Utf8_info (Section 5.6.4, “CONSTANT_Utf8” on page 5-7) structure
representing a valid Java field descriptor.
Representation of a field descriptor in an export file is the same as in a Java class
file. See the specification described in The Java Virtual Machine Specification
(§4.3.2).
If this field is a reference-type, the class referenced must be a public class.
descriptor_index对象的值指示着常量池中一个有效的索引。常量池对应的入口必须是一个CONSTANT_Utf8_info结构,用来表示java属性的描述符。
导出文件中属性的描述符和java类文件中的一致。参见java虚拟机规范4.3.2。
如果属性是一个引用类型,引用的类必须是一个公有类。

attributes_count
属性个数
The value of the attributes_count item indicates the number of additional
attributes of this field. The only field_info attribute currently defined is the
ConstantValue attribute (Section 5.10.1, “ConstantValue Attribute” on
page 5-15). For static final fields of primitive types, the value must be 1; that is,
when both the ACC_STATIC and ACC_FINAL bits in the flags item are set an
attribute must be present. For all other fields the value of the
attributes_count item must be 0.
attributes_count对象的值标识着属性的附加属性个数。当前唯一定义的field_info属性是常数属性。对静态基本类型常数来说,这个值必须是1.也就是说ACC_STATIC和ACC_FINAL同时满足,就必须提供一个attribute。对其它的属性,这个值必须是0

attributes[]
The only attribute defined for the attributes table of a field_info structure by
this specification is the ConstantValue attribute (Section 5.10.1, “ConstantValue
Attribute” on page 5-15). This must be defined for static final fields of primitive
types (boolean, byte, short, and int).
属性
这个规范field_info结构中定义的唯一属性是常量属性,必须定义为static final的基本类型。

5.9 Methods
5.9 方法

Each method is described by a variable-length method_info structure. The format
of this structure is:
每个方法都被描述成一个method_info的变长结构。结构的格式为:

method_info {
u1 token
u2 access_flags
u2 name_index
u2 descriptor_index
}

The items of the method_info structure are as follows:

token
令牌

The token item is the token assigned to this method. If this method is a static
method or constructor, the token item represents a static method token
(Section 4.3.7.4, “Static Methods and Constructors” on page 4-8). If this method is
a virtual method, the token item represents a virtual method token
(Section 4.3.7.6, “Virtual Methods” on page 4-9). If this method is an interface
method, the token item represents an interface method token (Section 4.3.7.7,
“Interface Methods” on page 4-10).
token对象的值是方法分配的令牌,如果这个方法是一个静态方法或者构造函数,令牌对象提供一个静态方法令牌。如果这个方法是一个虚方法,这个令牌对象提供一个虚方法令牌。
如果方法是一个接口方法,令牌推向提供一个接口方法令牌。

access_flags
访问标志
The value of the access_flags item is a mask of modifiers used with methods.
The access_flags modifiers are shown in the following table.
访问标志来标识方法的访问范围,如下:

TABLE 5-5  Export File Method Access and Modifier Flags
Name         Value       Meaning            Used By
ACC_PUBLIC      0x0001       Is public; may be accessed   Any method
                   from outside its package.

ACC_PROTECTED    0x0004       Is protected; may be      Class/instance method
                   accessed within
                   subclasses.

ACC_STATIC      0x0008       Is static.           Class/instance method

ACC_FINAL      0x0010       Is final; no further      Class/instance method
                   overriding or assignment
                   after initialization.

ACC_ABSTRACT     0x0400       Is abstract; no        Any method
                   implementation is
                   provided

Method access and modifier flags are defined in the same way and with the same
restrictions as described in The Java Virtual Machine Specification.
方法访问标志和java虚拟机规范中的定义一致。

Since all methods represented in an export file are either public or protected,
exactly one of the ACC_PUBLIC or ACC_PROTECTED flag must be set.
因为导出文件中的所有方法都是public活着protected的,所以ACC_PUBLIC和ACC_PROTECTED二居其一。

Unlike in Java class files, the ACC_NATIVE flag is not supported in export files.
Whether a method is native is an implementation detail that is not relevant to
importing packages. The Java Card virtual machine reserves all other flag values.
Their values must be zero.
和java类文件不同,ACC_NATIVE标志在导出文件中不提供。一个方法是否是本地方法是和导出文件无关的实现细节。java卡虚拟机保留其他所有标志的值,值必须置0。

name_index
名称下标
The value of the name_index item must be a valid index into the
constant_pool table. The constant_pool entry at that index must be a
CONSTANT_Utf8_info (Section 5.6.4, “CONSTANT_Utf8” on page 5-7) structure
representing either the special internal method name for constructors, <init>, or
a valid Java method name stored as a simple (not fully qualified) name.
name_index必须是一个指向常量池的有效索引,对应的常量池入口必须是一个CONSTANT_Utf8结构来提供方法名,或者是构造函数的特殊内部方法名<init>。名字用简单方式提供,而不是全名。

descriptor_index
描述符下标

The value of the descriptor_index item must be a valid index into the
constant_pool table. The constant_pool entry at that index must be a
CONSTANT_Utf8_info (Section 5.6.4, “CONSTANT_Utf8” on page 5-7) structure
representing a valid Java method descriptor.
Representation of a method descriptor in an export file is the same as in a Java
class file. See the specification described in The Java Virtual Machine Specification
(Section 4.3.3, “The Export File and Conversion” on page 4-6).
All classes referenced in a descriptor must be public classes.
descriptor_index的值必须是一个指向常量池的有效下标。对应入口必须是一个CONSTANT_Utf8_info结构来标识一个有效的java方法描述符。
导出文件中的描述符标识和java class文件规范相同。所有在描述符中类的引用必须指向public类。


5.10 Attributes
5.10 属性

Attributes are used in the field_info (Section 5.8, “Fields” on page 5-11) structure
of the export file format. All attributes have the following general format:
属性用在导出文件结构的field_info结构中,所有的属性有如下的格式:

attribute_info {
u2 attribute_name_index
u4 attribute_length
u1 info[attribute_length]
}

5.10.1 ConstantValue Attribute
5.10.1 常数属性

The ConstantValue attribute is a fixed-length attribute used in the attributes table
of the field_info structures. A ConstantValue attribute represents the value of
a final static field (compile-time constant); that is, both the ACC_STATIC and
ACC_FINAL bits in the flags item of the field_info structure must be set. There
can be no more than one ConstantValue attribute in the attributes table of a given
field_info structure.
常数属性是一个固定长度的属性。一个常数属性表述一个final static属性的值。对应的ACC_STATIC和ACC_FINAL必须同时置上,并且一个field_info中,只有一个常数属性。

The ConstantValue attribute has the format:
常数属性的结构:
ConstantValue_attribute {
u2 attribute_name_index
u4 attribute_length
u2 constantvalue_index
}

The items of the ConstantValue_attribute structure are as follows:
常数属性对象结构如下:

attribute_name_index
属性名下标

The value of the attribute_name_index item must be a valid index into the
constant_pool table. The constant_pool entry at that index must be a
CONSTANT_Utf8_info (Section 5.6.4, “CONSTANT_Utf8” on page 5-7) structure
representing the string “ConstantValue.”
attribute_name_index对象的值必须是一个指向常量池的有效下表,对应的常量池入口必须是一个CONSTANT_Utf8_info结构来表示串“ConstantValue”

attribute_length
属性长度
The value of the attribute_length item of a ConstantValue_attribute
structure must be 2.
attribute_length长度必须是2

constantvalue_index
常数值下标

The value of the constantvalue_index item must be a valid index into the
constant_pool table. The constant_pool entry at that index must give the
constant value represented by this attribute.
The constant_pool entry must be of a type CONSTANT_Integer (Section 5.6.3,
“CONSTANT_Integer” on page 5-7).
constantvalue_index值必须是一个指向常量池的有效下表,对应的入口必须是一个CONSTANT_Integer给出常量值具体的值。

原创粉丝点击