📄 classfile.doc.html
字号:
<i>BaseType</i><br> <i>ObjectType</i><br> <i>ArrayType</i> <br><a name="81068"></a><p>states that a <i>FieldType</i> may represent either a <i>BaseType</i>, an <i>ObjectType</i>, or an <i>ArrayType</i>.<p><a name="81084"></a>A nonterminal symbol on the right-hand side of a production that is followed by an asterisk (*) represents zero or more possibly different values produced from that nonterminal, appended without any intervening space. The production:<p><a name="81087"></a><i>MethodDescriptor:</i><br> ( <i>ParameterDescriptor*    </i>) <i>ReturnDescriptor</i><p><a name="81085"></a>states that a <i>MethodDescriptor</i> represents a left parenthesis, followed by zero or more <i>ParameterDescriptor</i> values, followed by a right parenthesis, followed by a <i>ReturnDescriptor</i>.<p><a name="14152"></a><h3>4.3.2 Field Descriptors</h3><a name="7028"></a>A <i>field descriptor</i> represents the type of a class, instance, or local variable. It is a series of characters generated by the grammar:<p><a name="13975"></a> <i>FieldDescriptor:</i><br><blockquote><a name="23539"></a><i>FieldType</i><p></blockquote><a name="23540"></a><p><a name="23546"></a> <i>ComponentType:</i><br><blockquote><a name="13979"></a><i>FieldType</i><p></blockquote><a name="23520"></a><p><a name="23545"></a> <i>FieldType:</i><br><blockquote><a name="13982"></a><i>BaseType</i><p><a name="14135"></a><i>ObjectType</i><p><a name="13983"></a><i>ArrayType</i> <p></blockquote><a name="13984"></a><p><a name="23547"></a> <i>BaseType:</i><br><blockquote><a name="13985"></a>B<p><a name="13986"></a>C<p><a name="13987"></a>D<p><a name="13988"></a>F<p><a name="13989"></a>I<p><a name="13990"></a>J<p><a name="13991"></a>S<p><a name="13992"></a>Z<p><a name="14125"></a><p></blockquote><a name="23548"></a> <i>ObjectType:</i><br><blockquote><a name="14126"></a>L <classname> ;<p></blockquote><a name="14127"></a> <i>ArrayType:</i><br><blockquote><a name="14128"></a>[ <i>ComponentType</i><p></blockquote><a name="14019"></a><a name="14019"></a>The characters of <i>BaseType</i>, the L and ; of <i>ObjectType</i>, and the [ of <i>ArrayType</i> are all ASCII characters. The <classname> represents a fully qualified class or interface name. For historical reasons it is encoded in internal form (<a href="ClassFile.doc.html#14757">§4.2)</a>.<p><a name="16252"></a>The interpretation of the field types is as shown in <a href="ClassFile.doc.html#84645">Table 4.2</a>.<p><Table Border="1"><tr><td><a name="84645"></a><i>BaseType</i><strong> Character</strong><td><a name="84647"></a><strong>Type</strong><td><a name="84649"></a><strong>Interpretation</strong><tr><td><a name="84652"></a>B<td><a name="84654"></a><code>byte</code><td><a name="84656"></a>signed byte<tr><td><a name="84659"></a>C<td><a name="84661"></a><code>char</code><td><a name="84663"></a>Unicode character<tr><td><a name="84666"></a>D<td><a name="84668"></a><code>double</code><td><a name="84670"></a>double-precision floating-point value<tr><td><a name="84673"></a>F<td><a name="84675"></a><code>float</code><td><a name="84677"></a>single-precision floating-point value<tr><td><a name="84681"></a>I<td><a name="84683"></a><code>int</code><td><a name="84685"></a>integer<tr><td><a name="84689"></a>J<td><a name="84691"></a><code>long</code><td><a name="84693"></a>long integer<tr><td><a name="84697"></a>L<classname>;<td><a name="84699"></a><code>reference</code><td><a name="84701"></a>an instance of class <code><classname></code><tr><td><a name="84705"></a>S<td><a name="84707"></a><code>short</code><td><a name="84709"></a>signed short<tr><td><a name="84713"></a>Z<td><a name="84715"></a><code>boolean</code><td><a name="84717"></a><code>true</code> or <code>false</code><tr><td><a name="84783"></a><strong>[ </strong><td><a name="84785"></a><code>reference</code><td><a name="84787"></a>one array dimension</Table><br><br><p><a name="84641"></a><p><a name="84868"></a>For example, the descriptor of an instance variable of type <code>int</code> is simply I. The descriptor of an instance variable of type <code>Object</code> is Ljava/lang/Object;. Note that the internal form of the fully qualified name for class <code>Object</code> is used. The descriptor of an instance variable that is a multidimensional <code>double</code> array,<p><pre> <code>double d[][][];</code></pre><a name="12776"></a>is<p><pre> <strong>[[[D</strong></pre><a name="7035"></a><h3>4.3.3 Method Descriptors</h3><a name="74607"></a>A <i>method descriptor</i> represents the parameters that the method takes and the value that it returns:<p><a name="81101"></a><blockquote><i>MethodDescriptor:</i><br> ( <i>ParameterDescriptor*    </i>) <i>ReturnDescriptor</i><p><a name="81108"></a></blockquote>A <i>parameter descriptor </i>represents a parameter passed to a method:<p><blockquote><a name="14034"></a><i>ParameterDescriptor:</i><br> <i>FieldType</i><p><a name="42504"></a></blockquote>A <i>return descriptor </i>represents the type of the value returned from a method. It is a series of characters generated by the grammar:<p><a name="14049"></a><blockquote><i>ReturnDescriptor:</i><br> <i>FieldType</i><br> V<p> </blockquote><a name="7587"></a>The character V indicates that the method returns no value (its return type is <code>void</code>).<p><a name="11151"></a>A method descriptor is valid only if it represents method parameters with a total length of 255 or less, where that length includes the contribution for <code>this</code> in the case of instance or interface method invocations. The total length is calculated by summing the contributions of the individual parameters, where a parameter of type <code>long</code> or <code>double</code> contributes two units to the length and a parameter of any other type contributes one unit.<p><a name="12746"></a>For example, the method descriptor for the method<p><pre> <code>Object mymethod(int i, double d, Thread t)</code></pre><a name="12751"></a>is<p><pre> <strong>(IDLjava/lang/Thread;)Ljava/lang/Object;</strong></pre><a name="18238"></a>Note that internal forms of the fully qualified names of <code>Thread</code> and <code>Object</code> are used in the method descriptor.<p><a name="15525"></a>The method descriptor for <code>mymethod</code> is the same whether <code>mymethod</code> is a class or an instance method. Although an instance method is passed <code>this</code>, a reference to the current class instance, in addition to its intended parameters, that fact is not reflected in the method descriptor. (A reference to <code>this</code> is not passed to a class method.) The reference to <code>this</code> is passed implicitly by the method invocation instructions of the Java virtual machine used to invoke instance methods.<p><a name="20080"></a><hr><h2>4.4 The Constant Pool</h2><a name="9597"></a>Java virtual machine instructions do not rely on the runtime layout of classes, interfaces, class instances, or arrays. Instead, instructions refer to symbolic informationin the <code>constant_pool</code> table. <p><a name="36992"></a>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -