深入理解Java虚拟机:JVM高级特性与最佳实践(第3版) (华章原创精品) (周志明)(Z-Library)
java
本书一共分为五个部分:走近Java、自动内存管理、虚拟机执行子系统、程序编译与代码优化、高效并发。各个部分之间基本上是互相独立的,没有必然的前后依赖关系,读者可以从任何一个感兴趣的专题开始阅读,但是每个部分各个章节间则有先后顺序。
199
Views
0
Downloads
0.00
Total Donations
AI Guide
AI Reading Assistant
Whole-book reading guide from stratified index samples; jump to passages in the text
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.
##
Passage locations
Excerpt 1
irst 收集器 3.6低延迟垃圾收集器 3.6.1 Shenandoah 收集器 3.6.2 ZGC收集器 3.7选择合适的垃圾收集器 3.7.1 Epsilon 收集器 3.7.2收集器的权衡 3.7.3虚拟机及垃圾收集器日志 3.7.4垃圾收集器参数总结 3.8实战:内存分配与回收策略 3.8.1...
View in text
Excerpt 2
线程安全所涉及的概念和分类、同步实现的方式及虚拟机的底层运作原理,并且 介绍了虚拟机实现高效并发所做的一系列锁优化措施。 ❶第3版更新:本章主体内容并没有过多变化,但对不少细节进行了修饰,对一些读者疑问较多 的地方进行了补充讲解。 参考资料 本书名为“深入理解Java虚拟机”,但要想真的深入理解虚拟机,仅凭一本书...
View in text
Excerpt 3
1997年被Sun公司收购。Hot-Spot虚拟机刚发布时是作为 JDK 1.2的附加程序提供的,后来它成为JDK 1.3及之后所有JDK版本的默认Java虚拟机。 2000年5月8日,工程代号为Kestrel (美洲红隼)的JDK 1.3发布。相对于JDK 1.2,JDK 1.3的改进 主要体现在Java类库上...
View in text
Excerpt 4
//www. infoq. cn/article/2018/02/from-j avaee-to-j akartaee。 [15] Java One大会从2019年起停办,合并入Oracle CodeOne大会中。 [16] 需要使用 +XX: +UnlockCommercialFeatures解锁的特...
View in text
Support Author
0.00
Total Amount (¥)
0
Donation Count
Please enter an amount
Minimum ¥1
You will be redirected to Alipay to complete payment, then return here.
Order created — please complete Alipay payment
{{#payUrl}} Pay with Alipay {{/payUrl}} {{^payUrl}}{{message}}
{{/payUrl}}
Donation failed:{{message}}
Log in to link the donation to your account (anonymous payment also works)
Recommended for You
{{#thumbnailUrl}}
{{/thumbnailUrl}}
{{^thumbnailUrl}}
{{/thumbnailUrl}}
Loading recommended books...
Failed to load, please try again later