Understanding Android: The Java Virtual Machine ART cover

Understanding Android: The Java Virtual Machine ART

Rating 4.8
Word count
469K words
Chapters
14
Series
Understanding Android
ISBN
9787111621225

Tags

Summary

This book is the volume in the "Understanding Android" series devoted to dissecting the ART virtual machine. In 14 chapters, it takes reading real source code as its main thread and systematically explains the architecture and implementation principles of ART, Android's runtime environment. The author first equips readers with the tools, environment, and reading methods needed to read source code, then unpacks three file formats in turn—Class files, dex files, and ELF files—which are the necessary foundation for understanding the Dalvik and ART virtual machines. Next comes the key C++11 knowledge needed to read ART source code. The middle section follows the creation and startup of ArtRuntime as its main thread, connecting ART's major modules, key classes and data structures, class parsing, loading, linking, and initialization, and compilation-related principles. It then goes deep into the core stages of virtual machine operation: the dex2oat process that converts dex bytecode to machine code and the .oat and .art file formats, interpretation and JIT, exception delivery and handling, and the implementation of JNI in the native environment. Finally it focuses on Java thread execution (thread suspension and resumption, synchronized, Object wait/notify, volatile reads and writes), memory allocation and release, garbage collector implementation, and Java Reference handling. The book uses non-standard UML diagrams to show class relationships and data structures, with theoretical explanation and source code excerpts corroborating each other. It is suitable for engineers who want to understand Android system and application runtime mechanisms from the ground up.

Editor's review

讲Android的书很多,真正敢把虚拟机源码一行行摊开来讲的极少。这本书难得之处在于它给出了完整的阅读路线:先补Class、dex、ELF三种文件格式与C++11基础,再顺着ArtRuntime创建与启动的主线进入模块结构,最后落到dex2oat、解释执行与JIT、JNI、线程、内存与垃圾回收这些最难的环节。全书依据Android 10源码展开,图、文、码混排,非标准UML图让类关系与数据结构一目了然。它不是速成手册,而是一部能陪你读完源码的“导航图”——读完后再回头看应用层的卡顿、内存抖动、冷启动慢,你会知道它们究竟发生在虚拟机的哪一段。对想从应用开发走向系统底层的工程师来说,这是一条比硬啃AOSP省力得多的路径。

Who it's for

A good fit for

  • 有Java与C++基础,想弄清代码如何被虚拟机执行的中高级Android开发者
  • 从事Android系统层、性能优化或ROM工作的工程师
  • 对JVM/Dalvik/ART运行机制有研究兴趣的技术爱好者
  • 准备研读AOSP源码、需要一条入门路线的读者

Not a good fit for

  • 零基础编程入门者,书中大量源码片段与编译器概念门槛较高
  • 只想学Android界面开发或快速上手的应用初学者
  • 期望通过本书直接获得具体性能优化操作清单的实用派

Reading tips

  1. 按章节顺序读:文件格式与C++11两章不要跳过,后面几乎处处依赖。
  2. 对照Android 10源码同步阅读,把书中类名、函数名在本地代码里定位一遍。
  3. 第6至第9章为全书的难点核心,遇到编译细节可在同一章内反复回看,不必强行推进。
  4. 每读完一章用自己的话写下运行时调用链的小结,比只做标注更能巩固理解。

About the publisher

China Machine Press China · Founded in 1950

In addition to science and technology and professional publishing, the books in our catalog from China Machine Press also reflect a sustained focus on psychology, computing, management, finance and economics, and social sciences. In psychology, the catalog includes works by C. G. Jung and introductions to analytical psychology, as well as applied topics such as stress and health, and addiction and healing. In computing, it features Structure and Interpretation of Computer Programs (JavaScript Edition). Management and finance titles include Administrative Behavior (4th Edition), The Price of Inequality (Collector's Edition), and This Time Is Different: Eight Centuries of Financial Folly (Commemorative Edition). In the philosophy and history of science, there is The Worldview: The Third Edition. Relevant authors include C. G. Jung, William McGuire, Sonu Shamdasani, and Gabor Maté. Public information is limited; the above summarizes the publisher's profile based solely on the books in our catalog.

Contents

  1. Chapter 1: Must-Read for This Book
  2. Chapter 2: Class File Format
  3. Chapter 3: Dex File Format in Android
  4. Chapter 4: ELF File Format
  5. Chapter 5: C++11 Knowledge Needed to Read ART Source Code
  6. Chapter 6: Basic Knowledge of ART Virtual Machine Compilation
  7. Chapter 7: Creation of the ArtRuntime Object
  8. Chapter 8: Startup of ArtRuntime: Class Parsing, Loading, Linking, and Initialization
  9. Chapter 9: dex2oat and the .oat and .art File Formats
  10. Chapter 10: Interpretation, JIT, and Exception Handling
  11. Chapter 11: Implementation of JNI in the ART Virtual Machine
  12. Chapter 12: Java Thread Execution: Thread Suspension and Resumption, synchronized, wait/notify, volatile
  13. Chapter 13: Memory Allocation and Release
  14. Chapter 14: Garbage Collection and Java Reference Handling

FAQ

这本书需要什么前置基础?
需要一定的Java基础、C++(尤其C++11)阅读能力,以及操作系统与编译原理的基本概念。作者在第1章专门说明了工具、环境与阅读方法,但完全没有编程经验很难跟上源码分析。
这本书面向哪一版Android源码?
书中源码分析主要基于Android 10(10.0.0_r39 版本)的ART实现。读其他版本时,模块划分与整体设计依然适用,但具体类名、文件路径可能有变动。
和《深入理解Java虚拟机》有什么区别?
《深入理解Java虚拟机》以Oracle HotSpot为对象,偏重JVM规范与通用原理;本书则聚焦Android的ART,讲的是Dalvik字节码、dex2oat、AOT与JIT并存、.oat/.art文件等Android独有内容。
这本书适合当工具书查阅吗?
可以。目录按知识点切分得很细,遇到dex格式、JNI实现、垃圾回收等问题时可直接翻到对应章节;但首次阅读时仍建议按顺序通读,因为后面的分析依赖前面的文件格式基础。
书里的图解多吗?
较多。书中采用非标准UML图来展示类关系、数据结构与调用流程,配合源码片段使用,能帮助读者在不逐行读代码时也把握整体结构。

Comments

Find this book

This site is an index: you start “Search all sources” in your browser, and the entries it lists all point to third-party sites; please judge their availability yourself.

More by the same author

Top rated in the same category