Whole-book reading guide from stratified index samples; jump to passages in the text
Tip the Site
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat Pay
Alipay
Open WeChat or Alipay and scan. No login required.
AI guide
# 深入理解Java虚拟机:JVM高级特性与最佳实践(第3版)
## 【One-Line Pitch】
The definitive Chinese-language guide to JVM internals—covering memory management, garbage collection, class loading, compilation, and concurrency—for senior Java developers, architects, and performance tuners who need to understand what happens beneath their code.
## 【Book Arc】
- **Opening (~0%–9%)**: Introduces the Java technology ecosystem, its history, and the JVM family tree (HotSpot, JRockit, J9, Dalvik, etc.), plus a practical walkthrough of compiling your own JDK. Sets the stage for why JVM knowledge matters for production-grade applications.
- **Early (~9%–25%)**: Dives into automatic memory management—runtime data areas (heap, stack, method area, etc.), object creation and layout, OutOfMemoryError troubleshooting, garbage collection algorithms (mark-sweep, mark-copy, mark-compact), and the classic collectors from Serial to G1, plus low-latency newcomers Shenandoah and ZGC.
- **Early (~25%–34%)**: Explores the virtual machine execution subsystem—Class file structure (updated to JDK 12), the five-phase class loading process (load, verify, prepare, resolve, initialize), classloader mechanics, and the Java module system (Jigsaw) introduced in JDK 9.
- **Middle (~34%–47%)**: Covers program compilation and code optimization—syntax sugar (generics, autoboxing, conditional compilation), the Javac compiler front-end, annotation processors, JIT compilation (HotSpot's C1/C2 compilers), AOT compilation with Jaotc, and optimization techniques like method inlining, escape analysis, and the Graal compiler.
- **Late (~47%–end)**: Tackles high-efficiency concurrency—the Java Memory Model (main memory vs. working memory, volatile semantics, happens-before rules), thread implementation and scheduling, the emerging coroutine support, thread safety classifications, and lock optimization techniques (spin locks, lock elimination, lock coarsening, lightweight locks, biased locks).
## 【Key Takeaways】
- **JVM knowledge is a differentiator for production systems** (Opening): Code that works for 10 users often fails for 10,000—understanding VM internals helps you write code that the JVM can optimize effectively. This is the book's core motivation.
- **Memory management is the first frontier** (Early): The runtime data areas (program counter, VM stack, native method stack, heap, method area, constant pool, direct memory) form the foundation. Knowing where objects live and how they're accessed is prerequisite to diagnosing OutOfMemoryError.
- **GC is a spectrum of trade-offs** (Early): From Serial's simplicity to G1's region-based collection to ZGC/Shenandoah's sub-millisecond pause targets, each collector balances throughput, latency, and footprint. The book explains the algorithms (mark-sweep, mark-copy, mark-compact) and the HotSpot implementation details (safe points, card tables, write barriers).
- **Class files are the contract between language and VM** (Early): The Class file structure (updated through JDK 12) is tedious but unavoidable—it's the foundation for understanding class loading, bytecode execution, and dynamic language support. New attributes for modules (JDK 9) and nest-based access control (JDK 11) reflect evolving language features.
- **Compilation is a two-stage pipeline** (Middle): Java source → bytecode (front-end, Javac) → native code (back-end, JIT/AOT). Understanding syntax sugar like generics (implemented via type erasure) and autoboxing reveals why certain code patterns perform better than they appear.
- **JIT optimization is where performance lives** (Middle): HotSpot's hotspot detection, tiered compilation, and techniques like method inlining and escape analysis can dramatically improve runtime performance. The Graal compiler and JVMCI interface represent the future of JVM compilation.
- **The Java Memory Model defines concurrency semantics** (Late): The happens-before relationship, volatile guarantees, and atomicity/visibility/ordering rules are the backbone of correct concurrent programming. Understanding these prevents subtle race conditions that are nearly impossible to debug empirically.
- **Lock optimization is a VM-level art** (Late): Modern JVMs employ biased locks, lightweight locks, spin locks, and lock coarsening to reduce synchronization overhead—meaning the cost of `synchronized` is far lower than most developers assume.
## 【Reading Tips】
- **Part independence is real**: The five parts (Java overview, memory management, execution subsystem, compilation, concurrency) are designed to be read in any order. If you're a working developer, start with Part 2 (memory) or Part 5 (concurrency)—they have the most immediate practical payoff.
- **Chapter 3 (GC) deserves deep reading**: It's the longest and most technical chapter, covering everything from basic algorithms to cutting-edge collectors. Skim the historical collectors (Serial, ParNew) if you're on modern JDKs, but read G1, ZGC, and Shenandoah carefully—they're what you'll actually encounter.
- **Chapter 6 (Class files) is reference material**: The author admits this chapter reads like a technical manual. Don't read it cover-to-cover; use it as a reference when you need to understand a specific attribute or constant pool entry.
- **Follow the practical exercises**: The book includes hands-on projects—compiling your own JDK, triggering OutOfMemoryError scenarios, building an annotation processor, and analyzing JIT compilation output. These cement the theory and are worth the time investment.
- **Watch for version-specific notes**: The 3rd edition is written from a mid-2019 perspective (JDK 13 era). The author explicitly flags version differences, so pay attention to these callouts—they explain why some features exist only in certain JDK releases.
## 【Coverage Limits】
This guide covers the book's structure, key themes, and practical reading strategies based on the table of contents, preface, and introductory material. Detailed technical content from the middle chapters (GC algorithms, class loading internals, JIT optimization specifics) is summarized at a high level—the excerpts do not include the full depth of those chapters.
##
Support this siteYour recognition and a small knowledge-service contribution help keep this technical work open source.
Scan the WeChat Pay or Alipay code below. Logged-in and guest visitors can both tip.
WeChat PayAlipay
Open WeChat or Alipay and scan. No login required.
Loading comments...
Reply to Comment
Edit Comment