# HG changeset patch # User Andrew John Hughes # Date 1350400394 -3600 # Node ID fdde7e12b1e503d84a6bab57d8a0c29cfb2b0f21 # Parent f51056fa74b07addcc14e7841f6866290a31f43d S7199153: TEST_BUG: try-with-resources syntax pushed to 6-open repo 2012-10-15 Andrew John Hughes * Makefile.am: (ICEDTEA_PATCHES): Add new patch. * NEWS: Mention S7199153. * patches/openjdk/7199153-try_with_resources_pushed_to_6.patch: Added to fix tests from previous commit. diff -r f51056fa74b0 -r fdde7e12b1e5 ChangeLog --- a/ChangeLog Mon Oct 15 19:45:41 2012 +0100 +++ b/ChangeLog Tue Oct 16 16:13:14 2012 +0100 @@ -1,3 +1,11 @@ +2012-10-15 Andrew John Hughes + + * Makefile.am: + (ICEDTEA_PATCHES): Add new patch. + * NEWS: Mention S7199153. + * patches/openjdk/7199153-try_with_resources_pushed_to_6.patch: + Added to fix tests from previous commit. + 2012-10-15 Andrew John Hughes * Makefile.am: diff -r f51056fa74b0 -r fdde7e12b1e5 Makefile.am --- a/Makefile.am Mon Oct 15 19:45:41 2012 +0100 +++ b/Makefile.am Tue Oct 16 16:13:14 2012 +0100 @@ -426,7 +426,8 @@ patches/openjdk/6979329-ccacheinput_stream_fails_to_read_ticket_cache.patch \ patches/openjdk/7110373-krb5_test_infrastructure.patch \ patches/openjdk/7175845-jar_uf_changes_file_permissions.patch \ - patches/openjdk/7177216-native2ascii_changes_file_permissions.patch + patches/openjdk/7177216-native2ascii_changes_file_permissions.patch \ + patches/openjdk/7199153-try_with_resources_pushed_to_6.patch if WITH_ALT_HSBUILD ICEDTEA_PATCHES += \ diff -r f51056fa74b0 -r fdde7e12b1e5 NEWS --- a/NEWS Mon Oct 15 19:45:41 2012 +0100 +++ b/NEWS Tue Oct 16 16:13:14 2012 +0100 @@ -39,6 +39,7 @@ - PR1194: IcedTea tries to build with /usr/lib/jvm/java-openjdk (now a 1.7 VM) by default - S7175845: "jar uf" changes file permissions unexpectedly - S7177216: native2ascii changes file permissions of input file + - S7199153: TEST_BUG: try-with-resources syntax pushed to 6-open repo New in release 1.10.9 (2012-08-31): diff -r f51056fa74b0 -r fdde7e12b1e5 patches/openjdk/7199153-try_with_resources_pushed_to_6.patch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/patches/openjdk/7199153-try_with_resources_pushed_to_6.patch Tue Oct 16 16:13:14 2012 +0100 @@ -0,0 +1,194 @@ +# HG changeset patch +# User coffeys +# Date 1348007758 -3600 +# Node ID 0abac47de6d12023982e35effe00ea028d613b5e +# Parent 5998d43cb08ce2477ad9ba7970a26ef5be1f175c +7199153: TEST_BUG: try-with-resources syntax pushed to 6-open repo +Reviewed-by: ohair + +diff --git a/test/sun/tools/native2ascii/Permission.java b/test/sun/tools/native2ascii/Permission.java +--- openjdk/jdk/test/sun/tools/native2ascii/Permission.java ++++ openjdk/jdk/test/sun/tools/native2ascii/Permission.java +@@ -21,25 +21,43 @@ + * questions. + */ + +-/** ++/* + * @test +- * @bug 7177216 ++ * @bug 7177216 7199153 + * @summary resulting file of native2ascii should have normal permission + */ + + import java.io.*; +-import java.nio.file.*; +-import java.nio.file.attribute.*; + import sun.tools.native2ascii.Main; + + public class Permission { + + private static void cleanup(String... fnames) throws Throwable { + for (String fname : fnames) { +- Files.deleteIfExists(Paths.get(fname)); ++ File f = new File(fname); ++ if (f.exists()) ++ f.delete(); + } + } + ++ private static String permission(String fname) throws Throwable { ++ Process p = Runtime.getRuntime().exec("ls -l " + fname); ++ InputStream is = null; ++ String ret = null; ++ if (p != null && (is = p.getInputStream()) != null) { ++ p.waitFor(); ++ BufferedReader br = new BufferedReader(new InputStreamReader(is, "ISO-8859-1")); ++ try { ++ ret = br.readLine(); ++ if (ret != null) ++ ret = ret.split(" ")[0]; ++ } finally { ++ br.close(); ++ } ++ } ++ return ret; ++ } ++ + public static void realMain(String[] args) throws Throwable { + if (!System.getProperty("os.name").startsWith("Windows")) { + String src = "native2ascii_permtest_src"; +@@ -47,21 +65,22 @@ + + cleanup(src, dst); + try { +- try (FileOutputStream fos = new FileOutputStream(src)) { ++ FileOutputStream fos = new FileOutputStream(src); ++ try { + fos.write('a'); fos.write('b'); fos.write('c'); ++ } finally { ++ fos.close(); + } + String[] n2aArgs = new String[] {"-encoding", "utf8", src, dst}; + if (!new Main().convert(n2aArgs)) { + fail("n2a failed."); + } +- equal(Files.getPosixFilePermissions(Paths.get(src)), +- Files.getPosixFilePermissions(Paths.get(dst))); ++ equal(permission(src), permission(dst)); + String[] a2nArgs = new String[] {"-reverse", "-encoding", "utf8", dst, src}; + if (!new Main().convert(a2nArgs)) { + fail("a2n failed."); + } +- equal(Files.getPosixFilePermissions(Paths.get(src)), +- Files.getPosixFilePermissions(Paths.get(dst))); ++ equal(permission(src), permission(dst)); + } finally { + cleanup(src, dst); + } +diff --git a/test/tools/jar/UpdateJar.java b/test/tools/jar/UpdateJar.java +--- openjdk/jdk/test/tools/jar/UpdateJar.java ++++ openjdk/jdk/test/tools/jar/UpdateJar.java +@@ -23,48 +23,76 @@ + + /** + * @test +- * @bug 7175845 ++ * @bug 7175845 7199153 + * @summary jar -uf should not change file permission + */ + + import java.io.*; +-import java.nio.file.*; +-import java.nio.file.attribute.*; +-import java.util.Set; + import sun.tools.jar.Main; + + public class UpdateJar { + +- private static void cleanup(String... fnames) throws Throwable { +- for (String fname : fnames) { +- Files.deleteIfExists(Paths.get(fname)); ++ private static void cleanup(File f) throws Throwable { ++ if (f.exists()) ++ f.delete(); ++ } ++ ++ private static String permission(String fname) throws Throwable { ++ Process p = Runtime.getRuntime().exec("ls -l " + fname); ++ InputStream is = null; ++ String ret = null; ++ if (p != null && (is = p.getInputStream()) != null) { ++ p.waitFor(); ++ BufferedReader br = new BufferedReader(new InputStreamReader(is, "ISO-8859-1")); ++ try { ++ ret = br.readLine(); ++ if (ret != null) ++ ret = ret.split(" ")[0]; ++ } finally { ++ br.close(); ++ } + } ++ return ret; + } + + public static void realMain(String[] args) throws Throwable { + if (!System.getProperty("os.name").startsWith("Windows")) { +- String jar = "testUpdateJar.jar"; +- String e0 = "testUpdateJar_entry0.txt"; +- String e1 = "testUpdateJar_entry1.txt"; +- cleanup(jar, e0, e1); ++ String jarName = "testUpdateJar.jar"; ++ String e0Name = "testUpdateJar_entry0.txt"; ++ String e1Name = "testUpdateJar_entry1.txt"; ++ ++ File jar = new File(jarName); ++ File e0 = new File(e0Name); ++ File e1 = new File(e1Name); + try { +- try (FileOutputStream fos0 = new FileOutputStream(e0); +- FileOutputStream fos1 = new FileOutputStream(e1)) { +- fos0.write(0); +- fos1.write(0); +- } +- String[] jarArgs = new String[] {"cfM0", jar, e0}; ++ cleanup(jar); ++ cleanup(e0); ++ cleanup(e1); ++ ++ FileOutputStream fos = new FileOutputStream(e0Name); ++ fos.write(0); ++ fos.close(); ++ ++ fos = new FileOutputStream(e1Name); ++ fos.write(0); ++ fos.close(); ++ ++ String[] jarArgs = new String[] {"cfM0", jarName, e0Name}; + if (!new Main(System.out, System.err, "jar").run(jarArgs)) { + fail("Could not create jar file."); + } +- Set pm = Files.getPosixFilePermissions(Paths.get(jar)); +- jarArgs = new String[] {"uf", jar, e1}; ++ String pm = permission(jarName); ++ jarArgs = new String[] {"uf", jarName, e1Name}; + if (!new Main(System.out, System.err, "jar").run(jarArgs)) { + fail("Could not create jar file."); + } +- equal(pm, Files.getPosixFilePermissions(Paths.get(jar))); ++ equal(pm, permission(jarName)); ++ + } finally { +- cleanup(jar, e0, e1); ++ cleanup(jar); ++ cleanup(e0); ++ cleanup(e1); ++ + } + } + } +@@ -84,4 +112,3 @@ + System.out.println("\nPassed = " + passed + " failed = " + failed); + if (failed > 0) throw new AssertionError("Some tests failed");} + } +-