没有合适的资源?快使用搜索试试~ 我知道了~
首页Java SE 8虚拟机详解:新特性和class文件深度解析
"《Java虚拟机规范:基于Java SE 8》是一本权威的专业书籍,由Java技术的创始人撰写,详细解析了Java虚拟机的工作原理和特性和变化。该书专为Java SE 8版本设计,旨在提供全面、准确的指导,涵盖新特性如默认实现接口方法的调用和类型注解的支持。读者可以深入理解class文件格式的结构,包括其属性及其在字节码验证中的作用。 第1章概述了Java的历史背景和发展,强调了Java虚拟机在Java平台中的核心地位。作者介绍了书籍的组织结构和使用的符号约定,同时鼓励读者提供反馈,促进技术交流和改进。章节2深入探讨了Java虚拟机的内部结构,包括class文件的格式,这是程序执行的基础。这部分内容解释了数据类型和它们的表示,特别关注了整型和浮点型数值的处理,这些是字节码指令的基础。 书中还涵盖了Java SE 8引入的新功能,如接口的默认方法,它们在运行时为程序员提供了更大的灵活性。此外,为了支持类型注解和方法参数注解,class文件格式得到了扩展,这进一步增强了程序的元数据表达能力。字节码验证的规则在书中也有详尽阐述,确保了编译后的代码能够在Java虚拟机上正确运行,并遵循安全性和兼容性标准。 版权信息表明,这本书受到Oracle的保护,只在附录A的有限许可下提供。最后,作者表达了对Sophia和Susan的深深感谢,以及对读者的期待,希望这本书能帮助他们深化对Java虚拟机的理解。 《Java虚拟机规范:基于Java SE 8》是一本不可多得的Java开发者必备参考书,对于深入研究Java底层机制,理解最新规范,提升编程效率和代码质量具有重要意义。"
资源详情
资源推荐
1.2 The Java Virtual Machine INTRODUCTION
2
A Web browser incorporating the Java platform is no longer limited to a
predetermined set of capabilities. Visitors to Web pages incorporating dynamic
content can be assured that their machines cannot be damaged by that content.
Programmers can write a program once, and it will run on any machine supplying
a Java run-time environment.
1.2 The Java Virtual Machine
The Java Virtual Machine is the cornerstone of the Java platform. It is the
component of the technology responsible for its hardware- and operating system-
independence, the small size of its compiled code, and its ability to protect users
from malicious programs.
The Java Virtual Machine is an abstract computing machine. Like a real computing
machine, it has an instruction set and manipulates various memory areas at run time.
It is reasonably common to implement a programming language using a virtual
machine; the best-known virtual machine may be the P-Code machine of UCSD
Pascal.
The first prototype implementation of the Java Virtual Machine, done at Sun
Microsystems, Inc., emulated the Java Virtual Machine instruction set in software
hosted by a handheld device that resembled a contemporary Personal Digital
Assistant (PDA). Oracle's current implementations emulate the Java Virtual
Machine on mobile, desktop and server devices, but the Java Virtual Machine
does not assume any particular implementation technology, host hardware, or
host operating system. It is not inherently interpreted, but can just as well be
implemented by compiling its instruction set to that of a silicon CPU. It may also
be implemented in microcode or directly in silicon.
The Java Virtual Machine knows nothing of the Java programming language, only
of a particular binary format, the class file format. A class file contains Java
Virtual Machine instructions (or bytecodes) and a symbol table, as well as other
ancillary information.
For the sake of security, the Java Virtual Machine imposes strong syntactic and
structural constraints on the code in a class file. However, any language with
functionality that can be expressed in terms of a valid class file can be hosted by
the Java Virtual Machine. Attracted by a generally available, machine-independent
platform, implementors of other languages can turn to the Java Virtual Machine as
a delivery vehicle for their languages.
INTRODUCTION Organization of the Specification 1.3
3
The Java Virtual Machine specified here is compatible with the Java SE 8 platform,
and supports the Java programming language specified in The Java Language
Specification, Java SE 8 Edition.
1.3 Organization of the Specification
Chapter 2 gives an overview of the Java Virtual Machine architecture.
Chapter 3 introduces compilation of code written in the Java programming
language into the instruction set of the Java Virtual Machine.
Chapter 4 specifies the class file format, the hardware- and operating system-
independent binary format used to represent compiled classes and interfaces.
Chapter 5 specifies the start-up of the Java Virtual Machine and the loading,
linking, and initialization of classes and interfaces.
Chapter 6 specifies the instruction set of the Java Virtual Machine, presenting the
instructions in alphabetical order of opcode mnemonics.
Chapter 7 gives a table of Java Virtual Machine opcode mnemonics indexed by
opcode value.
In the Second Edition of The Java
®
Virtual Machine Specification, Chapter 2
gave an overview of the Java programming language that was intended to support
the specification of the Java Virtual Machine but was not itself a part of the
specification. In The Java Virtual Machine Specification, Java SE 8 Edition, the
reader is referred to The Java Language Specification, Java SE 8 Edition for
information about the Java programming language. References of the form: (JLS
§x.y) indicate where this is necessary.
In the Second Edition of The Java
®
Virtual Machine Specification, Chapter 8
detailed the low-level actions that explained the interaction of Java Virtual Machine
threads with a shared main memory. In The Java Virtual Machine Specification,
Java SE 8 Edition, the reader is referred to Chapter 17 of The Java Language
Specification, Java SE 8 Edition for information about threads and locks. Chapter
17 reflects The Java Memory Model and Thread Specification produced by the JSR
133 Expert Group.
1.4 Notation INTRODUCTION
4
1.4 Notation
Throughout this specification we refer to classes and interfaces drawn from the
Java SE platform API. Whenever we refer to a class or interface (other than those
declared in an example) using a single identifier N, the intended reference is to the
class or interface named N in the package java.lang. We use the fully qualified
name for classes or interfaces from packages other than java.lang.
Whenever we refer to a class or interface that is declared in the package java or
any of its subpackages, the intended reference is to that class or interface as loaded
by the bootstrap class loader (§5.3.1).
Whenever we refer to a subpackage of a package named java, the intended
reference is to that subpackage as determined by the bootstrap class loader.
The use of fonts in this specification is as follows:
• A fixed width font is used for Java Virtual Machine data types, exceptions,
errors, class file structures, Prolog code, and Java code fragments.
• Italic is used for Java Virtual Machine "assembly language", its opcodes and
operands, as well as items in the Java Virtual Machine's run-time data areas. It
is also used to introduce new terms and simply for emphasis.
Non-normative information, designed to clarify the specification, is given in
smaller, indented text.
This is non-normative information. It provides intuition, rationale, advice, examples, etc.
1.5 Feedback
Readers are invited to report technical errors and ambiguities in The Java
®
Virtual
Machine Specification to jls-jvms-spec-comments@openjdk.java.net.
Questions concerning the generation and manipulation of class files by javac (the
reference compiler for the Java programming language) may be sent to compiler-
dev@openjdk.java.net.
5
CHAPTER 2
The Structure of the Java
Virtual Machine
THIS document specifies an abstract machine. It does not describe any particular
implementation of the Java Virtual Machine.
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 used, 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.
All references to Unicode in this specification are given with respect to The
Unicode Standard, Version 6.0.0, available at http://www.unicode.org/.
2.1 The class File Format
Compiled code to be executed by the Java Virtual Machine is represented using
a hardware- and operating system-independent binary format, typically (but not
necessarily) stored in a file, known as the class file format. The class file format
precisely defines the representation of a class or interface, including details such
as byte ordering that might be taken for granted in a platform-specific object file
format.
Chapter 4, "The class File Format", covers the class file format in detail.
2.2 Data Types THE STRUCTURE OF THE JAVA VIRTUAL MACHINE
6
2.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, passed 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 itself. Values of primitive types need not be tagged or otherwise
be inspectable to determine their types at run time, or to be distinguished from
values of reference types. Instead, the instruction set of the Java Virtual Machine
distinguishes its operand types using instructions 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. For a
summary of type support in the Java Virtual Machine instruction set, see §2.11.1.
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, passed, and tested via values of
type reference.
2.3 Primitive Types and Values
The primitive data types supported by the Java Virtual Machine are the numeric
types, the boolean type (§2.3.4), and the returnAddress type (§2.3.3).
The numeric types consist of the integral types (§2.3.1) and the floating-point types
(§2.3.2).
The integral types are:
• byte, whose values are 8-bit signed two's-complement integers, and whose
default value is zero
• short, whose values are 16-bit signed two's-complement integers, and whose
default value is zero
剩余603页未读,继续阅读
双螺旋
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 计算机人脸表情动画技术发展综述
- 关系数据库的关键字搜索技术综述:模型、架构与未来趋势
- 迭代自适应逆滤波在语音情感识别中的应用
- 概念知识树在旅游领域智能分析中的应用
- 构建is-a层次与OWL本体集成:理论与算法
- 基于语义元的相似度计算方法研究:改进与有效性验证
- 网格梯度多密度聚类算法:去噪与高效聚类
- 网格服务工作流动态调度算法PGSWA研究
- 突发事件连锁反应网络模型与应急预警分析
- BA网络上的病毒营销与网站推广仿真研究
- 离散HSMM故障预测模型:有效提升系统状态预测
- 煤矿安全评价:信息融合与可拓理论的应用
- 多维度Petri网工作流模型MD_WFN:统一建模与应用研究
- 面向过程追踪的知识安全描述方法
- 基于收益的软件过程资源调度优化策略
- 多核环境下基于数据流Java的Web服务器优化实现提升性能
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功