Duplicate :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
|
Relates :
|
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.
|