Java虚拟机架构中英文资料
The structure of the Java Virtual Machine
This book specifies an abstract machine. It does not document any particular implementation of the Java virtual machine, including Sun Microsystems'.
To implement the Java virtual machine correctly, you need only be able to read the class file format and correctly perform the operations specified therein. Implementation details that are not part of the Java virtual machine's specification would unnecessarily constrain the creativity of implementors. For example, the memory layout of run-time data areas, the garbage-collection algorithm ud, and any internal optimization of the Java virtual machine instructions (for example, translating them into machine code) are left to the discretion of the implementor.
1. The class File Format
Compiled code to be executed by the Java virtual machine is repr痘痘图
ented using a hardwar
e- and operating system-independent binary format, typically (but not necessarily) stored in a file, known as the class file format. The class file format precily defines the reprentation of a class or interface, including details such as byte ordering that might be taken for granted in a platform-specific object file format.
2 .Data Types
Like the Java programming language, the Java virtual machine operates on two kinds of types: primitive types and reference types. There are, correspondingly, two kinds of values that can be stored in variables, pasd as arguments, returned by methods, and operated upon: primitive values and reference values.
The Java virtual machine expects that nearly all type checking is done prior to run time, typically by a compiler, and 杀人吧
does not have to be done by the Java virtual machine itlf. Values of primitive types need not be tagged or otherwi be inspectable to determine their types at run time, or to be distinguished from values of reference types. Instead, the instruction t of the Java virtual 描写昆虫的作文
machine distinguishes its operand types using instructio
ns intended to operate on values of specific types. For instance, iadd, ladd, fadd, and dadd are all Java virtual machine instructions that add two numeric values and produce numeric results, but each is specialized for its operand type: int, long, float, and double, respectively.
The Java virtual machine contains explicit support for objects. An object is either a dynamically allocated class instance or an array. A reference to an object is considered to have Java virtual machine type reference. Values of type reference can be thought of as pointers to objects. More than one reference to an object may exist. Objects are always operated on, pasd, and tested via values of type reference.
3. Primitive Types and Values
The primitive data types supported by the Java virtual machine are the numeric types, the boolean type and the returnAddress type. The numeric types consist of the integral types and the floating-point types. The integral types are:
byte, who values are 8-bit signed two's-complement integers
●short, who values are 16-bit signed two's-complement integers
●int, who values are 32-bit signed two's-complement integers
●long, who values are 64-bit signed two's-complement integers
●char, who values are 16-bit unsigned integers reprenting Unicode characters
The floating-point types are:
●float, who values are elements of the float value t or, where supported, the float-extended-exponent value t
●double, who values are elements of the double value t or, where supported, the double-extended-exponent value t
The values of the boolean type encode the truth values true and fal.
The values of the returnAddress type are pointers to the opcodes of Java virtual machine
instructions. Of the primitive types only the returnAddress type is not directly associated with a Java programming language type.
3.1 Integral Types and Values
The values of the integral types of the Java virtual machine are the same as tho for the integral types of the Java programming language:
For byte, from -128 to 127 (-27 to 27-1), inclusive
For short, from -32768 to 32767 (-215 to 215-1), inclusive
For int, from -2147483648 to 2147483647 (-231 to 231-1), inclusive
For long, from -9223372036854775808 to 9223372036854775807 (-263 to 263-1), inclusive
For char, from 0 to 65535 inclusive
3.2 Floating-Point Types, Value Sets, and Values
The floating-point types are float and double, which are conceptually associated w商品专员
ith the 32-bit single-precision and 64-bit double-precision format IEEE 754 values and operations as specified in IEEE Standard for Binary Floating-Point Arithmetic , ANSI/IEEE Std. 754-1985 (IEEE, New York).
The IEEE 754 standard includes not only positive and negative sign-magnitude numbers, but also positive and negative zeros, positive and negative infinities, and a special Not-a-Number value (hereafter abbreviated as "NaN"). The NaN value is ud to reprent the result of certain invalid operations such as dividing zero by zero.