This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA/JDWP] ReferenceTypeCommandSet.java


Keith Seitz wrote:

There's also a couple places I use classes from java.lang.reflect
This is a bit of a problem as it's been pointed out if in the instance
of a command like http://java.sun.com/j2se/1.5.0/docs/guide/jpda/jdwp/jdwp-protocol.html#JDWP_ReferenceType_GetValues
Using the Field object will cause the Class to initialize which would be
changing the execution of the program. Tom Tromey suggested we could
replace the java.lang.relfect classes we use by our own classes later on
that reach into the JVM and avoid this problem.



The question is, though, is this really a problem?


In order to use ReferenceType commands, the debugger must have already
requested a reference ID for the given class. AFAICT the only way to get
a reference type ID for a class is to register for some event. Eclipse,
for example, uses class prepare events.

Anyway, the existence of a reference type ID would mean that the class
must have been loaded/initialized at some time, no?



Class preparation is distinct from initialization. Preparation is effectively linking the class: laying out its fields, initializing class data structures in the VM, etc. Initialization involves actually running Java code to initialize the classes static fields, and any "static" code blocks the class may have. The point at which initialization occurs is strictly defined by the JLS, and its pretty easy to write a program that will behave differently if initializations are not performed in the "right" order.


That means that application could be behave differently when it is debugged. So, I think ultimately we will need to address this issue. Whether it matters in practice for the majority of debug sessions, I don't know.

At the very least, as Tom suggests, we could certainly use this a first
attempt, replacing when/if necessary.



That sounds good to me.


Bryce



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]