[
https://issues.apache.org/jira/browse/NETBEANS-4962?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17469474#comment-17469474
]
Thomas Schapitz commented on NETBEANS-4962:
-------------------------------------------
What exactly do you mean with "ShutdownHooks". Are you talking about
finalizers? Please take note of the following:
[https://openjdk.java.net/jeps/421.]
Also keep in mind, that Java does finalization on a best effort basis, but in
fact, doesn't guarantee that to happen - because it can't. That is a general
problem, not just Javas. Unless there is no special precaution in your Program,
say active JMX instrumentation, or a custom shutdown port as offered e. g. by
many Servlet containers or JMeter, other Java processes appear to NB just like
any other process. The only possibility to terminate them prematurely, is the
same the OS uses - a signal. And this usually leads to immediate termination.
This is considered a security feature, because if you tell a program to
terminate using Ctrl+C, kill (unix), taskkill (windows), you don't want it to
hang around for ever doing shady things under the guise of "cleaning up" -
there is no choice other than to abandon all execution right away.
And since NB is a development tool, I'd say this is a sensible choice too,
espcially when being amidst of a debug.
Sorry, there is no remedy for that. Netbeans does use coordinated shutdown, e.
g. when issuing a "Stop" command to a running J2EE Server in the servers tab -
if this is supported by the servers integration. But supporting this in a
generic way for arbitrary processes is impossible, because there is no generic
way apart from what is supported by the OS.
So this is no Bug, and certainly not critical.
But I see, that there are use cases out there where this might be of interest.
The most generic approach I can see here, is Netbeans probing into the running
JVM using the attachment interface JConsole/VisualVM style, and offering a
method for a "soft shutdown", if it is successful. But this is still a long
shot, and would require changes in the UI. Maybe if there are enough votes or a
code contribution...
Downgraded to "Minor Improvement".
> Due to the way that NetBeans' terminates programs, ShutDownHooks are unusable.
> ------------------------------------------------------------------------------
>
> Key: NETBEANS-4962
> URL: https://issues.apache.org/jira/browse/NETBEANS-4962
> Project: NetBeans
> Issue Type: Improvement
> Environment: Windows 10
> Reporter: Sean Gray
> Priority: Minor
>
> ShutDownHooks do not work in NetBeans. They have never worked in NetBeans.
> They need to work in NetBeans.
> They do not work because the only option in NetBeans to stop a program is the
> terminate button, which (as of the most recent information I can find) calls
> Process.destroy(). The terminate button should either stop the program in a
> clean way that allows for ShutDownHooks, or there should be another option to
> stop the program that does that.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists