changeset 4978:7dbc129d8e5c

7127906: (launcher) convert the launcher regression tests to java Reviewed-by: darcy, naoto
author ksrini
date Sat, 28 Jan 2012 10:46:46 -0800
parents ff24779c147f
children 7a25b72b3644
files test/tools/launcher/Arrrghs.java test/tools/launcher/ChangeDataModel.java test/tools/launcher/ChangeDataModel.sh test/tools/launcher/CreatePlatformFile.java test/tools/launcher/DefaultLocaleTestRun.java test/tools/launcher/ExecutionEnvironment.java test/tools/launcher/I18NJarTest.java test/tools/launcher/I18NTest.java test/tools/launcher/MiscTests.java test/tools/launcher/Settings.java test/tools/launcher/SomeException.java test/tools/launcher/Test7029048.java test/tools/launcher/TestHelper.java test/tools/launcher/UnicodeCleanup.java test/tools/launcher/UnicodeTest.java test/tools/launcher/UnicodeTest.sh test/tools/launcher/UnresolvedExceptions.java test/tools/launcher/deleteI18n.sh test/tools/launcher/i18nTest.sh test/tools/launcher/unresolvedExceptions.sh
diffstat 20 files changed, 580 insertions(+), 979 deletions(-) [+]
line wrap: on
line diff
--- a/test/tools/launcher/Arrrghs.java	Fri Jan 27 15:25:17 2012 -0800
+++ b/test/tools/launcher/Arrrghs.java	Sat Jan 28 10:46:46 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2012, 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
@@ -26,7 +26,7 @@
  * @bug 5030233 6214916 6356475 6571029 6684582 6742159 4459600 6758881 6753938
  *      6894719 6968053 7067922
  * @summary Argument parsing validation.
- * @compile -XDignore.symbol.file Arrrghs.java TestHelper.java
+ * @compile -XDignore.symbol.file Arrrghs.java
  * @run main Arrrghs
  */
 
@@ -38,7 +38,7 @@
 import java.io.InputStreamReader;
 import java.util.Map;
 
-public class Arrrghs {
+public class Arrrghs extends TestHelper {
     private Arrrghs(){}
     /**
      * This class provides various tests for arguments processing.
@@ -62,7 +62,7 @@
      * SIGH, On Windows all strings are quoted, we need to unwrap it
      */
     private static String removeExtraQuotes(String in) {
-        if (TestHelper.isWindows) {
+        if (isWindows) {
             // Trim the string and remove the enclosed quotes if any.
             in = in.trim();
             if (in.startsWith("\"") && in.endsWith("\"")) {
@@ -82,7 +82,7 @@
 
         String in = rd.readLine();
         while (in != null) {
-            if (TestHelper.debug) System.out.println(in);
+            if (debug) System.out.println(in);
             if (in.startsWith(Cookie)) {
                 String detectedArgument = removeExtraQuotes(in.substring(Cookie.length()));
                 if (expectedArguments.equals(detectedArgument)) {
@@ -94,7 +94,7 @@
                             detectedArgument + "'");
                 }
                 // Return the value asap if not in debug mode.
-                if (!TestHelper.debug) {
+                if (!debug) {
                     rd.close();
                     istream.close();
                     return retval;
@@ -125,7 +125,7 @@
      * Quoting could cause dissimilar testArguments and expected arguments.
      */
     static int doTest(String testArguments, String expectedPattern) {
-        ProcessBuilder pb = new ProcessBuilder(TestHelper.javaCmd,
+        ProcessBuilder pb = new ProcessBuilder(javaCmd,
                 VersionStr, testArguments);
 
         Map<String, String> env = pb.environment();
@@ -146,8 +146,7 @@
          * These tests require that a JVM (any JVM) be installed in the system registry.
          * If none is installed, skip this test.
          */
-        TestHelper.TestResult tr =
-                TestHelper.doExec(TestHelper.javaCmd, VersionStr, "-version");
+        TestResult tr = doExec(javaCmd, VersionStr, "-version");
         if (!tr.isOK()) {
             System.err.println("Warning:Argument Passing Tests were skipped, " +
                     "no java found in system registry.");
@@ -155,38 +154,38 @@
         }
 
         // Basic test
-        TestHelper.testExitValue += doTest("-a -b -c -d");
+        testExitValue += doTest("-a -b -c -d");
 
         // Basic test with many spaces
-        TestHelper.testExitValue += doTest("-a    -b      -c       -d");
+        testExitValue += doTest("-a    -b      -c       -d");
 
         // Quoted whitespace does matter ?
-        TestHelper.testExitValue += doTest("-a \"\"-b      -c\"\" -d");
+        testExitValue += doTest("-a \"\"-b      -c\"\" -d");
 
 
         // Escaped quotes outside of quotes as literals
-        TestHelper.testExitValue += doTest("-a \\\"-b -c\\\" -d");
+        testExitValue += doTest("-a \\\"-b -c\\\" -d");
 
         // Check for escaped quotes inside of quotes as literal
-        TestHelper.testExitValue += doTest("-a \"-b \\\"stuff\\\"\" -c -d");
+        testExitValue += doTest("-a \"-b \\\"stuff\\\"\" -c -d");
 
         // A quote preceeded by an odd number of slashes is a literal quote
-        TestHelper.testExitValue += doTest("-a -b\\\\\\\" -c -d");
+        testExitValue += doTest("-a -b\\\\\\\" -c -d");
 
         // A quote preceeded by an even number of slashes is a literal quote
         // see 6214916.
-        TestHelper.testExitValue += doTest("-a -b\\\\\\\\\" -c -d");
+        testExitValue += doTest("-a -b\\\\\\\\\" -c -d");
 
         // Make sure that whitespace doesn't interfere with the removal of the
         // appropriate tokens. (space-tab-space preceeds -jre-restict-search).
-        TestHelper.testExitValue += doTest("-a -b  \t -jre-restrict-search -c -d","-a -b -c -d");
+        testExitValue += doTest("-a -b  \t -jre-restrict-search -c -d","-a -b -c -d");
 
         // Make sure that the mJRE tokens being stripped, aren't stripped if
         // they happen to appear as arguments to the main class.
-        TestHelper.testExitValue += doTest("foo -version:1.1+");
+        testExitValue += doTest("foo -version:1.1+");
 
         System.out.println("Completed arguments quoting tests with " +
-                TestHelper.testExitValue + " errors");
+                testExitValue + " errors");
     }
 
     /*
@@ -194,156 +193,167 @@
      */
     static void runBasicErrorMessageTests() {
         // Tests for 5030233
-        TestHelper.TestResult tr = TestHelper.doExec(TestHelper.javaCmd, "-cp");
+        TestResult tr = doExec(javaCmd, "-cp");
         tr.checkNegative();
         tr.isNotZeroOutput();
         System.out.println(tr);
 
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-classpath");
+        tr = doExec(javaCmd, "-classpath");
         tr.checkNegative();
         tr.isNotZeroOutput();
         System.out.println(tr);
 
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-jar");
+        tr = doExec(javaCmd, "-jar");
         tr.checkNegative();
         tr.isNotZeroOutput();
         System.out.println(tr);
 
-        tr = TestHelper.doExec(TestHelper.javacCmd, "-cp");
+        tr = doExec(javacCmd, "-cp");
         tr.checkNegative();
         tr.isNotZeroOutput();
         System.out.println(tr);
 
         // Test for 6356475 "REGRESSION:"java -X" from cmdline fails"
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-X");
+        tr = doExec(javaCmd, "-X");
         tr.checkPositive();
         tr.isNotZeroOutput();
         System.out.println(tr);
 
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-help");
+        tr = doExec(javaCmd, "-help");
         tr.checkPositive();
         tr.isNotZeroOutput();
         System.out.println(tr);
 
         // 6753938, test for non-negative exit value for an incorrectly formed
         // command line,  '% java'
-        tr = TestHelper.doExec(TestHelper.javaCmd);
+        tr = doExec(javaCmd);
         tr.checkNegative();
         tr.isNotZeroOutput();
         System.out.println(tr);
 
         // 6753938, test for non-negative exit value for an incorrectly formed
         // command line,  '% java -Xcomp'
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-Xcomp");
+        tr = doExec(javaCmd, "-Xcomp");
         tr.checkNegative();
         tr.isNotZeroOutput();
         System.out.println(tr);
     }
 
     /*
-     * A set of tests which tests various dispositions of the main method.
+     * Tests various dispositions of the main method, these tests are limited
+     * to English locales as they check for error messages that are localized.
      */
     static void runMainMethodTests() throws FileNotFoundException {
-        TestHelper.TestResult tr = null;
+        if (!isEnglishLocale()) {
+            return;
+        }
+
+        TestResult tr = null;
 
         // a missing class
-        TestHelper.createJar("MIA", new File("some.jar"), new File("Foo"),
+        createJar("MIA", new File("some.jar"), new File("Foo"),
                 (String[])null);
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar");
+        tr = doExec(javaCmd, "-jar", "some.jar");
         tr.contains("Error: Could not find or load main class MIA");
         System.out.println(tr);
         // use classpath to check
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "MIA");
+        tr = doExec(javaCmd, "-cp", "some.jar", "MIA");
         tr.contains("Error: Could not find or load main class MIA");
         System.out.println(tr);
 
         // incorrect method access
-        TestHelper.createJar(new File("some.jar"), new File("Foo"),
+        createJar(new File("some.jar"), new File("Foo"),
                 "private static void main(String[] args){}");
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar");
+        tr = doExec(javaCmd, "-jar", "some.jar");
         tr.contains("Error: Main method not found in class Foo");
         System.out.println(tr);
         // use classpath to check
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "Foo");
+        tr = doExec(javaCmd, "-cp", "some.jar", "Foo");
         tr.contains("Error: Main method not found in class Foo");
         System.out.println(tr);
 
         // incorrect return type
-        TestHelper.createJar(new File("some.jar"), new File("Foo"),
+        createJar(new File("some.jar"), new File("Foo"),
                 "public static int main(String[] args){return 1;}");
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar");
+        tr = doExec(javaCmd, "-jar", "some.jar");
         tr.contains("Error: Main method must return a value of type void in class Foo");
         System.out.println(tr);
         // use classpath to check
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "Foo");
+        tr = doExec(javaCmd, "-cp", "some.jar", "Foo");
         tr.contains("Error: Main method must return a value of type void in class Foo");
         System.out.println(tr);
 
         // incorrect parameter type
-        TestHelper.createJar(new File("some.jar"), new File("Foo"),
+        createJar(new File("some.jar"), new File("Foo"),
                 "public static void main(Object[] args){}");
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar");
+        tr = doExec(javaCmd, "-jar", "some.jar");
         tr.contains("Error: Main method not found in class Foo");
         System.out.println(tr);
         // use classpath to check
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "Foo");
+        tr = doExec(javaCmd, "-cp", "some.jar", "Foo");
         tr.contains("Error: Main method not found in class Foo");
         System.out.println(tr);
 
         // incorrect method type - non-static
-         TestHelper.createJar(new File("some.jar"), new File("Foo"),
+         createJar(new File("some.jar"), new File("Foo"),
                 "public void main(String[] args){}");
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar");
+        tr = doExec(javaCmd, "-jar", "some.jar");
         tr.contains("Error: Main method is not static in class Foo");
         System.out.println(tr);
         // use classpath to check
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "Foo");
+        tr = doExec(javaCmd, "-cp", "some.jar", "Foo");
         tr.contains("Error: Main method is not static in class Foo");
         System.out.println(tr);
 
         // amongst a potpourri of kindred main methods, is the right one chosen ?
-        TestHelper.createJar(new File("some.jar"), new File("Foo"),
+        createJar(new File("some.jar"), new File("Foo"),
             "void main(Object[] args){}",
             "int  main(Float[] args){return 1;}",
             "private void main() {}",
             "private static void main(int x) {}",
             "public int main(int argc, String[] argv) {return 1;}",
             "public static void main(String[] args) {System.out.println(\"THE_CHOSEN_ONE\");}");
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar");
+        tr = doExec(javaCmd, "-jar", "some.jar");
         tr.contains("THE_CHOSEN_ONE");
         System.out.println(tr);
         // use classpath to check
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-cp", "some.jar", "Foo");
+        tr = doExec(javaCmd, "-cp", "some.jar", "Foo");
         tr.contains("THE_CHOSEN_ONE");
         System.out.println(tr);
 
         // test for extraneous whitespace in the Main-Class attribute
-        TestHelper.createJar(" Foo ", new File("some.jar"), new File("Foo"),
+        createJar(" Foo ", new File("some.jar"), new File("Foo"),
                 "public static void main(String... args){}");
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "some.jar");
+        tr = doExec(javaCmd, "-jar", "some.jar");
         tr.checkPositive();
         System.out.println(tr);
     }
-    // tests 6968053, ie. we turn on the -Xdiag (for now) flag and check if
-    // the suppressed stack traces are exposed.
+    /*
+     * tests 6968053, ie. we turn on the -Xdiag (for now) flag and check if
+     * the suppressed stack traces are exposed, ignore these tests for localized
+     * locales, limiting to English only.
+     */
     static void runDiagOptionTests() throws FileNotFoundException {
-        TestHelper.TestResult tr = null;
+        if (!isEnglishLocale()) { // only english version
+            return;
+        }
+        TestResult tr = null;
         // a missing class
-        TestHelper.createJar("MIA", new File("some.jar"), new File("Foo"),
+        createJar("MIA", new File("some.jar"), new File("Foo"),
                 (String[])null);
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-Xdiag", "-jar", "some.jar");
+        tr = doExec(javaCmd, "-Xdiag", "-jar", "some.jar");
         tr.contains("Error: Could not find or load main class MIA");
         tr.contains("java.lang.ClassNotFoundException: MIA");
         System.out.println(tr);
 
         // use classpath to check
-        tr = TestHelper.doExec(TestHelper.javaCmd,  "-Xdiag", "-cp", "some.jar", "MIA");
+        tr = doExec(javaCmd,  "-Xdiag", "-cp", "some.jar", "MIA");
         tr.contains("Error: Could not find or load main class MIA");
         tr.contains("java.lang.ClassNotFoundException: MIA");
         System.out.println(tr);
 
         // a missing class on the classpath
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-Xdiag", "NonExistentClass");
+        tr = doExec(javaCmd, "-Xdiag", "NonExistentClass");
         tr.contains("Error: Could not find or load main class NonExistentClass");
         tr.contains("java.lang.ClassNotFoundException: NonExistentClass");
         System.out.println(tr);
@@ -351,23 +361,29 @@
 
     static void test6894719() {
         // test both arguments to ensure they exist
-        TestHelper.TestResult tr = null;
-        tr = TestHelper.doExec(TestHelper.javaCmd,
+        TestResult tr = null;
+        tr = doExec(javaCmd,
                 "-no-jre-restrict-search", "-version");
         tr.checkPositive();
         System.out.println(tr);
 
-        tr = TestHelper.doExec(TestHelper.javaCmd,
+        tr = doExec(javaCmd,
                 "-jre-restrict-search", "-version");
         tr.checkPositive();
         System.out.println(tr);
     }
 
+    /*
+     * a missing manifest entry 7067922, we ignore this test for locales
+     * which are localized, thus the testing is limited to English locales.
+     */
     static void test7067922() {
-        // a missing manifest entry 7067922
-        TestHelper.TestResult tr = null;
-        TestHelper.createJar("cvf", "missingmainentry.jar", ".");
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-jar", "missingmainentry.jar");
+        if (!isEnglishLocale()) {
+            return;
+        }
+        TestResult tr = null;
+        createJar("cvf", "missingmainentry.jar", ".");
+        tr = doExec(javaCmd, "-jar", "missingmainentry.jar");
         tr.contains("no main manifest attribute");
         System.out.println(tr);
     }
@@ -377,7 +393,7 @@
      * @throws java.io.FileNotFoundException
      */
     public static void main(String[] args) throws FileNotFoundException {
-        if (TestHelper.debug) {
+        if (debug) {
             System.out.println("Starting Arrrghs tests");
         }
         quoteParsingTests();
@@ -386,8 +402,8 @@
         test6894719();
         test7067922();
         runDiagOptionTests();
-        if (TestHelper.testExitValue > 0) {
-            System.out.println("Total of " + TestHelper.testExitValue + " failed");
+        if (testExitValue > 0) {
+            System.out.println("Total of " + testExitValue + " failed");
             System.exit(1);
         } else {
             System.out.println("All tests pass");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/launcher/ChangeDataModel.java	Sat Jan 28 10:46:46 2012 -0800
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2012, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/**
+ * @test
+ * @bug 4894330 4810347 6277269
+ * @compile -XDignore.symbol.file ChangeDataModel.java
+ * @run main ChangeDataModel
+ * @summary Verify -d32 and -d64 options are accepted(rejected) on all platforms
+ * @author Joseph D. Darcy, ksrini
+ */
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ChangeDataModel extends TestHelper {
+    private static final File TestJar      = new File("test" + JAR_FILE_EXT);
+    private static final String OPT_PREFIX = "ARCH_OPT:";
+
+    public static void main(String... args) throws Exception {
+        String[] code = {
+            "   public static void main(String argv[]) {",
+            "      System.out.println(\"" + OPT_PREFIX + "-d\" + System.getProperty(\"sun.arch.data.model\", \"none\"));",
+            "   }",
+        };
+        createJar(TestJar, code);
+
+        // verify if data model flag for default data model is accepted
+        if (is32Bit) {
+            checkAcceptance(javaCmd, "-d32");
+        } else if (is64Bit) {
+            checkAcceptance(javaCmd, "-d64");
+        } else {
+            throw new Error("unsupported data model");
+        }
+
+        // test dual mode systems
+        if (isDualMode) {
+            // albeit dual mode we may not have the 64 bit components present
+            if (dualModePresent()) {
+                // 32-bit -> 64-bit
+                checkExecCount(javaCmd, "-d64");
+                // 64-bit -> 32-bit
+                checkExecCount(java64Cmd, "-d32");
+
+                checkAcceptance(javaCmd, "-d64");
+                checkAcceptance(java64Cmd, "-d32");
+            } else {
+                System.out.println("Warning: no 64-bit components found;" +
+                    " only one data model tested.");
+            }
+        } else {
+            // Negative tests: ensure that non-dual mode systems reject the
+            // complementary (other) data model
+            if (is32Bit) {
+                checkRejection(javaCmd, "-d64");
+            } else if (is64Bit) {
+                checkRejection(javaCmd, "-d32");
+            } else {
+                throw new Error("unsupported data model");
+            }
+        }
+    }
+
+    static void checkExecCount(String cmd, String dmodel) {
+        Map<String, String> envMap = new HashMap<>();
+        envMap.put(JLDEBUG_KEY, "true");
+        TestResult tr = doExec(envMap, javaCmd, "-d64",
+                "-jar", TestJar.getAbsolutePath());
+        int count = 0;
+        for (String x : tr.testOutput) {
+            if (x.contains(EXPECTED_MARKER)) {
+                count++;
+                if (count > 1) {
+                    System.out.println(tr);
+                    throw new RuntimeException("Maximum exec count of 1 execeeded");
+                }
+            }
+        }
+    }
+
+    static void checkAcceptance(String cmd, String dmodel) {
+        TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath());
+        if (!tr.contains(OPT_PREFIX + dmodel)) {
+            System.out.println(tr);
+            String message = "Data model flag " + dmodel +
+                    " not accepted or had improper effect.";
+            throw new RuntimeException(message);
+        }
+    }
+
+    static void checkRejection(String cmd, String dmodel) {
+        TestResult tr = doExec(cmd, dmodel, "-jar", TestJar.getAbsolutePath());
+        if (tr.contains(OPT_PREFIX + dmodel)) {
+            System.out.println(tr);
+            String message = "Data model flag " + dmodel + " was accepted.";
+            throw new RuntimeException(message);
+        }
+    }
+}
--- a/test/tools/launcher/ChangeDataModel.sh	Fri Jan 27 15:25:17 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,260 +0,0 @@
-#
-# Copyright (c) 2003, 2010, 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4894330 4810347 6277269
-# @run shell ChangeDataModel.sh
-# @summary Verify -d32 and -d64 options are accepted(rejected) on all platforms 
-# @author Joseph D. Darcy
-
-OS=`uname -s`;
-
-# To remove CR from output, needed for java apps in CYGWIN, harmless otherwise
-SED_CR="sed -e s@\\r@@g"
-
-case "$OS" in
-	Windows* | CYGWIN* )
-	  PATHSEP=";"
-	  ;;
-
-	* )
-	  PATHSEP=":"
-	;;
-esac
-
-# Verify directory context variables are set
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-# Construct paths to default Java executables
-JAVA="$TESTJAVA/bin/java -classpath $TESTCLASSES${PATHSEP}."
-JAVAC="$TESTJAVA/bin/javac"
-
-
-# Create our little Java test on the fly
-( printf "public class GetDataModel {"
-  printf "   public static void main(String argv[]) {"
-  printf "      System.out.println(System.getProperty(\"sun.arch.data.model\", \"none\"));"
-  printf "   }"
-  printf "}"
-) > GetDataModel.java
-
-$JAVAC GetDataModel.java
-
-
-# All preconditions are met; run the tests.
-
-
-# Verify data model flag for default data model is accepted
-
-DM=`$JAVA GetDataModel | ${SED_CR}`
-case "$DM" in
-        32 )
-		DM2=`${JAVA} -d32 GetDataModel | ${SED_CR}`	
-		if [ "${DM2}" != "32" ]
-		then
-	  	echo "Data model flag -d32 not accepted or had improper effect."
-	  	exit 1
-		fi
-        ;;
-
-        64 )
-		DM2=`${JAVA} -d64 GetDataModel | ${SED_CR}`	
-		if [ "${DM2}" != "64" ]
-		then
-	  	echo "Data model flag -d64 not accepted or had improper effect."
-	  	exit 1
-		fi
-	;;
-
-	* )
-		echo "Unrecognized data model: $DM"
-        	exit 1
-	;;
-esac
-
-# Determine if platform might be dual-mode capable.
-
-case "$OS" in
-	SunOS )
-		# ARCH should be sparc or i386
-		ARCH=`uname -p`
-		case "${ARCH}" in 
-			sparc )
-			DUALMODE=true
-			PATH64=sparcv9
-			;;
-
-			i386 )
-			DUALMODE=true
-			PATH64=amd64
-			;;
-
-			* )
-			DUALMODE=false
-			;;
-		esac
-	;;
-
-
-	Linux )
-		# ARCH should be ia64, x86_64, or i*86
-		ARCH=`uname -m`
-		case "${ARCH}" in 
-			ia64 )
-			DUALMODE=false
-			;;
-
-			x86_64 )
-			DUALMODE=true
-			PATH64=amd64
-			;;
-
-			* )
-			DUALMODE=false;
-			;;
-		esac
-	;;
-
-	Windows* | CYGWIN* )
-		ARCH=`uname -m`
-		case "${ARCH}" in 
-			* )
-			DUALMODE=false;
-			;;
-		esac
-	;;
-
-	* )
-		echo "Warning: unknown environment."
-		DUALMODE=false
-	;;
-esac
-
-if [ "${DUALMODE}" = "true" ]
-then
-	# Construct path to 64-bit Java executable, might not exist
-	JAVA64FILE="${TESTJAVA}/bin/${PATH64}/java"
-	JAVA64="${JAVA64FILE} -classpath ${TESTCLASSES}${PATHSEP}."
-
-	if [ -f ${JAVA64FILE} ]; then
-		# Verify that, at least on Solaris, only one exec is
-		# used to change data models
-		if [ "${OS}" = "SunOS" ]
-		then
-			rm -f truss.out
-			truss -texec ${JAVA} -d64 GetDataModel > /dev/null 2> truss.out
-			execCount=`grep -c execve truss.out`
-			if [ "${execCount}" -gt 2 ]
-			then
-				echo "Maximum exec count of 2 exceeded: got $execCount."
-				exit 1
-			fi
-
-			rm -f truss.out
-			truss -texec ${JAVA64} -d32 GetDataModel > /dev/null 2> truss.out
-			execCount=`grep -c execve truss.out`
-			if [ "${execCount}" -gt 2 ]
-			then
-				echo "Maximum exec count of 2 exceeded: got $execCount."
-				exit 1
-			fi
-		fi
-
-		DM2=`${JAVA} -d64 GetDataModel`
-		if [ "${DM2}" != "64" ]
-		then
-		  echo "Data model flag -d64 not accepted or had improper effect."
-		  exit 1
-		fi
-
-		DM2=`${JAVA64} GetDataModel`
-		if [ "${DM2}" != "64" ]
-		then
-		  echo "Improper data model returned."
-		  exit 1
-		fi
-
-		DM2=`${JAVA64} -d64 GetDataModel`
-		if [ "${DM2}" != "64" ]
-		then
-		  echo "Data model flag -d64 not accepted or had improper effect."
-		  exit 1
-		fi
-
-		DM2=`${JAVA64} -d32 GetDataModel`
-		if [ "${DM2}" != "32" ]
-		then
-		  echo "Data model flag -d32 not accepted or had improper effect."
-		  exit 1
-		fi
-
-	else
-	  echo "Warning: no 64-bit components found; only one data model tested."
-	fi
-else
-# Negative tests for non-dual mode platforms to ensure the other data model is 
-# rejected
-	DM=`$JAVA GetDataModel | ${SED_CR}`
-	case "$DM" in
-	   32 )
-		DM2=`${JAVA} -d64 GetDataModel | ${SED_CR}`	
-		if [ "x${DM2}" != "x" ]
-		then
-		   echo "Data model flag -d64 was accepted."
-		   exit 1
-		fi
-           ;;
-
-	   64 )
-		DM2=`${JAVA} -d32 GetDataModel | ${SED_CR}`	
-		if [ "x${DM2}" != "x" ]
-		  then
-		    echo "Data model flag -d32 was accepted."
-	  	    exit 1
-		fi
-	   ;;
-
-	   * )
-		echo "Unrecognized data model: $DM"
-        	exit 1
-	   ;;
-        esac
-fi
-
-exit 0;
--- a/test/tools/launcher/CreatePlatformFile.java	Fri Jan 27 15:25:17 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 2002, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- *
- *
- * This class is used by test i18nTest.sh
- *
- * Class to create various i18n Hello World Java source files using
- * the platform's default encoding of a non-ASCII name; create plain
- * ASCII Hello World if the platform's default is charset is US-ASCII.
- */
-
-import java.io.PrintWriter;
-import java.io.FileOutputStream;
-
-public class CreatePlatformFile {
-    public static void main(String argv[])  {
-        String fileSep = System.getProperty("file.separator");
-        String defaultEncoding = System.getProperty("file.encoding");
-
-        if(defaultEncoding == null) {
-            System.err.println("Default encoding not found; Error.");
-            return;
-        }
-
-        if (defaultEncoding.equals("Cp1252") ) {
-            // "HelloWorld" with an accented e
-            String fileName = "i18nH\u00e9lloWorld.java";
-            try {
-                PrintWriter pw = new PrintWriter(new FileOutputStream("."+fileSep+fileName));
-                pw.println("public class i18nH\u00e9lloWorld {");
-                pw.println("    public static void main(String [] argv) {");
-                pw.println("        System.out.println(\"Hello Cp1252 World\");");
-                pw.println("    }");
-                pw.println("}");
-                pw.flush();
-                pw.close();
-            }
-            catch (java.io.FileNotFoundException e) {
-                System.err.println("Problem opening file; test fails");
-            }
-
-        } else {
-            // ASCII "HelloWorld"
-            String fileName = "i18nHelloWorld.java";
-            try {
-                PrintWriter pw = new PrintWriter(new FileOutputStream("."+fileSep+fileName));
-                pw.println("public class i18nHelloWorld {");
-                pw.println("    public static void main(String [] argv) {");
-                pw.println("        System.out.println(\"Warning: US-ASCII assumed; filenames with\");");
-                pw.println("        System.out.println(\"non-ASCII characters will not be tested\");");
-                pw.println("    }");
-                pw.println("}");
-                pw.flush();
-                pw.close();
-            }
-            catch (java.io.FileNotFoundException e) {
-                System.err.println("Problem opening file; test fails");
-            }
-        }
-    }
-}
--- a/test/tools/launcher/DefaultLocaleTestRun.java	Fri Jan 27 15:25:17 2012 -0800
+++ b/test/tools/launcher/DefaultLocaleTestRun.java	Sat Jan 28 10:46:46 2012 -0800
@@ -31,23 +31,23 @@
           Following 2 testing scenarios are recommended
           (1)systemLocale=Japanese, userLocale=English
           (2)systemLocale=English, userLocale=Japanese
- * @compile -XDignore.symbol.file DefaultLocaleTest.java TestHelper.java
+ * @compile -XDignore.symbol.file DefaultLocaleTest.java
  * @run main DefaultLocaleTestRun
  */
 
-public class DefaultLocaleTestRun {
+public class DefaultLocaleTestRun extends TestHelper {
     public static void main(String... args) {
-        if (!TestHelper.isWindows) {
+        if (!isWindows) {
             System.out.println("Test passes vacuously on non-windows");
             return;
         }
-        TestHelper.TestResult tr = null;
-        tr = TestHelper.doExec(TestHelper.javaCmd,
-                "-cp", TestHelper.TEST_CLASSES_DIR.getAbsolutePath(),
+        TestResult tr = null;
+        tr = doExec(javaCmd,
+                "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
                 "DefaultLocaleTest", "-w", "x.out");
         System.out.println(tr.testOutput);
-        tr = TestHelper.doExec(TestHelper.javawCmd,
-                "-cp", TestHelper.TEST_CLASSES_DIR.getAbsolutePath(),
+        tr = doExec(javawCmd,
+                "-cp", TEST_CLASSES_DIR.getAbsolutePath(),
                 "DefaultLocaleTest", "-r", "x.out");
         System.out.println(tr.testOutput);
         if (!tr.isOK()) {
--- a/test/tools/launcher/ExecutionEnvironment.java	Fri Jan 27 15:25:17 2012 -0800
+++ b/test/tools/launcher/ExecutionEnvironment.java	Sat Jan 28 10:46:46 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2012, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 4780570 4731671 6354700 6367077 6670965 4882974
  * @summary Checks for LD_LIBRARY_PATH and execution  on *nixes
- * @compile -XDignore.symbol.file ExecutionEnvironment.java TestHelper.java
+ * @compile -XDignore.symbol.file ExecutionEnvironment.java
  * @run main ExecutionEnvironment
  */
 
@@ -60,7 +60,7 @@
 import java.util.Map;
 
 
-public class ExecutionEnvironment {
+public class ExecutionEnvironment extends TestHelper {
     static final String LD_LIBRARY_PATH    = "LD_LIBRARY_PATH";
     static final String LD_LIBRARY_PATH_32 = LD_LIBRARY_PATH + "_32";
     static final String LD_LIBRARY_PATH_64 = LD_LIBRARY_PATH + "_64";
@@ -70,9 +70,6 @@
     static final String LD_LIBRARY_PATH_32_VALUE = "/Lawrence/Of/Arabia";
     static final String LD_LIBRARY_PATH_64_VALUE = "/A/Passage/To/India";
 
-    static final String JLDEBUG_KEY = "_JAVA_LAUNCHER_DEBUG";
-    static final String EXPECTED_MARKER = "TRACER_MARKER:About to EXEC";
-
     static final String[] LD_PATH_STRINGS = {
         LD_LIBRARY_PATH + "=" + LD_LIBRARY_PATH_VALUE,
         LD_LIBRARY_PATH_32 + "=" + LD_LIBRARY_PATH_32_VALUE,
@@ -84,11 +81,11 @@
     static int errors = 0;
     static int passes = 0;
 
-    static final String LIBJVM = TestHelper.isWindows ? "jvm.dll" : "libjvm.so";
+    static final String LIBJVM = isWindows ? "jvm.dll" : "libjvm.so";
 
     static void createTestJar() {
         try {
-            List<String> codeList = new ArrayList<String>();
+            List<String> codeList = new ArrayList<>();
             codeList.add("static void printValue(String name, boolean property) {\n");
             codeList.add("    String value = (property) ? System.getProperty(name) : System.getenv(name);\n");
             codeList.add("    System.out.println(name + \"=\" + value);\n");
@@ -105,7 +102,7 @@
             codeList.add("    printValue(\"" + LD_LIBRARY_PATH_64 + "\", false);\n");
             codeList.add("}\n");
             String[] clist = new String[codeList.size()];
-            TestHelper.createJar(testJarFile, codeList.toArray(clist));
+            createJar(testJarFile, codeList.toArray(clist));
         } catch (FileNotFoundException fnfe) {
             throw new RuntimeException(fnfe);
         }
@@ -117,16 +114,15 @@
      * environment should be pristine.
      */
     private static void ensureEcoFriendly() {
-        TestHelper.TestResult tr = null;
+        TestResult tr = null;
 
-        Map<String, String> env = new HashMap<String, String>();
+        Map<String, String> env = new HashMap<>();
         for (String x : LD_PATH_STRINGS) {
             String pairs[] = x.split("=");
             env.put(pairs[0], pairs[1]);
         }
 
-        tr = TestHelper.doExec(env, TestHelper.javaCmd, "-jar",
-                testJarFile.getAbsolutePath());
+        tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
 
         if (!tr.isNotZeroOutput()) {
             System.out.println(tr);
@@ -149,10 +145,9 @@
      * data model
      */
     static void ensureNoExec() {
-        Map<String, String> env = new HashMap<String, String>();
+        Map<String, String> env = new HashMap<>();
         env.put(JLDEBUG_KEY, "true");
-        TestHelper.TestResult tr =
-                TestHelper.doExec(env, TestHelper.javaCmd, "-version");
+        TestResult tr = doExec(env, javaCmd, "-version");
         if (tr.testOutput.contains(EXPECTED_MARKER)) {
             System.out.println("FAIL: EnsureNoExecs: found expected warning <" +
                     EXPECTED_MARKER +
@@ -176,25 +171,23 @@
      */
 
     static void verifyJavaLibraryPath() {
-        TestHelper.TestResult tr = null;
+        TestResult tr = null;
 
-        Map<String, String> env = new HashMap<String, String>();
+        Map<String, String> env = new HashMap<>();
 
-        if (TestHelper.isLinux) {
+        if (isLinux) {
             for (String x : LD_PATH_STRINGS) {
                 String pairs[] = x.split("=");
                 env.put(pairs[0], pairs[1]);
             }
 
-            tr = TestHelper.doExec(env, TestHelper.javaCmd, "-jar",
-                    testJarFile.getAbsolutePath());
+            tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
             verifyJavaLibraryPathGeneric(tr);
         } else {
             // no override
             env.clear();
             env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
-            tr = TestHelper.doExec(env, TestHelper.javaCmd, "-jar",
-                    testJarFile.getAbsolutePath());
+            tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
             verifyJavaLibraryPathGeneric(tr);
 
             env.clear();
@@ -206,53 +199,52 @@
             // verify the override occurs, since we know the invocation always
             // uses by default is 32-bit, therefore we also set the test
             // expectation to be the same.
-            tr = TestHelper.doExec(env, TestHelper.javaCmd, "-jar",
-                    testJarFile.getAbsolutePath());
+            tr = doExec(env, javaCmd, "-jar", testJarFile.getAbsolutePath());
             verifyJavaLibraryPathOverride(tr, true);
 
             // try changing the model from 32 to 64 bit
-            if (TestHelper.dualModePresent() && TestHelper.is32Bit) {
+            if (dualModePresent() && is32Bit) {
                 // verify the override occurs
                 env.clear();
                 for (String x : LD_PATH_STRINGS) {
                     String pairs[] = x.split("=");
                     env.put(pairs[0], pairs[1]);
                 }
-                tr = TestHelper.doExec(env, TestHelper.javaCmd, "-d64", "-jar",
+                tr = doExec(env, javaCmd, "-d64", "-jar",
                     testJarFile.getAbsolutePath());
                 verifyJavaLibraryPathOverride(tr, false);
 
                 // no override
                 env.clear();
                 env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
-                tr = TestHelper.doExec(env, TestHelper.javaCmd, "-jar",
+                tr = doExec(env, javaCmd, "-jar",
                         testJarFile.getAbsolutePath());
                 verifyJavaLibraryPathGeneric(tr);
             }
 
             // try changing the model from 64 to 32 bit
-            if (TestHelper.java64Cmd != null && TestHelper.is64Bit) {
+            if (java64Cmd != null && is64Bit) {
                 // verify the override occurs
                 env.clear();
                 for (String x : LD_PATH_STRINGS) {
                     String pairs[] = x.split("=");
                     env.put(pairs[0], pairs[1]);
                 }
-                tr = TestHelper.doExec(env, TestHelper.java64Cmd, "-d32", "-jar",
+                tr = doExec(env, java64Cmd, "-d32", "-jar",
                     testJarFile.getAbsolutePath());
                 verifyJavaLibraryPathOverride(tr, true);
 
                 // no override
                 env.clear();
                 env.put(LD_LIBRARY_PATH, LD_LIBRARY_PATH_VALUE);
-                tr = TestHelper.doExec(env, TestHelper.java64Cmd, "-d32", "-jar",
+                tr = doExec(env, java64Cmd, "-d32", "-jar",
                         testJarFile.getAbsolutePath());
                 verifyJavaLibraryPathGeneric(tr);
             }
         }
     }
 
-    private static void verifyJavaLibraryPathGeneric(TestHelper.TestResult tr) {
+    private static void verifyJavaLibraryPathGeneric(TestResult tr) {
         if (!tr.matches("java.library.path=.*" + LD_LIBRARY_PATH_VALUE + ".*")) {
             System.out.print("FAIL: verifyJavaLibraryPath: ");
             System.out.println(" java.library.path does not contain " +
@@ -264,7 +256,7 @@
         }
     }
 
-    private static void verifyJavaLibraryPathOverride(TestHelper.TestResult tr,
+    private static void verifyJavaLibraryPathOverride(TestResult tr,
             boolean is32Bit) {
         // make sure the 32/64 bit value exists
         if (!tr.matches("java.library.path=.*" +
@@ -295,10 +287,10 @@
      */
     static void verifyVmSelection() {
 
-        TestHelper.TestResult tr = null;
+        TestResult tr = null;
 
-        if (TestHelper.is32Bit) {
-            tr = TestHelper.doExec(TestHelper.javaCmd, "-client", "-version");
+        if (is32Bit) {
+            tr = doExec(javaCmd, "-client", "-version");
             if (!tr.matches(".*Client VM.*")) {
                 System.out.println("FAIL: the expected vm -client did not launch");
                 System.out.println(tr);
@@ -307,7 +299,7 @@
                 passes++;
             }
         }
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-server", "-version");
+        tr = doExec(javaCmd, "-server", "-version");
         if (!tr.matches(".*Server VM.*")) {
             System.out.println("FAIL: the expected vm -server did not launch");
             System.out.println(tr);
@@ -321,14 +313,14 @@
      * checks to see there is no extra libjvm.so than needed
      */
     static void verifyNoSymLink() {
-        if (TestHelper.is64Bit) {
+        if (is64Bit) {
             return;
         }
 
         File symLink = null;
-        String libPathPrefix = TestHelper.isSDK ? "jre/lib" : "/lib";
-        symLink = new File(TestHelper.JAVAHOME, libPathPrefix +
-                TestHelper.getJreArch() + "/" + LIBJVM);
+        String libPathPrefix = isSDK ? "jre/lib" : "/lib";
+        symLink = new File(JAVAHOME, libPathPrefix +
+                getJreArch() + "/" + LIBJVM);
         if (symLink.exists()) {
             System.out.println("FAIL: The symlink exists " +
                     symLink.getAbsolutePath());
@@ -339,7 +331,7 @@
     }
 
     public static void main(String... args) throws Exception {
-        if (TestHelper.isWindows) {
+        if (isWindows) {
             System.out.println("Warning: noop on windows");
             return;
         }
--- a/test/tools/launcher/I18NJarTest.java	Fri Jan 27 15:25:17 2012 -0800
+++ b/test/tools/launcher/I18NJarTest.java	Sat Jan 28 10:46:46 2012 -0800
@@ -26,7 +26,7 @@
  * @bug 7125442
  * @summary ensures a jar path as well as a class located in a path containing
  *          unicode characters are launched.
- * @compile -XDignore.symbol.file I18NJarTest.java TestHelper.java
+ * @compile -XDignore.symbol.file I18NJarTest.java
  * @run main/othervm I18NJarTest
  */
 import java.io.File;
@@ -48,7 +48,7 @@
  * in its own VM (othervm mode), such that the ensuing tests can run unperturbed,
  * regardless of the outcome.
  */
-public class I18NJarTest {
+public class I18NJarTest extends TestHelper {
     private static final File cwd = new File(".");
     private static final File dir = new File("\uFF66\uFF67\uFF68\uFF69");
     private static final String encoding = System.getProperty("sun.jnu.encoding", "");
@@ -78,7 +78,7 @@
         }
         dir.mkdir();
         File dirfile = new File(dir, "foo.jar");
-        TestHelper.createJar(dirfile,
+        createJar(dirfile,
                 "public static void main(String... args) {",
                 "System.out.println(\"Hello World\");",
                 "System.exit(0);",
@@ -86,22 +86,20 @@
 
         // remove the class files, to ensure that the class is indeed picked up
         // from the jar file and not from ambient classpath.
-        File[] classFiles = cwd.listFiles(TestHelper.createFilter(TestHelper.CLASS_FILE_EXT));
+        File[] classFiles = cwd.listFiles(createFilter(CLASS_FILE_EXT));
         for (File f : classFiles) {
             f.delete();
         }
 
         // test with a jar file
-        TestHelper.TestResult tr = TestHelper.doExec(TestHelper.javaCmd,
-                "-jar", dirfile.getAbsolutePath());
+        TestResult tr = doExec(javaCmd, "-jar", dirfile.getAbsolutePath());
         System.out.println(tr);
         if (!tr.isOK()) {
             throw new RuntimeException("TEST FAILED");
         }
 
         // test the same class but by specifying it as a classpath
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-cp",
-                dirfile.getAbsolutePath(), "Foo");
+        tr = doExec(javaCmd, "-cp", dirfile.getAbsolutePath(), "Foo");
         System.out.println(tr);
         if (!tr.isOK()) {
             throw new RuntimeException("TEST FAILED");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tools/launcher/I18NTest.java	Sat Jan 28 10:46:46 2012 -0800
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2012, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 4761384
+ * @compile -XDignore.symbol.file I18NTest.java
+ * @run main I18NTest
+ * @summary Test to see if class files with non-ASCII characters can be run
+ * @author Joseph D. Darcy, Kumar Srinivasan
+ */
+
+
+import java.util.ArrayList;
+import java.io.File;
+import java.util.List;
+
+public class I18NTest extends TestHelper {
+    static String fileName = null;
+    public static void main(String... args) throws Exception {
+        String defaultEncoding = System.getProperty("file.encoding");
+        if (defaultEncoding == null) {
+            System.err.println("Default encoding not found; Error.");
+            return;
+        }
+        if (!defaultEncoding.equals("Cp1252")) {
+            System.err.println("Warning: required encoding not found, test skipped.");
+            return;
+        }
+        // for some reason the shell test version insisted on cleaning out the
+        // directory, likely being pedantic.
+        File cwd = new File(".");
+        for (File f : cwd.listFiles(createFilter(CLASS_FILE_EXT))) {
+            f.delete();
+        }
+        for (File f : cwd.listFiles(createFilter(JAVA_FILE_EXT))) {
+            f.delete();
+        }
+        createPlatformFile();
+
+        // compile the generate code using the javac compiler vs. the api, to
+        // as a bonus point to see if the argument is passed correctly
+        TestResult tr = null;
+        tr = doExec(javacCmd, fileName + JAVA_FILE_EXT);
+        if (!tr.isOK()) {
+            System.out.println(tr);
+            throw new Error("compilation failed...");
+        }
+        tr = doExec(javaCmd, "-cp", ".", fileName);
+        if (!tr.isOK()) {
+            System.out.println(tr);
+            throw new RuntimeException("run failed with encoding " + defaultEncoding);
+        }
+    }
+
+    public static void createPlatformFile() throws Exception {
+        List<String> buffer = new ArrayList<>();
+        // "HelloWorld" with an accented e
+        fileName = "i18nH\u00e9lloWorld";
+        buffer.clear();
+        buffer.add("public class i18nH\u00e9lloWorld {");
+        buffer.add("    public static void main(String [] argv) {");
+        buffer.add("        System.out.println(\"Hello Cp1252 World\");");
+        buffer.add("    }");
+        buffer.add("}");
+        File outFile = new File(fileName + JAVA_FILE_EXT);
+        createFile(outFile, buffer);
+    }
+}
--- a/test/tools/launcher/MiscTests.java	Fri Jan 27 15:25:17 2012 -0800
+++ b/test/tools/launcher/MiscTests.java	Sat Jan 28 10:46:46 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 6856415
  * @summary Miscellaneous tests, Exceptions
- * @compile -XDignore.symbol.file MiscTests.java TestHelper.java
+ * @compile -XDignore.symbol.file MiscTests.java
  * @run main MiscTests
  */
 
@@ -33,12 +33,12 @@
 import java.io.File;
 import java.io.FileNotFoundException;
 
-public class MiscTests {
+public class MiscTests extends TestHelper {
 
     // 6856415: Checks to ensure that proper exceptions are thrown by java
     static void test6856415() {
         // No pkcs library on win-x64, so we bail out.
-        if (TestHelper.is64Bit && TestHelper.isWindows) {
+        if (is64Bit && isWindows) {
             return;
         }
         StringBuilder sb = new StringBuilder();
@@ -49,11 +49,11 @@
         File testJar = new File("Foo.jar");
         testJar.delete();
         try {
-            TestHelper.createJar(testJar, sb.toString());
+            createJar(testJar, sb.toString());
         } catch (FileNotFoundException fnfe) {
             throw new RuntimeException(fnfe);
         }
-        TestHelper.TestResult tr = TestHelper.doExec(TestHelper.javaCmd,
+        TestResult tr = doExec(javaCmd,
                 "-Djava.security.manager", "-jar", testJar.getName(), "foo.bak");
         for (String s : tr.testOutput) {
             System.out.println(s);
@@ -67,8 +67,8 @@
 
     public static void main(String... args) {
         test6856415();
-        if (TestHelper.testExitValue != 0) {
-            throw new Error(TestHelper.testExitValue + " tests failed");
+        if (testExitValue != 0) {
+            throw new Error(testExitValue + " tests failed");
     }
 }
 }
--- a/test/tools/launcher/Settings.java	Fri Jan 27 15:25:17 2012 -0800
+++ b/test/tools/launcher/Settings.java	Sat Jan 28 10:46:46 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2012, 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
@@ -27,11 +27,11 @@
  * @test
  * @bug 6994753 7123582
  * @summary tests -XshowSettings options
- * @compile -XDignore.symbol.file Settings.java TestHelper.java
+ * @compile -XDignore.symbol.file Settings.java
  * @run main Settings
  * @author ksrini
  */
-public class Settings {
+public class Settings extends TestHelper {
     private static File testJar = null;
 
     static void init() throws IOException {
@@ -45,17 +45,17 @@
         tsrc.append("        System.out.println(x);\n");
         tsrc.append("   }\n");
         tsrc.append("}\n");
-        TestHelper.createJar(testJar, tsrc.toString());
+        createJar(testJar, tsrc.toString());
     }
 
-    static void checkContains(TestHelper.TestResult tr, String str) {
+    static void checkContains(TestResult tr, String str) {
         if (!tr.contains(str)) {
             System.out.println(tr);
             throw new RuntimeException(str + " not found");
         }
     }
 
-    static void checkNoContains(TestHelper.TestResult tr, String str) {
+    static void checkNoContains(TestResult tr, String str) {
         if (tr.contains(str)) {
             System.out.println(tr.status);
             throw new RuntimeException(str + " found");
@@ -66,22 +66,22 @@
     private static final String PROP_SETTINGS = "Property settings:";
     private static final String LOCALE_SETTINGS = "Locale settings:";
 
-    static void containsAllOptions(TestHelper.TestResult tr) {
+    static void containsAllOptions(TestResult tr) {
         checkContains(tr, VM_SETTINGS);
         checkContains(tr, PROP_SETTINGS);
         checkContains(tr, LOCALE_SETTINGS);
     }
 
     static void runTestOptionDefault() throws IOException {
-        TestHelper.TestResult tr = null;
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-Xms64m", "-Xmx512m",
+        TestResult tr = null;
+        tr = doExec(javaCmd, "-Xms64m", "-Xmx512m",
                 "-Xss128k", "-XshowSettings", "-jar", testJar.getAbsolutePath());
         containsAllOptions(tr);
         if (!tr.isOK()) {
             System.out.println(tr.status);
             throw new RuntimeException("test fails");
         }
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-Xms65536k", "-Xmx712m",
+        tr = doExec(javaCmd, "-Xms65536k", "-Xmx712m",
                 "-Xss122880", "-XshowSettings", "-jar", testJar.getAbsolutePath());
         containsAllOptions(tr);
         if (!tr.isOK()) {
@@ -92,38 +92,38 @@
 
     static void runTestOptionAll() throws IOException {
         init();
-        TestHelper.TestResult tr = null;
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:all");
+        TestResult tr = null;
+        tr = doExec(javaCmd, "-XshowSettings:all");
         containsAllOptions(tr);
     }
 
     static void runTestOptionVM() throws IOException {
-        TestHelper.TestResult tr = null;
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:vm");
+        TestResult tr = null;
+        tr = doExec(javaCmd, "-XshowSettings:vm");
         checkContains(tr, VM_SETTINGS);
         checkNoContains(tr, PROP_SETTINGS);
         checkNoContains(tr, LOCALE_SETTINGS);
     }
 
     static void runTestOptionProperty() throws IOException {
-        TestHelper.TestResult tr = null;
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:properties");
+        TestResult tr = null;
+        tr = doExec(javaCmd, "-XshowSettings:properties");
         checkNoContains(tr, VM_SETTINGS);
         checkContains(tr, PROP_SETTINGS);
         checkNoContains(tr, LOCALE_SETTINGS);
     }
 
     static void runTestOptionLocale() throws IOException {
-        TestHelper.TestResult tr = null;
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings:locale");
+        TestResult tr = null;
+        tr = doExec(javaCmd, "-XshowSettings:locale");
         checkNoContains(tr, VM_SETTINGS);
         checkNoContains(tr, PROP_SETTINGS);
         checkContains(tr, LOCALE_SETTINGS);
     }
 
     static void runTestBadOptions() throws IOException {
-        TestHelper.TestResult tr = null;
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettingsBadOption");
+        TestResult tr = null;
+        tr = doExec(javaCmd, "-XshowSettingsBadOption");
         checkNoContains(tr, VM_SETTINGS);
         checkNoContains(tr, PROP_SETTINGS);
         checkNoContains(tr, LOCALE_SETTINGS);
@@ -131,8 +131,8 @@
     }
 
     static void runTest7123582() throws IOException {
-        TestHelper.TestResult tr = null;
-        tr = TestHelper.doExec(TestHelper.javaCmd, "-XshowSettings", "-version");
+        TestResult tr = null;
+        tr = doExec(javaCmd, "-XshowSettings", "-version");
         if (!tr.isOK()) {
             System.out.println(tr.status);
             throw new RuntimeException("test fails");
--- a/test/tools/launcher/SomeException.java	Fri Jan 27 15:25:17 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2002, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- *
- *
- * Used by unresolvedExceptions.sh
- */
-
-public class SomeException extends RuntimeException {
-
-}
--- a/test/tools/launcher/Test7029048.java	Fri Jan 27 15:25:17 2012 -0800
+++ b/test/tools/launcher/Test7029048.java	Sat Jan 28 10:46:46 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2012, 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
@@ -25,7 +25,7 @@
  * @test
  * @bug 7029048
  * @summary Checks for LD_LIBRARY_PATH on *nixes
- * @compile -XDignore.symbol.file ExecutionEnvironment.java TestHelper.java Test7029048.java
+ * @compile -XDignore.symbol.file ExecutionEnvironment.java Test7029048.java
  * @run main Test7029048
  */
 
@@ -42,7 +42,7 @@
 import java.util.List;
 import java.util.Map;
 
-public class Test7029048 {
+public class Test7029048 extends TestHelper {
 
     static int passes = 0;
     static int errors = 0;
@@ -62,7 +62,7 @@
 
     private static final File dstLibDir = new File("lib");
     private static final File dstLibArchDir =
-            new File(dstLibDir, TestHelper.getJreArch());
+            new File(dstLibDir, getJreArch());
 
     private static final File dstServerDir = new File(dstLibArchDir, "server");
     private static final File dstServerLibjvm = new File(dstServerDir, LIBJVM);
@@ -78,8 +78,8 @@
     private static final Map<String, String> env = new HashMap<>();
 
     static {
-        if (TestHelper.isDualMode) {
-            dstOtherArchDir = new File(dstLibDir, TestHelper.getComplementaryJreArch());
+        if (isDualMode) {
+            dstOtherArchDir = new File(dstLibDir, getComplementaryJreArch());
             dstOtherServerDir = new File(dstOtherArchDir, "server");
             dstOtherServerLibjvm = new File(dstOtherServerDir, LIBJVM);
         } else {
@@ -106,10 +106,10 @@
         List<String> cmdsList = new ArrayList<>();
 
         // only for a dual-mode system
-        if (want64 && TestHelper.isDualMode) {
-            cmdsList.add(TestHelper.java64Cmd);
+        if (want64 && isDualMode) {
+            cmdsList.add(java64Cmd);
         } else {
-            cmdsList.add(TestHelper.javaCmd); // a 32-bit java command for all
+            cmdsList.add(javaCmd); // a 32-bit java command for all
         }
 
         /*
@@ -127,18 +127,18 @@
         cmdsList.add("-jar");
         cmdsList.add(ExecutionEnvironment.testJarFile.getAbsolutePath());
         String[] cmds = new String[cmdsList.size()];
-        TestHelper.TestResult tr = TestHelper.doExec(env, cmdsList.toArray(cmds));
+        TestResult tr = doExec(env, cmdsList.toArray(cmds));
         analyze(tr, nLLPComponents, caseID);
     }
 
     // no cross launch, ie. no change to the data model.
     static void run(Map<String, String> env, int nLLPComponents, String caseID)
             throws IOException {
-        boolean want32 = TestHelper.is32Bit;
+        boolean want32 = is32Bit;
         run(want32, null, env, nLLPComponents, caseID);
     }
 
-    static void analyze(TestHelper.TestResult tr, int nLLPComponents, String caseID) {
+    static void analyze(TestResult tr, int nLLPComponents, String caseID) {
         String envValue = getValue(LD_LIBRARY_PATH, tr.testOutput);
        /*
         * the envValue can never be null, since the test code should always
@@ -189,12 +189,12 @@
             switch (v) {
                 case LLP_SET_WITH_JVM:
                     // copy the files into the directory structures
-                    TestHelper.copyFile(srcLibjvmSo, dstServerLibjvm);
+                    copyFile(srcLibjvmSo, dstServerLibjvm);
                     // does not matter if it is client or a server
-                    TestHelper.copyFile(srcLibjvmSo, dstClientLibjvm);
+                    copyFile(srcLibjvmSo, dstClientLibjvm);
                     // does not matter if the arch do not match either
-                    if (TestHelper.isDualMode) {
-                        TestHelper.copyFile(srcLibjvmSo, dstOtherServerLibjvm);
+                    if (isDualMode) {
+                        copyFile(srcLibjvmSo, dstOtherServerLibjvm);
                     }
                     desc = "LD_LIBRARY_PATH should be set";
                     break;
@@ -211,7 +211,7 @@
                         Files.deleteIfExists(dstServerLibjvm.toPath());
                     }
 
-                    if (TestHelper.isDualMode) {
+                    if (isDualMode) {
                         if (!dstOtherServerDir.exists()) {
                             Files.createDirectories(dstOtherServerDir.toPath());
                         } else {
@@ -223,7 +223,7 @@
                     break;
                 case LLP_SET_NON_EXISTENT_PATH:
                     if (dstLibDir.exists()) {
-                        TestHelper.recursiveDelete(dstLibDir);
+                        recursiveDelete(dstLibDir);
                     }
                     desc = "LD_LIBRARY_PATH should not be set";
                     break;
@@ -245,18 +245,18 @@
             env.put(LD_LIBRARY_PATH, dstClientDir.getAbsolutePath());
             run(env, v.value + 1, "Case 2: " + desc);
 
-            if (!TestHelper.isDualMode) {
+            if (!isDualMode) {
                 continue; // nothing more to do for Linux
             }
 
             // Tests applicable only to solaris.
 
             // initialize test variables for dual mode operations
-            final File dst32ServerDir = TestHelper.is32Bit
+            final File dst32ServerDir = is32Bit
                     ? dstServerDir
                     : dstOtherServerDir;
 
-            final File dst64ServerDir = TestHelper.is64Bit
+            final File dst64ServerDir = is64Bit
                     ? dstServerDir
                     : dstOtherServerDir;
 
@@ -268,7 +268,7 @@
             env.clear();
             env.put(LD_LIBRARY_PATH_32, dst32ServerDir.getAbsolutePath());
             env.put(LD_LIBRARY_PATH_64, dst64ServerDir.getAbsolutePath());
-            run(TestHelper.is32Bit, null, env, v.value + 1, "Case 3: " + desc);
+            run(is32Bit, null, env, v.value + 1, "Case 3: " + desc);
 
             /*
              * Case 4: we are in dual mode environment, running 64-bit then
@@ -276,7 +276,7 @@
              * java32 -d64, LLP_64 is relevant, LLP_32 is ignored
              * java64 -d32, LLP_32 is relevant, LLP_64 is ignored
              */
-            if (TestHelper.dualModePresent()) {
+            if (dualModePresent()) {
                 run(true, "-d64", env, v.value + 1, "Case 4A: " + desc);
                 run(false,"-d32", env, v.value + 1, "Case 4B: " + desc);
             }
@@ -285,7 +285,7 @@
     }
 
     public static void main(String... args) throws Exception {
-        if (TestHelper.isWindows) {
+        if (isWindows) {
             System.out.println("Warning: noop on windows");
             return;
         }
@@ -297,13 +297,13 @@
         if (errors > 0) {
             throw new Exception("Test7029048: FAIL: with "
                     + errors + " errors and passes " + passes);
-        } else if (TestHelper.dualModePresent() && passes < 15) {
+        } else if (dualModePresent() && passes < 15) {
             throw new Exception("Test7029048: FAIL: " +
                     "all tests did not run, expected " + 15 + " got " + passes);
-        } else if (TestHelper.isSolaris && passes < 9) {
+        } else if (isSolaris && passes < 9) {
             throw new Exception("Test7029048: FAIL: " +
                     "all tests did not run, expected " + 9 + " got " + passes);
-        } else if (TestHelper.isLinux && passes < 6) {
+        } else if (isLinux && passes < 6) {
              throw new Exception("Test7029048: FAIL: " +
                     "all tests did not run, expected " + 6 + " got " + passes);
         } else {
--- a/test/tools/launcher/TestHelper.java	Fri Jan 27 15:25:17 2012 -0800
+++ b/test/tools/launcher/TestHelper.java	Sat Jan 28 10:46:46 2012 -0800
@@ -29,6 +29,7 @@
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.io.PrintStream;
+import java.nio.charset.Charset;
 import java.nio.file.attribute.BasicFileAttributes;
 import java.nio.file.Files;
 import java.nio.file.FileVisitResult;
@@ -36,17 +37,18 @@
 import java.nio.file.Path;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Locale;
 import java.util.Map;
 import javax.tools.JavaCompiler;
 import javax.tools.ToolProvider;
 
 import static java.nio.file.StandardCopyOption.*;
+import static java.nio.file.StandardOpenOption.*;
 
 /**
  * This class provides some common utilities for the launcher tests.
  */
-public enum TestHelper {
-    INSTANCE;
+public class TestHelper {
     // commonly used jtreg constants
     static final File TEST_CLASSES_DIR;
     static final File TEST_SOURCES_DIR;
@@ -73,9 +75,14 @@
     static final boolean isDualMode = isSolaris;
     static final boolean isSparc = System.getProperty("os.arch").startsWith("sparc");
 
+    // make a note of the golden default locale
+    static final Locale DefaultLocale = Locale.getDefault();
+
     static final String JAVA_FILE_EXT  = ".java";
     static final String CLASS_FILE_EXT = ".class";
     static final String JAR_FILE_EXT   = ".jar";
+    static final String JLDEBUG_KEY     = "_JAVA_LAUNCHER_DEBUG";
+    static final String EXPECTED_MARKER = "TRACER_MARKER:About to EXEC";
 
     static int testExitValue = 0;
 
@@ -197,6 +204,19 @@
     }
 
     /*
+     * A convenience method to compile java files.
+     */
+    static void compile(String... compilerArgs) {
+        if (compiler.run(null, null, null, compilerArgs) != 0) {
+            String sarg = "";
+            for (String x : compilerArgs) {
+                sarg.concat(x + " ");
+            }
+            throw new Error("compilation failed: " + sarg);
+        }
+    }
+
+    /*
      * A generic jar file creator to create a java file, compile it
      * and jar it up, a specific Main-Class entry name in the
      * manifest can be specified or a null to use the sole class file name
@@ -255,6 +275,11 @@
         Files.copy(src.toPath(), dst.toPath(), COPY_ATTRIBUTES, REPLACE_EXISTING);
     }
 
+    static void createFile(File outFile, List<String> content) throws IOException {
+        Files.write(outFile.getAbsoluteFile().toPath(), content,
+                Charset.defaultCharset(), CREATE_NEW);
+    }
+
     static void recursiveDelete(File target) throws IOException {
         if (!target.exists()) {
             return;
@@ -337,6 +362,10 @@
         };
     }
 
+    static boolean isEnglishLocale() {
+        return Locale.getDefault().getLanguage().equals("en");
+    }
+
     /*
      * A class to encapsulate the test results and stuff, with some ease
      * of use methods to check the test results.
--- a/test/tools/launcher/UnicodeCleanup.java	Fri Jan 27 15:25:17 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,69 +0,0 @@
-/*
- * Copyright (c) 2007, 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
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-
-/*
- *
- *
- * Used by UnicodeTest.sh.
- *
- * Recursively deletes the given file/directory and its contents.
- * Equivalent to "rm -rf args...", but on NT-based Windows can
- * handle files with full Unicode names inside the given directories
- * while shells are generally limited to names using the system encoding.
- *
- * @author Norbert Lindenberg
- */
-
-
-
-import java.io.File;
-
-public class UnicodeCleanup {
-
-    public static void main(String[] args) {
-
-        for (int i = 0; i < args.length; i++) {
-            delete(new File(args[i]));
-        }
-    }
-
-    private static void delete(File file) {
-        // paranoia is healthy in rm -rf
-        String name = file.toString();
-        if (name.equals(".") || name.equals("..") ||
-                name.endsWith(File.separator + ".") ||
-                name.endsWith(File.separator + "..")) {
-            throw new RuntimeException("too risky to process: " + name);
-        }
-        if (file.isDirectory()) {
-            File[] contents = file.listFiles();
-            for (int i = 0; i < contents.length; i++) {
-                delete(contents[i]);
-            }
-        }
-        if (!file.delete()) {
-            throw new RuntimeException("Unable to delete " + file);
-        }
-    }
-}
--- a/test/tools/launcher/UnicodeTest.java	Fri Jan 27 15:25:17 2012 -0800
+++ b/test/tools/launcher/UnicodeTest.java	Sat Jan 28 10:46:46 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2012, 2012 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
@@ -21,12 +21,18 @@
  * questions.
  */
 
+/*
+ * @test
+ * @bug 5030265
+ * @compile  -XDignore.symbol.file UnicodeTest.java
+ * @run main/othervm UnicodeTest
+ * @summary Verify that the J2RE can handle all legal Unicode characters
+ *          in class names unless limited by the file system encoding
+ *          or the encoding used for command line arguments.
+ * @author Norbert Lindenberg, ksrini
+ */
 
 /*
- *
- *
- * Used by UnicodeTest.sh.
- *
  * This class creates Java source files using Unicode characters
  * that test the limits of what's possible
  * - in situations where the platform encoding imposes limits
@@ -35,38 +41,126 @@
  *   (file system access in UTF-8 locales and on Windows 2000++,
  *    jar file contents)
  *
- * @author Norbert Lindenberg
+ * This test needs to be run in othervm as the locale is reset.
  */
 
-
-
+import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
 import java.nio.charset.Charset;
 import java.util.Locale;
 
-public class UnicodeTest {
+public class UnicodeTest extends TestHelper {
+    static final File UnicodeTestSrc        = new File("UnicodeTest-src");
+    static final File UnicodeTestClasses    = new File("UnicodeTest-classes");
+    static final String UnicodeTestJarName  = "UnicodeTest" + JAR_FILE_EXT;
+    static final File UnicodeTestJar        = new File(UnicodeTestJarName);
+    static final File SolarisUnicodeTestJar = new File(TEST_SOURCES_DIR,
+                                                       UnicodeTestJarName);
 
-    public static void main(String[] args) throws Exception {
+    /*
+     * the main method is a port of the shell based test to a java, this
+     * eliminates the need for MKS on windows, thus we can rely on consistent
+     * results regardless of the shell being used.
+     */
+    public static void main(String... args) throws Exception {
+        System.out.println("creating test source files");
+        UnicodeTestSrc.mkdirs();
+        UnicodeTestClasses.mkdirs();
+        String classname = generateSources();
+        File javaFile = new File(UnicodeTestSrc, classname + JAVA_FILE_EXT);
+        System.out.println("building test apps");
+        compile("-encoding", "UTF-8",
+                "-sourcepath", UnicodeTestSrc.getAbsolutePath(),
+                "-d", UnicodeTestClasses.getAbsolutePath(),
+                javaFile.getAbsolutePath());
 
+        createJar("-cvfm", UnicodeTestJar.getAbsolutePath(),
+                  new File(UnicodeTestSrc, "MANIFEST.MF").getAbsolutePath(),
+                  "-C", UnicodeTestClasses.getAbsolutePath(), ".");
+
+        if (!UnicodeTestJar.exists()) {
+            throw new Error("failed to create " + UnicodeTestJar.getAbsolutePath());
+        }
+
+        System.out.println("running test app using class file");
+        TestResult tr = doExec(javaCmd,
+                        "-cp", UnicodeTestClasses.getAbsolutePath(), classname);
+        if (!tr.isOK()) {
+            System.out.println(tr);
+            throw new RuntimeException("test fails");
+        }
+
+        System.out.println("delete generated files with non-ASCII names");
+        recursiveDelete(UnicodeTestSrc);
+        recursiveDelete(UnicodeTestClasses);
+
+        /*
+         * test in whatever the default locale is
+         */
+        runJarTests();
+
+        /*
+         * if the Japanese locale is available, test in that locale as well
+         */
+        if (setLocale(Locale.JAPANESE)) {
+            runJarTests();
+        }
+
+       /*
+        * if we can switch to a C locale, then test whether jar files with
+        * non-ASCII characters in the manifest still work in this crippled
+        * environment
+        */
+        if (setLocale(Locale.ENGLISH)) {
+            runJarTests();
+        }
+        // thats it we are outta here
+    }
+
+    static void runJarTests() {
+        System.out.println("running test app using newly built jar file in " +
+                Locale.getDefault());
+        runTest(UnicodeTestJar);
+
+        System.out.println("running test app using jar file " +
+                "(built with Solaris UTF-8 locale) in " + Locale.getDefault());
+        runTest(SolarisUnicodeTestJar);
+    }
+
+    static void runTest(File testJar) {
+        TestResult tr = doExec(javaCmd, "-jar", testJar.getAbsolutePath());
+        if (!tr.isOK()) {
+            System.out.println(tr);
+            throw new RuntimeException("test fails");
+        }
+    }
+
+    static boolean setLocale(Locale desired) {
+        if (Locale.getDefault().equals(desired)) {
+            return true;  // already set nothing more
+        }
+        for (Locale l : Locale.getAvailableLocales()) {
+            if (l == desired) {
+                Locale.setDefault(l);
+                return true;
+            }
+        }
+        return false;
+    }
+
+    static String generateSources() throws Exception {
         String commandLineClassNameSuffix = commandLineClassNameSuffix();
         String commandLineClassName = "ClassA" + commandLineClassNameSuffix;
-        String manifestClassName;
-        if (hasUnicodeFileSystem()) {
-            manifestClassName = "ClassB" + unicode;
-        } else {
-            manifestClassName = "ClassB" + commandLineClassNameSuffix;
-        }
+        String manifestClassName = "ClassB" +
+                (hasUnicodeFileSystem() ? unicode : commandLineClassNameSuffix);
 
         generateSource(commandLineClassName, manifestClassName);
         generateSource(manifestClassName, commandLineClassName);
         generateManifest(manifestClassName);
-
-        System.out.println(commandLineClassName);
+        return commandLineClassName;
     }
 
-    private static final String fileSeparator = System.getProperty("file.separator");
-    private static final String osName = System.getProperty("os.name");
     private static final String defaultEncoding = Charset.defaultCharset().name();
 
     // language names taken from java.util.Locale.getDisplayLanguage for the respective language
@@ -132,12 +226,7 @@
             { "tis-620",        thai,           null            },
         };
 
-        int column;
-        if (osName.startsWith("Windows")) {
-            column = 2;
-        } else {
-            column = 1;
-        }
+        int column = isWindows ? 2 : 1;
         for (int i = 0; i < names.length; i++) {
              if (names[i][0].equalsIgnoreCase(defaultEncoding)) {
                  return names[i][column];
@@ -147,17 +236,12 @@
     }
 
     private static boolean hasUnicodeFileSystem() {
-        if (osName.startsWith("Windows")) {
-            return ! osName.startsWith("Windows 9") &&
-                   ! osName.equals("Windows Me");
-        } else {
-            return defaultEncoding.equalsIgnoreCase("UTF-8");
-        }
+        return (isWindows) ? true : defaultEncoding.equalsIgnoreCase("UTF-8");
     }
 
     private static void generateSource(String thisClass, String otherClass) throws Exception {
-        String fileName = "UnicodeTest-src" + fileSeparator + thisClass + ".java";
-        OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(fileName), "UTF-8");
+        File file = new File(UnicodeTestSrc, thisClass + JAVA_FILE_EXT);
+        OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
         out.write("public class " + thisClass + " {\n");
         out.write("    public static void main(String[] args) {\n");
         out.write("        if (!" + otherClass + "." + otherClass.toLowerCase() + "().equals(\"" + otherClass + "\")) {\n");
@@ -172,8 +256,8 @@
     }
 
     private static void generateManifest(String mainClass) throws Exception {
-        String fileName = "UnicodeTest-src" + fileSeparator + "MANIFEST.MF";
-        FileOutputStream out = new FileOutputStream(fileName);
+        File file = new File(UnicodeTestSrc, "MANIFEST.MF");
+        FileOutputStream out = new FileOutputStream(file);
         out.write("Manifest-Version: 1.0\n".getBytes("UTF-8"));
         // Header lines are limited to 72 bytes.
         // The manifest spec doesn't say we have to break at character boundaries,
--- a/test/tools/launcher/UnicodeTest.sh	Fri Jan 27 15:25:17 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-# Copyright (c) 2007, 2010, 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-
-# @test
-# @bug 5030265
-# @summary Verify that the J2RE can handle all legal Unicode characters
-#          in class names unless limited by the file system encoding
-#          or the encoding used for command line arguments.
-# @author Norbert Lindenberg
-
-
-# Verify directory context variables are set
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-JAVAC="${TESTJAVA}"/bin/javac
-JAVA="${TESTJAVA}"/bin/java
-JAR="${TESTJAVA}"/bin/jar
-
-mkdir UnicodeTest-src UnicodeTest-classes
-
-echo "creating test source files"
-"$JAVAC" -d . "${TESTSRC}"/UnicodeTest.java
-if [ "`uname -s | grep CYGWIN`" != "" ] ; then
-  CLASS_NAME=`"$JAVA" UnicodeTest | sed -e 's@\\r@@g' `
-else
-  CLASS_NAME=`"$JAVA" UnicodeTest`
-fi
-
-if [ "$CLASS_NAME" = "" ]
-then
-  echo "CLASS_NAME not generated.  Test failed."
-  exit 1
-fi
-
-echo "building test apps"
-"$JAVAC" -encoding UTF-8 -sourcepath UnicodeTest-src \
-    -d UnicodeTest-classes UnicodeTest-src/"${CLASS_NAME}".java || exit 1
-"$JAR" -cvfm UnicodeTest.jar UnicodeTest-src/MANIFEST.MF \
-    -C UnicodeTest-classes . || exit 1
-
-echo "running test app using class file"
-"$JAVA" -classpath UnicodeTest-classes "$CLASS_NAME" || exit 1
-
-echo "delete generated files with non-ASCII names"
-# do it now because on Unix they may not be accessible when locale changes
-# do it in Java because shells on Windows can't handle full Unicode
-"$JAVAC" -d . "${TESTSRC}"/UnicodeCleanup.java || exit 1
-"$JAVA" UnicodeCleanup UnicodeTest-src UnicodeTest-classes || exit 1
-
-echo "running test app using newly built jar file"
-"$JAVA" -jar UnicodeTest.jar || exit 1
-
-echo "running test app using jar file built in Solaris UTF-8 locale"
-"$JAVA" -jar "${TESTSRC}"/UnicodeTest.jar || exit 1
-
-# if we can switch to a C locale, then test whether jar files with
-# non-ASCII characters in the manifest still work in this crippled
-# environment
-if test -n "`locale -a 2>/dev/null | grep '^C$'`"
-then
-    LC_ALL=C
-    export LC_ALL
-
-    echo "running test app using newly built jar file in C locale"
-    "$JAVA" -jar UnicodeTest.jar || exit 1
-
-    echo "running test app using premade jar file in C locale"
-    "$JAVA" -jar "${TESTSRC}"/UnicodeTest.jar || exit 1
-fi
-
-exit 0
-
--- a/test/tools/launcher/UnresolvedExceptions.java	Fri Jan 27 15:25:17 2012 -0800
+++ b/test/tools/launcher/UnresolvedExceptions.java	Sat Jan 28 10:46:46 2012 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2012, 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
@@ -22,15 +22,39 @@
  */
 
 /*
- *
- *
- * Used by unresolvedExceptions.sh
+ * @test
+ * @bug 4529320
+ * @compile -XDignore.symbol.file UnresolvedExceptions.java
+ * @run main UnresolvedExceptions
+ * @summary Verifying jvm won't segv if exception not available
+ * @author Joseph D. Darcy, ksrini
  */
 
-public class UnresolvedExceptions  {
-    public static void main(String[] argv) throws SomeException {
-        // main is invoked from a shell so calling exit won't stop all
-        // tests.
-        System.exit(0);
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+
+public class UnresolvedExceptions extends TestHelper {
+
+    public static void main(String... args) throws Exception {
+        final String fname = "Foo";
+        List<String> buffer = new ArrayList<>();
+        buffer.add("public class " + fname + " {");
+        buffer.add("    public static void main(String[] argv) throws "
+                       + "Foo.SomeException {");
+        buffer.add("        System.exit(0);");
+        buffer.add("    }");
+        buffer.add("    static class SomeException extends RuntimeException{}");
+        buffer.add("}");
+
+        File testJavaFile = new File("Foo" + JAVA_FILE_EXT);
+        createFile(testJavaFile, buffer);
+        compile(testJavaFile.getName());
+        TestResult tr = doExec(javaCmd, "-cp", ".", fname);
+        if (!tr.isOK()) {
+            System.out.println(tr);
+            throw new RuntimeException("java -cp ... failed");
     }
 }
+}
--- a/test/tools/launcher/deleteI18n.sh	Fri Jan 27 15:25:17 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-#
-#
-# This file is used by test i18nTest.sh; this file is called to use
-# shell globbing to delete Java source and class files whose names
-# include non-ASCII characters.
-
-
-# Verify directory context variables are set
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-rm -f i18n*.java
-rm -f i18n*.class
-
-
--- a/test/tools/launcher/i18nTest.sh	Fri Jan 27 15:25:17 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,82 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4761384
-# @run shell deleteI18n.sh
-# @build CreatePlatformFile
-# @run main CreatePlatformFile
-# @run shell i18nTest.sh
-# @summary Test to see if class files with non-ASCII characters can be run
-# @author Joseph D. Darcy
-
-
-# Verify directory context variables are set
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-JAVAC="${TESTJAVA}/bin/javac -d . "
-JAVA="${TESTJAVA}/bin/java -classpath . "
-
-NAME=`ls i18n*.java | sed s/.java//`
-echo $NAME
-$JAVAC ${NAME}.java
-
-RESULT=$?
-case "$RESULT" in
-        0  )
-        ;;
-
-        * )
-	echo "Compile of i18n*.java failed."
-        exit 1
-esac
-
-$JAVA ${NAME}
-RESULT=$?
-
-case "$RESULT" in
-        0  )
-        exit 0;
-        ;;
-
-        * )
-	echo "Class $NAME did not run successfully."
-        exit 1
-esac
--- a/test/tools/launcher/unresolvedExceptions.sh	Fri Jan 27 15:25:17 2012 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#
-# Copyright (c) 2002, 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4529320
-# @build SomeException
-# @build UnresolvedExceptions
-# @clean SomeException
-# @run shell/timeout=60 unresolvedExceptions.sh
-# @summary Verifying jvm won't segv if exception not available
-# @author Joseph D. Darcy
-
-# Verify directory context variables are set
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-JAVA="${TESTJAVA}/bin/java"
-
-$JAVA -classpath ${TESTCLASSES} UnresolvedExceptions
-RESULT=$?
-
-case "$RESULT" in
-	0 | 1 )
-	exit 0;
-	;;
-
-	* )
-	exit 1
-esac