8006036: (process) cleanup code in java/lang/Runtime/exec/WinCommand.java
authorlancea
Mon, 08 Apr 2013 15:29:24 -0400
changeset 16741 36089fa1bbb5
parent 16740 c1b07ad4c3eb
child 16742 e6b0ac6581f1
8006036: (process) cleanup code in java/lang/Runtime/exec/WinCommand.java Reviewed-by: lancea Contributed-by: Jim Gish <jim.gish@oracle.com>
jdk/test/java/lang/Runtime/exec/WinCommand.java
--- a/jdk/test/java/lang/Runtime/exec/WinCommand.java	Fri Apr 05 18:20:12 2013 -0700
+++ b/jdk/test/java/lang/Runtime/exec/WinCommand.java	Mon Apr 08 15:29:24 2013 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 2013 Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -135,19 +135,24 @@
 
         // Win9x systems don't have a cmd.exe
         if (new File(systemDirW, "cmd.exe").exists()) {
-            out.println("Running cmd.exe tests...");
-            writeFile("cdcmd.cmd", "@echo off\r\nCD\r\n");
-            writeFile("cdbat.bat", "@echo off\r\nCD\r\n");
-            checkCD("cmd",
-                    "cmd.exe",
-                    systemDirW + "\\cmd.exe",
-                    // Only the ".exe" extension can be omitted
-                    systemDirW + "\\cmd",
-                    systemDirM + "/cmd.exe",
-                    systemDirM + "/cmd",
-                    "/" + systemDirM + "/cmd",
-                    "cdcmd.cmd", "./cdcmd.cmd", ".\\cdcmd.cmd",
-                    "cdbat.bat", "./cdbat.bat", ".\\cdbat.bat");
+            try {
+                out.println("Running cmd.exe tests...");
+                writeFile("cdcmd.cmd", "@echo off\r\nCD\r\n");
+                writeFile("cdbat.bat", "@echo off\r\nCD\r\n");
+                checkCD("cmd",
+                        "cmd.exe",
+                        systemDirW + "\\cmd.exe",
+                        // Only the ".exe" extension can be omitted
+                        systemDirW + "\\cmd",
+                        systemDirM + "/cmd.exe",
+                        systemDirM + "/cmd",
+                        "/" + systemDirM + "/cmd",
+                        "cdcmd.cmd", "./cdcmd.cmd", ".\\cdcmd.cmd",
+                        "cdbat.bat", "./cdbat.bat", ".\\cdbat.bat");
+            } finally {
+                new File("cdcmd.cmd").delete();
+                new File("cdbat.bat").delete();
+            }
         }
 
         // 16-bit apps like command.com must have a console;