This is why’s 47th original article. This article mainly compares the content of “Deep Understanding Java Virtual Machine” 2nd edition and 3rd edition with more than 9000 words. It is for you to decide whether it is worth buying. Plus five little eggs I found about the book.

Drought cavity be out of tune


Hello, I’m Why. As usual, it’s a short, rambling talk about life.

The picture above was taken a few days ago. That night after work, I saw the meniscus and a very bright star next to it as I walked into the community.

I don’t know why, but all of a sudden, I felt like I was back in summer when I was a kid.

Some pictures came to my mind: a big iron spoon to scoop a spoonful of cool water from the well, a watermelon cooled by the water tank, an old man selling cherries under the shade of a tree, a companion by the river laughing and catching crabs, myself on the way to school with a cup of cold white tea, and neighbors cooling off in the attic in the evening.

When I was young, I grew up in tongzilou, a seven-story building with about 10 families on each floor.

At that time no one had a refrigerator at home, but every family had a large water tank. Summer, buy a watermelon to come back, after flushing, throw in the big water tank inside, eat at night, don’t say more exciting.

There’s no fridge, let alone air conditioning. So when it’s hot in summer, just relying on a ceiling fan can’t bring the slightest coolness. Everyone would take MATS, pillows, blankets and fans to the attic for a night’s sleep.

Most of the upstairs and downstairs neighbors knew each other well, and they walked around on the top floor, chatting on MATS.

I especially like to sleep in the attic, where I can see a lot of stars and hear the rustling of insects.

Sleep when grandpa will tell me a story, see the meteor across the remember to make a wish is grandpa told me. He also told me that when a person is born into the world, a lamp lights up in the sky. These are the stars we see. If the person were to leave the world, his star would fall, and this would be a meteor.

When I look back on it now, I smile. I love summer when I was a kid.

All right, back to the article.

Say first conclusion

Since The release of Understanding the Java Virtual Machine (Version 3), I’ve seen a lot of people asking the same question: Is Version 3 worth buying?

I have read both the second and third editions, so the text answers this question from my personal Angle.

In-depth Understanding of the Java Virtual Machine (version 3), which I bought at the end of December 19. So far, it’s pretty much finished.

Now I’m finally qualified to answer questions like:


You can also do this by saying:


First, the conclusion: personally, it is necessary.

As far as I can tell, there are three categories (assuming you want to read the book).

1. Never read the second edition. This situation is very simple, directly buy the third edition to read the line. Nothing to say.

2. Bought the second edition but didn’t flip through it many times or even open it. In this case, I suggest you simply save the second edition and buy a third edition. Do not hesitate to “waste” time on the second edition before reading it several times. Because the third edition of the content is included in the second edition, and the second edition of the supplement, equivalent to the second edition +. So, in terms of time gain, it makes sense to go straight to version 3.

3. Bought and read the second edition. My advice is to read the second edition, be sure to read the third edition, you will know that the author of this book to the third edition, is not to circle money, is really dry goods, is really to update the knowledge. This is an attitude of reverence for technology, self-awareness and responsibility for readers.

The first edition of this book, published in 2011, filled a gap in the Domestic JVM.

The second edition, released in 2013, arguably helped drive the popularity of the JVM in China.

In my opinion, the third edition released in 2019 is more a reflection of the rapid updating of technology, reminding us that if we do not learn today, we will become garbage tomorrow.


Let me put it this way: without this book, there wouldn’t be so many interview questions for the JVM. But without it, you’re missing a very important link in your technological chain.

At the same time, as stated in the introduction to the book, a programmer who understands the necessary Java class library apis, Java syntax, and appropriate third-party development frameworks is generally satisfied with the needs of daily development.

In other words, if you don’t want to be an average programmer, you should read the book.

You carefully taste, you want to interview questions, or want to be a common programmer, or want to perfect the degree of technology?

The third edition I’ve been looking forward to:


To be honest, I didn’t know what it was until the third edition came out. It was the second release that opened the door to the JVM and taught me a lot about hardcore, internal mechanics, and I’m going to support the third release anyway.

Now, version 3 doesn’t disappoint me, and it deserves my support.

Next, I will stand on my own point of view and give you a detailed comparison of the differences between the second edition and the third edition.

Third edition VS second edition

First, a visual comparison:


As you can see above, the third edition is noticeably thicker than the second edition. What are the exact dimensions?

I measured it for everyone. The second edition is two centimeters thick and the third edition is 2.7 centimeters thick, which is seven millimeters longer than the second edition.

The second edition is 433 pages, and the third edition is 521 pages, 88 pages more.

That’s 88 pages too many. Do you know what that means?

That means nearly 100,000 more words for the JVM interview question pool.


Look again at the words on the cover:


The cover of the second edition reads: Based on the latest JDK 1.7.

The second edition was written by Mr. Zhou Zhiming between 2011 and 2012 and was officially published in September 2013. At the time, the latest version of the JDK was 1.7.

The third edition is due out at the end of 2019, and the cover says it will be fully updated with the new JDK version.

At the time, the latest version of the JDK was version 13.

As I write this, it’s May 2020. Oracle released JDK 14 on March 17, 2020.

Between 2011 and 2020, that’s almost 10 years.

First, the naming rules for JDK versions have changed. After the release of JDK 10 in March 2018, the development version of the JDK deprecated the previous 1.x naming convention.

As a result, we slowly changed from JDK 1.7 to JDK 7.

Second, although Oracle acquired Sun in April 2009, Oracle officially owns the Java trademark.

But in my mind, when I was in college, I thought more about Sun when I talked about Java. Now, when IT comes to Java, my first reaction is to switch from Sun to Oracle.

During that time, the name changed, the version number doubled from 7 to 14. Even the companies they belong to have changed.

Really, white cloud dog, for the world.

All right, let’s get back to the book.

Both editions of the book are divided into five major sections:

1. Into the Java

2. Automatic memory management

3. Vm execution subsystem

4. Program compilation and code optimization

5. Efficient concurrency

So, what I’m going to talk about in the next part is basically following these five parts to talk about what was added to the third edition of the second edition of these five parts.

1. Into the Java

This section focuses on the history of Java technology.

As I said earlier, in the nearly 10 years between release 2 and release 3, a lot of big things have happened in Java, including some that the public would love to hear.

For example, In 2018, Google paid Oracle $8.8 billion in damages for Android’s infringement of Java.

Google is bitter. Kotlin replaced Java as Google’s official Tier 1 Development language for Android in 2017. Fuchsia, which will replace Android, has nothing to do with Java.

$8.8 billion. That’s tough.


Another thing to eat is the release of JDK 11 on September 25, 2018. Meanwhile, there’s a big rumor: Java is going to start charging!

One stone stirred up thousands of waves, a rumor excited countless title party.

Major science and technology “we media” rushed into the battlefield with a keyboard, and various articles flooded in.


Maybe we were all uncertain people, but two years have passed, and I don’t need to say the result, because time gives you the answer.

The two things mentioned above are what I read in the third edition of the book, which is not in the second edition.

This is an illustration of the timeline of the development of Java technology in the second edition. In fact, it was only written on July 28, 2011, and the following content is the outlook:


Here’s an illustration from the third edition:


There is also a section on the future of Java technology.

In the second edition, the author stands in 2011 envisioning modular, mixed-language, multi-core parallel, rich syntax, 64-bit virtual machines…… These things have arrived as promised.

In the third edition, the authors envision this:


It can be said that we are standing at the time node of 2020, looking forward 10 years, the future of Java can be expected, and our future is also certain to be white clouds and dark dogs, changing the world.

But for the better or for the less desirable…… This one is hard to say.


Hahaha, ok, next part.

2. Automatic memory management

This section is arguably the most important and JVM part of the book.

I still remember the first sentence I saw when I first read this part of the book:


People outside the wall want to get in, people inside the wall want to get out.

After I read, belongs to the wall in a face meng forced people, do not know is should go in or should come out.

This is the part where I take notes and underline the most. Basically, I feel that every sentence is the test point, so when I look at it, there are many situations like the following, one page is full of underlined lines, because I feel that all the interview questions are:


This part is the most important part of the book, so Mr. Zhou Zhiming also in the third edition of this part of the effort.

This part is divided into chapters 2 to 5. They’re all important, so let’s go through them chapter by chapter.

First of all, chapter 2 “Java memory region and memory overflow exceptions”, the first is king fried, I give you a picture you understand:


How many interview questions have you asked about your doubts about life?

And this section is mostly written around these areas, so it’s very important.

The third edition is more detailed than the second edition, such as the following two versions of the description of the Java heap (3rd edition on the left, 2nd edition on the right, I took, can click open to see the larger picture) :

You can see that in the second edition, where I’ve framed it and marked it with a black line, in the third edition, there’s quite a long addendum to these nouns and the division of regions, which is really quite rigorous.


The descriptions of other areas have not changed much, so it is not clear.

However, there is one change that must be noted, and that is that the concept of permanent generation is no longer in JDK 8. Instead, it is called meta space.

As a result, the following was added in version 3 to simulate overflow situations in the method area:


Next, let’s look at Chapter 3, Garbage Collector and Memory allocation Strategies:

This part, I don’t know, it’s like, wow, the most, the most, the most.


When I looked at the G1 collector in the second edition, I didn’t make much sense of it. After reading this, I just missed the G1 memory “whole” idea, feeling and the previous introduction of several garbage collector has a significant difference.

Then there are the undecipherable memory sets, card tables, writing barriers — terms that feel important.

This is understandable; when Mr. Chou wrote the second version, JDK 7 had just been released, and the G1 collector was still in the laboratory stage, with no actual production environment data to support it. So a lot of things are written vaguely.

In the third edition, I read and compared this part of the content, can be said to be completely rewritten this part.

In JDK 11 and JDK 12, ZGC and Shenandoah, two new low-latency, fully concurrent collectors, are explained in detail.

It also gives a brief introduction to Epsilon, the “unconventional” garbage collector that does not collect garbage.

Shenandoah and Epsilon I won’t talk about. ZGC is likely to be the next high frequency interview question, as this is officially where the garbage collector is headed in the future.

I won’t elaborate on it here, but it’s worth learning.

In addition to the garbage collector part for G1 content rewrite, added ZGC, Shenandoah, Epsilon content.

This chapter also adds theoretical knowledge about memory sets and card tables (for cross-generation references), tricolor tagging (for concurrent tagging), incremental updates and raw snapshots (for concurrent tagging), and write barriers (how incremental updates and raw snapshots are implemented).

With this theoretical knowledge, it is easier to understand the design of HotSpot. These are not available in the second edition.

Ok, take a look at the table of contents for the two editions of Chapter 3 (3rd edition on the left, 2nd edition on the right) :


The third page on the left that I’ve circled in red are new additions.

Chapter 4 VM Performance Monitoring and Troubleshooting Tool. This section is the most useful.

Both versions introduce six command-line tools that come with the JDK:

JPS: tool for vm process status.

Jstat: monitors vm statistics.

Jinfo: Java configuration information tool.

Jmap: Java memory mapping tool.

Jhat: vm heap dump snapshot analysis tool.

Jstack: Java stack tracing tool.

The main difference between the third and second releases in this section is the introduction of JDK visualization tools.

In addition to JConsole and VisualVM, JHSDB debugging tools added in JDK 9 are also introduced in the third version:


Java Mission Control is an online monitoring tool with a cool interface:


The report it generates contains the following types of information:


HSDIS: JIT generated code disassembly is then introduced.

This tool is very useful, and I used it when analyzing code in previous articles. It can output assembly language with a few startup parameters.

With JITWatch tool, it has a magic effect. You can see the Java source code, bytecode, and assembly code generated by just-in-time compilation directly, which looks something like this:


It’s similar to how ordinary people look at code and see the surface. Looking at the code with this tool, you can see the quirks of the program.

Chapter 5 tuning case analysis and actual combat.

Several case analysis in this section, is the need to carefully read, can learn a lot from others’ actual combat, after the content of the front, you will say: harm, this ah, learning.


Finally, the Eclipse speed tuning, I have a very deep memory, because when I first read here on my computer some actual combat, is indeed some effect.

3. Vm execution subsystem

This part, first of all, tells the structure of the class file, countless heroes are in this place to be persuaded to retire.

I remember 0xCAFEBABE the first time I saw it.

The collection of field tables, method tables, property tables, and various bytecodes are all forgotten immediately after the book is closed.

But then I realized, this part of the content, you don’t have to remember so well. As long as you know that there is such a thing, and then when you encounter this knowledge point of time know to turn over a book here, it is ok.

In other words, this place can be looked at as a reference book.

After explaining the class file structure, I entered the virtual machine class loading mechanism. I believe that millions of people are introduced to the “parent delegation model” from here.

In this section, the third release mainly introduces the modular system introduction of JDK 9.

Due to the introduction of the Java modular system, the classloading part has had a huge impact.

If the parent delegate pattern has been broken three times before, they are:

The first time was due to the historical legacy of the schema, which was introduced after JDK 1.2.

The second is a defect in the model itself that causes the SPI interface to fail to be loaded.

The third was to pursue Hot Swap.

Modularity in JDK 9, then, is the fourth break in the parental delegate pattern.

Can give you a comparison:


You can taste it yourself first. For details, go to the book.

4. Program compilation and code optimization

This section rewrites the section of generics in the third edition, describes the method of generics implementation in Java and C#, and introduces the historical background of the emergence of generics. Of course, there’s also type erasure, which you can’t talk about without generics.

Grammatical sugar is also a word I learned in this chapter of the book.

All Java object instances are allocated memory in the heap, right?

There are also answers in this chapter:


But in particular, note the footnote:


In fact, if you go back to the introduction of Java heap in the book:


** Where I take notes, the book says “almost”, “not so absolutely”. You knew there was something wrong with this. **

Then in Chapter 11 of this section, the name changed from late (runtime) optimization to back-end compilation and optimization. (second page left, third page right)


At the same time, you can see that in version 3, there is a new section devoted to precompilation, which analyzes the pros and cons of precompilation.

The third edition also includes an in-depth look at Graal.

I’ve used this tool before when I was preparing for an article. In the words of the author, I cannot help feeling that the emergence of Graal compiler is of inestimable value to the study and research of virtual machine code compilation technology.

5. Efficient concurrency

This section focuses on the Java Memory Model (JMM) and threads and thread safety and lock optimization.

I won’t talk too much about this part because it hasn’t changed much, but I don’t think it’s relevant to the JVM anymore, it’s just an extension.

If you want to learn more about the techniques of multithreaded programming, read other books that specifically describe multithreaded programming.

In this section, version 3 introduces more about Java’s future concurrency model based on coroutines.

Supporting coroutines in Java should be very difficult. For example a simple: coroutines encountered traditional thread synchronization measures should be handled?

It is difficult to solve such a thorny problem.

But Java’s solution is fibers. What is specific I will not say, interested to turn over the book.

In fact, I don’t think it matters that much, because in my short career as a programmer, I don’t think I will ever deal with fiber. Belongs to the lifetime series.

What if you knew?

Well, congratulations, my friend, on learning another point of knowledge that you almost never needed.


Ok, above, I have analyzed the new content of the third edition from five parts.

Next, I’ll give you five eggs I found in the book.

Five eggs

Of course, these five eggs are for me, from my personal point of view, I am an egg, everyone’s opinion is different.

Just to be clear, my second edition was printed 13 times in May 2016. The third edition was printed for the first time in January 2020. The printed version is different, there may be subtle differences.

Eggs in a


At the beginning of the book.

The second edition says: Today, the Java technology system has attracted more than 9 million software developers, the largest software development team in the world.

The third edition says: Today, the Java technology system has attracted more than 6 million software developers, the largest software development team in the world.

The second edition was written in 2011 and the third in 2019, leaving more than 3 million fewer workers in just eight years.

The author says his data comes from a Java AD. I don’t know if the change in the statistical dimension is the reason for the 3-million-plus difference, or if there are just so many people missing.

Eggs in two

Section 2.4.3 (Method area and runtime Constant pool overflow) :


The egg is hidden in the footnotes of the third edition. For this, I also wrote a special article, interested can go to read.

The hole dug by Deep Understanding the Java Virtual Machine (2ND edition) was finally filled in by R in 3rd edition

Three eggs

In chapter 3, Garbage Collector and Memory Allocation Strategies, a description differs between the second and third editions (second above, third below) :


Obviously, the description of Full GC in the second edition above is incorrect.

But it just so happens that in one of my interviews, one of the interviewees said “Full GC” means “old GC”, which means “Full promise”. He said he read it in a book.

I went back and looked at the book and found that this was true, unfortunately there was something wrong with this place and it was redescribed in the third edition. Full GC must be a whole heap collection, my friends.

I used this Easter egg to answer some of the questions I was asked in my post.


Four eggs

In the fifth part, about the description of thread states, there was a clerical error in the second edition, which changed the 6 states into 5 states, and it was fixed in the third edition (in the picture below, the top is the second edition, and the bottom is the third edition) :


But I found that there was a problem with the state picture in the 3rd edition (3rd edition on the left, 2nd edition on the right) :


There is no problem with the state diagrams in the second version. In the third version, there are double arrows between New and Running and Running to Terminated.

Eggs out of five

The third edition, page 312, has this example code for dynamic dispatch:


Obviously, the author wanted to write Guy. He shook his hand and typed it gay. It’s not a problem. It’s just a little weird.


A little egg from a clerical error.

My story with the JVM

Then, share my story with the JVM.

It is no exaggeration to say that WHEN I graduated I knew nothing about the JVM. I’ve only heard the word before.

In my junior year, I worked as an intern for one year, wrote CRUD (add, delete, change and check) for one year, and did two outsourced government projects. In fact, all requirements are not complicated and can be realized through the combination of add, delete, change and check interfaces.

So a year later, I felt like it wasn’t that hard to be a programmer, CRUD wrote a book that was perfect. To the point where I felt I could go to Beijing with my CRUD skills.

Fortunately, the JVM interview question didn’t seem to be particularly popular in 2016, at least for a recent graduate, so I interviewed several companies without asking a single JVMS question.

Later, I entered a company smoothly. Two months after joining the company, it was the 7-day National Day.

I bought this book before National Day. National Day seven days did not go out, the second version of the finished again.

Gnaw is extremely difficult, can be said to be swallowed. A lot of things are completely rote learning, opening the book, knowing everything. Closing the book: What was that again?

I’m sure many of my friends had similar feelings when they first read the book. Now looking back is very normal, all said is the internal skill mind method, only less than a year of work experience is difficult to practice this kind of excellent martial arts.

Only with the increase of work experience and repeated reading of what I did not understand, I finally became ignorant and felt that I had absorbed a little and could cope with the interview.

Wait until after reading through several times. You’ll find that even if you read it a hundred times, you won’t see it for yourself. It just gets you through the door to the JVM.

Of course, I’m not saying the book is bad, but the JVM is inherently a difficult subject. It’s not something you can read a book or two and figure out, it’s just a character that takes you through.

The world inside that door, to me, is bottomless.

For example, I’ve written several articles about the JVM, and a reader has asked me a question that extends from the article. I don’t know:


When I was writing, I came into contact with this part of the knowledge, but when I looked through the relevant materials, I found that it was extremely complicated, so I did not go into further research.

My point with this example is that the JVM is endlessly learning, and of course you can get by by memorizing a few interview questions. But don’t you really want to know more? The book of martial arts is right in front of you. Don’t you want to read it?

In fact, I’ve been seeing articles about “new” JVMS every year for four years since I started. These “new” JVM articles are filled with old wine.

I’m not saying it’s bad. This is no problem, every year’s “new” article is summed up by others after they read the relevant knowledge, and shared, and we can also see the new, so it is a win-win situation.

It’s just, why don’t we just go to the source. The source is nothing more than a few books, including the article said this.

Finally, I’d like to share a small change in my reading of the book:

When I first read this book in 2016, I didn’t understand it, but I thought it was the Bible.

Now in 2020, I have some work experience. After reading this book for several times and derivating other knowledge points, I found that this book is just an introductory level of popular science.

No disrespect, but the JVM is really a deep science. And any broad and profound knowledge is impossible for you to read a book or two can master, can only be said to be the entry.

And don’t ever try to absorb the book in a single reading. Honestly, you’ll be good enough to read it in its entirety.

When you look into an abyss, the abyss looks into you. As you learn the JVM, the JVM is pulling you “deeper and deeper.”

All in all, I recommend buying it.

One last word

This article feels like the soft text of this book, but it doesn’t matter. I am the tap water of this book, from which I learn and gain a lot. Overall, this is a book that deserves to be known by more people.

Oh, right. Mr. Zhou Zhiming, the author of “In-depth Understanding of Java Virtual Machine”, also saw this article and praised it after it was first published on a platform.

Oh my God! My highlight moment, this is a great encouragement!



Give me a thumbs up, zhou is more tired, don’t fuck me, need some positive feedback.

If you find something wrong, please leave a message and point it out to me so that I can modify it. (I have this quote in every technical article, and I mean it.)

Thank you for reading, I insist on original, very welcome and thank you for your attention.

I am Why, a programmer who has only written a few articles. I am not a big shot, but I like to share. I am a nice sichuan man who is warm and interesting.

Welcome to pay attention to the public account [WHY Technology], adhere to the output of original. Share technology, taste life, wish you and I progress together.