8166139: Refactor java/net shell cases to java
authorxiaofeya
Tue, 30 May 2017 07:03:33 -0700
changeset 45285 7f8db2139152
parent 45284 f80c912ae287
child 45286 cd809e28c082
8166139: Refactor java/net shell cases to java Reviewed-by: chegar, rriggs
jdk/test/java/net/Socket/OldSocketImpl.sh
jdk/test/java/net/Socket/OldSocketImplTestDriver.java
jdk/test/java/net/URL/B5086147.java
jdk/test/java/net/URL/B5086147.sh
jdk/test/java/net/URLClassLoader/B5077773.java
jdk/test/java/net/URLClassLoader/B5077773.sh
jdk/test/java/net/URLClassLoader/closetest/CloseTest.java
jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java
jdk/test/java/net/URLClassLoader/closetest/build.sh
jdk/test/java/net/URLClassLoader/closetest/build2.sh
jdk/test/java/net/URLClassLoader/getresourceasstream/TestDriver.java
jdk/test/java/net/URLClassLoader/getresourceasstream/policy
jdk/test/java/net/URLClassLoader/getresourceasstream/test.sh
jdk/test/java/net/URLClassLoader/sealing/CheckSealed.java
jdk/test/java/net/URLClassLoader/sealing/CheckSealedTest.java
jdk/test/java/net/URLClassLoader/sealing/checksealed.sh
jdk/test/java/net/URLConnection/6212146/Test.java
jdk/test/java/net/URLConnection/6212146/TestDriver.java
jdk/test/java/net/URLConnection/6212146/test.sh
jdk/test/java/net/URLConnection/UNCTest.java
jdk/test/java/net/URLConnection/UNCTest.sh
--- a/jdk/test/java/net/Socket/OldSocketImpl.sh	Fri May 26 16:35:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#
-# Copyright (c) 2006, 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 6449565
-# @run shell/timeout=140 OldSocketImpl.sh
-# @summary Pre-1.4 SocketImpl no longer supported
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | AIX )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-# no need to compile the test. It is already compiled
-# with 1.3 and in OldStyleImpl.jar
-
-# run
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp ${TESTSRC}${FS}OldSocketImpl.jar OldSocketImpl
-result=$?
-if [ "$result" -ne "0" ]; then
-    exit 1
-fi
-
-# no failures, exit.
-exit 0
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/Socket/OldSocketImplTestDriver.java	Tue May 30 07:03:33 2017 -0700
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2017, 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 jdk.test.lib.process.ProcessTools;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * @test
+ * @bug 6449565
+ * @library /test/lib
+ * @build jdk.test.lib.process.ProcessTools
+ * @run main OldSocketImplTestDriver
+ * @summary Test driver for OdlSocketImpl
+ */
+public class OldSocketImplTestDriver {
+    public static void main(String[] args) throws Throwable {
+        Path jar = Paths.get(System.getProperty("test.src"),
+                "OldSocketImpl.jar");
+        ProcessTools.executeTestJava("-cp", jar.toString(), "OldSocketImpl")
+                    .outputTo(System.out)
+                    .errorTo(System.out)
+                    .shouldHaveExitValue(0);
+    }
+}
--- a/jdk/test/java/net/URL/B5086147.java	Fri May 26 16:35:45 2017 +0200
+++ b/jdk/test/java/net/URL/B5086147.java	Tue May 30 07:03:33 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2017, 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
@@ -24,12 +24,13 @@
 /**
  * @test
  * @bug 5086147
- * @run shell B5086147.sh
+ * @requires (os.family == "windows")
+ * @run main B5086147
  * @summary File,URI,URL conversions are strange for UNC path
  */
 
-import java.net.*;
-import java.io.*;
+import java.io.File;
+import java.net.URI;
 
 public class B5086147 {
     public static final void main( String[] aaParamters ) throws Exception{
--- a/jdk/test/java/net/URL/B5086147.sh	Fri May 26 16:35:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,56 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 2005, 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.
-#
-
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Linux | Darwin | AIX )
-    exit 0
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}B5086147.java
-
-failures=0
-
-echo ''
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} B5086147
-if [ $? != 0 ]; then failures=`expr $failures + 1`; fi
-
-if [ "$failures" != "0" ]; then
-    echo $failures tests failed
-    exit 1;
-fi
--- a/jdk/test/java/net/URLClassLoader/B5077773.java	Fri May 26 16:35:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2004, 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.*;
-import java.net.*;
-
-public class B5077773 {
-
-    public static void main(String[] args) throws Exception {
-        URLClassLoader loader =  new URLClassLoader (new URL[] {new URL("file:foo.jar")});
-        /* This test will fail if the file below is removed from rt.jar */
-        InputStream is = loader.getResourceAsStream ("javax/swing/text/rtf/charsets/mac.txt");
-        if (is == null) {
-            System.out.println ("could not find mac.txt");
-            return;
-        }
-        int c=0;
-        while ((is.read()) != -1) {
-            c++;
-        }
-        if (c == 26) /* size of bad file */  {
-            throw new RuntimeException ("Wrong mac.txt file was loaded");
-        }
-    }
-}
--- a/jdk/test/java/net/URLClassLoader/B5077773.sh	Fri May 26 16:35:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,66 +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
-# @author Michael McMahon
-# @bug 5077773
-# @summary Change in behaviour w.r.t jdk1.4.2 when loading resourcebundles
-#
-# ${TESTJAVA} is pointing to the jre
-#
-# set platform-dependent variables
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Darwin | AIX )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-cp ${TESTSRC}${FS}foo.jar .
-
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
-    ${TESTSRC}${FS}B5077773.java
-
-WD=`pwd`
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} B5077773
-
--- a/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java	Fri May 26 16:35:45 2017 +0200
+++ b/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java	Tue May 30 07:03:33 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,24 +26,32 @@
  * @bug 4167874
  * @modules java.logging
  *          jdk.httpserver
+ *          jdk.compiler
  * @library ../../../../com/sun/net/httpserver
- * @library /lib/testlibrary
- * @build FileServerHandler jdk.testlibrary.FileUtils
- * @run shell build.sh
+ *          /lib/testlibrary
+ * @build FileServerHandler jdk.testlibrary.FileUtils JarUtils CompilerUtils
  * @run main/othervm CloseTest
  * @summary URL-downloaded jar files can consume all available file descriptors
  */
 
 import java.io.File;
+import java.io.IOException;
 import java.lang.reflect.Method;
 import java.net.URLClassLoader;
 import java.net.InetSocketAddress;
 import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
 import com.sun.net.httpserver.HttpContext;
 import com.sun.net.httpserver.HttpServer;
 
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
 public class CloseTest extends Common {
-
+    private static final String WORK_DIR = System.getProperty("user.dir")
+            + "/";
 //
 // needs two jar files test1.jar and test2.jar with following structure
 //
@@ -54,39 +62,31 @@
 //
 // and a directory hierarchy with the same structure/contents
 
-    public static void main (String args[]) throws Exception {
+    public static void main(String args[]) throws Exception {
+        setup();
 
-        String workdir = System.getProperty("test.classes");
-        if (workdir == null) {
-            workdir = args[0];
-        }
-        if (!workdir.endsWith("/")) {
-            workdir = workdir+"/";
-        }
+        startHttpServer(WORK_DIR + "serverRoot/");
 
-        startHttpServer (workdir+"serverRoot/");
-
-        String testjar = workdir + "test.jar";
-        copyFile (workdir+"test1.jar", testjar);
-        test (testjar, 1);
+        String testjar = WORK_DIR + "test.jar";
+        copyFile(WORK_DIR + "test1.jar", testjar);
+        test(testjar, 1);
 
         // repeat test with different implementation
         // of test.jar (whose TestClass.getValue() returns 2
-
-        copyFile (workdir+"test2.jar", testjar);
-        test (testjar, 2);
+        copyFile(WORK_DIR + "test2.jar", testjar);
+        test(testjar, 2);
 
         // repeat test using a directory of files
-        String testdir=workdir+"testdir/";
-        rm_minus_rf (new File(testdir));
-        copyDir (workdir+"test1/", testdir);
-        test (testdir, 1);
+        String testdir = WORK_DIR + "testdir/";
+        rm_minus_rf(new File(testdir));
+        copyDir(WORK_DIR + "test1/", testdir);
+        test(testdir, 1);
 
-        testdir=workdir+"testdir/";
-        rm_minus_rf (new File(testdir));
-        copyDir (workdir+"test2/", testdir);
-        test (testdir, 2);
-        getHttpServer().stop (3);
+        testdir = WORK_DIR + "testdir/";
+        rm_minus_rf(new File(testdir));
+        copyDir(WORK_DIR + "test2/", testdir);
+        test(testdir, 2);
+        getHttpServer().stop(3);
     }
 
     // create a loader on jarfile (or directory), plus a http loader
@@ -98,47 +98,48 @@
     // check existing classes can be loaded
     // check boot classes can be loaded
 
-    static void test (String name, int expectedValue) throws Exception {
-        URL url = new URL ("file", null, name);
+    static void test(String name, int expectedValue) throws Exception {
+
+        URL url = new URL("file", null, name);
         URL url2 = getServerURL();
-        System.out.println ("Doing tests with URL: " + url + " and " + url2);
+        System.out.println("Doing tests with URL: " + url + " and " + url2);
         URL[] urls = new URL[2];
-        urls[0] =  url;
-        urls[1] =  url2;
-        URLClassLoader loader = new URLClassLoader (urls);
-        Class testclass = loadClass ("com.foo.TestClass", loader, true);
-        Class class2 = loadClass ("Test", loader, true); // from http
+        urls[0] = url;
+        urls[1] = url2;
+        URLClassLoader loader = new URLClassLoader(urls);
+        Class testclass = loadClass("com.foo.TestClass", loader, true);
+        Class class2 = loadClass("Test", loader, true); // from http
         class2.newInstance();
         Object test = testclass.newInstance();
         Method method = testclass.getDeclaredMethods()[0]; // int getValue();
-        int res = (Integer) method.invoke (test);
+        int res = (Integer) method.invoke(test);
 
         if (res != expectedValue) {
-            throw new RuntimeException ("wrong value from getValue() ["+res+
-                        "/"+expectedValue+"]");
+            throw new RuntimeException("wrong value from getValue() [" + res +
+                    "/" + expectedValue + "]");
         }
 
         // should find /resource1
-        URL u1 = loader.findResource ("com/foo/Resource1");
+        URL u1 = loader.findResource("com/foo/Resource1");
         if (u1 == null) {
-            throw new RuntimeException ("can't find com/foo/Resource1 in test1.jar");
+            throw new RuntimeException("can't find com/foo/Resource1 in test1.jar");
         }
-        loader.close ();
+        loader.close();
 
         // should NOT find /resource2 even though it is in jar
-        URL u2 = loader.findResource ("com/foo/Resource2");
+        URL u2 = loader.findResource("com/foo/Resource2");
         if (u2 != null) {
-            throw new RuntimeException ("com/foo/Resource2 unexpected in test1.jar");
+            throw new RuntimeException("com/foo/Resource2 unexpected in test1.jar");
         }
 
         // load tests
-        loadClass ("com.foo.TestClass1", loader, false);
-        loadClass ("com.foo.TestClass", loader, true);
-        loadClass ("java.util.ArrayList", loader, true);
+        loadClass("com.foo.TestClass1", loader, false);
+        loadClass("com.foo.TestClass", loader, true);
+        loadClass("java.util.ArrayList", loader, true);
 
         // now check we can delete the path
-        rm_minus_rf (new File(name));
-        System.out.println (" ... OK");
+        rm_minus_rf(new File(name));
+        System.out.println(" ... OK");
     }
 
     static HttpServer httpServer;
@@ -147,17 +148,54 @@
         return httpServer;
     }
 
-    static URL getServerURL () throws Exception {
+    static URL getServerURL() throws Exception {
         int port = httpServer.getAddress().getPort();
-        String s = "http://127.0.0.1:"+port+"/";
+        String s = "http://127.0.0.1:" + port + "/";
         return new URL(s);
     }
 
-    static void startHttpServer (String docroot) throws Exception {
-        httpServer = HttpServer.create (new InetSocketAddress(0), 10);
-        HttpContext ctx = httpServer.createContext (
+    static void startHttpServer(String docroot) throws Exception {
+        httpServer = HttpServer.create(new InetSocketAddress(0), 10);
+        HttpContext ctx = httpServer.createContext(
                 "/", new FileServerHandler(docroot)
         );
         httpServer.start();
     }
+
+    /**
+     * Prepare jars files for the tests
+     */
+    private static void setup () throws IOException {
+        String[] tests = new String[]{"test1", "test2"};
+        Path workDir = Paths.get(WORK_DIR);
+        Path testSrc = Paths.get(System.getProperty("test.src"));
+        for (String test : tests) {
+            Path testSrcDir =  testSrc.resolve(test);
+            Path testTargetDir = workDir.resolve(test);
+            // Compile sources for corresponding test
+            CompilerUtils.compile(testSrcDir, testTargetDir);
+            // Copy all resources
+            Path packages = Paths.get("com", "foo");
+            Path copySrcDir = testSrcDir.resolve(packages);
+            Path copyTargetDir = testTargetDir.resolve(packages);
+            Files.createDirectories(copyTargetDir);
+            Path res1 = Paths.get("Resource1");
+            Path res2 = Paths.get("Resource2");
+            Files.copy(copySrcDir.resolve(res1), copyTargetDir.resolve(res1),
+                       REPLACE_EXISTING);
+            Files.copy(copySrcDir.resolve(res2), copyTargetDir.resolve(res2),
+                       REPLACE_EXISTING);
+            // Create jar
+            JarUtils.createJarFile(workDir.resolve(test + ".jar"), testTargetDir);
+        }
+
+        // Copy and compile server test class
+        Path serverRoot = Paths.get("serverRoot");
+        Path targetDir = workDir.resolve(serverRoot);
+        Path file = Paths.get("Test.java");
+        Files.createDirectories(targetDir);
+        Files.copy(testSrc.resolve(serverRoot).resolve(file),
+                   targetDir.resolve(file), REPLACE_EXISTING);
+        CompilerUtils.compile(targetDir, targetDir);
+    }
 }
--- a/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java	Fri May 26 16:35:45 2017 +0200
+++ b/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java	Tue May 30 07:03:33 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,15 +25,24 @@
  * @test
  * @bug 6899919
  * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
- * @run shell build2.sh
+ * @modules jdk.compiler
+ * @build jdk.testlibrary.FileUtils JarUtils CompilerUtils
  * @run main/othervm GetResourceAsStream
  */
 
-import java.io.*;
-import java.net.*;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+import java.nio.file.StandardOpenOption;
 
 public class GetResourceAsStream extends Common {
+    private static  final String WORK_DIR = System.getProperty("user.dir");
 
 /*
  * We simply test various scenarios with class/resource files
@@ -42,35 +51,30 @@
  * on Windows. It will still run correctly on other platforms
  */
     public static void main (String args[]) throws Exception {
-
-        String workdir = System.getProperty("test.classes");
-        if (workdir == null) {
-            workdir = args[0];
-        }
+        setup();
 
         /* the jar we copy for each test */
-        File srcfile = new File (workdir, "foo.jar");
+        File srcfile = new File(WORK_DIR, "foo.jar");
 
         /* the jar we use for the test */
-        File testfile = new File (workdir, "test.jar");
+        File testfile = new File(WORK_DIR, "test.jar");
 
-        copyFile (srcfile, testfile);
-        test (testfile, false, false);
+        copyFile(srcfile, testfile);
+        test(testfile, false, false);
 
-        copyFile (srcfile, testfile);
-        test (testfile, true, false);
+        copyFile(srcfile, testfile);
+        test(testfile, true, false);
 
-        copyFile (srcfile, testfile);
-        test (testfile, true, true);
+        copyFile(srcfile, testfile);
+        test(testfile, true, true);
 
         // repeat test using a directory of files
 
-        File testdir= new File (workdir, "testdir");
-        File srcdir= new File (workdir, "test3");
+        File testdir = new File(WORK_DIR, "testdir");
+        File srcdir = new File(WORK_DIR, "test3");
 
-        copyDir (srcdir, testdir);
-        test (testdir, true, false);
-
+        copyDir(srcdir, testdir);
+        test(testdir, true, false);
     }
 
     // create a loader on jarfile (or directory)
@@ -82,7 +86,7 @@
     static void test (File file, boolean loadclass, boolean readall)
         throws Exception
     {
-        URL[] urls = new URL[] {file.toURL()};
+        URL[] urls = new URL[] {file.toURI().toURL()};
         System.out.println ("Doing tests with URL: " + urls[0]);
         URLClassLoader loader = new URLClassLoader (urls);
         if (loadclass) {
@@ -97,7 +101,7 @@
 
         loader.close ();
 
-        // shouuld not find bye.txt now
+        // should not find bye.txt now
         InputStream s1 = loader.getResourceAsStream("bye.txt");
         if (s1 != null) {
             throw new RuntimeException ("closed loader returned resource");
@@ -107,4 +111,26 @@
         rm_minus_rf (file);
         System.out.println (" ... OK");
     }
+
+    /**
+     * Prepare jars files for the tests
+     */
+    private static void setup () throws IOException {
+        Path classes = Paths.get(WORK_DIR);
+        Path testSrc = Paths.get(System.getProperty("test.src"),
+                "test1", "com", "foo", "TestClass.java");
+        Path targetDir = classes.resolve("test3");
+        Path testTarget = targetDir.resolve("TestClass.java");
+        Files.createDirectories(targetDir);
+        Files.copy(testSrc, testTarget, StandardCopyOption.REPLACE_EXISTING);
+        // Compile sources for corresponding test
+        CompilerUtils.compile(targetDir, targetDir);
+        // Prepare txt files
+        Files.write(targetDir.resolve("hello.txt"), "Hello world".getBytes(),
+                    StandardOpenOption.CREATE);
+        Files.write(targetDir.resolve("bye.txt"), "Bye world".getBytes(),
+                    StandardOpenOption.CREATE);
+        // Create jar
+        JarUtils.createJarFile(classes.resolve("foo.jar"), targetDir);
+    }
 }
--- a/jdk/test/java/net/URLClassLoader/closetest/build.sh	Fri May 26 16:35:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-#!/bin/sh
-# 
-# Copyright (c) 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.
-# 
-#
-#
-# This script builds the test files for the test
-# but not the actual test sources themselves.
-#
-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 [ "${COMPILEJAVA}" = "" ]; then
-  COMPILEJAVA="${TESTJAVA}"
-fi
-echo "COMPILEJAVA=${COMPILEJAVA}"
-
-if [ "${TESTCLASSES}" = "" ]
-then
-  echo "TESTCLASSES not set.  Test cannot execute.  Failed."
-  exit 1
-fi
-
-JAVAC="${COMPILEJAVA}/bin/javac"
-JAR="${COMPILEJAVA}/bin/jar"
-
-rm -rf ${TESTCLASSES}/test1
-rm -rf ${TESTCLASSES}/test2
-rm -rf ${TESTCLASSES}/serverRoot
-mkdir -p ${TESTCLASSES}/test1/com/foo
-mkdir -p ${TESTCLASSES}/test2/com/foo
-mkdir -p ${TESTCLASSES}/serverRoot
-
-cd ${TESTSRC}/test1/com/foo
-cp * ${TESTCLASSES}/test1/com/foo
-cd ${TESTCLASSES}/test1
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} com/foo/*.java
-${JAR} ${TESTTOOLVMOPTS} cvf ../test1.jar com/foo/*.class com/foo/Resource*
-
-cd ${TESTSRC}/test2/com/foo
-cp * ${TESTCLASSES}/test2/com/foo
-cd ${TESTCLASSES}/test2
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} com/foo/*.java
-${JAR} ${TESTTOOLVMOPTS} cvf ../test2.jar com/foo/*.class com/foo/Resource*
-
-cp ${TESTSRC}/serverRoot/Test.java ${TESTCLASSES}/serverRoot
-cd ${TESTCLASSES}/serverRoot
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} Test.java
--- a/jdk/test/java/net/URLClassLoader/closetest/build2.sh	Fri May 26 16:35:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,58 +0,0 @@
-#!/bin/sh
-#
-#  Copyright (c) 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.
-#
-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
-
-JAVAC="${TESTJAVA}/bin/javac"
-JAR="${TESTJAVA}/bin/jar"
-
-rm -rf ${TESTCLASSES}/test3
-mkdir -p ${TESTCLASSES}/test3
-
-echo "Hello world" > ${TESTCLASSES}/test3/hello.txt
-echo "Bye world" > ${TESTCLASSES}/test3/bye.txt
-cp ${TESTSRC}/test1/com/foo/TestClass.java ${TESTCLASSES}/test3
-cd ${TESTCLASSES}/test3
-${JAVAC} -d . TestClass.java
-
-${JAR} cvf foo.jar hello.txt bye.txt com/foo/TestClass.class
-rm -f ../foo.jar
-mv foo.jar ..
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLClassLoader/getresourceasstream/TestDriver.java	Tue May 30 07:03:33 2017 -0700
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2017, 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 5103449
+ * @summary REGRESSION: getResourceAsStream is broken in JDK1.5.0-rc
+ * @library /test/lib
+ * @build jdk.test.lib.JDKToolFinder
+ *        jdk.test.lib.process.ProcessTools
+ *        Test
+ * @run main/othervm TestDriver
+ */
+
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+public class TestDriver {
+    private static final String ARCHIVE_NAME = "test.jar";
+    private static final String TEST_NAME = "Test";
+    private static final String POLICY_FILE = "policy";
+    public static void main(String[] args)
+            throws Throwable {
+
+        Path userDir = Paths.get(System.getProperty("user.dir"));
+        String java = JDKToolFinder.getTestJDKTool("java");
+        String basename = userDir.getFileName().toString();
+        setup(userDir);
+        ProcessBuilder[] tests = new ProcessBuilder[]{
+                new ProcessBuilder(
+                        java, TEST_NAME, "./" + ARCHIVE_NAME
+                ),
+                new ProcessBuilder(
+                        java, "-cp", ".",
+                        "-Djava.security.policy=file:./policy",
+                        "-Djava.security.manager",
+                        TEST_NAME, "./" + ARCHIVE_NAME
+                ),
+                new ProcessBuilder(
+                        java, "-cp", ".",
+                        "-Djava.security.policy=file:./policy",
+                        "-Djava.security.manager",
+                        TEST_NAME, "./" + ARCHIVE_NAME
+                ),
+                new ProcessBuilder(
+                        java, "-cp", "..",
+                        "-Djava.security.policy=file:../policy",
+                        "-Djava.security.manager",
+                        TEST_NAME, "../" + ARCHIVE_NAME
+                ).directory(userDir.resolve("tmp").toFile()),
+                new ProcessBuilder(
+                        java, "-cp", basename,
+                        "-Djava.security.policy=file:" + basename + "/policy",
+                        "-Djava.security.manager",
+                        TEST_NAME, basename + "/" + ARCHIVE_NAME
+                ).directory(userDir.resolve("..").toFile())};
+        for (ProcessBuilder test : tests) {
+            runTest(test);
+        }
+    }
+
+    private static void setup(Path userDir) throws IOException {
+        Path src = Paths.get(System.getProperty("test.src"));
+        Path testJar = src.resolve(ARCHIVE_NAME);
+        Path policy = src.resolve(POLICY_FILE);
+        Path testClass = Paths.get(System.getProperty("test.classes"),
+                                   TEST_NAME + ".class");
+        Files.copy(testJar, userDir.resolve(ARCHIVE_NAME), REPLACE_EXISTING);
+        Files.copy(policy, userDir.resolve(POLICY_FILE), REPLACE_EXISTING);
+        Files.copy(testClass, userDir.resolve(TEST_NAME + ".class"),
+                   REPLACE_EXISTING);
+        Files.createDirectories(userDir.resolve("tmp"));
+    }
+
+    private static void runTest(ProcessBuilder pb) throws Exception {
+        System.out.println("Testing with command: [" + pb.command() + "]");
+        ProcessTools.executeProcess(pb)
+                    .outputTo(System.out)
+                    .errorTo(System.err)
+                    .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLClassLoader/getresourceasstream/policy	Tue May 30 07:03:33 2017 -0700
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2017, 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.
+ */
+
+grant {
+    permission java.lang.RuntimePermission "createClassLoader";
+};
--- a/jdk/test/java/net/URLClassLoader/getresourceasstream/test.sh	Fri May 26 16:35:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2004, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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.
-#
-
-set -x
-# @test
-# @bug 5103449
-# @run shell test.sh
-# @summary REGRESSION: getResourceAsStream is broken in JDK1.5.0-rc
-#      
-
-
-cat << POLICY > policy
-grant {
-    permission java.lang.RuntimePermission "createClassLoader";
-};
-POLICY
-
-checkExit () {
-    if [ $? != 0 ]; then
-	exit $1;
-    fi
-}
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java
-cp ${TESTSRC}/test.jar .
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test ./test.jar
-checkExit 1
-
-# try with security manager
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.security.policy=file:./policy \
-		-Djava.security.manager Test ./test.jar
-checkExit 2
-
-mkdir tmp
-cd tmp
-${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.security.policy=file:../policy \
-		-cp .. -Djava.security.manager Test ../test.jar
-checkExit 3
-
-cd ..
-THISDIR=$(basename $(pwd))
-cd ..
-${TESTJAVA}/bin/java ${TESTVMOPTS} -Djava.security.policy=file:$THISDIR/policy \
-		-cp $THISDIR -Djava.security.manager Test $THISDIR/test.jar
-checkExit 4
-
-exit 0
--- a/jdk/test/java/net/URLClassLoader/sealing/CheckSealed.java	Fri May 26 16:35:45 2017 +0200
+++ b/jdk/test/java/net/URLClassLoader/sealing/CheckSealed.java	Tue May 30 07:03:33 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, 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,13 +21,6 @@
  * questions.
  */
 
-/*
- * @test
- * @bug 4244970
- * @summary Test to see if sealing violation is detected correctly
- * @run shell checksealed.sh
- *
- */
 public class CheckSealed {
 
     public static void main(String[] argv) throws Exception {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLClassLoader/sealing/CheckSealedTest.java	Tue May 30 07:03:33 2017 -0700
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2017, 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 4244970
+ * @summary Test to see if sealing violation is detected correctly
+ * @library /test/lib
+ * @build jdk.test.lib.JDKToolFinder
+ *        jdk.test.lib.process.OutputAnalyzer
+ * @run main CheckSealedTest
+ */
+
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.List;
+
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+public class CheckSealedTest {
+    private static final String ARCHIVE_NAME = "b.jar";
+    private static final String TEST_NAME = "CheckSealed";
+    public static void main(String[] args)
+            throws Throwable {
+
+        String baseDir = System.getProperty("user.dir") + File.separator;
+        String javac = JDKToolFinder.getTestJDKTool("javac");
+        String java = JDKToolFinder.getTestJDKTool("java");
+
+        setup(baseDir);
+        String srcDir = System.getProperty("test.src");
+        String cp = srcDir + File.separator + "a" + File.pathSeparator
+                + srcDir + File.separator + "b.jar" + File.pathSeparator
+                + ".";
+        List<String[]> allCMDs = List.of(
+                // Compile command
+                new String[]{
+                        javac, "-cp", cp, "-d", ".",
+                        srcDir + File.separator + TEST_NAME + ".java"
+                },
+                // Run test the first time
+                new String[]{
+                        java, "-cp", cp, TEST_NAME, "1"
+                },
+                // Run test the second time
+                new String[]{
+                        java, "-cp", cp, TEST_NAME, "2"
+                }
+        );
+
+        for (String[] cmd : allCMDs) {
+            ProcessTools.executeCommand(cmd)
+                        .outputTo(System.out)
+                        .errorTo(System.out)
+                        .shouldHaveExitValue(0);
+        }
+    }
+
+    private static void setup(String baseDir) throws IOException {
+        Path testJar = Paths.get(System.getProperty("test.src"), ARCHIVE_NAME);
+        Files.copy(testJar, Paths.get(baseDir, ARCHIVE_NAME), REPLACE_EXISTING);
+    }
+}
--- a/jdk/test/java/net/URLClassLoader/sealing/checksealed.sh	Fri May 26 16:35:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#! /bin/sh
-
-#
-# Copyright (c) 1999, 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.
-#
-
-#
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Darwin | AIX )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-
-if [ x"$TESTJAVA" = x ]; then TESTJAVA=$1; fi
-if [ x"$COMPILEJAVA" = x ]; then COMPILEJAVA=$1; fi
-if [ x"$TESTSRC" = x ]; then TESTSRC=.; fi
-
-CLASSPATH=".${PS}${TESTSRC}${FS}a${PS}${TESTSRC}${FS}b.jar"
-
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath "${CLASSPATH}" -d . \
-    ${TESTSRC}${FS}CheckSealed.java
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp "${CLASSPATH}" CheckSealed 1
-if [ $? != 0 ]; then exit 1; fi
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -cp "${CLASSPATH}" CheckSealed 2
-if [ $? != 0 ]; then exit 1; fi
--- a/jdk/test/java/net/URLConnection/6212146/Test.java	Fri May 26 16:35:45 2017 +0200
+++ b/jdk/test/java/net/URLConnection/6212146/Test.java	Tue May 30 07:03:33 2017 -0700
@@ -21,49 +21,43 @@
  * questions.
  */
 
-import java.net.*;
-import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.file.Paths;
 
 public class Test {
 
     public static void main(String[] args)
          throws Exception {
-      String BASE_DIR = args[0];
-      String ARCHIVE_NAME = args[1];
-      String lProperty = System.getProperty( "do.iterations", "5000" );
-      int lRepetitions = new Integer( lProperty ).intValue();
-      System.out.println ( "Start creating copys of the archive, " + lRepetitions + " times" );
-      for( int i = 0; i < lRepetitions; i++ ) {
-         // Copy the given jar file and add a prefix
-         copyFile( BASE_DIR, ARCHIVE_NAME, i);
+        String baseDir = args[0];
+        String archiveName = args[1];
+        String lProperty = System.getProperty("do.iterations", "5000");
+        int lRepetitions = Integer.valueOf(lProperty);
+        System.out.println("Start creating copys of the archive, "
+                + lRepetitions + " times");
+        for (int i = 0; i < lRepetitions; i++) {
+            // Copy the given jar file and add a prefix
+            copyFile(baseDir, archiveName, i);
+        }
+        System.out.println("Start opening the archives archive, "
+                + lRepetitions + " times");
+        System.out.println("First URL is jar:" + Paths.get(baseDir,
+                0 + archiveName).toUri() + "!/foo/Test.class");
+        for (int i = 0; i < lRepetitions; i++) {
+            // Create URL
+            String lURLPath = "jar:" + Paths.get(baseDir, i
+                    + archiveName).toUri() + "!/foo/Test.class";
+            URL lURL = new URL(lURLPath);
+            // Open URL Connection
+            try {
+                URLConnection lConnection = lURL.openConnection();
+                lConnection.getInputStream();
+            } catch (java.io.FileNotFoundException fnfe) {
+                // Ignore this one because we expect this one
+            } catch (java.util.zip.ZipException ze) {
+                throw new RuntimeException("Test failed: " + ze.getMessage());
+            }
       }
-      System.out.println ( "Start opening the archives archive, " + lRepetitions + " times" );
-      System.out.println ( "First URL is jar:file://" + BASE_DIR + "1" + ARCHIVE_NAME + "!/foo/Test.class");
-      for( int i = 0; i < lRepetitions; i++ ) {
-         // Create ULR
-         String lURLPath = "jar:file://" + BASE_DIR + i + ARCHIVE_NAME + "!/foo/Test.class";
-         URL lURL = new URL( lURLPath );
-         // Open URL Connection
-         try {
-            URLConnection lConnection = lURL.openConnection();
-            lConnection.getInputStream();
-         } catch( java.io.FileNotFoundException fnfe ) {
-            // Ignore this one because we expect this one
-         } catch( java.util.zip.ZipException ze ) {
-            throw new RuntimeException ("Test failed: " + ze.getMessage());
-         }
-      }
-      //System.out.println ( "Done testing, waiting 20 seconds for checking" );
-      //System.out.println ( "Cleaning up");
-      //for( int i = 0; i < lRepetitions; i++ ) {
-         // Copy the given jar file and add a prefix
-         //deleteFile( BASE_DIR, i, ARCHIVE_NAME);
-      ////}
-   }
-
-   private static void deleteFile (String BASE_DIR, int pIndex, String pArchiveName) {
-         java.io.File file = new java.io.File (BASE_DIR, pIndex + pArchiveName );
-         file.delete ();
    }
 
    private static void copyFile( String pBaseDir, String pArchiveName, int pIndex) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/net/URLConnection/6212146/TestDriver.java	Tue May 30 07:03:33 2017 -0700
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2017, 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 6212146
+ * @summary URLConnection.connect() fails on JAR Entry it creates
+ * file handler leak
+ * @library /test/lib
+ * @build jdk.test.lib.JDKToolFinder
+ *        jdk.test.lib.process.ProcessTools
+ *        Test
+ * @run main/othervm TestDriver
+ */
+
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import static java.nio.file.StandardCopyOption.REPLACE_EXISTING;
+
+public class TestDriver {
+    private static final String BASE_DIR = System.getProperty("user.dir")
+            +  "/jars/";
+    private static final String ARCHIVE_NAME = "test.jar";
+    private static final String CMD_ULIMIT = "ulimit -n 300;";
+
+    public static void main(String[] args)
+            throws Throwable {
+        setup(BASE_DIR);
+        String testCMD = CMD_ULIMIT + JDKToolFinder.getTestJDKTool("java")
+                + " Test " + BASE_DIR + " " + ARCHIVE_NAME;
+        boolean isWindows = System.getProperty("os.name").startsWith("Windows");
+        if (isWindows) {
+            testCMD = testCMD.replace("\\", "/");
+        }
+        ProcessTools.executeCommand("sh", "-c", testCMD)
+                    .outputTo(System.out)
+                    .errorTo(System.err)
+                    .shouldHaveExitValue(0);
+    }
+
+    private static void setup(String baseDir) throws IOException {
+        Path testJar = Paths.get(System.getProperty("test.src"), ARCHIVE_NAME);
+        Path targetDir = Paths.get(baseDir);
+        Files.createDirectories(targetDir);
+        Files.copy(testJar, targetDir.resolve(ARCHIVE_NAME), REPLACE_EXISTING);
+    }
+}
--- a/jdk/test/java/net/URLConnection/6212146/test.sh	Fri May 26 16:35:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2006, 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
-#  @run shell/timeout=380 test.sh
-#  @bug 6212146
-#  @summary URLConnection.connect() fails on JAR Entry it creates file handler leak
-#
-# set platform-dependent variables
-
-OS=`uname -s`
-case "$OS" in
-  SunOS | Darwin | AIX )
-    PS=":"
-    FS="/"
-    ;;
-  Linux )
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-if [ -d jars ]; then
-    rm -rf jars
-fi
-
-mkdir jars
-
-cp ${TESTSRC}${FS}test.jar  jars
-
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}${FS}Test.java
-
-WD=`pwd`
-ulimit -H -n 300
-${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} Test ${WD}/jars/ test.jar
-result=$?
-rm -rf jars
-exit $?
--- a/jdk/test/java/net/URLConnection/UNCTest.java	Fri May 26 16:35:45 2017 +0200
+++ b/jdk/test/java/net/URLConnection/UNCTest.java	Tue May 30 07:03:33 2017 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2001, 2017, 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,7 +21,16 @@
  * questions.
  */
 
-import java.net.*;
+/**
+ * @test
+ * @bug 4401485
+ * @requires (os.family == "windows")
+ * @summary  Check that URL.openConnection() doesn't open connection to UNC
+ * @run main UNCTest file://jdk/LOCAL-JAVA/jdk1.4/win/README.txt
+ */
+
+import java.net.URL;
+import java.net.URLConnection;
 
 public class UNCTest {
     public static void main(String args[]) throws Exception {
--- a/jdk/test/java/net/URLConnection/UNCTest.sh	Fri May 26 16:35:45 2017 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,47 +0,0 @@
-#!/bin/sh
-
-#
-# 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 4401485
-# @run shell UNCTest.sh
-# @summary Check that URL.openConnection() doesn't open connection
-#          to UNC.
-
-UNC="file://jdk/LOCAL-JAVA/jdk1.4/win/README.txt"
-
-OS=`uname -s`
-case "$OS" in
-    Windows_95 | Windows_98 | Windows_NT )
-	${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}\\UNCTest.java
-	${TESTJAVA}/bin/java ${TESTVMOPTS} UNCTest ${UNC}
-	exit
-        ;;
-
-    * )
-        echo "This test is not intended for this OS - passing test"
-	exit 0
-        ;;
-esac