JPDA (Java Platform Debugger architecture) is the acronym for the Java Platform Debug architecture, and with the API provided by JPDA, developers can easily and flexibly build Java debugging applications. JPDA consists of three main components: Java Virtual Machine Tool Interface (JVMTI), Java Debug Line Protocol (JDWP), and Java Debugging Interface (JDI), this series will detail the internal details of these three modules and uncover the JPDA veil for readers through examples. This is the first of the series, which will focus on the overall composition of the JPDA, explaining their intrinsic relationship to each other.
JPDA Overview
All programmers will encounter bugs, and for run-time errors, we often need methods to observe and test the environment in the run state. In Java programs, in the simplest case, have you ever tried to use SYSTEM.OUT.PRINTLN () to output various variable states in the execution of your Java program to discover problems with your Java program running? This is easy to use and can solve your problem in some simple situations, but what if your program is running in a remote environment, or the current environment does not allow console terminal output (for example, consider the virtual machine initialization) When you can't get the terminal output? Or, what if you can't modify your program locally to run it at all?
Needless to worry, you can help you solve this problem with a lot of debugging tools, and the common IDE comes with a very intuitive and simple debugging tool, such as Eclipse (Figure 1), which provides a very comprehensive, very simple debugger.
Figure 1. Debugging Java programs with Eclipse
Other common Java Ides, such as Netbeans and IntelliJ, also provide similar functionality, and you can even debug your Java program in a text command using the JDK's own jdb tool without the IDE's graphical interface. These various debuggers support local and remote program debugging, so how are they developed? What is the connection between them? We have to mention the Java debugging system--JPDA.
We know that Java programs are running on the Java Virtual machine, we have to debug the Java program, in fact, to the Java Virtual machine to request the status of the current run state, and the virtual machine issued a certain command, set some callback, etc., then the Java debugging System, is a complete set of tools and interfaces for the virtual machine to debug.
For people familiar with Java Virtual machine interfaces, you must remember that Java provides two interface systems, JVMPI (Java Virtual Machine Profiler Interface) and Jvmdi (Java VPN virtual Machine Debug Interface), and they, as well as the JVMTI (Java Virtual Machine Tool Interface) that are prepared to replace them in Java SE 5, are Java Platform Debugging systems (Java Platform Debugger Ar CHITECTURE,JPDA) is an important component. Java SE has launched the Java Platform Debug Architecture (JPDA) toolset since the 1.2.2 Edition, and the Java SDK provides direct support for the Java Platform Debug architecture from JDK 1.3.x. As the name suggests, this system provides developers with a complete set of APIs for debugging Java programs, and an interface and protocol for developing Java Debugging Tools. Essentially, it's a path to a virtual machine that examines the running state of a virtual machine, a set of tools. Understanding this is very important for learning JPDA.
In other words, by JPDA This set of interfaces, we can develop our own debugging tools. With the interfaces and protocols provided by these JPDA, the debugger developers can extend custom Java debugging applications to the needs of specific developers and develop debugging tools that attract developers. The IDE Debugging Tools we mentioned earlier are developed based on the JPDA system, except that they may provide a different graphical interface with a number of different customization features. In addition, we should note that the JPDA is a set of standards, any JDK implementation must complete this standard, so the debugging tools developed through JPDA have the advantages of cross-platform, no reliance on virtual machine implementations, JDK version-Independent, and so on, so most of the debugging tools are based on this system.
JPDA Composition Module
JPDA defines a complete and independent system, which is composed of three relatively independent levels, and defines the interaction between them, or the interfaces that they communicate. These three levels are the Java Virtual Machine tool Interface (JVMTI), the Java Debug Line Protocol (JDWP), and the Java Debugging Interface (JDI), respectively, from low to high. These three modules decompose the debugging process into several natural concepts: the debugger (debugger) and the debugger (debuggee), and the communicator in their midst. The debugger runs on top of the Java virtual machine we want to debug, it can monitor the information of the current virtual machine by JVMTI This standard interface, the debugger defines the debugging interface that the user can use, through which the user can send debug commands to the virtual machine being debugged, while the debugger accepts and displays the debug result. Between the debugger and the debugged, debug commands and debug results are transmitted through the JDWP communication protocol. All commands are encapsulated into JDWP command packs, sent to the debugger through the transport layer, and after being received by the debugger JDWP the command packet, parsing the command and converting it into a jvmti call to run on the debugger. Similarly, the JVMTI run result is formatted as a JDWP packet, sent to the debugger and returned to the JDI call. The debugger developer is using JDI to get the data and to issue instructions. Figure 2 illustrates this process:
Figure 2. JPDA module level