--- a/jdk/src/share/classes/java/io/DeleteOnExitHook.java Mon Mar 09 09:56:58 2009 -0400
+++ b/jdk/src/share/classes/java/io/DeleteOnExitHook.java Thu Mar 12 10:27:22 2009 -0700
@@ -34,17 +34,18 @@
*/
class DeleteOnExitHook {
- private static DeleteOnExitHook instance = null;
+ static {
+ sun.misc.SharedSecrets.getJavaLangAccess()
+ .registerShutdownHook(2 /* Shutdown hook invocation order */,
+ new Runnable() {
+ public void run() {
+ runHooks();
+ }
+ });
+ }
private static LinkedHashSet<String> files = new LinkedHashSet<String>();
- static DeleteOnExitHook hook() {
- if (instance == null)
- instance = new DeleteOnExitHook();
-
- return instance;
- }
-
private DeleteOnExitHook() {}
static synchronized void add(String file) {
@@ -54,7 +55,7 @@
files.add(file);
}
- void run() {
+ static void runHooks() {
LinkedHashSet<String> theFiles;
synchronized (DeleteOnExitHook.class) {