1

In JDI, there is a method

 Value ObjectReference.invokeMethod(ThreadReference, Method, args list, int options)

that invokes a method in the target (debuggee) VM.

But how can I call a static method? In such a case, I don't have an object reference.

TIL Java lets you call static methods on null, but this does not work here.

What would make sense is

 static Value ReferenceType.invokeStaticMethod(ThreadReference, Method, etc)

but no such thing exists, and I cannot for the life of me figure out a way to do by any other means either.

Community
  • 1
  • 1
daveagp
  • 2,599
  • 2
  • 20
  • 19

1 Answers1

3

ClassType extends ReferenceType which should give you what you want. See ClassType.invokeMethod.

DannyMo
  • 11,344
  • 4
  • 31
  • 37
  • Hey! Is there a way that I use `invokeMethod` and the thread does not resume? I have seen IDEs that allow evaluating expression and the thread does not resume. Any idea how it is implemented? – Aman Sharma Apr 09 '22 at 13:25