0
点赞
收藏
分享

微信扫一扫

JVM学习(一)

你带来了我的快乐 2022-04-30 阅读 71
java

一、概述

TIOBE语言热度排行榜,每个月都会更新编程语言排行榜。

 世界上没有最好的编程语言,只有最适用于具体应用场景的编程语言。

Oracle官网,找到Java Downloads,Online Documentation-->Java Language and Virtual Machine Specifications--->找到相应版本自己进行下载JVM官方规范文档。Java Language and Virtual Machine Specifications

The Java® Virtual Machine Specification

1、官方JVM简介

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.

The Java Virtual Machine specified here is compatible with the Java SE 18 platform,
and supports the Java programming language specified in The Java Language 
Specification, Java SE 18 Edition.

跨语言的平台JVM

      随着Java7的正式发布,Java虚拟机的设计者们通过JSR-292规范基本实现在Java虚拟机平台上运行非Java语言编写的程序。

      Java虚拟机根本不关心运行在其内部的程序到底是使用何种编程语言编写的,它只关心"字节码"文件。也就是说Java虚拟机拥有语言无关性,并不会单纯地与Java语言“终身绑定”,只要其他语言的编译结果满足并包含Java虚拟机的内部指令集、符号表以及其他的辅助信息,它就是一个有效的字节码文件,就能够被虚拟机所识别并装载运行。

      跨语言的平台JVM使得可以多语言混合编程成为可能或趋势。Java平台上的多语言混合编程正成为主流,通过特定领域的语言去解决特定领域的问题是当前软件开发应对日趋复杂的项目需求的一个方向。

      试想一下,在一个项目中,并行处理用Clojure语言编写,展示层使用JRuby/Rails,中间层则是Java,每个应用层都将使用不同的编程语言来完成,而且,接口对每一层的开发者都是透明的,各种语言之间的交互不存在任何困难,就像使用自己的语言的原生API一样方便,因为它们最终都运行在一个虚拟机上。

如何真正搞懂JVM?

最好的方式是自己动手编写一个。书<自己动手写Java虚拟机>

天下事有难易乎?为之,则难者亦易矣;不为,则易者亦难矣。

Java虚拟机

Java虚拟机是一台执行Java字节码的虚拟机计算机,它拥有独立的运行机制,其运行的Java字节码也未必由Java语言编译而成。

JVM平台的各种语言可以共享Java虚拟机带来的跨平台性、优秀的垃圾回收器,以及可靠的即时编译器。

Java技术的核心就是Java虚拟机(JVM,Java Virtual Machine),因为所有的Java程序都运行在Java虚拟机内部。

Java虚拟机就是二进制字节码的运行环境。

JVM是运行在操作系统之上,它与硬件没有直接的交互。

天下事有难易乎?为之,则难者亦易矣;不为,则易者亦难矣。

今天多学一份本事,明天少说一句求人的话。

勿在浮沙之上筑高台

举报

相关推荐

0 条评论