JVM (a): the long name you know, early home of my heart

JVM talk

JVM, a familiar and unfamiliar terms, from the understanding of Java's first day, we would have heard the name before a year or two to work, and when the interview will often asked JDK, JRE, JVM this difference between the three.

JVM can be said and we are old friends, but the scenario at work may not be as those of the framework, but at a critical time or rely on it to fix the problem, as the saying goes, know ourselves, can only know yourself, go JVM as a senior engineer a hurdle, beginning from this article, we will go step by step analysis, to explain, to overcome the mountain.

What is the JVM

The JVM ( J AVA V irtual M achine), translated into Chinese is the Java Virtual Machine, the total is well known, Java language has a very distinct characteristics, but also one of the early development of Java slogan

Write Once Run Everywhere

"Write once," I believe as a Java developer, we are not familiar with this sentence, the sentence of confidence comes from our JVM.

The principle which is that we need to write java source files are compiled into JVM bytecode files can be recognized (as a suffix to the class file), run everywhere it depends in fact implement different for different platforms virtual machine.

Java program running on the JVM, rather than run directly on the CPU.

JVM learning points

First, we need to know is, as a virtual machine, must have their own memory mechanism , so we have to understand the mechanisms of his memory, including memory structures , garbage collection, some of the content.

其次,我们需要知道,我们写的源代码被翻译成了字节码文件(因其后缀名为class,所以也会被称为类文件),对于这个文件的结构,我们必须有所了解,在知道了该类的结构下,对于一些并发多线程的知识才能做到洞若观火,知其然知其所以然。

该字节码文件在进入虚拟机到执行之前,会经历一系列的过程,我们对于这个过程的机制一般称为类加载机制,当这个类被加载到JVM中,在运行的过程中,会有一系列的指令去帮助程序到达最终的目的。

其实,上面说了那么多,都是在帮助我们对于java文件的一个执行过程发生的事情有一个更深的了解,在遇到问题时,我们可以胸有成竹,刨根问底的去解决问题,但是在日常工作中,我们不会甚至肯定不会去看我们写完的字节码文件,我们关心的是如何使用工具调优,使最低的成本发挥最高的价值,通过对JVM的调优使我们的程序的鲁棒性得到提升。

关于JVM的一个补充

虽然,JVM叫做Java Virtual Machine,但是需要注意,随着Java的发展壮大,有越来越多的语言加入到JVM生态中,比如我们耳熟能详的Groovy,Scala,Kotlin等等,他们都是依托于JVM平台的,编译产生的文件也都是后缀为class的字节码文件。

写在末尾

当亲爱的读者大人看到这篇文章的时候,说明Vi的技术博客JVM系列已经开启更新,之前的Spring Boot系列暂告一段落(后续会不定期更新),同时最开始接触写作时写的Java基础系列也会迎来一次回炉重造,敬请期待。

很庆幸能够遇到你们,谢谢你们一直以来的支持和陪伴 :)

公众号

Guess you like

Origin www.cnblogs.com/viyoung/p/11248180.html