📄 jcvm05export.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><HTML LANG="en"><HEAD><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><META HTTP-EQUIV="Content-Style-Type" CONTENT="text/css"><META NAME="GENERATOR" CONTENT="Adobe FrameMaker 7.0/HTML Export Filter"><LINK REL="STYLESHEET" HREF="unx_unstr_styles.css" CHARSET="ISO-8859-1" TYPE="text/css"><META name="DC.TITLE" content="Virtual Machine Specification, Java Card Platform, v2.2.2"><TITLE>C H A P T E R 5 - The Export File Format </TITLE></HEAD><BODY BGCOLOR="#ffffff"><DIV><div class="navbar" align="center"><table dir="LTR" summary="Navigation bar, includes the book title and navigation buttons" width=100% cellpadding="0" cellspacing="0" border="0"><colgroup span="2" width="100%"><col id="1" span="1" width="50%"><col id="2" span="1" width="50%"><tr bgcolor="#cccccc"><td class="navbartitle" align=left rowspan="1" colspan="1" abbr="ChapTitle"> Virtual Machine Specification, Java Card Platform, v2.2.2</td><td valign="top" align="right" rowspan="1" colspan="1" abbr="NavButtons"><a href="index.html"><img src="shared/toc01.gif" title="Table Of Contents" alt="Table Of Contents" width="30" height="26" border="0"></a><a href="JCVM04naming.html"><img src="shared/prev01.gif" title="Previous Chapter" alt="Previous Chapter" width="30" height="26" border="0"></a><a href="JCVM06cap.html"><img src="shared/next01.gif" title="Next Chapter" alt="Next Chapter" width="30" height="26" border="0"></a><a href="ix.html"><img src="shared/index01.gif" title="Book Index" alt="Book Index" width="30" height="26" border="0"></a></td></tr></table><br><br></div></DIV><TABLE DIR="LTR" SUMMARY="Chapter Number" ABBR="ChapNum" WIDTH="100%" BORDER="0"><COLGROUP SPAN="1" WIDTH="100%"><COL ID="1" SPAN="1"><TR><TD ALIGN="right" CLASS="ChapNumber"><SPAN CLASS="ChapNumPrefix"><A NAME="pgfId-6948"></A>C H A P T E R </SPAN> <SPAN CLASS="ChapNumNum">5</SPAN><A NAME="26841"></A></TD></TR></TABLE><TABLE DIR="LTR" SUMMARY="Chapter Title" ABBR="ChapTitle" WIDTH="100%" BORDER="0"><COLGROUP SPAN="1" WIDTH="100%"><COL ID="1" SPAN="1" WIDTH="100%"><TR><TD ALIGN="right" CLASS="ChapTitle"><HR SIZE=7 NOSHADE><A NAME="pgfId-11318"></A><A NAME="20730"></A>The <A NAME="marker-20697"></A>Export File Format</TD></TR></TABLE><P CLASS="Paragraph"><A NAME="pgfId-15523"></A>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.</P><P CLASS="Paragraph"><A NAME="pgfId-15527"></A>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.</P><P CLASS="Paragraph"><A NAME="pgfId-6964"></A>This chapter defines its own set of data types representing Java Card export file data: the types <KBD CLASS="Filename-Command">u1</KBD>, <KBD CLASS="Filename-Command">u2</KBD>, and <KBD CLASS="Filename-Command">u4</KBD> represent an unsigned one-, two-, and four-byte quantities, respectively.</P><P CLASS="Paragraph"><A NAME="pgfId-6965"></A>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 <A NAME="marker-20698"></A>items. Unlike the fields of a C structure, successive items are stored in the Java Card platform file sequentially, without padding or alignment.</P><P CLASS="Paragraph"><A NAME="pgfId-6966"></A>Variable-sized <EM CLASS="Emphasis">tables</EM><A NAME="marker-20699"></A>, 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.</P><P CLASS="Paragraph"><A NAME="pgfId-6967"></A>In a data structure that is referred to as an<A NAME="marker-20700"></A> <EM CLASS="Emphasis">array</EM>, the elements are equal in size.</P><H2 CLASS="Head1"><A NAME="pgfId-15810"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>5.1 <A NAME="marker-20701"></A>Export File Name</H2><P CLASS="Paragraph"><A NAME="pgfId-15811"></A>As described in <A HREF="JCVM04naming.html#38821" CLASS="XRef">Section 4.1.1, Export File Format</A>, the name of a export file must be the last portion of the package specification followed by the extension `<KBD CLASS="Filename-Command">.exp</KBD>'. For example, the name of the export file of the <KBD CLASS="Filename-Command">javacard.framework</KBD> package must be <KBD CLASS="Filename-Command">framework.exp</KBD>. Operating systems that impose limitations on file name lengths may transform an export file's name according to its conventions.</P><H2 CLASS="Head1"><A NAME="pgfId-17933"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>5.2 Containment in a <A NAME="marker-20702"></A>JAR File</H2><P CLASS="Paragraph"><A NAME="pgfId-17937"></A>As described in <A HREF="JCVM04naming.html#10054" CLASS="XRef">Section 4.1.3, JAR File Container</A>, 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 <KBD CLASS="Filename-Command">javacard</KBD> that is a subdirectory of the package's directory. For example, the <KBD CLASS="Filename-Command">framework.exp</KBD> file would be located in the subdirectory <KBD CLASS="Filename-Command">javacard/framework/javacard</KBD>.</P><H2 CLASS="Head1"><A NAME="pgfId-18005"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>5.3 <A NAME="marker-20703"></A>Ownership</H2><P CLASS="Paragraph"><A NAME="pgfId-18006"></A>An <KBD CLASS="Filename-Command">export</KBD> 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 <KBD CLASS="Filename-Command">export</KBD> file provided by the owner.</P><P CLASS="Paragraph"><A NAME="pgfId-18026"></A>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 <KBD CLASS="Filename-Command">export</KBD> 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 <KBD CLASS="Filename-Command">export</KBD> files.</P><H2 CLASS="Head1"><A NAME="pgfId-17953"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>5.4 Hierarchies Represented</H2><P CLASS="Paragraph"><A NAME="pgfId-18198"></A>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.</P><H2 CLASS="Head1"><A NAME="pgfId-18191"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>5.5 <A NAME="marker-20704"></A>Export File</H2><P CLASS="Paragraph"><A NAME="pgfId-9485"></A>An <KBD CLASS="Filename-Command">export</KBD> file is defined by the following structure:</P><DIV CLASS="Code"><BR><TABLE CLASS="Code" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 DIR="LTR"><TBODY><TR><TD SCOPE="ROW"><P CLASS="TableTextCode"><A NAME="pgfId-1002554"></A>ExportFile {</P><P CLASS="TableTextCode"><A NAME="pgfId-1002556"></A> u4 magic</P><P CLASS="TableTextCode"><A NAME="pgfId-1002558"></A> u1 minor_version</P><P CLASS="TableTextCode"><A NAME="pgfId-1002560"></A> u1 major_version</P><P CLASS="TableTextCode"><A NAME="pgfId-1002562"></A> u2 constant_pool_count</P><P CLASS="TableTextCode"><A NAME="pgfId-1002564"></A> cp_info constant_pool[constant_pool_count]</P><P CLASS="TableTextCode"><A NAME="pgfId-1002566"></A> u2 this_package</P><P CLASS="TableTextCode"><A NAME="pgfId-1002568"></A> u1 export_class_count</P><P CLASS="TableTextCode"><A NAME="pgfId-1002570"></A> class_info classes[export_class_count]</P><P CLASS="TableTextCode"><A NAME="pgfId-1002572"></A>}</P></TD></TR></TBODY></TABLE><BR></DIV><P CLASS="Paragraph"><A NAME="pgfId-6980"></A>The items in the <KBD CLASS="Filename-Command">ExportFile</KBD> structure are as follows:</P><P CLASS="Paragraph"><A NAME="pgfId-6981"></A><KBD CLASS="Filename-Command">magic</KBD></P><P CLASS="ParaIndent1"><A NAME="pgfId-6982"></A>The <KBD CLASS="Filename-Command">magic</KBD> item contains the magic number identifying the <KBD CLASS="Filename-Command">ExportFile</KBD> format; it has the value <KBD CLASS="Filename-Command">0x00FACADE</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-6983"></A><KBD CLASS="Filename-Command">minor_version, major_version</KBD></P><P CLASS="ParaIndent1"><A NAME="pgfId-7669"></A>The <KBD CLASS="Filename-Command">minor_version</KBD> and <KBD CLASS="Filename-Command">major_version</KBD> 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 <I CLASS="Variable">M</I> and minor version number of <I CLASS="Variable">m</I>, the version of the export file's format is <I CLASS="Variable">M.m</I>. </P><P CLASS="ParaIndent1"><A NAME="pgfId-20447"></A>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 <KBD CLASS="Filename-Command">export</KBD> files with different major version numbers. A Java Card virtual machine is required to support <KBD CLASS="Filename-Command">export</KBD> files having a given major version number and all valid minor version numbers in the range 0 through some particular <KBD CLASS="Filename-Command">minor_version</KBD> 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.</P><P CLASS="ParaIndent1"><A NAME="pgfId-7672"></A>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.</P><P CLASS="Paragraph"><A NAME="pgfId-6985"></A><KBD CLASS="Filename-Command">constant_pool_count</KBD></P><P CLASS="ParaIndent1"><A NAME="pgfId-6986"></A>The <KBD CLASS="Filename-Command">constant_pool_count</KBD> item is a non-zero, positive value that indicates the number of constants in the constant pool.</P><P CLASS="Paragraph"><A NAME="pgfId-6987"></A><KBD CLASS="Filename-Command">constant_pool[]</KBD></P><P CLASS="ParaIndent1"><A NAME="pgfId-6988"></A>The <KBD CLASS="Filename-Command">constant_pool</KBD> is a table of variable-length structures representing various string constants, class names, field names and other constants referred to within the <KBD CLASS="Filename-Command">ExportFile</KBD> structure.</P><P CLASS="ParaIndent1"><A NAME="pgfId-11508"></A>Each of the <KBD CLASS="Filename-Command">constant_pool</KBD> table entries, including entry zero, is a variable-length structure whose format is indicated by its first "tag" byte.</P><P CLASS="ParaIndent1"><A NAME="pgfId-11578"></A>There are no ordering constrains on entries in the <KBD CLASS="Filename-Command">constant_pool</KBD> table.</P><P CLASS="Paragraph"><A NAME="pgfId-11509"></A><KBD CLASS="Filename-Command">this_package</KBD></P><P CLASS="ParaIndent1"><A NAME="pgfId-6991"></A>The value of <KBD CLASS="Filename-Command">this_package</KBD> must be a valid index into the <KBD CLASS="Filename-Command">constant_pool</KBD> table. The <KBD CLASS="Filename-Command">constant_pool</KBD> entry at that index must be a <KBD CLASS="Filename-Command">CONSTANT_Package_info</KBD> (<A HREF="JCVM05export.html#26538" CLASS="XRef">Section 5.6.1, CONSTANT_Package</A>) structure representing the package defined by this <KBD CLASS="Filename-Command">ExportFile</KBD>.</P><P CLASS="Paragraph"><A NAME="pgfId-6992"></A><KBD CLASS="Filename-Command">export_class_count</KBD></P><P CLASS="ParaIndent1"><A NAME="pgfId-6993"></A>The value of the <KBD CLASS="Filename-Command">export_class_count</KBD> item gives the number of elements in the classes table.</P><P CLASS="Paragraph"><A NAME="pgfId-6994"></A><KBD CLASS="Filename-Command">classes[]</KBD></P><P CLASS="ParaIndent1"><A NAME="pgfId-6995"></A>Each value of the classes table is a variable-length <KBD CLASS="Filename-Command">class_info</KBD> structure (<A HREF="JCVM05export.html#31663" CLASS="XRef">Section 5.7, Classes and Interfaces</A>) giving the description of a publicly accessible class or interface declared in this package. If the <KBD CLASS="Filename-Command">ACC_LIBRARY</KBD> flag item in the <KBD CLASS="Filename-Command">CONSTANT_Package_info</KBD> (<A HREF="JCVM05export.html#26538" CLASS="XRef">Section 5.6.1, CONSTANT_Package</A>) 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 <KBD CLASS="Filename-Command">ACC_LIBRARY</KBD> flag item is not set, the classes table has an entry for each public shareable interface declared in this package.<A NAME="fnote1"></A><A HREF="#pgfId-11479" CLASS="footnote"><SUP>[1]</SUP></A></P><H2 CLASS="Head1"><A NAME="pgfId-6996"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>5.6 <A NAME="marker-20705"></A>Constant Pool</H2><P CLASS="Paragraph"><A NAME="pgfId-6997"></A>All <KBD CLASS="Filename-Command">constant_pool</KBD> table entries have the following general format:</P><DIV CLASS="Code"><BR><TABLE CLASS="Code" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 DIR="LTR"><TBODY><TR><TD SCOPE="ROW"><P CLASS="TableTextCode"><A NAME="pgfId-1002644"></A>cp_info {</P><P CLASS="TableTextCode"><A NAME="pgfId-1002646"></A> u1 tag</P><P CLASS="TableTextCode"><A NAME="pgfId-1002648"></A> u1 info[]</P><P CLASS="TableTextCode"><A NAME="pgfId-1002650"></A>}</P></TD></TR></TBODY></TABLE><BR></DIV><P CLASS="Paragraph"><A NAME="pgfId-7602"></A>Each item in the <KBD CLASS="Filename-Command">constant_pool</KBD> must begin with a 1-byte tag indicating the kind of <KBD CLASS="Filename-Command">cp_info</KBD> entry. The content of the info array varies with the value of tag. The valid tags and their values are listed in <A HREF="JCVM05export.html#15221" CLASS="XRef">TABLE 5-1</A>. 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.</P><BR><TABLE CLASS="Titled" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 DIR="LTR"><CAPTION CLASS="TableCaption"><A NAME="pgfId-998817"> </A> TABLE 5-1 <A NAME="15221"> </A> Export File Constant Pool Tags </CAPTION><THEAD><TR><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-998764"></A>Constant Type</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-998766"></A>Value</P></TH></TR></THEAD><TBODY><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableTextCode"><A NAME="pgfId-998768"></A><KBD CLASS="Filename-Command">CONSTANT_Package</KBD></P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableTextCode"><A NAME="pgfId-998770"></A><KBD CLASS="Filename-Command">13</KBD></P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableTextCode"><A NAME="pgfId-998772"></A><KBD CLASS="Filename-Command">CONSTANT_Classref</KBD></P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableTextCode"><A NAME="pgfId-998774"></A><KBD CLASS="Filename-Command">7</KBD></P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableTextCode"><A NAME="pgfId-998780"></A><KBD CLASS="Filename-Command">CONSTANT_Integer</KBD></P></TD><TD ROWSPAN="1" COLSPAN="1">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -