JDK-6920451 : File.deleteOnExit should make it clear that Runtime.halt does not require deletions to be attempted
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 6u14
  • Priority: P4
  • Status: Resolved
  • Resolution: Not an Issue
  • OS: windows_xp
  • CPU: x86
  • Submitted: 2010-01-27
  • Updated: 2017-09-14
  • Resolved: 2014-12-03
Related Reports
Relates :  
Description
When a program registered files/folders by File#deleteOnExit() and then launch Runtime#halt().

REPRODUCE:

1) Compile the attached J800003.java and Tester.java
2) Invoke 
    java J800003 3

RESULT:
 In jdk5u20, only folders02 remains and other files and folders are deleted.
 On the other habd, in jdk6u14, all the created files remain.

Comments
EVALUATION The deleteOnExit method clearly specifies that deletion will only be attempted for normal termination of the VM. As the test is invoking Runtime#halt to forcibly terminate the VM then there should be no expectation that the deletion will be attempted. The halt method already makes it clear that invoking the method does not cause shutdown hooks and finalizers to be executed. We should add to this to make it clear that the method is not required to attempt deletion of files that are registered for delete. The reason for the behavior change in jdk6 is that the deleteOnExit mechanism was re-implemented as a special type of shutdown hook that runs after the user-registered shutdown hooks have completed. In jdk5 and older releases the mechanism was implemented as an onexit hook and these hooks were run when the VM was halted.
16-02-2010