JPDA Trace access to object

B

Ben War

Hi,

is there a way to access the current object while processing a
methodEntryEvent? I am extending the trace example in
EventThread.java and cannot find a method in the API of
com.sun.jdi.Method to access the (this-) object.

Regards,
Ben
 
F

Fabian Buettner

Does this work for you?

<snip>
void methodEntryEvent(MethodEntryEvent event) {
try {
Method method = event.method();
StackFrame frame = event.thread().frame(0);
if ((!event.method().isNative()) && (!event.method().isStatic())) {
println("this: " + frame.thisObject());
}
// ...
}
</snip>
 
B

Ben War

Fabian Buettner said:
Does this work for you?

<snip>
void methodEntryEvent(MethodEntryEvent event) {
try {
Method method = event.method();
StackFrame frame = event.thread().frame(0);
if ((!event.method().isNative()) && (!event.method().isStatic())) {
println("this: " + frame.thisObject());
}
// ...
}
</snip>

Thanks for zour help. However, it does not work. For methods other
than main, thread().frameCount() results in 0.

Ben
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top