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

📄 classfile.doc.html

📁 Jvm 规范说明。The Java Virtual Machine was designed to support the Java programming language. Some concep
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<br><br>.<p>
</blockquote><a name="1327"></a>
<h3>4.4.6	 <em>CONSTANT_NameAndType </em></h3>
<a name="5970"></a>
The <code>CONSTANT_NameAndType_info</code> structure is used to represent a field or method, 
without indicating which class or interface type it belongs to:
<p><pre><br><a name="1328"></a>&nbsp;&nbsp;&nbsp;&nbsp;<code>CONSTANT_NameAndType_info {
</code></pre><pre>&nbsp;&nbsp;&nbsp;&nbsp;<code>	u1 tag;
</code>&nbsp;&nbsp;&nbsp;&nbsp;<code>	u2 name_index;
</code>&nbsp;&nbsp;&nbsp;&nbsp;<code>	u2 descriptor_index;
</code><a name="1332"></a>&nbsp;&nbsp;&nbsp;&nbsp;<code>}
</code><br></pre><a name="9390"></a>
The items of the <code>CONSTANT_NameAndType_info</code> structure are as follows:
<p><a name="1334"></a>
<b>&nbsp; &nbsp; &nbsp; &nbsp;tag</b><br><blockquote><a name="1335"></a>
The <code>tag</code> item of the <code>CONSTANT_NameAndType_info</code> structure has the value <code>CONSTANT_NameAndType</code> (<code>12</code>).<p>
</blockquote><a name="1336"></a>
<b>&nbsp; &nbsp; &nbsp; &nbsp;name_index</b><br><blockquote><a name="1337"></a>
The value of the <code>name_index</code> item must be a valid index into the <code>constant_pool</code> table. The <code>constant_pool</code> entry at that index must be a <code>CONSTANT_Utf8_info</code> <a href="ClassFile.doc.html#7963">(&#167;4.4.7)</a> structure representing a valid Java field name or method name <a href="Concepts.doc.html#21272">(&#167;2.7)</a> stored as a simple (not fully qualified) name <a href="Concepts.doc.html#21410">(&#167;2.7.1)</a>, that is, as a Java identifier.<p>
</blockquote><a name="1338"></a>
<b>&nbsp; &nbsp; &nbsp; &nbsp;descriptor_index</b><br><blockquote><a name="7955"></a>
The value of the <code>descriptor_index</code> item must be a valid index into the <code>constant_pool</code> table. The <code>constant_pool</code> entry at that index must be a <code>CONSTANT_Utf8_info</code> <a href="ClassFile.doc.html#7963">(&#167;4.4.7)</a> structure representing a valid Java field descriptor <a href="ClassFile.doc.html#14152">(&#167;4.3.2)</a> or method descriptor <a href="ClassFile.doc.html#7035">(&#167;4.3.3)</a>.<p>
</blockquote><a name="7963"></a>
<h3>4.4.7	 <em>CONSTANT_Utf8 </em></h3>
<a name="1297"></a>
The <code>CONSTANT_Utf8_info</code> structure is used to represent constant string values.
<p><a name="3310"></a>
UTF-8 strings are encoded so that character sequences that contain only non-null ASCII characters can be represented using only one byte per character, but characters of up to 16 bits can be represented. All characters in the range <code>'u0001'</code> to <code>'u007F'</code> are represented by a single byte:<p>
<a name="17394"></a>
<p><Table Border="0">
<tr><td><a name="17389"></a>
 
<td><a name="17391"></a>
 0
<td><a name="17393"></a>
 bits 0-7

</Table><br><br><p>
<a name="17395"></a>
<p>
<a name="23575"></a>
The seven bits of data in the byte give the value of the character represented. The 
null character (<code>'u0000'</code>) and characters in the range <code>'u0080'</code> to <code>'u07FF'</code> are represented 
by a pair of bytes x and y:
<p><a name="23595"></a>
<p><Table Border="0">
<tr><td><a name="23599"></a>
 x: 
<td><a name="23580"></a>
 1
<td><a name="23582"></a>
 1
<td><a name="23584"></a>
 0
<td><a name="23586"></a>
 bits 6-10
<td><a name="23588"></a>
 y:
<td><a name="23590"></a>
 1
<td><a name="23592"></a>
 0
<td><a name="23594"></a>
 bits 0-5

</Table><br><br><p>
<a name="23596"></a>
<p>
<a name="3319"></a>
The bytes represent the character with the value ((x & <code>0x1f</code>) << <code>6</code>) + (y & <code>0x3f</code>).
<p><a name="12876"></a>
Characters in the range <code>'u0800'</code> to <code>'uFFFF'</code> are represented by three bytes x, y, and z:<p>
<a name="15268"></a>
<p><Table Border="0">
<tr><td><a name="13601"></a>
 x:
<td><a name="5200"></a>
 1
<td><a name="5202"></a>
 1
<td><a name="5204"></a>
 1
<td><a name="5206"></a>
 0
<td><a name="5208"></a>
 bits 12-15
<td><a name="5210"></a>
 y:
<td><a name="5212"></a>
 1
<td><a name="5214"></a>
 0
<td><a name="5216"></a>
 bits 6-11
<td><a name="5218"></a>
 z:
<td><a name="5220"></a>
 1
<td><a name="5222"></a>
 0
<td><a name="5224"></a>
 bits 0-5

</Table><br><br><p>
<a name="15575"></a>
<p>
<a name="15576"></a>
The character with the value ((x & <code>0xf</code>) << <code>12</code>) + ((y & <code>0x3f</code>) << <code>6</code>) + (z & <code>0x3f</code>) is represented by the bytes.
<p><a name="12887"></a>
The bytes of multibyte characters are stored in the <code>class</code> file in big-endian (high byte first) order.<p>
<a name="6111"></a>
There are two differences between this format and the "standard" UTF-8 format. First, the null byte <code>(byte)0</code> is encoded using the two-byte format rather than the one-byte format, so that Java Virtual Machine UTF-8 strings never have embedded nulls. Second, only the one-byte, two-byte, and three-byte formats are used. The Java Virtual Machine does not recognize the longer UTF-8 formats.<p>
<a name="14071"></a>
For more information regarding the UTF-8 format, see <i>File System Safe UCS Transformation Format (FSS_UTF)</i>, X/Open Preliminary Specification, X/Open Company Ltd., Document Number: P316. This information also appears in ISO/IEC 10646, Annex P.<p>
<a name="7715"></a>
The <code>CONSTANT_Utf8_info</code> structure is<p>
<pre><br><a name="1298"></a>&nbsp;&nbsp;&nbsp;&nbsp;<code>CONSTANT_Utf8_info {
</code></pre><pre>&nbsp;&nbsp;&nbsp;&nbsp;<code>	u1 tag;
</code>&nbsp;&nbsp;&nbsp;&nbsp;<code>	u2 length;
</code>&nbsp;&nbsp;&nbsp;&nbsp;<code>	u1 bytes[length];
</code><a name="9399"></a>&nbsp;&nbsp;&nbsp;&nbsp;<code>}
</code><br></pre><a name="9402"></a>
The items of the <code>CONSTANT_Utf8_info</code> structure are the following:
<p><a name="9401"></a>
<b>&nbsp; &nbsp; &nbsp; &nbsp;tag</b><br><blockquote><a name="1311"></a>
The <code>tag</code> item of the <code>CONSTANT_Utf8_info</code> structure has the value <code>CONSTANT_Utf8</code> (<code>1</code>).<p>
</blockquote><a name="1312"></a>
<b>&nbsp; &nbsp; &nbsp; &nbsp;length</b><br><blockquote><a name="1313"></a>
The value of the <code>length</code> item gives the number of bytes in the <code>bytes</code> array (not the length of the resulting string). The strings in the <code>CONSTANT_Utf8_info</code> structure are not null-terminated.<p>
</blockquote><a name="2874"></a>
<b>&nbsp; &nbsp; &nbsp; &nbsp;bytes[]</b><br><blockquote><a name="2875"></a>
The <code>bytes</code> array contains the bytes of the string. No byte may have the value <code>(byte)0</code> or <code>(byte)0xf0</code>-<code>(byte)0xff</code>.<p>
</blockquote><a name="2877"></a>
<hr><h2>4.5	 Fields</h2>
<a name="1480"></a>
Each field is described by a variable-length <code>field_info</code> structure. The format of this 
structure is
<p><pre><br><a name="1481"></a>&nbsp;&nbsp;&nbsp;&nbsp;<code>field_info {
</code></pre><pre>&nbsp;&nbsp;&nbsp;&nbsp;<code>	u2 access_flags;
</code>&nbsp;&nbsp;&nbsp;&nbsp;<code>	u2 name_index;
</code>&nbsp;&nbsp;&nbsp;&nbsp;<code>	u2 descriptor_index;
</code>&nbsp;&nbsp;&nbsp;&nbsp;<code>	u2 attributes_count;
</code>&nbsp;&nbsp;&nbsp;&nbsp;<code>	attribute_info attributes[attributes_count];
</code><a name="1487"></a>&nbsp;&nbsp;&nbsp;&nbsp;<code>}
</code><br></pre><a name="9407"></a>
The items of the <code>field_info</code> structure are as follows:
<p><a name="1488"></a>
<b>&nbsp; &nbsp; &nbsp; &nbsp;access_flags</b><br><blockquote><a name="23392"></a>
The value of the <code>access_flags</code> item is a mask of modifiers used to describe access permission to and properties of a field. The <code>access_flags</code> modifiers are shown in Table 4.3. <p><Table Border="0">
<tr><td><a name="23398"></a>
Flag Name
<td><a name="23400"></a>
Value
<td><a name="23402"></a>
Meaning
<td><a name="23404"></a>
Used By

<tr><td><a name="23406"></a>
<code>ACC_PUBLIC</code>
<td><a name="23408"></a>
<code>0x0001</code>
<td><a name="23410"></a>
Is <code>public</code>; may be accessed from outside its package. 
<td><a name="23412"></a>
Any field

<tr><td><a name="23414"></a>
<code>ACC_PRIVATE</code>
<td><a name="23416"></a>
<code>0x0002</code>
<td><a name="23418"></a>
Is <code>private</code>; usable only within the defining class.
<td><a name="23420"></a>
Class field

<tr><td><a name="23422"></a>
<code>ACC_PROTECTED</code>
<td><a name="23424"></a>
<code>0x0004</code>
<td><a name="23426"></a>
Is <code>protected</code>; may be accessed within subclasses.
<td><a name="23428"></a>
Class field

<tr><td><a name="23430"></a>
<code>ACC_STATIC</code>
<td><a name="23432"></a>
<code>0x0008</code>
<td><a name="23434"></a>

⌨️ 快捷键说明

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