8180887: move FileUtils to top level testlibrary
Reviewed-by: psandoz
diff --git a/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java b/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java
index 1539720..c4eaa55 100644
--- a/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java
+++ b/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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,7 +25,7 @@
* @test
* @bug 7130985
* @summary Four helper classes missing in Sun JDK
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @build jdk.testlibrary.*
* @modules java.corba
* @run main CorbaExceptionsCompileTest
@@ -35,12 +35,12 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.rmi.RemoteException;
+
import org.omg.CORBA.ORBPackage.InvalidName;
import org.omg.CORBA.TypeCodePackage.BadKind;
import org.omg.CORBA.TypeCodePackage.Bounds;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import jdk.testlibrary.JDKToolLauncher;
public class CorbaExceptionsCompileTest implements CorbaExceptionsTest {
diff --git a/jdk/test/java/io/Serializable/failureAtomicity/FailureAtomicity.java b/jdk/test/java/io/Serializable/failureAtomicity/FailureAtomicity.java
index 789153d..f20f3f4 100644
--- a/jdk/test/java/io/Serializable/failureAtomicity/FailureAtomicity.java
+++ b/jdk/test/java/io/Serializable/failureAtomicity/FailureAtomicity.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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,8 +26,7 @@
* @bug 8071474
* @summary Better failure atomicity for default read object.
* @modules jdk.compiler
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library /test/lib
* @compile FailureAtomicity.java SerialRef.java
* @run main failureAtomicity.FailureAtomicity
*/
@@ -59,7 +58,7 @@
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
@SuppressWarnings("unchecked")
public class FailureAtomicity {
diff --git a/jdk/test/java/lang/Class/forName/modules/TestDriver.java b/jdk/test/java/lang/Class/forName/modules/TestDriver.java
index 7ab1f63..425a16f 100644
--- a/jdk/test/java/lang/Class/forName/modules/TestDriver.java
+++ b/jdk/test/java/lang/Class/forName/modules/TestDriver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -29,7 +29,7 @@
import java.util.Arrays;
import java.util.stream.Stream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import static jdk.testlibrary.ProcessTools.*;
import org.testng.annotations.BeforeClass;
@@ -40,9 +40,9 @@
* @test
* @bug 8087335
* @summary Tests for Class.forName(Module,String)
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @modules jdk.compiler
- * @build TestDriver CompilerUtils jdk.testlibrary.ProcessTools jdk.testlibrary.FileUtils TestMain TestLayer
+ * @build TestDriver CompilerUtils jdk.testlibrary.ProcessTools TestMain TestLayer
* @run testng TestDriver
*/
diff --git a/jdk/test/java/net/URLClassLoader/closetest/Common.java b/jdk/test/java/net/URLClassLoader/closetest/Common.java
index 0326a3d..0fa1624 100644
--- a/jdk/test/java/net/URLClassLoader/closetest/Common.java
+++ b/jdk/test/java/net/URLClassLoader/closetest/Common.java
@@ -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
@@ -24,7 +24,7 @@
import java.io.*;
import java.net.*;
import java.nio.file.Files;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import static java.nio.file.StandardCopyOption.*;
public class Common {
diff --git a/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java b/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java
index dac1265..68a2f82 100644
--- a/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java
+++ b/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java
@@ -24,9 +24,9 @@
/**
* @test
* @bug 6899919
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @modules jdk.compiler
- * @build jdk.testlibrary.FileUtils JarUtils CompilerUtils
+ * @build JarUtils CompilerUtils
* @run main/othervm GetResourceAsStream
*/
diff --git a/jdk/test/java/net/httpclient/RequestBodyTest.java b/jdk/test/java/net/httpclient/RequestBodyTest.java
index fd0bbcc..e60a06a 100644
--- a/jdk/test/java/net/httpclient/RequestBodyTest.java
+++ b/jdk/test/java/net/httpclient/RequestBodyTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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,7 +26,7 @@
* @modules jdk.incubator.httpclient
* java.logging
* jdk.httpserver
- * @library /lib/testlibrary/
+ * @library /lib/testlibrary/ /test/lib
* @compile ../../../com/sun/net/httpserver/LogFilter.java
* @compile ../../../com/sun/net/httpserver/FileServerHandler.java
* @build LightWeightHttpServer
@@ -52,7 +52,7 @@
import java.util.concurrent.Executors;
import java.util.function.Supplier;
import javax.net.ssl.SSLContext;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import static java.nio.charset.StandardCharsets.*;
import static java.nio.file.StandardOpenOption.*;
import static jdk.incubator.http.HttpRequest.BodyProcessor.*;
diff --git a/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java b/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java
index 6d28773..eff3d6a 100644
--- a/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java
+++ b/jdk/test/java/net/spi/URLStreamHandlerProvider/Basic.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -45,7 +45,7 @@
import javax.tools.StandardJavaFileManager;
import javax.tools.StandardLocation;
import javax.tools.ToolProvider;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import jdk.testlibrary.JDKToolFinder;
import static java.lang.String.format;
import static java.util.Arrays.asList;
@@ -55,8 +55,8 @@
* @bug 8064924
* @modules jdk.compiler
* @summary Basic test for URLStreamHandlerProvider
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
+ * @library /lib/testlibrary /test/lib
+ * @build jdk.testlibrary.JDKToolFinder
* @compile Basic.java Child.java
* @run main Basic
*/
diff --git a/jdk/test/java/nio/file/FileStore/Basic.java b/jdk/test/java/nio/file/FileStore/Basic.java
index c2b482d..16997de 100644
--- a/jdk/test/java/nio/file/FileStore/Basic.java
+++ b/jdk/test/java/nio/file/FileStore/Basic.java
@@ -25,9 +25,7 @@
* @bug 4313887 6873621 6979526 7006126 7020517
* @summary Unit test for java.nio.file.FileStore
* @key intermittent
- * @library ..
- * @library .. /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library .. /test/lib
* @run main Basic
*/
@@ -35,8 +33,8 @@
import java.nio.file.attribute.*;
import java.io.File;
import java.io.IOException;
-import java.util.*;
-import jdk.testlibrary.FileUtils;
+
+import jdk.test.lib.util.FileUtils;
public class Basic {
diff --git a/jdk/test/java/nio/file/FileSystem/Basic.java b/jdk/test/java/nio/file/FileSystem/Basic.java
index bc4c77b..d054689 100644
--- a/jdk/test/java/nio/file/FileSystem/Basic.java
+++ b/jdk/test/java/nio/file/FileSystem/Basic.java
@@ -24,8 +24,7 @@
/* @test
* @bug 4313887 6838333 8132497
* @summary Unit test for java.nio.file.FileSystem
- * @library .. /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library .. /test/lib
* @run main/othervm Basic
*/
@@ -41,7 +40,7 @@
import java.nio.file.Paths;
import java.nio.file.ProviderNotFoundException;
import java.util.HashMap;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
/**
* Simple sanity checks for java.nio.file.FileSystem
diff --git a/jdk/test/java/util/logging/FileHandlerMaxLocksTest.java b/jdk/test/java/util/logging/FileHandlerMaxLocksTest.java
index fef03b2..74924ba 100644
--- a/jdk/test/java/util/logging/FileHandlerMaxLocksTest.java
+++ b/jdk/test/java/util/logging/FileHandlerMaxLocksTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -28,8 +28,7 @@
* "java.util.logging.FileHandler.maxLocks" which will be present in
* "logging.properties" file with default value of 100. This property can be
* overriden by specifying this property in the custom config file.
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library /test/lib
* @author rpatil
* @run main/othervm FileHandlerMaxLocksTest
*/
@@ -40,7 +39,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.logging.FileHandler;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
public class FileHandlerMaxLocksTest {
diff --git a/jdk/test/java/util/zip/ZipFile/MultiThreadedReadTest.java b/jdk/test/java/util/zip/ZipFile/MultiThreadedReadTest.java
index a97e1f3..d5344c3 100644
--- a/jdk/test/java/util/zip/ZipFile/MultiThreadedReadTest.java
+++ b/jdk/test/java/util/zip/ZipFile/MultiThreadedReadTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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,8 +24,7 @@
/* @test
* @bug 8038491
* @summary Crash in ZipFile.read() when ZipFileInputStream is shared between threads
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library /test/lib
* @run main MultiThreadedReadTest
* @key randomness
*/
@@ -38,7 +37,7 @@
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipOutputStream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
public class MultiThreadedReadTest extends Thread {
diff --git a/jdk/test/java/util/zip/ZipFile/ReadLongZipFileName.java b/jdk/test/java/util/zip/ZipFile/ReadLongZipFileName.java
index 217ce52..4dc480c 100644
--- a/jdk/test/java/util/zip/ZipFile/ReadLongZipFileName.java
+++ b/jdk/test/java/util/zip/ZipFile/ReadLongZipFileName.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2006, 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,15 +24,14 @@
/**
* @test
* @bug 6374379
- * @library ../../../../lib/testlibrary
+ * @library /test/lib
* @summary Verify that we can read zip file names > 255 chars long
*/
import java.io.*;
import java.util.jar.*;
-import java.util.zip.*;
import java.util.Stack;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
public class ReadLongZipFileName {
private static String entryName = "testFile.txt";;
diff --git a/jdk/test/java/util/zip/ZipFile/ZipEntryFreeTest.java b/jdk/test/java/util/zip/ZipFile/ZipEntryFreeTest.java
index 7695a33..bee70c0 100644
--- a/jdk/test/java/util/zip/ZipFile/ZipEntryFreeTest.java
+++ b/jdk/test/java/util/zip/ZipFile/ZipEntryFreeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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,8 +24,7 @@
/* @test
* @bug 6907252
* @summary ZipFileInputStream Not Thread-Safe
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main ZipEntryFreeTest
*/
@@ -35,7 +34,7 @@
import java.util.Timer;
import java.util.TimerTask;
import java.util.zip.*;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
public class ZipEntryFreeTest extends Thread {
diff --git a/jdk/test/jdk/internal/util/jar/TestVersionedStream.java b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java
index 1f043b2..9a370d2 100644
--- a/jdk/test/jdk/internal/util/jar/TestVersionedStream.java
+++ b/jdk/test/jdk/internal/util/jar/TestVersionedStream.java
@@ -25,9 +25,8 @@
* @test
* @bug 8163798
* @summary basic tests for multi-release jar versioned streams
- * @library /lib/testlibrary
+ * @library /test/lib
* @modules jdk.jartool/sun.tools.jar java.base/jdk.internal.util.jar
- * @build jdk.testlibrary.FileUtils
* @run testng TestVersionedStream
*/
@@ -57,7 +56,7 @@
import java.util.stream.Stream;
import java.util.zip.ZipFile;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
public class TestVersionedStream {
private final Path userdir;
diff --git a/jdk/test/jdk/modules/incubator/ImageModules.java b/jdk/test/jdk/modules/incubator/ImageModules.java
index 6b9c9ea..7588767 100644
--- a/jdk/test/jdk/modules/incubator/ImageModules.java
+++ b/jdk/test/jdk/modules/incubator/ImageModules.java
@@ -25,7 +25,7 @@
* @test
* @bug 8170859
* @summary Basic test for incubator modules in jmods and images
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @key intermittent
* @modules jdk.compiler jdk.jartool jdk.jlink
* @build CompilerUtils
@@ -39,14 +39,13 @@
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.spi.ToolProvider;
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/FileUtils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/FileUtils.java
deleted file mode 100644
index 9c41b8e..0000000
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/FileUtils.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * 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.
- */
-
-package jdk.testlibrary;
-
-import java.io.IOException;
-import java.nio.file.DirectoryNotEmptyException;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.NoSuchFileException;
-import java.nio.file.Path;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-
-/**
- * Common library for various test file utility functions.
- */
-public final class FileUtils {
-
- private static final boolean isWindows =
- System.getProperty("os.name").startsWith("Windows");
- private static final int RETRY_DELETE_MILLIS = isWindows ? 500 : 0;
- private static final int MAX_RETRY_DELETE_TIMES = isWindows ? 15 : 0;
-
- /**
- * Deletes a file, retrying if necessary.
- *
- * @param path the file to delete
- *
- * @throws NoSuchFileException
- * if the file does not exist (optional specific exception)
- * @throws DirectoryNotEmptyException
- * if the file is a directory and could not otherwise be deleted
- * because the directory is not empty (optional specific exception)
- * @throws IOException
- * if an I/O error occurs
- */
- public static void deleteFileWithRetry(Path path)
- throws IOException
- {
- try {
- deleteFileWithRetry0(path);
- } catch (InterruptedException x) {
- throw new IOException("Interrupted while deleting.", x);
- }
- }
-
- /**
- * Deletes a file, retrying if necessary.
- * No exception thrown if file doesn't exist.
- *
- * @param path the file to delete
- *
- * @throws NoSuchFileException
- * if the file does not exist (optional specific exception)
- * @throws DirectoryNotEmptyException
- * if the file is a directory and could not otherwise be deleted
- * because the directory is not empty (optional specific exception)
- * @throws IOException
- * if an I/O error occurs
- */
- public static void deleteFileIfExistsWithRetry(Path path)
- throws IOException
- {
- try {
- if(Files.exists(path))
- deleteFileWithRetry0(path);
- } catch (InterruptedException x) {
- throw new IOException("Interrupted while deleting.", x);
- }
- }
-
- private static void deleteFileWithRetry0(Path path)
- throws IOException, InterruptedException
- {
- int times = 0;
- IOException ioe = null;
- while (true) {
- try {
- Files.delete(path);
- while (Files.exists(path)) {
- times++;
- if (times > MAX_RETRY_DELETE_TIMES)
- throw new IOException("File still exists after " + times + " waits.");
- Thread.sleep(RETRY_DELETE_MILLIS);
- }
- break;
- } catch (NoSuchFileException | DirectoryNotEmptyException x) {
- throw x;
- } catch (IOException x) {
- // Backoff/retry in case another process is accessing the file
- times++;
- if (ioe == null)
- ioe = x;
- else
- ioe.addSuppressed(x);
-
- if (times > MAX_RETRY_DELETE_TIMES)
- throw ioe;
- Thread.sleep(RETRY_DELETE_MILLIS);
- }
- }
- }
-
- /**
- * Deletes a directory and its subdirectories, retrying if necessary.
- *
- * @param dir the directory to delete
- *
- * @throws IOException
- * If an I/O error occurs. Any such exceptions are caught
- * internally. If only one is caught, then it is re-thrown.
- * If more than one exception is caught, then the second and
- * following exceptions are added as suppressed exceptions of the
- * first one caught, which is then re-thrown.
- */
- public static void deleteFileTreeWithRetry(Path dir)
- throws IOException
- {
- IOException ioe = null;
- final List<IOException> excs = deleteFileTreeUnchecked(dir);
- if (!excs.isEmpty()) {
- ioe = excs.remove(0);
- for (IOException x : excs)
- ioe.addSuppressed(x);
- }
- if (ioe != null)
- throw ioe;
- }
-
- public static List<IOException> deleteFileTreeUnchecked(Path dir) {
- final List<IOException> excs = new ArrayList<>();
- try {
- java.nio.file.Files.walkFileTree(dir, new SimpleFileVisitor<Path>() {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) {
- try {
- deleteFileWithRetry0(file);
- } catch (IOException x) {
- excs.add(x);
- } catch (InterruptedException x) {
- excs.add(new IOException("Interrupted while deleting.", x));
- return FileVisitResult.TERMINATE;
- }
- return FileVisitResult.CONTINUE;
- }
- @Override
- public FileVisitResult postVisitDirectory(Path dir, IOException exc) {
- try {
- deleteFileWithRetry0(dir);
- } catch (IOException x) {
- excs.add(x);
- } catch (InterruptedException x) {
- excs.add(new IOException("Interrupted while deleting.", x));
- return FileVisitResult.TERMINATE;
- }
- return FileVisitResult.CONTINUE;
- }
- @Override
- public FileVisitResult visitFileFailed(Path file, IOException exc) {
- excs.add(exc);
- return FileVisitResult.CONTINUE;
- }
- });
- } catch (IOException x) {
- excs.add(x);
- }
- return excs;
- }
-
- /**
- * Checks whether all file systems are accessible. This is performed
- * by checking free disk space on all mounted file systems via a
- * separate, spawned process. File systems are considered to be
- * accessible if this process completes successfully before a given
- * fixed duration has elapsed.
- *
- * @implNote On Unix this executes the {@code df} command in a separate
- * process and on Windows always returns {@code true}.
- */
- public static boolean areFileSystemsAccessible() throws IOException {
- boolean areFileSystemsAccessible = true;
- if (!isWindows) {
- // try to check whether 'df' hangs
- System.out.println("\n--- df output ---");
- System.out.flush();
- Process proc = new ProcessBuilder("df").inheritIO().start();
- try {
- proc.waitFor(90, TimeUnit.SECONDS);
- } catch (InterruptedException ignored) {
- }
- try {
- int exitValue = proc.exitValue();
- if (exitValue != 0) {
- System.err.printf("df process exited with %d != 0%n",
- exitValue);
- areFileSystemsAccessible = false;
- }
- } catch (IllegalThreadStateException ignored) {
- System.err.println("df command apparently hung");
- areFileSystemsAccessible = false;
- }
- }
- return areFileSystemsAccessible;
- }
-}
diff --git a/jdk/test/tools/jar/InputFilesTest.java b/jdk/test/tools/jar/InputFilesTest.java
index 280cad5..e853daf 100644
--- a/jdk/test/tools/jar/InputFilesTest.java
+++ b/jdk/test/tools/jar/InputFilesTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -28,9 +28,8 @@
* options with/without a --release option. Some input files are
* duplicates that sometimes cause exceptions and other times do not,
* demonstrating identical behavior to JDK 8 jar tool.
- * @library /lib/testlibrary
+ * @library /test/lib
* @modules jdk.jartool
- * @build jdk.testlibrary.FileUtils
* @run testng InputFilesTest
*/
@@ -51,7 +50,7 @@
import java.util.stream.Stream;
import java.util.zip.ZipException;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
public class InputFilesTest {
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
diff --git a/jdk/test/tools/jar/ReleaseBeforeFiles.java b/jdk/test/tools/jar/ReleaseBeforeFiles.java
index 56c27107..8272eb4 100644
--- a/jdk/test/tools/jar/ReleaseBeforeFiles.java
+++ b/jdk/test/tools/jar/ReleaseBeforeFiles.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -27,9 +27,8 @@
* @summary test that both old style command line options and new gnu style
* command line options work with the --release option whether or
* not the --release option is preceded by a file name.
- * @library /lib/testlibrary
+ * @library /test/lib
* @modules jdk.jartool/sun.tools.jar
- * @build jdk.testlibrary.FileUtils
* @run testng ReleaseBeforeFiles
*/
@@ -46,7 +45,7 @@
import java.util.Arrays;
import java.util.stream.Stream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
public class ReleaseBeforeFiles {
private Runnable onCompletion;
diff --git a/jdk/test/tools/jar/compat/CLICompatibility.java b/jdk/test/tools/jar/compat/CLICompatibility.java
index c31762e..21cf815 100644
--- a/jdk/test/tools/jar/compat/CLICompatibility.java
+++ b/jdk/test/tools/jar/compat/CLICompatibility.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -35,7 +35,7 @@
import java.util.jar.JarOutputStream;
import java.util.stream.Stream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import jdk.testlibrary.JDKToolFinder;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
@@ -49,8 +49,8 @@
/*
* @test
* @bug 8170952
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
+ * @library /lib/testlibrary /test/lib
+ * @build jdk.testlibrary.JDKToolFinder
* @run testng CLICompatibility
* @summary Basic test for compatibility of CLI options
*/
diff --git a/jdk/test/tools/jar/mmrjar/Basic.java b/jdk/test/tools/jar/mmrjar/Basic.java
index a5b1eca..7a9cdaa 100644
--- a/jdk/test/tools/jar/mmrjar/Basic.java
+++ b/jdk/test/tools/jar/mmrjar/Basic.java
@@ -29,8 +29,7 @@
* @modules java.base/jdk.internal.module
* jdk.compiler
* jdk.jartool
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library /test/lib
* @run testng Basic
*/
@@ -57,7 +56,7 @@
import java.util.zip.ZipFile;
import jdk.internal.module.ModuleInfoExtender;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
public class Basic {
private static final ToolProvider JAR_TOOL = ToolProvider.findFirst("jar")
diff --git a/jdk/test/tools/jar/modularJar/Basic.java b/jdk/test/tools/jar/modularJar/Basic.java
index a656a86..9b81495 100644
--- a/jdk/test/tools/jar/modularJar/Basic.java
+++ b/jdk/test/tools/jar/modularJar/Basic.java
@@ -25,7 +25,6 @@
import java.lang.module.ModuleDescriptor;
import java.lang.reflect.Method;
import java.nio.file.*;
-import java.nio.file.attribute.BasicFileAttributes;
import java.util.*;
import java.util.function.Consumer;
import java.util.jar.JarEntry;
@@ -36,7 +35,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import jdk.testlibrary.JDKToolFinder;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
@@ -48,10 +47,10 @@
/*
* @test
* @bug 8167328 8171830 8165640 8174248 8176772
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @modules jdk.compiler
* jdk.jartool
- * @build jdk.testlibrary.FileUtils jdk.testlibrary.JDKToolFinder
+ * @build jdk.testlibrary.JDKToolFinder
* @compile Basic.java
* @run testng Basic
* @summary Tests for plain Modular jars & Multi-Release Modular jars
diff --git a/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java b/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java
index 03b2e5d..f084220 100644
--- a/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java
+++ b/jdk/test/tools/jar/multiRelease/ApiValidatorTest.java
@@ -24,18 +24,16 @@
/*
* @test
* @summary Tests for API validator.
- * @library /test/lib /lib/testlibrary
+ * @library /test/lib
* @modules java.base/jdk.internal.misc
* jdk.compiler
* jdk.jartool
- * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.*
- * @build jdk.testlibrary.FileUtils
* @build MRTestBase
* @run testng/timeout=1200 ApiValidatorTest
*/
import jdk.test.lib.process.OutputAnalyzer;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
@@ -421,4 +419,5 @@
javac(classes, sourceFiles);
}
-}
\ No newline at end of file
+}
+
diff --git a/jdk/test/tools/jar/multiRelease/Basic.java b/jdk/test/tools/jar/multiRelease/Basic.java
index 80f3795..37f50d2 100644
--- a/jdk/test/tools/jar/multiRelease/Basic.java
+++ b/jdk/test/tools/jar/multiRelease/Basic.java
@@ -23,19 +23,17 @@
/*
* @test
- * @library /test/lib /lib/testlibrary
+ * @library /test/lib
* @modules java.base/jdk.internal.misc
* jdk.compiler
* jdk.jartool
- * @build jdk.test.lib.JDKToolFinder jdk.test.lib.Utils jdk.test.lib.process.*
- * @build jdk.testlibrary.FileUtils
* @build MRTestBase
* @run testng Basic
*/
import static org.testng.Assert.*;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import org.testng.annotations.*;
import java.io.File;
diff --git a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java
index 36f82a9..c148e5a 100644
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/CompiledVersionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 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
@@ -29,7 +29,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import static jdk.testlibrary.ProcessTools.*;
@@ -39,9 +39,9 @@
/**
* @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @modules jdk.compiler jdk.jlink
- * @build CompiledVersionTest CompilerUtils jdk.testlibrary.FileUtils jdk.testlibrary.ProcessTools
+ * @build CompiledVersionTest CompilerUtils jdk.testlibrary.ProcessTools
* @run testng CompiledVersionTest
*/
diff --git a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java
index c8a2218..9c839d7 100644
--- a/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java
+++ b/jdk/test/tools/jlink/plugins/SystemModuleDescriptors/UserModuleTest.java
@@ -23,7 +23,6 @@
import java.io.File;
import java.io.IOException;
-import java.lang.module.ModuleDescriptor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -33,7 +32,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import static jdk.testlibrary.ProcessTools.*;
@@ -44,11 +43,11 @@
/**
* @test
* @bug 8142968 8173381 8174740
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @modules jdk.compiler jdk.jlink
* @modules java.base/jdk.internal.module
* @modules java.base/jdk.internal.org.objectweb.asm
- * @build ModuleTargetHelper UserModuleTest CompilerUtils jdk.testlibrary.FileUtils jdk.testlibrary.ProcessTools
+ * @build ModuleTargetHelper UserModuleTest CompilerUtils jdk.testlibrary.ProcessTools
* @run testng UserModuleTest
*/
diff --git a/jdk/test/tools/jmod/JmodNegativeTest.java b/jdk/test/tools/jmod/JmodNegativeTest.java
index 00d89a6..bcb4055 100644
--- a/jdk/test/tools/jmod/JmodNegativeTest.java
+++ b/jdk/test/tools/jmod/JmodNegativeTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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
@@ -23,10 +23,10 @@
/*
* @test
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @modules jdk.compiler
* jdk.jlink
- * @build jdk.testlibrary.FileUtils CompilerUtils
+ * @build CompilerUtils
* @run testng JmodNegativeTest
* @summary Negative tests for jmod
*/
@@ -41,7 +41,7 @@
import java.util.function.Supplier;
import java.util.spi.ToolProvider;
import java.util.zip.ZipOutputStream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
diff --git a/jdk/test/tools/jmod/JmodTest.java b/jdk/test/tools/jmod/JmodTest.java
index e578b2f..30df12f 100644
--- a/jdk/test/tools/jmod/JmodTest.java
+++ b/jdk/test/tools/jmod/JmodTest.java
@@ -1,5 +1,5 @@
/**
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 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,10 +25,10 @@
* @test
* @bug 8142968 8166568 8166286 8170618 8168149
* @summary Basic test for jmod
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @modules jdk.compiler
* jdk.jlink
- * @build jdk.testlibrary.FileUtils CompilerUtils
+ * @build CompilerUtils
* @run testng/othervm -Djava.io.tmpdir=. JmodTest
*/
@@ -40,9 +40,8 @@
import java.util.function.Consumer;
import java.util.regex.Pattern;
import java.util.spi.ToolProvider;
-import java.util.stream.Collectors;
import java.util.stream.Stream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
diff --git a/jdk/test/tools/launcher/LauncherMessageTest.java b/jdk/test/tools/launcher/LauncherMessageTest.java
index d83ad82..6643f12 100644
--- a/jdk/test/tools/launcher/LauncherMessageTest.java
+++ b/jdk/test/tools/launcher/LauncherMessageTest.java
@@ -24,16 +24,16 @@
/**
* @test
* @bug 8167063
- * @library /lib/testlibrary
- * @build jdk.testlibrary.FileUtils
+ * @library /test/lib
* @run main LauncherMessageTest
* @summary LauncherHelper should not throw JNI error for LinkageError
*/
+
import java.io.File;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
public class LauncherMessageTest {
diff --git a/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java
index c1c8deb..fe50d25 100644
--- a/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java
+++ b/jdk/test/tools/launcher/modules/patch/systemmodules/PatchSystemModules.java
@@ -25,7 +25,7 @@
* @test
* @bug 8157068 8177844
* @summary Patch java.base and user module with ModuleHashes attribute
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @modules jdk.compiler
* @build CompilerUtils
* @run testng PatchSystemModules
@@ -39,7 +39,7 @@
import java.util.List;
import java.util.stream.Stream;
-import jdk.testlibrary.FileUtils;
+import jdk.test.lib.util.FileUtils;
import jdk.testlibrary.JDKToolFinder;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;