The mirror mechanism of JPDA architecture research 18-jdi

Source: Internet
Author: User

Introduced:

The previous article looks at the JDI protocol as a whole, which combines the implementation code of Eclipse to discuss the mirror mechanism of JDI.


Analysis:

The mirroring mechanism maps all data, types, domains, methods, events, states, and resources on the target virtual machine, as well as event requests sent by the debugger to the target virtual machine, to the Mirror object. The idea, like the O/R mapping we often call it, is to unify the things in 2 heterogeneous systems.


The Mirror interface is the primary interface defined in the JDI specification, which is located in the Com.sun.jdi package:

Public abstract Interface mirror{public abstract String toString (); Public abstract Virtualmachine Virtualmachine ();}

This interface provides only 2 methods, one is the string description that returns the image, and one is the virtual machine that gets the instance of the image.


The mirror mechanism defines a large interface hierarchy, and almost all of the interfaces defined in the COM.SUN.JDI package inherit the mirror interface directly or indirectly, thus mapping any elements, processes, events used in the large debug process.

For example, the value of the base type is mapped to Primitivevalue, the object instance is mapped to objectreference, and so on.


In Eclipse, it provides a mirror implementation class for Mirrorimpl, where the code that gets the mirrored virtual machine is the Read member Variable Fvirtualmachineimpl field, which is initialized in the constructor:

Public Mirrorimpl (String description) {this.fdescription = description;    This.fvirtualmachineimpl = ((Virtualmachineimpl) this);    PrintWriter writer = ((Virtualmachinemanagerimpl) Bootstrap.virtualmachinemanager ()). Verboseprintwriter ();  if (writer = null) This.fverbosewriter = new Verbosewriter (writer); }


The virtual machine class provides many ways to obtain all the data and state information on the target virtual machine directly or indirectly, or to suspend, resume, or terminate the target virtual machine. This way the debugger can pass a mirror, then indirectly obtain the corresponding virtual machine, and send the corresponding instructions to complete the corresponding operation.


This article is from the "cohesion of parallel Lines" blog, please be sure to keep this source http://supercharles888.blog.51cto.com/609344/1587968

JPDA Architecture Studies 18-jdi's mirror mechanism

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.