Bug 553021 - [req] Please provide "clean shutdown" option that calls all finally blocks when program is stopped
Summary: [req] Please provide "clean shutdown" option that calls all finally blocks wh...
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Debug (show other bugs)
Version: 4.14   Edit
Hardware: PC Linux
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-Debug-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-11-13 16:01 EST by Luke Hutchison CLA
Modified: 2019-11-14 22:33 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luke Hutchison CLA 2019-11-13 16:01:49 EST
When a running program is stopped in the Eclipse debugger, it would help with clean shutdown (to delete temporary files etc.) if shutdown hooks are called (Bug 38016). However, it would be even better if there were a way to initiate a "clean shutdown", where all threads were paused, then all finally blocks connected to code on the call stack executed, before shutting down.

There are conceivably issues that could arise with stopping code at an arbitrary point, and running all finally blocks connected to stack frames (so this should probably be a non-default option, and/or a separate type of stop button) -- but probably not more so than code throwing an uncaught RuntimeException at some arbitrary point. For code that has been carefully written, calling all the finally blocks would provide the cleanest exit possible.

Probably all finalizers should be run too, all Cleaner code called, and all shutdown hooks called, before shutdown -- but specifically I wanted to ask if there was a way to have the debugger interrupt running code and call all the nested finally blocks, since that seems like the bare minimum for clean shutdown.
Comment 1 Stephan Herrmann CLA 2019-11-14 17:10:02 EST
Moving to JDT/Debug, although I doubt that this is possible without bending over backwards. The debugger can't simply set the instruction counter to the desired code position -- it would probably need to re-compile all finally blocks into a synthetic method to invoke. But then: how to we establish the context of local variables for this execution. 
=> Huge efforts, for an enhancement that we are hearing of for the first time here.
Comment 2 Sarika Sinha CLA 2019-11-14 22:33:21 EST
Yes, unless JVM gives an option to invoke a method which takes care of calling the nested finally blocks.

You can open an enhancement for JDK as this will be more relevant for real time execution as compared to development time using an IDE.