📄 jcvm06cap.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 6 - The CAP 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="JCVM05export.html"><img src="shared/prev01.gif" title="Previous Chapter" alt="Previous Chapter" width="30" height="26" border="0"></a><a href="JCVM07instr.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-53138"></A>C H A P T E R </SPAN> <SPAN CLASS="ChapNumNum">6</SPAN><A NAME="74217"></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-53140"></A><A NAME="12322"></A>The <A NAME="marker-54587"></A>CAP File Format</TD></TR></TABLE><P CLASS="Paragraph"><A NAME="pgfId-6950"></A>This chapter describes the Java Card converted applet (CAP) 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.</P><P CLASS="Paragraph"><A NAME="pgfId-6951"></A>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 <EM CLASS="Emphasis">high bit</EM><A NAME="marker-54588"></A>.</P><P CLASS="Paragraph"><A NAME="pgfId-6952"></A>This chapter defines its own set of data types representing Java Card CAP file data: the types <KBD CLASS="Filename-Command">u1</KBD>, and <KBD CLASS="Filename-Command">u2</KBD> represent an unsigned one-, and two-byte quantities, respectively. Some <KBD CLASS="Filename-Command">u1</KBD> types are represented as <EM CLASS="Emphasis">bitfield</EM><A NAME="marker-54589"></A> structures, consisting of arrays of bits. The zeroeth bit in each bit array represents the most significant bit, or high bit.</P><P CLASS="Paragraph"><A NAME="pgfId-6953"></A>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<A NAME="marker-54590"></A> <EM CLASS="Emphasis">items</EM>. 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-6954"></A>Variable-sized t<A NAME="marker-54591"></A>ables, 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.</P><P CLASS="Paragraph"><A NAME="pgfId-6955"></A>A data structure referred to as an<A NAME="marker-54592"></A> array consists of items equal in size.</P><P CLASS="Paragraph"><A NAME="pgfId-17535"></A>Some items in the structures of the CAP file format are describe using a C-like <A NAME="marker-54593"></A>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.</P><H2 CLASS="Head1"><A NAME="pgfId-6960"></A><DIV><HR ALIGN=left SIZE=6 WIDTH=15% noshade></DIV>6.1 <A NAME="marker-54594"></A>Component Model</H2><P CLASS="Paragraph"><A NAME="pgfId-6961"></A>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 <KBD CLASS="Filename-Command">components</KBD> are optional: the Applet Component (<A HREF="JCVM06cap.html#Applet Component" CLASS="XRef">Section 6.5, Applet Component</A>), Export Component (<A HREF="JCVM06cap.html#Export Component" CLASS="XRef">Section 6.12, Export Component</A>), and Debug Component (<A HREF="JCVM06cap.html#26211" CLASS="XRef">Section 6.14, Debug Component</A>). 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.</P><P CLASS="Paragraph"><A NAME="pgfId-16083"></A>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:</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-1011898"></A>component {</P><P CLASS="TableTextCode"><A NAME="pgfId-1011900"></A> u1 tag</P><P CLASS="TableTextCode"><A NAME="pgfId-1011902"></A> u2 size</P><P CLASS="TableTextCode"><A NAME="pgfId-1011904"></A> u1 info[]</P><P CLASS="TableTextCode"><A NAME="pgfId-1011906"></A>}</P></TD></TR></TBODY></TABLE><BR></DIV><P CLASS="Paragraph"><A NAME="pgfId-44747"></A>Each component begins with a 1-byte tag indicating the kind of component. Valid tags and their values are listed in <A HREF="JCVM06cap.html#81073" CLASS="XRef">TABLE 6-1</A>. The size item indicates the number of bytes in the info array of the component, not including the tag and size items.</P><P CLASS="Paragraph"><A NAME="pgfId-40219"></A>The content and format of the info array varies with the type of component.</P><BR><TABLE CLASS="Titled" BORDER=1 BORDERCOLORLIGHT="#FFFFFF" BORDERCOLORDARK="#000000" CELLPADDING=5 CELLSPACING=0 DIR="LTR"><CAPTION CLASS="TableCaption"><A NAME="pgfId-999983"> </A> TABLE 6-1 <A NAME="81073"> </A> CAP File Component Tags </CAPTION><THEAD><TR><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-38794"></A>Component Type</P></TH><TH SCOPE="COL" ROWSPAN="1" COLSPAN="1" BGCOLOR="#CCCCCC"><P CLASS="TableHead"><A NAME="pgfId-38796"></A>Value</P></TH></TR></THEAD><TBODY><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38798"></A>COMPONENT_Header</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38800"></A>1</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38802"></A>COMPONENT_Directory</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38804"></A>2</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38806"></A>COMPONENT_Applet</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38808"></A>3</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38810"></A>COMPONENT_Import</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38812"></A>4</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38814"></A>COMPONENT_ConstantPool</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38816"></A>5</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38818"></A>COMPONENT_Class</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38820"></A>6</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38822"></A>COMPONENT_Method</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38824"></A>7</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38826"></A>COMPONENT_StaticField</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38828"></A>8</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38830"></A>COMPONENT_ReferenceLocation</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38832"></A>9</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38834"></A>COMPONENT_Export</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38836"></A>10</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-51816"></A>COMPONENT_Descriptor</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-51818"></A>11</P></TD></TR><TR><TD SCOPE="ROW" ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38838"></A>COMPONENT_Debug</P></TD><TD ROWSPAN="1" COLSPAN="1"><P CLASS="TableText"><A NAME="pgfId-38840"></A>12</P></TD></TR></TBODY></TABLE><BR><P CLASS="Paragraph"><A NAME="pgfId-16065"></A>Sun Microsystems, Inc. may define additional components in future versions of this Java Card virtual machine specification. It is guaranteed that additional components will have <KBD CLASS="Filename-Command">tag</KBD> values between 13 and 127, inclusive.</P><H3 CLASS="Head2"><A NAME="pgfId-15498"></A>6.1.1 <A NAME="61479"></A>Containment in a <A NAME="marker-54595"></A>JAR File</H3><P CLASS="Paragraph"><A NAME="pgfId-1001966"></A>Each CAP file component is represented as a single file. The component file names are enumerated in <A HREF="JCVM06cap.html#55066" CLASS="XRef">TABLE 6-2</A>. These names are not case sensitive.</P>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -