JDK-6517249 : JDWP: Cannot do an invokeMethod after a popFrames operation
  • Type: Bug
  • Component: core-svc
  • Sub-Component: debugger
  • Affected Version: 6
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-01-24
  • Updated: 2010-12-08
  • Resolved: 2007-02-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u2Fixed 7 b09Fixed
Description
Stop at a breakpoint, do a popFrames, and then an invokeMethod.
An IncompatibleThreadStateException is thrown.

The JDI spec for invokeMethod says:

  Method invocation can occur only if the specified thread
  has been suspended by an event which occurred in that thread. 
  :
  @throws IncompatibleThreadStateException if the specified thread has not
          been suspended by an event.

It seems logical to assume that if the thread is suspended by an event
which occured in that thread, and a popFrames is done, the thread should
still be considered to be suspended by an event, and so invokeMethod should
be allowed.

Comments
EVALUATION When the back-end reports an event to the front-end, the thread on which the event occurred is suspended. If an invokeMethod command is received, the back-end sets some special flags and resumes the suspended thread. The suspended thread resumes inside the event-handler which checks those special flags to see if an invoke is to be done, and if so, the event handler does the invoke instead of letting the thread resume its normal processing. When JVM Ti completes a pop operation, an internal step event is received by the back-end event handler. The event handler notices that this is a special event and does some processing to complete the pop operation. When the thread is resumed in this state, it doesn't check the special flags to see if an invoke is to be done, but just resumes normal processing. To prevent this from happening, the back-end generates an error which results in the IncompatibleThreadStateException being thrown if an invokeMethod is attempted while the thread is in this state.
24-01-2007

SUGGESTED FIX - fix the back-end event handler's handling of the completion of a pop to notice that when the thread is resumed, an invoke is to be done instead of a normal resume - fix the back-end to remember the state of invoke being allowed or not when a popFrames operation is begun, and restore that state when the popFrames finishes. See attached webrev.
24-01-2007