United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-4809375 File.deleteOnExit() should be implemented with shutdown hooks
JDK-4809375 : File.deleteOnExit() should be implemented with shutdown hooks

Details
Type:
Enhancement
Submit Date:
2003-01-28
Status:
Resolved
Updated Date:
2005-12-03
Project Name:
JDK
Resolved Date:
2005-12-03
Component:
core-libs
OS:
linux,generic
Sub-Component:
java.io
CPU:
x86,generic
Priority:
P5
Resolution:
Fixed
Affected Versions:
1.4.0,5.0,6
Fixed Versions:

Related Reports
Duplicate:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

Description
File.deleteOnExit() uses the JVM entry point JVM_OnExit to register an at-exit
cleanup hook. It currently does not use the shutdown hooks mechanism introduced
in 1.3 because the API predates shutdown hooks. Unfortunately it turns out that
due to implementation details these two mechanisms are not orthogonal; in order
for the JVM at-exit hooks to be called, shutdown hooks need to be initialized.
Specifically, Terminator.setup() needs to be called during core libraries
startup.

A better solution which would reduce the amount of core libraries initialization
would be to reimplement File.deleteOnExit() to use shutdown hooks. This would
delay the first call to Terminator.setup() until actually required by the
application.

                                    

Comments
EVALUATION

Should be done but cannot be finished for first tiger beta.
###@###.### 2003-11-18
                                     
2003-11-18
SUGGESTED FIX

###@###.### has provided a second installation of changes for the re-implementation of deleteOnExit as a shutdown hook. I've merged his changes with the latest mustang to get this webrev:
   http://sunweb.ireland/~ab23780/4809375/webrev/index.html
The general approach seems okay  but it does need clean-up. He's deleted Terminator but we need this for platform specific setup. Also he's moved Shutdown.java which we can probably avoid too.
                                     
2005-11-02
EVALUATION

The deleteOnExit mechanism can't be implemented using the current shutdown hooks mechanism as it is today (as otherwise file deletion would execute concurrently with shutdown hooks that might access those files). However we can have a second set system-specific hooks that execute after the shutdown hooks have executed. We have community contributer with an initial implementation for this but it requires some finishing off work to complete.
                                     
2005-11-09
SUGGESTED FIX

Matthias submitted an updated contribution. Chris has polished off the changes and made them available here:
http://sunweb.ireland/~ch122065/j2se/jsn/matthias_webrev/index.html
                                     
2005-11-14



Hardware and Software, Engineered to Work Together