JVMS Specification(2)-Compiling for the Java Virtual Machine
Subsections
2 Compiling for the Java Virtual Machine
2.2 Use of Constants, Local Variables, and Control Constructs
2.4 Accessing the Runtime Constant Pool
2.8 Working with Class Instances
2.11 Operationson the Operand Stack
2.12 Throwingand Handling Exceptions
THE Java virtual machine is designed to support the Java programminglanguage.
Oracle’s JDK software contains both a compiler from source code written inthe
Java programming language to the instruction set of the Java virtualmachine, and a
runtime system that implements the Java virtual machine itself.Understanding how
one compiler utilizes the Java virtual machine is useful to theprospective compiler
writer, as well as to one trying to understand the Java virtual machineitself. The
numbered sections in this chapter are not normative.
Note that the term “compiler” is sometimes used when referring to atranslator
from the instruction set of a Java virtual machine to the instruction setof a specific
CPU. One example of such a translator is a just-in-time (JIT) codegenerator,
which generates platform-specific instructions only after Java virtualmachine
code has been loaded. This chapter does not address issues associated withcode
generation, only those associated with compiling source code written inthe Java
programming languageto Java virtual machine instructions.
JVM被设计成支持java编程语言,Oracle JDK软件支持包括两套,一套被java语言编写的源码编译成虚拟机指令集合的编译器。
一套是JVM自己执行时环境。
理解一个编译器怎样应用在JVM中,对一个未来编译器工作者是非常实用的。这也是非常好的理解JVM本身自己。
注意。提到的编译器有时是指从JVM指令转换到CPU特殊的机器指令,比方JIT代码生成器,用来生成平台特殊的指令当JVM代码被载入以后。
这章不讨论这样的代码生成器,仅仅讨论被java程序语言编写的源码转换为JVM指令。
1.1 Formatof Examples
This chapter consists mainly of examples of source code together withannotated
listings of the Java virtual machine code that the javac compiler in Oracle’sJDK
release 1.0.2 generates for the examples. The Java virtual machine code iswritten in
the informal “virtual machine assembly language” output by Oracle’s javap utility,
distributed with the JDK release. You can use javap to generate additionalexamples
of compiled methods.
The format of the examples should be familiar to anyone who has readassembly
code. Each instruction takes the form
实例主要包含源码和JVM代码凝视列表,JVM代码凝视列表是又oracle JDK 1.0.2版本号来生成。你能够使用javap命令来生成编译方法的样例。
这个样例的格式对读取汇编代码的人都非常熟悉,每一个指令例如以下格式。
<index> <opcode> [<operand1> [<operand2>...]] [<comment>]
The <index>