⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 chap06.html

📁 Inside the java virtualMachine,深入研究java虚拟机
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<P><H4><EM>ReturnDescriptor:</P></EM></H4>
<P><I>FieldType</P></EM></H4>
<P><FONT FACE="Courier New">V</FONT></P>
<P>The meaning of each of the <I>BaseType</I> terminals is shown in Table 6-5. The <FONT FACE="Courier New">V</FONT> terminal represents methods that return <FONT FACE="Courier New">void</FONT>.</P>
<P>Table 6-5. <I>BaseType</I> terminals</P>
<TABLE WIDTH="500">
<TR><TD VALIGN="TOP"><STRONG>Terminal</STRONG></TD><TD VALIGN="TOP"><STRONG>Type</STRONG></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">B</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">byte</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">C</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">char</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">D</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">double</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">F</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">float</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">I</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">int</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">J</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">long</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">S</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">short</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">Z</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">boolean</FONT></TD></TR>
</TABLE>
<P>Some examples of field descriptors are shown in Table 6-6.</P>
<P>Table 6-6. Examples of field descriptors</P>
<TABLE WIDTH="500">
<TR><TD VALIGN="TOP"><STRONG>Descriptor</STRONG></TD><TD VALIGN="TOP"><STRONG>Field Declaration</STRONG></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">I</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">int i;</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">[[J</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">long[][] windingRoad;</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">[Ljava/lang/Object;</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">java.lang.Object[] stuff;</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">Ljava/util/Hashtable;</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">java.util.Hashtable ht;</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">[[[Z</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">boolean[][][] isReady;</FONT></TD></TR>
</TABLE>
<P>Some examples of method descriptors are shown in Table 6-7. Note that method descriptors don韙 include the hidden <FONT FACE="Courier New">this</FONT> parameter passed as the first argument to all instance methods.</P>
<P>Table 6-7. Examples of method descriptors</P>
<TABLE WIDTH="500">
<TR><TD VALIGN="TOP"><STRONG>Descriptor</STRONG></TD><TD VALIGN="TOP"><STRONG>Method Declaration</STRONG></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">()I</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">int getSize();</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">()Ljava/lang/String;</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">String toString();</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">([Ljava/lang/String;)V</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">void main(String[] args);</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">()V</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">void wait()</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">(JI)V</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">void wait(long timeout, int nanos)</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">(ZILjava/lang/String;II)Z</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">boolean regionMatches(boolean ignoreCase, int toOffset, String other, int ooffset, int len);</FONT></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">([BII)I</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">int read(byte[] b, int off, int len);</FONT></TD></TR>
</TABLE>
<H3><EM><P>The Constant Pool</P>
</EM></H3><P>The constant pool is an ordered list of <FONT FACE="Courier New">cp_info</FONT> tables, each of which follows the general form shown in Table 6-8. The <FONT FACE="Courier New">tag</FONT> item of a <FONT FACE="Courier New">cp_info</FONT> table, an unsigned byte, indicates the table韘 variety and format. <FONT FACE="Courier New">cp_info</FONT> tables come in eleven varieties, each of which is described in detail in the following sections.</P>
<P>Table 6-8. General form of a <FONT FACE="Courier New">cp_info</FONT> table</P>
<TABLE WIDTH="500">
<TR><TD VALIGN="TOP"><STRONG>Type</STRONG></TD><TD VALIGN="TOP"><STRONG>Name </STRONG></TD><TD VALIGN="TOP"><STRONG>Count</STRONG></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">u1</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">tag</FONT></TD><TD VALIGN="TOP">1</TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">u1</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">info</FONT> </TD><TD VALIGN="TOP">depends on tag value</TD></TR>
</TABLE>
<H3><P>The CONSTANT_Utf8_info Table</P>
</H3><P>A <FONT FACE="Courier New">CONSTANT_Utf8_info</FONT> table stores one constant string value in a modified UTF-8 format. This table is used to store many different kinds of strings, including:</P>
<UL>
<LI> string literals that get instantiated as <FONT FACE="Courier New">String</FONT> objects
<LI> the fully qualified name of the class or interface being defined
<LI> the fully qualified name of the superclass (if any) of the class being defined
<LI> the fully qualified names of any superinterfaces of the class or interface being defined
<LI> the simple names and descriptors of any fields declared by the class or interface
<LI> the simple names and descriptors of any methods declared by the class or interface
<LI> fully qualified names of any referenced classes and interfaces
<LI> simple names and descriptors of any referenced fields
<LI> simple names and descriptors of any referenced methods
<LI> strings associated with attributes
</UL>
<P>As you can see from the above list, there are four basic kinds of information stored in <FONT FACE="Courier New">CONSTANT_Utf8_info</FONT> tables: string literals, descriptions of the class or interface being defined, symbolic references to other classes and interfaces, and strings associated with attributes. Some examples of strings associated with attributes are: the name of the attribute, the name of the source file from which the class file was generated, and the names and descriptors of local variables.</P>
<P>The UTF-8 encoding scheme allows all two-byte Unicode characters to be represented in a string, but enables ASCII characters to be represented by just one byte. Table 6-9 shows the format of a <FONT FACE="Courier New">CONSTANT_Utf8_info</FONT> table.</P>
<P>Table 6-9. Format of a <FONT FACE="Courier New">CONSTANT_Utf8_info</FONT> table</P>
<TABLE WIDTH="500">
<TR><TD VALIGN="TOP"><STRONG>Type</STRONG></TD><TD VALIGN="TOP"><STRONG>Name</STRONG></TD><TD VALIGN="TOP"><STRONG>Count</STRONG></TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">u1</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">tag</FONT></TD><TD VALIGN="TOP">1</TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">u2</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">length</FONT></TD><TD VALIGN="TOP">1</TD></TR>
<TR><TD VALIGN="TOP"><FONT FACE="Courier New">u1</FONT></TD><TD VALIGN="TOP"><FONT FACE="Courier New">bytes</FONT> </TD><TD VALIGN="TOP"><FONT FACE="Courier New">length</FONT></TD></TR>
</TABLE>
<I><P><FONT FACE="Courier New">tag</FONT></P>
</I><P>The <FONT FACE="Courier New">tag</FONT> item has the value <FONT FACE="Courier New">CONSTANT_Utf8</FONT> (1).</P>
<I><P><FONT FACE="Courier New">length</FONT></P>
</I><P>The <FONT FACE="Courier New">length</FONT> item gives the length in bytes of the subsequent <FONT FACE="Courier New">bytes</FONT> item.</P>
<I><P><FONT FACE="Courier New">bytes</FONT></P>
</I><P>The <FONT FACE="Courier New">bytes</FONT> item contains the characters of the string stored in a modified UTF-8 format. Characters in the range <FONT FACE="Courier New">'\u0001'</FONT> through <FONT FACE="Courier New">'\u007f'</FONT> (all the ASCII characters except the null character) are represented by one byte:</P>
<P><IMG SRC="fig6-sgl.gif" tppabs="http://www.pbg.mcgraw-hill.com/betabooks/venners/images/fig6-sgl.gif" ALT="Figure 6-Single"></P>
<P>The <FONT FACE="Courier New">null</FONT> character, <FONT FACE="Courier New">'\u0000'</FONT>, and the characters in the range <FONT FACE="Courier New">'\u0080'</FONT> through <FONT FACE="Courier New">'\u07ff'</FONT> are represented by two bytes:</P>
<P><IMG SRC="fig6-dbl.gif" tppabs="http://www.pbg.mcgraw-hill.com/betabooks/venners/images/fig6-dbl.gif" ALT="Figure 6-Double"></P>
<P>Characters in the range <FONT FACE="Courier New">'\u0800'</FONT> through <FONT FACE="Courier New">'\uffff'</FONT> are represented by three bytes:</P>
<P><IMG SRC="fig6-tpl.gif" tppabs="http://www.pbg.mcgraw-hill.com/betabooks/venners/images/fig6-tpl.gif" ALT="Figure 6-Triple"></P>
<P>The encoding of UTF-8 strings in the <FONT FACE="Courier New">bytes</FONT> item of <FONT FACE="Courier New">CONSTANT_Utf8_info</FONT> tables differs from the standard UTF-8 format in two ways. First, in the standard UTF-8 encoding scheme, the <FONT FACE="Courier New">null</FONT> character is represented by one byte. In a <FONT FACE="Courier New">CONSTANT_Utf8_info</FONT> table, <FONT FACE="Courier New">null</FONT> characters are represented by two bytes. This two-byte encoding of <FONT FACE="Courier New">null</FONT>s means that the <FONT FACE="Courier New">bytes</FONT> item never contains any byte equal to zero. The second way the <FONT FACE="Courier New">bytes</FONT> item of a <FONT FACE="Courier New">CONSTANT_Utf8_info</FONT> departs from the standard UTF-8 encoding is that only one-, two-, and three-byte encodings are used in the <FONT FACE="Courier New">bytes</FONT> item.  The standard UTF-8 includes longer formats that aren韙 used in <FONT FACE="Courier New">CONSTANT_Utf8_info</FONT> tables.</P>
<H3><P>The CONSTANT_Integer_info Table</P>
</H3><P>The <FONT FACE="Courier New">CONSTANT_Integer_info</FONT> table stores a constant <FONT FACE="Courier New">int</FONT> value. This table is used only to store <FONT FACE="Courier New">int</FONT> literals. It is not used in symbolic references. Table 6-10 shows the format of a <FONT FACE="Courier New">CONSTANT_Integer_info</FONT> table.</P>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -