This README file contains build instructions for the OpenJDK. Building the source code for the OpenJDK requires a certain degree of technical expertise.
@@ -149,50 +151,50 @@
-
Package
-
Version
+
Package
+
Version
-
developer/solarisstudio-124/backend
-
12.4-1.0.6.0
+
developer/solarisstudio-124/backend
+
12.4-1.0.6.0
-
developer/solarisstudio-124/c++
-
12.4-1.0.10.0
+
developer/solarisstudio-124/c++
+
12.4-1.0.10.0
-
developer/solarisstudio-124/cc
-
12.4-1.0.4.0
+
developer/solarisstudio-124/cc
+
12.4-1.0.4.0
-
developer/solarisstudio-124/library/c++-libs
-
12.4-1.0.10.0
+
developer/solarisstudio-124/library/c++-libs
+
12.4-1.0.10.0
-
developer/solarisstudio-124/library/math-libs
-
12.4-1.0.0.1
+
developer/solarisstudio-124/library/math-libs
+
12.4-1.0.0.1
-
developer/solarisstudio-124/library/studio-gccrt
-
12.4-1.0.0.1
+
developer/solarisstudio-124/library/studio-gccrt
+
12.4-1.0.0.1
-
developer/solarisstudio-124/studio-common
-
12.4-1.0.0.1
+
developer/solarisstudio-124/studio-common
+
12.4-1.0.0.1
-
developer/solarisstudio-124/studio-ja
-
12.4-1.0.0.1
+
developer/solarisstudio-124/studio-ja
+
12.4-1.0.0.1
-
developer/solarisstudio-124/studio-legal
-
12.4-1.0.0.1
+
developer/solarisstudio-124/studio-legal
+
12.4-1.0.0.1
-
developer/solarisstudio-124/studio-zhCN
-
12.4-1.0.0.1
+
developer/solarisstudio-124/studio-zhCN
+
12.4-1.0.0.1
@@ -211,66 +213,66 @@
-
Binary Name
-
Category
-
Package
-
Description
+
Binary Name
+
Category
+
Package
+
Description
-
ar.exe
-
Devel
-
binutils
-
The GNU assembler, linker and binary utilities
+
ar.exe
+
Devel
+
binutils
+
The GNU assembler, linker and binary utilities
-
make.exe
-
Devel
-
make
-
The GNU version of the 'make' utility built for CYGWIN
+
make.exe
+
Devel
+
make
+
The GNU version of the 'make' utility built for CYGWIN
-
m4.exe
-
Interpreters
-
m4
-
GNU implementation of the traditional Unix macro processor
+
m4.exe
+
Interpreters
+
m4
+
GNU implementation of the traditional Unix macro processor
-
cpio.exe
-
Utils
-
cpio
-
A program to manage archives of files
+
cpio.exe
+
Utils
+
cpio
+
A program to manage archives of files
-
gawk.exe
-
Utils
-
awk
-
Pattern-directed scanning and processing language
+
gawk.exe
+
Utils
+
awk
+
Pattern-directed scanning and processing language
-
file.exe
-
Utils
-
file
-
Determines file type using 'magic' numbers
+
file.exe
+
Utils
+
file
+
Determines file type using 'magic' numbers
-
zip.exe
-
Archive
-
zip
-
Package and compress (archive) files
+
zip.exe
+
Archive
+
zip
+
Package and compress (archive) files
-
unzip.exe
-
Archive
-
unzip
-
Extract compressed files in a ZIP archive
+
unzip.exe
+
Archive
+
unzip
+
Extract compressed files in a ZIP archive
-
free.exe
-
System
-
procps
-
Display amount of free and used memory in the system
+
free.exe
+
System
+
procps
+
Display amount of free and used memory in the system
@@ -561,14 +563,14 @@ This is caused by a missing libstdc++.a library. This is installed as part of a
This is probably an issue with SELinux (See SELinux on Wikipedia). Parts of the VM is built without the -fPIC for performance reasons.
To completely disable SELinux:
-
+
$ su root
# system-config-securitylevel
In the window that appears, select the SELinux tab
Disable SELinux
Alternatively, instead of completely disabling it you could disable just this one check.
-
+
Select System->Administration->SELinux Management
In the SELinux Management Tool which appears, select "Boolean" from the menu on the left
Expand the "Memory Protection" group
@@ -616,62 +618,62 @@ Try rebooting the system, or there could be some kind of issue with the disk or
-
Base OS and Architecture
-
OS
-
C/C++ Compiler
-
Processors
-
RAM Minimum
-
DISK Needs
+
Base OS and Architecture
+
OS
+
C/C++ Compiler
+
Processors
+
RAM Minimum
+
DISK Needs
-
Linux X86 (32-bit) and X64 (64-bit)
-
Oracle Enterprise Linux 6.4
-
gcc 4.9.2
-
2 or more
-
1 GB
-
6 GB
+
Linux X86 (32-bit) and X64 (64-bit)
+
Oracle Enterprise Linux 6.4
+
gcc 4.9.2
+
2 or more
+
1 GB
+
6 GB
-
Solaris SPARCV9 (64-bit)
-
Solaris 11 Update 1
-
Studio 12 Update 4 + patches
-
4 or more
-
4 GB
-
8 GB
+
Solaris SPARCV9 (64-bit)
+
Solaris 11 Update 1
+
Studio 12 Update 4 + patches
+
4 or more
+
4 GB
+
8 GB
-
Solaris X64 (64-bit)
-
Solaris 11 Update 1
-
Studio 12 Update 4 + patches
-
4 or more
-
4 GB
-
8 GB
+
Solaris X64 (64-bit)
+
Solaris 11 Update 1
+
Studio 12 Update 4 + patches
+
4 or more
+
4 GB
+
8 GB
-
Windows X86 (32-bit)
-
Windows Server 2012 R2 x64
-
Microsoft Visual Studio C++ 2013 Professional Edition
-
2 or more
-
2 GB
-
6 GB
+
Windows X86 (32-bit)
+
Windows Server 2012 R2 x64
+
Microsoft Visual Studio C++ 2013 Professional Edition
+
2 or more
+
2 GB
+
6 GB
-
Windows X64 (64-bit)
-
Windows Server 2012 R2 x64
-
Microsoft Visual Studio C++ 2013 Professional Edition
-
2 or more
-
2 GB
-
6 GB
+
Windows X64 (64-bit)
+
Windows Server 2012 R2 x64
+
Microsoft Visual Studio C++ 2013 Professional Edition
This new way of running tests is developer-centric. It assumes that you have built a jdk locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.
This new way of running tests is developer-centric. It assumes that you have built a jdk locally and want to test it. Running common test targets is simple, and more complex ad-hoc combination of tests is possible. The user interface is forgiving, and clearly report errors it cannot resolve.
+
The main target "run-test" uses the jdk-image as the tested product. There is also an alternate target "exploded-run-test" that uses the exploded image instead. Not all tests will run successfully on the exploded image, but using this target can greatly improve rebuild times for certain workflows.
Some example command-lines:
$ make run-test-tier1
$ make run-test-jdk_lang JTREG="JOBS=8"
$ make run-test TEST=jdk_lang
$ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1"
$ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"
-$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
+$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
+$ make exploded-run-test TEST=hotspot_tier1
Test selection
All functionality is available using the run-test make target. In this use case, the test or tests to be executed is controlled using the TEST variable. To speed up subsequent test runs with no source code changes, run-test-only can be used instead, which do not depend on the source and test image build.
For some common top-level tests, direct make targets have been generated. This includes all JTreg test groups, the hotspot gtest, and custom tests (if present). This means that make run-test-tier1 is equivalent to make run-test TEST="tier1", but the latter is more tab-completion friendly. For more complex test runs, the run-test TEST="x" solution needs to be used.
diff --git a/common/doc/testing.md b/common/doc/testing.md
index f84bd27dda2..231755c92b1 100644
--- a/common/doc/testing.md
+++ b/common/doc/testing.md
@@ -7,6 +7,11 @@ built a jdk locally and want to test it. Running common test targets is simple,
and more complex ad-hoc combination of tests is possible. The user interface is
forgiving, and clearly report errors it cannot resolve.
+The main target "run-test" uses the jdk-image as the tested product. There is
+also an alternate target "exploded-run-test" that uses the exploded image
+instead. Not all tests will run successfully on the exploded image, but using
+this target can greatly improve rebuild times for certain workflows.
+
Some example command-lines:
$ make run-test-tier1
@@ -15,6 +20,7 @@ Some example command-lines:
$ make run-test-only TEST="gtest:LogTagSet gtest:LogTagSetDescriptions" GTEST="REPEAT=-1"
$ make run-test TEST="hotspot/test:hotspot_gc" JTREG="JOBS=1;TIMEOUT=8;VM_OTIONS=-XshowSettings -Xlog:gc+ref=debug"
$ make run-test TEST="jtreg:hotspot/test:hotspot_gc hotspot/test/native_sanity/JniVersion.java"
+ $ make exploded-run-test TEST=hotspot_tier1
## Test selection
diff --git a/make/Help.gmk b/make/Help.gmk
index c9a06d291af..4514eb08b8d 100644
--- a/make/Help.gmk
+++ b/make/Help.gmk
@@ -56,6 +56,8 @@ help:
$(info $(_) make test # Run tests, default is all tests (see TEST below))
$(info $(_) make run-test- # Run test, e.g. run-test-tier1)
$(info $(_) make run-test TEST= # Run test(s) given by TEST specification)
+ $(info $(_) make exploded-run-test TEST= # Run test(s) on the exploded image instead of)
+ $(info $(_) # the full jdk image)
$(info )
$(info Targets for cleaning)
$(info $(_) make clean # Remove all files generated by make, but not those)
diff --git a/make/Main.gmk b/make/Main.gmk
index ab6eb7d2e2b..7d85c1b062a 100644
--- a/make/Main.gmk
+++ b/make/Main.gmk
@@ -450,13 +450,18 @@ define DeclareRunTestRecipe
run-test-$1:
+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$1")
+ exploded-run-test-$1:
+ +($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test \
+ TEST="$1" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR))
+
endef
# ALL_NAMED_TESTS is defined in FindTests.gmk
$(foreach t, $(ALL_NAMED_TESTS), $(eval $(call DeclareRunTestRecipe,$t)))
ALL_TEST_TARGETS := $(addprefix run-test-, $(ALL_NAMED_TESTS))
+ALL_EXPLODED_TEST_TARGETS := $(addprefix exploded-run-test-, $(ALL_NAMED_TESTS))
-ALL_TARGETS += $(ALL_TEST_TARGETS)
+ALL_TARGETS += $(ALL_TEST_TARGETS) $(ALL_EXPLODED_TEST_TARGETS)
################################################################################
# Build tests
@@ -485,6 +490,10 @@ test-image-jdk-jtreg-native:
run-test:
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test TEST="$(TEST)")
+exploded-run-test:
+ +($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f RunTests.gmk run-test \
+ TEST="$(TEST)" JDK_IMAGE_DIR=$(JDK_OUTPUTDIR))
+
ifeq ($(BUILD_GTEST), true)
test-image-hotspot-gtest:
+($(CD) $(HOTSPOT_TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f GtestImage.gmk)
@@ -514,7 +523,7 @@ ALL_TARGETS += prepare-test-image build-test-hotspot-jtreg-native \
test-image-hotspot-jtreg-native build-test-jdk-jtreg-native \
test-image-jdk-jtreg-native build-test-lib build-test-failure-handler \
test-failure-handler test-image-failure-handler test-image-hotspot-gtest \
- run-test
+ run-test exploded-run-test
################################################################################
# Run tests
@@ -807,9 +816,11 @@ else
test: jdk-image test-image
run-test: jdk-image test-image
+ exploded-run-test: exploded-image test-image
# Declare dependency for all generated test targets
$(foreach t, $(ALL_TEST_TARGETS), $(eval $t: jdk-image test-image))
+ $(foreach t, $(ALL_EXPLODED_TEST_TARGETS), $(eval $t: exploded-image test-image))
create-buildjdk-copy: jdk.jlink-java java.base-gendata \
$(addsuffix -java, $(INTERIM_IMAGE_MODULES))
From 4f2e94d65ada7d54f46bcaf43d392f6b503f6376 Mon Sep 17 00:00:00 2001
From: Felix Yang
Date: Tue, 30 May 2017 07:03:33 -0700
Subject: [PATCH 43/55] 8166139: Refactor java/net shell cases to java
Reviewed-by: chegar, rriggs
---
jdk/test/java/net/Socket/OldSocketImpl.sh | 61 -------
.../OldSocketImplTestDriver.java} | 39 ++---
jdk/test/java/net/URL/B5086147.java | 9 +-
jdk/test/java/net/URL/B5086147.sh | 56 -------
jdk/test/java/net/URLClassLoader/B5077773.sh | 66 --------
.../URLClassLoader/closetest/CloseTest.java | 150 +++++++++++-------
.../closetest/GetResourceAsStream.java | 76 ++++++---
.../net/URLClassLoader/closetest/build.sh | 78 ---------
.../net/URLClassLoader/closetest/build2.sh | 58 -------
.../getresourceasstream/TestDriver.java | 108 +++++++++++++
.../URLClassLoader/getresourceasstream/policy | 26 +++
.../getresourceasstream/test.sh | 71 ---------
.../URLClassLoader/sealing/CheckSealed.java | 9 +-
.../sealing/CheckSealedTest.java | 89 +++++++++++
.../net/URLClassLoader/sealing/checksealed.sh | 64 --------
.../java/net/URLConnection/6212146/Test.java | 68 ++++----
.../net/URLConnection/6212146/TestDriver.java | 73 +++++++++
.../java/net/URLConnection/6212146/test.sh | 73 ---------
jdk/test/java/net/URLConnection/UNCTest.java | 13 +-
jdk/test/java/net/URLConnection/UNCTest.sh | 47 ------
20 files changed, 509 insertions(+), 725 deletions(-)
delete mode 100644 jdk/test/java/net/Socket/OldSocketImpl.sh
rename jdk/test/java/net/{URLClassLoader/B5077773.java => Socket/OldSocketImplTestDriver.java} (56%)
delete mode 100644 jdk/test/java/net/URL/B5086147.sh
delete mode 100644 jdk/test/java/net/URLClassLoader/B5077773.sh
delete mode 100644 jdk/test/java/net/URLClassLoader/closetest/build.sh
delete mode 100644 jdk/test/java/net/URLClassLoader/closetest/build2.sh
create mode 100644 jdk/test/java/net/URLClassLoader/getresourceasstream/TestDriver.java
create mode 100644 jdk/test/java/net/URLClassLoader/getresourceasstream/policy
delete mode 100644 jdk/test/java/net/URLClassLoader/getresourceasstream/test.sh
create mode 100644 jdk/test/java/net/URLClassLoader/sealing/CheckSealedTest.java
delete mode 100644 jdk/test/java/net/URLClassLoader/sealing/checksealed.sh
create mode 100644 jdk/test/java/net/URLConnection/6212146/TestDriver.java
delete mode 100644 jdk/test/java/net/URLConnection/6212146/test.sh
delete mode 100644 jdk/test/java/net/URLConnection/UNCTest.sh
diff --git a/jdk/test/java/net/Socket/OldSocketImpl.sh b/jdk/test/java/net/Socket/OldSocketImpl.sh
deleted file mode 100644
index 70b92afc7b6..00000000000
--- a/jdk/test/java/net/Socket/OldSocketImpl.sh
+++ /dev/null
@@ -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
-
diff --git a/jdk/test/java/net/URLClassLoader/B5077773.java b/jdk/test/java/net/Socket/OldSocketImplTestDriver.java
similarity index 56%
rename from jdk/test/java/net/URLClassLoader/B5077773.java
rename to jdk/test/java/net/Socket/OldSocketImplTestDriver.java
index 28a4a4ca374..840579f3ab9 100644
--- a/jdk/test/java/net/URLClassLoader/B5077773.java
+++ b/jdk/test/java/net/Socket/OldSocketImplTestDriver.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -21,25 +21,26 @@
* questions.
*/
-import java.io.*;
-import java.net.*;
+import jdk.test.lib.process.ProcessTools;
-public class B5077773 {
+import java.nio.file.Path;
+import java.nio.file.Paths;
- 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");
- }
+/**
+ * @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);
}
}
diff --git a/jdk/test/java/net/URL/B5086147.java b/jdk/test/java/net/URL/B5086147.java
index 284b4f60508..47260912a41 100644
--- a/jdk/test/java/net/URL/B5086147.java
+++ b/jdk/test/java/net/URL/B5086147.java
@@ -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{
diff --git a/jdk/test/java/net/URL/B5086147.sh b/jdk/test/java/net/URL/B5086147.sh
deleted file mode 100644
index 772d7a32cd1..00000000000
--- a/jdk/test/java/net/URL/B5086147.sh
+++ /dev/null
@@ -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
diff --git a/jdk/test/java/net/URLClassLoader/B5077773.sh b/jdk/test/java/net/URLClassLoader/B5077773.sh
deleted file mode 100644
index 3b52698840a..00000000000
--- a/jdk/test/java/net/URLClassLoader/B5077773.sh
+++ /dev/null
@@ -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
-
diff --git a/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java b/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java
index 47feb498c51..c25cb3e1241 100644
--- a/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java
+++ b/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java
@@ -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;
-public class CloseTest extends Common {
+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 @@ public class CloseTest extends Common {
//
// 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 @@ public class CloseTest extends Common {
// 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 @@ public class CloseTest extends Common {
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);
+ }
}
diff --git a/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java b/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java
index a11d58afe8f..dac12653f4b 100644
--- a/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.java
+++ b/jdk/test/java/net/URLClassLoader/closetest/GetResourceAsStream.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
@@ -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 @@ public class GetResourceAsStream extends Common {
* 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");
-
- copyDir (srcdir, testdir);
- test (testdir, true, false);
+ File testdir = new File(WORK_DIR, "testdir");
+ File srcdir = new File(WORK_DIR, "test3");
+ copyDir(srcdir, testdir);
+ test(testdir, true, false);
}
// create a loader on jarfile (or directory)
@@ -82,7 +86,7 @@ public class GetResourceAsStream extends Common {
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 @@ public class GetResourceAsStream extends Common {
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 @@ public class GetResourceAsStream extends Common {
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);
+ }
}
diff --git a/jdk/test/java/net/URLClassLoader/closetest/build.sh b/jdk/test/java/net/URLClassLoader/closetest/build.sh
deleted file mode 100644
index 4fe159be83a..00000000000
--- a/jdk/test/java/net/URLClassLoader/closetest/build.sh
+++ /dev/null
@@ -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
diff --git a/jdk/test/java/net/URLClassLoader/closetest/build2.sh b/jdk/test/java/net/URLClassLoader/closetest/build2.sh
deleted file mode 100644
index 5b6f830d84e..00000000000
--- a/jdk/test/java/net/URLClassLoader/closetest/build2.sh
+++ /dev/null
@@ -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 ..
diff --git a/jdk/test/java/net/URLClassLoader/getresourceasstream/TestDriver.java b/jdk/test/java/net/URLClassLoader/getresourceasstream/TestDriver.java
new file mode 100644
index 00000000000..5daaee95407
--- /dev/null
+++ b/jdk/test/java/net/URLClassLoader/getresourceasstream/TestDriver.java
@@ -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);
+ }
+}
diff --git a/jdk/test/java/net/URLClassLoader/getresourceasstream/policy b/jdk/test/java/net/URLClassLoader/getresourceasstream/policy
new file mode 100644
index 00000000000..3a2f6b420a6
--- /dev/null
+++ b/jdk/test/java/net/URLClassLoader/getresourceasstream/policy
@@ -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";
+};
diff --git a/jdk/test/java/net/URLClassLoader/getresourceasstream/test.sh b/jdk/test/java/net/URLClassLoader/getresourceasstream/test.sh
deleted file mode 100644
index 790017f0b0a..00000000000
--- a/jdk/test/java/net/URLClassLoader/getresourceasstream/test.sh
+++ /dev/null
@@ -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
diff --git a/jdk/test/java/net/URLClassLoader/sealing/CheckSealed.java b/jdk/test/java/net/URLClassLoader/sealing/CheckSealed.java
index 7805de0faeb..93f4cce3b6c 100644
--- a/jdk/test/java/net/URLClassLoader/sealing/CheckSealed.java
+++ b/jdk/test/java/net/URLClassLoader/sealing/CheckSealed.java
@@ -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 {
diff --git a/jdk/test/java/net/URLClassLoader/sealing/CheckSealedTest.java b/jdk/test/java/net/URLClassLoader/sealing/CheckSealedTest.java
new file mode 100644
index 00000000000..f0f70496281
--- /dev/null
+++ b/jdk/test/java/net/URLClassLoader/sealing/CheckSealedTest.java
@@ -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 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);
+ }
+}
diff --git a/jdk/test/java/net/URLClassLoader/sealing/checksealed.sh b/jdk/test/java/net/URLClassLoader/sealing/checksealed.sh
deleted file mode 100644
index 339525a1042..00000000000
--- a/jdk/test/java/net/URLClassLoader/sealing/checksealed.sh
+++ /dev/null
@@ -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
diff --git a/jdk/test/java/net/URLConnection/6212146/Test.java b/jdk/test/java/net/URLConnection/6212146/Test.java
index 7f3adbf307b..1e33349b9dd 100644
--- a/jdk/test/java/net/URLConnection/6212146/Test.java
+++ b/jdk/test/java/net/URLConnection/6212146/Test.java
@@ -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) {
diff --git a/jdk/test/java/net/URLConnection/6212146/TestDriver.java b/jdk/test/java/net/URLConnection/6212146/TestDriver.java
new file mode 100644
index 00000000000..31bee6fefec
--- /dev/null
+++ b/jdk/test/java/net/URLConnection/6212146/TestDriver.java
@@ -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);
+ }
+}
diff --git a/jdk/test/java/net/URLConnection/6212146/test.sh b/jdk/test/java/net/URLConnection/6212146/test.sh
deleted file mode 100644
index 9a0615cadf3..00000000000
--- a/jdk/test/java/net/URLConnection/6212146/test.sh
+++ /dev/null
@@ -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 $?
diff --git a/jdk/test/java/net/URLConnection/UNCTest.java b/jdk/test/java/net/URLConnection/UNCTest.java
index 2e834f840b7..653b4c96699 100644
--- a/jdk/test/java/net/URLConnection/UNCTest.java
+++ b/jdk/test/java/net/URLConnection/UNCTest.java
@@ -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 {
diff --git a/jdk/test/java/net/URLConnection/UNCTest.sh b/jdk/test/java/net/URLConnection/UNCTest.sh
deleted file mode 100644
index 8030deb30e3..00000000000
--- a/jdk/test/java/net/URLConnection/UNCTest.sh
+++ /dev/null
@@ -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
From 6d94dde81362e5bc451048afbd0bc5466c825009 Mon Sep 17 00:00:00 2001
From: Igor Ignatyev
Date: Tue, 30 May 2017 14:56:43 -0700
Subject: [PATCH 44/55] 8180887: move FileUtils to top level testlibrary
Reviewed-by: psandoz
---
test/lib/jdk/test/lib/util/FileUtils.java | 229 ++++++++++++++++++++++
1 file changed, 229 insertions(+)
create mode 100644 test/lib/jdk/test/lib/util/FileUtils.java
diff --git a/test/lib/jdk/test/lib/util/FileUtils.java b/test/lib/jdk/test/lib/util/FileUtils.java
new file mode 100644
index 00000000000..8bbaded9586
--- /dev/null
+++ b/test/lib/jdk/test/lib/util/FileUtils.java
@@ -0,0 +1,229 @@
+/*
+ * 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.test.lib.util;
+
+import jdk.test.lib.Platform;
+
+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 IS_WINDOWS = Platform.isWindows();
+ private static final int RETRY_DELETE_MILLIS = IS_WINDOWS ? 500 : 0;
+ private static final int MAX_RETRY_DELETE_TIMES = IS_WINDOWS ? 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 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 deleteFileTreeUnchecked(Path dir) {
+ final List excs = new ArrayList<>();
+ try {
+ java.nio.file.Files.walkFileTree(dir, new SimpleFileVisitor<>() {
+ @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 (!IS_WINDOWS) {
+ // 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;
+ }
+}
From c85d273e7d6aa0b6f1c79b3addb4563e7cd197ab Mon Sep 17 00:00:00 2001
From: Igor Ignatyev
Date: Tue, 30 May 2017 15:05:33 -0700
Subject: [PATCH 45/55] 8180887: move FileUtils to top level testlibrary
Reviewed-by: psandoz
---
.../7130985/CorbaExceptionsCompileTest.java | 8 +-
.../failureAtomicity/FailureAtomicity.java | 7 +-
.../Class/forName/modules/TestDriver.java | 8 +-
.../net/URLClassLoader/closetest/Common.java | 4 +-
.../closetest/GetResourceAsStream.java | 4 +-
.../java/net/httpclient/RequestBodyTest.java | 6 +-
.../spi/URLStreamHandlerProvider/Basic.java | 8 +-
jdk/test/java/nio/file/FileStore/Basic.java | 8 +-
jdk/test/java/nio/file/FileSystem/Basic.java | 5 +-
.../util/logging/FileHandlerMaxLocksTest.java | 7 +-
.../zip/ZipFile/MultiThreadedReadTest.java | 7 +-
.../util/zip/ZipFile/ReadLongZipFileName.java | 7 +-
.../util/zip/ZipFile/ZipEntryFreeTest.java | 7 +-
.../util/jar/TestVersionedStream.java | 5 +-
.../jdk/modules/incubator/ImageModules.java | 5 +-
.../jdk/testlibrary/FileUtils.java | 230 ------------------
jdk/test/tools/jar/InputFilesTest.java | 7 +-
jdk/test/tools/jar/ReleaseBeforeFiles.java | 7 +-
.../tools/jar/compat/CLICompatibility.java | 8 +-
jdk/test/tools/jar/mmrjar/Basic.java | 5 +-
jdk/test/tools/jar/modularJar/Basic.java | 7 +-
.../jar/multiRelease/ApiValidatorTest.java | 9 +-
jdk/test/tools/jar/multiRelease/Basic.java | 6 +-
.../CompiledVersionTest.java | 8 +-
.../UserModuleTest.java | 7 +-
jdk/test/tools/jmod/JmodNegativeTest.java | 8 +-
jdk/test/tools/jmod/JmodTest.java | 9 +-
.../tools/launcher/LauncherMessageTest.java | 6 +-
.../systemmodules/PatchSystemModules.java | 4 +-
29 files changed, 84 insertions(+), 333 deletions(-)
delete mode 100644 jdk/test/lib/testlibrary/jdk/testlibrary/FileUtils.java
diff --git a/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java b/jdk/test/com/sun/corba/7130985/CorbaExceptionsCompileTest.java
index 15397206330..c4eaa555e9a 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.io.*;
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 789153d394d..f20f3f44539 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.JavaFileObject;
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 7ab1f636c9e..425a16f18ff 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.nio.file.Paths;
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 @@ import static org.testng.Assert.assertTrue;
* @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 0326a3d8ce4..0fa16248e1c 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 dac12653f4b..68a2f82d67f 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 fd0bbcc7aaa..e60a06abc4f 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.ExecutorService;
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 6d287738eee..eff3d6a785e 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.JavaFileObject;
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 @@ import static java.util.Arrays.asList;
* @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 c2b482d8fbd..16997de8495 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.*;
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 bc4c77b021b..d0546896206 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.Path;
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 fef03b2ef89..74924badd9c 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.nio.file.Paths;
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 a97e1f35285..d5344c3bdf2 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.Random;
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 217ce52dcd3..4dc480c67ea 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 7695a339cc8..bee70c019b0 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.Random;
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 1f043b2bc33..9a370d27df0 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.Collectors;
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 6b9c9ea1665..75887671d64 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.io.PrintStream;
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 9c41b8e7580..00000000000
--- 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 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 deleteFileTreeUnchecked(Path dir) {
- final List excs = new ArrayList<>();
- try {
- java.nio.file.Files.walkFileTree(dir, new SimpleFileVisitor() {
- @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 280cad57a58..e853dafa03a 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.spi.ToolProvider;
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 56c27107a1b..8272eb44273 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.nio.file.Paths;
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 c31762eedc3..21cf815a573 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.JarInputStream;
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 @@ import static org.testng.Assert.assertTrue;
/*
* @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 a5b1eca0346..7a9cdaa46c7 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.stream.Stream;
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 a656a86b24b..9b81495a0f1 100644
--- a/jdk/test/tools/jar/modularJar/Basic.java
+++ b/jdk/test/tools/jar/modularJar/Basic.java
@@ -25,7 +25,6 @@ import java.io.*;
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.regex.Pattern;
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 @@ import static java.lang.System.out;
/*
* @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 03b2e5d550f..f08422061f1 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 @@ public class ApiValidatorTest extends MRTestBase {
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 80f37950591..37f50d2403b 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 36f82a9ddc4..c148e5ab2e2 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.Arrays;
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 @@ import static org.testng.Assert.*;
/**
* @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 c8a221840b1..9c839d7c8b1 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.spi.ToolProvider;
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 @@ import static org.testng.Assert.*;
/**
* @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 00d89a635e4..bcb40558320 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.Consumer;
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 e578b2f360e..30df12fc210 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.*;
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 d83ad82acba..6643f122ea1 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 c1c8deb0d9a..fe50d255b85 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.ArrayList;
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;
From b3100eb84a169aba0261688ff39453f4dbe0d120 Mon Sep 17 00:00:00 2001
From: Igor Ignatyev
Date: Tue, 30 May 2017 21:07:08 -0700
Subject: [PATCH 46/55] 8180888: move jdk.testlibrary.JarUtils to the top level
testlibrary
Reviewed-by: weijun
---
.../DoPrivAccompliceTest.java | 4 +-
.../ExtensiblePolicyWithJarTest.java | 6 +-
jdk/test/jdk/security/jarsigner/Spec.java | 6 +-
.../testlibrary/jdk/testlibrary/JarUtils.java | 148 ------------------
.../security/tools/jarsigner/AltProvider.java | 4 +-
.../sun/security/tools/jarsigner/Options.java | 6 +-
.../tools/jarsigner/TimestampCheck.java | 6 +-
.../tools/jarsigner/TsacertOptionTest.java | 2 +-
.../sun/security/tools/jarsigner/Warning.java | 6 +-
.../warnings/AliasNotInStoreTest.java | 6 +-
.../warnings/BadExtendedKeyUsageTest.java | 6 +-
.../jarsigner/warnings/BadKeyUsageTest.java | 6 +-
.../warnings/BadNetscapeCertTypeTest.java | 6 +-
.../warnings/ChainNotValidatedTest.java | 6 +-
.../warnings/HasExpiredCertTest.java | 6 +-
.../warnings/HasExpiringCertTest.java | 6 +-
.../warnings/HasUnsignedEntryTest.java | 6 +-
.../warnings/MultipleWarningsTest.java | 6 +-
.../jarsigner/warnings/NoTimestampTest.java | 6 +-
.../warnings/NotSignedByAliasTest.java | 6 +-
.../warnings/NotYetValidCertTest.java | 6 +-
.../sun/security/tools/keytool/ReadJar.java | 3 +-
22 files changed, 57 insertions(+), 206 deletions(-)
delete mode 100644 jdk/test/lib/testlibrary/jdk/testlibrary/JarUtils.java
diff --git a/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java b/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java
index 2abf45d3128..be8b719bb33 100644
--- a/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java
+++ b/jdk/test/java/security/AccessController/DoPrivAccompliceTest.java
@@ -25,7 +25,7 @@
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
import java.io.FileWriter;
import java.io.IOException;
@@ -41,7 +41,7 @@ import java.nio.file.Paths;
* Run DoPrivTest.jar and try to access user.name property using
* DoPrivAccmplice.jar.
*
- * @library /test/lib /lib/testlibrary
+ * @library /test/lib
*
* @run main/othervm DoPrivAccompliceTest
*/
diff --git a/jdk/test/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java b/jdk/test/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java
index f3b77b920a7..f6701e995d8 100644
--- a/jdk/test/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.java
+++ b/jdk/test/java/security/Policy/ExtensiblePolicy/ExtensiblePolicyWithJarTest.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
@@ -27,13 +27,13 @@ import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.AccessController;
import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8050402
* @summary Check policy is extensible with user defined permissions
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
* @compile TVJar/TVPermission.java
* @run main ExtensiblePolicyWithJarTest
*/
diff --git a/jdk/test/jdk/security/jarsigner/Spec.java b/jdk/test/jdk/security/jarsigner/Spec.java
index b36b90690df..07e46851e6f 100644
--- a/jdk/test/jdk/security/jarsigner/Spec.java
+++ b/jdk/test/jdk/security/jarsigner/Spec.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,7 +25,7 @@
* @test
* @bug 8056174
* @summary Make sure JarSigner impl conforms to spec
- * @library /lib/testlibrary
+ * @library /test/lib
* @modules java.base/sun.security.tools.keytool
* java.base/sun.security.provider.certpath
* jdk.jartool
@@ -35,7 +35,7 @@
import com.sun.jarsigner.ContentSigner;
import com.sun.jarsigner.ContentSignerParameters;
import jdk.security.jarsigner.JarSigner;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
import sun.security.provider.certpath.X509CertPath;
import java.io.File;
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/JarUtils.java b/jdk/test/lib/testlibrary/jdk/testlibrary/JarUtils.java
deleted file mode 100644
index 07fd00c19e6..00000000000
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/JarUtils.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (c) 2015, 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.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-
-/**
- * Common library for various test jar file utility functions.
- */
-public final class JarUtils {
-
- /**
- * Create jar file with specified files. If a specified file does not exist,
- * a new jar entry will be created with the file name itself as the content.
- */
- public static void createJar(String dest, String... files)
- throws IOException {
- try (JarOutputStream jos = new JarOutputStream(
- new FileOutputStream(dest), new Manifest())) {
- for (String file : files) {
- System.out.println(String.format("Adding %s to %s",
- file, dest));
-
- // add an archive entry, and write a file
- jos.putNextEntry(new JarEntry(file));
- try (FileInputStream fis = new FileInputStream(file)) {
- fis.transferTo(jos);
- } catch (FileNotFoundException e) {
- jos.write(file.getBytes());
- }
- }
- }
- System.out.println();
- }
-
- /**
- * Add or remove specified files to existing jar file. If a specified file
- * to be updated or added does not exist, the jar entry will be created
- * with the file name itself as the content.
- *
- * @param src the original jar file name
- * @param dest the new jar file name
- * @param files the files to update. The list is broken into 2 groups
- * by a "-" string. The files before in the 1st group will
- * be either updated or added. The files in the 2nd group
- * will be removed. If no "-" exists, all files belong to
- * the 1st group.
- */
- public static void updateJar(String src, String dest, String... files)
- throws IOException {
- try (JarOutputStream jos = new JarOutputStream(
- new FileOutputStream(dest))) {
-
- // copy each old entry into destination unless the entry name
- // is in the updated list
- List updatedFiles = new ArrayList<>();
- try (JarFile srcJarFile = new JarFile(src)) {
- Enumeration entries = srcJarFile.entries();
- while (entries.hasMoreElements()) {
- JarEntry entry = entries.nextElement();
- String name = entry.getName();
- boolean found = false;
- boolean update = true;
- for (String file : files) {
- if (file.equals("-")) {
- update = false;
- } else if (name.equals(file)) {
- updatedFiles.add(file);
- found = true;
- break;
- }
- }
-
- if (found) {
- if (update) {
- System.out.println(String.format("Updating %s with %s",
- dest, name));
- jos.putNextEntry(new JarEntry(name));
- try (FileInputStream fis = new FileInputStream(name)) {
- fis.transferTo(jos);
- } catch (FileNotFoundException e) {
- jos.write(name.getBytes());
- }
- } else {
- System.out.println(String.format("Removing %s from %s",
- name, dest));
- }
- } else {
- System.out.println(String.format("Copying %s to %s",
- name, dest));
- jos.putNextEntry(entry);
- srcJarFile.getInputStream(entry).transferTo(jos);
- }
- }
- }
-
- // append new files
- for (String file : files) {
- if (file.equals("-")) {
- break;
- }
- if (!updatedFiles.contains(file)) {
- System.out.println(String.format("Adding %s with %s",
- dest, file));
- jos.putNextEntry(new JarEntry(file));
- try (FileInputStream fis = new FileInputStream(file)) {
- fis.transferTo(jos);
- } catch (FileNotFoundException e) {
- jos.write(file.getBytes());
- }
- }
- }
- }
- System.out.println();
- }
-
-}
diff --git a/jdk/test/sun/security/tools/jarsigner/AltProvider.java b/jdk/test/sun/security/tools/jarsigner/AltProvider.java
index 2717ef9e22e..b8d689b05d6 100644
--- a/jdk/test/sun/security/tools/jarsigner/AltProvider.java
+++ b/jdk/test/sun/security/tools/jarsigner/AltProvider.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
@@ -32,7 +32,7 @@
import jdk.test.lib.JDKToolLauncher;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.process.ProcessTools;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
import java.nio.file.*;
diff --git a/jdk/test/sun/security/tools/jarsigner/Options.java b/jdk/test/sun/security/tools/jarsigner/Options.java
index e70903d06e3..ed2dda9ba96 100644
--- a/jdk/test/sun/security/tools/jarsigner/Options.java
+++ b/jdk/test/sun/security/tools/jarsigner/Options.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
@@ -26,7 +26,7 @@
* @bug 8056174
* @summary Make sure the jarsigner tool still works after it's modified to
* be based on JarSigner API
- * @library /lib/testlibrary
+ * @library /test/lib
* @modules java.base/sun.security.tools.keytool
* jdk.jartool/sun.security.tools.jarsigner
* java.base/sun.security.pkcs
@@ -35,7 +35,7 @@
import com.sun.jarsigner.ContentSigner;
import com.sun.jarsigner.ContentSignerParameters;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
import sun.security.pkcs.PKCS7;
import java.io.ByteArrayInputStream;
diff --git a/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java b/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java
index 928bc5aa199..795ec89eb0b 100644
--- a/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java
+++ b/jdk/test/sun/security/tools/jarsigner/TimestampCheck.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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 java.util.jar.JarFile;
import jdk.test.lib.SecurityTools;
import jdk.testlibrary.*;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
import sun.security.pkcs.ContentInfo;
import sun.security.pkcs.PKCS7;
import sun.security.pkcs.PKCS9Attribute;
@@ -557,7 +557,7 @@ public class TimestampCheck {
}
static void prepare() throws Exception {
- jdk.testlibrary.JarUtils.createJar("old.jar", "A");
+ JarUtils.createJar("old.jar", "A");
Files.deleteIfExists(Paths.get("tsks"));
keytool("-alias ca -genkeypair -ext bc -dname CN=CA");
keytool("-alias old -genkeypair -dname CN=old");
diff --git a/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java b/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java
index cfe23932f3f..8c07047586a 100644
--- a/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/TsacertOptionTest.java
@@ -22,7 +22,7 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
diff --git a/jdk/test/sun/security/tools/jarsigner/Warning.java b/jdk/test/sun/security/tools/jarsigner/Warning.java
index 70233634e0b..c4760c488fc 100644
--- a/jdk/test/sun/security/tools/jarsigner/Warning.java
+++ b/jdk/test/sun/security/tools/jarsigner/Warning.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
@@ -22,7 +22,7 @@
*/
import jdk.testlibrary.JDKToolLauncher;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
import jdk.testlibrary.OutputAnalyzer;
import jdk.testlibrary.ProcessTools;
@@ -34,7 +34,7 @@ import java.util.Arrays;
* @test
* @bug 8024302 8026037 8130132
* @summary warnings, errors and -strict
- * @library /lib/testlibrary
+ * @library /lib/testlibrary /test/lib
*/
public class Warning {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java
index d4f0a8ef390..2e0bac3f740 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/AliasNotInStoreTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,13 +22,13 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Test for aliasNotInStore warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main AliasNotInStoreTest
*/
public class AliasNotInStoreTest extends Test {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java
index 503b9c066aa..f0d45d7750a 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/BadExtendedKeyUsageTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,13 +22,13 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Test for badExtendedKeyUsage warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main BadExtendedKeyUsageTest
*/
public class BadExtendedKeyUsageTest extends Test {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java
index 9f7cc362320..2a3c79a6a63 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,13 +22,13 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Test for badKeyUsage warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @ignore until 8026393 is fixed
* @run main BadKeyUsageTest
*/
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java
index f198bfa8b2c..742b36f5bb0 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/BadNetscapeCertTypeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,7 +22,7 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
import java.nio.file.Files;
import java.nio.file.Paths;
@@ -32,7 +32,7 @@ import java.util.Base64;
* @test
* @bug 8024302 8026037
* @summary Test for badNetscapeCertType warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main BadNetscapeCertTypeTest
*/
public class BadNetscapeCertTypeTest extends Test {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java
index ab5ef7c9ee7..197a4137538 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/ChainNotValidatedTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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,13 +24,13 @@
import java.io.File;
import jdk.testlibrary.OutputAnalyzer;
import jdk.testlibrary.ProcessTools;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Test for chainNotValidated warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main ChainNotValidatedTest
*/
public class ChainNotValidatedTest extends Test {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java
index 2c987d79ea7..10d6f9358a9 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiredCertTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,13 +22,13 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Test for hasExpiredCert warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main HasExpiredCertTest
*/
public class HasExpiredCertTest extends Test {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java
index a1d8bbe00e6..be936dcbec3 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/HasExpiringCertTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,13 +22,13 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Test for hasExpiringCert warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main HasExpiringCertTest
*/
public class HasExpiringCertTest extends Test {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java
index 5dbb63ac986..a4ffdae18d6 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/HasUnsignedEntryTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,13 +22,13 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Test for hasUnsignedEntry warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main HasUnsignedEntryTest
*/
public class HasUnsignedEntryTest extends Test {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java
index c539ba4a6d6..73ccb0e6562 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/MultipleWarningsTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,13 +22,13 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Checks if jarsigner prints appropriate warnings
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main MultipleWarningsTest
*/
public class MultipleWarningsTest extends Test {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/NoTimestampTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/NoTimestampTest.java
index f69118c807c..5fda7782fd6 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/NoTimestampTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/NoTimestampTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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,13 +23,13 @@
import java.util.Date;
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Checks warnings if -tsa and -tsacert options are not specified
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main NoTimestampTest
*/
public class NoTimestampTest extends Test {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java
index f309cf5233e..041b715d46b 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/NotSignedByAliasTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,13 +22,13 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Test for notSignedByAlias warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main NotSignedByAliasTest
*/
public class NotSignedByAliasTest extends Test {
diff --git a/jdk/test/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java b/jdk/test/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java
index 235170e14cd..a63ab253e96 100644
--- a/jdk/test/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java
+++ b/jdk/test/sun/security/tools/jarsigner/warnings/NotYetValidCertTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -22,13 +22,13 @@
*/
import jdk.testlibrary.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
/**
* @test
* @bug 8024302 8026037
* @summary Test for notYetValidCert warning
- * @library /lib/testlibrary ../
+ * @library /lib/testlibrary /test/lib ../
* @run main NotYetValidCertTest
*/
public class NotYetValidCertTest extends Test {
diff --git a/jdk/test/sun/security/tools/keytool/ReadJar.java b/jdk/test/sun/security/tools/keytool/ReadJar.java
index 644033cc1fa..ef6d1c868b9 100644
--- a/jdk/test/sun/security/tools/keytool/ReadJar.java
+++ b/jdk/test/sun/security/tools/keytool/ReadJar.java
@@ -26,14 +26,13 @@
* @bug 6890872 8168882
* @summary keytool -printcert to recognize signed jar files
* @library /test/lib
- * @library /lib/testlibrary
*/
import java.nio.file.Files;
import java.nio.file.Paths;
import jdk.test.lib.SecurityTools;
import jdk.test.lib.process.OutputAnalyzer;
-import jdk.testlibrary.JarUtils;
+import jdk.test.lib.util.JarUtils;
public class ReadJar {
From 88c4940eeb34d8d2a702a21ce1ef8ad7cf781b62 Mon Sep 17 00:00:00 2001
From: Igor Ignatyev
Date: Tue, 30 May 2017 21:07:14 -0700
Subject: [PATCH 47/55] 8180888: move jdk.testlibrary.JarUtils to the top level
testlibrary
Reviewed-by: weijun
---
test/lib/jdk/test/lib/util/JarUtils.java | 148 +++++++++++++++++++++++
1 file changed, 148 insertions(+)
create mode 100644 test/lib/jdk/test/lib/util/JarUtils.java
diff --git a/test/lib/jdk/test/lib/util/JarUtils.java b/test/lib/jdk/test/lib/util/JarUtils.java
new file mode 100644
index 00000000000..76705f5395c
--- /dev/null
+++ b/test/lib/jdk/test/lib/util/JarUtils.java
@@ -0,0 +1,148 @@
+/*
+ * 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
+ * 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.test.lib.util;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+/**
+ * Common library for various test jar file utility functions.
+ */
+public final class JarUtils {
+
+ /**
+ * Create jar file with specified files. If a specified file does not exist,
+ * a new jar entry will be created with the file name itself as the content.
+ */
+ public static void createJar(String dest, String... files)
+ throws IOException {
+ try (JarOutputStream jos = new JarOutputStream(
+ new FileOutputStream(dest), new Manifest())) {
+ for (String file : files) {
+ System.out.println(String.format("Adding %s to %s",
+ file, dest));
+
+ // add an archive entry, and write a file
+ jos.putNextEntry(new JarEntry(file));
+ try (FileInputStream fis = new FileInputStream(file)) {
+ fis.transferTo(jos);
+ } catch (FileNotFoundException e) {
+ jos.write(file.getBytes());
+ }
+ }
+ }
+ System.out.println();
+ }
+
+ /**
+ * Add or remove specified files to existing jar file. If a specified file
+ * to be updated or added does not exist, the jar entry will be created
+ * with the file name itself as the content.
+ *
+ * @param src the original jar file name
+ * @param dest the new jar file name
+ * @param files the files to update. The list is broken into 2 groups
+ * by a "-" string. The files before in the 1st group will
+ * be either updated or added. The files in the 2nd group
+ * will be removed. If no "-" exists, all files belong to
+ * the 1st group.
+ */
+ public static void updateJar(String src, String dest, String... files)
+ throws IOException {
+ try (JarOutputStream jos = new JarOutputStream(
+ new FileOutputStream(dest))) {
+
+ // copy each old entry into destination unless the entry name
+ // is in the updated list
+ List updatedFiles = new ArrayList<>();
+ try (JarFile srcJarFile = new JarFile(src)) {
+ Enumeration entries = srcJarFile.entries();
+ while (entries.hasMoreElements()) {
+ JarEntry entry = entries.nextElement();
+ String name = entry.getName();
+ boolean found = false;
+ boolean update = true;
+ for (String file : files) {
+ if (file.equals("-")) {
+ update = false;
+ } else if (name.equals(file)) {
+ updatedFiles.add(file);
+ found = true;
+ break;
+ }
+ }
+
+ if (found) {
+ if (update) {
+ System.out.println(String.format("Updating %s with %s",
+ dest, name));
+ jos.putNextEntry(new JarEntry(name));
+ try (FileInputStream fis = new FileInputStream(name)) {
+ fis.transferTo(jos);
+ } catch (FileNotFoundException e) {
+ jos.write(name.getBytes());
+ }
+ } else {
+ System.out.println(String.format("Removing %s from %s",
+ name, dest));
+ }
+ } else {
+ System.out.println(String.format("Copying %s to %s",
+ name, dest));
+ jos.putNextEntry(entry);
+ srcJarFile.getInputStream(entry).transferTo(jos);
+ }
+ }
+ }
+
+ // append new files
+ for (String file : files) {
+ if (file.equals("-")) {
+ break;
+ }
+ if (!updatedFiles.contains(file)) {
+ System.out.println(String.format("Adding %s with %s",
+ dest, file));
+ jos.putNextEntry(new JarEntry(file));
+ try (FileInputStream fis = new FileInputStream(file)) {
+ fis.transferTo(jos);
+ } catch (FileNotFoundException e) {
+ jos.write(file.getBytes());
+ }
+ }
+ }
+ }
+ System.out.println();
+ }
+
+}
From 1ccebabd11bc30ab0bf4dd9f1f03bd4359ee29c1 Mon Sep 17 00:00:00 2001
From: Igor Ignatyev
Date: Tue, 30 May 2017 21:14:02 -0700
Subject: [PATCH 48/55] 8180805: move RandomFactory to the top level
testlibrary
Reviewed-by: bpb, rriggs
---
test/lib/jdk/test/lib/RandomFactory.java | 103 +++++++++++++++++++++++
1 file changed, 103 insertions(+)
create mode 100644 test/lib/jdk/test/lib/RandomFactory.java
diff --git a/test/lib/jdk/test/lib/RandomFactory.java b/test/lib/jdk/test/lib/RandomFactory.java
new file mode 100644
index 00000000000..8930a380008
--- /dev/null
+++ b/test/lib/jdk/test/lib/RandomFactory.java
@@ -0,0 +1,103 @@
+/*
+ * 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
+ * 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.test.lib;
+
+import java.util.Random;
+import java.util.SplittableRandom;
+
+/**
+ * Factory class which generates and prints to STDOUT a long-valued seed
+ * for use in initializing a PRNG. An instance of {@code Random} or
+ * {@code SplittableRandom} may likewise be obtained.
+ */
+public class RandomFactory {
+ /**
+ * Attempt to obtain the seed from the value of the "seed" property.
+ * @return The seed or {@code null} if the "seed" property was not set or
+ * could not be parsed.
+ */
+ private static Long getSystemSeed() {
+ Long seed = null;
+ try {
+ // note that Long.valueOf(null) also throws a
+ // NumberFormatException so if the property is undefined this
+ // will still work correctly
+ seed = Long.valueOf(System.getProperty("seed"));
+ } catch (NumberFormatException e) {
+ // do nothing: seed is still null
+ }
+
+ return seed;
+ }
+
+ /**
+ * Obtain a seed from an independent PRNG.
+ *
+ * @return A random seed.
+ */
+ private static long getRandomSeed() {
+ return new Random().nextLong();
+ }
+
+ /**
+ * Obtain and print to STDOUT a seed appropriate for initializing a PRNG.
+ * If the system property "seed" is set and has value which may be correctly
+ * parsed it is used, otherwise a seed is generated using an independent
+ * PRNG.
+ *
+ * @return The seed.
+ */
+ public static long getSeed() {
+ Long seed = getSystemSeed();
+ if (seed == null) {
+ seed = getRandomSeed();
+ }
+ System.out.println("Seed from RandomFactory = "+seed+"L");
+ return seed;
+ }
+
+ /**
+ * Obtain and print to STDOUT a seed and use it to initialize a new
+ * {@code Random} instance which is returned. If the system
+ * property "seed" is set and has value which may be correctly parsed it
+ * is used, otherwise a seed is generated using an independent PRNG.
+ *
+ * @return The {@code Random} instance.
+ */
+ public static Random getRandom() {
+ return new Random(getSeed());
+ }
+
+ /**
+ * Obtain and print to STDOUT a seed and use it to initialize a new
+ * {@code SplittableRandom} instance which is returned. If the system
+ * property "seed" is set and has value which may be correctly parsed it
+ * is used, otherwise a seed is generated using an independent PRNG.
+ *
+ * @return The {@code SplittableRandom} instance.
+ */
+ public static SplittableRandom getSplittableRandom() {
+ return new SplittableRandom(getSeed());
+ }
+}
From 551c6fdad3d3e999ee92160b6b06b1763794489f Mon Sep 17 00:00:00 2001
From: Igor Ignatyev
Date: Tue, 30 May 2017 21:14:45 -0700
Subject: [PATCH 49/55] 8180805: move RandomFactory to the top level
testlibrary
Reviewed-by: bpb, rriggs
---
.../provider/CICO/PBEFunc/CipherNCFuncTest.java | 12 +++++++-----
jdk/test/java/io/InputStream/ReadAllBytes.java | 7 +++----
jdk/test/java/io/InputStream/ReadNBytes.java | 7 +++----
jdk/test/java/lang/Double/ParseHexFloatingPoint.java | 7 +++----
jdk/test/java/lang/Integer/BitTwiddle.java | 7 +++----
jdk/test/java/lang/Long/BitTwiddle.java | 7 +++----
jdk/test/java/lang/Math/CubeRootTests.java | 7 +++----
jdk/test/java/lang/Math/HypotTests.java | 7 +++----
jdk/test/java/lang/Math/IeeeRecommendedTests.java | 7 +++----
jdk/test/java/lang/Math/Log1pTests.java | 7 +++----
jdk/test/java/lang/Math/MultiplicationTests.java | 7 +++----
jdk/test/java/lang/StackWalker/StackWalkTest.java | 7 +++----
jdk/test/java/lang/StrictMath/CubeRootTests.java | 7 +++----
jdk/test/java/lang/StrictMath/ExpTests.java | 7 +++----
jdk/test/java/lang/StrictMath/HypotTests.java | 7 +++----
jdk/test/java/lang/String/LiteralReplace.java | 7 +++----
jdk/test/java/math/BigDecimal/StringConstructor.java | 7 +++----
jdk/test/java/math/BigInteger/BigIntegerTest.java | 7 +++----
jdk/test/java/math/BigInteger/ModPow65537.java | 7 +++----
jdk/test/java/math/BigInteger/PrimeTest.java | 7 +++----
.../java/math/BigInteger/SymmetricRangeTests.java | 7 +++----
.../channels/AsynchronousSocketChannel/Basic.java | 5 ++---
jdk/test/java/nio/channels/FileChannel/Transfer.java | 5 ++---
.../java/nio/channels/SocketChannel/VectorIO.java | 5 ++---
jdk/test/java/nio/file/Files/CopyAndMove.java | 8 ++++----
jdk/test/java/nio/file/Files/StreamLinesTest.java | 5 ++---
.../java/nio/file/WatchService/LotsOfEvents.java | 5 ++---
.../KeyStore/PKCS12/EntryProtectionTest.java | 6 +++---
.../security/MessageDigest/TestDigestIOStream.java | 7 +++----
.../java/security/MessageDigest/TestSameLength.java | 7 +++----
.../java/security/MessageDigest/TestSameValue.java | 7 +++----
jdk/test/java/security/Signature/Offsets.java | 6 +++---
jdk/test/java/util/Base64/TestBase64.java | 7 +++----
jdk/test/java/util/List/SubList.java | 7 +++----
.../java/util/WeakHashMap/GCDuringIteration.java | 7 +++----
.../concurrent/ThreadPoolExecutor/ConfigChanges.java | 7 +++----
.../util/jar/JarFile/mrjar/MultiReleaseJarAPI.java | 7 +++----
jdk/test/java/util/regex/RegExTest.java | 7 +++----
.../util/zip/InflaterInputStream/TestAvailable.java | 7 +++----
.../plugins/tiff/MultiPageTest/MultiPageTest.java | 7 +++----
.../javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java | 6 +++---
.../DTLS/DTLSRehandshakeWithCipherChangeTest.java | 4 ++--
.../javax/net/ssl/DTLS/DTLSSequenceNumberTest.java | 6 +++---
.../net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java | 4 ++--
.../DTLSv10RehandshakeWithCipherChangeTest.java | 4 ++--
.../ssl/TLS/TLSRehandshakeWithCipherChangeTest.java | 4 ++--
.../TLSCommon/RehandshakeWithCipherChangeTest.java | 4 ++--
.../TLSv1/TLSRehandshakeWithCipherChangeTest.java | 4 ++--
.../TLSv11/TLSRehandshakeWithCipherChangeTest.java | 4 ++--
.../swing/ToolTipManager/7123767/bug7123767.java | 7 +++----
.../testlibrary/jdk/testlibrary/RandomFactory.java | 7 ++++++-
jdk/test/sun/nio/cs/FindDecoderBugs.java | 7 +++----
jdk/test/sun/nio/cs/FindEncoderBugs.java | 7 +++----
jdk/test/sun/security/ec/SignatureOffsets.java | 4 ++--
jdk/test/sun/security/mscapi/SignatureOffsets.java | 4 ++--
.../security/pkcs11/rsa/TestKeyPairGenerator.java | 5 ++---
jdk/test/sun/security/rsa/SignatureOffsets.java | 4 ++--
jdk/test/sun/security/ssl/rsa/SignatureOffsets.java | 4 ++--
58 files changed, 165 insertions(+), 198 deletions(-)
diff --git a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CipherNCFuncTest.java b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CipherNCFuncTest.java
index 73952ebb7c3..c923edb2a1a 100644
--- a/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CipherNCFuncTest.java
+++ b/jdk/test/com/sun/crypto/provider/CICO/PBEFunc/CipherNCFuncTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2015, 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
@@ -20,20 +20,22 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
/*
* @test
* @bug 8048604
- * @library ../ /lib/testlibrary
+ * @library ../ /test/lib
* @summary This test verifies the assertion "There should be no transformation
- * on the plaintext/ciphertext in encryption/decryption mechanism" for
- * feature "NullCipher".
+ * on the plaintext/ciphertext in encryption/decryption mechanism" for
+ * feature "NullCipher".
*/
+
import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
import javax.crypto.IllegalBlockSizeException;
import javax.crypto.NullCipher;
import javax.crypto.ShortBufferException;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class CipherNCFuncTest {
public static void main(String[] args) throws ShortBufferException,
diff --git a/jdk/test/java/io/InputStream/ReadAllBytes.java b/jdk/test/java/io/InputStream/ReadAllBytes.java
index ef9a2728df9..88ab4d66791 100644
--- a/jdk/test/java/io/InputStream/ReadAllBytes.java
+++ b/jdk/test/java/io/InputStream/ReadAllBytes.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
@@ -27,13 +27,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/*
* @test
* @bug 8080835
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main ReadAllBytes
* @summary Basic test for InputStream.readAllBytes
* @key randomness
diff --git a/jdk/test/java/io/InputStream/ReadNBytes.java b/jdk/test/java/io/InputStream/ReadNBytes.java
index 8f26a6e9d78..3b3999f1647 100644
--- a/jdk/test/java/io/InputStream/ReadNBytes.java
+++ b/jdk/test/java/io/InputStream/ReadNBytes.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
@@ -27,13 +27,12 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/*
* @test
* @bug 8080835
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main ReadNBytes
* @summary Basic test for InputStream.readNBytes
* @key randomness
diff --git a/jdk/test/java/lang/Double/ParseHexFloatingPoint.java b/jdk/test/java/lang/Double/ParseHexFloatingPoint.java
index e4b2ac2a62e..39f8f750e18 100644
--- a/jdk/test/java/lang/Double/ParseHexFloatingPoint.java
+++ b/jdk/test/java/lang/Double/ParseHexFloatingPoint.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main ParseHexFloatingPoint
* @bug 4826774 8078672
* @summary Numerical tests for hexadecimal inputs to parse{Double, Float} (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
* @key randomness
*/
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class ParseHexFloatingPoint {
private ParseHexFloatingPoint(){}
diff --git a/jdk/test/java/lang/Integer/BitTwiddle.java b/jdk/test/java/lang/Integer/BitTwiddle.java
index 50b5762bd7d..9fc710c513e 100644
--- a/jdk/test/java/lang/Integer/BitTwiddle.java
+++ b/jdk/test/java/lang/Integer/BitTwiddle.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main BitTwiddle
* @bug 4495754 8078672
* @summary Basic test for int bit twiddling (use -Dseed=X to set PRNG seed)
@@ -33,7 +32,7 @@
*/
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
import static java.lang.Integer.*;
public class BitTwiddle {
diff --git a/jdk/test/java/lang/Long/BitTwiddle.java b/jdk/test/java/lang/Long/BitTwiddle.java
index d3833ae042c..52925458420 100644
--- a/jdk/test/java/lang/Long/BitTwiddle.java
+++ b/jdk/test/java/lang/Long/BitTwiddle.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main BitTwiddle
* @bug 4495754 8078672
* @summary Basic test for long bit twiddling (use -Dseed=X to set PRNG seed)
@@ -33,7 +32,7 @@
*/
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
import static java.lang.Long.*;
public class BitTwiddle {
diff --git a/jdk/test/java/lang/Math/CubeRootTests.java b/jdk/test/java/lang/Math/CubeRootTests.java
index ca629a53db3..7dd4a18b81c 100644
--- a/jdk/test/java/lang/Math/CubeRootTests.java
+++ b/jdk/test/java/lang/Math/CubeRootTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
* @run main CubeRootTests
* @bug 4347132 4939441 8078672
* @summary Tests for {Math, StrictMath}.cbrt (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
* @key randomness
*/
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class CubeRootTests {
private CubeRootTests(){}
diff --git a/jdk/test/java/lang/Math/HypotTests.java b/jdk/test/java/lang/Math/HypotTests.java
index dbec84bf48f..a55549f12f1 100644
--- a/jdk/test/java/lang/Math/HypotTests.java
+++ b/jdk/test/java/lang/Math/HypotTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
* @run main HypotTests
* @bug 4851638 4939441 8078672
* @summary Tests for {Math, StrictMath}.hypot (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
* @key randomness
*/
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class HypotTests {
private HypotTests(){}
diff --git a/jdk/test/java/lang/Math/IeeeRecommendedTests.java b/jdk/test/java/lang/Math/IeeeRecommendedTests.java
index 5697505ef17..8315fa74ba1 100644
--- a/jdk/test/java/lang/Math/IeeeRecommendedTests.java
+++ b/jdk/test/java/lang/Math/IeeeRecommendedTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
* @run main IeeeRecommendedTests
* @bug 4860891 4826732 4780454 4939441 4826652 8078672
* @summary Tests for IEEE 754[R] recommended functions and similar methods (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
* @key randomness
*/
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class IeeeRecommendedTests {
private IeeeRecommendedTests(){}
diff --git a/jdk/test/java/lang/Math/Log1pTests.java b/jdk/test/java/lang/Math/Log1pTests.java
index 7fda0203d75..b1dde3ab965 100644
--- a/jdk/test/java/lang/Math/Log1pTests.java
+++ b/jdk/test/java/lang/Math/Log1pTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
* @run main Log1pTests
* @bug 4851638 4939441 8078672
* @summary Tests for {Math, StrictMath}.log1p (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
* @key randomness
*/
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class Log1pTests {
private Log1pTests(){}
diff --git a/jdk/test/java/lang/Math/MultiplicationTests.java b/jdk/test/java/lang/Math/MultiplicationTests.java
index 1a9c3da2a67..1bc29d092ef 100644
--- a/jdk/test/java/lang/Math/MultiplicationTests.java
+++ b/jdk/test/java/lang/Math/MultiplicationTests.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
@@ -23,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main MultiplicationTests
* @bug 5100935
* @summary Tests for multiplication methods (use -Dseed=X to set PRNG seed)
@@ -32,7 +31,7 @@
*/
import java.math.BigInteger;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class MultiplicationTests {
private MultiplicationTests(){}
diff --git a/jdk/test/java/lang/StackWalker/StackWalkTest.java b/jdk/test/java/lang/StackWalker/StackWalkTest.java
index 711bd4bd584..9d4dd991e65 100644
--- a/jdk/test/java/lang/StackWalker/StackWalkTest.java
+++ b/jdk/test/java/lang/StackWalker/StackWalkTest.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
@@ -31,14 +31,13 @@ import java.util.Random;
import java.util.Set;
import java.util.TreeSet;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* @test
* @bug 8140450
* @summary Stack Walk Test (use -Dseed=X to set PRNG seed)
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @compile StackRecorderUtil.java
* @run main/othervm StackWalkTest
* @run main/othervm/java.security.policy=stackwalktest.policy StackWalkTest
diff --git a/jdk/test/java/lang/StrictMath/CubeRootTests.java b/jdk/test/java/lang/StrictMath/CubeRootTests.java
index afbdb4c7fb5..094150010a0 100644
--- a/jdk/test/java/lang/StrictMath/CubeRootTests.java
+++ b/jdk/test/java/lang/StrictMath/CubeRootTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,8 +25,7 @@
* @test
* @bug 4347132 8136799
* @key randomness
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
* @build Tests
* @build FdlibmTranslit
* @build CubeRootTests
@@ -35,7 +34,7 @@
* @author Joseph D. Darcy
*/
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* The tests in ../Math/CubeRootTests.java test properties that should
diff --git a/jdk/test/java/lang/StrictMath/ExpTests.java b/jdk/test/java/lang/StrictMath/ExpTests.java
index 0a2e1f0304d..ec463f2cbee 100644
--- a/jdk/test/java/lang/StrictMath/ExpTests.java
+++ b/jdk/test/java/lang/StrictMath/ExpTests.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,8 +25,7 @@
* @test
* @bug 8139688
* @key randomness
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
* @build Tests
* @build FdlibmTranslit
* @build ExpTests
@@ -34,7 +33,7 @@
* @summary Tests specifically for StrictMath.exp
*/
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* The role of this test is to verify that the FDLIBM exp algorithm is
diff --git a/jdk/test/java/lang/StrictMath/HypotTests.java b/jdk/test/java/lang/StrictMath/HypotTests.java
index 75524334539..6fa4cdeafca 100644
--- a/jdk/test/java/lang/StrictMath/HypotTests.java
+++ b/jdk/test/java/lang/StrictMath/HypotTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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 4851638
* @key randomness
* @summary Tests for StrictMath.hypot
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
* @build Tests
* @build FdlibmTranslit
* @build HypotTests
@@ -35,7 +34,7 @@
* @author Joseph D. Darcy
*/
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* The tests in ../Math/HypotTests.java test properties that should
diff --git a/jdk/test/java/lang/String/LiteralReplace.java b/jdk/test/java/lang/String/LiteralReplace.java
index 32fc779408f..4a3541986db 100644
--- a/jdk/test/java/lang/String/LiteralReplace.java
+++ b/jdk/test/java/lang/String/LiteralReplace.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
@@ -23,8 +23,7 @@
/* @test
* @bug 8058779 8054307
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
* @run testng LiteralReplace
* @summary Basic tests of String.replace(CharSequence, CharSequence)
* @key randomness
@@ -37,7 +36,7 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
import org.testng.annotations.Test;
import org.testng.annotations.DataProvider;
diff --git a/jdk/test/java/math/BigDecimal/StringConstructor.java b/jdk/test/java/math/BigDecimal/StringConstructor.java
index 4a3e3c4757f..df51b32574a 100644
--- a/jdk/test/java/math/BigDecimal/StringConstructor.java
+++ b/jdk/test/java/math/BigDecimal/StringConstructor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, 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
@@ -23,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main StringConstructor
* @bug 4103117 4331084 4488017 4490929 6255285 6268365 8074460 8078672
* @summary Tests the BigDecimal string constructor (use -Dseed=X to set PRNG seed).
@@ -33,7 +32,7 @@
import java.math.*;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class StringConstructor {
diff --git a/jdk/test/java/math/BigInteger/BigIntegerTest.java b/jdk/test/java/math/BigInteger/BigIntegerTest.java
index f8632809fb0..06c2da5b06e 100644
--- a/jdk/test/java/math/BigInteger/BigIntegerTest.java
+++ b/jdk/test/java/math/BigInteger/BigIntegerTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main BigIntegerTest
* @bug 4181191 4161971 4227146 4194389 4823171 4624738 4812225 4837946 4026465 8074460 8078672 8032027
* @summary tests methods in BigInteger (use -Dseed=X to set PRNG seed)
@@ -47,7 +46,7 @@ import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
import java.util.stream.LongStream;
import java.util.stream.Stream;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* This is a simple test class created to ensure that the results
diff --git a/jdk/test/java/math/BigInteger/ModPow65537.java b/jdk/test/java/math/BigInteger/ModPow65537.java
index 1ca8d603bf0..d8acf648548 100644
--- a/jdk/test/java/math/BigInteger/ModPow65537.java
+++ b/jdk/test/java/math/BigInteger/ModPow65537.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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,8 +23,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main ModPow65537
* @bug 4891312 8074460 8078672
* @summary verify that modPow() not broken by the special case for 65537 (use -Dseed=X to set PRNG seed)
@@ -37,7 +36,7 @@ import java.math.BigInteger;
import java.security.*;
import java.security.spec.*;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class ModPow65537 {
diff --git a/jdk/test/java/math/BigInteger/PrimeTest.java b/jdk/test/java/math/BigInteger/PrimeTest.java
index 42946106820..bfac4c82dde 100644
--- a/jdk/test/java/math/BigInteger/PrimeTest.java
+++ b/jdk/test/java/math/BigInteger/PrimeTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2015, 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
@@ -25,8 +25,7 @@
/*
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main PrimeTest
* @bug 8026236 8074460 8078672
* @summary test primality verification methods in BigInteger (use -Dseed=X to set PRNG seed)
@@ -40,7 +39,7 @@ import java.util.NavigableSet;
import java.util.Set;
import java.util.SplittableRandom;
import java.util.TreeSet;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
import static java.util.stream.Collectors.toCollection;
import static java.util.stream.Collectors.toList;
diff --git a/jdk/test/java/math/BigInteger/SymmetricRangeTests.java b/jdk/test/java/math/BigInteger/SymmetricRangeTests.java
index bae3c17fd48..61a65b4b7c8 100644
--- a/jdk/test/java/math/BigInteger/SymmetricRangeTests.java
+++ b/jdk/test/java/math/BigInteger/SymmetricRangeTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
* @ignore This test has huge memory requirements
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main/timeout=180/othervm -Xmx8g SymmetricRangeTests
* @bug 6910473 8021204 8021203 9005933 8074460 8078672
* @summary Test range of BigInteger values (use -Dseed=X to set PRNG seed)
@@ -40,7 +39,7 @@ import java.io.ObjectOutputStream;
import java.util.Arrays;
import java.math.BigInteger;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class SymmetricRangeTests {
diff --git a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java
index 64861b4c865..bc2b4fa81c1 100644
--- a/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java
+++ b/jdk/test/java/nio/channels/AsynchronousSocketChannel/Basic.java
@@ -24,8 +24,7 @@
/* @test
* @bug 4607272 6842687 6878369 6944810 7023403
* @summary Unit test for AsynchronousSocketChannel(use -Dseed=X to set PRNG seed)
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main Basic -skipSlowConnectTest
* @key randomness intermittent
*/
@@ -40,7 +39,7 @@ import java.util.Random;
import java.util.Set;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class Basic {
private static final Random RAND = RandomFactory.getRandom();
diff --git a/jdk/test/java/nio/channels/FileChannel/Transfer.java b/jdk/test/java/nio/channels/FileChannel/Transfer.java
index 43d7202408c..a6566996b0c 100644
--- a/jdk/test/java/nio/channels/FileChannel/Transfer.java
+++ b/jdk/test/java/nio/channels/FileChannel/Transfer.java
@@ -25,8 +25,7 @@
* @bug 4434723 4482726 4559072 4795550 5081340 5103988 6984545
* @summary Test FileChannel.transferFrom and transferTo (use -Dseed=X to set PRNG seed)
* @library ..
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run testng/timeout=300 Transfer
* @key randomness
*/
@@ -51,7 +50,7 @@ import java.nio.channels.spi.SelectorProvider;
import java.util.Random;
import java.util.concurrent.TimeUnit;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
import org.testng.annotations.Test;
diff --git a/jdk/test/java/nio/channels/SocketChannel/VectorIO.java b/jdk/test/java/nio/channels/SocketChannel/VectorIO.java
index 8f585afb21a..11df48a71f1 100644
--- a/jdk/test/java/nio/channels/SocketChannel/VectorIO.java
+++ b/jdk/test/java/nio/channels/SocketChannel/VectorIO.java
@@ -23,8 +23,7 @@
/* @test
* @summary Test socketchannel vector IO (use -Dseed=X to set PRNG seed)
- * @library .. /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library .. /test/lib
* @run main VectorIO
* @key randomness
*/
@@ -34,7 +33,7 @@ import java.net.*;
import java.nio.*;
import java.nio.channels.*;
import java.util.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class VectorIO {
diff --git a/jdk/test/java/nio/file/Files/CopyAndMove.java b/jdk/test/java/nio/file/Files/CopyAndMove.java
index 80f35b88960..f3094f2b357 100644
--- a/jdk/test/java/nio/file/Files/CopyAndMove.java
+++ b/jdk/test/java/nio/file/Files/CopyAndMove.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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,8 @@
/* @test
* @bug 4313887 6838333 6917021 7006126 6950237 8006645
* @summary Unit test for java.nio.file.Files copy and move methods (use -Dseed=X to set PRNG seed)
- * @library .. /lib/testlibrary/
- * @build jdk.testlibrary.* CopyAndMove PassThroughFileSystem
+ * @library .. /test/lib
+ * @build CopyAndMove PassThroughFileSystem
* @run main/othervm CopyAndMove
* @key randomness
*/
@@ -39,7 +39,7 @@ import java.nio.file.attribute.*;
import java.io.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class CopyAndMove {
static final Random rand = RandomFactory.getRandom();
diff --git a/jdk/test/java/nio/file/Files/StreamLinesTest.java b/jdk/test/java/nio/file/Files/StreamLinesTest.java
index 2cf90e765a7..8ffe8919a87 100644
--- a/jdk/test/java/nio/file/Files/StreamLinesTest.java
+++ b/jdk/test/java/nio/file/Files/StreamLinesTest.java
@@ -23,9 +23,8 @@
/* @test
* @bug 8072773
- * @library /lib/testlibrary/ /lib/testlibrary/bootlib
+ * @library /test/lib /lib/testlibrary/bootlib
* @build java.base/java.util.stream.OpTestCase
- * @build jdk.testlibrary.RandomFactory
* @run testng/othervm StreamLinesTest
* @summary Tests streams returned from Files.lines, primarily focused on
* testing the file-channel-based stream stream with supported
@@ -54,7 +53,7 @@ import java.util.function.Supplier;
import java.util.stream.OpTestCase;
import java.util.stream.Stream;
import java.util.stream.TestData;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class StreamLinesTest extends OpTestCase {
diff --git a/jdk/test/java/nio/file/WatchService/LotsOfEvents.java b/jdk/test/java/nio/file/WatchService/LotsOfEvents.java
index 6990c1e8d89..04a96c09fda 100644
--- a/jdk/test/java/nio/file/WatchService/LotsOfEvents.java
+++ b/jdk/test/java/nio/file/WatchService/LotsOfEvents.java
@@ -25,8 +25,7 @@
* @bug 6907760 6929532
* @summary Tests WatchService behavior when lots of events are pending (use -Dseed=X to set PRNG seed)
* @library ..
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main/timeout=180 LotsOfEvents
* @key randomness
*/
@@ -37,7 +36,7 @@ import java.nio.file.*;
import static java.nio.file.StandardWatchEventKinds.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class LotsOfEvents {
diff --git a/jdk/test/java/security/KeyStore/PKCS12/EntryProtectionTest.java b/jdk/test/java/security/KeyStore/PKCS12/EntryProtectionTest.java
index 4500431bff0..225ffa3a6eb 100644
--- a/jdk/test/java/security/KeyStore/PKCS12/EntryProtectionTest.java
+++ b/jdk/test/java/security/KeyStore/PKCS12/EntryProtectionTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -30,7 +30,7 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import javax.crypto.spec.PBEParameterSpec;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
import static java.lang.System.out;
import java.util.Arrays;
@@ -40,7 +40,7 @@ import java.util.Arrays;
* @summary Test for feature 'support stronger entry protection'. An entry is
* stored to keystore with different PasswordProtection objects which are
* specified by different PBE algorithms (use -Dseed=X to set PRNG seed)
- * @library /lib/testlibrary ../
+ * @library /test/lib /lib/testlibrary ../
* @key randomness
*/
public class EntryProtectionTest {
diff --git a/jdk/test/java/security/MessageDigest/TestDigestIOStream.java b/jdk/test/java/security/MessageDigest/TestDigestIOStream.java
index c94dbfbdd16..623ee0f9c8b 100644
--- a/jdk/test/java/security/MessageDigest/TestDigestIOStream.java
+++ b/jdk/test/java/security/MessageDigest/TestDigestIOStream.java
@@ -1,6 +1,5 @@
-
/*
- * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -32,7 +31,7 @@ import java.security.NoSuchAlgorithmException;
import java.security.Security;
import java.util.Arrays;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
import static java.lang.System.out;
/**
@@ -41,7 +40,7 @@ import static java.lang.System.out;
* @summary MessageDigest tests with DigestIOStream
* @author Kevin Liu
* @key randomness
- * @library /lib/testlibrary
+ * @library /test/lib
* @run main/timeout=180 TestDigestIOStream
*/
diff --git a/jdk/test/java/security/MessageDigest/TestSameLength.java b/jdk/test/java/security/MessageDigest/TestSameLength.java
index 571dd91619b..4d614b1e387 100644
--- a/jdk/test/java/security/MessageDigest/TestSameLength.java
+++ b/jdk/test/java/security/MessageDigest/TestSameLength.java
@@ -1,6 +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
@@ -27,7 +26,7 @@ import java.nio.ByteBuffer;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* @test
@@ -36,7 +35,7 @@ import jdk.testlibrary.RandomFactory;
* algorithm/dataLen/(update,digest methods).
* @author Kevin Liu
* @key randomness
- * @library /lib/testlibrary
+ * @library /test/lib
*/
public class TestSameLength {
diff --git a/jdk/test/java/security/MessageDigest/TestSameValue.java b/jdk/test/java/security/MessageDigest/TestSameValue.java
index 931cb6aa7da..dbf109e46f5 100644
--- a/jdk/test/java/security/MessageDigest/TestSameValue.java
+++ b/jdk/test/java/security/MessageDigest/TestSameValue.java
@@ -1,6 +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
@@ -28,7 +27,7 @@ import java.security.DigestException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.security.Security;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* @test
@@ -37,7 +36,7 @@ import jdk.testlibrary.RandomFactory;
* with various update/digest methods.
* @author Kevin Liu
* @key randomness
- * @library /lib/testlibrary
+ * @library /test/lib
*/
public class TestSameValue {
diff --git a/jdk/test/java/security/Signature/Offsets.java b/jdk/test/java/security/Signature/Offsets.java
index 9e71690ea4f..35a9b569acf 100644
--- a/jdk/test/java/security/Signature/Offsets.java
+++ b/jdk/test/java/security/Signature/Offsets.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
@@ -30,7 +30,7 @@ import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
import java.security.SignatureException;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/*
* @test
@@ -41,7 +41,7 @@ import jdk.testlibrary.RandomFactory;
* get random set of clear text data to sign. After the signature
* generation, the test tries to verify signature with the above API
* and passing in different signature offset (0, 33, 66, 99).
- * @library /lib/testlibrary
+ * @library /test/lib
* @run main Offsets SUN NONEwithDSA
* @run main Offsets SUN SHA1withDSA
* @run main Offsets SUN SHA224withDSA
diff --git a/jdk/test/java/util/Base64/TestBase64.java b/jdk/test/java/util/Base64/TestBase64.java
index d28f0d0f88a..b557965080e 100644
--- a/jdk/test/java/util/Base64/TestBase64.java
+++ b/jdk/test/java/util/Base64/TestBase64.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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,8 +25,7 @@
* @test 4235519 8004212 8005394 8007298 8006295 8006315 8006530 8007379 8008925
* 8014217 8025003 8026330 8028397 8129544 8165243
* @summary tests java.util.Base64
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main TestBase64
* @key randomness
*/
@@ -43,7 +42,7 @@ import java.util.Base64;
import java.util.List;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class TestBase64 {
diff --git a/jdk/test/java/util/List/SubList.java b/jdk/test/java/util/List/SubList.java
index 8d82dbfeaaa..29610fa33f5 100644
--- a/jdk/test/java/util/List/SubList.java
+++ b/jdk/test/java/util/List/SubList.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
@@ -24,8 +24,7 @@
/*
* @test
* @bug 8079136
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run testng SubList
* @summary Basic functionality of sublists
* @key randomness
@@ -46,7 +45,7 @@ import java.util.Vector;
import org.testng.annotations.Test;
import org.testng.annotations.DataProvider;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class SubList extends org.testng.Assert {
diff --git a/jdk/test/java/util/WeakHashMap/GCDuringIteration.java b/jdk/test/java/util/WeakHashMap/GCDuringIteration.java
index 029b51e5cbf..8c6c4eacda5 100644
--- a/jdk/test/java/util/WeakHashMap/GCDuringIteration.java
+++ b/jdk/test/java/util/WeakHashMap/GCDuringIteration.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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 6499848
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
* @run main GCDuringIteration
* @summary Check that iterators work properly in the presence of
* concurrent finalization and removal of elements.
@@ -43,7 +42,7 @@ import java.util.Random;
import java.util.WeakHashMap;
import java.util.concurrent.CountDownLatch;
import java.util.function.BooleanSupplier;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class GCDuringIteration {
diff --git a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
index 7457e6cc252..9b52728e56a 100644
--- a/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
+++ b/jdk/test/java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 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,8 +25,7 @@
* @test
* @bug 6450200
* @summary Test proper handling of pool state changes
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.RandomFactory
+ * @library /test/lib
* @run main/othervm ConfigChanges
* @key randomness
* @author Martin Buchholz
@@ -45,7 +44,7 @@ import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.function.Supplier;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class ConfigChanges {
static final ThreadGroup tg = new ThreadGroup("pool");
diff --git a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java
index f0b35d06a94..149cc66c74c 100644
--- a/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.java
+++ b/jdk/test/java/util/jar/JarFile/mrjar/MultiReleaseJarAPI.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,9 +26,8 @@
* @bug 8132734 8144062 8165723
* @summary Test the extended API and the aliasing additions in JarFile that
* support multi-release jar files
- * @library /lib/testlibrary/java/util/jar /lib/testlibrary/
+ * @library /lib/testlibrary/java/util/jar /test/lib
* @build Compiler JarBuilder CreateMultiReleaseTestJars
- * @build jdk.testlibrary.RandomFactory
* @run testng MultiReleaseJarAPI
*/
@@ -45,7 +44,7 @@ import java.util.jar.JarFile;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
diff --git a/jdk/test/java/util/regex/RegExTest.java b/jdk/test/java/util/regex/RegExTest.java
index d60c1caaf3d..724052e900d 100644
--- a/jdk/test/java/util/regex/RegExTest.java
+++ b/jdk/test/java/util/regex/RegExTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2015, 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
@@ -37,8 +37,7 @@
* 6328855 6192895 6345469 6988218 6693451 7006761 8140212 8143282 8158482
* 8176029
*
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main RegExTest
* @key randomness
*/
@@ -52,7 +51,7 @@ import java.nio.file.*;
import java.util.*;
import java.nio.CharBuffer;
import java.util.function.Predicate;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* This is a test class created to check the operation of
diff --git a/jdk/test/java/util/zip/InflaterInputStream/TestAvailable.java b/jdk/test/java/util/zip/InflaterInputStream/TestAvailable.java
index 1a8f3ba71e2..0234016bbe1 100644
--- a/jdk/test/java/util/zip/InflaterInputStream/TestAvailable.java
+++ b/jdk/test/java/util/zip/InflaterInputStream/TestAvailable.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
@@ -22,8 +22,7 @@
*/
/* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main TestAvailable
* @bug 7031075 8161426
* @summary Make sure that available() method behaves as expected.
@@ -33,7 +32,7 @@
import java.io.*;
import java.util.Random;
import java.util.zip.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class TestAvailable {
diff --git a/jdk/test/javax/imageio/plugins/tiff/MultiPageTest/MultiPageTest.java b/jdk/test/javax/imageio/plugins/tiff/MultiPageTest/MultiPageTest.java
index 823b9ea1bc4..3b722971385 100644
--- a/jdk/test/javax/imageio/plugins/tiff/MultiPageTest/MultiPageTest.java
+++ b/jdk/test/javax/imageio/plugins/tiff/MultiPageTest/MultiPageTest.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
@@ -23,8 +23,7 @@
/**
* @test
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
*
* @bug 8145776
* @author a.stepanov
@@ -47,7 +46,7 @@ import java.util.*;
import javax.imageio.*;
import javax.imageio.stream.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class MultiPageTest {
diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java
index c19e58a73b6..cf31ffd3122 100644
--- a/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.java
+++ b/jdk/test/javax/net/ssl/DTLS/DTLSIncorrectAppDataTest.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 @@
* @bug 8043758
* @summary Testing DTLS incorrect app data packages unwrapping.
* @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.krb5:+open
@@ -49,7 +49,7 @@ import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;
import javax.net.ssl.SSLException;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* Testing DTLS incorrect app data packages unwrapping. Incorrect application
diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java
index bfe5b7e9b2c..de31945ab54 100644
--- a/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.java
+++ b/jdk/test/javax/net/ssl/DTLS/DTLSRehandshakeWithCipherChangeTest.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
@@ -27,7 +27,7 @@
* @summary Testing DTLS engines re-handshaking with cipher change. New cipher
* is taken randomly from the supporetd ciphers list.
* @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
* @modules java.security.jgss
* java.security.jgss/sun.security.krb5:+open
* java.security.jgss/sun.security.krb5.internal:+open
diff --git a/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java b/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java
index 1475f8b8f05..82f7df7d5d8 100644
--- a/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.java
+++ b/jdk/test/javax/net/ssl/DTLS/DTLSSequenceNumberTest.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
@@ -27,7 +27,7 @@
* @summary Testing DTLS records sequence number property support in application
* data exchange.
* @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.krb5:+open
@@ -51,7 +51,7 @@ import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;
import javax.net.ssl.SSLException;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* Testing DTLS records sequence number property support in application data
diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java
index baec575c1cc..f15badec323 100644
--- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.java
+++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10IncorrectAppDataTest.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 @@
* @bug 8043758
* @summary Testing DTLS incorrect app data packages unwrapping.
* @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon /javax/net/ssl/DTLS
* @modules java.security.jgss
* jdk.security.auth
* java.security.jgss/sun.security.krb5:+open
diff --git a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java
index f69afe69057..98fb334a4ff 100644
--- a/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.java
+++ b/jdk/test/javax/net/ssl/DTLSv10/DTLSv10RehandshakeWithCipherChangeTest.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
@@ -27,7 +27,7 @@
* @summary Testing DTLS engines re-handshaking with cipher change. New cipher
* is taken randomly from the supporetd ciphers list.
* @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
* @modules java.security.jgss
* java.security.jgss/sun.security.krb5:+open
* java.security.jgss/sun.security.krb5.internal:+open
diff --git a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java
index 8221c8d1a2c..d154c27d331 100644
--- a/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.java
+++ b/jdk/test/javax/net/ssl/TLS/TLSRehandshakeWithCipherChangeTest.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
@@ -27,7 +27,7 @@
* @summary Testing TLS engines re-handshaking with cipher change. New cipher
* is taken randomly from the supporetd ciphers list.
* @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
* @modules java.security.jgss
* java.security.jgss/sun.security.krb5:+open
* java.security.jgss/sun.security.krb5.internal:+open
diff --git a/jdk/test/javax/net/ssl/TLSCommon/RehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/TLSCommon/RehandshakeWithCipherChangeTest.java
index 50e99f71a95..22b15994a33 100644
--- a/jdk/test/javax/net/ssl/TLSCommon/RehandshakeWithCipherChangeTest.java
+++ b/jdk/test/javax/net/ssl/TLSCommon/RehandshakeWithCipherChangeTest.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
@@ -26,7 +26,7 @@ import javax.net.ssl.SSLEngine;
import javax.net.ssl.SSLEngineResult;
import javax.net.ssl.SSLException;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
/**
* Testing SSLEngines re-handshaking with cipher change. New cipher is taken
diff --git a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java
index cdbc16f5c46..c7a8a8cf5ec 100644
--- a/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.java
+++ b/jdk/test/javax/net/ssl/TLSv1/TLSRehandshakeWithCipherChangeTest.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
@@ -27,7 +27,7 @@
* @summary Testing TLS engines re-handshaking with cipher change. New cipher
* is taken randomly from the supporetd ciphers list.
* @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
* @modules java.security.jgss
* java.security.jgss/sun.security.krb5:+open
* java.security.jgss/sun.security.krb5.internal:+open
diff --git a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java
index c42454a9043..d94b2e65eda 100644
--- a/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.java
+++ b/jdk/test/javax/net/ssl/TLSv11/TLSRehandshakeWithCipherChangeTest.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
@@ -27,7 +27,7 @@
* @summary Testing TLS engines re-handshaking with cipher change. New cipher
* is taken randomly from the supporetd ciphers list.
* @key randomness
- * @library /sun/security/krb5/auto /lib/testlibrary /javax/net/ssl/TLSCommon
+ * @library /sun/security/krb5/auto /test/lib /javax/net/ssl/TLSCommon
* @modules java.security.jgss
* java.security.jgss/sun.security.krb5:+open
* java.security.jgss/sun.security.krb5.internal:+open
diff --git a/jdk/test/javax/swing/ToolTipManager/7123767/bug7123767.java b/jdk/test/javax/swing/ToolTipManager/7123767/bug7123767.java
index 1db5dc50d66..3ca2a713243 100644
--- a/jdk/test/javax/swing/ToolTipManager/7123767/bug7123767.java
+++ b/jdk/test/javax/swing/ToolTipManager/7123767/bug7123767.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -38,8 +38,7 @@
* @key randomness
*
* @modules java.desktop/sun.awt
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
*
* @run main/timeout=300 bug7123767
*/
@@ -55,7 +54,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class bug7123767 extends JFrame {
diff --git a/jdk/test/lib/testlibrary/jdk/testlibrary/RandomFactory.java b/jdk/test/lib/testlibrary/jdk/testlibrary/RandomFactory.java
index 0951d11031d..4cac61c1a0c 100644
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/RandomFactory.java
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/RandomFactory.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
@@ -30,7 +30,12 @@ import java.util.SplittableRandom;
* Factory class which generates and prints to STDOUT a long-valued seed
* for use in initializing a PRNG. An instance of {@code Random} or
* {@code SplittableRandom} may likewise be obtained.
+ *
+ * @deprecated This class is deprecated. Use the one from
+ * {@code /test/lib/jdk/test/lib}
+ *
*/
+@Deprecated
public class RandomFactory {
/**
* Attempt to obtain the seed from the value of the "seed" property.
diff --git a/jdk/test/sun/nio/cs/FindDecoderBugs.java b/jdk/test/sun/nio/cs/FindDecoderBugs.java
index f21d7c0de2f..6868ce297ec 100644
--- a/jdk/test/sun/nio/cs/FindDecoderBugs.java
+++ b/jdk/test/sun/nio/cs/FindDecoderBugs.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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,8 +25,7 @@
* @test
* @bug 6380723
* @summary Decode many byte sequences in many ways (use -Dseed=X to set PRNG seed)
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main/timeout=1800 FindDecoderBugs
* @author Martin Buchholz
* @key randomness
@@ -36,7 +35,7 @@ import java.util.*;
import java.util.regex.*;
import java.nio.*;
import java.nio.charset.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class FindDecoderBugs {
diff --git a/jdk/test/sun/nio/cs/FindEncoderBugs.java b/jdk/test/sun/nio/cs/FindEncoderBugs.java
index 78ef3029522..091686593f1 100644
--- a/jdk/test/sun/nio/cs/FindEncoderBugs.java
+++ b/jdk/test/sun/nio/cs/FindEncoderBugs.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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,8 +25,7 @@
* @test
* @bug 6233345 6381699 6381702 6381705 6381706
* @summary Encode many char sequences in many ways
- * @library /lib/testlibrary/
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @run main/timeout=1200 FindEncoderBugs
* @author Martin Buchholz
* @key randomness
@@ -36,7 +35,7 @@ import java.util.*;
import java.util.regex.*;
import java.nio.*;
import java.nio.charset.*;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class FindEncoderBugs {
diff --git a/jdk/test/sun/security/ec/SignatureOffsets.java b/jdk/test/sun/security/ec/SignatureOffsets.java
index efd931a6dcb..288ca39731e 100644
--- a/jdk/test/sun/security/ec/SignatureOffsets.java
+++ b/jdk/test/sun/security/ec/SignatureOffsets.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
@@ -34,7 +34,7 @@ import java.security.SignatureException;
* get random set of clear text data to sign. After the signature
* generation, the test tries to verify signature with the above API
* and passing in different signature offset (0, 33, 66, 99).
- * @library /lib/testlibrary
+ * @library /test/lib
* @compile ../../../java/security/Signature/Offsets.java
* @run main SignatureOffsets SunEC NONEwithECDSA
* @run main SignatureOffsets SunEC SHA1withECDSA
diff --git a/jdk/test/sun/security/mscapi/SignatureOffsets.java b/jdk/test/sun/security/mscapi/SignatureOffsets.java
index 128cc00ca04..e0d2a816fda 100644
--- a/jdk/test/sun/security/mscapi/SignatureOffsets.java
+++ b/jdk/test/sun/security/mscapi/SignatureOffsets.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
@@ -34,7 +34,7 @@ import java.security.SignatureException;
* get random set of clear text data to sign. After the signature
* generation, the test tries to verify signature with the above API
* and passing in different signature offset (0, 33, 66, 99).
- * @library /lib/testlibrary
+ * @library /test/lib
* @compile ../../../java/security/Signature/Offsets.java
* @requires os.family == "windows"
* @run main SignatureOffsets SunMSCAPI NONEwithRSA
diff --git a/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java b/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java
index 78e305e1880..9ffab3d5051 100644
--- a/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java
+++ b/jdk/test/sun/security/pkcs11/rsa/TestKeyPairGenerator.java
@@ -27,8 +27,7 @@
* @summary Verify that the RSA KeyPairGenerator works (use -Dseed=X to set PRNG seed)
* @author Andreas Sterbenz
* @library ..
- * @library /lib/testlibrary
- * @build jdk.testlibrary.*
+ * @library /test/lib
* @modules jdk.crypto.cryptoki
* @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator
* @run main/othervm -Djava.security.debug=sunpkcs11 TestKeyPairGenerator
@@ -46,7 +45,7 @@ import java.security.Signature;
import java.security.interfaces.RSAPrivateCrtKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.RSAKeyGenParameterSpec;
-import jdk.testlibrary.RandomFactory;
+import jdk.test.lib.RandomFactory;
public class TestKeyPairGenerator extends PKCS11Test {
diff --git a/jdk/test/sun/security/rsa/SignatureOffsets.java b/jdk/test/sun/security/rsa/SignatureOffsets.java
index db9dbb03698..bebaa8ba1f8 100644
--- a/jdk/test/sun/security/rsa/SignatureOffsets.java
+++ b/jdk/test/sun/security/rsa/SignatureOffsets.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
@@ -34,7 +34,7 @@ import java.security.SignatureException;
* get random set of clear text data to sign. After the signature
* generation, the test tries to verify signature with the above API
* and passing in different signature offset (0, 33, 66, 99).
- * @library /lib/testlibrary
+ * @library /test/lib
* @compile ../../../java/security/Signature/Offsets.java
* @run main SignatureOffsets SunRsaSign MD2withRSA
* @run main SignatureOffsets SunRsaSign MD5withRSA
diff --git a/jdk/test/sun/security/ssl/rsa/SignatureOffsets.java b/jdk/test/sun/security/ssl/rsa/SignatureOffsets.java
index 8b07950eee8..9b761d3a6fc 100644
--- a/jdk/test/sun/security/ssl/rsa/SignatureOffsets.java
+++ b/jdk/test/sun/security/ssl/rsa/SignatureOffsets.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
@@ -34,7 +34,7 @@ import java.security.SignatureException;
* get random set of clear text data to sign. After the signature
* generation, the test tries to verify signature with the above API
* and passing in different signature offset (0, 33, 66, 99).
- * @library /lib/testlibrary
+ * @library /test/lib
* @compile ../../../../java/security/Signature/Offsets.java
* @run main SignatureOffsets SunJSSE MD2withRSA
* @run main SignatureOffsets SunJSSE MD5withRSA
From 325d3e68d86c6df851cb0fefa63e10736f5c53c5 Mon Sep 17 00:00:00 2001
From: Amy Lu
Date: Wed, 31 May 2017 14:00:55 +0800
Subject: [PATCH 50/55] 8181126: Refactor shell test
java/nio/Buffer/LimitDirectMemory.sh to java
Reviewed-by: bchristi, psandoz, rriggs
---
.../java/nio/Buffer/LimitDirectMemory.java | 40 +++++++-
jdk/test/java/nio/Buffer/LimitDirectMemory.sh | 93 -------------------
.../Buffer/LimitDirectMemoryNegativeTest.java | 57 ++++++++++++
3 files changed, 94 insertions(+), 96 deletions(-)
delete mode 100644 jdk/test/java/nio/Buffer/LimitDirectMemory.sh
create mode 100644 jdk/test/java/nio/Buffer/LimitDirectMemoryNegativeTest.java
diff --git a/jdk/test/java/nio/Buffer/LimitDirectMemory.java b/jdk/test/java/nio/Buffer/LimitDirectMemory.java
index e8a22b4b89c..0036f5ea30b 100644
--- a/jdk/test/java/nio/Buffer/LimitDirectMemory.java
+++ b/jdk/test/java/nio/Buffer/LimitDirectMemory.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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,6 +21,35 @@
* questions.
*/
+/*
+ * @test
+ * @bug 4627316 6743526
+ * @summary Test option to limit direct memory allocation
+ * @requires (os.arch == "x86_64") | (os.arch == "amd64") | (os.arch == "sparcv9")
+ * @library /test/lib
+ *
+ * @summary Test: memory is properly limited using multiple buffers
+ * @run main/othervm -XX:MaxDirectMemorySize=10 LimitDirectMemory true 10 1
+ * @run main/othervm -XX:MaxDirectMemorySize=1k LimitDirectMemory true 1k 100
+ * @run main/othervm -XX:MaxDirectMemorySize=10m LimitDirectMemory true 10m 10m
+ *
+ * @summary Test: We can increase the amount of available memory
+ * @run main/othervm -XX:MaxDirectMemorySize=65M LimitDirectMemory false 64M 65M
+ *
+ * @summary Test: Exactly the default amount of memory is available
+ * @run main/othervm LimitDirectMemory false 10 1
+ * @run main/othervm -Xmx64m LimitDirectMemory false 0 DEFAULT
+ * @run main/othervm -Xmx64m LimitDirectMemory true 0 DEFAULT+1
+ *
+ * @summary Test: We should be able to eliminate direct memory allocation entirely
+ * @run main/othervm -XX:MaxDirectMemorySize=0 LimitDirectMemory true 0 1
+ *
+ * @summary Test: Setting the system property should not work so we should be able
+ * to allocate the default amount
+ * @run main/othervm -Dsun.nio.MaxDirectMemorySize=1K -Xmx64m
+ * LimitDirectMemory false DEFAULT-1 DEFAULT/2
+ */
+
import java.nio.ByteBuffer;
import java.util.Properties;
@@ -28,8 +57,13 @@ public class LimitDirectMemory {
private static final int K = 1024;
public static void main(String [] args) throws Exception {
- if (args.length < 2)
- throw new RuntimeException();
+ if (args.length < 2) {
+ throw new IllegalArgumentException("Usage: "
+ + "java LimitDirectMemory"
+ + " "
+ + " "
+ + " ");
+ }
boolean throwp = parseThrow(args[0]);
int size = parseSize(args[1]);
int incr = (args.length > 2 ? parseSize(args[2]) : size);
diff --git a/jdk/test/java/nio/Buffer/LimitDirectMemory.sh b/jdk/test/java/nio/Buffer/LimitDirectMemory.sh
deleted file mode 100644
index 372dc0532db..00000000000
--- a/jdk/test/java/nio/Buffer/LimitDirectMemory.sh
+++ /dev/null
@@ -1,93 +0,0 @@
-#!/bin/sh
-
-#
-# Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4627316 6743526
-# @summary Test option to limit direct memory allocation
-#
-# @requires (os.arch == "x86_64") | (os.arch == "amd64") | (os.arch == "sparcv9")
-# @build LimitDirectMemory
-# @run shell LimitDirectMemory.sh
-
-TMP1=tmp_$$
-
-runTest() {
- echo "Testing: $*"
- ${TESTJAVA}/bin/java ${TESTVMOPTS} $*
- if [ $? -eq 0 ]
- then echo "--- passed as expected"
- else
- echo "--- failed"
- exit 1
- fi
-}
-
-
-launchFail() {
- echo "Testing: -XX:MaxDirectMemorySize=$* -cp ${TESTCLASSES} \
- LimitDirectMemory true DEFAULT DEFAULT+1M"
- ${TESTJAVA}/bin/java ${TESTVMOPTS} -XX:MaxDirectMemorySize=$* -cp ${TESTCLASSES} \
- LimitDirectMemory true DEFAULT DEFAULT+1M > ${TMP1} 2>&1
- cat ${TMP1}
- cat ${TMP1} | grep -s "Unrecognized VM option: \'MaxDirectMemorySize="
- if [ $? -ne 0 ]
- then echo "--- failed as expected"
- else
- echo "--- failed"
- exit 1
- fi
-}
-
-# $java LimitDirectMemory throwp fill_direct_memory size_per_buffer
-
-# Memory is properly limited using multiple buffers.
-runTest -XX:MaxDirectMemorySize=10 -cp ${TESTCLASSES} LimitDirectMemory true 10 1
-runTest -XX:MaxDirectMemorySize=1k -cp ${TESTCLASSES} LimitDirectMemory true 1k 100
-runTest -XX:MaxDirectMemorySize=10m -cp ${TESTCLASSES} LimitDirectMemory true 10m 10m
-
-# We can increase the amount of available memory.
-runTest -XX:MaxDirectMemorySize=65M -cp ${TESTCLASSES} \
- LimitDirectMemory false 64M 65M
-
-# Exactly the default amount of memory is available.
-runTest -cp ${TESTCLASSES} LimitDirectMemory false 10 1
-runTest -Xmx64m -cp ${TESTCLASSES} LimitDirectMemory false 0 DEFAULT
-runTest -Xmx64m -cp ${TESTCLASSES} LimitDirectMemory true 0 DEFAULT+1
-
-# We should be able to eliminate direct memory allocation entirely.
-runTest -XX:MaxDirectMemorySize=0 -cp ${TESTCLASSES} LimitDirectMemory true 0 1
-
-# Setting the system property should not work so we should be able to allocate
-# the default amount.
-runTest -Dsun.nio.MaxDirectMemorySize=1K -Xmx64m -cp ${TESTCLASSES} \
- LimitDirectMemory false DEFAULT-1 DEFAULT/2
-
-# Various bad values fail to launch the VM.
-launchFail foo
-launchFail 10kmt
-launchFail -1
-
-# Clean-up
-rm ${TMP1}
diff --git a/jdk/test/java/nio/Buffer/LimitDirectMemoryNegativeTest.java b/jdk/test/java/nio/Buffer/LimitDirectMemoryNegativeTest.java
new file mode 100644
index 00000000000..136839bd539
--- /dev/null
+++ b/jdk/test/java/nio/Buffer/LimitDirectMemoryNegativeTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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 4627316 6743526
+ * @summary Test option to limit direct memory allocation,
+ * various bad values fail to launch the VM
+ * @requires (os.arch == "x86_64") | (os.arch == "amd64") | (os.arch == "sparcv9")
+ * @library /test/lib
+ *
+ * @run main LimitDirectMemoryNegativeTest foo
+ * @run main LimitDirectMemoryNegativeTest 10kmt
+ * @run main LimitDirectMemoryNegativeTest -1
+ */
+
+import jdk.test.lib.process.ProcessTools;
+
+public class LimitDirectMemoryNegativeTest {
+
+ private static final String ERR = "Improperly specified VM option 'MaxDirectMemorySize=";
+
+ public static void main(String[] args) throws Exception {
+ if (args.length != 1) {
+ throw new IllegalArgumentException("missing size argument");
+ }
+
+ int exitCode = ProcessTools.executeTestJava(
+ "-XX:MaxDirectMemorySize=" + args[0],
+ LimitDirectMemoryNegativeTest.class.getName())
+ .shouldContain(ERR + args[0])
+ .getExitValue();
+ if (exitCode != 1) {
+ throw new RuntimeException("Unexpected exit code: " + exitCode);
+ }
+ }
+}
From d0b5e2390856f95d7eec98979da9b50d612a7181 Mon Sep 17 00:00:00 2001
From: Igor Ignatyev
Date: Wed, 31 May 2017 10:41:07 -0700
Subject: [PATCH 51/55] 8181307: tests added/changed by 8166139 should be
updated to use the latest testlibrary
Reviewed-by: rriggs
---
jdk/test/java/net/URLClassLoader/closetest/CloseTest.java | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java b/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java
index c25cb3e1241..4a8b15f0b05 100644
--- a/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java
+++ b/jdk/test/java/net/URLClassLoader/closetest/CloseTest.java
@@ -29,7 +29,8 @@
* jdk.compiler
* @library ../../../../com/sun/net/httpserver
* /lib/testlibrary
- * @build FileServerHandler jdk.testlibrary.FileUtils JarUtils CompilerUtils
+ * /test/lib
+ * @build FileServerHandler JarUtils CompilerUtils
* @run main/othervm CloseTest
* @summary URL-downloaded jar files can consume all available file descriptors
*/
From 93c47c498db9ffeb087df84ed1eb50c97db374d2 Mon Sep 17 00:00:00 2001
From: Igor Ignatyev
Date: Wed, 31 May 2017 13:14:34 -0700
Subject: [PATCH 52/55] 8180898: remove JavaToolUtils testlibrary class
Reviewed-by: alanb
---
jdk/test/lib/testlibrary/JavaToolUtils.java | 209 --------------------
1 file changed, 209 deletions(-)
delete mode 100644 jdk/test/lib/testlibrary/JavaToolUtils.java
diff --git a/jdk/test/lib/testlibrary/JavaToolUtils.java b/jdk/test/lib/testlibrary/JavaToolUtils.java
deleted file mode 100644
index c9736bcf9a0..00000000000
--- a/jdk/test/lib/testlibrary/JavaToolUtils.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2014, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.file.Files;
-import java.util.List;
-import java.util.Objects;
-import java.util.concurrent.TimeUnit;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-
-/**
- * Utils class for compiling , creating jar file and executing a java command
- *
- * @author Raghu Nair
- */
-
-public class JavaToolUtils {
-
- public static final long DEFAULT_WAIT_TIME = 10000;
-
- private JavaToolUtils() {
- }
-
- /**
- * Takes a list of files and compile these files into the working directory.
- *
- * @param files
- * @throws IOException
- */
- public static void compileFiles(List files) throws IOException {
- JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
- try (StandardJavaFileManager fileManager = compiler.
- getStandardFileManager(null, null, null)) {
- Iterable extends JavaFileObject> compilationUnit
- = fileManager.getJavaFileObjectsFromFiles(files);
- compiler.getTask(null, fileManager, null, null, null,
- compilationUnit).call();
- }
- }
-
- /**
- * Create a jar file using the list of files provided.
- *
- * @param jar
- * @param files
- * @throws IOException
- */
- public static void createJar(File jar, List files)
- throws IOException {
- Manifest manifest = new Manifest();
- manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION,
- "1.0");
- try (JarOutputStream target = new JarOutputStream(
- new FileOutputStream(jar), manifest)) {
- for (File file : files) {
- add(file, target);
- }
- }
- }
-
- private static void add(File source, JarOutputStream target)
- throws IOException {
- Objects.requireNonNull(source, "source cannot be null");
- Objects.requireNonNull(target, "target cannot be null");
- // not tested against directories and from different path.
- String name = source.getName();
- if (source.isDirectory()) {
- if (!name.isEmpty()) {
- if (!name.endsWith("/")) {
- name += "/";
- }
- JarEntry entry = new JarEntry(name);
- entry.setTime(source.lastModified());
- target.putNextEntry(entry);
- target.closeEntry();
- }
- for (File nestedFile : source.listFiles()) {
- add(nestedFile, target);
- }
- return;
- }
- System.out.println("Adding entry " + name);
- JarEntry entry = new JarEntry(name);
- entry.setTime(source.lastModified());
- target.putNextEntry(entry);
- Files.copy(source.toPath(), target);
- target.closeEntry();
- }
-
- /**
- * Runs java command with provided arguments. Caller should not pass java
- * command in the argument list.
- *
- * @param commands
- * @param waitTime time to wait for the command to exit in milli seconds
- * @return
- * @throws Exception
- */
- public static int runJava(List commands,long waitTime)
- throws Exception {
- String java = System.getProperty("java.home") + "/bin/java";
- commands.add(0, java);
- String command = commands.toString().replace(",", " ");
- System.out.println("Executing the following command \n" + command);
- ProcessBuilder processBuilder = new ProcessBuilder(commands);
- final Process process = processBuilder.start();
- BufferedReader errorStream = new BufferedReader(
- new InputStreamReader(process.getErrorStream()));
- BufferedReader outStream = new BufferedReader(
- new InputStreamReader(process.getInputStream()));
- String errorLine;
- StringBuilder errors = new StringBuilder();
- String outLines;
- while ((errorLine = errorStream.readLine()) != null) {
- errors.append(errorLine).append("\n");
- }
- while ((outLines = outStream.readLine()) != null) {
- System.out.println(outLines);
- }
- errorLine = errors.toString();
- System.err.println(errorLine);
- process.waitFor(waitTime, TimeUnit.MILLISECONDS);
- int exitStatus = process.exitValue();
- if (exitStatus != 0 && errorLine != null && errorLine.isEmpty()) {
- throw new RuntimeException(errorLine);
- }
- return exitStatus;
- }
-
- /**
- * Runs java command with provided arguments. Caller should not pass java
- * command in the argument list.
- *
- * @param commands
- * @return
- * @throws Exception
- */
- public static int runJava(List commands) throws Exception {
- return runJava(commands, DEFAULT_WAIT_TIME);
- }
-
- /**
- * Run any command
- * @param commands
- * @return
- * @throws Exception
- */
- public static int runCommand(List commands) throws Exception {
- String command = commands.toString().replace(",", " ");
- System.out.println("Executing the following command \n" + command);
- ProcessBuilder processBuilder = new ProcessBuilder(commands);
- final Process process = processBuilder.start();
- BufferedReader errorStream = new BufferedReader(
- new InputStreamReader(process.getErrorStream()));
- BufferedReader outStream = new BufferedReader(
- new InputStreamReader(process.getInputStream()));
- String errorLine;
- StringBuilder errors = new StringBuilder();
- String outLines;
- while ((errorLine = errorStream.readLine()) != null) {
- errors.append(errorLine).append("\n");
- }
- while ((outLines = outStream.readLine()) != null) {
- System.out.println(outLines);
- }
- errorLine = errors.toString();
- System.err.println(errorLine);
- int exitStatus = process.exitValue();
- if (exitStatus != 0 && errorLine != null && errorLine.isEmpty()) {
- throw new RuntimeException(errorLine);
- }
- return exitStatus;
- }
-
-
-}
From 4422752a4c2a982bff99dda2826e52efd1982335 Mon Sep 17 00:00:00 2001
From: Hamlin Li
Date: Wed, 31 May 2017 20:01:33 -0700
Subject: [PATCH 53/55] 8166142: Refactor java.io.serialization shell tests to
java
Reviewed-by: rriggs
---
.../evolution/AddedExternField/run.sh | 33 -----
.../RenamePackage/RenamePackageTest.java | 107 ++++++++++++++++
.../evolution/RenamePackage/run.sh | 105 ---------------
...st.java => MaskSyntheticModifierTest.java} | 18 ++-
.../Serializable/maskSyntheticModifier/run.sh | 49 -------
.../{Test.java => PackageAccessTest.java} | 72 +++++++----
.../java/io/Serializable/packageAccess/run.sh | 54 --------
.../consTest/{Test.java => ConsTest.java} | 19 ++-
.../consTest/SetupJar.java} | 19 ++-
.../Serializable/resolveClass/consTest/run.sh | 53 --------
.../{Test.java => DeserializeButtonTest.java} | 33 +++--
.../resolveClass/deserializeButton/run.sh | 54 --------
.../serialver/classpath/ClasspathTest.java | 59 +++++++++
.../Serializable/serialver/classpath/run.sh | 64 ---------
.../nested/{Test.java => NestedTest.java} | 33 ++++-
.../io/Serializable/serialver/nested/run.sh | 64 ---------
.../io/Serializable/subclass/Allow.policy | 1 -
.../subclass/{Test.java => SubclassTest.java} | 32 +++--
jdk/test/java/io/Serializable/subclass/run.sh | 30 -----
.../SuperclassDataLossTest.java | 121 ++++++++++++++++++
.../Serializable/superclassDataLoss/Test.java | 79 ------------
.../io/Serializable/superclassDataLoss/run.sh | 56 --------
...est.java => UnnamedPackageSwitchTest.java} | 16 ++-
.../Serializable/unnamedPackageSwitch/run.sh | 49 -------
24 files changed, 461 insertions(+), 759 deletions(-)
delete mode 100644 jdk/test/java/io/Serializable/evolution/AddedExternField/run.sh
create mode 100644 jdk/test/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java
delete mode 100644 jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh
rename jdk/test/java/io/Serializable/maskSyntheticModifier/{Test.java => MaskSyntheticModifierTest.java} (71%)
delete mode 100644 jdk/test/java/io/Serializable/maskSyntheticModifier/run.sh
rename jdk/test/java/io/Serializable/packageAccess/{Test.java => PackageAccessTest.java} (55%)
delete mode 100644 jdk/test/java/io/Serializable/packageAccess/run.sh
rename jdk/test/java/io/Serializable/resolveClass/consTest/{Test.java => ConsTest.java} (76%)
rename jdk/test/java/io/Serializable/{serialver/classpath/Test.java => resolveClass/consTest/SetupJar.java} (71%)
delete mode 100644 jdk/test/java/io/Serializable/resolveClass/consTest/run.sh
rename jdk/test/java/io/Serializable/resolveClass/deserializeButton/{Test.java => DeserializeButtonTest.java} (62%)
delete mode 100644 jdk/test/java/io/Serializable/resolveClass/deserializeButton/run.sh
create mode 100644 jdk/test/java/io/Serializable/serialver/classpath/ClasspathTest.java
delete mode 100644 jdk/test/java/io/Serializable/serialver/classpath/run.sh
rename jdk/test/java/io/Serializable/serialver/nested/{Test.java => NestedTest.java} (55%)
delete mode 100644 jdk/test/java/io/Serializable/serialver/nested/run.sh
rename jdk/test/java/io/Serializable/subclass/{Test.java => SubclassTest.java} (83%)
delete mode 100644 jdk/test/java/io/Serializable/subclass/run.sh
create mode 100644 jdk/test/java/io/Serializable/superclassDataLoss/SuperclassDataLossTest.java
delete mode 100644 jdk/test/java/io/Serializable/superclassDataLoss/Test.java
delete mode 100644 jdk/test/java/io/Serializable/superclassDataLoss/run.sh
rename jdk/test/java/io/Serializable/unnamedPackageSwitch/{Test.java => UnnamedPackageSwitchTest.java} (82%)
delete mode 100644 jdk/test/java/io/Serializable/unnamedPackageSwitch/run.sh
diff --git a/jdk/test/java/io/Serializable/evolution/AddedExternField/run.sh b/jdk/test/java/io/Serializable/evolution/AddedExternField/run.sh
deleted file mode 100644
index 981f9360af9..00000000000
--- a/jdk/test/java/io/Serializable/evolution/AddedExternField/run.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-#
-# @bug 4088176
-# @summary Test reading an evolved class serialization into the original class
-
-rm *.class tmp.ser
-javac WriteAddedField.java
-java ${TESTVMOPTS} WriteAddedField
-rm *.class
-javac ReadAddedField.java
-java ${TESTVMOPTS} ReadAddedField
diff --git a/jdk/test/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java b/jdk/test/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java
new file mode 100644
index 00000000000..10456827f78
--- /dev/null
+++ b/jdk/test/java/io/Serializable/evolution/RenamePackage/RenamePackageTest.java
@@ -0,0 +1,107 @@
+/*
+ * 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 4087295 4785472
+ * @library /test/lib
+ * @build jdk.test.lib.compiler.CompilerUtils
+ * @build jdk.test.lib.process.ProcessTools
+ * @build RenamePackageTest
+ * @run main RenamePackageTest
+ * @summary Enable resolveClass() to accommodate package renaming.
+ * This fix enables one to implement a resolveClass method that maps a
+ * Serialiazable class within a serialization stream to the same class
+ * in a different package within the JVM runtime. See run shell script
+ * for instructions on how to run this test.
+ */
+
+import java.io.File;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import jdk.test.lib.compiler.CompilerUtils;
+import jdk.test.lib.process.ProcessTools;
+
+public class RenamePackageTest {
+ public static void main(String args[]) throws Exception {
+ setup();
+
+ runTestSerialDriver();
+ runInstallSerialDriver();
+
+ runInstallSerialDriver();
+ runTestSerialDriver();
+ }
+
+ private static final Path SHARE = Paths.get(System.getProperty("test.classes"), "share");
+ private static final Path OCLASSES = Paths.get(System.getProperty("test.classes"), "oclasses");
+ private static final Path NCLASSES = Paths.get(System.getProperty("test.classes"), "nclasses");
+
+ private static void setup() throws Exception {
+
+ boolean b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "extension"),
+ SHARE);
+ assertTrue(b);
+ b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "test"),
+ OCLASSES,
+ "-classpath",
+ SHARE.toString());
+ assertTrue(b);
+ b = CompilerUtils.compile(Paths.get(System.getProperty("test.src"), "install"),
+ NCLASSES,
+ "-classpath",
+ SHARE.toString());
+ assertTrue(b);
+ }
+
+ private static void runTestSerialDriver() throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
+ "-classpath",
+ SHARE.toString()
+ + File.pathSeparator
+ + OCLASSES.toString(),
+ "test.SerialDriver", "-s");
+ Process p = ProcessTools.startProcess("test SerialDriver", pb);
+ p.waitFor();
+ assertTrue(p.exitValue() == 0);
+ }
+
+ private static void runInstallSerialDriver() throws Exception {
+ ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true,
+ "-classpath",
+ SHARE.toString()
+ + File.pathSeparator
+ + NCLASSES.toString(),
+ "install.SerialDriver", "-d");
+ Process p = ProcessTools.startProcess("install SerialDriver", pb);
+ p.waitFor();
+ assertTrue(p.exitValue() == 0);
+ }
+
+ private static void assertTrue(boolean b) {
+ if (!b) {
+ throw new RuntimeException("expected true, get false");
+ }
+ }
+}
diff --git a/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh b/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh
deleted file mode 100644
index eb9f210083f..00000000000
--- a/jdk/test/java/io/Serializable/evolution/RenamePackage/run.sh
+++ /dev/null
@@ -1,105 +0,0 @@
-#
-# Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4087295 4785472
-# @summary Enable resolveClass() to accommodate package renaming.
-# This fix enables one to implement a resolveClass method that maps a
-# Serialiazable class within a serialization stream to the same class
-# in a different package within the JVM runtime. See run shell script
-# for instructions on how to run this test.
-
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
- COMPILEJAVA="${TESTJAVA}"
-fi
-
-
-OS=`uname -s`
-# Need to determine the classpath separator and filepath separator based on the
-# operating system.
-case "$OS" in
-SunOS | Linux | Darwin | AIX )
- PS=":" ;;
-Windows* | CYGWIN* )
- PS=";" ;;
-* )
- echo "Unrecognized system!"
- exit 1 ;;
-esac
-
-JAVA=${TESTJAVA}/bin/java
-JAVAC=${COMPILEJAVA}/bin/javac
-MKDIR=mkdir
-RDEL="rm -r"
-
-if [ -d ${TESTCLASSES}/oclasses ]
-then
- ${RDEL} ${TESTCLASSES}/oclasses
-fi
-if [ -d ${TESTCLASSES}/nclasses ]
-then
- ${RDEL} ${TESTCLASSES}/nclasses
-fi
-if [ -d ${TESTCLASSES}/share ]
-then
- ${RDEL} ${TESTCLASSES}/share
-fi
-if [ -f ${TESTCLASSES}/stream.ser ]
-then
- ${RDEL} ${TESTCLASSES}/stream.ser
-fi
-
-mkdir ${TESTCLASSES}/oclasses
-mkdir ${TESTCLASSES}/share
-mkdir ${TESTCLASSES}/nclasses
-
-# Build sources
-set -e
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}/share \
- ${TESTSRC}/extension/ExtendedObjectInputStream.java
-CLASSPATH=${TESTCLASSES}/share; export CLASSPATH;
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}/oclasses \
- ${TESTSRC}/test/SerialDriver.java
-CLASSPATH=${TESTCLASSES}/share; export CLASSPATH;
-${JAVAC} ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${TESTCLASSES}/nclasses \
- ${TESTSRC}/install/SerialDriver.java
-
-# Run Case 1. Map test.SerialDriver within stream to install.SerialDriver.
-CLASSPATH="${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
-${JAVA} ${TESTVMOPTS} test.SerialDriver -s
-CLASSPATH="${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
-${JAVA} ${TESTVMOPTS} install.SerialDriver -d
-rm stream.ser
-
-# Run Case 2. Map install.SerialDriver within stream to test.SerialDriver.
-CLASSPATH="${TESTCLASSES}/nclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
-${JAVA} ${TESTVMOPTS} install.SerialDriver -s
-CLASSPATH="${TESTCLASSES}/oclasses${PS}${TESTCLASSES}/share"; export CLASSPATH;
-${JAVA} ${TESTVMOPTS} test.SerialDriver -d
diff --git a/jdk/test/java/io/Serializable/maskSyntheticModifier/Test.java b/jdk/test/java/io/Serializable/maskSyntheticModifier/MaskSyntheticModifierTest.java
similarity index 71%
rename from jdk/test/java/io/Serializable/maskSyntheticModifier/Test.java
rename to jdk/test/java/io/Serializable/maskSyntheticModifier/MaskSyntheticModifierTest.java
index 23e445a441e..08ee9cd6238 100644
--- a/jdk/test/java/io/Serializable/maskSyntheticModifier/Test.java
+++ b/jdk/test/java/io/Serializable/maskSyntheticModifier/MaskSyntheticModifierTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -22,19 +22,31 @@
*/
/*
+ * @test
* @bug 4897937
+ * @run main MaskSyntheticModifierTest
* @summary Verify that the presence of the JVM_ACC_SYNTHETIC bit in the
* modifiers of fields and methods does not affect default
* serialVersionUID calculation.
*/
import java.io.ObjectStreamClass;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+
+public class MaskSyntheticModifierTest {
+ public static void main(String[] args) throws Exception {
+ setup();
-public class Test {
- public static void main(String[] args) {
long suid = ObjectStreamClass.lookup(Foo.class).getSerialVersionUID();
if (suid != 8027844768744011556L) {
throw new Error("incorrect serialVersionUID: " + suid);
}
}
+
+ private static void setup() throws Exception {
+ Files.copy(Paths.get(System.getProperty("test.src"), "Foo.class"),
+ Paths.get("Foo.class"), StandardCopyOption.REPLACE_EXISTING);
+ }
}
diff --git a/jdk/test/java/io/Serializable/maskSyntheticModifier/run.sh b/jdk/test/java/io/Serializable/maskSyntheticModifier/run.sh
deleted file mode 100644
index eb06b407b1c..00000000000
--- a/jdk/test/java/io/Serializable/maskSyntheticModifier/run.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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 4897937
-# @summary Verify that the presence of the JVM_ACC_SYNTHETIC bit in the
-# modifiers of fields and methods does not affect default
-# serialVersionUID calculation.
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
- COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
- TESTSRC="."
-fi
-
-set -ex
-cp ${TESTSRC}/Foo.class .
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
-rm -f *.class
diff --git a/jdk/test/java/io/Serializable/packageAccess/Test.java b/jdk/test/java/io/Serializable/packageAccess/PackageAccessTest.java
similarity index 55%
rename from jdk/test/java/io/Serializable/packageAccess/Test.java
rename to jdk/test/java/io/Serializable/packageAccess/PackageAccessTest.java
index 464ccb93504..d53cb3485a8 100644
--- a/jdk/test/java/io/Serializable/packageAccess/Test.java
+++ b/jdk/test/java/io/Serializable/packageAccess/PackageAccessTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -22,41 +22,59 @@
*/
/*
+ * @test
* @bug 4765255
+ * @library /lib/testlibrary
+ * @build JarUtils A B C D PackageAccessTest
+ * @run main PackageAccessTest
* @summary Verify proper functioning of package equality checks used to
* determine accessibility of superclass constructor and inherited
* writeReplace/readResolve methods.
*/
-import java.io.*;
-import java.net.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.io.InvalidClassException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
-public class Test {
+public class PackageAccessTest {
static Class bcl;
static Class dcl;
public static void main(String[] args) throws Exception {
- ClassLoader ldr =
+ setup();
+
+ try (URLClassLoader ldr =
new URLClassLoader(new URL[]{ new URL("file:foo.jar") },
- Test.class.getClassLoader());
- bcl = Class.forName("B", true, ldr);
- dcl = Class.forName("D", true, ldr);
+ PackageAccessTest.class.getClassLoader())) {
+ bcl = Class.forName("B", true, ldr);
+ dcl = Class.forName("D", true, ldr);
- Object b = bcl.newInstance();
- try {
- swizzle(b);
- throw new Error("expected InvalidClassException for class B");
- } catch (InvalidClassException e) {
- System.out.println("caught " + e);
- e.printStackTrace();
- }
- if (A.packagePrivateConstructorInvoked) {
- throw new Error("package private constructor of A invoked");
- }
+ Object b = bcl.newInstance();
+ try {
+ swizzle(b);
+ throw new Error("expected InvalidClassException for class B");
+ } catch (InvalidClassException e) {
+ System.out.println("caught " + e);
+ e.printStackTrace();
+ }
+ if (A.packagePrivateConstructorInvoked) {
+ throw new Error("package private constructor of A invoked");
+ }
- Object d = dcl.newInstance();
- swizzle(d);
+ Object d = dcl.newInstance();
+ swizzle(d);
+ }
}
static void swizzle(Object obj) throws Exception {
@@ -68,6 +86,14 @@ public class Test {
new ByteArrayInputStream(bout.toByteArray());
new TestObjectInputStream(bin).readObject();
}
+
+ static void setup() throws Exception {
+ Path classes = Paths.get(System.getProperty("test.classes", ""));
+ JarUtils.createJarFile(Paths.get("foo.jar"), classes,
+ classes.resolve("B.class"), classes.resolve("D.class"));
+ Files.delete(classes.resolve("B.class"));
+ Files.delete(classes.resolve("D.class"));
+ }
}
class TestObjectInputStream extends ObjectInputStream {
@@ -80,9 +106,9 @@ class TestObjectInputStream extends ObjectInputStream {
{
String n = desc.getName();
if (n.equals("B")) {
- return Test.bcl;
+ return PackageAccessTest.bcl;
} else if (n.equals("D")) {
- return Test.dcl;
+ return PackageAccessTest.dcl;
} else {
return super.resolveClass(desc);
}
diff --git a/jdk/test/java/io/Serializable/packageAccess/run.sh b/jdk/test/java/io/Serializable/packageAccess/run.sh
deleted file mode 100644
index 29e9267abcc..00000000000
--- a/jdk/test/java/io/Serializable/packageAccess/run.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4765255
-# @summary Verify proper functioning of package equality checks used to
-# determine accessibility of superclass constructor and inherited
-# writeReplace/readResolve methods.
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
- COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
- TESTSRC="."
-fi
-
-set -ex
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
- ${TESTSRC}/A.java ${TESTSRC}/B.java ${TESTSRC}/C.java ${TESTSRC}/D.java \
- ${TESTSRC}/Test.java
-${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf foo.jar B.class D.class
-rm -f B.class D.class
-
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
-rm -f *.class *.jar
diff --git a/jdk/test/java/io/Serializable/resolveClass/consTest/Test.java b/jdk/test/java/io/Serializable/resolveClass/consTest/ConsTest.java
similarity index 76%
rename from jdk/test/java/io/Serializable/resolveClass/consTest/Test.java
rename to jdk/test/java/io/Serializable/resolveClass/consTest/ConsTest.java
index 1bd03ece763..3cabfdd5014 100644
--- a/jdk/test/java/io/Serializable/resolveClass/consTest/Test.java
+++ b/jdk/test/java/io/Serializable/resolveClass/consTest/ConsTest.java
@@ -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
@@ -22,21 +22,30 @@
*/
/*
+ * @test
* @bug 4413434
+ * @library /lib/testlibrary
+ * @build JarUtils SetupJar Boot
+ * @run driver SetupJar
+ * @run main/othervm -Xbootclasspath/a:boot.jar ConsTest
* @summary Verify that generated java.lang.reflect implementation classes do
* not interfere with serialization's class resolution mechanism.
*/
-import java.io.*;
-import java.lang.reflect.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.lang.reflect.Constructor;
-public class Test implements Serializable {
+public class ConsTest implements Serializable {
public static void main(String[] args) throws Exception {
Constructor cons = Boot.class.getConstructor(
new Class[] { ObjectInputStream.class });
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(bout);
- oout.writeObject(new Test());
+ oout.writeObject(new ConsTest());
oout.close();
for (int i = 0; i < 100; i++) {
diff --git a/jdk/test/java/io/Serializable/serialver/classpath/Test.java b/jdk/test/java/io/Serializable/resolveClass/consTest/SetupJar.java
similarity index 71%
rename from jdk/test/java/io/Serializable/serialver/classpath/Test.java
rename to jdk/test/java/io/Serializable/resolveClass/consTest/SetupJar.java
index 3568a59d52b..f741a61af3b 100644
--- a/jdk/test/java/io/Serializable/serialver/classpath/Test.java
+++ b/jdk/test/java/io/Serializable/resolveClass/consTest/SetupJar.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -21,15 +21,14 @@
* questions.
*/
-/*
- *
- * @bug 4035147
- * @sumary Simple java class for test purposes
- */
+import java.nio.file.Path;
+import java.nio.file.Paths;
-package serialver;
+public class SetupJar {
-public class Test implements java.io.Serializable{
- int a;
- int b;
+ public static void main(String args[]) throws Exception {
+ Path classes = Paths.get(System.getProperty("test.classes", ""));
+ JarUtils.createJarFile(Paths.get("boot.jar"), classes,
+ classes.resolve("Boot.class"));
+ }
}
diff --git a/jdk/test/java/io/Serializable/resolveClass/consTest/run.sh b/jdk/test/java/io/Serializable/resolveClass/consTest/run.sh
deleted file mode 100644
index 5dfa01e31e8..00000000000
--- a/jdk/test/java/io/Serializable/resolveClass/consTest/run.sh
+++ /dev/null
@@ -1,53 +0,0 @@
-#
-# Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4413434
-# @summary Verify that generated java.lang.reflect implementation classes do
-# not interfere with serialization's class resolution mechanism.
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
- COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
- TESTSRC="."
-fi
-
-set -ex
-
-rm -f *.class *.jar
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Boot.java
-${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf boot.jar *.class
-rm -f *.class
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -classpath boot.jar -d . \
- ${TESTSRC}/Test.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} -Xbootclasspath/a:boot.jar Test
-rm -f *.class *.jar
diff --git a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/Test.java b/jdk/test/java/io/Serializable/resolveClass/deserializeButton/DeserializeButtonTest.java
similarity index 62%
rename from jdk/test/java/io/Serializable/resolveClass/deserializeButton/Test.java
rename to jdk/test/java/io/Serializable/resolveClass/deserializeButton/DeserializeButtonTest.java
index 7f973b2213d..31f6b12f8b0 100644
--- a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/Test.java
+++ b/jdk/test/java/io/Serializable/resolveClass/deserializeButton/DeserializeButtonTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2001, 2012, 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
@@ -22,21 +22,38 @@
*/
/*
+ * @test
* @bug 4413434
+ * @library /lib/testlibrary
+ * @build JarUtils Foo
+ * @run main DeserializeButtonTest
* @summary Verify that class loaded outside of application class loader is
* correctly resolved during deserialization when read in by custom
* readObject() method of a bootstrap class (in this case,
* java.util.Vector).
*/
-import java.io.*;
-import java.net.*;
+import java.net.URLClassLoader;
+import java.net.URL;
+import java.nio.file.Path;
+import java.nio.file.Paths;
-public class Test {
+public class DeserializeButtonTest {
public static void main(String[] args) throws Exception {
- ClassLoader ldr =
- new URLClassLoader(new URL[]{ new URL("file:cb.jar") });
- Runnable r = (Runnable) Class.forName("Foo", true, ldr).newInstance();
- r.run();
+ setup();
+
+ try (URLClassLoader ldr =
+ new URLClassLoader(new URL[]{ new URL("file:cb.jar") })) {
+ Runnable r = (Runnable) Class.forName("Foo", true, ldr).newInstance();
+ r.run();
+ }
+ }
+
+ private static void setup() throws Exception {
+ Path classes = Paths.get(System.getProperty("test.classes", ""));
+ JarUtils.createJarFile(Paths.get("cb.jar"),
+ classes,
+ classes.resolve("Foo.class"),
+ classes.resolve("Foo$TestElement.class"));
}
}
diff --git a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/run.sh b/jdk/test/java/io/Serializable/resolveClass/deserializeButton/run.sh
deleted file mode 100644
index 40b3da0e028..00000000000
--- a/jdk/test/java/io/Serializable/resolveClass/deserializeButton/run.sh
+++ /dev/null
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4413434
-# @summary Verify that class loaded outside of application class loader is
-# correctly resolved during deserialization when read in by custom
-# readObject() method of a bootstrap class (in this case,
-# java.util.Vector).
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
- COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
- TESTSRC="."
-fi
-
-set -ex
-
-rm -f *.class *.jar
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Foo.java
-${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf cb.jar *.class
-rm -f *.class
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/Test.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
-rm -f *.class *.jar
diff --git a/jdk/test/java/io/Serializable/serialver/classpath/ClasspathTest.java b/jdk/test/java/io/Serializable/serialver/classpath/ClasspathTest.java
new file mode 100644
index 00000000000..b4cb6085321
--- /dev/null
+++ b/jdk/test/java/io/Serializable/serialver/classpath/ClasspathTest.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2000, 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 4035147 4785472
+ * @library /test/lib
+ * @build jdk.test.lib.JDKToolLauncher
+ * @build jdk.test.lib.process.ProcessTools
+ * @build ClasspathTest
+ * @run main serialver.ClasspathTest
+ * @summary Test the use of the -classpath switch in the serialver application.
+ */
+
+package serialver;
+
+import java.io.File;
+
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.process.ProcessTools;
+
+public class ClasspathTest implements java.io.Serializable {
+ int a;
+ int b;
+
+ public static void main(String args[]) throws Exception {
+ JDKToolLauncher serialver =
+ JDKToolLauncher.create("serialver")
+ .addToolArg("-classpath")
+ .addToolArg(System.getProperty("test.class.path"))
+ .addToolArg("serialver.ClasspathTest");
+ Process p = ProcessTools.startProcess("serialver",
+ new ProcessBuilder(serialver.getCommand()));
+ p.waitFor();
+ if (p.exitValue() != 0) {
+ throw new RuntimeException("error occurs in serialver");
+ }
+ }
+}
diff --git a/jdk/test/java/io/Serializable/serialver/classpath/run.sh b/jdk/test/java/io/Serializable/serialver/classpath/run.sh
deleted file mode 100644
index 2aa1b0e92ea..00000000000
--- a/jdk/test/java/io/Serializable/serialver/classpath/run.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#
-# Copyright (c) 2000, 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 4035147 4785472
-# @summary Test the use of the -classpath switch in the serialver application.
-# @author Naveen Sanjeeva
-#
-# @build Test
-# @run shell run.sh
-
-# set a few environment variables so that the shell-script can run stand-alone
-# in the source directory
-
-if [ "${TESTSRC}" = "" ] ; then
- TESTSRC="."
-fi
-if [ "${TESTCLASSES}" = "" ] ; then
- TESTCLASSES="."
-fi
-if [ "${TESTJAVA}" = "" ] ; then
- echo "TESTJAVA not set. Test cannot execute."
- echo "FAILED!!!"
- exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | AIX )
- PS=":" ;;
- Windows* | CYGWIN* )
- PS=";" ;;
- * )
- echo "Unrecognized system!"
- exit 1 ;;
-esac
-
-# the test code
-
-echo "Using the classpath .${PS}${TESTCLASSES}"
-${TESTJAVA}/bin/serialver -classpath ".${PS}${TESTCLASSES}" serialver.Test
-
-exit $?
diff --git a/jdk/test/java/io/Serializable/serialver/nested/Test.java b/jdk/test/java/io/Serializable/serialver/nested/NestedTest.java
similarity index 55%
rename from jdk/test/java/io/Serializable/serialver/nested/Test.java
rename to jdk/test/java/io/Serializable/serialver/nested/NestedTest.java
index 6136ae9cc61..160a931d9da 100644
--- a/jdk/test/java/io/Serializable/serialver/nested/Test.java
+++ b/jdk/test/java/io/Serializable/serialver/nested/NestedTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -22,19 +22,42 @@
*/
/*
- *
- * @bug 4312217
+ * @test
+ * @bug 4312217 4785473
+ * @library /test/lib
+ * @build jdk.test.lib.JDKToolLauncher
+ * @build jdk.test.lib.process.ProcessTools
+ * @build NestedTest
+ * @run main serialver.NestedTest
* @summary To test the use of nested class specification using the '.'
* notation instead of the '$' notation.
*/
+
package serialver;
-import java.io.*;
+import java.io.Serializable;
-public class Test implements Serializable {
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.process.ProcessTools;
+
+public class NestedTest implements Serializable {
public static class Test1 implements Serializable {
public static class Test2 implements Serializable{
private static final long serialVersionUID = 100L;
}
}
+
+ public static void main(String args[]) throws Exception {
+ JDKToolLauncher serialver =
+ JDKToolLauncher.create("serialver")
+ .addToolArg("-classpath")
+ .addToolArg(System.getProperty("test.class.path"))
+ .addToolArg("serialver.NestedTest.Test1.Test2");
+ Process p = ProcessTools.startProcess("serialver",
+ new ProcessBuilder(serialver.getCommand()));
+ p.waitFor();
+ if (p.exitValue() != 0) {
+ throw new RuntimeException("error occurs in serialver.");
+ }
+ }
}
diff --git a/jdk/test/java/io/Serializable/serialver/nested/run.sh b/jdk/test/java/io/Serializable/serialver/nested/run.sh
deleted file mode 100644
index 578e74afc51..00000000000
--- a/jdk/test/java/io/Serializable/serialver/nested/run.sh
+++ /dev/null
@@ -1,64 +0,0 @@
-#
-# Copyright (c) 2000, 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 4312217 4785473
-# @summary Test the use of the -classpath switch in the serialver application.
-# @author Naveen Sanjeeva
-#
-# @build Test
-# @run shell run.sh
-
-# set a few environment variables so that the shell-script can run stand-alone
-# in the source directory
-
-if [ "${TESTSRC}" = "" ] ; then
- TESTSRC="."
-fi
-if [ "${TESTCLASSES}" = "" ] ; then
- TESTCLASSES="."
-fi
-if [ "${TESTJAVA}" = "" ] ; then
- echo "TESTJAVA not set. Test cannot execute."
- echo "FAILED!!!"
- exit 1
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | Darwin | AIX )
- PS=":" ;;
- Windows* | CYGWIN* )
- PS=";" ;;
- * )
- echo "Unrecognized system!"
- exit 1 ;;
-esac
-
-# the test code
-
-echo "Using the classpath .${PS}${TESTCLASSES}"
-${TESTJAVA}/bin/serialver -classpath ".${PS}${TESTCLASSES}" 'serialver.Test.Test1.Test2'
-
-exit $?
diff --git a/jdk/test/java/io/Serializable/subclass/Allow.policy b/jdk/test/java/io/Serializable/subclass/Allow.policy
index 234de2c9d37..a31cebf4926 100644
--- a/jdk/test/java/io/Serializable/subclass/Allow.policy
+++ b/jdk/test/java/io/Serializable/subclass/Allow.policy
@@ -2,7 +2,6 @@ grant {
// "standard" properies that can be read by anyone
permission java.io.FilePermission "-","read,write,execute";
permission java.io.SerializablePermission "enableSubstitution";
- permission java.io.SerializablePermission "enableSubclassImplementation";
// Needed to get access to private writeObjectMethod and
// to be able to call it.
diff --git a/jdk/test/java/io/Serializable/subclass/Test.java b/jdk/test/java/io/Serializable/subclass/SubclassTest.java
similarity index 83%
rename from jdk/test/java/io/Serializable/subclass/Test.java
rename to jdk/test/java/io/Serializable/subclass/SubclassTest.java
index bc72741cba1..916e1d4295c 100644
--- a/jdk/test/java/io/Serializable/subclass/Test.java
+++ b/jdk/test/java/io/Serializable/subclass/SubclassTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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,23 +26,32 @@
* @bug 4100915
* @summary Verify that [write/read]ObjectOverride methods get called.
* Test verifies that ALL methods to write an object can
- * be overridden. Howver, the testing for reading an object
+ * be overridden. However, the testing for reading an object
* is incomplete. Only test that readObjectOverride is called.
* An entire protocol would need to be implemented and written
* out before being able to test the input side of the API.
*
* Also, would be appropriate that this program verify
- * that if SerializablePermission "enableSubclassImplamentation"
+ * that if SerializablePermission "enableSubclassImplementation"
* is not in the security policy and security is enabled, that
- * a security excepiton is thrown when constructing the
+ * a security exception is thrown when constructing the
* ObjectOutputStream subclass.
*
*
- * @compile AbstractObjectInputStream.java AbstractObjectOutputStream.java XObjectInputStream.java XObjectOutputStream.java Test.java
- * @run main Test
+ * @compile AbstractObjectInputStream.java AbstractObjectOutputStream.java
+ * @compile XObjectInputStream.java XObjectOutputStream.java
+ * @compile SubclassTest.java
+ * @run main SubclassTest
+ * @run main/othervm/policy=Allow.policy SubclassTest -expectSecurityException
*/
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamField;
+import java.io.Serializable;
/**
* Test if customized readObject and writeObject are called.
@@ -111,7 +120,7 @@ class A implements Serializable {
}
};
-public class Test {
+public class SubclassTest {
public static void main(String argv[])
throws IOException, ClassNotFoundException
{
@@ -129,10 +138,11 @@ public class Test {
throw new Error("Assertion failure. " +
"Expected a security exception on previous line.");
} catch (SecurityException e) {
- if (expectSecurityException)
+ if (expectSecurityException) {
+ System.err.println("Caught expected security exception.");
return;
- else
- throw e;
+ }
+ throw e;
}
os.writeObject(new A());
os.close();
diff --git a/jdk/test/java/io/Serializable/subclass/run.sh b/jdk/test/java/io/Serializable/subclass/run.sh
deleted file mode 100644
index 8990d50f19b..00000000000
--- a/jdk/test/java/io/Serializable/subclass/run.sh
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-#
-# @bug 4100915
-mkdir classes
-javac -d classes *.java
-java ${TESTVMOPTS} -classpath classes -Djava.policy=Allow.policy Test
-# ENABLE next line when new method for invoking a main with a SecureClassLoader is known
-#java -classpath classes -Djava.policy=NotAllow.policy Test -expectSecurityException
diff --git a/jdk/test/java/io/Serializable/superclassDataLoss/SuperclassDataLossTest.java b/jdk/test/java/io/Serializable/superclassDataLoss/SuperclassDataLossTest.java
new file mode 100644
index 00000000000..c1674d1a0de
--- /dev/null
+++ b/jdk/test/java/io/Serializable/superclassDataLoss/SuperclassDataLossTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2000, 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 4325590
+ * @library /lib/testlibrary
+ * @build JarUtils A B
+ * @run main SuperclassDataLossTest
+ * @summary Verify that superclass data is not lost when incoming superclass
+ * descriptor is matched with local class that is not a superclass of
+ * the deserialized instance's class.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.ObjectStreamClass;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.net.MalformedURLException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+
+class MixedSuperclassStream extends ObjectInputStream {
+ private boolean ldr12A;
+ private URLClassLoader ldr1;
+ private URLClassLoader ldr2;
+
+ MixedSuperclassStream(InputStream in, URLClassLoader ldr1,
+ URLClassLoader ldr2, boolean ldr1First) throws IOException {
+ super(in);
+ this.ldr1 = ldr1;
+ this.ldr2 = ldr2;
+ this.ldr12A = ldr12A;
+ }
+
+ protected Class resolveClass(ObjectStreamClass desc)
+ throws IOException, ClassNotFoundException
+ {
+ // resolve A's classdesc to class != B's superclass
+ String name = desc.getName();
+ if (ldr12A) {
+ if (name.equals("A")) {
+ return Class.forName(name, true, ldr1);
+ } else if (name.equals("B")) {
+ return Class.forName(name, true, ldr2);
+ }
+ } else {
+ if (name.equals("B")) {
+ return Class.forName(name, true, ldr1);
+ } else if (name.equals("A")) {
+ return Class.forName(name, true, ldr2);
+ }
+ }
+ return super.resolveClass(desc);
+ }
+}
+
+public class SuperclassDataLossTest {
+
+ public static void main(String[] args) throws Exception {
+ try (URLClassLoader ldr1 = new URLClassLoader(new URL[] { new URL("file:cb1.jar") });
+ URLClassLoader ldr2 = new URLClassLoader(new URL[] { new URL("file:cb2.jar") })) {
+ setup();
+
+ Runnable a = (Runnable) Class.forName("B", true, ldr1).newInstance();
+ a.run();
+
+ ByteArrayOutputStream bout = new ByteArrayOutputStream();
+ ObjectOutputStream oout = new ObjectOutputStream(bout);
+ oout.writeObject(a);
+ oout.close();
+
+ test(bout, ldr1, ldr2, true);
+ test(bout, ldr1, ldr2, false);
+ }
+ }
+
+ private static void test(ByteArrayOutputStream bout, URLClassLoader ldr1,
+ URLClassLoader ldr2, boolean ldr12A) throws Exception {
+ ByteArrayInputStream bin =
+ new ByteArrayInputStream(bout.toByteArray());
+ ObjectInputStream oin = new MixedSuperclassStream(bin, ldr1, ldr2, ldr12A);
+ Runnable a = (Runnable) oin.readObject();
+ a.run();
+ }
+
+ private static void setup() throws Exception {
+ Path classes = Paths.get(System.getProperty("test.classes", ""));
+ JarUtils.createJarFile(Paths.get("cb1.jar"), classes,
+ classes.resolve("A.class"), classes.resolve("B.class"));
+ Files.copy(Paths.get("cb1.jar"), Paths.get("cb2.jar"),
+ StandardCopyOption.REPLACE_EXISTING);
+ }
+}
diff --git a/jdk/test/java/io/Serializable/superclassDataLoss/Test.java b/jdk/test/java/io/Serializable/superclassDataLoss/Test.java
deleted file mode 100644
index 49db5f8ae27..00000000000
--- a/jdk/test/java/io/Serializable/superclassDataLoss/Test.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @bug 4325590
- * @summary Verify that superclass data is not lost when incoming superclass
- * descriptor is matched with local class that is not a superclass of
- * the deserialized instance's class.
- */
-
-import java.io.*;
-import java.net.*;
-
-class MixedSuperclassStream extends ObjectInputStream {
- MixedSuperclassStream(InputStream in) throws IOException { super(in); }
-
- protected Class resolveClass(ObjectStreamClass desc)
- throws IOException, ClassNotFoundException
- {
- // resolve A's classdesc to class != B's superclass
- String name = desc.getName();
- if (name.equals("A")) {
- return Class.forName(name, true, Test.ldr1);
- } else if (name.equals("B")) {
- return Class.forName(name, true, Test.ldr2);
- } else {
- return super.resolveClass(desc);
- }
- }
-}
-
-public class Test {
-
- static URLClassLoader ldr1, ldr2;
- static {
- try {
- ldr1 = new URLClassLoader(new URL[] { new URL("file:cb1.jar") });
- ldr2 = new URLClassLoader(new URL[] { new URL("file:cb2.jar") });
- } catch (MalformedURLException ex) {
- throw new Error();
- }
- }
-
- public static void main(String[] args) throws Exception {
- Runnable a = (Runnable) Class.forName("B", true, ldr1).newInstance();
- a.run();
-
- ByteArrayOutputStream bout = new ByteArrayOutputStream();
- ObjectOutputStream oout = new ObjectOutputStream(bout);
- oout.writeObject(a);
- oout.close();
-
- ByteArrayInputStream bin =
- new ByteArrayInputStream(bout.toByteArray());
- ObjectInputStream oin = new MixedSuperclassStream(bin);
- a = (Runnable) oin.readObject();
- a.run();
- }
-}
diff --git a/jdk/test/java/io/Serializable/superclassDataLoss/run.sh b/jdk/test/java/io/Serializable/superclassDataLoss/run.sh
deleted file mode 100644
index 7550cd2c3cb..00000000000
--- a/jdk/test/java/io/Serializable/superclassDataLoss/run.sh
+++ /dev/null
@@ -1,56 +0,0 @@
-#
-# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4325590
-# @summary Verify that superclass data is not lost when incoming superclass
-# descriptor is matched with local class that is not a superclass of
-# the deserialized instance's class.
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
- COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
- TESTSRC="."
-fi
-
-set -ex
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
- ${TESTSRC}/A.java ${TESTSRC}/B.java
-${COMPILEJAVA}/bin/jar ${TESTTOOLVMOPTS} cf cb1.jar A.class B.class
-cp cb1.jar cb2.jar
-rm -f A.class B.class
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
- ${TESTSRC}/Test.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
-rm -f *.class *.jar
diff --git a/jdk/test/java/io/Serializable/unnamedPackageSwitch/Test.java b/jdk/test/java/io/Serializable/unnamedPackageSwitch/UnnamedPackageSwitchTest.java
similarity index 82%
rename from jdk/test/java/io/Serializable/unnamedPackageSwitch/Test.java
rename to jdk/test/java/io/Serializable/unnamedPackageSwitch/UnnamedPackageSwitchTest.java
index 51944dfd5b3..9f2b9c88ba9 100644
--- a/jdk/test/java/io/Serializable/unnamedPackageSwitch/Test.java
+++ b/jdk/test/java/io/Serializable/unnamedPackageSwitch/UnnamedPackageSwitchTest.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 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
@@ -22,13 +22,23 @@
*/
/*
+ * @test
* @bug 4348213
+ * @build UnnamedPackageSwitchTest pkg.A
+ * @run main UnnamedPackageSwitchTest
* @summary Verify that deserialization allows an incoming class descriptor
* representing a class in the unnamed package to be resolved to a
* local class with the same name in a named package, and vice-versa.
*/
-import java.io.*;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.io.Serializable;
class A implements Serializable {
private static final long serialVersionUID = 0L;
@@ -50,7 +60,7 @@ class TestObjectInputStream extends ObjectInputStream {
}
}
-public class Test {
+public class UnnamedPackageSwitchTest {
public static void main(String[] args) throws Exception {
ByteArrayOutputStream bout = new ByteArrayOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(bout);
diff --git a/jdk/test/java/io/Serializable/unnamedPackageSwitch/run.sh b/jdk/test/java/io/Serializable/unnamedPackageSwitch/run.sh
deleted file mode 100644
index e801163af0e..00000000000
--- a/jdk/test/java/io/Serializable/unnamedPackageSwitch/run.sh
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4348213
-# @summary Verify that deserialization allows an incoming class descriptor
-# representing a class in the unnamed package to be resolved to a
-# local class with the same name in a named package, and vice-versa.
-
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
-exit 1
-fi
-
-if [ "${COMPILEJAVA}" = "" ] ; then
- COMPILEJAVA="${TESTJAVA}"
-fi
-
-if [ "${TESTSRC}" = "" ]
-then
- TESTSRC="."
-fi
-
-set -ex
-
-${COMPILEJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . \
- ${TESTSRC}/A.java ${TESTSRC}/Test.java
-${TESTJAVA}/bin/java ${TESTVMOPTS} Test
From acac03897680b4d1df3ed216939c1e23b41a5791 Mon Sep 17 00:00:00 2001
From: Amy Lu
Date: Thu, 1 Jun 2017 11:10:22 +0800
Subject: [PATCH 54/55] 8181301: Refactor shell test
AsynchronousChannelGroup/run_any_task.sh to java
Reviewed-by: alanb
---
.../AsynchronousChannelGroup/AsExecutor.java | 21 +++++---
.../AsynchronousChannelGroup/SetupJar.java | 34 ++++++++++++
.../{ => bootlib}/Attack.java | 4 +-
.../PrivilegedThreadFactory.java | 0
.../AsynchronousChannelGroup/run_any_task.sh | 52 -------------------
5 files changed, 51 insertions(+), 60 deletions(-)
create mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/SetupJar.java
rename jdk/test/java/nio/channels/AsynchronousChannelGroup/{ => bootlib}/Attack.java (96%)
rename jdk/test/java/nio/channels/AsynchronousChannelGroup/{ => bootlib}/PrivilegedThreadFactory.java (100%)
delete mode 100644 jdk/test/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh
diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java
index ec4cb09d61c..6accf29d38e 100644
--- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java
+++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/AsExecutor.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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,22 @@
* questions.
*/
-import java.nio.channels.AsynchronousChannelGroup;
-import java.util.concurrent.*;
-
-/**
- * Test that arbitrary tasks can be submitted to a channel group's thread pool.
+/*
+ * @test
+ * @bug 4607272
+ * @summary tests tasks can be submitted to a channel group's thread pool.
+ * @library /lib/testlibrary bootlib
+ * @build JarUtils PrivilegedThreadFactory Attack
+ * @run driver SetupJar
+ * @run main/othervm -Xbootclasspath/a:privileged.jar AsExecutor
*/
+import java.nio.channels.AsynchronousChannelGroup;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.Executor;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ThreadFactory;
+
public class AsExecutor {
public static void main(String[] args) throws Exception {
diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/SetupJar.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/SetupJar.java
new file mode 100644
index 00000000000..a50a3891f30
--- /dev/null
+++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/SetupJar.java
@@ -0,0 +1,34 @@
+/*
+ * 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 java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class SetupJar {
+
+ public static void main(String args[]) throws Exception {
+ Path classes = Paths.get(System.getProperty("test.classes", ""));
+ JarUtils.createJarFile(Paths.get("privileged.jar"),
+ classes.resolve("bootlib"));
+ }
+}
diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Attack.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/bootlib/Attack.java
similarity index 96%
rename from jdk/test/java/nio/channels/AsynchronousChannelGroup/Attack.java
rename to jdk/test/java/nio/channels/AsynchronousChannelGroup/bootlib/Attack.java
index 7572b89b3f4..c0317632443 100644
--- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/Attack.java
+++ b/jdk/test/java/nio/channels/AsynchronousChannelGroup/bootlib/Attack.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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,8 +21,8 @@
* questions.
*/
-import java.net.*;
import java.io.IOException;
+import java.net.Socket;
import java.util.concurrent.CountDownLatch;
/**
diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java b/jdk/test/java/nio/channels/AsynchronousChannelGroup/bootlib/PrivilegedThreadFactory.java
similarity index 100%
rename from jdk/test/java/nio/channels/AsynchronousChannelGroup/PrivilegedThreadFactory.java
rename to jdk/test/java/nio/channels/AsynchronousChannelGroup/bootlib/PrivilegedThreadFactory.java
diff --git a/jdk/test/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh b/jdk/test/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh
deleted file mode 100644
index f1631ce8434..00000000000
--- a/jdk/test/java/nio/channels/AsynchronousChannelGroup/run_any_task.sh
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (c) 2008, 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 4607272
-# @summary Unit test for AsynchronousChannelGrou#execute
-# @build AsExecutor PrivilegedThreadFactory Attack
-# @run shell run_any_task.sh
-
-# if TESTJAVA isn't set then we assume an interactive run.
-
-if [ -z "$TESTJAVA" ]; then
- TESTSRC=.
- TESTCLASSES=.
- JAVA=java
- JAR=jar
-else
- JAVA="${TESTJAVA}/bin/java"
- JAR="${TESTJAVA}/bin/jar"
-fi
-
-echo "Creating JAR file ..."
-$JAR -cf "${TESTCLASSES}/Privileged.jar" \
- -C "${TESTCLASSES}" PrivilegedThreadFactory.class \
- -C "${TESTCLASSES}" PrivilegedThreadFactory\$1.class \
- -C "${TESTCLASSES}" Attack.class
-
-echo "Running test ..."
-$JAVA ${TESTVMOPTS} \
- -Xbootclasspath/a:"${TESTCLASSES}/Privileged.jar" \
- -classpath "${TESTCLASSES}" \
- AsExecutor
From 7d4c61e2b7c0053c8a204d1a6f21bd412845be82 Mon Sep 17 00:00:00 2001
From: Thomas Stuefe
Date: Thu, 1 Jun 2017 08:59:24 +0200
Subject: [PATCH 55/55] 8181207: 8177809 breaks AIX 5.3, 6.1 builds
Reviewed-by: vtewari, simonis, clanger
---
.../unix/native/libjava/UnixFileSystem_md.c | 23 +++++++++++--------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c b/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c
index 95b5674830d..e3eae8bac17 100644
--- a/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c
+++ b/jdk/src/java.base/unix/native/libjava/UnixFileSystem_md.c
@@ -229,12 +229,15 @@ Java_java_io_UnixFileSystem_getLastModifiedTime(JNIEnv *env, jobject this,
WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) {
struct stat64 sb;
if (stat64(path, &sb) == 0) {
-#ifndef MACOSX
- rv = (jlong)sb.st_mtim.tv_sec * 1000;
- rv += (jlong)sb.st_mtim.tv_nsec / 1000000;
-#else
+#if defined(_AIX)
+ rv = (jlong)sb.st_mtime * 1000;
+ rv += (jlong)sb.st_mtime_n / 1000000;
+#elif defined(MACOSX)
rv = (jlong)sb.st_mtimespec.tv_sec * 1000;
rv += (jlong)sb.st_mtimespec.tv_nsec / 1000000;
+#else
+ rv = (jlong)sb.st_mtim.tv_sec * 1000;
+ rv += (jlong)sb.st_mtim.tv_nsec / 1000000;
#endif
}
} END_PLATFORM_STRING(env, path);
@@ -419,14 +422,16 @@ Java_java_io_UnixFileSystem_setLastModifiedTime(JNIEnv *env, jobject this,
struct timeval tv[2];
/* Preserve access time */
-#ifndef MACOSX
- tv[0].tv_sec = sb.st_atim.tv_sec;
- tv[0].tv_usec = sb.st_atim.tv_nsec / 1000;
-#else
+#if defined(_AIX)
+ tv[0].tv_sec = sb.st_atime;
+ tv[0].tv_usec = sb.st_atime_n / 1000;
+#elif defined(MACOSX)
tv[0].tv_sec = sb.st_atimespec.tv_sec;
tv[0].tv_usec = sb.st_atimespec.tv_nsec / 1000;
+#else
+ tv[0].tv_sec = sb.st_atim.tv_sec;
+ tv[0].tv_usec = sb.st_atim.tv_nsec / 1000;
#endif
-
/* Change last-modified time */
tv[1].tv_sec = time / 1000;
tv[1].tv_usec = (time % 1000) * 1000;