foreword
Java is currently the software development technology with the most users and the widest range of applications. The technical system of Java is mainly composed of a virtual machine that supports the running of Java programs, a Java class library that provides interface support for various development fields, Java programming language and many third-party applications. E-side Java framework (such as Spring, MyBatis, etc.). In China, there are abundant technical materials and books about Java class library API, Java language grammar and third-party frameworks. In contrast, the data about Java virtual machine is extremely poor.
With the continuous development of Java technology, it has been applied in more and more fields. Some of these fields, such as the Internet, energy, finance, communications, etc., have extremely high requirements for program performance, stability, and scalability. A program may be perfectly fine when used by 10 people at the same time, but will slow down, deadlock or even crash when used by 10,000 people at the same time. There is no doubt that higher-performance physical hardware is needed to satisfy 10,000 people's simultaneous use, but in most cases, improving hardware performance cannot increase the running performance and concurrency of the program proportionally, and may even have no effect on the running status of the program. any improvement. There is a reason for the Java virtual machine: in order to achieve the goal of "providing a consistent virtual platform for all hardware", some hardware-related performance characteristics are sacrificed. More importantly, it is a human reason: if developers do not understand the operating principles of many technical features of the virtual machine, they cannot write code that is most suitable for virtual machine operation and self-optimization.
Let's walk into the world of virtual machines together!
1. Walking into Java
There is no perfect program in the world, but we are not depressed because writing a program is a process of constant pursuit of perfection.
1.1 Overview
1.2 Java technology system
1.3 History of Java Development
1.4 Java virtual machine family
1.5 Looking forward to the future of Java technology
1.6 Combat: Compile JDK by yourself
1.7 Chapter Summary
2. Automatic memory management
Between Java and C++, there is a high wall surrounded by dynamic memory allocation and garbage collection technology. People outside the wall want to get in, but people inside the wall want to come out.
Chapter 2 Java memory area and memory overflow exception
2.1 Overview
2.2 Runtime data area
2.3 Exploration of HotSpot virtual machine objects
2. 4 Actual Combat: 0utOfMem oryErr or exception
2.5 Summary of this chapter
Chapter 3 The Garbage Collector and Memory Allocation Strategies
3.1 Overview
3.2 Subject is dead?
3.3 Garbage Collection Algorithm
3.4 Implementation of the Algorithm Details of HotSpot
3.5 Classic Garbage Collector
3.6 Low Latency Garbage Collector
3.7 Choosing the Right Garbage Collector
3.8 Actual Combat: Memory Allocation and Recovery Strategy
3.9 Summary
Chapter 4 Virtual Machine Performance Monitoring and Troubleshooting Tools
4.1 Overview
4.2 Basic Troubleshooting Tools
4.3 Visual troubleshooting tools
4.4 HotSpot virtual machine plug-ins and tools
4.5 Summary of this chapter
Chapter 5 Tuning Case Analysis and Practice
5.1 Overview
5.2 Case Analysis
5.3 Actual Combat: Eclipse Running Speed Tuning
5.4 Chapter Summary
3. Virtual Machine Execution Subsystem
The result of code compilation is converted from local machine code to bytecode, which is a small step in the development of storage formats, but a big step in the development of programming languages.
Chapter 6: Class File Structure
6.1 Overview
6.2 The cornerstone of irrelevance
6.3 Structure of Class class file
6.4 Introduction to Bytecode Instructions
6.5 Public Design, Private Implementation
6.6 Development of Class file structure
6.7 Chapter Summary
Chapter 7: Virtual Machine Class Loading Mechanism
7.1 Overview
7.2 Timing of class loading
7.3 The process of class loading
7.4 Class loaders
7.5 The Java Modular System
7.6 Chapter Summary
Chapter 8: Virtual Machine Bytecode Execution Engine
8.1 Overview
8.2 Runtime stack frame structure
8.3 Method calls
8.4 Dynamically typed language support
8.5 Stack-based bytecode interpretation and execution engine
8.6 Chapter Summary
Chapter 9: Cases and Practices of Class Loading and Execution Subsystems
9.1 Overview
9.2 Case Analysis
9.3 Actual Combat: Realize the Remote Execution Function by Doing It Yourself
9.4 Chapter Summary
4. Program compilation and code optimization
From the first day when computer programs appeared, the pursuit of efficiency has been a natural and firm belief of programmers. This process is like a never-ending, never-ending Formula 1 race. The programmer is the driver, and the technology platform is on the track. Speeding racing car.
Chapter 10: Front-End Compilation and Optimization
10.1 Overview
10.2 Javac Compiler
10.3 A taste of Java syntactic sugar
10.4 Practical combat: plug-in annotation processor
10.5 Chapter Summary
Chapter 11: Backend Compilation and Optimization
11.1 Overview
11.2 Just-in-time compiler
11.3 Ahead of time compilers
11.4 Compiler Optimization Techniques
11.5 Actual Combat: In-depth understanding of Graal compiler
11.6 Chapter Summary
5. Efficient Concurrency
Chapter 12: The Java Memory Model and Threads
The wide application of concurrent processing is the fundamental reason why Amdah's law has replaced Moore's law as the source of computer performance development, and it is also the most powerful weapon for human beings to squeeze computer computing power.
12.1 Overview
12.2 Efficiency and Consistency of Hardware
12.3 The Java Memory Model
12.4 Java and threads
12.5 Java and Coroutines
12.6 Chapter Summary
Chapter 13: Thread Safety and Lock Optimization
We understand the structure and operation of the virtual machine Java memory model, and explain the embodiment of atomicity, visibility, and order in the Java memory model, and introduce the rules and usage of the principle of occurrence first. In addition, we also learned how threads are implemented in the Java language and how the new concurrency model that represents the future of multithreading in Java works.
Regarding the topic of "efficient concurrency", this chapter mainly introduces how the virtual machine achieves "concurrency". What kind of optimization methods are provided.
13.1 Overview
13.2 Thread safety
13.3 Lock Optimization
13.4 Chapter Summary