diff -r c70d99150c40 -r a375b8714147 jdk/test/tools/launcher/TestHelper.java --- a/jdk/test/tools/launcher/TestHelper.java Tue Jul 19 08:21:05 2011 -0700 +++ b/jdk/test/tools/launcher/TestHelper.java Tue Jul 19 10:58:50 2011 -0700 @@ -171,15 +171,15 @@ if (jarName.exists()) { jarName.delete(); } - PrintStream ps = new PrintStream(new FileOutputStream(mainClass + ".java")); - ps.println("public class Foo {"); - if (mainDefs != null) { - for (String x : mainDefs) { - ps.println(x); + try (PrintStream ps = new PrintStream(new FileOutputStream(mainClass + ".java"))) { + ps.println("public class Foo {"); + if (mainDefs != null) { + for (String x : mainDefs) { + ps.println(x); + } } + ps.println("}"); } - ps.println("}"); - ps.close(); String compileArgs[] = { mainClass + ".java" @@ -196,12 +196,20 @@ mEntry, mainClass.getName() + ".class" }; + createJar(jarArgs); + } + + static void createJar(String... args) { sun.tools.jar.Main jarTool = new sun.tools.jar.Main(System.out, System.err, "JarCreator"); - if (!jarTool.run(jarArgs)) { - throw new RuntimeException("jar creation failed " + jarName); + if (!jarTool.run(args)) { + String message = "jar creation failed with command:"; + for (String x : args) { + message = message.concat(" " + x); + } + throw new RuntimeException(message); } - } + } static void copyFile(File src, File dst) throws IOException { Path parent = dst.toPath().getParent();