8006212: javac, convert jtreg tests from shell script to java
authorvromero
Tue, 19 Feb 2013 17:53:16 +0000
changeset 16304 475504933a2d
parent 16303 b5dca0b42963
child 16305 ee7f13d9d434
8006212: javac, convert jtreg tests from shell script to java Reviewed-by: jjg
langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java
langtools/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java
langtools/test/tools/apt/Basics/CheckAptIsRemovedTest.java
langtools/test/tools/apt/Basics/NullAPF.java
langtools/test/tools/apt/Basics/apt.sh
langtools/test/tools/apt/verifyVariables.sh
langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java
langtools/test/tools/javac/4846262/Test.java
langtools/test/tools/javac/4846262/Test.out
langtools/test/tools/javac/4846262/Test.sh
langtools/test/tools/javac/6302184/HiddenOptionsShouldUseGivenEncodingTest.java
langtools/test/tools/javac/6302184/T6302184.sh
langtools/test/tools/javac/ClassPathTest/ClassPathTest.java
langtools/test/tools/javac/ClassPathTest/ClassPathTest.sh
langtools/test/tools/javac/ClassPathTest/ClassPathTest1.java
langtools/test/tools/javac/ClassPathTest/ClassPathTest2.java
langtools/test/tools/javac/ClassPathTest/ClassPathTest3.java
langtools/test/tools/javac/ClassPathTest/bar/pkg/ClassPathTestAux2.java
langtools/test/tools/javac/ClassPathTest/foo/pkg/ClassPathTestAux1.java
langtools/test/tools/javac/ClassPathTest/pkg/ClassPathTestAux3.java
langtools/test/tools/javac/ExtDirs/ExtDirTest.java
langtools/test/tools/javac/ExtDirs/ExtDirTest_1.java
langtools/test/tools/javac/ExtDirs/ExtDirTest_2.java
langtools/test/tools/javac/ExtDirs/ExtDirTest_3.java
langtools/test/tools/javac/ExtDirs/ExtDirs.sh
langtools/test/tools/javac/MissingInclude.java
langtools/test/tools/javac/MissingInclude.sh
langtools/test/tools/javac/MissingInclude/MissingIncludeTest.java
langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh
langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClassesTest.java
langtools/test/tools/javac/ProtectedInnerClass/p1/ProtectedInnerClass1.java
langtools/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass2.java
langtools/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass3.java
langtools/test/tools/javac/T5090006/AssertionFailureTest.java
langtools/test/tools/javac/T5090006/T5090006.java
langtools/test/tools/javac/T5090006/compiler.sh
langtools/test/tools/javac/constDebug/ConstDebug.java
langtools/test/tools/javac/constDebug/ConstDebug.sh
langtools/test/tools/javac/constDebug/ConstDebugTest.java
langtools/test/tools/javac/fatalErrors/NoJavaLang.java
langtools/test/tools/javac/fatalErrors/NoJavaLang.out
langtools/test/tools/javac/fatalErrors/NoJavaLang.sh
langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java
langtools/test/tools/javac/innerClassFile/Driver.sh
langtools/test/tools/javac/innerClassFile/InnerClassFileTest.java
langtools/test/tools/javac/innerClassFile/x/B.java
langtools/test/tools/javac/innerClassFile/x/C.java
langtools/test/tools/javac/innerClassFile/y/Main.java
langtools/test/tools/javac/innerClassFile/y/R1.java
langtools/test/tools/javac/innerClassFile/y/R2.java
langtools/test/tools/javac/innerClassFile/y/R3.java
langtools/test/tools/javac/javazip/A.java
langtools/test/tools/javac/javazip/JavaZipTest.java
langtools/test/tools/javac/javazip/Test.sh
langtools/test/tools/javac/javazip/bad/B.java
langtools/test/tools/javac/javazip/good/B.java
langtools/test/tools/javac/lib/ToolBox.java
langtools/test/tools/javac/links/LinksTest.java
langtools/test/tools/javac/links/T.java
langtools/test/tools/javac/links/b/B.java
langtools/test/tools/javac/links/links.sh
langtools/test/tools/javac/newlines/NewLineTest.java
langtools/test/tools/javac/newlines/Newlines.sh
langtools/test/tools/javac/stackmap/StackMapTest.java
langtools/test/tools/javac/stackmap/T4955930.java
langtools/test/tools/javac/stackmap/T4955930.sh
langtools/test/tools/javac/unicode/SupplementaryJavaID6.java
langtools/test/tools/javac/unicode/SupplementaryJavaID6.sh
langtools/test/tools/javah/6257087/T6257087.java
langtools/test/tools/javah/6257087/foo.java
langtools/test/tools/javah/6257087/foo.sh
langtools/test/tools/javah/6257087/foo_bar.h
langtools/test/tools/javah/ConstMacroTest.sh
langtools/test/tools/javah/MissingParamClassException.java
langtools/test/tools/javah/MissingParamClassTest.sh
langtools/test/tools/javah/ParamClassTest.java
langtools/test/tools/javah/SubClassConsts.java
langtools/test/tools/javah/SubClassConsts.out
langtools/test/tools/javah/SubClassConsts.win
langtools/test/tools/javah/SuperClassConsts.java
langtools/test/tools/javah/T4942232/MissingParamClassTest.java
langtools/test/tools/javah/constMacroTest/ConstMacroTest.java
langtools/test/tools/javap/4798312/JavapShouldLoadClassesFromRTJarTest.java
langtools/test/tools/javap/4866831/PublicInterfaceTest.java
langtools/test/tools/javap/NotPackagePrivateInterface.java
langtools/test/tools/javap/PublicInterfaceTest.sh
langtools/test/tools/javap/pathsep.sh
langtools/test/tools/javap/stackmap/StackmapTest.java
langtools/test/tools/javap/stackmap/T6271292.java
langtools/test/tools/javap/stackmap/T6271292.out
langtools/test/tools/javap/stackmap/T6271292.sh
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Tue Feb 19 00:31:45 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java	Tue Feb 19 17:53:16 2013 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -121,19 +121,23 @@
         return result.toList();
     }
 
-    public Boolean call() {
+    public Main.Result doCall() {
         if (!used.getAndSet(true)) {
             initContext();
             notYetEntered = new HashMap<JavaFileObject, JCCompilationUnit>();
             compilerMain.setAPIMode(true);
             result = compilerMain.compile(args, classNames, context, fileObjects, processors);
             cleanup();
-            return result.isOK();
+            return result;
         } else {
             throw new IllegalStateException("multiple calls to method 'call'");
         }
     }
 
+    public Boolean call() {
+        return doCall().isOK();
+    }
+
     public void setProcessors(Iterable<? extends Processor> processors) {
         processors.getClass(); // null check
         // not mt-safe
--- a/langtools/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java	Tue Feb 19 00:31:45 2013 -0800
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/ArrayUtils.java	Tue Feb 19 17:53:16 2013 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -84,4 +84,18 @@
             return result;
         }
     }
+
+    public static <T> T[] concat(T[] anArr, T[] anotherArr) {
+        int newLength = anArr.length + anotherArr.length;
+        @SuppressWarnings("unchecked")
+        T[] result = (T[]) Array.newInstance(anArr.getClass().getComponentType(), newLength);
+        System.arraycopy(anArr, 0, result, 0, anArr.length);
+        System.arraycopy(anotherArr, 0, result, anArr.length, anotherArr.length);
+        return result;
+    }
+
+    @SuppressWarnings("unchecked")
+    public static <T> T[] concatOpen(T[] anArr, T... anotherArr) {
+        return concat(anArr, anotherArr);
+    }
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/apt/Basics/CheckAptIsRemovedTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249
+ * @summary Make sure apt is removed and doesn't come back
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main CheckAptIsRemovedTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+//original test: test/tools/apt/Basics/apt.sh
+public class CheckAptIsRemovedTest {
+    //I think this class can be let with the imports only and that should be enough for as test's purpose
+    private static final String NullAPFSrc =
+        "import com.sun.mirror.apt.*;\n" +
+        "import com.sun.mirror.declaration.*;\n" +
+        "import com.sun.mirror.type.*;\n" +
+        "import com.sun.mirror.util.*;\n" +
+        "import java.util.Collection;\n" +
+        "import java.util.Set;\n\n" +
+
+        "public class NullAPF implements AnnotationProcessorFactory {\n" +
+        "    static class NullAP implements AnnotationProcessor {\n" +
+        "        NullAP(AnnotationProcessorEnvironment ape) {}\n" +
+        "        public void process() {return;}\n" +
+        "    }\n\n" +
+
+        "    static Collection<String> supportedTypes;\n\n" +
+        "    static {\n" +
+        "        String types[] = {\"*\"};\n" +
+        "        supportedTypes = java.util.Arrays.asList(types);\n" +
+        "    }\n\n" +
+
+        "    public Collection<String> supportedOptions() {\n" +
+        "        return java.util.Collections.emptySet();\n" +
+        "    }\n\n" +
+
+        "    public Collection<String> supportedAnnotationTypes() {\n" +
+        "        return supportedTypes;\n" +
+        "    }\n\n" +
+
+        "    public AnnotationProcessor getProcessorFor(" +
+        "        Set<AnnotationTypeDeclaration> atds,\n" +
+        "        AnnotationProcessorEnvironment env) {\n" +
+        "        return new NullAP(env);\n" +
+        "    }\n" +
+        "}";
+
+    public static void main(String[] args) throws Exception {
+        String testJDK = System.getProperty("test.jdk");
+        Path aptLin = Paths.get(testJDK, "bin", "apt");
+        Path aptWin = Paths.get(testJDK, "bin", "apt.exe");
+
+//        if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then
+        if (Files.exists(aptLin) || Files.exists(aptWin)) {
+            throw new AssertionError("apt executable should not exist");
+        }
+
+//        JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
+//        $JAVAC ${TESTSRC}/NullAPF.java
+        Path classpath = Paths.get(testJDK, "lib", "tools.jar");
+        ToolBox.JavaToolArgs javacArgs =
+                new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+                .setOptions("-source", "1.5", "-sourcepath", ".",
+                    "-classpath", classpath.toString())
+                .setSources(NullAPFSrc);
+        ToolBox.javac(javacArgs);
+    }
+
+}
--- a/langtools/test/tools/apt/Basics/NullAPF.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-/*
- * Copyright (c) 2004, 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.
- */
-
-
-import com.sun.mirror.apt.*;
-import com.sun.mirror.declaration.*;
-import com.sun.mirror.type.*;
-import com.sun.mirror.util.*;
-
-import java.util.Collection;
-import java.util.Set;
-
-public class NullAPF implements AnnotationProcessorFactory {
-    static class NullAP implements AnnotationProcessor {
-        NullAP(AnnotationProcessorEnvironment ape) {
-        }
-
-        public void process() {
-            return;
-        }
-    }
-
-    static Collection<String> supportedTypes;
-
-    static {
-        String types[] = {"*"};
-        supportedTypes = java.util.Arrays.asList(types);
-    }
-
-    /*
-     * Processor doesn't examine any options.
-     */
-    public Collection<String> supportedOptions() {
-        return java.util.Collections.emptySet();
-    }
-
-    /*
-     * All annotation types are supported.
-     */
-    public Collection<String> supportedAnnotationTypes() {
-        return supportedTypes;
-    }
-
-    /*
-     * Return the same processor independent of what annotations are
-     * present, if any.
-     */
-    public AnnotationProcessor getProcessorFor(Set<AnnotationTypeDeclaration> atds,
-                                        AnnotationProcessorEnvironment env) {
-        return new NullAP(env);
-    }
-}
--- a/langtools/test/tools/apt/Basics/apt.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 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 4908512 5024825 4957203 4993280 4996963 6174696 6177059 7041249
-# @run shell ../verifyVariables.sh
-# @run shell apt.sh
-# @summary Make sure apt is removed and doesn't come back
-# @author Joseph D. Darcy
-
-OS=`uname -s`;
-case "${OS}" in
-        CYGWIN* )
-                DIFFOPTS="--strip-trailing-cr"
-        ;;
-
-	* )
-	;;
-esac
-
-# Verify apt executable does not exist
-if [ -f "${TESTJAVA}/bin/apt" -o -f "${TESTJAVA}/bin/apt.exe" ];then
-    echo "apt executable should not exist."
-    exit 1
-fi
-
-# Construct path to javac executable
-JAVAC="${TESTJAVA}/bin/javac ${TESTTOOLVMOPTS} -source 1.5 -sourcepath ${TESTSRC} -classpath ${TESTJAVA}/lib/tools.jar -d . "
-
-$JAVAC ${TESTSRC}/NullAPF.java
-RESULT=$?
-
-case "${RESULT}" in
-        0  )
-        echo "Compilation of apt-using source passed improperly."
-        exit 1
-	;;
-
-        * )
-	;;
-esac
--- a/langtools/test/tools/apt/verifyVariables.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 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.
-#
-
-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
-
-exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/4846262/CheckEBCDICLocaleTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4846262
+ * @summary check that javac operates correctly in EBCDIC locale
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main CheckEBCDICLocaleTest
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import com.sun.tools.javac.util.ArrayUtils;
+
+//original test: test/tools/javac/4846262/Test.sh
+public class CheckEBCDICLocaleTest {
+
+    private static final String TestSrc =
+        "public class Test {\n" +
+        "    public void test() {\n" +
+        "        abcdefg\n" +
+        "    }\n" +
+        "}";
+
+    private static final String TestOut =
+        "output/Test.java:3: error: not a statement\n" +
+        "        abcdefg\n" +
+        "        ^\n" +
+        "output/Test.java:3: error: ';' expected\n" +
+        "        abcdefg\n" +
+        "               ^\n" +
+        "2 errors\n";
+
+    public static void main(String[] args) throws Exception {
+        new CheckEBCDICLocaleTest().test();
+    }
+
+    public void test() throws Exception {
+        String native2asciiBinary = Paths.get(
+                System.getProperty("test.jdk"),"bin", "native2ascii").toString();
+        String testVMOpts = System.getProperty("test.tool.vm.opts");
+        String[] mainArgs = ToolBox.getJavacBin();
+
+        ToolBox.createJavaFileFromSource(TestSrc);
+        Files.createDirectory(Paths.get("output"));
+
+//"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java
+        ToolBox.AnyToolArgs nativeCmdParams =
+                new ToolBox.AnyToolArgs()
+                .setAllArgs(native2asciiBinary, testVMOpts,
+                    "-reverse", "-encoding", "IBM1047",
+                    "Test.java", "output/Test.java");
+        ToolBox.executeCommand(nativeCmdParams);
+
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp
+        ToolBox.AnyToolArgs javacParams =
+                new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+                .setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Duser.language=en",
+                "-J-Duser.region=US", "-J-Dfile.encoding=IBM1047",
+                "output/Test.java"))
+                .setErrOutput(new File("Test.tmp"));
+        ToolBox.executeCommand(javacParams);
+
+//"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out
+        nativeCmdParams.setAllArgs(native2asciiBinary, "-encoding", "IBM1047",
+                    "Test.tmp", "Test.out");
+        ToolBox.executeCommand(nativeCmdParams);
+
+//diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out
+        ToolBox.compareLines(Paths.get("Test.out"),
+                Arrays.asList(TestOut.split("\n")), null);
+
+    }
+
+}
--- a/langtools/test/tools/javac/4846262/Test.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,6 +0,0 @@
-/* /nodynamiccopyright/ */
-public class Test {
-    public void test() {
-        abcdefg
-    }
-}
--- a/langtools/test/tools/javac/4846262/Test.out	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,7 +0,0 @@
-Test.java:4: error: not a statement
-        abcdefg
-        ^
-Test.java:4: error: ';' expected
-        abcdefg
-               ^
-2 errors
--- a/langtools/test/tools/javac/4846262/Test.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-#!/bin/sh -f
-
-#
-# Copyright (c) 2005, 2011, 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 4846262
-# @summary check that javac operates correctly in EBCDIC locale
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    FS="/"
-    ;;
-  CYGWIN* )
-    FS="/"
-    DIFFOPTS="--strip-trailing-cr"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-rm -f Test.java Test.out
-
-"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -reverse -encoding IBM1047 ${TESTSRC}${FS}Test.java Test.java
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Duser.language=en -J-Duser.region=US -J-Dfile.encoding=IBM1047 Test.java 2>Test.tmp
-
-"${TESTJAVA}${FS}bin${FS}native2ascii" ${TESTTOOLVMOPTS} -encoding IBM1047 Test.tmp Test.out
-
-diff ${DIFFOPTS} -c "${TESTSRC}${FS}Test.out" Test.out
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6302184/HiddenOptionsShouldUseGivenEncodingTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 6302184 6350124 6357979
+ * @summary javac hidden options that generate source should use the given
+ * encoding, if available
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile -encoding iso-8859-1 -XD-printsource T6302184.java
+ * @run main HiddenOptionsShouldUseGivenEncodingTest
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/6302184/T6302184.sh
+public class HiddenOptionsShouldUseGivenEncodingTest {
+
+    public static void main(String[] args) throws Exception {
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -cp ${TC} -encoding iso-8859-1 -XD-printsource ${TS}${FS}T6302184.java 2>&1
+//diff ${DIFFOPTS} -c ${TC}${FS}T6302184.java ${TS}${FS}T6302184.out
+        Path path1 = Paths.get(System.getProperty("test.classes"), "T6302184.java");
+        Path path2 = Paths.get(System.getProperty("test.src"), "T6302184.out");
+        ToolBox.compareLines(path1, path2, "iso-8859-1");
+    }
+
+}
--- a/langtools/test/tools/javac/6302184/T6302184.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#! /bin/sh -f
-
-#
-# Copyright (c) 2005, 2009, 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 6302184 6350124 6357979
-# @summary javac hidden options that generate source should use the given encoding, if available
-# @run shell T6302184.sh
-
-TS=${TESTSRC-.}
-TC=${TESTCLASSES-.}
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    FS="/"
-    ;;
-  CYGWIN* )
-    FS="/"
-    DIFFOPTS="--strip-trailing-cr"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -cp ${TC} -encoding iso-8859-1 -XD-printsource ${TS}${FS}T6302184.java 2>&1
-diff ${DIFFOPTS} -c ${TC}${FS}T6302184.java ${TS}${FS}T6302184.out
-result=$?
-
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/ClassPathTest/ClassPathTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,148 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4241229 4785453
+ * @summary Test -classpath option and classpath defaults.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ClassPathTest
+ */
+
+import java.nio.file.Paths;
+import java.util.Map;
+import java.util.TreeMap;
+import com.sun.tools.javac.util.ArrayUtils;
+
+//original test: test/tools/javac/ClassPathTest/ClassPathTest.sh
+public class ClassPathTest {
+
+    private static final String ClassPathTest1Src =
+        "import pkg.*;\n" +
+        "public class ClassPathTest1 {\n" +
+        "    ClassPathTestAux1 x;\n" +
+        "}";
+
+    private static final String ClassPathTest2Src =
+        "import pkg.*;\n" +
+        "public class ClassPathTest2 {\n" +
+        "    ClassPathTestAux2 x;\n" +
+        "}";
+
+    private static final String ClassPathTest3Src =
+        "import pkg.*;\n" +
+        "public class ClassPathTest3 {\n" +
+        "    ClassPathTestAux3 x;\n" +
+        "}";
+
+    private static final String fooPkgClassPathTestAux1Src =
+        "package pkg;\n" +
+        "public class ClassPathTestAux1 {}";
+
+    private static final String barPkgClassPathTestAux2Src =
+        "package pkg;\n" +
+        "public class ClassPathTestAux2 {}";
+
+    private static final String pkgClassPathTestAux3Src =
+        "package pkg;\n" +
+        "public class ClassPathTestAux3 {}";
+
+    ProcessBuilder pb = null;
+
+    public static void main(String[] args) throws Exception {
+        new ClassPathTest().test();
+    }
+
+    public void test() throws Exception {
+        createOutputDirAndSourceFiles();
+        checkCompileCommands();
+    }
+
+    void createOutputDirAndSourceFiles() throws Exception {
+        //dirs and files creation
+        ToolBox.createJavaFileFromSource(ClassPathTest1Src);
+        ToolBox.createJavaFileFromSource(ClassPathTest2Src);
+        ToolBox.createJavaFileFromSource(ClassPathTest3Src);
+        ToolBox.createJavaFileFromSource(Paths.get("foo"),
+                fooPkgClassPathTestAux1Src);
+        ToolBox.createJavaFileFromSource(Paths.get("bar"),
+                barPkgClassPathTestAux2Src);
+        ToolBox.createJavaFileFromSource(pkgClassPathTestAux3Src);
+    }
+
+    void checkCompileCommands() throws Exception {
+        String[] mainArgs = ToolBox.getJavacBin();
+
+//        Without the -cp . parameter the command will fail seems like when called
+//        from the command line, the current dir is added to the classpath
+//        automatically but this is not happening when called using ProcessBuilder
+
+//        testJavac success ClassPathTest3.java
+        String[] commonArgs = ArrayUtils.concatOpen(mainArgs, "-cp", ".");
+
+        ToolBox.AnyToolArgs successParams =
+                new ToolBox.AnyToolArgs()
+                .setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest3.java"));
+        ToolBox.executeCommand(successParams);
+
+//        testJavac failure ClassPathTest1.java
+        ToolBox.AnyToolArgs failParams =
+                new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+                .setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest1.java"));
+        ToolBox.executeCommand(failParams);
+
+//        This is done inside the executeCommand method
+//        CLASSPATH=bar; export CLASSPATH
+
+        Map<String, String> extVars = new TreeMap<>();
+        extVars.put("CLASSPATH", "bar");
+
+//        testJavac success ClassPathTest2.java
+        successParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest2.java")).set(extVars);
+        ToolBox.executeCommand(successParams);
+
+//        testJavac failure ClassPathTest1.java
+        failParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest1.java")).set(extVars);
+        ToolBox.executeCommand(failParams);
+
+//        testJavac failure ClassPathTest3.java
+        failParams.setAllArgs(ArrayUtils.concatOpen(mainArgs, "ClassPathTest3.java"));
+        ToolBox.executeCommand(failParams);
+
+//        testJavac success -classpath foo ClassPathTest1.java
+
+        commonArgs = ArrayUtils.concatOpen(mainArgs, "-cp", "foo");
+        successParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest1.java"));
+        ToolBox.executeCommand(successParams);
+
+//        testJavac failure -classpath foo ClassPathTest2.java
+        failParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest2.java"));
+        ToolBox.executeCommand(failParams);
+
+//        testJavac failure -classpath foo ClassPathTest3.java
+        failParams.setAllArgs(ArrayUtils.concatOpen(commonArgs, "ClassPathTest3.java"));
+        ToolBox.executeCommand(failParams);
+    }
+
+}
--- a/langtools/test/tools/javac/ClassPathTest/ClassPathTest.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,134 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2011, 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 4241229 4785453
-# @summary Test -classpath option and classpath defaults.
-# @author maddox
-#
-# @run shell/timeout=180 ClassPathTest.sh
-
-# TODO: Should test sourcepath and classpath separately.
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-javac="${TESTJAVA}${FS}bin${FS}javac"
-
-cleanup() {
-	rm -f *.class pkg${FS}*.class foo${FS}pkg${FS}*.class bar${FS}pkg${FS}*.class
-	cp -rf $TESTSRC${FS}* .
-}
-
-fail() {
-	echo "FAIL: $1"
-	failed="yes"
-}
-
-# report expectedResult $?
-report() {
-	if   test "$1" = "success" -a "$2" = 0; then
-		echo "PASS: succeeded as expected"
-	elif test "$1" = "failure" -a "$2" != 0; then
-		echo "PASS: failed as expected"
-	elif test "$1" = "success" -a "$2" != 0; then
-		fail "test failed unexpectedly"
-	elif test "$1" = "failure" -a "$2" = 0; then
-		fail "test succeeded unexpectedly"
-	else
-		fail "internal error"
-	fi
-}
-
-# testJavac expectedResult javacArgs...
-testJavac() {
-	expectedResult="$1"; shift
-	cleanup
-	echo $javac ${TESTTOOLVMOPTS} "$@"
-	"$javac" ${TESTTOOLVMOPTS} "$@"
-	report $expectedResult $?
-}
-
-unset CLASSPATH
-
-# classpath should default to current directory
-
-testJavac success ClassPathTest3.java
-testJavac failure ClassPathTest1.java
-
-# if CLASSPATH is set, it should be honored
-
-CLASSPATH=bar; export CLASSPATH
-
-testJavac success ClassPathTest2.java
-testJavac failure ClassPathTest1.java
-testJavac failure ClassPathTest3.java
-
-# -classpath option should override default
-
-testJavac success -classpath foo ClassPathTest1.java
-testJavac failure -classpath foo ClassPathTest2.java
-testJavac failure -classpath foo ClassPathTest3.java
-
-if test -n "$failed"; then
-	echo "Some tests failed"
-	exit 1
-else
-	echo PASS: all tests gave expected results
-	exit 0
-fi
--- a/langtools/test/tools/javac/ClassPathTest/ClassPathTest1.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-import pkg.*;
-
-public class ClassPathTest1 {
-    ClassPathTestAux1 x;
-
-}
--- a/langtools/test/tools/javac/ClassPathTest/ClassPathTest2.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-import pkg.*;
-
-public class ClassPathTest2 {
-    ClassPathTestAux2 x;
-
-}
--- a/langtools/test/tools/javac/ClassPathTest/ClassPathTest3.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-import pkg.*;
-
-public class ClassPathTest3 {
-    ClassPathTestAux3 x;
-
-}
--- a/langtools/test/tools/javac/ClassPathTest/bar/pkg/ClassPathTestAux2.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-package pkg;
-
-public class ClassPathTestAux2 {}
--- a/langtools/test/tools/javac/ClassPathTest/foo/pkg/ClassPathTestAux1.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-package pkg;
-
-public class ClassPathTestAux1 {}
--- a/langtools/test/tools/javac/ClassPathTest/pkg/ClassPathTestAux3.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-package pkg;
-
-public class ClassPathTestAux3 {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/ExtDirs/ExtDirTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,176 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4204897 4256097 4785453 4863609
+ * @summary Test that '.jar' files in -extdirs are found.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ExtDirTest
+ */
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
+import java.util.List;
+
+//original test: test/tools/javac/ExtDirs/ExtDirs.sh
+public class ExtDirTest {
+
+    private static final String ExtDirTestClass1Src =
+        "package pkg1;\n" +
+        "\n" +
+        "public class ExtDirTestClass1 {}";
+
+    private static final String ExtDirTestClass2Src =
+        "package pkg2;\n" +
+        "\n" +
+        "public class ExtDirTestClass2 {}";
+
+    private static final String ExtDirTest_1Src =
+        "import pkg1.*;\n" +
+        "\n" +
+        "public class ExtDirTest_1 {\n" +
+        "  ExtDirTestClass1 x;\n" +
+        "}";
+
+    private static final String ExtDirTest_2Src =
+        "import pkg1.*;\n" +
+        "import pkg2.*;\n" +
+        "\n" +
+        "public class ExtDirTest_2 {\n" +
+        "  ExtDirTestClass1 x;\n" +
+        "  ExtDirTestClass2 y;\n" +
+        "}";
+
+    private static final String ExtDirTest_3Src =
+        "import pkg1.*;\n" +
+        "import pkg2.*;\n" +
+        "\n" +
+        "public class ExtDirTest_3 {\n" +
+        "  ExtDirTestClass1 x;\n" +
+        "  ExtDirTestClass2 y;\n" +
+        "}";
+
+    private static final String jar1Manifest =
+        "Manifest-Version: 1.0\n" +
+        "\n" +
+        "Name: pkg1/ExtDirTestClass1.class\n" +
+        "Digest-Algorithms: SHA MD5 \n" +
+        "SHA-Digest: 9HEcO9LJmND3cvOlq/AbUsbD9S0=\n" +
+        "MD5-Digest: hffPBwfqcUcnEdNv4PXu1Q==\n" +
+        "\n" +
+        "Name: pkg1/ExtDirTestClass1.java\n" +
+        "Digest-Algorithms: SHA MD5 \n" +
+        "SHA-Digest: 2FQVe6w3n2Ma1ACYpe8a988EBU8=\n" +
+        "MD5-Digest: /Ivr4zVI9MSM26NmqWtZpQ==\n";
+
+    private static final String jar2Manifest =
+        "Manifest-Version: 1.0\n" +
+        "\n" +
+        "Name: pkg2/ExtDirTestClass2.class\n" +
+        "Digest-Algorithms: SHA MD5 \n" +
+        "SHA-Digest: elbPaqWf8hjj1+ZkkdW3PGTsilo=\n" +
+        "MD5-Digest: 57Nn0e2t1yEQfu/4kSw8yg==\n" +
+        "\n" +
+        "Name: pkg2/ExtDirTestClass2.java\n" +
+        "Digest-Algorithms: SHA MD5 \n" +
+        "SHA-Digest: ILJOhwHg5US+yuw1Sc1d+Avu628=\n" +
+        "MD5-Digest: j8wnz8wneEcuJ/gjXBBQNA==\n";
+
+    List<String> ouputDirParam = Arrays.asList("-d", ".");
+
+    public static void main(String args[]) throws Exception {
+        new ExtDirTest().run();
+    }
+
+    void run() throws Exception {
+        createJars();
+        compileWithExtDirs();
+    }
+
+    void createJars() throws Exception {
+
+//        for i in 1 2 3; do
+//            if test ! -d ext${i}; then mkdir ext${i}; fi
+//            cp ${TESTSRC}${FS}ext${i}${FS}*.jar ext${i}
+//        done
+        sun.tools.jar.Main jarGenerator =
+                new sun.tools.jar.Main(System.out, System.err, "jar");
+
+        ToolBox.JavaToolArgs javacParams =
+                new ToolBox.JavaToolArgs()
+                .setOptions(ouputDirParam)
+                .setSources(ExtDirTestClass1Src);
+        ToolBox.javac(javacParams);
+
+        ToolBox.writeFile(Paths.get("pkg1", "MANIFEST.MF"), jar1Manifest);
+        jarGenerator.run(new String[] {"cfm", "pkg1.jar", "pkg1/MANIFEST.MF",
+            "pkg1/ExtDirTestClass1.class"});
+
+        javacParams.setSources(ExtDirTestClass2Src);
+        ToolBox.javac(javacParams);
+
+        ToolBox.writeFile(Paths.get("pkg2", "MANIFEST.MF"), jar2Manifest);
+        jarGenerator.run(new String[] {"cfm", "pkg2.jar", "pkg2/MANIFEST.MF",
+            "pkg2/ExtDirTestClass2.class"});
+
+        ToolBox.copyFile(Paths.get("ext1", "pkg1.jar"), Paths.get("pkg1.jar"));
+        ToolBox.copyFile(Paths.get("ext2", "pkg2.jar"), Paths.get("pkg2.jar"));
+        ToolBox.copyFile(Paths.get("ext3", "pkg1.jar"), Paths.get("pkg1.jar"));
+        ToolBox.copyFile(Paths.get("ext3", "pkg2.jar"), Paths.get("pkg2.jar"));
+
+        Files.delete(Paths.get("pkg1.jar"));
+        Files.delete(Paths.get("pkg2.jar"));
+
+        Files.delete(Paths.get("pkg1", "ExtDirTestClass1.class"));
+        Files.delete(Paths.get("pkg1", "MANIFEST.MF"));
+        Files.delete(Paths.get("pkg1"));
+        Files.delete(Paths.get("pkg2", "ExtDirTestClass2.class"));
+        Files.delete(Paths.get("pkg2", "MANIFEST.MF"));
+        Files.delete(Paths.get("pkg2"));
+    }
+
+    void compileWithExtDirs() throws Exception {
+
+//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
+        ToolBox.JavaToolArgs params =
+                new ToolBox.JavaToolArgs()
+                .setOptions("-d", ".", "-extdirs", "ext1")
+                .setSources(ExtDirTest_1Src);
+        ToolBox.javac(params);
+
+//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
+        params.setOptions("-d", ".", "-extdirs", "ext1" + File.pathSeparator + "ext2")
+                .setSources(ExtDirTest_2Src);
+        ToolBox.javac(params);
+
+//"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
+        params.setOptions("-d", ".", "-extdirs", "ext3")
+                .setSources(ExtDirTest_3Src);
+        ToolBox.javac(params);
+    }
+
+}
--- a/langtools/test/tools/javac/ExtDirs/ExtDirTest_1.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-import pkg1.*;
-
-public class ExtDirTest_1 {
-  ExtDirTestClass1 x;
-}
--- a/langtools/test/tools/javac/ExtDirs/ExtDirTest_2.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-import pkg1.*;
-import pkg2.*;
-
-public class ExtDirTest_2 {
-  ExtDirTestClass1 x;
-  ExtDirTestClass2 y;
-}
--- a/langtools/test/tools/javac/ExtDirs/ExtDirTest_3.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 1999, 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.
- */
-
-import pkg1.*;
-import pkg2.*;
-
-public class ExtDirTest_3 {
-  ExtDirTestClass1 x;
-  ExtDirTestClass2 y;
-}
--- a/langtools/test/tools/javac/ExtDirs/ExtDirs.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,100 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2011, 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 4204897 4256097 4785453 4863609
-# @summary Test that '.jar' files in -extdirs are found.
-# @author maddox
-#
-# @run shell/timeout=180 ExtDirs.sh
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";" # native PS, not Cygwin PS
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-fail() {
-	echo 'FAIL: unexpected result encountered'
-        exit 1
-}
-
-javac="${TESTJAVA}${FS}bin${FS}javac"
-
-for i in 1 2 3; do
-    if test ! -d ext${i}; then mkdir ext${i}; fi
-    cp ${TESTSRC}${FS}ext${i}${FS}*.jar ext${i}
-done
-
-echo "Test 1"
-"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1 "${TESTSRC}${FS}ExtDirTest_1.java"
-if [ $? -ne 0 ] ; then fail ; fi
-
-echo "Test 2"
-"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext1${PS}ext2 "${TESTSRC}${FS}ExtDirTest_2.java"
-if [ $? -ne 0 ] ; then fail ; fi
-
-echo "Test 3"
-"$javac" ${TESTTOOLVMOPTS} -d . -extdirs ext3 "${TESTSRC}${FS}ExtDirTest_3.java"
-if [ $? -ne 0 ] ; then fail ; fi
-
-echo PASS: all tests gave expected results
-exit 0
--- a/langtools/test/tools/javac/MissingInclude.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2001, 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 4509051 4785453
- * @summary javac <AT>sourcefiles should catch Exception, when sourcefiles doesn't exist.
- * @author gafter
- *
- * @run shell MissingInclude.sh
- */
-
-class MissingInclude {}
--- a/langtools/test/tools/javac/MissingInclude.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2001, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TMP1=OUTPUT.txt
-
-cp "${TESTSRC}${FS}MissingInclude.java" .
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} @/nonexistent_file MissingInclude.java 2> ${TMP1}
-result=$?
-cat ${TMP1}
-rm ${TMP1}
-
-if [ $result -eq 0 ]
-then
-  echo "Failed"
-  exit 1
-else
-  echo "Passed"
-  exit 0
-fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/MissingInclude/MissingIncludeTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4509051 4785453
+ * @summary javac <AT>sourcefiles should catch Exception, when sourcefiles
+ * doesn't exist.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main MissingIncludeTest
+ */
+
+//original test: test/tools/javac/MissingInclude.sh
+public class MissingIncludeTest {
+
+    private static final String MissingIncludeSrc =
+        "class MissingInclude {}";
+
+    public static void main(String[] args) throws Exception {
+        ToolBox.createJavaFileFromSource(MissingIncludeSrc);
+
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} @/nonexistent_file MissingInclude.java 2> ${TMP1}
+        ToolBox.JavaToolArgs params =
+                new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+                .setAllArgs("@/nonexistent_file", "MissingInclude.java");
+        ToolBox.javac(params);
+    }
+
+}
--- a/langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-#
-# Copyright (c) 1998, 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 4087314 4800342
-# @summary Verify allowed access to protected class from another package.
-# @author William Maddox (maddox)
-#
-# @run shell ProtectedInnerClass.sh
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* ) 
-    PS=";" # native PS, not Cygwin PS
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-rm -f ${TESTCLASSES}${FS}p1${FS}*.class ${TESTCLASSES}${FS}p2${FS}*.class
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TESTCLASSES}" "${TESTSRC}${FS}p1${FS}ProtectedInnerClass1.java" "${TESTSRC}${FS}p2${FS}ProtectedInnerClass2.java"
-"${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -classpath "${CLASSPATH}${PS}${TESTCLASSES}" p2.ProtectedInnerClass2
-result=$?
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
--- a/langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2000, 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 4307565
- * @summary Verify that access to inaccessable protected inner class is rejected.
- * @author William Maddox (maddox)
- *
- * @run compile p1/ProtectedInnerClass1.java
- * @run compile/fail p2/ProtectedInnerClass3.java
- */
-class Dummy {}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/ProtectedInnerClass/ProtectedInnerClassesTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4087314 4800342 4307565
+ * @summary Verify allowed access to protected class from another package
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ProtectedInnerClassesTest
+ */
+
+//original tests: test/tools/javac/ProtectedInnerClass/ProtectedInnerClass.sh
+//and test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
+public class ProtectedInnerClassesTest {
+
+    private static final String protectedInnerClass1Src =
+        "package p1;\n" +
+        "\n" +
+        "public class ProtectedInnerClass1 {\n" +
+        "    protected class Foo {\n" +
+        "        public String getBar() { return \"bar\"; }\n" +
+        "    }\n" +
+        "}";
+
+    private static final String protectedInnerClass2Src =
+        "package p2;\n" +
+        "\n" +
+        "public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1\n" +
+        "{\n" +
+        "    class Bug extends Foo {\n" +
+        "        String getBug() { return getBar(); }\n" +
+        "    }\n" +
+        "\n" +
+        "    public static void main(String[] args) {\n" +
+        "        ProtectedInnerClass2 x = new ProtectedInnerClass2();\n" +
+        "        Bug y = x.new Bug();\n" +
+        "        System.out.println(y.getBug());\n" +
+        "    }\n" +
+        "}";
+
+    private static final String protectedInnerClass3Src =
+        "package p2;\n" +
+        "\n" +
+        "public class ProtectedInnerClass3 {\n" +
+        "\n" +
+        "  void test() {\n" +
+        "    p1.ProtectedInnerClass1.Foo x;\n" +
+        "  }\n" +
+        "\n" +
+        "}";
+
+    public static void main(String args[]) throws Exception {
+        new ProtectedInnerClassesTest().run();
+    }
+
+    void run() throws Exception {
+        compileAndExecute();
+        compileOnly();
+    }
+
+    void compileAndExecute() throws Exception {
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TESTCLASSES}" "${TESTSRC}${FS}p1${FS}ProtectedInnerClass1.java" "${TESTSRC}${FS}p2${FS}ProtectedInnerClass2.java"
+        ToolBox.JavaToolArgs javacParams =
+                new ToolBox.JavaToolArgs()
+                .setOptions("-d", ".")
+                .setSources(protectedInnerClass1Src, protectedInnerClass2Src);
+
+        ToolBox.javac(javacParams);
+
+//"${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} -classpath "${CLASSPATH}${PS}${TESTCLASSES}" p2.ProtectedInnerClass2
+        ToolBox.AnyToolArgs javaParams =
+                new ToolBox.AnyToolArgs()
+                .setAllArgs(ToolBox.javaBinary, "-classpath", System.getProperty("user.dir"),
+                    "p2.ProtectedInnerClass2");
+        ToolBox.executeCommand(javaParams);
+    }
+
+//from test/tools/javac/ProtectedInnerClass/ProtectedInnerClass_2.java
+    void compileOnly() throws Exception {
+//@run compile p1/ProtectedInnerClass1.java
+        ToolBox.JavaToolArgs javacParams =
+                new ToolBox.JavaToolArgs()
+                .setOptions("-d", ".")
+                .setSources(protectedInnerClass1Src);
+
+        ToolBox.javac(javacParams);
+
+//@run compile/fail p2/ProtectedInnerClass3.java
+        javacParams.setSources(protectedInnerClass3Src)
+                .set(ToolBox.Expect.FAIL);
+        ToolBox.javac(javacParams);
+    }
+
+}
--- a/langtools/test/tools/javac/ProtectedInnerClass/p1/ProtectedInnerClass1.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 1997, 2000, 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.
- */
-
-/*
- * Auxiliary file for test for 4087314.
- * Verify allowed access to protected class from another package.
- * This file must be compiled prior to compiling p2.ProtectedInnerClass2.
- * It is that compilation that will either succeed or fail.
- */
-
-package p1;
-
-public class ProtectedInnerClass1 {
-    protected class Foo {
-        public String getBar() { return "bar"; }
-    }
-}
--- a/langtools/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass2.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1997, 2000, 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.
- */
-
-/*
- * Auxiliary file for test for 4087314.
- * Verify allowed access to protected class from another package.
- *
- * This file should compile and run successfully.
- * Note that class p1.ProtectedInnerClass1 must be compiled first.
- */
-
-package p2;
-
-public class ProtectedInnerClass2 extends p1.ProtectedInnerClass1
-{
-    class Bug extends Foo {
-        String getBug() { return getBar(); }
-    }
-
-    public static void main(String[] args) {
-        ProtectedInnerClass2 x = new ProtectedInnerClass2();
-        Bug y = x.new Bug();
-        System.out.println(y.getBug());
-    }
-}
--- a/langtools/test/tools/javac/ProtectedInnerClass/p2/ProtectedInnerClass3.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2000, 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.
- */
-
-/*
- * Auxiliary file for ProtectedInnerClass_2.java (bugid 4307565)
- */
-
-package p2;
-
-public class ProtectedInnerClass3 {
-
-  void test() {
-    p1.ProtectedInnerClass1.Foo x;
-  }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/T5090006/AssertionFailureTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 5090006
+ * @summary javac fails with assertion error
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main AssertionFailureTest
+ */
+
+import java.io.File;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/T5090006/compiler.sh
+public class AssertionFailureTest {
+
+    private static final String testSrc =
+        "import stub_tie_gen.wsdl_hello_lit.client.*;\n" +
+        "import junit.framework.*;\n" +
+        "import testutil.ClientServerTestUtil;\n" +
+        "\n" +
+        "public class Test {\n" +
+        "\n" +
+        "    void getStub() throws Exception {\n" +
+        "        Hello_PortType_Stub x = null;\n" +
+        "        new ClientServerTestUtil().setTransport(x, null, null, null);\n" +
+        "    }\n" +
+        "\n" +
+        "    public static void main(String[] args) {\n" +
+        "        System.out.println(\"FISK\");\n" +
+        "    }\n" +
+        "}";
+
+    public static void main(String args[]) throws Exception {
+        String classpath = Paths.get(System.getProperty("test.src"), "broken.jar")
+                .toString();
+        classpath = new StringBuilder(classpath)
+                .append(File.pathSeparator).append(".").toString();
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -verbose -d "${TESTCLASSES}" -cp "${TESTSRC}${FS}broken.jar" "${TESTSRC}${FS}$1"
+        ToolBox.JavaToolArgs params =
+                new ToolBox.JavaToolArgs()
+                .setOptions("-cp", classpath)
+                .setSources(testSrc);
+        ToolBox.javac(params);
+    }
+
+}
--- a/langtools/test/tools/javac/T5090006/T5090006.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2004, 2006, 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 5090006
- * @summary javac fails with assertion error
- * @author Peter von der Ah\u00e9
- * @run shell compiler.sh T5090006.java
- * @run main T5090006
- */
-
-import stub_tie_gen.wsdl_hello_lit.client.*;
-import junit.framework.*;
-import testutil.ClientServerTestUtil;
-
-public class T5090006 {
-
-    void getStub() throws Exception {
-        Hello_PortType_Stub x = null;
-        new ClientServerTestUtil().setTransport(x, null, null, null);
-    }
-
-    public static void main(String[] args) {
-        System.out.println("FISK");
-    }
-}
--- a/langtools/test/tools/javac/T5090006/compiler.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -verbose -d "${TESTCLASSES}" -cp "${TESTSRC}${FS}broken.jar" "${TESTSRC}${FS}$1"
-
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
--- a/langtools/test/tools/javac/constDebug/ConstDebug.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +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 4645152 4785453
- * @summary javac compiler incorrectly inserts <clinit> when -g is specified
- * @author gafter
- *
- * @run shell ConstDebug.sh ConstDebug
- */
-
-public class ConstDebug {
-    public static final long l = 12;
-}
--- a/langtools/test/tools/javac/constDebug/ConstDebug.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";" # Platform PS, not Cygwin PS
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TMP1=OUTPUT.txt
-
-cp "${TESTSRC}${FS}$1.java" .
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1}
-result=$?
-if [ $result -ne 0 ]; then exit $result; fi
-if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then
-  echo "Failed"
-  exit 1;
-else
-  echo "Passed"
-  exit 0;
-fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/constDebug/ConstDebugTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4645152 4785453
+ * @summary javac compiler incorrectly inserts <clinit> when -g is specified
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile -g ConstDebugTest.java
+ * @run main ConstDebugTest
+ */
+
+//original test: test/tools/javac/constDebug/ConstDebug.sh
+public class ConstDebugTest {
+
+    public static final long l = 12;
+
+    public static void main(String args[]) throws Exception {
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -g -d . -classpath .${PS}${TESTSRC} $1.java 2> ${TMP1}
+//        if "${TESTJAVA}${FS}bin${FS}javap" $1.class | grep clinit; then fail
+        ToolBox.JavaToolArgs javapArgs =
+                new ToolBox.JavaToolArgs().setAllArgs("-v",
+                "-classpath", System.getProperty("test.classes"), "ConstDebugTest.class");
+        if (ToolBox.javap(javapArgs).contains("clinit")) {
+            throw new AssertionError(
+                "javac should not create a <clinit> method for ConstDebugTest class");
+        }
+    }
+
+}
--- a/langtools/test/tools/javac/fatalErrors/NoJavaLang.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 1999, 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 4263768 4785453
- * @summary Verify that the compiler does not crash when java.lang is not
- * found.
- * @author iag
- *
- * @run shell NoJavaLang.sh
- */
-
-public class NoJavaLang {
-    private String s;
-
-    public String s() {
-        return s;
-    }
-}
--- a/langtools/test/tools/javac/fatalErrors/NoJavaLang.out	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-Fatal Error: Unable to find package java.lang in classpath or bootclasspath
--- a/langtools/test/tools/javac/fatalErrors/NoJavaLang.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 1999, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf '%s' "TESTSRC=${TESTSRC}" ; echo
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf '%s' "TESTJAVA=${TESTJAVA}" ; echo
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf '%s' "TESTCLASSES=${TESTCLASSES}" ; echo
-printf '%s' "CLASSPATH=${CLASSPATH}" ; echo
-echo
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    FS="/"
-    ;;
-  CYGWIN* )
-    FS="/"
-    DIFFOPTS="--strip-trailing-cr"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TMP1=OUTPUT.txt
-
-cp "${TESTSRC}${FS}NoJavaLang.java" .
-
-echo "- verifing that fatal error is not produced in the regular case" 
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NoJavaLang.java 2> "${TMP1}"
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed - base compilation successful"
-else
-  echo "Failed - unable to compile test"
-  exit $result
-fi
-
-echo
-
-echo "- verifing the fatal error is produced"
-rm "${TMP1}"
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -bootclasspath . NoJavaLang.java 2> "${TMP1}"
-
-# return code should be EXIT_SYSERR
-result=$?
-if [ $result -ne 3 ]
-then
-  echo "Failed - unexpected return code"
-  exit $result
-else
-  echo "Passed - expected return code"
-fi
-
-# expected message
-cat "${TMP1}"
-diff ${DIFFOPTS} -c "${TESTSRC}${FS}NoJavaLang.out" "${TMP1}"
-result=$?
-rm "${TMP1}"
-
-if [ $result -eq 0 ]
-then
-  echo "Passed - expected message"
-else
-  echo "Failed - unexpected message"
-  exit $result
-
-fi
-
-exit
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/fatalErrors/NoJavaLangTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4263768 4785453
+ * @summary Verify that the compiler does not crash when java.lang is not
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main NoJavaLangTest
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+//original test: test/tools/javac/fatalErrors/NoJavaLang.sh
+public class NoJavaLangTest {
+
+    private static final String noJavaLangSrc =
+        "public class NoJavaLang {\n" +
+        "    private String s;\n" +
+        "\n" +
+        "    public String s() {\n" +
+        "        return s;\n" +
+        "    }\n" +
+        "}";
+
+    private static final String compilerErrorMessage =
+        "Fatal Error: Unable to find package java.lang in classpath or bootclasspath";
+
+    public static void main(String[] args) throws Exception {
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} NoJavaLang.java 2> "${TMP1}"
+        ToolBox.JavaToolArgs javacSuccessArgs =
+                new ToolBox.JavaToolArgs().setSources(noJavaLangSrc);
+        ToolBox.javac(javacSuccessArgs);
+
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -bootclasspath . NoJavaLang.java 2> "${TMP1}"
+        List<String> output = new ArrayList<>();
+        ToolBox.JavaToolArgs javacFailArgs =
+                new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+                .setOptions("-bootclasspath", ".")
+                .setSources(noJavaLangSrc)
+                .setErrOutput(output);
+
+        int cr = ToolBox.javac(javacFailArgs);
+        if (cr != 3) {
+            throw new AssertionError("Compiler exit result should be 3");
+        }
+
+//        diff ${DIFFOPTS} -c "${TESTSRC}${FS}NoJavaLang.out" "${TMP1}"
+        if (!(output.size() == 1 && output.get(0).equals(compilerErrorMessage))) {
+            throw new AssertionError("javac generated error output is not correct");
+        }
+    }
+
+}
--- a/langtools/test/tools/javac/innerClassFile/Driver.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2009, 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 4491755 4785453
-# @summary Prob w/static inner class with same name as a regular class
-# @author gafter
-#
-# @run shell Driver.sh
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-set -x
-mkdir src
-cp -r ${TESTSRC}${FS}* src
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath . -sourcepath src src/x/B.java src/x/C.java src/y/Main.java
-rm y/R3.class
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath . -sourcepath src src/y/Main.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/innerClassFile/InnerClassFileTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,127 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4491755 4785453
+ * @summary Prob w/static inner class with same name as a regular class
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main InnerClassFileTest
+ */
+
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/innerClassFile/Driver.sh
+public class InnerClassFileTest {
+
+    private static final String BSrc =
+        "package x;\n" +
+        "\n" +
+        "import x.*;\n" +
+        "\n" +
+        "public class B {\n" +
+        "    public static class C {}\n" +
+        "}";
+
+    private static final String CSrc =
+        "package x;\n" +
+        "\n" +
+        "import x.*;\n" +
+        "\n" +
+        "public class C {}";
+
+    private static final String MainSrc =
+        "package y;\n" +
+        "\n" +
+        "class Main {\n" +
+        "        private R1 a;\n" +
+        "        private R2 b;\n" +
+        "        private R3 c;\n" +
+        "}";
+
+    private static final String R1Src =
+        "package y;\n" +
+        "\n" +
+        "public final class R1 {\n" +
+        "    x.B.C a = null;\n" +
+        "    x.C b = null;\n" +
+        "    R2 c = new R2();\n" +
+        "}";
+
+    private static final String R2Src =
+        "package y;\n" +
+        "\n" +
+        "public final class R2 {\n" +
+        "    x.B.C a = null;\n" +
+        "    x.C b = null;\n" +
+        "}";
+
+    private static final String R3Src =
+        "package y;\n" +
+        "\n" +
+        "public final class R3 {\n" +
+        "    x.B.C a = null;\n" +
+        "    x.C b = null;\n" +
+        "    R1 c = new R1();\n" +
+        "}";
+
+    public static void main(String args[]) throws Exception {
+        new InnerClassFileTest().run();
+    }
+
+    void run() throws Exception {
+        createFiles();
+        compileFiles();
+    }
+
+    void createFiles() throws Exception {
+//        mkdir src
+//        cp -r ${TESTSRC}${FS}* src
+        ToolBox.createJavaFileFromSource(Paths.get("src"), BSrc);
+        ToolBox.createJavaFileFromSource(Paths.get("src"), CSrc);
+        ToolBox.createJavaFileFromSource(Paths.get("src"), MainSrc);
+        ToolBox.createJavaFileFromSource(Paths.get("src"), R1Src);
+        ToolBox.createJavaFileFromSource(Paths.get("src"), R2Src);
+        ToolBox.createJavaFileFromSource(Paths.get("src"), R3Src);
+    }
+
+    void compileFiles() throws Exception {
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath .
+//              -sourcepath src src/x/B.java src/x/C.java src/y/Main.java
+        ToolBox.JavaToolArgs args =
+                new ToolBox.JavaToolArgs()
+                .setAllArgs("-d", ".", "-cp" , ".", "-sourcepath", "src",
+                "src/x/B.java", "src/x/C.java", "src/y/Main.java");
+        ToolBox.javac(args);
+
+//        rm y/R3.class
+        ToolBox.rm(Paths.get("y", "R3.class"));
+
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath .
+//                -sourcepath src src/y/Main.java
+        args.setAllArgs("-d", ".", "-cp", ".", "-sourcepath", "src", "src/y/Main.java");
+        ToolBox.javac(args);
+    }
+
+}
--- a/langtools/test/tools/javac/innerClassFile/x/B.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +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.
- */
-
-package x;
-
-import x.*;
-
-public class B {
-    public static class C {}
-}
--- a/langtools/test/tools/javac/innerClassFile/x/C.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +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.
- */
-
-package x;
-
-import x.*;
-
-public class C {}
--- a/langtools/test/tools/javac/innerClassFile/y/Main.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +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.
- */
-
-package y;
-
-class Main {
-        private R1 a;
-        private R2 b;
-        private R3 c;
-}
--- a/langtools/test/tools/javac/innerClassFile/y/R1.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +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.
- */
-
-package y;
-
-public final class R1 {
-    x.B.C a = null;
-    x.C b = null;
-    R2 c = new R2();
-}
--- a/langtools/test/tools/javac/innerClassFile/y/R2.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +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.
- */
-
-package y;
-
-public final class R2 {
-    x.B.C a = null;
-    x.C b = null;
-}
--- a/langtools/test/tools/javac/innerClassFile/y/R3.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,30 +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.
- */
-
-package y;
-
-public final class R3 {
-    x.B.C a = null;
-    x.C b = null;
-    R1 c = new R1();
-}
--- a/langtools/test/tools/javac/javazip/A.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2005, 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.
- */
-
-// A class that references another
-class A {
-    B b;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/javazip/JavaZipTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,126 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4098712 6304984 6388453
+ * @summary check that source files inside zip files on the class path are ignored
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main JavaZipTest
+ */
+
+import java.io.File;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/javazip/Test.sh
+public class JavaZipTest {
+
+    private static final String ASrc =
+        "class A {\n" +
+        "    B b;\n" +
+        "}";
+
+    private static final String BGoodSrc =
+        "public class B {}";
+
+    private static final String BBadSrc =
+        "class B";
+
+    private static final String[][] jarArgs = {
+        {"cf", "good.jar", "-C", "good", "B.java"},
+        {"cf", "good.zip", "-C", "good", "B.java"},
+        {"cf", "bad.jar", "-C", "bad", "B.java"},
+        {"cf", "bad.zip", "-C", "bad", "B.java"},
+    };
+
+    private static final String[][] successfulCompilationArgs = {
+        {"-d", "output", "A.java", "good/B.java"},
+        {"-d", "output", "-cp", "good", "A.java"},
+        {"-d", "output", "-sourcepath", "good", "A.java"},
+        {"-d", "output", "-cp", "good.zip", "A.java"},
+        {"-d", "output", "-cp", "good.jar", "A.java"},
+    };
+
+    private static final String[][] unSuccessfulCompilationArgs = {
+        {"-d", "output", "A.java", "bad/B.java"},
+        {"-d", "output", "-cp", "bad", "A.java"},
+        {"-d", "output", "-sourcepath", "bad", "A.java"},
+        {"-d", "output", "-sourcepath", "bad.zip", "A.java"},
+        {"-d", "output", "-sourcepath", "bad.jar", "A.java"},
+    };
+
+    public static void main(String[] args) throws Exception {
+        new JavaZipTest().test();
+    }
+
+    public void test() throws Exception {
+        createOutputDirAndSourceFiles();
+        createZipsAndJars();
+        check(ToolBox.Expect.SUCCESS, successfulCompilationArgs);
+        check(ToolBox.Expect.FAIL, unSuccessfulCompilationArgs);
+    }
+
+    void createOutputDirAndSourceFiles() throws Exception {
+        //create output dir
+        new File("output").mkdir();
+
+        //source file creation
+        ToolBox.createJavaFileFromSource(Paths.get("good"), BGoodSrc);
+        ToolBox.createJavaFileFromSource(Paths.get("bad"), BBadSrc);
+        ToolBox.createJavaFileFromSource(ASrc);
+    }
+
+    void createZipsAndJars() throws Exception {
+        //jar and zip creation
+//        check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.jar" -C "${TESTSRC}${FS}good" B.java
+//        check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.zip" -C "${TESTSRC}${FS}good" B.java
+//        check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.jar"  -C "${TESTSRC}${FS}bad" B.java
+//        check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.zip"  -C "${TESTSRC}${FS}bad" B.java
+        for (String[] args: jarArgs) {
+            ToolBox.jar(args);
+        }
+    }
+
+    void check(ToolBox.Expect whatToExpect, String[][] theArgs) throws Exception {
+//        check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}good${FS}B.java"
+//        check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}good"   "${TESTSRC}${FS}A.java"
+//        check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}good"  "${TESTSRC}${FS}A.java"
+//        check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.zip"   "${TESTSRC}${FS}A.java"
+//        check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.jar"   "${TESTSRC}${FS}A.java"
+
+//        check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}bad${FS}B.java"
+//        check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}bad"    "${TESTSRC}${FS}A.java"
+//        check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}bad"   "${TESTSRC}${FS}A.java"
+//        check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.zip"   "${TESTSRC}${FS}A.java"
+//        check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.jar"   "${TESTSRC}${FS}A.java"
+        ToolBox.JavaToolArgs args =
+                new ToolBox.JavaToolArgs(whatToExpect);
+
+        for (String[] allArgs: theArgs) {
+            args.setAllArgs(allArgs);
+            ToolBox.javac(args);
+        }
+    }
+
+}
--- a/langtools/test/tools/javac/javazip/Test.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,111 +0,0 @@
-#! /bin/sh -f
-
-#
-# Copyright (c) 2005, 2011, 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 4098712 6304984 6388453
-# @summary check that source files inside zip files on the class path are ignored
-# @run shell Test.sh
-
-TS=${TESTSRC-.}
-TC=${TESTCLASSES-.}
-SCR=`pwd`
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    FS="/"
-    SCR=`pwd`
-    ;;
-  CYGWIN* )
-    FS="/"
-    SCR=`pwd | cygpath -d -f -`
-    ;;
-  Windows* )
-    FS="\\"
-    SCR=`pwd`
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-check() {
-    expected=$1
-    shift
-
-    # clean old classes
-    rm -f ${TC}${FS}*.class 
-
-    echo "$@"
-    if "$@" 2>&1 ; then
-      actual=ok
-    else
-      actual=err
-    fi
-    if [ "$actual" != "$expected" ]; then
-      case "$actual" in
-        ok  ) echo "error: unexpected result: command succeeded" ;;
-        err ) echo "error: unexpected result: command failed"
-      esac
-      exit 1
-    else 
-      case "$actual" in
-        ok  ) echo "command succeeded as expected" ;;
-        err ) echo "command failed as expected."
-      esac
-    fi
-
-    echo 
-}
-
-echo "# create zip/jar files with source code"
-check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.jar" -C "${TESTSRC}${FS}good" B.java
-check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}good.zip" -C "${TESTSRC}${FS}good" B.java
-check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.jar"  -C "${TESTSRC}${FS}bad" B.java
-check ok   "${TESTJAVA}${FS}bin${FS}jar" cf "${SCR}${FS}bad.zip"  -C "${TESTSRC}${FS}bad" B.java
-
-echo "# control tests, with no paths"
-check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}good${FS}B.java"
-check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} "${TESTSRC}${FS}A.java" "${TESTSRC}${FS}bad${FS}B.java"
-
-echo "# test that source files are found in directories on path"
-check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}good"   "${TESTSRC}${FS}A.java"
-check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}good"  "${TESTSRC}${FS}A.java"
-check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${TESTSRC}${FS}bad"    "${TESTSRC}${FS}A.java"
-check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${TESTSRC}${FS}bad"   "${TESTSRC}${FS}A.java"
-
-echo "# test that source files are found in zip/jar files on path"
-check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.zip"   "${TESTSRC}${FS}A.java"
-check ok   "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -classpath "${SCR}${FS}good.jar"   "${TESTSRC}${FS}A.java"
-check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.zip"   "${TESTSRC}${FS}A.java"  
-check err  "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d ${TC} -sourcepath "${SCR}${FS}bad.jar"   "${TESTSRC}${FS}A.java" 
--- a/langtools/test/tools/javac/javazip/bad/B.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * Copyright (c) 2005, 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 invalid
-class B
--- a/langtools/test/tools/javac/javazip/good/B.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2005, 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 is a valid class
-public class B {
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lib/ToolBox.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,911 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.net.URI;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardOpenOption;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+import com.sun.source.util.JavacTask;
+import com.sun.tools.javac.api.JavacTaskImpl;
+
+import sun.tools.jar.Main;
+
+import static java.nio.file.StandardCopyOption.*;
+
+/**
+ * Toolbox for jtreg tests.
+ */
+
+public class ToolBox {
+
+    public static final String lineSeparator = System.getProperty("line.separator");
+    public static final String jdkUnderTest = System.getProperty("test.jdk");
+    public static final String testVMOpts = System.getProperty("test.tool.vm.opts");
+    public static final String javaBinary = Paths.get(jdkUnderTest, "bin", "java").toString();
+    //why this one private. Because the function which provide also the test options should be used
+    private static final String javacBinary = Paths.get(jdkUnderTest, "bin", "javac").toString();
+
+    private static final Charset defaultCharset = Charset.defaultCharset();
+
+    static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler();
+
+    /**
+     * The expected result of command-like method execution.
+     */
+    public enum Expect {SUCCESS, FAIL}
+
+    enum AcceptedParams {
+        EXPECT,
+        SOURCES,
+        OPTIONS,
+        STD_OUTPUT,
+        ERR_OUTPUT,
+        EXTRA_ENV,
+    }
+
+    enum OutputKind {STD, ERR}
+
+    /**
+     * Helper class to abstract the processing of command's output.
+     */
+    static abstract class WriterHelper {
+        OutputKind kind;
+        public abstract void pipeOutput(ProcessBuilder pb);
+        public abstract void readFromStream(Process p) throws IOException;
+        public abstract void addAll(Collection<? extends String> c) throws IOException;
+    }
+
+    /**
+     * Helper class for redirecting command's output to a file.
+     */
+    static class FileWriterHelper extends WriterHelper {
+        File file;
+
+        FileWriterHelper(File file, OutputKind kind) {
+            this.file = file;
+            this.kind = kind;
+        }
+
+        @Override
+        public void pipeOutput(ProcessBuilder pb) {
+            if (file != null) {
+                switch (kind) {
+                    case STD:
+                        pb.redirectInput(file);
+                        break;
+                    case ERR:
+                        pb.redirectError(file);
+                        break;
+                }
+            }
+        }
+
+        @Override
+        public void readFromStream(Process p) throws IOException {}
+
+        @Override
+        public void addAll(Collection<? extends String> c) throws IOException {
+            if (file.exists())
+                Files.write(file.toPath(), c, defaultCharset,
+                        StandardOpenOption.WRITE, StandardOpenOption.APPEND);
+            else
+                Files.write(file.toPath(), c, defaultCharset);
+        }
+    }
+
+    /**
+     * Helper class for redirecting command's output to a String list.
+     */
+    static class ListWriterHelper extends WriterHelper {
+        List<String> list;
+
+        public ListWriterHelper(List<String> list, OutputKind kind) {
+            this.kind = kind;
+            this.list = list;
+        }
+
+        @Override
+        public void pipeOutput(ProcessBuilder pb) {}
+
+        @Override
+        public void readFromStream(Process p) throws IOException {
+            BufferedReader br = null;
+            switch (kind) {
+                case STD:
+                    br = new BufferedReader(new InputStreamReader(p.getInputStream()));
+                    break;
+                case ERR:
+                    br = new BufferedReader(new InputStreamReader(p.getErrorStream()));
+                    break;
+            }
+            String line;
+            while ((line = br.readLine()) != null) {
+                list.add(line);
+            }
+        }
+
+        public void addAll(Collection<? extends String> c) {
+            list.addAll(c);
+        }
+    }
+
+    /**
+     * Simple factory class for creating a WriterHelper instance.
+     */
+    static class WriterHelperFactory {
+        static WriterHelper make(File file, OutputKind kind) {
+            return new FileWriterHelper(file, kind);
+        }
+
+        static WriterHelper make(List<String> list, OutputKind kind) {
+            return new ListWriterHelper(list, kind);
+        }
+    }
+
+    /**
+     * A generic class for holding command's arguments.
+     */
+    public static abstract class GenericArgs <T extends GenericArgs> {
+        protected static List<Set<AcceptedParams>> minAcceptedParams;
+
+        protected Set<AcceptedParams> currentParams =
+                EnumSet.<AcceptedParams>noneOf(AcceptedParams.class);
+
+        protected Expect whatToExpect;
+        protected WriterHelper stdOutput;
+        protected WriterHelper errOutput;
+        protected List<String> options;
+        protected String[] optionsArr;
+
+        protected GenericArgs() {
+            set(Expect.SUCCESS);
+        }
+
+        public T set(Expect whatToExpt) {
+            currentParams.add(AcceptedParams.EXPECT);
+            this.whatToExpect = whatToExpt;
+            return (T)this;
+        }
+
+        public T setStdOutput(List<String> stdOutput) {
+            currentParams.add(AcceptedParams.STD_OUTPUT);
+            this.stdOutput = WriterHelperFactory.make(stdOutput, OutputKind.STD);
+            return (T)this;
+        }
+
+        public T setStdOutput(File output) {
+            currentParams.add(AcceptedParams.STD_OUTPUT);
+            this.stdOutput = WriterHelperFactory.make(output, OutputKind.STD);
+            return (T)this;
+        }
+
+        public T setErrOutput(List<String> errOutput) {
+            currentParams.add(AcceptedParams.ERR_OUTPUT);
+            this.errOutput = WriterHelperFactory.make(errOutput, OutputKind.ERR);
+            return (T)this;
+        }
+
+        public T setErrOutput(File errOutput) {
+            currentParams.add(AcceptedParams.ERR_OUTPUT);
+            this.errOutput = WriterHelperFactory.make(errOutput, OutputKind.ERR);
+            return (T)this;
+        }
+
+        public T setAllArgs(String... args) {
+            currentParams.add(AcceptedParams.OPTIONS);
+            this.optionsArr = args;
+            return (T)this;
+        }
+
+        public T setOptions(List<String> options) {
+            currentParams.add(AcceptedParams.OPTIONS);
+            this.options = options;
+            return (T)this;
+        }
+
+        public T setOptions(String... options) {
+            currentParams.add(AcceptedParams.OPTIONS);
+            this.options = Arrays.asList(options);
+            return (T)this;
+        }
+
+        public boolean hasMinParams() {
+            for (Set<AcceptedParams> minSet : minAcceptedParams) {
+                if (currentParams.containsAll(minSet)) {
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    /**
+     * A more specific class for holding javac-like command's arguments.
+     */
+    public static class JavaToolArgs extends GenericArgs<JavaToolArgs> {
+
+        static {
+            minAcceptedParams = new ArrayList<>();
+            minAcceptedParams.add(EnumSet.<AcceptedParams>of(
+                    AcceptedParams.EXPECT, AcceptedParams.OPTIONS));
+            minAcceptedParams.add(EnumSet.<AcceptedParams>of(
+                    AcceptedParams.EXPECT, AcceptedParams.SOURCES));
+        }
+
+        protected List<? extends JavaFileObject> sources;
+
+        public JavaToolArgs() {
+            super();
+        }
+
+        public JavaToolArgs(Expect whatToExpt) {
+            super.set(whatToExpt);
+        }
+
+        public JavaToolArgs setSources(List<? extends JavaFileObject> sources) {
+            currentParams.add(AcceptedParams.SOURCES);
+            this.sources = sources;
+            return this;
+        }
+
+        public JavaToolArgs setSources(JavaSource... sources) {
+            return setSources(Arrays.asList(sources));
+        }
+
+        public JavaToolArgs setSources(String... sources) {
+            List<JavaSource> javaSrcs = new ArrayList<>();
+            for (String source : sources) {
+                javaSrcs.add(new JavaSource(source));
+            }
+            return setSources(javaSrcs);
+        }
+    }
+
+    /**
+     * A more specific class for holding any command's arguments.
+     */
+    public static class AnyToolArgs extends GenericArgs<AnyToolArgs> {
+
+        static {
+            minAcceptedParams = new ArrayList<>();
+            minAcceptedParams.add(EnumSet.<AcceptedParams>of(
+                    AcceptedParams.EXPECT, AcceptedParams.OPTIONS));
+        }
+
+        Map<String, String> extraEnv;
+
+        public AnyToolArgs() {
+            super();
+        }
+
+        public AnyToolArgs(Expect whatToExpt) {
+            set(whatToExpt);
+        }
+
+        public AnyToolArgs set(Map<String, String> extraEnv) {
+            currentParams.add(AcceptedParams.EXTRA_ENV);
+            this.extraEnv = extraEnv;
+            return this;
+        }
+    }
+
+    /**
+     * Custom exception for bad command execution.
+     */
+    public static class CommandExecutionException extends Exception {
+        CommandExecutionException(List<String> command, Expect whatToExpt) {
+            super(createMessage(command, whatToExpt));
+        }
+
+        CommandExecutionException(Expect whatToExpt, String... command) {
+            this(Arrays.asList(command), whatToExpt);
+        }
+
+        private static String createMessage(List<String> command, Expect whatToExpt) {
+            StringBuilder sb = new StringBuilder().append("Command : ");
+            sb.append(command.toString()).append(lineSeparator);
+            switch (whatToExpt) {
+                case SUCCESS:
+                    sb.append("    has unexpectedly failed");
+                    break;
+                case FAIL:
+                    sb.append("    has been unexpectedly successful");
+                    break;
+            }
+            return sb.toString();
+        }
+    }
+
+    /**
+     * Custom exception for not equal resources.
+     */
+    public static class ResourcesNotEqualException extends Exception {
+        public ResourcesNotEqualException() {
+            super("The resources provided for comparison are different");
+        }
+
+        public ResourcesNotEqualException(Path path1, Path path2) {
+            super(createMessage(path1, path2));
+        }
+
+        private static String createMessage(Path path1, Path path2) {
+            return new StringBuilder()
+                    .append("The resources provided for comparison in paths \n")
+                    .append(path1.toString()).append(" and \n")
+                    .append(path2.toString()).append("are different").toString();
+        }
+    }
+
+    /**
+     * Method to get the a path to the javac command available at the jdk being
+     * tested along with the test vm options.
+     * @return a String[] with the two components mentioned.
+     */
+    public static String[] getJavacBin() {
+        return new String[]{javacBinary, testVMOpts};
+    }
+
+    /**
+     * A javac compiler caller method.
+     */
+    public static int javac(JavaToolArgs params)
+            throws CommandExecutionException, IOException {
+        if (params.hasMinParams()) {
+            if (params.optionsArr != null) {
+                return genericJavaCMD(JavaCMD.JAVAC, params);
+            } else {
+                return genericJavaCMD(JavaCMD.JAVAC_API, params);
+            }
+        }
+        throw new AssertionError("javac command has been invoked with less parameters than needed");
+    }
+
+    /**
+     * A javap calling method.
+     */
+    public static String javap(JavaToolArgs params)
+            throws CommandExecutionException, IOException {
+        if (params.hasMinParams()) {
+            List<String> list = new ArrayList<>();
+            params.setErrOutput(list);
+            genericJavaCMD(JavaCMD.JAVAP, params);
+            return listToString(list);
+        }
+        throw new AssertionError("javap command has been invoked with less parameters than needed");
+    }
+
+    /**
+     * A javah calling method.
+     */
+    public static int javah(JavaToolArgs params)
+            throws CommandExecutionException, IOException {
+        if (params.hasMinParams()) {
+            return genericJavaCMD(JavaCMD.JAVAH, params);
+        }
+        throw new AssertionError("javah command has been invoked with less parameters than needed");
+    }
+
+    /**
+     * A enum class for langtools commands.
+     */
+    enum JavaCMD {
+        JAVAC {
+            @Override
+            int run(JavaToolArgs params, PrintWriter pw) {
+                return com.sun.tools.javac.Main.compile(params.optionsArr, pw);
+            }
+        },
+        JAVAC_API {
+            @Override
+            int run(JavaToolArgs params, PrintWriter pw) {
+                JavacTask ct = (JavacTask)comp.getTask(pw, null, null,
+                        params.options, null, params.sources);
+                return ((JavacTaskImpl)ct).doCall().exitCode;
+            }
+
+            @Override
+            String getName() {
+                return "javac";
+            }
+
+            @Override
+            List<String> getExceptionMsgContent(JavaToolArgs params) {
+                List<String> result = super.getExceptionMsgContent(params);
+                for (JavaFileObject source : params.sources) {
+                    if (source instanceof JavaSource) {
+                        result.add(((JavaSource)source).name);
+                    }
+                }
+                return result;
+            }
+        },
+        JAVAH {
+            @Override
+            int run(JavaToolArgs params, PrintWriter pw) {
+                return com.sun.tools.javah.Main.run(params.optionsArr, pw);
+            }
+        },
+        JAVAP {
+            @Override
+            int run(JavaToolArgs params, PrintWriter pw) {
+                return com.sun.tools.javap.Main.run(params.optionsArr, pw);
+            }
+        };
+
+        abstract int run(JavaToolArgs params, PrintWriter pw);
+
+        String getName() {
+            return this.name().toLowerCase();
+        }
+
+        List<String> getExceptionMsgContent(JavaToolArgs params) {
+            List<String> result = new ArrayList<>();
+            result.add(getName());
+            result.addAll(params.optionsArr != null ?
+                    Arrays.asList(params.optionsArr) :
+                    params.options);
+            return result;
+        }
+    }
+
+    /**
+     * A helper method for executing langtools commands.
+     */
+    private static int genericJavaCMD(
+            JavaCMD cmd,
+            JavaToolArgs params)
+            throws CommandExecutionException, IOException {
+        int rc = 0;
+        StringWriter sw = null;
+        try (PrintWriter pw = (params.errOutput == null) ?
+                null : new PrintWriter(sw = new StringWriter())) {
+            rc = cmd.run(params, pw);
+        }
+        String out = (sw == null) ? null : sw.toString();
+
+        if (params.errOutput != null && (out != null) && !out.isEmpty()) {
+            params.errOutput.addAll(splitLines(out));
+        }
+
+        if ( (rc == 0 && params.whatToExpect == Expect.SUCCESS) ||
+             (rc != 0 && params.whatToExpect == Expect.FAIL) ) {
+            return rc;
+        }
+
+        throw new CommandExecutionException(cmd.getExceptionMsgContent(params),
+                params.whatToExpect);
+    }
+
+    /**
+     * A jar calling method.
+     */
+    public static boolean jar(String... params) throws CommandExecutionException {
+        Main jarGenerator = new Main(System.out, System.err, "jar");
+        boolean result = jarGenerator.run(params);
+        if (!result) {
+            List<String> command = new ArrayList<>();
+            command.add("jar");
+            command.addAll(Arrays.asList(params));
+            throw new CommandExecutionException(command, Expect.SUCCESS);
+        }
+        return result;
+    }
+
+    /**
+     * A general command calling method.
+     */
+    public static int executeCommand(AnyToolArgs params)
+            throws CommandExecutionException, IOException, InterruptedException {
+        if (params.hasMinParams()) {
+            List<String> cmd = (params.options != null) ?
+                    params.options :
+                    Arrays.asList(params.optionsArr);
+            return executeCommand(cmd, params.extraEnv, params.stdOutput,
+                    params.errOutput, params.whatToExpect);
+        }
+        throw new AssertionError("command has been invoked with less parameters than needed");
+    }
+
+    /**
+     * A helper method for calling a general command.
+     */
+    private static int executeCommand(
+            List<String> command,
+            Map<String, String> extraEnv,
+            WriterHelper stdOutput,
+            WriterHelper errOutput,
+            Expect whatToExpt)
+            throws IOException, InterruptedException, CommandExecutionException {
+        ProcessBuilder pb = new ProcessBuilder(command);
+
+        if (stdOutput != null) stdOutput.pipeOutput(pb);
+        if (errOutput != null) errOutput.pipeOutput(pb);
+
+        if (extraEnv != null) {
+            pb.environment().putAll(extraEnv);
+        }
+
+        Process p = pb.start();
+
+        if (stdOutput != null) stdOutput.readFromStream(p);
+        if (errOutput != null) errOutput.readFromStream(p);
+
+        int result = p.waitFor();
+        if ( (result == 0 && whatToExpt == Expect.SUCCESS) ||
+             (result != 0 && whatToExpt == Expect.FAIL) ) {
+            return result;
+        }
+
+        throw new CommandExecutionException(command, whatToExpt);
+    }
+
+    /**
+     * This set of methods can be used instead of diff when the only needed
+     * result is the equality or inequality of the two given resources.
+     *
+     * A resource can be a file or a String list.
+     */
+    public static void compareLines(Path aPath, Path otherPath, String encoding)
+            throws FileNotFoundException, IOException, ResourcesNotEqualException {
+        compareLines(aPath, otherPath, encoding, false);
+    }
+
+    public static void compareLines(
+            Path aPath, Path otherPath, String encoding, boolean trim)
+            throws FileNotFoundException, IOException, ResourcesNotEqualException {
+        Charset charset = encoding != null ?
+                Charset.forName(encoding) :
+                defaultCharset;
+        List<String> list1 = Files.readAllLines(aPath, charset);
+        List<String> list2 = Files.readAllLines(otherPath, charset);
+        compareLines(list1, list2, trim);
+    }
+
+    public static void compareLines(Path path, List<String> strings, String encoding)
+            throws FileNotFoundException, IOException, ResourcesNotEqualException {
+        compareLines(path, strings, encoding, false);
+    }
+
+    public static void compareLines(Path path, List<String> strings,
+            String encoding, boolean trim)
+            throws FileNotFoundException, IOException, ResourcesNotEqualException {
+        Charset charset = encoding != null ?
+                Charset.forName(encoding) :
+                defaultCharset;
+        List<String> list = Files.readAllLines(path, charset);
+        compareLines(list, strings, trim);
+    }
+
+    public static void compareLines(List<String> list1, List<String> list2)
+            throws ResourcesNotEqualException {
+        compareLines(list1, list2, false);
+    }
+
+    public static void compareLines(List<String> list1,
+            List<String> list2, boolean trim) throws ResourcesNotEqualException {
+        if ((list1 == list2) || (list1 == null && list2 == null)) return;
+        if (list1.size() != list2.size())
+            throw new ResourcesNotEqualException();
+        int i = 0;
+        int j = 0;
+        while (i < list1.size() &&
+               j < list2.size() &&
+               equals(list1.get(i), list2.get(j), trim)) {
+            i++; j++;
+        }
+        if (!(i == list1.size() && j == list2.size()))
+            throw new ResourcesNotEqualException();
+    }
+
+    private static boolean equals(String s1, String s2, boolean trim) {
+        return (trim ? s1.trim().equals(s2.trim()) : s1.equals(s2));
+    }
+
+    /**
+     * A set of simple grep-like methods, looks for regExpr in text.
+     * The content of text is split using the new line character as a pattern
+     * and later the regExpr is seek in every split line. If a match is found,
+     * the whole line is added to the result.
+     */
+    public static List<String> grep(String regExpr, String text) {
+        return grep(regExpr, splitLines(text));
+    }
+
+    public static List<String> grep(String regExpr, List<String> text) {
+        List<String> result = new ArrayList<>();
+        Pattern pattern = Pattern.compile(regExpr);
+        for (String s : text) {
+            if (pattern.matcher(s).find()) {
+                result.add(s);
+            }
+        }
+        return result;
+    }
+
+    public static List<String> grep(String regExpr, File f)
+            throws IOException {
+        List<String> lines = Files.readAllLines(f.toPath(), defaultCharset);
+        return grep(regExpr, lines);
+    }
+
+    /**
+     * A touch-like method.
+     */
+    public static boolean touch(String fileName) {
+        File file = new File(fileName);
+        return touch(file);
+    }
+
+    public static boolean touch(File file) {
+        if (file.exists()) {
+            file.setLastModified(System.currentTimeMillis());
+            return true;
+        }
+        return false;
+    }
+
+    public static void createJavaFile(File outFile) throws IOException {
+        createJavaFile(outFile, null);
+    }
+
+    /**
+     * A method for creating a valid but very simple java file.
+     */
+    public static void createJavaFile(File outFile, File superClass)
+            throws IOException {
+        String srcStr = "public class " + getSimpleName(outFile) + " ";
+        if (superClass != null) {
+            srcStr = srcStr.concat("extends " + getSimpleName(superClass) + " ");
+        }
+        srcStr = srcStr.concat("{}");
+        try (PrintWriter ps = new PrintWriter(new FileWriter(outFile))) {
+            ps.println(srcStr);
+        }
+    }
+
+    /**
+     * Creates a java file name given its source.
+     * The file is created in the working directory, creating a directory
+     * tree if there is a package declaration.
+     */
+    public static void createJavaFileFromSource(String source) throws IOException {
+        createJavaFileFromSource(null, source);
+    }
+
+    /**
+     * Creates a java file name given its source.
+     * The file is created in the working directory, creating a directory
+     * tree if there is a package declaration or the argument initialPath
+     * has a valid path.
+     *
+     * e.i. if initialPath is foo/ and the source is:
+     * package bar;
+     *
+     * public class bazz {}
+     *
+     * this method will create the file foo/bar/bazz.java in the working
+     * directory.
+     */
+    public static void createJavaFileFromSource(Path initialPath,
+            String source) throws IOException {
+        String fileName = getJavaFileNameFromSource(source);
+        String dirTree = getDirTreeFromSource(source);
+        Path path = (dirTree != null) ?
+                Paths.get(dirTree, fileName) :
+                Paths.get(fileName);
+        path = (initialPath != null) ?
+                initialPath.resolve(path):
+                path;
+        writeFile(path, source);
+    }
+
+    static Pattern publicClassPattern =
+            Pattern.compile("public\\s+(?:class|enum|interface){1}\\s+(\\w+)");
+    static Pattern packageClassPattern =
+            Pattern.compile("(?:class|enum|interface){1}\\s+(\\w+)");
+
+    /**
+     * Extracts the java file name from the class declaration.
+     * This method is intended for simple files and uses regular expressions,
+     * so comments matching the pattern can make the method fail.
+     */
+    private static String getJavaFileNameFromSource(String source) {
+        String className = null;
+        Matcher matcher = publicClassPattern.matcher(source);
+        if (matcher.find()) {
+            className = matcher.group(1) + ".java";
+        } else {
+            matcher = packageClassPattern.matcher(source);
+            if (matcher.find()) {
+                className = matcher.group(1) + ".java";
+            } else {
+                throw new AssertionError("Could not extract the java class " +
+                        "name from the provided source");
+            }
+        }
+        return className;
+    }
+
+    static Pattern packagePattern =
+            Pattern.compile("package\\s+(((?:\\w+\\.)*)(?:\\w+))");
+
+    /**
+     * Extracts the path from the package declaration if present.
+     * This method is intended for simple files and uses regular expressions,
+     * so comments matching the pattern can make the method fail.
+     */
+    private static String getDirTreeFromSource(String source) {
+        Matcher matcher = packagePattern.matcher(source);
+        return matcher.find() ?
+            matcher.group(1).replace(".", File.separator) :
+            null;
+    }
+
+    /**
+     * A method for creating a jar's manifest file with supplied data.
+     */
+    public static void mkManifestWithClassPath(String mainClass,
+            String... classes) throws IOException {
+        List <String> lines = new ArrayList<>();
+
+        StringBuilder sb = new StringBuilder("Class-Path: ".length() +
+                classes[0].length()).append("Class-Path: ").append(classes[0]);
+        for (int i = 1; i < classes.length; i++) {
+            sb.append(" ").append(classes[i]);
+        }
+        lines.add(sb.toString());
+        if (mainClass != null) {
+            lines.add(new StringBuilder("Main-Class: ".length() +
+                      mainClass.length())
+                      .append("Main-Class: ")
+                      .append(mainClass).toString());
+        }
+        Files.write(Paths.get("MANIFEST.MF"), lines, null);
+    }
+
+    /**
+     * A utility method to obtain the file name.
+     */
+    static String getSimpleName(File inFile) {
+        return inFile.toPath().getFileName().toString();
+    }
+
+    /**
+     * A method to write to a file, the directory tree is created if needed.
+     */
+    public static File writeFile(Path path, String body) throws IOException {
+        File result;
+        if (path.getParent() != null) {
+            Files.createDirectories(path.getParent());
+        }
+        try (FileWriter out = new FileWriter(result = path.toAbsolutePath().toFile())) {
+            out.write(body);
+        }
+        return result;
+    }
+
+    public static File writeFile(String path, String body) throws IOException {
+        return writeFile(Paths.get(path), body);
+    }
+
+    /**
+     * A rm-like method, the file is deleted only if it exists.
+     */
+    public static void rm(Path path) throws Exception {
+        Files.deleteIfExists(path);
+    }
+
+    public static void rm(String filename) throws Exception {
+        rm(Paths.get(filename));
+    }
+
+    public static void rm(File f) throws Exception {
+        rm(f.toPath());
+    }
+
+    /**
+     * Copy source file to destination file.
+     */
+    public static void copyFile(File destfile, File srcfile)
+        throws IOException {
+        copyFile(destfile.toPath(), srcfile.toPath());
+    }
+
+    public static void copyFile(Path destPath, Path srcPath)
+        throws IOException {
+        Files.createDirectories(destPath);
+        Files.copy(srcPath, destPath, REPLACE_EXISTING);
+    }
+
+    /**
+     * Splits a String using the System's line separator character as splitting point.
+     */
+    public static List<String> splitLines(String lines) {
+        return Arrays.asList(lines.split(lineSeparator));
+    }
+
+    /**
+     * Converts a String list into one String by appending the System's line separator
+     * character after each component.
+     */
+    private static String listToString(List<String> lines) {
+        StringBuilder sb = new StringBuilder();
+        for (String s : lines) {
+            sb.append(s).append(lineSeparator);
+        }
+        return sb.toString();
+    }
+
+    /**
+     * Class representing an in-memory java source file. It is able to extract
+     * the file name from simple source codes using regular expressions.
+     */
+    public static class JavaSource extends SimpleJavaFileObject {
+        String source;
+        String name;
+
+        public JavaSource(String className, String source) {
+            super(URI.create(className),
+                    JavaFileObject.Kind.SOURCE);
+            this.name = className;
+            this.source = source;
+        }
+
+        public JavaSource(String source) {
+            super(URI.create(getJavaFileNameFromSource(source)),
+                    JavaFileObject.Kind.SOURCE);
+            this.name = getJavaFileNameFromSource(source);
+            this.source = source;
+        }
+
+        @Override
+        public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+            return source;
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/links/LinksTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4266026
+ * @summary javac no longer follows symlinks
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main LinksTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/links/links.sh
+public class LinksTest {
+
+    private static final String BSrc =
+        "package a;\n" +
+        "\n" +
+        "public class B {}";
+
+    private static final String TSrc =
+        "class T extends a.B {}";
+
+    public static void main(String args[])
+            throws Exception {
+//      mkdir tmp
+//      cp ${TESTSRC}/b/B.java tmp
+        ToolBox.writeFile(Paths.get("tmp", "B.java"), BSrc);
+
+//        ln -s `pwd`/tmp "${TESTCLASSES}/a"
+        Files.createSymbolicLink(Paths.get("a"), Paths.get("tmp"));
+//
+////"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1
+        ToolBox.JavaToolArgs javacArgs =
+                new ToolBox.JavaToolArgs()
+                .setOptions("-sourcepath", ".", "-d", ".").setSources(TSrc);
+        ToolBox.javac(javacArgs);
+    }
+
+}
--- a/langtools/test/tools/javac/links/T.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2001, 2008, 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.
- */
-
-class T extends a.B {}
--- a/langtools/test/tools/javac/links/b/B.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2001, 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.
- */
-
-package a;
-
-public class B {}
--- a/langtools/test/tools/javac/links/links.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2001, 2008, 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 4266026
-# @summary javac no longer follows symlinks
-#
-# @run shell links.sh
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    NULL=/dev/null
-    PS=":"
-    FS="/"
-    ;;
-  * )
-    echo "Unrecognized system - test skipped."
-    exit 0;
-    ;;
-esac
-
-mkdir tmp
-cp ${TESTSRC}/b/B.java tmp
-
-rm -rf T.class B.class b/B.class "${TESTCLASSES}/a" "${TESTCLASSES}/classes"
-ln -s `pwd`/tmp "${TESTCLASSES}/a"
-mkdir "${TESTCLASSES}/classes"
-
-"${TESTJAVA}/bin/javac" ${TESTTOOLVMOPTS} -sourcepath "${TESTCLASSES}" -d "${TESTCLASSES}/classes" "${TESTSRC}/T.java" 2>&1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/newlines/NewLineTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4110560 4785453
+ * @summary portability : javac.properties
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main NewLineTest
+ */
+
+import java.io.File;
+import java.nio.charset.Charset;
+import java.nio.file.Files;
+import java.util.List;
+import com.sun.tools.javac.util.ArrayUtils;
+
+//original test: test/tools/javac/newlines/Newlines.sh
+public class NewLineTest {
+
+    public static void main(String args[]) throws Exception {
+        String[] mainArgs = ToolBox.getJavacBin();
+
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Dline.separator='@' > ${TMP1} 2>&1
+        File javacErrOutput = new File("output.txt");
+        ToolBox.AnyToolArgs cmdArgs =
+                new ToolBox.AnyToolArgs(ToolBox.Expect.FAIL)
+                .setAllArgs(ArrayUtils.concatOpen(mainArgs, "-J-Dline.separator='@'"))
+                .setErrOutput(javacErrOutput);
+        ToolBox.executeCommand(cmdArgs);
+
+//        result=`cat ${TMP1} | wc -l`
+//        if [ "$result" -eq 0 ] passed
+        List<String> lines = Files.readAllLines(javacErrOutput.toPath(),
+                Charset.defaultCharset());
+        if (lines.size() != 1) {
+            throw new AssertionError("The compiler output should have one line only");
+        }
+    }
+
+}
--- a/langtools/test/tools/javac/newlines/Newlines.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#
-# 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
-# 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 4110560 4785453
-# @summary portability : javac.properties
-#
-# @run shell Newlines.sh
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TMP1=OUTPUT.txt
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -J-Dline.separator='@' > ${TMP1} 2>&1
-cat ${TMP1}
-result=`cat ${TMP1} | wc -l`
-if [ "$result" -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/stackmap/StackMapTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4955930
+ * @summary The "method0" StackMap attribute should have two entries instead of three
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile -source 6 -target 6 StackMapTest.java
+ * @run main StackMapTest
+ */
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+//original test: test/tools/javac/stackmap/T4955930.sh
+public class StackMapTest {
+
+    class Test {
+        void method0(boolean aboolean) throws Exception {
+            label_0:
+            while (true) {
+                if (aboolean) ;
+                else break label_0;
+            }
+        }
+    }
+
+    public static void main(String args[]) throws Exception {
+//    "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -source 6 -target 6 T4955930.java
+
+//    "${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -verbose T4955930 > ${TMP1}
+        Path pathToClass = Paths.get(System.getProperty("test.classes"),
+                "StackMapTest$Test.class");
+        ToolBox.JavaToolArgs javapArgs =
+                new ToolBox.JavaToolArgs().setAllArgs("-v", pathToClass.toString());
+
+//        grep "StackMapTable: number_of_entries = 2" ${TMP1}
+        if (!ToolBox.javap(javapArgs).contains("StackMapTable: number_of_entries = 2"))
+            throw new AssertionError("The number of entries of the stack map "
+                    + "table should be equal to 2");
+    }
+
+}
--- a/langtools/test/tools/javac/stackmap/T4955930.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2005, 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 4955930
- * @summary The "method0" StackMap attribute should have two entries instead of three
- * @author wtao
- *
- * @run shell T4955930.sh
- */
-
-public class T4955930 {
-
-   void method0(boolean aboolean) throws Exception {
-      label_0:
-      while (true) {
-         if (aboolean) {
-            ;
-         }
-         else {
-            break label_0;
-         }
-         System.out.println("");
-      }
-   }
-}
--- a/langtools/test/tools/javac/stackmap/T4955930.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2005, 2009, 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.
-#
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows_95 | Windows_98 | Windows_NT )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-TMP1=T4955930.javap
-
-cp "${TESTSRC}${FS}T4955930.java" .
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -source 6 -target 6 T4955930.java
-result=$?
-if [ $result -ne 0 ]
-then
-    exit $result
-fi
-
-"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -verbose T4955930 > ${TMP1}
-grep "StackMapTable: number_of_entries = 2" ${TMP1}
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
--- a/langtools/test/tools/javac/unicode/SupplementaryJavaID6.java	Tue Feb 19 00:31:45 2013 -0800
+++ b/langtools/test/tools/javac/unicode/SupplementaryJavaID6.java	Tue Feb 19 17:53:16 2013 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -21,12 +21,20 @@
  * questions.
  */
 
+/*
+ * @test
+ * @bug 4914724 4973116 5014511
+ * @summary Ensure that a supplementary character can be used as part/whole of a
+ * class name on platforms that have Unicode aware filesystems.
+ * @run main SupplementaryJavaID6
+ */
+
 public class SupplementaryJavaID6 {
     public static void main(String[] s) {
-        new SupplementaryJavaID6();
+        new SupplementaryJavaID6().test();
     }
 
-    public SupplementaryJavaID6() {
+    void test() {
         \ud801\udc00 instance = new \ud801\udc00();
         instance.\ud801\udc01();
     }
--- a/langtools/test/tools/javac/unicode/SupplementaryJavaID6.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2009, 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 4914724 4973116 5014511
-# @summary Ensure that a supplementary character can be used as part/whole of a class
-#          name on platforms that have Unicode aware filesystems.
-# @author Naoto Sato
-# @run shell SupplementaryJavaID6.sh SupplementaryJavaID6
-
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    if [ -d /usr/lib/locale/en_US.UTF-8 -o -d /usr/lib/locale/en_US.utf8 ]
-    then
-        ENV="env LANG=en_US.UTF-8"
-        PS=":"
-        FS="/"
-    else
-        echo "As there is no en_US.UTF-8 locale available on this system, the compilation of the test case may or may not fail.  Ignoring this test."
-        exit 0;
-    fi
-    ;;
-  Windows_98 | Windows_ME )
-    echo "As Windows 98/Me do not provide Unicode-aware file system, the compilation of the test case is expected to fail on these platforms.  Ignoring this test."
-    exit 0;
-    ;;
-  Windows* )
-    ENV=""
-    PS=";"
-    FS="\\"
-    ;;
-  CYGWIN* )
-    ENV=""
-    PS=";" # platform PS, not cygwin PS
-    FS="/"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-# compile
-cp "${TESTSRC}${FS}$1.java" .
-${ENV} "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . -classpath ".${PS}${TESTSRC}" $1.java
-result=$?
-
-if [ $result -ne 0 ]
-then
-  echo "Failed"
-  exit $result
-fi
-
-# run
-${ENV} "${TESTJAVA}${FS}bin${FS}java" ${TESTVMOPTS} $1 
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-
-# Cleanup
-${ENV} rm -f ./$1*.class
-
-exit $result
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javah/6257087/T6257087.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 6257087
+ * @summary javah doesn't produce proper signatures for inner class native methods
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main T6257087
+ */
+
+import java.nio.file.Paths;
+
+//original test: test/tools/javah/6257087/foo.sh
+public class T6257087 {
+
+    private static final String fooBarGoldenFile =
+        "/* DO NOT EDIT THIS FILE - it is machine generated */\n" +
+        "#include <jni.h>\n" +
+        "/* Header for class foo_bar */\n" +
+        "\n" +
+        "#ifndef _Included_foo_bar\n" +
+        "#define _Included_foo_bar\n" +
+        "#ifdef __cplusplus\n" +
+        "extern \"C\" {\n" +
+        "#endif\n" +
+        "/*\n" +
+        " * Class:     foo_bar\n" +
+        " * Method:    aardvark\n" +
+        " * Signature: ()V\n" +
+        " */\n" +
+        "JNIEXPORT void JNICALL Java_foo_00024bar_aardvark\n" +
+        "  (JNIEnv *, jobject);\n" +
+        "\n" +
+        "#ifdef __cplusplus\n" +
+        "}\n" +
+        "#endif\n" +
+        "#endif";
+
+    public static void main(String[] args) throws Exception {
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TC}" "${TS}${FS}foo.java"
+
+//        "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} -classpath "${TC}" -d "${TC}" foo
+        ToolBox.JavaToolArgs javahArgs =
+                new ToolBox.JavaToolArgs()
+                .setAllArgs("-cp", System.getProperty("test.classes"), "foo");
+        ToolBox.javah(javahArgs);
+
+//        diff ${DIFFOPTS} -c "${TS}${FS}foo_bar.h" "${TC}${FS}foo_bar.h"
+        ToolBox.compareLines(Paths.get("foo_bar.h"),
+                ToolBox.splitLines(fooBarGoldenFile), null);
+    }
+
+}
+
+class foo {
+    class bar {
+        public native void aardvark();
+    }
+}
--- a/langtools/test/tools/javah/6257087/foo.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2006, 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.
- */
-
-
-class foo {
-    class bar {
-        public native void aardvark();
-    }
-}
--- a/langtools/test/tools/javah/6257087/foo.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-#! /bin/sh -f
-
-#
-# Copyright (c) 2006, 2009, 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 6257087
-# @run shell foo.sh
-
-
-TS=${TESTSRC-.}
-TC=${TESTCLASSES-.}
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=":"
-    FS="/"
-    DIFFOPTS="--strip-trailing-cr"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d "${TC}" "${TS}${FS}foo.java" 
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} -classpath "${TC}" -d "${TC}" foo
-diff ${DIFFOPTS} -c "${TS}${FS}foo_bar.h" "${TC}${FS}foo_bar.h"
-result=$?
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
--- a/langtools/test/tools/javah/6257087/foo_bar.h	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,21 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class foo_bar */
-
-#ifndef _Included_foo_bar
-#define _Included_foo_bar
-#ifdef __cplusplus
-extern "C" {
-#endif
-/*
- * Class:     foo_bar
- * Method:    aardvark
- * Signature: ()V
- */
-JNIEXPORT void JNICALL Java_foo_00024bar_aardvark
-  (JNIEnv *, jobject);
-
-#ifdef __cplusplus
-}
-#endif
-#endif
--- a/langtools/test/tools/javah/ConstMacroTest.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,102 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2009, 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 4786406 4781221 4780341 6214324
-
-# Validates rewritten javah handling of class defined constants
-# and ensures that the appropriate macro definitions are placed
-# in the generated header file.
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-EXPECTED_JAVAH_OUT_FILE=SubClassConsts.out
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=":"
-    FS="/"
-    DIFFOPTS="--strip-trailing-cr"
-    EXPECTED_JAVAH_OUT_FILE=SubClassConsts.win
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    EXPECTED_JAVAH_OUT_FILE=SubClassConsts.win
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
- esac
-
-GENERATED_HEADER_FILE=SubClassConsts.h
-HEADER_FILE_FILTERED=SubClassConsts.h.linefeed-filtered
-
-rm -rf SuperClassConsts.class SubClassConsts.class
-
-cp "${TESTSRC}${FS}SuperClassConsts.java" .
-cp "${TESTSRC}${FS}SubClassConsts.java" .
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}SubClassConsts.java"
-
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} SubClassConsts
-
-diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}"
-result=$?
-rm ${GENERATED_HEADER_FILE}
-
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
--- a/langtools/test/tools/javah/MissingParamClassException.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-
-/*
- * ParamClassTest has a native method param which subclasses
- * this class
- *
- */
-
-public class MissingParamClassException extends Exception {
-    public MissingParamClassException() {
-        System.out.println("MissingParamClassException constructor called");
-    }
-}
--- a/langtools/test/tools/javah/MissingParamClassTest.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,124 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2009, 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 4942232
-
-#
-# Verifies that javah won't attempt to generate a header file
-# if a native method in a supplied class contains a parameter
-# type whose corresponding class is missing or not in the 
-# classpath
-
-TMP1=OUTPUT.txt
-
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    PS=":"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
- esac
-
-GENERATED_HEADER_FILE=ParamClassTest.h
-
-rm -f ParamClassTest.class MissingParamClassException.class ParamClassTest.h
-rm -f ${TMP1}
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
-
-# Before running javah remove dependent class file
-rm -f MissingParamClassException.class 
-
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
-
-if [ -f $GENERATED_HEADER_FILE ]; then
-     echo "1-- Failed: $GENERATED_HEADER_FILE found"
-     rc=1
-fi
-if [ ! -s ${TMP1} ]; then
-     echo "1-- Failed: ${TMP1} is empty"
-     rc=1
-fi
-
-# Clean out work dir
-rm -f MissingParamClassException.class ParamClassTest.class
-rm -f $GENERATED_HEADER_FILE $TMP1 
-
-# Re-compile everything
-
-"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
-
-
-# Before re-run of javah remove dependent class file Param.class 
-rm -f Param.class
-
-"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
-
-if [ -f $GENERATED_HEADER_FILE ]; then
-     echo "2-- Failed: $GENERATED_HEADER_FILE found"
-     rc=1
-fi
-if [ ! -s ${TMP1} ]; then
-     echo "2-- Failed: ${TMP1} is empty"
-     rc=1
-fi
-
-if [ "$rc" = "" ]; then
-    echo Passed
-else
-    echo Failed
-    exit 1
-fi
--- a/langtools/test/tools/javah/ParamClassTest.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-
-/*
- * Class containing a native method which contains a native
- * method with non primitive type
- */
-
-public class ParamClassTest {
-    public native void method(Param s);
-
-    public static void main(String args[]) {
-    }
-}
-
-class Param extends MissingParamClassException {
-    Param() {
-        System.out.println("Param constructor");
-    }
-}
--- a/langtools/test/tools/javah/SubClassConsts.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-
-/*
- * Subclass defines its own set of constants
- * It is itself serializable by virtue of extending SuperClassConsts
- *
- */
-public class SubClassConsts extends SuperClassConsts {
-
-    private final static int SUB_INT_CONSTANT = 2;
-    private final static double SUB_DOUBLE_CONSTANT = 2.25;
-    private final static float SUB_FLOAT_CONSTANT = 7.90f;
-    private final static boolean SUB_BOOLEAN_CONSTANT = true;
-
-    public SubClassConsts(String p) {
-        super(p);
-    }
-}
--- a/langtools/test/tools/javah/SubClassConsts.out	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class SubClassConsts */
-
-#ifndef _Included_SubClassConsts
-#define _Included_SubClassConsts
-#ifdef __cplusplus
-extern "C" {
-#endif
-#undef SubClassConsts_serialVersionUID
-#define SubClassConsts_serialVersionUID 6733861379283244755LL
-#undef SubClassConsts_SUPER_INT_CONSTANT
-#define SubClassConsts_SUPER_INT_CONSTANT 3L
-#undef SubClassConsts_SUPER_FLOAT_CONSTANT
-#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f
-#undef SubClassConsts_SUPER_DOUBLE_CONSTANT
-#define SubClassConsts_SUPER_DOUBLE_CONSTANT 33.2
-#undef SubClassConsts_SUPER_BOOLEAN_CONSTANT
-#define SubClassConsts_SUPER_BOOLEAN_CONSTANT 0L
-#undef SubClassConsts_SUB_INT_CONSTANT
-#define SubClassConsts_SUB_INT_CONSTANT 2L
-#undef SubClassConsts_SUB_DOUBLE_CONSTANT
-#define SubClassConsts_SUB_DOUBLE_CONSTANT 2.25
-#undef SubClassConsts_SUB_FLOAT_CONSTANT
-#define SubClassConsts_SUB_FLOAT_CONSTANT 7.9f
-#undef SubClassConsts_SUB_BOOLEAN_CONSTANT
-#define SubClassConsts_SUB_BOOLEAN_CONSTANT 1L
-#ifdef __cplusplus
-}
-#endif
-#endif
--- a/langtools/test/tools/javah/SubClassConsts.win	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,31 +0,0 @@
-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class SubClassConsts */
-
-#ifndef _Included_SubClassConsts
-#define _Included_SubClassConsts
-#ifdef __cplusplus
-extern "C" {
-#endif
-#undef SubClassConsts_serialVersionUID
-#define SubClassConsts_serialVersionUID 6733861379283244755i64
-#undef SubClassConsts_SUPER_INT_CONSTANT
-#define SubClassConsts_SUPER_INT_CONSTANT 3L
-#undef SubClassConsts_SUPER_FLOAT_CONSTANT
-#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f
-#undef SubClassConsts_SUPER_DOUBLE_CONSTANT
-#define SubClassConsts_SUPER_DOUBLE_CONSTANT 33.2
-#undef SubClassConsts_SUPER_BOOLEAN_CONSTANT
-#define SubClassConsts_SUPER_BOOLEAN_CONSTANT 0L
-#undef SubClassConsts_SUB_INT_CONSTANT
-#define SubClassConsts_SUB_INT_CONSTANT 2L
-#undef SubClassConsts_SUB_DOUBLE_CONSTANT
-#define SubClassConsts_SUB_DOUBLE_CONSTANT 2.25
-#undef SubClassConsts_SUB_FLOAT_CONSTANT
-#define SubClassConsts_SUB_FLOAT_CONSTANT 7.9f
-#undef SubClassConsts_SUB_BOOLEAN_CONSTANT
-#define SubClassConsts_SUB_BOOLEAN_CONSTANT 1L
-#ifdef __cplusplus
-}
-#endif
-#endif
--- a/langtools/test/tools/javah/SuperClassConsts.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-
-/*
- * Parent class implements serializable and provides static initializers
- * for a bunch of primitive type class constants
- * (required for regtest 4786406, 4780341)
- */
-
-import java.io.*;
-
-public class SuperClassConsts implements Serializable {
-
-    // Define class constant values, base class is serializable
-
-    private static final long serialVersionUID = 6733861379283244755L;
-    public static final int SUPER_INT_CONSTANT = 3;
-    public final static float SUPER_FLOAT_CONSTANT = 99.3f;
-    public final static double SUPER_DOUBLE_CONSTANT  = 33.2;
-    public final static boolean SUPER_BOOLEAN_CONSTANT  = false;
-
-    // A token instance field
-    int instanceField;
-
-    public SuperClassConsts(String p) {
-    }
-
-    public native int numValues();
-
-    private void writeObject(ObjectOutputStream s)
-        throws IOException
-    {
-        System.err.println("writing state");
-    }
-
-    /**
-     * readObject is called to restore the state of the FilePermission from
-     * a stream.
-     */
-    private void readObject(ObjectInputStream s)
-         throws IOException, ClassNotFoundException
-    {
-        System.err.println("reading back state");
-    }
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javah/T4942232/MissingParamClassTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4942232
+ * @summary Verifies that javah won't attempt to generate a header file if a
+ * native method in a supplied class contains a parameter type whose corresponding
+ * class is missing or not in the classpath
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run compile MissingParamClassTest.java
+ * @clean MissingParamClassException
+ * @run main MissingParamClassTest
+ * @run compile MissingParamClassTest.java
+ * @clean Param
+ * @run main MissingParamClassTest
+ */
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+
+//original test: test/tools/javah/MissingParamClassTest.sh
+public class MissingParamClassTest {
+
+    public static void main(String[] args) throws Exception {
+        //first steps done now by jtreg
+//"${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}ParamClassTest.java" "${TESTSRC}${FS}MissingParamClassException.java"
+//rm -f MissingParamClassException.class
+
+//"${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} ParamClassTest 2>${TMP1}
+        List<String> errOutput = new ArrayList<>();
+        ToolBox.JavaToolArgs javahParams =
+            new ToolBox.JavaToolArgs(ToolBox.Expect.FAIL)
+            .setAllArgs("-classpath", System.getProperty("test.classes"), "ParamClassTest")
+            .setErrOutput(errOutput);
+        ToolBox.javah(javahParams);
+
+//if [ -f $GENERATED_HEADER_FILE ]; then  fail
+//if [ ! -s ${TMP1} ]; then fail
+        if (Files.exists(Paths.get("ParamClassTest.h")) || errOutput.size() == 0)
+            throw new AssertionError("The only output generated by javah must be an error message");
+        //jtreg again
+//rm -f MissingParamClassException.class ParamClassTest.class
+//rm -f $GENERATED_HEADER_FILE $TMP1
+    }
+
+}
+
+class MissingParamClassException extends Exception {
+    public MissingParamClassException() {
+        System.out.println("MissingParamClassException constructor called");
+    }
+}
+
+class ParamClassTest {
+    public native void method(Param s);
+
+    public static void main(String args[]) {
+    }
+}
+
+class Param extends MissingParamClassException {
+    Param() {
+        System.out.println("Param constructor");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javah/constMacroTest/ConstMacroTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4786406 4781221 4780341 6214324
+ * @summary Validates rewritten javah handling of class defined constants and
+ * ensures that the appropriate macro definitions are placed in the generated
+ * header file.
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main ConstMacroTest
+ */
+
+import java.io.*;
+import java.nio.file.Paths;
+
+//original test: test/tools/javah/ConstMacroTest.sh
+public class ConstMacroTest {
+
+    private static final String SubClassConstsGoldenFile =
+        "/* DO NOT EDIT THIS FILE - it is machine generated */\n" +
+        "#include <jni.h>\n" +
+        "/* Header for class SubClassConsts */\n" +
+        "\n" +
+        "#ifndef _Included_SubClassConsts\n" +
+        "#define _Included_SubClassConsts\n" +
+        "#ifdef __cplusplus\n" +
+        "extern \"C\" {\n" +
+        "#endif\n" +
+        "#undef SubClassConsts_serialVersionUID\n" +
+        "#define SubClassConsts_serialVersionUID 6733861379283244755LL\n" +
+        "#undef SubClassConsts_SUPER_INT_CONSTANT\n" +
+        "#define SubClassConsts_SUPER_INT_CONSTANT 3L\n" +
+        "#undef SubClassConsts_SUPER_FLOAT_CONSTANT\n" +
+        "#define SubClassConsts_SUPER_FLOAT_CONSTANT 99.3f\n" +
+        "#undef SubClassConsts_SUPER_DOUBLE_CONSTANT\n" +
+        "#define SubClassConsts_SUPER_DOUBLE_CONSTANT 33.2\n" +
+        "#undef SubClassConsts_SUPER_BOOLEAN_CONSTANT\n" +
+        "#define SubClassConsts_SUPER_BOOLEAN_CONSTANT 0L\n" +
+        "#undef SubClassConsts_SUB_INT_CONSTANT\n" +
+        "#define SubClassConsts_SUB_INT_CONSTANT 2L\n" +
+        "#undef SubClassConsts_SUB_DOUBLE_CONSTANT\n" +
+        "#define SubClassConsts_SUB_DOUBLE_CONSTANT 2.25\n" +
+        "#undef SubClassConsts_SUB_FLOAT_CONSTANT\n" +
+        "#define SubClassConsts_SUB_FLOAT_CONSTANT 7.9f\n" +
+        "#undef SubClassConsts_SUB_BOOLEAN_CONSTANT\n" +
+        "#define SubClassConsts_SUB_BOOLEAN_CONSTANT 1L\n" +
+        "#ifdef __cplusplus\n" +
+        "}\n" +
+        "#endif\n" +
+        "#endif";
+
+    public static void main(String[] args) throws Exception {
+        //first steps are now done by jtreg
+//        cp "${TESTSRC}${FS}SuperClassConsts.java" .
+//        cp "${TESTSRC}${FS}SubClassConsts.java" .
+
+//        "${TESTJAVA}${FS}bin${FS}javac" ${TESTTOOLVMOPTS} -d . "${TESTSRC}${FS}SubClassConsts.java"
+
+//        "${TESTJAVA}${FS}bin${FS}javah" ${TESTTOOLVMOPTS} SubClassConsts
+        ToolBox.JavaToolArgs successParams =
+                new ToolBox.JavaToolArgs()
+                .setAllArgs("-cp", System.getProperty("test.classes"), "SubClassConsts");
+        ToolBox.javah(successParams);
+
+//        diff ${DIFFOPTS} "${TESTSRC}${FS}${EXPECTED_JAVAH_OUT_FILE}" "${GENERATED_HEADER_FILE}"
+        ToolBox.compareLines(Paths.get("SubClassConsts.h"),
+                ToolBox.splitLines(SubClassConstsGoldenFile), null);
+    }
+
+}
+
+class SuperClassConsts implements Serializable {
+    // Define class constant values, base class is serializable
+    private static final long serialVersionUID = 6733861379283244755L;
+    public static final int SUPER_INT_CONSTANT = 3;
+    public final static float SUPER_FLOAT_CONSTANT = 99.3f;
+    public final static double SUPER_DOUBLE_CONSTANT  = 33.2;
+    public final static boolean SUPER_BOOLEAN_CONSTANT  = false;
+    // A token instance field
+    int instanceField;
+
+    public native int numValues();
+}
+
+class SubClassConsts extends SuperClassConsts {
+    private final static int SUB_INT_CONSTANT = 2;
+    private final static double SUB_DOUBLE_CONSTANT = 2.25;
+    private final static float SUB_FLOAT_CONSTANT = 7.90f;
+    private final static boolean SUB_BOOLEAN_CONSTANT = true;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/4798312/JavapShouldLoadClassesFromRTJarTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4798312
+ * @summary In Windows, javap doesnt load classes from rt.jar
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main JavapShouldLoadClassesFromRTJarTest
+ */
+public class JavapShouldLoadClassesFromRTJarTest {
+
+    public static void main(String[] args) throws Exception {
+//        "${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} java.lang.String
+        ToolBox.JavaToolArgs params =
+                new ToolBox.JavaToolArgs().
+                setAllArgs("-v", "java.lang.String");
+        if (ToolBox.javap(params).isEmpty())
+            throw new AssertionError("javap generated no output");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/4866831/PublicInterfaceTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,52 @@
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 4866831
+ * @summary Verify that javap marks public interfaces as public
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main PublicInterfaceTest
+ */
+
+//original test: test/tools/javap/PublicInterfaceTest.sh
+public class PublicInterfaceTest {
+    public interface Test {}
+
+    public static void main(String[] args) throws Exception {
+//        "$JAVAP" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" NotPackagePrivateInterface | grep public
+        Path pathToClass = Paths.get(System.getProperty("test.classes"),
+                "PublicInterfaceTest$Test.class");
+        ToolBox.JavaToolArgs javapParams =
+                new ToolBox.JavaToolArgs()
+                .setAllArgs(pathToClass.toString());
+        if (!ToolBox.javap(javapParams).contains("public"))
+            throw new AssertionError("The javap output does not contain \"public\"");
+    }
+
+}
--- a/langtools/test/tools/javap/NotPackagePrivateInterface.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2003, 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.
- */
-
-
-/*
- * This class is used by PublicInterfaceTest.sh to generate a class
- * file with a public interface to verify javap will output the
- * "public" modifier for such interfaces.  (At the vm level, the only
- * access control properties an interface can can have are public and
- * package private.)
- */
-
-public interface NotPackagePrivateInterface {
-}
--- a/langtools/test/tools/javap/PublicInterfaceTest.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 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.
-#
-
-# @test
-# @bug 4866831
-# @build NotPackagePrivateInterface
-# @run shell PublicInterfaceTest.sh
-# @summary Verify that javap marks public interfaces as public
-# @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 [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-JAVAP="${TESTJAVA}/bin/javap"
-
-"$JAVAP" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" NotPackagePrivateInterface | grep public
-
-# If the exit status of grep is 0, then "public" was correctly found
-# in the output of javap.
-
-RESULT=$?
-case "$RESULT" in
-        0  )
-	exit 0;
-        ;;
-
-        * )
-        echo "The javap tool did not output \"public\" for a public interface."
-        exit 1
-esac
--- a/langtools/test/tools/javap/pathsep.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,63 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2003, 2009, 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 4798312
-# @summary In Windows, javap doesnt load classes from rt.jar
-# @author gafter
-#
-# @run shell pathsep.sh
-
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | CYGWIN* )
-    FS="/"
-    ;;
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} java.lang.String
-result=$?
-if [ $result -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit $result
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javap/stackmap/StackmapTest.java	Tue Feb 19 17:53:16 2013 +0000
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 6271292
+ * @summary Verify that javap prints StackMapTable attribute contents
+ * @library /tools/javac/lib
+ * @build ToolBox
+ * @run main StackmapTest
+ */
+
+import java.util.Arrays;
+import java.util.List;
+
+//original test: test/tools/javap/stackmap/T6271292.sh
+public class StackmapTest {
+
+    private static final String TestSrc =
+        "public class Test extends SuperClass {\n" +
+        "    public static void main(String[] args) {\n" +
+        "        new SuperClass((args[0].equals(\"0\")) ? 0 : 1)\n" +
+        "            .test();\n" +
+        "    }\n" +
+        "    Test(boolean b) {\n" +
+        "        super(b ? 1 : 2);\n" +
+        "    }\n" +
+        "}\n" +
+        "class SuperClass {\n" +
+        "    double d;\n" +
+        "    SuperClass(double dd) { d = dd; }\n" +
+        "    double test() {\n" +
+        "        if (d == 0)\n" +
+        "            return d;\n" +
+        "        else\n" +
+        "            return d > 0 ? d++ : d--;\n" +
+        "    }\n" +
+        "}\n";
+
+    private static final String goldenOut =
+        "frame_type = 255 /* full_frame */\n" +
+        "frame_type = 255 /* full_frame */\n" +
+        "frame_type = 73 /* same_locals_1_stack_item */\n" +
+        "frame_type = 255 /* full_frame */\n" +
+        "offset_delta = 19\n" +
+        "offset_delta = 0\n" +
+        "offset_delta = 2\n" +
+        "stack = [ uninitialized 0, uninitialized 0 ]\n" +
+        "stack = [ uninitialized 0, uninitialized 0, double ]\n" +
+        "stack = [ this ]\n" +
+        "stack = [ this, double ]\n" +
+        "locals = [ class \"[Ljava/lang/String;\" ]\n" +
+        "locals = [ class \"[Ljava/lang/String;\" ]\n" +
+        "locals = [ this, int ]\n";
+
+    public static void main(String[] args) throws Exception {
+        //        @compile T6271292.java
+        ToolBox.JavaToolArgs javacParams =
+                new ToolBox.JavaToolArgs().setSources(TestSrc);
+        ToolBox.javac(javacParams);
+
+//        "${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" -verbose T6271292 > "${JAVAPFILE}"
+        ToolBox.JavaToolArgs javapParams =
+                new ToolBox.JavaToolArgs()
+                .setAllArgs("-v", "Test.class");
+        String out = ToolBox.javap(javapParams);
+        List<String> grepResult = ToolBox.grep("frame_type", out);
+        grepResult.addAll(ToolBox.grep("offset_delta", out));
+        grepResult.addAll(ToolBox.grep("stack = ", out));
+        grepResult.addAll(ToolBox.grep("locals = ", out));
+        List<String> goldenList = Arrays.asList(goldenOut.split("\n"));
+
+//        diff -w "${OUTFILE}" "${TESTSRC}${FS}T6271292.out"
+        ToolBox.compareLines(goldenList, grepResult, true);
+    }
+
+}
--- a/langtools/test/tools/javap/stackmap/T6271292.java	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2005, 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.
- */
-
-
-public class T6271292 extends SuperClass {
-
-    public static void main(String[] args) {
-        SuperClass s = new SuperClass((args[0].equals("0")) ? 0 : 1);
-        s.test();
-    }
-    T6271292(boolean b) {
-        super(b ? 1 : 2);
-    }
-}
-
-class SuperClass {
-    double d;
-    SuperClass(double dd) { d = dd; }
-
-    double test() {
-        if (d == 0) {
-            return d;
-        } else if (d > 0) {
-            return d++;
-        } else {
-            return d--;
-        }
-    }
-}
--- a/langtools/test/tools/javap/stackmap/T6271292.out	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,14 +0,0 @@
-   frame_type = 255 /* full_frame */
-   frame_type = 255 /* full_frame */
-   frame_type = 73 /* same_locals_1_stack_item */
-   frame_type = 255 /* full_frame */
-     offset_delta = 19
-     offset_delta = 0
-     offset_delta = 2
-     stack = [ uninitialized 0, uninitialized 0 ]
-     stack = [ uninitialized 0, uninitialized 0, double ]
-     stack = [ this ]
-     stack = [ this, double ]
-     locals = [ class "[Ljava/lang/String;" ]
-     locals = [ class "[Ljava/lang/String;" ]
-     locals = [ this, int ]
--- a/langtools/test/tools/javap/stackmap/T6271292.sh	Tue Feb 19 00:31:45 2013 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2005, 2009, 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 6271292
-# @compile T6271292.java
-# @run shell T6271292.sh
-# @summary Verify that javap prints StackMapTable attribute contents
-# @author Wei Tao
-    
-if [ "${TESTSRC}" = "" ]
-then
-  echo "TESTSRC not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf 'TESTSRC="%s"' "${TESTSRC}" >&2 ; echo >&2
-if [ "${TESTJAVA}" = "" ]
-then
-  echo "TESTJAVA not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf 'TESTJAVA="%s"' "${TESTJAVA}" >&2 ; echo >&2
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-printf 'TESTCLASSES="%s"' "${TESTCLASSES}" >&2 ; echo >&2
-printf 'CLASSPATH="%s"' "${CLASSPATH}" >&2 ; echo >&2
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-JAVAPFILE=T6271292.javap
-OUTFILE=outfile
-
-"${TESTJAVA}${FS}bin${FS}javap" ${TESTTOOLVMOPTS} -classpath "${TESTCLASSES}" -verbose T6271292 > "${JAVAPFILE}"
-result="$?"
-if [ "$result" -ne 0 ] 
-then
-  exit "$result"
-fi
-
-grep "frame_type" "${JAVAPFILE}" > "${OUTFILE}"
-grep "offset_delta" "${JAVAPFILE}" >> "${OUTFILE}"
-grep "stack = " "${JAVAPFILE}" >> "${OUTFILE}"
-grep "locals = " "${JAVAPFILE}" >> "${OUTFILE}"
-diff -w "${OUTFILE}" "${TESTSRC}${FS}T6271292.out"
-result="$?"
-if [ "$result" -eq 0 ]
-then
-  echo "Passed"
-else
-  echo "Failed"
-fi
-exit "$result"
-
-