📄 jcvm04naming.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 4 - Binary Representation</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%"></colgroup><tbody> <tr bgcolor="#cccccc"> <td class="navbartitle" align="left" rowspan="1" colspan="1" abbr="ChapTitle"> Virtual Machine Specification, Java CardPlatform, 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="JCVM03structVM.html"><img src="shared/prev01.gif" title="Previous Chapter" alt="Previous Chapter" width="30" height="26" border="0"></a><a href="JCVM05export.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> </tbody></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"></colgroup><tbody> <tr> <td align="right" class="ChapNumber"><span class="ChapNumPrefix"><a name="pgfId-7777"></a>C H A P T E R </span> <span class="ChapNumNum">4</span><a name="23356"></a> </td> </tr> </tbody></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%"></colgroup><tbody> <tr> <td align="right" class="ChapTitle"> <hr size="7" noshade="noshade"><a name="pgfId-7778"></a><a name="25467"></a><a name="marker-14165"></a>Binary Representation </td> </tr> </tbody></table><p class="Paragraph"><a name="pgfId-7779"></a>This chapter presentsinformation about the binary representation of Java Card programs. JavaCard technology-based binaries ("Java Card binaries") are usuallycontained in files, therefore this chapter addresses binaryrepresentation in terms of this common case.</p><p class="Paragraph"><a name="pgfId-8094"></a>Several topics relatingto binary representation are covered. The first section describes thebasic organization of program representation in export and CAP files,as well as the use of the Java<img src="shared/chars/tm.gif" title="trademark" alt="trademark"> Archive (JAR) file containers. Thesecond section covers how Java Card applets and packages are namedusing unique identifiers. The third section presents the scheme usedfor naming and linking items within Java Card API packages. The fourthand fifth sections describe the constraints for upward compatibilitybetween different versions of a Java Card technology-based binary("Java Card binary") program file, and versions assigned based uponthat compatibility.</p><h2 class="Head1"><a name="pgfId-8434"></a><div><hr align="left" size="6" width="15%" noshade="noshade"></div>4.1 <a name="marker-14166"></a>Java Card Platform File Formats</h2><p class="Paragraph"><a name="pgfId-8560"></a>Java programs arerepresented in compiled, binary form as <a name="marker-14167"></a>classfiles. Java class files are used not only to execute programs on a Javavirtual machine, but also to provide type and name information to aJava compiler. In the latter role, a class file is essentially used todocument the API of its class to client code. That client code iscompiled into its own class file, including symbolic references used todynamically link to the API class at runtime.</p><p class="Paragraph"><a name="pgfId-8561"></a>Java Card technology usesa different strategy for binary representation of programs. Executablebinaries and interface binaries are represented in two separate files.These files are respectively called <a name="marker-14168"></a>CAPfiles (for converted applet) and export files.</p><h3 class="Head2"><a name="pgfId-8562"></a>4.1.1 <a name="38821"></a>Export<a name="marker-14170"></a>File Format</h3><p class="Paragraph"><a name="pgfId-8619"></a>Export files are not useddirectly on a device that implements a Java Card virtual machine.However, the information in an export file is critical to the operationof the virtual machine on a device. An export file can be produced by aJava Card converter when a package is converted. This package's exportfile can be used later to convert another package that imports classesfrom the first package. Information in the export file is included inthe CAP file of the second package, then is used on the device to linkthe contents of the second package to items imported from the firstpackage.</p><p class="Paragraph"><a name="pgfId-8634"></a>A Java Cardtechnology-based export file ("Java Card export file") contains thepublic interface information for an entire package of classes. Thismeans that an export file only contains information about the publicAPI of a package, and does not include information used to link classeswithin a package.</p><p class="Paragraph"><a name="pgfId-8620"></a>The name of an exportfile is the last portion of the package specification followed by theextension `.exp'. For example, the name of the export file of thejavacard.framework package must be framework.exp. Operating systemsthat impose limitations on file name lengths may transform an exportfile's name according to their own conventions.</p><p class="Paragraph"><a name="pgfId-8641"></a>For a completedescription of the Java Card export file format, see <a href="JCVM05export.html#26841" class="XRef">Chapter 5</a>, "The ExportFile Format".</p><h3 class="Head2"><a name="pgfId-8564"></a>4.1.2 CAP File Format</h3><p class="Paragraph"><a name="pgfId-8565"></a>A Java Card CAP filecontains a binary representation of a package of classes that can beinstalled on a device and used to execute the package's classes on aJava Card virtual machine.</p><p class="Paragraph"><a name="pgfId-8650"></a>A CAP file is produced bya Java Card converter when a package of classes is converted. A CAPfile consists of a set of components, each of which describes adifferent aspect of the contents. The set of components in a CAP filecan vary, depending on whether the file contains a library or appletdefinition(s).</p><p class="Paragraph"><a name="pgfId-8643"></a>For a completedescription of the Java Card CAP file format, see <a href="JCVM06cap.html#74217" class="XRef">Chapter 6</a>, "The CAP FileFormat".</p><h3 class="Head2"><a name="pgfId-8566"></a>4.1.3 <a name="10054"></a>JARFile <a name="marker-14172"></a>Container</h3><p class="Paragraph"><a name="pgfId-8602"></a>The JAR file format isused as the container format for CAP files. What this specificationcalls a "CAP file" is just a JAR file that contains the required set ofCAP components (see <a href="JCVM06cap.html#74217" class="XRef">Chapter6</a>, "The CAP File Format").</p><p class="Paragraph"><a name="pgfId-8725"></a>CAP file components arestored as files in a JAR file. Each CAP file component is located in asubdirectory called javacard that is in a directory representing thepackage. For example, the CAP file components of the packagecom.sun.framework are located in the directorycom/sun/framework/javacard.</p><p class="Paragraph"><a name="pgfId-8726"></a>An export file may alsobe contained in a JAR file, whether that JAR file contains CAP filecomponents or not. If an export file is included, it must be located inthe same directory as the components for that package would be.</p><p class="Paragraph"><a name="pgfId-8727"></a>The name of a JAR filecontaining CAP file components is not defined as part of thisspecification. Other files, including CAP file components for anotherpackage, may also reside in a JAR file that contains CAP filecomponents.</p><h2 class="Head1"><a name="pgfId-8482"></a><div><hr align="left" size="6" width="15%" noshade="noshade"></div>4.2 <a name="28462"></a>AID-based <a name="marker-14173"></a>Naming</h2><p class="Paragraph"><a name="pgfId-8208"></a>This section describesthe mechanism used for naming applets and packages in Java Card CAPfiles and export files, and custom components in Java Card CAP files.Java class files use Unicode strings to name Java packages. As the JavaCard platform does not include support for strings, an alternativemechanism for naming is provided.</p><p class="Paragraph"><a name="pgfId-8184"></a>ISO 7816 is a multipartstandard that describes a broad range of technology for building smartcard systems. ISO 7816-5 defines the <a name="marker-14174"></a>AID(application identifier) data format to be used for uniqueidentification of card applications (and certain kinds of files in cardfile systems). The Java Card platform uses the AID data format toidentify applets and packages. AIDs are administered by theInternational Standards Organization (ISO), so they can be used asunique identifiers.</p><h3 class="Head2"><a name="pgfId-8232"></a>4.2.1 The AID Format<a name="marker-14175"></a></h3><p class="Paragraph"><a name="pgfId-7962"></a>This section presents aminimal description of the AID data format used in Java Cardtechnology. For complete details, refer to ISO 7816-5, AID RegistrationCategory `D' format.</p><p class="Paragraph"><a name="pgfId-8236"></a>The AID format used bythe Java Card platform is an array of bytes that can be interpreted astwo distinct pieces, as shown in <a href="JCVM04naming.html#86206" class="XRef">TABLE 4-1</a>. The first piece is a 5-byte value known asa <a name="marker-14176"></a>RID (resource identifier). The secondpiece is a variable length value known as a <a name="marker-14177"></a>PIX(proprietary identifier extension). A PIX can be from 0 to 11 bytes inlength. Thus an AID can be from 5 to 16 bytes in total length.</p><p class="Paragraph"><a name="pgfId-1002282"></a> </p><a name="pgfId-1000647"> </a> TABLE 4-1 <a name="86206"> </a> AIDFormat <br><table class="Untitled" border="1" bordercolorlight="#FFFFFF" bordercolordark="#000000" cellpadding="5" cellspacing="0" dir="ltr"> <tbody> <tr> <td scope="row" rowspan="1" colspan="1"> <p class="TableText"><a name="pgfId-1000658"></a>RID (5 bytes) </p> </td> <td rowspan="1" colspan="1"> <p class="TableText"><a name="pgfId-1000660"></a>PIX (0-11 bytes) </p> </td> </tr> </tbody></table><br><p class="Paragraph"><a name="pgfId-8325"></a>ISO controls theassignment of RIDs to companies, with each company obtaining its ownunique RID from the ISO. Companies manage assignment of PIXs for AIDsusing their own RIDs.</p><h3 class="Head2"><a name="pgfId-8276"></a>4.2.2 AID Usage</h3><p class="Paragraph"><a name="pgfId-8304"></a>In the Java platform,packages are uniquely identified using Unicode strings and a namingscheme based on internet domain names. In the Java Card platform,packages and applets are identified using AIDs.</p><p class="Paragraph"><a name="pgfId-1002231"></a>Any package that isrepresented in an export file must be assigned a unique AID. The AIDfor a package is constructed from the concatenation of the company's
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -