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

📄 changesappendix.doc.html

📁 A Java virtual machine instruction consists of an opcode specifying the operation to be performed, f
💻 HTML
📖 第 1 页 / 共 2 页
字号:
</p><p>This choice gives programmers the flexibility of moving methods and fields in the class hierarchy while retaining binary compatibility with previous implementations of their programs.</p></ul><ul><li><em>Clarifying that an</em> <code>AbstractMethodError</code> <em>may not be raised during  preparation.</em> </ul><ul><p><i>The Java</i><sup><font size=-2>TM</font></sup><i> Language Specification</i> requires that adding a method to an interfacebe a binary compatible change. However, Sections 5.1.1 and 2.16.3 of  the original specification require that preparation reject a class that has an <code>abstract</code> method unless that class is itself <code>abstract</code>. The latter requirement contradicts the former. </p><p>Consider the case of an interface <i>I</i> implemented by a class <i>C</i> that is not <code>abstract</code>. If a new method is added to <i>I</i>, <i>C</i> must implement it. However, if  an old version of <i>C</i> is used together with the new version of <i>I</i> at run time, <i>C</i> will indeed have an <code>abstract</code> method. If preparation were to raise an <code>AbstractMethodError</code> in this case, adding a method to <i>I</i> would not have been a binary compatible change, since it would have resulted in a link-time failure. Consequently, the check at preparation time has been dropped. This change has implications for method invocation, as discussed below.</p></ul><ul><li><em>Clarifying that interface method resolution may raise exceptions.</em> </ul><ul><p>The description in Section 5.3 of the original specification omitted the checks required during interface method resolution. These checks (that the referenced interface exists and that the referenced method exists in that interface) are required by <i>The Java</i><sup><font size=-2>TM</font></sup><i> Language Specification</i> and are performed by most widely used implementations of the Java virtual machine. The checks are  documented in <a href="ConstantPool.doc.html#71722">Section 5.4.3.4</a> of the revised specification. </p></ul><ul><li><em>Specifying events triggering class or interface initialization.</em> </ul><ul><p>As a consequence of the decoupling of class and interface initialization from resolution, it became necessary to specify when the Java virtual machine  triggers initialization. This specification is given in <a href="ConstantPool.doc.html#77976">Section 5.5</a> of the revised specification. As noted earlier, this description agrees with the specification  of the events at the Java programming language level triggering initialization, given in <a href="Concepts.doc.html#19075">Section 2.17.4</a> of the revised specification.</p></ul><a name="445933"></a><hr><h2> Changes to Method Invocation</h2>The following changes have been made to the specification of the method invocation instructions. Many of these are direct consequences of the changes described in the previous section; others are designed merely to clarify the presentation.<p><ul><li><em>Reliance on method tables, which was merely illustrative, has been  removed.</em></ul><ul><p>The descriptions of the method invocation instructions made use of the well-known concept of a method dispatch table. The method tables were used as expository devices, but unfortunately many readers mistakenly thought that the use of such tables was a requirement of the specification. To clarify this point, a lookup algorithm is given instead.</p></ul><ul><li><em>Link-time and runtime exceptions are used consistently.</em></ul><ul><p>The original specification sometimes listed exceptions that could be raised by an instruction according to their position in the exception hierarchy, rather than by when they might occur. This usage was inconsistent and sometimes erroneous. </p><p>The intent of the categories Linking Exceptions and Runtime Exceptions at the end of each instruction description is to describe at what phase of executionan error will be thrown. An important example of this is the treatment of <code>UnsatisfiedLinkError</code>. The descriptions of all method invocation instructions specify that <code>native</code> methods are bound at run time if they have not been bound already. If the binding fails, an <code>UnsatisfiedLinkError</code> is thrown. However, <code>UnsatisfiedLinkError</code> is consistently listed in the instruction descriptions of the original specification as a Linking Exception. To make it clear that the exception is actually thrown at run time, the revised specification lists <code>UnsatisfiedLinkError</code> as a Runtime Exception in the descriptions of all the method invocation instructions.</p><p>Another instance of this problem was in the description of the <i>invokeinterface</i> instruction. Most of the exceptions listed in the original specification of <i>invokeinterface</i> as Linking Exceptions actually occurred at run time. They are listed in the revised specification as Runtime Exceptions.</p></ul><ul><li><em>It is possible to attempt to invoke</em> <code>abstract</code> <em>methods at run time.</em></ul><ul><p>This is a direct result of the elimination of the <code>abstract</code> method check during class or interface preparation, as discussed earlier. While in many cases the use of an <code>abstract</code> method on a class that is not <code>abstract</code> will still result in a link-time error, it is possible to construct cases where the error will not occur until run time. </p><p>Consider an <code>abstract</code> class <i>A</i> with <code>abstract</code> method <code>foo</code> and concrete subclass <i>B</i>. If <i>B</i> neglects to implement <code>foo</code>, then a method </p></ul><pre>&nbsp;&nbsp;&nbsp;&nbsp;<code>      void bar(A</code> <code>a) {a.foo();}</code> </pre><ul><p>will fail if invoked upon an instance of <i>B</i>. This will not be detected at link time, but at run time. As a result, <i>invokeinterface</i> and <i>invokevirtual</i> may raise an <code>AbstractMethodError</code> at run time.</p></ul><ul><li><em>The</em> <i>invokeinterface</i> <em>instruction specification has changed.</em></ul><ul><p>The description of the <i>invokeinterface</i> instruction now states that the target of the method invocation must support the referenced interface. This is required by <i>The Java</i><sup><font size=-2>TM</font></sup><i> Language Specification</i> and has been a property of all major Java virtual machine implementations for some time.</p></ul><ul><li><em>The description of the</em> <i>invokespecial</i> <em>instruction has been clarified.</em> </ul><ul><p>The second bullet on page 261 of the original specification was redundant and has been removed. The other bullets have been reordered, and the fact that ordinarily the resolved method is selected for execution has been asserted explicitly. These changes do not alter the specification in any way, but serve only to make the text more understandable.</p></ul><a name="448325"></a><hr><h2> Nested Classes</h2>Nested classes were introduced into the Java programming language after the originalspecification of the Java virtual machine and the first edition of <i>The Java</i><sup></sup><i> LanguageSpecification </i>were printed. The <code>Innerclasses</code> and <code>Synthetic</code> attributes, described in the revised specification in <a href="ClassFile.doc.html#79996">Section 4.7.5</a> and <a href="ClassFile.doc.html#80128">Section 4.7.6</a>, respectively,were added in JDK release 1.1 in order to support nested classes.<p><a name="448337"></a>Unfortunately, we have not been able to include a description of nested classes in the Java programming language overview given in Chapter 2. A complete description will be included in the next edition of the <i>The Java</i><sup><font size=-2>TM</font></sup><i> Language Specification</i>. Until then, refer to the documentation on the World Wide Web at <a href=http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses><code>http://java.sun.com/products/jdk/1.1/docs/guide/innerclasses</code></a>.<p><a name="448885"></a><hr><h2> Chapter 9 of Original Specification Deleted</h2>Chapter 9, "An Optimization," of the original specification documented an optimizationtechnique used in Sun's contemporary Java virtual machine implementation. The original specification was clear that this chapter and the technique it described were not part of the Java virtual machine specification. However, the chapter providedan example of the flexibility that the Java virtual machine specification intends to give implementors. This information about Sun's implementation was also consideredpossibly useful to writers of tools such as debuggers. <p><a name="448965"></a>The chapter has been removed from the revised specification. The optimization technique it described is now well understood. More important, the technique exactly as described is not used by many of the Java virtual machine implementations, including some of Sun's, developed since the original specification was published. The value of the chapter to tool writers has diminished for the same reason. Thus, the chapter is now best seen as documentation for a specific Java virtual machine implementation, making it inappropriate for the Java virtual machine specification.<p><a name="448889"></a><hr><h2> Other Issues</h2><ul><li>In light of our experience with several releases of the Java platform, the  interpretation of the version numbers defined as part of the <code>class</code> file format has changed. The major version number is now intended to correspond to new platform major releases (for instance, the Java 2 platform, Standard Edition, v1.2), while the minor version number may be used to represent release levels of platform implementations (for instance, the Java 2 SDK, Standard Edition, v1.2.1). Since the first public release of the Java platform, all <code>class</code> files have been generated using major version number 45 and minor version number 3. Hence, no existing well-formed <code>class</code> file is affected by this change in interpretation. <p><li>Corresponding to the change in version number interpretation, the actual  version numbers accepted by new implementations of the Java virtual machine have changed. Existing binaries are not affected by this change because these new virtual machine implementations will continue to accept <code>class</code> files  with the historically used version numbers.<p><li>It is now clear that reflective operations can cause class initialization. The  original specification did not discuss the topic of reflection at all, since  reflection did not yet exist in the Java programming language. Many subsequently added reflective operations correspond to language-level constructs that do require initialization and similarly must cause initialization. This is documented in the revised specification.<p><li>Class finalization has been removed from the Java programming language  and, consequently, from the revised specification as well. Class finalization  had never been implemented, so the change had no effect on existing programs. The effects of class finalization are obtainable via instance finalization.<p><li>The rules for class unloading have been clarified. The description of class unloading in the original specification gave, by way of illustration, certain  necessary conditions for unloading a class. These conditions were misinterpreted as being sufficient conditions. This led to implementations that unloaded classes usable by a running program. The revised specification describes the precise circumstances under which classes may be unloaded.<p><li>The instructions <i>aastore</i><em>, </em><i>checkcast</i>, and <i>instanceof</i> contain a subtyping  algorithm. The original version of this algorithm was flawed in that it did not cover the case where two arrays whose component types were interfaces were being compared. The revised specification corrects this.<p><li>The descriptions of the <i>getfield</i> and <i>putfield</i> instructions have been made less implementation specific. In particular, the revised specification eliminates the notion of particular field widths and offsets.<p><li>The descriptions of the instructions <i>putfield </i>and <i>putstatic</i> now include a specification of their behavior when a field is <code>final</code>. This documents the behavior of existing implementations.<p><li>The description of the process of throwing an exception in <a href="Overview.doc.html#15494">Section 3.10</a> has been made clearer and more precise.<p><li>The descriptions of the various return instructions and <i>athrow</i> failed to note that these instructions could raise an <code>IllegalMonitorStateException</code>. The original specification implicitly allowed for the raising of such an exception as a consequence of <a href="Threads.doc.html#25549">Section 8.5</a>: </ul><ul><p>An <i>unlock</i> operation by thread <i>T</i><em></em> on lock <i>L</i> may occur only if the number of preceding <i>unlock</i> operations by <i>T</i><em></em> on <i>L</i> is strictly less than the number of preceding<i>lock</i> operations by <i>T</i><em></em> on <i>L</i>. </p><p>and <a href="Threads.doc.html#22500">Section 8.13</a>: </p><p>If execution of the method's body is ever completed, either normally or abruptly, an <i>unlock</i> operation is automatically performed on that same lock.</p><p>However, this had not been stated clearly and explicitly. </p></ul><ul><li>Structured use of locks may now be enforced. The description of locking in <code>synchronized</code> statements given in Section 8.13 of the original specification was erroneous. It stated the following:</ul><ul><p>If execution of the body is ever completed, either normally or abruptly, an <i>unlock</i> operation is automatically performed on that same lock.</p><p>This is a property of programs written in the Java programming language, guaranteed by correct compilers for the Java programming language; it is not guaranteed by the Java virtual machine. However, programs do indeed make structured use of locking, and Java virtual machine implementations may rely on and enforce this property. The appropriate rules are given in the revised version of <a href="Threads.doc.html#22500">Section 8.13</a>. As a consequence of those rules, <code>IllegalMonitorStateException</code> exceptions may be raised by the return instructions and  <i>athrow</i>, and by the method invocation instructions when invoking <code>native</code> methods.</p></ul><ul><li>The <code>Deprecated</code> attribute, an attribute introduced in JDK release 1.1 to support the <code>@deprecated</code> tag in documentation comments, has been specified. The presence of a <code>Deprecated</code> attribute does not alter the semantics of a class or interface.</ul><hr><!-- This inserts footnotes--><p><a href="VMSpecTOC.doc.html">Contents</a> | <a href="Mnemonics.doc.html">Prev</a> | <a href="VMSpecIX.fm.html">Next</a> | <a href="VMSpecIX.fm.html">Index</a><p><font size="-1"><i>The Java</i><sup><font size=-2>TM</font></sup><i> Virtual Machine Specification </i><br><!-- HTML generated by Suzette Pelouch on March 31, 1999 --><i><a href="Copyright.doc.html">Copyright &#169 1999 Sun Microsystems, Inc.</a>All rights reserved</i><br>Please send any comments or corrections to <a href="mailto:jvm@java.sun.com">jvm@java.sun.com</a></font></body></html>

⌨️ 快捷键说明

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