• 欢迎访问速搜资源吧,如果在网站上找不到你需要的资源,可以在留言板上留言,管理员会尽量满足你!

【速搜问答】JVM是什么

问答 admin 3年前 (2020-08-06) 484次浏览 已收录 0个评论

汉英对照:
Chinese-English Translation:

JVM是Java Virtual Machine(Java虚拟机)的缩写,JVM是一种用于计算设备的规范,它是一个虚构出来的计算机,是通过在实际的计算机上仿真模拟各种计算机功能来实现的。

JVM is the abbreviation of Java virtual machine. JVM is a specification for computing devices. It is a fictitious computer, which is realized by simulating various computer functions on the actual computer.

JVM 是 Java Virtual Machine(Java 虚拟机)的缩写,JVM 是一种用于计算设备的规范,它是一个虚构出来的计算机,是通过在实际的计算机上仿真模拟各种计算机功能来实现的。

JVM is the abbreviation of Java virtual machine. JVM is a specification for computing devices. It is a fictitious computer, which is realized by simulating various computer functions on the actual computer.

引入 Java 语言虚拟机后,Java 语言在不同平台上运行时不需要重新编译。Java 语言使用 Java 虚拟机屏蔽了与具体平台相关的信息,使得 Java 语言编译程序只需生成在 Java 虚拟机上运行的目标代码(字节码),就可以在多种平台上不加修改地运行。

After the introduction of Java language virtual machine, Java language does not need to be recompiled when running on different platforms. Java language uses Java virtual machine to shield the information related to the specific platform, so that the Java language compiler can run on a variety of platforms without modification only by generating the object code (bytecode) running on the Java virtual machine.

概述

summary

Java 虚拟机有自己完善的硬件架构,如处理器、堆栈等,还具有相应的指令系统。

Java virtual machine has its own perfect hardware architecture, such as processor, stack, and corresponding instruction system.

Java 虚拟机本质上就是一个程序,当它在命令行上启动的时候,就开始执行保存在某字节码文件中的指令。Java 语言的可移植性正是建立在 Java 虚拟机的基础上。任何平台只要装有针对于该平台的 Java 虚拟机,字节码文件(.class)就可以在该平台上运行。这就是“一次编译,多次运行”。

Java virtual machine is essentially a program, when it starts on the command line, it starts to execute the instructions stored in a bytecode file. The portability of Java language is based on Java virtual machine. The bytecode file (. Class) can run on any platform as long as it has a Java virtual machine for that platform. This is “compile once, run many times.”.

Java 虚拟机不仅是一种跨平台的软件,而且是一种新的网络计算平台。该平台包括许多相关的技术,如符合开放接口标准的各种 API、优化技术等。Java 技术使同一种应用可以运行在不同的平台上。Java 平台可分为两部分,即 Java 虚拟机(Java virtual machine,JVM)和 Java API 类库。

Java virtual machine is not only a cross platform software, but also a new network computing platform. The platform includes many related technologies, such as various APIs conforming to open interface standards, optimization technology, etc. Java technology enables the same application to run on different platforms. Java platform can be divided into two parts, namely Java virtual machine (JVM) and Java API class library.

体系结构

Architecture

每个 Java 程序都离不开 Java 虚拟机,Java 程序的运行依靠具体的 Java 虚拟机实例。在 Java 虚拟机规范中,分

Every Java program is inseparable from Java virtual machine, and the running of Java program depends on specific Java virtual machine instance. In the Java virtual machine specification, the

别用子系统、内存区、数据类型以及指令这几个术语来描述的。这些组成部分一起展示出一个抽象化的虚拟机内部的抽象体系结构。

Don’t use terms like subsystem, memory area, data type and instruction. Together, these components present an abstract architecture within a virtual machine.

Java 虚拟机主要分为五大模块:类装载器子系统、运行时数据区、执行引擎、本地方法接口和垃圾收集模块。其中垃圾收集模块在 Java 虚拟机规范中并没有要求 Java 虚拟机垃圾收集,但是在没有发明无限的内存之前,大多数 JVM 实现都是有垃圾收集的。而运行时数据区都会以某种形式存在于每一个 JAVA 虚拟机实例中,但是 Java 虚拟机规范对它的描述却是相当抽象。这些运行时数据结构上的细节,大多数都由具体实现的设计者决定。

Java virtual machine is mainly divided into five modules: class loader subsystem, runtime data area, execution engine, local method interface and garbage collection module. The garbage collection module does not require Java virtual machine garbage collection in the Java virtual machine specification, but before the invention of unlimited memory, most JVM implementations have garbage collection. The runtime data area exists in every instance of Java virtual machine in some form, but the description of it in Java virtual machine specification is quite abstract. Most of the details of the runtime data structure are decided by the designer of the implementation.

Java 虚拟机不是真实的物理机,它没有寄存器,所以指令集是使用 Java 栈来存储中间数据,这样做的目的就是为了保持 Java 虚拟机的指令集尽量的紧凑,同时也便于 JAVA 虚拟机在那些只有很少通用寄存器的平台上实现。另外,JAVA 虚拟机的这种基于栈的体系结构,有助于运行时某些虚拟机实现的动态编译器和即时编译器的代码优化。

Java virtual machine is not a real physical machine, it has no registers, so the instruction set uses Java stack to store intermediate data. The purpose of this is to keep the instruction set of Java virtual machine as compact as possible, and also facilitate the implementation of Java virtual machine on platforms with few general registers. In addition, the stack based architecture of Java virtual machine is helpful to code optimization of dynamic compiler and instant compiler implemented by some virtual machines at runtime.

必要性

necessity

Java 语言的一个非常重要的特点就是与平台的无关性。而使用 Java 虚拟机是实现这一特点的关键。一般的高级语言如果要在不同的平台上运行,至少需要编译成不同的目标代码。而引入 Java 语言虚拟机后,Java 语言在不同平台上运行时不需要重新编译。Java 语言使用模式 Java 虚拟机屏蔽了与具体平台相关的信息,使得 Java 语言编译程序只需生成在 Java 虚拟机上运行的目标代码(字节码),就可以在多种平台上不加修改地运行。Java 虚拟机在执行字节码时,把字节码解释成具体平台上的机器指令执行。

One of the most important characteristics of Java language is platform independence. Using java virtual machine is the key to realize this feature. If a general high-level language is to run on different platforms, it needs to be compiled into different object codes at least. After the introduction of Java language virtual machine, Java language does not need to be recompiled when running on different platforms. Java language usage pattern java virtual machine shields the information related to the specific platform, so that the Java language compiler can run on a variety of platforms without modification only by generating the object code (bytecode) running on the Java virtual machine. When Java virtual machine executes bytecode, it interprets bytecode as machine instruction execution on specific platform.

内存管理

memory management

(1)对于 Java 运行时涉及到的存储区域主要包括程序计数器、Java 虚拟机栈、本地方法栈、java 堆、方法区以及直接内存等等。对于每个部分,都有其使用的条件。程序计数器主要是取下一条指令,在 Java 里面主要是取下一条指令的字节码文件;Java 虚拟机栈主要是利用栈先进后出的特性存储局部变量表,动态链接等,主要包括堆内存和栈内存,对于程序员内存分析而言是特别重要的。本地方法栈与上边的栈基本作用差不多,只不过这里是为 Java 方法而服务。Java 堆是内存管理中最大的一块,所有的线程共享这一块内容,同时该部分也是垃圾收集器的主要区域。

(1) For Java runtime, the storage area involved mainly includes program counter, Java virtual machine stack, local method stack, Java heap, method area and direct memory, etc. For each part, there are conditions for its use. Program counter is mainly to remove an instruction, in Java, it is mainly to remove the bytecode file of an instruction; Java virtual machine stack mainly uses the stack’s first in and last out feature to store local variable table, dynamic link, etc., mainly including heap memory and stack memory, which is particularly important for programmer memory analysis. The local method stack has the same basic function as the upper stack, except that it serves Java methods. Java heap is the largest piece of memory management, which is shared by all threads. At the same time, this part is also the main area of garbage collector.

(2)虚拟机的垃圾回收机制是完善的,动态内存分配和回收是比较成熟的,在内存管理机制中,大部分都不需要我们考虑内存回收,只有 Java 堆和方法区需要我们考虑处理内存问题。一般的对于内存回收首先就是判断某一个部分是生存还是死亡,主要是通过下面二种算法:

(2) Virtual machine garbage collection mechanism is perfect, dynamic memory allocation and recycling is relatively mature, in the memory management mechanism, most do not need us to consider memory recycling, only Java heap and method area need us to consider handling memory issues. Generally, for memory recycling, the first thing is to judge whether a certain part is alive or dead, mainly through the following two algorithms:

其一是引用计数算法,本算法实现简单,判定的效率也是比较高的,很多的软件都使用了该算法,但是主流的 Java 并没有选择该算法,核心的问题是该算法难以处理对象之间相互调用的问题。

The first is the reference counting algorithm, which is simple to implement and has high efficiency. Many software use this algorithm, but the mainstream Java does not choose this algorithm. The core problem is that the algorithm is difficult to deal with the problem of calling each other between objects.

其二是称可达性分析算法,该算法核心思想是依靠判断对象是否存活来实现的,本算法是通过一系列的 GC ROOTS 的对象作为起始点,采用搜索的算法遍历引用链,如果搜索过程中没有发现该节点,则认为该节点是不可达的,即可回收的,在 Java 里面,一般可以使用该算法处理问题。

The second is called reachability analysis algorithm. The core idea of the algorithm is to judge whether the object is alive or not. This algorithm uses a series of GC roots objects as the starting point, and uses the search algorithm to traverse the reference chain. If the node is not found in the search process, it is considered that the node is not reachable and can be recycled. In Java, the In general, we can use this algorithm to deal with problems.

特性

characteristic

1、移植性

1. Portability

无论是 GC 还是 Hotspot 都可以用在任何 Java 可用的地方。比方说,JRuby 可以运行在其他平台上,Rails 应用就可以运行在 IBM 主机上的 JRuby 上,而且这台 IBM 主机运行的是 CP/CMS.实际上,由于 Java 和 OpenJDK 项目的开源,我们正在看到越来越多的平台的衍生,因此 JVM 的移植性也将越来越棒。

Both GC and hotspot can be used wherever Java is available. For example, jruby can run on other platforms, rails applications can run on jruby on IBM host, and this IBM host is running CP / CMS. In fact, due to the open source of Java and openjdk projects, we are seeing more and more platform derivatives, so the portability of JVM will be better and better.

2、成熟

2. Maturity

JVM 已有多年的历史,在过去的这些年里,许多开发者为它做出了许多贡献,使得它的性能一次又一次地提升,让 JVM 变得更加稳定、快速和广泛。

The JVM has a history of many years. In the past few years, many developers have made many contributions to it, making its performance improve again and again, making the JVM more stable, fast and extensive.

3、覆盖面

3. Coverage

JRuby 和 JVM 上的其他语言项目已经被承认,一个例子是 invokedynamic specification(akaJSR292)。JSR 越来越配合新的语言,JVM 已不再是 Java 一个人定制规则。JVM 正在构建成为类如 JRuby 等项目的优良平台。还有一个 MLVM(multiple languageVM)项目,好比是新特性的清算机构,是一个许多企业应用的开发者试图添加应用的地方,而这些应用正是他们想在 JVM 中看到的。而且 JVM 开发者互相协作、彼此影响,无疑这有利于 JVM 新特性的诞生。这些细节都可以看到 JVM 正在关注开发者的需求,扩大他的覆盖面。

Jruby and other language projects on the JVM have been recognized. An example is invokedynamic specification (aka jsr292). With JSR becoming more and more compatible with new languages, the JVM is no longer a Java one-man custom rule. The JVM is being built as a good platform for projects like jruby. There is also a mlvm (multiple language VM) project, like a clearing house for new features, where developers of many enterprise applications try to add applications, and these applications are exactly what they want to see in the JVM. Moreover, JVM developers cooperate and influence each other, which is undoubtedly conducive to the birth of new features of the JVM. These details can be seen that the JVM is paying attention to the needs of developers and expanding its coverage.


速搜资源网 , 版权所有丨如未注明 , 均为原创丨转载请注明原文链接:【速搜问答】JVM是什么
喜欢 (0)
[361009623@qq.com]
分享 (0)
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址