Merge JDK-8200758-branch
authorherrick
Sat, 13 Apr 2019 07:52:21 -0400
branchJDK-8200758-branch
changeset 57325 e678ef92ef0b
parent 57324 c1d3935fbb79 (current diff)
parent 54527 96d290a7e94f (diff)
child 57326 603101a378fe
Merge
src/jdk.accessibility/windows/native/common/AccessBridgeStatusWindow.RC
test/hotspot/jtreg/runtime/containers/cgroup/PlainRead.java
test/hotspot/jtreg/runtime/containers/docker/AttemptOOM.java
test/hotspot/jtreg/runtime/containers/docker/CheckContainerized.java
test/hotspot/jtreg/runtime/containers/docker/DockerBasicTest.java
test/hotspot/jtreg/runtime/containers/docker/HelloDocker.java
test/hotspot/jtreg/runtime/containers/docker/JfrReporter.java
test/hotspot/jtreg/runtime/containers/docker/PrintContainerInfo.java
test/hotspot/jtreg/runtime/containers/docker/TEST.properties
test/hotspot/jtreg/runtime/containers/docker/TestCPUAwareness.java
test/hotspot/jtreg/runtime/containers/docker/TestCPUSets.java
test/hotspot/jtreg/runtime/containers/docker/TestJFREvents.java
test/hotspot/jtreg/runtime/containers/docker/TestMemoryAwareness.java
test/hotspot/jtreg/runtime/containers/docker/TestMisc.java
test/jdk/sun/security/tools/jarsigner/AlgOptions.sh
test/jdk/sun/security/tools/jarsigner/PercentSign.sh
test/jdk/sun/security/tools/jarsigner/certpolicy.sh
test/jdk/sun/security/tools/jarsigner/checkusage.sh
test/jdk/sun/security/tools/jarsigner/collator.sh
test/jdk/sun/security/tools/jarsigner/concise_jarsigner.sh
test/jdk/sun/security/tools/jarsigner/crl.sh
test/jdk/sun/security/tools/jarsigner/default_options.sh
test/jdk/sun/security/tools/jarsigner/diffend.sh
test/jdk/sun/security/tools/jarsigner/ec.sh
test/jdk/sun/security/tools/jarsigner/emptymanifest.sh
test/jdk/sun/security/tools/jarsigner/jvindex.sh
test/jdk/sun/security/tools/jarsigner/nameclash.sh
test/jdk/sun/security/tools/jarsigner/newsize7.sh
test/jdk/sun/security/tools/jarsigner/oldsig.sh
test/jdk/sun/security/tools/jarsigner/onlymanifest.sh
test/jdk/sun/security/tools/jarsigner/passtype.sh
test/jdk/sun/security/tools/jarsigner/samename.sh
test/jdk/sun/security/tools/jarsigner/weaksize.sh
test/jdk/sun/security/tools/keytool/CloneKeyAskPassword.sh
test/jdk/sun/security/tools/keytool/NoExtNPE.sh
test/jdk/sun/security/tools/keytool/SecretKeyKS.sh
test/jdk/sun/security/tools/keytool/StandardAlgName.sh
test/jdk/sun/security/tools/keytool/StorePasswordsByShell.sh
test/jdk/sun/security/tools/keytool/default_options.sh
test/jdk/sun/security/tools/keytool/emptysubject.sh
test/jdk/sun/security/tools/keytool/file-in-help.sh
test/jdk/sun/security/tools/keytool/i18n.sh
test/jdk/sun/security/tools/keytool/importreadall.sh
test/jdk/sun/security/tools/keytool/keyalg.sh
test/jdk/sun/security/tools/keytool/newhelp.sh
test/jdk/sun/security/tools/keytool/resource.sh
test/jdk/sun/security/tools/keytool/selfissued.sh
test/jdk/sun/security/tools/keytool/trystore.sh
--- a/doc/testing.html	Sat Apr 13 07:47:23 2019 -0400
+++ b/doc/testing.html	Sat Apr 13 07:52:21 2019 -0400
@@ -191,8 +191,8 @@
 <h2 id="notes-for-specific-tests">Notes for Specific Tests</h2>
 <h3 id="docker-tests">Docker Tests</h3>
 <p>Docker tests with default parameters may fail on systems with glibc versions not compatible with the one used in the default docker image (e.g., Oracle Linux 7.6 for x86). For example, they pass on Ubuntu 16.04 but fail on Ubuntu 18.04 if run like this on x86:</p>
-<pre><code>$ make test TEST=&quot;jtreg:test/hotspot/jtreg/runtime/containers/docker&quot;</code></pre>
+<pre><code>$ make test TEST=&quot;jtreg:test/hotspot/jtreg/containers/docker&quot;</code></pre>
 <p>To run these tests correctly, additional parameters for the correct docker image are required on Ubuntu 18.04 by using <code>JAVA_OPTIONS</code>.</p>
-<pre><code>$ make test TEST=&quot;jtreg:test/hotspot/jtreg/runtime/containers/docker&quot; JTREG=&quot;JAVA_OPTIONS=-Djdk.test.docker.image.name=ubuntu -Djdk.test.docker.image.version=latest&quot;</code></pre>
+<pre><code>$ make test TEST=&quot;jtreg:test/hotspot/jtreg/containers/docker&quot; JTREG=&quot;JAVA_OPTIONS=-Djdk.test.docker.image.name=ubuntu -Djdk.test.docker.image.version=latest&quot;</code></pre>
 </body>
 </html>
--- a/doc/testing.md	Sat Apr 13 07:47:23 2019 -0400
+++ b/doc/testing.md	Sat Apr 13 07:52:21 2019 -0400
@@ -381,12 +381,12 @@
 compatible with the one used in the default docker image (e.g., Oracle Linux 7.6 for x86).
 For example, they pass on Ubuntu 16.04 but fail on Ubuntu 18.04 if run like this on x86:
 
-    $ make test TEST="jtreg:test/hotspot/jtreg/runtime/containers/docker"
+    $ make test TEST="jtreg:test/hotspot/jtreg/containers/docker"
 
 To run these tests correctly, additional parameters for the correct docker image are
 required on Ubuntu 18.04 by using `JAVA_OPTIONS`.
 
-    $ make test TEST="jtreg:test/hotspot/jtreg/runtime/containers/docker" JTREG="JAVA_OPTIONS=-Djdk.test.docker.image.name=ubuntu -Djdk.test.docker.image.version=latest"
+    $ make test TEST="jtreg:test/hotspot/jtreg/containers/docker" JTREG="JAVA_OPTIONS=-Djdk.test.docker.image.name=ubuntu -Djdk.test.docker.image.version=latest"
 
 ---
 # Override some definitions in the global css file that are not optimal for
--- a/make/Coverage.gmk	Sat Apr 13 07:47:23 2019 -0400
+++ b/make/Coverage.gmk	Sat Apr 13 07:52:21 2019 -0400
@@ -49,6 +49,7 @@
 	    -exclude 'java.lang.Object' \
 	    -exclude 'jdk.internal.org.objectweb.**' \
 	    -exclude jdk.test.Main -exclude '**\$Proxy*' \
+	    $(JCOV_FILTERS) \
 	    $(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR)
 	$(MV) $(JCOV_TEMP)/$(JCOV_IMAGE_SUBDIR) $(JCOV_IMAGE_DIR)
 	$(RMDIR) $(JCOV_TEMP)
--- a/make/RunTests.gmk	Sat Apr 13 07:47:23 2019 -0400
+++ b/make/RunTests.gmk	Sat Apr 13 07:52:21 2019 -0400
@@ -1194,10 +1194,18 @@
 	$(call LogWarn, Stopping JCov Grabber...)
 	$(JAVA) -jar $(JCOV_HOME)/lib/jcov.jar GrabberManager -stop -stoptimeout 3600
 
+  JCOV_REPORT_TITLE := JDK code coverage report<br/>
+  ifneq ($(JCOV_FILTERS), )
+    JCOV_REPORT_TITLE += Code filters: $(JCOV_FILTERS)<br>
+  endif
+  JCOV_REPORT_TITLE += Tests: $(TEST)
+	
   jcov-gen-report: jcov-stop-grabber
 	$(call LogWarn, Generating JCov report ...)
 	$(JAVA) -Xmx4g -jar $(JCOV_HOME)/lib/jcov.jar RepGen -sourcepath \
 	    `$(ECHO) $(TOPDIR)/src/*/share/classes/ | $(TR) ' ' ':'` -fmt html \
+	    $(JCOV_FILTERS) \
+	    -mainReportTitle "$(JCOV_REPORT_TITLE)" \
 	    -o $(JCOV_REPORT) $(JCOV_RESULT_FILE)
 
   TARGETS += jcov-do-start-grabber jcov-start-grabber jcov-stop-grabber \
--- a/make/autoconf/flags-other.m4	Sat Apr 13 07:47:23 2019 -0400
+++ b/make/autoconf/flags-other.m4	Sat Apr 13 07:52:21 2019 -0400
@@ -81,21 +81,21 @@
     RC_FLAGS="$RC_FLAGS \
         -D\"JDK_VERSION_STRING=\$(VERSION_STRING)\" \
         -D\"JDK_COMPANY=\$(COMPANY_NAME)\" \
-        -D\"JDK_COMPONENT=\$(JDK_RC_NAME) binary\" \
+        -D\"JDK_FILEDESC=\$(JDK_RC_NAME) binary\" \
         -D\"JDK_VER=\$(VERSION_NUMBER)\" \
         -D\"JDK_COPYRIGHT=Copyright \xA9 $COPYRIGHT_YEAR\" \
         -D\"JDK_NAME=\$(JDK_RC_NAME) \$(VERSION_FEATURE)\" \
         -D\"JDK_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
 
     JVM_RCFLAGS="$JVM_RCFLAGS \
-        -D\"HS_BUILD_ID=\$(VERSION_STRING)\" \
+        -D\"HS_VERSION_STRING=\$(VERSION_STRING)\" \
         -D\"HS_COMPANY=\$(COMPANY_NAME)\" \
-        -D\"JDK_DOTVER=\$(VERSION_NUMBER_FOUR_POSITIONS)\" \
+        -D\"HS_VER=\$(VERSION_NUMBER_FOUR_POSITIONS)\" \
+        -D\"HS_INTERNAL_NAME=jvm\" \
         -D\"HS_COPYRIGHT=Copyright $COPYRIGHT_YEAR\" \
+        -D\"HS_FNAME=jvm.dll\" \
         -D\"HS_NAME=\$(PRODUCT_NAME) \$(VERSION_SHORT)\" \
-        -D\"JDK_VER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\" \
-        -D\"HS_FNAME=jvm.dll\" \
-        -D\"HS_INTERNAL_NAME=jvm\""
+        -D\"HS_FVER=\$(subst .,\$(COMMA),\$(VERSION_NUMBER_FOUR_POSITIONS))\""
   fi
   AC_SUBST(RC_FLAGS)
   AC_SUBST(JVM_RCFLAGS)
--- a/make/autoconf/jdk-options.m4	Sat Apr 13 07:47:23 2019 -0400
+++ b/make/autoconf/jdk-options.m4	Sat Apr 13 07:52:21 2019 -0400
@@ -404,9 +404,12 @@
       [jcov library location])])
   AC_ARG_WITH(jcov-input-jdk, [AS_HELP_STRING([--with-jcov-input-jdk],
       [jdk image to instrument])])
+  AC_ARG_WITH(jcov-filters, [AS_HELP_STRING([--with-jcov-filters],
+      [filters to limit code for jcov instrumentation and report generation])])
   JCOV_HOME=
   JCOV_INPUT_JDK=
   JCOV_ENABLED=
+  JCOV_FILTERS=
   if test "x$with_jcov" = "x" ; then
     JCOV_ENABLED="false"
   else
@@ -425,10 +428,14 @@
       fi
       BASIC_FIXUP_PATH(JCOV_INPUT_JDK)
     fi
+    if test "x$with_jcov_filters" != "x" ; then
+      JCOV_FILTERS="$with_jcov_filters"
+    fi
   fi
   AC_SUBST(JCOV_ENABLED)
   AC_SUBST(JCOV_HOME)
   AC_SUBST(JCOV_INPUT_JDK)
+  AC_SUBST(JCOV_FILTERS)
 ])
 
 ###############################################################################
--- a/make/autoconf/spec.gmk.in	Sat Apr 13 07:47:23 2019 -0400
+++ b/make/autoconf/spec.gmk.in	Sat Apr 13 07:52:21 2019 -0400
@@ -389,6 +389,7 @@
 JCOV_ENABLED=@JCOV_ENABLED@
 JCOV_HOME=@JCOV_HOME@
 JCOV_INPUT_JDK=@JCOV_INPUT_JDK@
+JCOV_FILTERS=@JCOV_FILTERS@
 
 # AddressSanitizer
 export ASAN_ENABLED:=@ASAN_ENABLED@
--- a/make/launcher/Launcher-jdk.accessibility.gmk	Sat Apr 13 07:47:23 2019 -0400
+++ b/make/launcher/Launcher-jdk.accessibility.gmk	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -43,7 +43,7 @@
       DISABLED_WARNINGS_microsoft := 4267 4996, \
       LDFLAGS := $(LDFLAGS_JDKEXE), \
       LIBS := advapi32.lib version.lib user32.lib, \
-      VERSIONINFO_RESOURCE := $(ACCESSBRIDGE_SRC)/AccessBridgeStatusWindow.RC, \
+      VERSIONINFO_RESOURCE := $(ACCESSBRIDGE_SRC)/AccessBridgeStatusWindow.rc, \
       MANIFEST := $(JABSWITCH_SRC)/jabswitch.manifest, \
       MANIFEST_VERSION := $(VERSION_NUMBER_FOUR_POSITIONS), \
   ))
--- a/src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/aarch64/interpreterRT_aarch64.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -418,7 +418,7 @@
 };
 
 
-IRT_ENTRY(address,
+JRT_ENTRY(address,
           InterpreterRuntime::slow_signature_handler(JavaThread* thread,
                                                      Method* method,
                                                      intptr_t* from,
@@ -435,4 +435,4 @@
 
   // return result handler
   return Interpreter::result_handler(m->result_type());
-IRT_END
+JRT_END
--- a/src/hotspot/cpu/arm/interpreterRT_arm.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/arm/interpreterRT_arm.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -369,9 +369,9 @@
   }
 };
 
-IRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(JavaThread* thread, Method* method, intptr_t* from, intptr_t* to))
+JRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(JavaThread* thread, Method* method, intptr_t* from, intptr_t* to))
   methodHandle m(thread, (Method*)method);
   assert(m->is_native(), "sanity check");
   SlowSignatureHandler(m, (address)from, to).iterate(UCONST64(-1));
   return Interpreter::result_handler(m->result_type());
-IRT_END
+JRT_END
--- a/src/hotspot/cpu/ppc/interpreterRT_ppc.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/ppc/interpreterRT_ppc.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2012, 2013 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -148,15 +148,15 @@
 
 
 // Access function to get the signature.
-IRT_ENTRY(address, InterpreterRuntime::get_signature(JavaThread* thread, Method* method))
+JRT_ENTRY(address, InterpreterRuntime::get_signature(JavaThread* thread, Method* method))
   methodHandle m(thread, method);
   assert(m->is_native(), "sanity check");
   Symbol *s = m->signature();
   return (address) s->base();
-IRT_END
+JRT_END
 
-IRT_ENTRY(address, InterpreterRuntime::get_result_handler(JavaThread* thread, Method* method))
+JRT_ENTRY(address, InterpreterRuntime::get_result_handler(JavaThread* thread, Method* method))
   methodHandle m(thread, method);
   assert(m->is_native(), "sanity check");
   return AbstractInterpreter::result_handler(m->result_type());
-IRT_END
+JRT_END
--- a/src/hotspot/cpu/s390/interpreterRT_s390.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/s390/interpreterRT_s390.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2016 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -151,15 +151,15 @@
 
 void SignatureHandlerLibrary::pd_set_handler(address handler) {}
 
-IRT_ENTRY(address, InterpreterRuntime::get_signature(JavaThread* thread, Method* method))
+JRT_ENTRY(address, InterpreterRuntime::get_signature(JavaThread* thread, Method* method))
   methodHandle m(thread, method);
   assert(m->is_native(), "sanity check");
   Symbol *s = m->signature();
   return (address) s->base();
-IRT_END
+JRT_END
 
-IRT_ENTRY(address, InterpreterRuntime::get_result_handler(JavaThread* thread, Method* method))
+JRT_ENTRY(address, InterpreterRuntime::get_result_handler(JavaThread* thread, Method* method))
   methodHandle m(thread, method);
   assert(m->is_native(), "sanity check");
   return AbstractInterpreter::result_handler(m->result_type());
-IRT_END
+JRT_END
--- a/src/hotspot/cpu/sparc/interpreterRT_sparc.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/sparc/interpreterRT_sparc.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -191,7 +191,7 @@
 };
 
 
-IRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(
+JRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(
                                                     JavaThread* thread,
                                                     Method* method,
                                                     intptr_t* from,
@@ -204,4 +204,4 @@
   SlowSignatureHandler(m, (address)from, m->is_static() ? to+2 : to+1, to).iterate((uint64_t)CONST64(-1));
   // return result handler
   return Interpreter::result_handler(m->result_type());
-IRT_END
+JRT_END
--- a/src/hotspot/cpu/x86/assembler_x86.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/x86/assembler_x86.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -3099,7 +3099,7 @@
     }
     return;
   }
-  if (UseAddressNop && VM_Version::is_amd()) {
+  if (UseAddressNop && VM_Version::is_amd_family()) {
     //
     // Using multi-bytes nops "0x0F 0x1F [address]" for AMD.
     //  1: 0x90
--- a/src/hotspot/cpu/x86/interpreterRT_x86_32.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/x86/interpreterRT_x86_32.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -147,11 +147,11 @@
   }
 };
 
-IRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(JavaThread* thread, Method* method, intptr_t* from, intptr_t* to))
+JRT_ENTRY(address, InterpreterRuntime::slow_signature_handler(JavaThread* thread, Method* method, intptr_t* from, intptr_t* to))
   methodHandle m(thread, (Method*)method);
   assert(m->is_native(), "sanity check");
   // handle arguments
   SlowSignatureHandler(m, (address)from, to + 1).iterate((uint64_t)CONST64(-1));
   // return result handler
   return Interpreter::result_handler(m->result_type());
-IRT_END
+JRT_END
--- a/src/hotspot/cpu/x86/interpreterRT_x86_64.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/x86/interpreterRT_x86_64.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -496,7 +496,7 @@
 #endif
 
 
-IRT_ENTRY(address,
+JRT_ENTRY(address,
           InterpreterRuntime::slow_signature_handler(JavaThread* thread,
                                                      Method* method,
                                                      intptr_t* from,
@@ -509,4 +509,4 @@
 
   // return result handler
   return Interpreter::result_handler(m->result_type());
-IRT_END
+JRT_END
--- a/src/hotspot/cpu/x86/vm_version_ext_x86.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/x86/vm_version_ext_x86.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -340,6 +340,10 @@
     return !is_amd_Barcelona();
   }
 
+  if (is_hygon()) {
+    return true;
+  }
+
   return false;
 }
 
@@ -407,6 +411,10 @@
     }
     return _family_id_intel[cpu_family_id];
   }
+  if (is_hygon()) {
+    return "Dhyana";
+  }
+
   return "Unknown x86";
 }
 
@@ -423,6 +431,9 @@
   } else if (is_amd()) {
     cpu_type = "AMD";
     x64 = cpu_is_em64t() ? " AMD64" : "";
+  } else if (is_hygon()) {
+    cpu_type = "Hygon";
+    x64 = cpu_is_em64t() ? " AMD64" : "";
   } else {
     cpu_type = "Unknown x86";
     x64 = cpu_is_em64t() ? " x86_64" : "";
--- a/src/hotspot/cpu/x86/vm_version_x86.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/x86/vm_version_x86.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -680,7 +680,7 @@
     _features &= ~CPU_HT;
   }
 
-  if( is_intel() ) { // Intel cpus specific settings
+  if (is_intel()) { // Intel cpus specific settings
     if (is_knights_family()) {
       _features &= ~CPU_VZEROUPPER;
     }
@@ -781,7 +781,7 @@
           FLAG_SET_DEFAULT(UseAESCTRIntrinsics, false);
         }
       } else {
-        if(supports_sse4_1()) {
+        if (supports_sse4_1()) {
           if (FLAG_IS_DEFAULT(UseAESCTRIntrinsics)) {
             FLAG_SET_DEFAULT(UseAESCTRIntrinsics, true);
           }
@@ -1001,7 +1001,7 @@
   } else if (UseAVX == 1 || UseAVX == 2) {
     // 32 bytes vectors (in YMM) are only supported with AVX+
     max_vector_size = 32;
-  } else if (UseAVX > 2 ) {
+  } else if (UseAVX > 2) {
     // 64 bytes vectors (in ZMM) are only supported with AVX 3
     max_vector_size = 64;
   }
@@ -1165,38 +1165,38 @@
     }
   }
 
-  if( is_amd() ) { // AMD cpus specific settings
-    if( supports_sse2() && FLAG_IS_DEFAULT(UseAddressNop) ) {
+  if (is_amd_family()) { // AMD cpus specific settings
+    if (supports_sse2() && FLAG_IS_DEFAULT(UseAddressNop)) {
       // Use it on new AMD cpus starting from Opteron.
       UseAddressNop = true;
     }
-    if( supports_sse2() && FLAG_IS_DEFAULT(UseNewLongLShift) ) {
+    if (supports_sse2() && FLAG_IS_DEFAULT(UseNewLongLShift)) {
       // Use it on new AMD cpus starting from Opteron.
       UseNewLongLShift = true;
     }
-    if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
+    if (FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper)) {
       if (supports_sse4a()) {
         UseXmmLoadAndClearUpper = true; // use movsd only on '10h' Opteron
       } else {
         UseXmmLoadAndClearUpper = false;
       }
     }
-    if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
-      if( supports_sse4a() ) {
+    if (FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll)) {
+      if (supports_sse4a()) {
         UseXmmRegToRegMoveAll = true; // use movaps, movapd only on '10h'
       } else {
         UseXmmRegToRegMoveAll = false;
       }
     }
-    if( FLAG_IS_DEFAULT(UseXmmI2F) ) {
-      if( supports_sse4a() ) {
+    if (FLAG_IS_DEFAULT(UseXmmI2F)) {
+      if (supports_sse4a()) {
         UseXmmI2F = true;
       } else {
         UseXmmI2F = false;
       }
     }
-    if( FLAG_IS_DEFAULT(UseXmmI2D) ) {
-      if( supports_sse4a() ) {
+    if (FLAG_IS_DEFAULT(UseXmmI2D)) {
+      if (supports_sse4a()) {
         UseXmmI2D = true;
       } else {
         UseXmmI2D = false;
@@ -1214,7 +1214,7 @@
     }
 
     // some defaults for AMD family 15h
-    if ( cpu_family() == 0x15 ) {
+    if (cpu_family() == 0x15) {
       // On family 15h processors default is no sw prefetch
       if (FLAG_IS_DEFAULT(AllocatePrefetchStyle)) {
         FLAG_SET_DEFAULT(AllocatePrefetchStyle, 0);
@@ -1239,8 +1239,8 @@
     }
 #endif // COMPILER2
 
-    // Some defaults for AMD family 17h
-    if ( cpu_family() == 0x17 ) {
+    // Some defaults for AMD family 17h || Hygon family 18h
+    if (cpu_family() == 0x17 || cpu_family() == 0x18) {
       // On family 17h processors use XMM and UnalignedLoadStores for Array Copy
       if (supports_sse2() && FLAG_IS_DEFAULT(UseXMMForArrayCopy)) {
         FLAG_SET_DEFAULT(UseXMMForArrayCopy, true);
@@ -1256,29 +1256,29 @@
     }
   }
 
-  if( is_intel() ) { // Intel cpus specific settings
-    if( FLAG_IS_DEFAULT(UseStoreImmI16) ) {
+  if (is_intel()) { // Intel cpus specific settings
+    if (FLAG_IS_DEFAULT(UseStoreImmI16)) {
       UseStoreImmI16 = false; // don't use it on Intel cpus
     }
-    if( cpu_family() == 6 || cpu_family() == 15 ) {
-      if( FLAG_IS_DEFAULT(UseAddressNop) ) {
+    if (cpu_family() == 6 || cpu_family() == 15) {
+      if (FLAG_IS_DEFAULT(UseAddressNop)) {
         // Use it on all Intel cpus starting from PentiumPro
         UseAddressNop = true;
       }
     }
-    if( FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper) ) {
+    if (FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper)) {
       UseXmmLoadAndClearUpper = true; // use movsd on all Intel cpus
     }
-    if( FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll) ) {
-      if( supports_sse3() ) {
+    if (FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll)) {
+      if (supports_sse3()) {
         UseXmmRegToRegMoveAll = true; // use movaps, movapd on new Intel cpus
       } else {
         UseXmmRegToRegMoveAll = false;
       }
     }
-    if( cpu_family() == 6 && supports_sse3() ) { // New Intel cpus
+    if (cpu_family() == 6 && supports_sse3()) { // New Intel cpus
 #ifdef COMPILER2
-      if( FLAG_IS_DEFAULT(MaxLoopPad) ) {
+      if (FLAG_IS_DEFAULT(MaxLoopPad)) {
         // For new Intel cpus do the next optimization:
         // don't align the beginning of a loop if there are enough instructions
         // left (NumberOfLoopInstrToAlign defined in c2_globals.hpp)
@@ -1324,7 +1324,7 @@
         FLAG_SET_DEFAULT(UseIncDec, false);
       }
     }
-    if(FLAG_IS_DEFAULT(AllocatePrefetchInstr) && supports_3dnow_prefetch()) {
+    if (FLAG_IS_DEFAULT(AllocatePrefetchInstr) && supports_3dnow_prefetch()) {
       FLAG_SET_DEFAULT(AllocatePrefetchInstr, 3);
     }
   }
--- a/src/hotspot/cpu/x86/vm_version_x86.hpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/x86/vm_version_x86.hpp	Sat Apr 13 07:52:21 2019 -0400
@@ -495,13 +495,13 @@
       result |= CPU_CX8;
     if (_cpuid_info.std_cpuid1_edx.bits.cmov != 0)
       result |= CPU_CMOV;
-    if (_cpuid_info.std_cpuid1_edx.bits.fxsr != 0 || (is_amd() &&
+    if (_cpuid_info.std_cpuid1_edx.bits.fxsr != 0 || (is_amd_family() &&
         _cpuid_info.ext_cpuid1_edx.bits.fxsr != 0))
       result |= CPU_FXSR;
     // HT flag is set for multi-core processors also.
     if (threads_per_core() > 1)
       result |= CPU_HT;
-    if (_cpuid_info.std_cpuid1_edx.bits.mmx != 0 || (is_amd() &&
+    if (_cpuid_info.std_cpuid1_edx.bits.mmx != 0 || (is_amd_family() &&
         _cpuid_info.ext_cpuid1_edx.bits.mmx != 0))
       result |= CPU_MMX;
     if (_cpuid_info.std_cpuid1_edx.bits.sse != 0)
@@ -553,7 +553,7 @@
           result |= CPU_VNNI;
       }
     }
-    if(_cpuid_info.sef_cpuid7_ebx.bits.bmi1 != 0)
+    if (_cpuid_info.sef_cpuid7_ebx.bits.bmi1 != 0)
       result |= CPU_BMI1;
     if (_cpuid_info.std_cpuid1_edx.bits.tsc != 0)
       result |= CPU_TSC;
@@ -567,17 +567,17 @@
       result |= CPU_CLMUL;
     if (_cpuid_info.sef_cpuid7_ebx.bits.rtm != 0)
       result |= CPU_RTM;
-    if(_cpuid_info.sef_cpuid7_ebx.bits.adx != 0)
+    if (_cpuid_info.sef_cpuid7_ebx.bits.adx != 0)
        result |= CPU_ADX;
-    if(_cpuid_info.sef_cpuid7_ebx.bits.bmi2 != 0)
+    if (_cpuid_info.sef_cpuid7_ebx.bits.bmi2 != 0)
       result |= CPU_BMI2;
     if (_cpuid_info.sef_cpuid7_ebx.bits.sha != 0)
       result |= CPU_SHA;
     if (_cpuid_info.std_cpuid1_ecx.bits.fma != 0)
       result |= CPU_FMA;
 
-    // AMD features.
-    if (is_amd()) {
+    // AMD|Hygon features.
+    if (is_amd_family()) {
       if ((_cpuid_info.ext_cpuid1_edx.bits.tdnow != 0) ||
           (_cpuid_info.ext_cpuid1_ecx.bits.prefetchw != 0))
         result |= CPU_3DNOW_PREFETCH;
@@ -587,8 +587,8 @@
         result |= CPU_SSE4A;
     }
     // Intel features.
-    if(is_intel()) {
-      if(_cpuid_info.ext_cpuid1_ecx.bits.lzcnt_intel != 0)
+    if (is_intel()) {
+      if (_cpuid_info.ext_cpuid1_ecx.bits.lzcnt_intel != 0)
         result |= CPU_LZCNT;
       // for Intel, ecx.bits.misalignsse bit (bit 8) indicates support for prefetchw
       if (_cpuid_info.ext_cpuid1_ecx.bits.misalignsse != 0) {
@@ -714,6 +714,8 @@
   static int  cpu_family()        { return _cpu;}
   static bool is_P6()             { return cpu_family() >= 6; }
   static bool is_amd()            { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x68747541; } // 'htuA'
+  static bool is_hygon()          { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x6F677948; } // 'ogyH'
+  static bool is_amd_family()     { return is_amd() || is_hygon(); }
   static bool is_intel()          { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x756e6547; } // 'uneG'
   static bool is_zx()             { assert_is_initialized(); return (_cpuid_info.std_vendor_name_0 == 0x746e6543) || (_cpuid_info.std_vendor_name_0 == 0x68532020); } // 'tneC'||'hS  '
   static bool is_atom_family()    { return ((cpu_family() == 0x06) && ((extended_cpu_model() == 0x36) || (extended_cpu_model() == 0x37) || (extended_cpu_model() == 0x4D))); } //Silvermont and Centerton
@@ -737,7 +739,7 @@
       if (!supports_topology || result == 0) {
         result = (_cpuid_info.dcp_cpuid4_eax.bits.cores_per_cpu + 1);
       }
-    } else if (is_amd()) {
+    } else if (is_amd_family()) {
       result = (_cpuid_info.ext_cpuid8_ecx.bits.cores_per_cpu + 1);
     } else if (is_zx()) {
       bool supports_topology = supports_processor_topology();
@@ -773,7 +775,7 @@
     intx result = 0;
     if (is_intel()) {
       result = (_cpuid_info.dcp_cpuid4_ebx.bits.L1_line_size + 1);
-    } else if (is_amd()) {
+    } else if (is_amd_family()) {
       result = _cpuid_info.ext_cpuid5_ecx.bits.L1_line_size;
     } else if (is_zx()) {
       result = (_cpuid_info.dcp_cpuid4_ebx.bits.L1_line_size + 1);
@@ -860,7 +862,7 @@
 
   // AMD features
   static bool supports_3dnow_prefetch()    { return (_features & CPU_3DNOW_PREFETCH) != 0; }
-  static bool supports_mmx_ext()  { return is_amd() && _cpuid_info.ext_cpuid1_edx.bits.mmx_amd != 0; }
+  static bool supports_mmx_ext()  { return is_amd_family() && _cpuid_info.ext_cpuid1_edx.bits.mmx_amd != 0; }
   static bool supports_lzcnt()    { return (_features & CPU_LZCNT) != 0; }
   static bool supports_sse4a()    { return (_features & CPU_SSE4A) != 0; }
 
@@ -873,8 +875,8 @@
   }
   static bool supports_tscinv() {
     return supports_tscinv_bit() &&
-           ( (is_amd() && !is_amd_Barcelona()) ||
-             is_intel_tsc_synched_at_init() );
+      ((is_amd_family() && !is_amd_Barcelona()) ||
+        is_intel_tsc_synched_at_init());
   }
 
   // Intel Core and newer cpus have fast IDIV instruction (excluding Atom).
@@ -899,7 +901,7 @@
     // Core      - 256 / prefetchnta
     // It will be used only when AllocatePrefetchStyle > 0
 
-    if (is_amd()) { // AMD
+    if (is_amd_family()) { // AMD | Hygon
       if (supports_sse2()) {
         return 256; // Opteron
       } else {
--- a/src/hotspot/cpu/zero/cppInterpreter_zero.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/zero/cppInterpreter_zero.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -699,11 +699,11 @@
   return stack->sp() + argument_slots;
 }
 
-IRT_ENTRY(void, CppInterpreter::throw_exception(JavaThread* thread,
+JRT_ENTRY(void, CppInterpreter::throw_exception(JavaThread* thread,
                                                 Symbol*     name,
                                                 char*       message))
   THROW_MSG(name, message);
-IRT_END
+JRT_END
 
 InterpreterFrame *InterpreterFrame::build(Method* const method, TRAPS) {
   JavaThread *thread = (JavaThread *) THREAD;
--- a/src/hotspot/cpu/zero/interpreterRT_zero.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/cpu/zero/interpreterRT_zero.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -141,7 +141,7 @@
   assert(status == FFI_OK, "should be");
 }
 
-IRT_ENTRY(address,
+JRT_ENTRY(address,
           InterpreterRuntime::slow_signature_handler(JavaThread* thread,
                                                      Method*     method,
                                                      intptr_t*   unused1,
@@ -162,7 +162,7 @@
   handler->finalize();
 
   return (address) handler;
-IRT_END
+JRT_END
 
 void SignatureHandlerLibrary::pd_set_handler(address handlerAddr) {
   InterpreterRuntime::SignatureHandler *handler =
--- a/src/hotspot/os/windows/version.rc	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/os/windows/version.rc	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
+// Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 //
 // This code is free software; you can redistribute it and/or modify it
@@ -36,8 +36,8 @@
 //
 
 VS_VERSION_INFO VERSIONINFO
- FILEVERSION    JDK_VER
- PRODUCTVERSION JDK_VER
+ FILEVERSION    HS_FVER
+ PRODUCTVERSION HS_FVER
  FILEFLAGSMASK 0x3fL
 #ifdef _DEBUG
  FILEFLAGS 0x1L
@@ -54,15 +54,15 @@
     BEGIN
         BLOCK "000004b0"
         BEGIN
-            VALUE "CompanyName",      XSTR(HS_COMPANY)       "\0"
-            VALUE "FileDescription",  XSTR(HS_FILEDESC)      "\0"
-            VALUE "FileVersion",      XSTR(JDK_DOTVER)        "\0"
-            VALUE "Full Version",     XSTR(HS_BUILD_ID)      "\0"
-	    VALUE "InternalName",     XSTR(HS_INTERNAL_NAME) "\0"
-            VALUE "LegalCopyright",   XSTR(HS_COPYRIGHT)     "\0"
-            VALUE "OriginalFilename", XSTR(HS_FNAME)         "\0"
-            VALUE "ProductName",      XSTR(HS_NAME)          "\0"
-            VALUE "ProductVersion",   XSTR(JDK_DOTVER)       "\0"
+            VALUE "CompanyName",      XSTR(HS_COMPANY)        "\0"
+            VALUE "FileDescription",  XSTR(HS_FILEDESC)       "\0"
+            VALUE "FileVersion",      XSTR(HS_VER)            "\0"
+            VALUE "Full Version",     XSTR(HS_VERSION_STRING) "\0"
+            VALUE "InternalName",     XSTR(HS_INTERNAL_NAME)  "\0"
+            VALUE "LegalCopyright",   XSTR(HS_COPYRIGHT)      "\0"
+            VALUE "OriginalFilename", XSTR(HS_FNAME)          "\0"
+            VALUE "ProductName",      XSTR(HS_NAME)           "\0"
+            VALUE "ProductVersion",   XSTR(HS_VER)            "\0"
         END
     END
     BLOCK "VarFileInfo"
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -459,8 +459,8 @@
 
   _max_workers = MAX2(_max_workers, 1U);
   _workers = new ShenandoahWorkGang("Shenandoah GC Threads", _max_workers,
-                            /* are_GC_task_threads */true,
-                            /* are_ConcurrentGC_threads */false);
+                            /* are_GC_task_threads */ true,
+                            /* are_ConcurrentGC_threads */ true);
   if (_workers == NULL) {
     vm_exit_during_initialization("Failed necessary allocation.");
   } else {
@@ -470,7 +470,8 @@
   if (ShenandoahParallelSafepointThreads > 1) {
     _safepoint_workers = new ShenandoahWorkGang("Safepoint Cleanup Thread",
                                                 ShenandoahParallelSafepointThreads,
-                                                false, false);
+                      /* are_GC_task_threads */ false,
+                 /* are_ConcurrentGC_threads */ false);
     _safepoint_workers->initialize_workers();
   }
 }
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp	Sat Apr 13 07:52:21 2019 -0400
@@ -115,11 +115,6 @@
 };
 #endif
 
-class ShenandoahAlwaysTrueClosure : public BoolObjectClosure {
-public:
-  bool do_object_b(oop p) { return true; }
-};
-
 class ShenandoahForwardedIsAliveClosure: public BoolObjectClosure {
 private:
   ShenandoahMarkingContext* const _mark_context;
--- a/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp	Sat Apr 13 07:52:21 2019 -0400
@@ -51,6 +51,7 @@
   f(scan_jfr_weak_roots,                            "    S: JFR Weak Roots")            \
   f(scan_jni_weak_roots,                            "    S: JNI Weak Roots")            \
   f(scan_stringtable_roots,                         "    S: String Table Roots")        \
+  f(scan_resolved_method_table_roots,               "    S: Resolved Table Roots")      \
   f(scan_vm_weak_roots,                             "    S: VM Weak Roots")             \
   f(scan_synchronizer_roots,                        "    S: Synchronizer Roots")        \
   f(scan_management_roots,                          "    S: Management Roots")          \
@@ -76,6 +77,7 @@
   f(update_jfr_weak_roots,                          "    U: JFR Weak Roots")            \
   f(update_jni_weak_roots,                          "    U: JNI Weak Roots")            \
   f(update_stringtable_roots,                       "    U: String Table Roots")        \
+  f(update_resolved_method_table_roots,             "    U: Resolved Table Roots")      \
   f(update_vm_weak_roots,                           "    U: VM Weak Roots")             \
   f(update_synchronizer_roots,                      "    U: Synchronizer Roots")        \
   f(update_management_roots,                        "    U: Management Roots")          \
@@ -109,6 +111,7 @@
   f(evac_jfr_weak_roots,                            "    E: JFR Weak Roots")            \
   f(evac_jni_weak_roots,                            "    E: JNI Weak Roots")            \
   f(evac_stringtable_roots,                         "    E: String Table Roots")        \
+  f(evac_resolved_method_table_roots,               "    E: Resolved Table Roots")      \
   f(evac_vm_weak_roots,                             "    E: VM Weak Roots")             \
   f(evac_synchronizer_roots,                        "    E: Synchronizer Roots")        \
   f(evac_management_roots,                          "    E: Management Roots")          \
@@ -139,6 +142,7 @@
   f(final_update_jfr_weak_roots,                     "    UR: JFR Weak Roots")          \
   f(final_update_jni_weak_roots,                     "    UR: JNI Weak Roots")          \
   f(final_update_stringtable_roots,                  "    UR: String Table Roots")      \
+  f(final_update_resolved_method_table_roots,        "    UR: Resolved Table Roots")    \
   f(final_update_vm_weak_roots,                      "    UR: VM Weak Roots")           \
   f(final_update_refs_synchronizer_roots,            "    UR: Synchronizer Roots")      \
   f(final_update_refs_management_roots,              "    UR: Management Roots")        \
@@ -164,6 +168,7 @@
   f(degen_gc_update_jfr_weak_roots,                  "    DU: JFR Weak Roots")          \
   f(degen_gc_update_jni_weak_roots,                  "    DU: JNI Weak Roots")          \
   f(degen_gc_update_stringtable_roots,               "    DU: String Table Roots")      \
+  f(degen_gc_update_resolved_method_table_roots,     "    DU: Resolved Table Roots")    \
   f(degen_gc_update_vm_weak_roots,                   "    DU: VM Weak Roots")           \
   f(degen_gc_update_synchronizer_roots,              "    DU: Synchronizer Roots")      \
   f(degen_gc_update_management_roots,                "    DU: Management Roots")        \
@@ -190,6 +195,7 @@
   f(init_traversal_gc_jfr_weak_roots,                "    TI: JFR Weak Roots")          \
   f(init_traversal_gc_jni_weak_roots,                "    TI: JNI Weak Roots")          \
   f(init_traversal_gc_stringtable_roots,             "    TI: String Table Roots")      \
+  f(init_traversal_gc_resolved_method_table_roots,   "    TI: Resolved Table Roots")    \
   f(init_traversal_gc_vm_weak_roots,                 "    TI: VM Weak Roots")           \
   f(init_traversal_gc_synchronizer_roots,            "    TI: Synchronizer Roots")      \
   f(init_traversal_gc_management_roots,              "    TI: Management Roots")        \
@@ -213,6 +219,7 @@
   f(final_traversal_gc_jfr_weak_roots,               "    TF: JFR Weak Roots")          \
   f(final_traversal_gc_jni_weak_roots,               "    TF: JNI Weak Roots")          \
   f(final_traversal_gc_stringtable_roots,            "    TF: String Table Roots")      \
+  f(final_traversal_gc_resolved_method_table_roots,  "    TF: Resolved Table Roots")    \
   f(final_traversal_gc_vm_weak_roots,                "    TF: VM Weak Roots")           \
   f(final_traversal_gc_synchronizer_roots,           "    TF: Synchronizer Roots")      \
   f(final_traversal_gc_management_roots,             "    TF: Management Roots")        \
@@ -225,24 +232,25 @@
   f(final_traversal_gc_termination,                  "    TF:   Termination")           \
                                                                                         \
   /* Per-thread timer block, should have "roots" counters in consistent order */        \
-  f(final_traversal_update_roots,                    "  Update Roots")                  \
-  f(final_traversal_update_thread_roots,             "    TU: Thread Roots")            \
-  f(final_traversal_update_code_roots,               "    TU: Code Cache Roots")        \
-  f(final_traversal_update_universe_roots,           "    TU: Universe Roots")          \
-  f(final_traversal_update_jni_roots,                "    TU: JNI Roots")               \
-  f(final_traversal_update_jvmti_weak_roots,         "    TU: JVMTI Weak Roots")        \
-  f(final_traversal_update_jfr_weak_roots,           "    TU: JFR Weak Roots")          \
-  f(final_traversal_update_jni_weak_roots,           "    TU: JNI Weak Roots")          \
-  f(final_traversal_update_stringtable_roots,        "    TU: String Table Roots")      \
-  f(final_traversal_update_vm_weak_roots,            "    TU: VM Weak Roots")           \
-  f(final_traversal_update_synchronizer_roots,       "    TU: Synchronizer Roots")      \
-  f(final_traversal_update_management_roots,         "    TU: Management Roots")        \
-  f(final_traversal_update_system_dict_roots,        "    TU: System Dict Roots")       \
-  f(final_traversal_update_cldg_roots,               "    TU: CLDG Roots")              \
-  f(final_traversal_update_jvmti_roots,              "    TU: JVMTI Roots")             \
-  f(final_traversal_update_string_dedup_table_roots, "    TU: Dedup Table Roots")       \
-  f(final_traversal_update_string_dedup_queue_roots, "    TU: Dedup Queue Roots")       \
-  f(final_traversal_update_finish_queues,            "    TU: Finish Queues")           \
+  f(final_traversal_update_roots,                       "  Update Roots")               \
+  f(final_traversal_update_thread_roots,                "    TU: Thread Roots")         \
+  f(final_traversal_update_code_roots,                  "    TU: Code Cache Roots")     \
+  f(final_traversal_update_universe_roots,              "    TU: Universe Roots")       \
+  f(final_traversal_update_jni_roots,                   "    TU: JNI Roots")            \
+  f(final_traversal_update_jvmti_weak_roots,            "    TU: JVMTI Weak Roots")     \
+  f(final_traversal_update_jfr_weak_roots,              "    TU: JFR Weak Roots")       \
+  f(final_traversal_update_jni_weak_roots,              "    TU: JNI Weak Roots")       \
+  f(final_traversal_update_stringtable_roots,           "    TU: String Table Roots")   \
+  f(final_traversal_update_resolved_method_table_roots, "    TU: Resolved Table Roots") \
+  f(final_traversal_update_vm_weak_roots,               "    TU: VM Weak Roots")        \
+  f(final_traversal_update_synchronizer_roots,          "    TU: Synchronizer Roots")   \
+  f(final_traversal_update_management_roots,            "    TU: Management Roots")     \
+  f(final_traversal_update_system_dict_roots,           "    TU: System Dict Roots")    \
+  f(final_traversal_update_cldg_roots,                  "    TU: CLDG Roots")           \
+  f(final_traversal_update_jvmti_roots,                 "    TU: JVMTI Roots")          \
+  f(final_traversal_update_string_dedup_table_roots,    "    TU: Dedup Table Roots")    \
+  f(final_traversal_update_string_dedup_queue_roots,    "    TU: Dedup Queue Roots")    \
+  f(final_traversal_update_finish_queues,               "    TU: Finish Queues")        \
                                                                                         \
   f(traversal_gc_cleanup,                            "  Cleanup")                       \
                                                                                         \
@@ -261,6 +269,7 @@
   f(full_gc_jfr_weak_roots,                          "    F: JFR Weak Roots")           \
   f(full_gc_jni_weak_roots,                          "    F: JNI Weak Roots")           \
   f(full_gc_stringtable_roots,                       "    F: String Table Roots")       \
+  f(full_gc_resolved_method_table_roots,             "    F: Resolved Table Roots")     \
   f(full_gc_vm_weak_roots,                           "    F: VM Weak Roots")            \
   f(full_gc_synchronizer_roots,                      "    F: Synchronizer Roots")       \
   f(full_gc_management_roots,                        "    F: Management Roots")         \
@@ -311,23 +320,24 @@
   // end
 
 #define SHENANDOAH_GC_PAR_PHASE_DO(f)                           \
-  f(ThreadRoots,             "Thread Roots (ms):")              \
-  f(CodeCacheRoots,          "CodeCache Roots (ms):")           \
-  f(UniverseRoots,           "Universe Roots (ms):")            \
-  f(JNIRoots,                "JNI Handles Roots (ms):")         \
-  f(JVMTIWeakRoots,          "JVMTI Weak Roots (ms):")          \
-  f(JFRWeakRoots,            "JFR Weak Roots (ms):")            \
-  f(JNIWeakRoots,            "JNI Weak Roots (ms):")            \
-  f(StringTableRoots,        "StringTable Roots(ms):")          \
-  f(VMWeakRoots,             "VM Weak Roots(ms)")               \
-  f(ObjectSynchronizerRoots, "ObjectSynchronizer Roots (ms):")  \
-  f(ManagementRoots,         "Management Roots (ms):")          \
-  f(SystemDictionaryRoots,   "SystemDictionary Roots (ms):")    \
-  f(CLDGRoots,               "CLDG Roots (ms):")                \
-  f(JVMTIRoots,              "JVMTI Roots (ms):")               \
-  f(StringDedupTableRoots,   "String Dedup Table Roots (ms):")  \
-  f(StringDedupQueueRoots,   "String Dedup Queue Roots (ms):")  \
-  f(FinishQueues,            "Finish Queues (ms):")             \
+  f(ThreadRoots,              "Thread Roots (ms):")              \
+  f(CodeCacheRoots,           "CodeCache Roots (ms):")           \
+  f(UniverseRoots,            "Universe Roots (ms):")            \
+  f(JNIRoots,                 "JNI Handles Roots (ms):")         \
+  f(JVMTIWeakRoots,           "JVMTI Weak Roots (ms):")          \
+  f(JFRWeakRoots,             "JFR Weak Roots (ms):")            \
+  f(JNIWeakRoots,             "JNI Weak Roots (ms):")            \
+  f(StringTableRoots,         "StringTable Roots(ms):")          \
+  f(ResolvedMethodTableRoots, "Resolved Table Roots(ms):")       \
+  f(VMWeakRoots,              "VM Weak Roots(ms)")               \
+  f(ObjectSynchronizerRoots,  "ObjectSynchronizer Roots (ms):")  \
+  f(ManagementRoots,          "Management Roots (ms):")          \
+  f(SystemDictionaryRoots,    "SystemDictionary Roots (ms):")    \
+  f(CLDGRoots,                "CLDG Roots (ms):")                \
+  f(JVMTIRoots,               "JVMTI Roots (ms):")               \
+  f(StringDedupTableRoots,    "String Dedup Table Roots (ms):")  \
+  f(StringDedupQueueRoots,    "String Dedup Queue Roots (ms):")  \
+  f(FinishQueues,             "Finish Queues (ms):")             \
   // end
 
 class ShenandoahPhaseTimings : public CHeapObj<mtGC> {
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -48,14 +48,15 @@
 
 static const struct PhaseMap phase_mapping[] = {
 #if INCLUDE_JVMTI
-  {WeakProcessorPhases::jvmti,       ShenandoahPhaseTimings::JVMTIWeakRoots},
+  {WeakProcessorPhases::jvmti,                 ShenandoahPhaseTimings::JVMTIWeakRoots},
 #endif
 #if INCLUDE_JFR
-  {WeakProcessorPhases::jfr,         ShenandoahPhaseTimings::JFRWeakRoots},
+  {WeakProcessorPhases::jfr,                   ShenandoahPhaseTimings::JFRWeakRoots},
 #endif
-  {WeakProcessorPhases::jni,         ShenandoahPhaseTimings::JNIWeakRoots},
-  {WeakProcessorPhases::stringtable, ShenandoahPhaseTimings::StringTableRoots},
-  {WeakProcessorPhases::vm,          ShenandoahPhaseTimings::VMWeakRoots}
+  {WeakProcessorPhases::jni,                   ShenandoahPhaseTimings::JNIWeakRoots},
+  {WeakProcessorPhases::stringtable,           ShenandoahPhaseTimings::StringTableRoots},
+  {WeakProcessorPhases::resolved_method_table, ShenandoahPhaseTimings::ResolvedMethodTableRoots},
+  {WeakProcessorPhases::vm,                    ShenandoahPhaseTimings::VMWeakRoots}
 };
 
 STATIC_ASSERT(sizeof(phase_mapping) / sizeof(PhaseMap) == WeakProcessorPhases::phase_count);
@@ -64,7 +65,6 @@
                                                  ShenandoahPhaseTimings::Phase phase) :
   _process_strong_tasks(new SubTasksDone(SHENANDOAH_RP_PS_NumElements)),
   _srs(n_workers),
-  _par_state_string(StringTable::weak_storage()),
   _phase(phase),
   _coderoots_all_iterator(ShenandoahCodeRoots::iterator()),
   _weak_processor_timings(n_workers),
--- a/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahRootProcessor.hpp	Sat Apr 13 07:52:21 2019 -0400
@@ -56,7 +56,6 @@
 class ShenandoahRootProcessor : public StackObj {
   SubTasksDone* _process_strong_tasks;
   StrongRootsScope _srs;
-  OopStorage::ParState<false, false> _par_state_string;
   ShenandoahPhaseTimings::Phase _phase;
   ParallelCLDRootIterator _cld_iterator;
   ShenandoahAllCodeRootsIterator _coderoots_all_iterator;
--- a/src/hotspot/share/gc/shenandoah/shenandoahStringDedup.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahStringDedup.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -92,7 +92,7 @@
 void ShenandoahStringDedup::oops_do_slow(OopClosure* cl) {
   assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint");
   assert(is_enabled(), "String deduplication not enabled");
-  ShenandoahAlwaysTrueClosure always_true;
+  AlwaysTrueClosure always_true;
   StringDedupUnlinkOrOopsDoClosure sd_cl(&always_true, cl);
   StringDedupQueue::unlink_or_oops_do(&sd_cl);
   StringDedupTable::unlink_or_oops_do(&sd_cl, 0);
--- a/src/hotspot/share/gc/shenandoah/shenandoahTimingTracker.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahTimingTracker.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -76,8 +76,11 @@
          phase == ShenandoahPhaseTimings::full_gc_weakrefs_termination,
          "Only these phases");
 
-  assert(Thread::current()->is_VM_thread() || Thread::current()->is_ConcurrentGC_thread(),
-    "Called from wrong thread");
+  assert(!Thread::current()->is_Worker_thread() &&
+             (Thread::current()->is_VM_thread() ||
+              Thread::current()->is_ConcurrentGC_thread()),
+        "Called from wrong thread");
+
   _current_termination_phase = phase;
   ShenandoahHeap::heap()->phase_timings()->termination_times()->reset();
 }
--- a/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/gc/shenandoah/shenandoahUtils.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -100,9 +100,10 @@
 
 ShenandoahGCPhase::ShenandoahGCPhase(const ShenandoahPhaseTimings::Phase phase) :
   _heap(ShenandoahHeap::heap()), _phase(phase) {
-  assert(Thread::current()->is_VM_thread() ||
-         Thread::current()->is_ConcurrentGC_thread(),
-        "Must be set by these threads");
+   assert(!Thread::current()->is_Worker_thread() &&
+              (Thread::current()->is_VM_thread() ||
+               Thread::current()->is_ConcurrentGC_thread()),
+          "Must be set by these threads");
   _parent_phase = _current_phase;
   _current_phase = phase;
 
--- a/src/hotspot/share/interpreter/interpreterRuntime.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -156,7 +156,7 @@
 // Constants
 
 
-IRT_ENTRY(void, InterpreterRuntime::ldc(JavaThread* thread, bool wide))
+JRT_ENTRY(void, InterpreterRuntime::ldc(JavaThread* thread, bool wide))
   // access constant pool
   LastFrameAccessor last_frame(thread);
   ConstantPool* pool = last_frame.method()->constants();
@@ -167,9 +167,9 @@
   Klass* klass = pool->klass_at(index, CHECK);
     oop java_class = klass->java_mirror();
     thread->set_vm_result(java_class);
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::Code bytecode)) {
+JRT_ENTRY(void, InterpreterRuntime::resolve_ldc(JavaThread* thread, Bytecodes::Code bytecode)) {
   assert(bytecode == Bytecodes::_ldc ||
          bytecode == Bytecodes::_ldc_w ||
          bytecode == Bytecodes::_ldc2_w ||
@@ -219,13 +219,13 @@
     thread->set_vm_result_2((Metadata*)flags);
   }
 }
-IRT_END
+JRT_END
 
 
 //------------------------------------------------------------------------------------------------------------------------
 // Allocation
 
-IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index))
+JRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index))
   Klass* k = pool->klass_at(index, CHECK);
   InstanceKlass* klass = InstanceKlass::cast(k);
 
@@ -251,23 +251,23 @@
   //       because the _breakpoint bytecode would be lost.
   oop obj = klass->allocate_instance(CHECK);
   thread->set_vm_result(obj);
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* thread, BasicType type, jint size))
+JRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* thread, BasicType type, jint size))
   oop obj = oopFactory::new_typeArray(type, size, CHECK);
   thread->set_vm_result(obj);
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* thread, ConstantPool* pool, int index, jint size))
+JRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* thread, ConstantPool* pool, int index, jint size))
   Klass*    klass = pool->klass_at(index, CHECK);
   objArrayOop obj = oopFactory::new_objArray(klass, size, CHECK);
   thread->set_vm_result(obj);
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address))
+JRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address))
   // We may want to pass in more arguments - could make this slightly faster
   LastFrameAccessor last_frame(thread);
   ConstantPool* constants = last_frame.method()->constants();
@@ -292,18 +292,18 @@
   }
   oop obj = ArrayKlass::cast(klass)->multi_allocate(nof_dims, dims, CHECK);
   thread->set_vm_result(obj);
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::register_finalizer(JavaThread* thread, oopDesc* obj))
+JRT_ENTRY(void, InterpreterRuntime::register_finalizer(JavaThread* thread, oopDesc* obj))
   assert(oopDesc::is_oop(obj), "must be a valid oop");
   assert(obj->klass()->has_finalizer(), "shouldn't be here otherwise");
   InstanceKlass::register_finalizer(instanceOop(obj), CHECK);
-IRT_END
+JRT_END
 
 
 // Quicken instance-of and check-cast bytecodes
-IRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* thread))
+JRT_ENTRY(void, InterpreterRuntime::quicken_io_cc(JavaThread* thread))
   // Force resolving; quicken the bytecode
   LastFrameAccessor last_frame(thread);
   int which = last_frame.get_index_u2(Bytecodes::_checkcast);
@@ -314,7 +314,7 @@
   // assert( cpool->tag_at(which).is_unresolved_klass(), "should only come here to quicken bytecodes" );
   Klass* klass = cpool->klass_at(which, CHECK);
   thread->set_vm_result_2(klass);
-IRT_END
+JRT_END
 
 
 //------------------------------------------------------------------------------------------------------------------------
@@ -354,10 +354,10 @@
 
 #ifdef CC_INTERP
 // As legacy note_trap, but we have more arguments.
-IRT_ENTRY(void, InterpreterRuntime::note_trap(JavaThread* thread, int reason, Method *method, int trap_bci))
+JRT_ENTRY(void, InterpreterRuntime::note_trap(JavaThread* thread, int reason, Method *method, int trap_bci))
   methodHandle trap_method(method);
   note_trap_inner(thread, reason, trap_method, trap_bci, THREAD);
-IRT_END
+JRT_END
 
 // Class Deoptimization is not visible in BytecodeInterpreter, so we need a wrapper
 // for each exception.
@@ -394,16 +394,16 @@
 // space left we use the pre-allocated & pre-initialized StackOverflowError
 // klass to create an stack overflow error instance.  We do not call its
 // constructor for the same reason (it is empty, anyway).
-IRT_ENTRY(void, InterpreterRuntime::throw_StackOverflowError(JavaThread* thread))
+JRT_ENTRY(void, InterpreterRuntime::throw_StackOverflowError(JavaThread* thread))
   Handle exception = get_preinitialized_exception(
                                  SystemDictionary::StackOverflowError_klass(),
                                  CHECK);
   // Increment counter for hs_err file reporting
   Atomic::inc(&Exceptions::_stack_overflow_errors);
   THROW_HANDLE(exception);
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::throw_delayed_StackOverflowError(JavaThread* thread))
+JRT_ENTRY(void, InterpreterRuntime::throw_delayed_StackOverflowError(JavaThread* thread))
   Handle exception = get_preinitialized_exception(
                                  SystemDictionary::StackOverflowError_klass(),
                                  CHECK);
@@ -412,9 +412,9 @@
   // Increment counter for hs_err file reporting
   Atomic::inc(&Exceptions::_stack_overflow_errors);
   THROW_HANDLE(exception);
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::create_exception(JavaThread* thread, char* name, char* message))
+JRT_ENTRY(void, InterpreterRuntime::create_exception(JavaThread* thread, char* name, char* message))
   // lookup exception klass
   TempNewSymbol s = SymbolTable::new_symbol(name, CHECK);
   if (ProfileTraps) {
@@ -427,10 +427,10 @@
   // create exception
   Handle exception = Exceptions::new_exception(thread, s, message);
   thread->set_vm_result(exception());
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::create_klass_exception(JavaThread* thread, char* name, oopDesc* obj))
+JRT_ENTRY(void, InterpreterRuntime::create_klass_exception(JavaThread* thread, char* name, oopDesc* obj))
   // Produce the error message first because note_trap can safepoint
   ResourceMark rm(thread);
   const char* klass_name = obj->klass()->external_name();
@@ -442,9 +442,9 @@
   // create exception, with klass name as detail message
   Handle exception = Exceptions::new_exception(thread, s, klass_name);
   thread->set_vm_result(exception());
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException(JavaThread* thread, arrayOopDesc* a, jint index))
+JRT_ENTRY(void, InterpreterRuntime::throw_ArrayIndexOutOfBoundsException(JavaThread* thread, arrayOopDesc* a, jint index))
   // Produce the error message first because note_trap can safepoint
   ResourceMark rm(thread);
   stringStream ss;
@@ -455,9 +455,9 @@
   }
 
   THROW_MSG(vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), ss.as_string());
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::throw_ClassCastException(
+JRT_ENTRY(void, InterpreterRuntime::throw_ClassCastException(
   JavaThread* thread, oopDesc* obj))
 
   // Produce the error message first because note_trap can safepoint
@@ -471,7 +471,7 @@
 
   // create exception
   THROW_MSG(vmSymbols::java_lang_ClassCastException(), message);
-IRT_END
+JRT_END
 
 // exception_handler_for_exception(...) returns the continuation address,
 // the exception oop (via TLS) and sets the bci/bcp for the continuation.
@@ -481,7 +481,7 @@
 // bci where the exception happened. If the exception was propagated back
 // from a call, the expression stack contains the values for the bci at the
 // invoke w/o arguments (i.e., as if one were inside the call).
-IRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThread* thread, oopDesc* exception))
+JRT_ENTRY(address, InterpreterRuntime::exception_handler_for_exception(JavaThread* thread, oopDesc* exception))
 
   LastFrameAccessor last_frame(thread);
   Handle             h_exception(thread, exception);
@@ -622,18 +622,18 @@
 
   thread->set_vm_result(h_exception());
   return continuation;
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::throw_pending_exception(JavaThread* thread))
+JRT_ENTRY(void, InterpreterRuntime::throw_pending_exception(JavaThread* thread))
   assert(thread->has_pending_exception(), "must only ne called if there's an exception pending");
   // nothing to do - eventually we should remove this code entirely (see comments @ call sites)
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodError(JavaThread* thread))
+JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodError(JavaThread* thread))
   THROW(vmSymbols::java_lang_AbstractMethodError());
-IRT_END
+JRT_END
 
 // This method is called from the "abstract_entry" of the interpreter.
 // At that point, the arguments have already been removed from the stack
@@ -641,28 +641,28 @@
 // on some platforms the receiver still resides in a register...). Thus,
 // we have no choice but print an error message not containing the receiver
 // type.
-IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorWithMethod(JavaThread* thread,
+JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorWithMethod(JavaThread* thread,
                                                                         Method* missingMethod))
   ResourceMark rm(thread);
   assert(missingMethod != NULL, "sanity");
   methodHandle m(thread, missingMethod);
   LinkResolver::throw_abstract_method_error(m, THREAD);
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorVerbose(JavaThread* thread,
+JRT_ENTRY(void, InterpreterRuntime::throw_AbstractMethodErrorVerbose(JavaThread* thread,
                                                                      Klass* recvKlass,
                                                                      Method* missingMethod))
   ResourceMark rm(thread);
   methodHandle mh = methodHandle(thread, missingMethod);
   LinkResolver::throw_abstract_method_error(mh, recvKlass, THREAD);
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* thread))
+JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeError(JavaThread* thread))
   THROW(vmSymbols::java_lang_IncompatibleClassChangeError());
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose(JavaThread* thread,
+JRT_ENTRY(void, InterpreterRuntime::throw_IncompatibleClassChangeErrorVerbose(JavaThread* thread,
                                                                               Klass* recvKlass,
                                                                               Klass* interfaceKlass))
   ResourceMark rm(thread);
@@ -673,7 +673,7 @@
                recvKlass ? recvKlass->external_name() : "NULL",
                interfaceKlass ? interfaceKlass->external_name() : "NULL");
   THROW_MSG(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
-IRT_END
+JRT_END
 
 //------------------------------------------------------------------------------------------------------------------------
 // Fields
@@ -760,7 +760,7 @@
 //%note synchronization_3
 
 //%note monitor_1
-IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem))
+JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorenter(JavaThread* thread, BasicObjectLock* elem))
 #ifdef ASSERT
   thread->last_frame().interpreter_frame_verify_monitor(elem);
 #endif
@@ -781,11 +781,11 @@
 #ifdef ASSERT
   thread->last_frame().interpreter_frame_verify_monitor(elem);
 #endif
-IRT_END
+JRT_END
 
 
 //%note monitor_1
-IRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorexit(JavaThread* thread, BasicObjectLock* elem))
+JRT_ENTRY_NO_ASYNC(void, InterpreterRuntime::monitorexit(JavaThread* thread, BasicObjectLock* elem))
 #ifdef ASSERT
   thread->last_frame().interpreter_frame_verify_monitor(elem);
 #endif
@@ -802,15 +802,15 @@
 #ifdef ASSERT
   thread->last_frame().interpreter_frame_verify_monitor(elem);
 #endif
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* thread))
+JRT_ENTRY(void, InterpreterRuntime::throw_illegal_monitor_state_exception(JavaThread* thread))
   THROW(vmSymbols::java_lang_IllegalMonitorStateException());
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* thread))
+JRT_ENTRY(void, InterpreterRuntime::new_illegal_monitor_state_exception(JavaThread* thread))
   // Returns an illegal exception to install into the current thread. The
   // pending_exception flag is cleared so normal exception handling does not
   // trigger. Any current installed exception will be overwritten. This
@@ -826,23 +826,23 @@
                        CATCH);
   }
   thread->set_vm_result(exception());
-IRT_END
+JRT_END
 
 
 //------------------------------------------------------------------------------------------------------------------------
 // Invokes
 
-IRT_ENTRY(Bytecodes::Code, InterpreterRuntime::get_original_bytecode_at(JavaThread* thread, Method* method, address bcp))
+JRT_ENTRY(Bytecodes::Code, InterpreterRuntime::get_original_bytecode_at(JavaThread* thread, Method* method, address bcp))
   return method->orig_bytecode_at(method->bci_from(bcp));
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* thread, Method* method, address bcp, Bytecodes::Code new_code))
+JRT_ENTRY(void, InterpreterRuntime::set_original_bytecode_at(JavaThread* thread, Method* method, address bcp, Bytecodes::Code new_code))
   method->set_orig_bytecode_at(method->bci_from(bcp), new_code);
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* thread, Method* method, address bcp))
+JRT_ENTRY(void, InterpreterRuntime::_breakpoint(JavaThread* thread, Method* method, address bcp))
   JvmtiExport::post_raw_breakpoint(thread, method, bcp);
-IRT_END
+JRT_END
 
 void InterpreterRuntime::resolve_invoke(JavaThread* thread, Bytecodes::Code bytecode) {
   Thread* THREAD = thread;
@@ -998,7 +998,7 @@
 // This function is the interface to the assembly code. It returns the resolved
 // cpCache entry.  This doesn't safepoint, but the helper routines safepoint.
 // This function will check for redefinition!
-IRT_ENTRY(void, InterpreterRuntime::resolve_from_cache(JavaThread* thread, Bytecodes::Code bytecode)) {
+JRT_ENTRY(void, InterpreterRuntime::resolve_from_cache(JavaThread* thread, Bytecodes::Code bytecode)) {
   switch (bytecode) {
   case Bytecodes::_getstatic:
   case Bytecodes::_putstatic:
@@ -1023,7 +1023,7 @@
     break;
   }
 }
-IRT_END
+JRT_END
 
 //------------------------------------------------------------------------------------------------------------------------
 // Miscellaneous
@@ -1069,7 +1069,7 @@
   return nm;
 }
 
-IRT_ENTRY(nmethod*,
+JRT_ENTRY(nmethod*,
           InterpreterRuntime::frequency_counter_overflow_inner(JavaThread* thread, address branch_bcp))
   // use UnlockFlagSaver to clear and restore the _do_not_unlock_if_synchronized
   // flag, in case this method triggers classloading which will call into Java.
@@ -1113,17 +1113,17 @@
     }
   }
   return osr_nm;
-IRT_END
+JRT_END
 
-IRT_LEAF(jint, InterpreterRuntime::bcp_to_di(Method* method, address cur_bcp))
+JRT_LEAF(jint, InterpreterRuntime::bcp_to_di(Method* method, address cur_bcp))
   assert(ProfileInterpreter, "must be profiling interpreter");
   int bci = method->bci_from(cur_bcp);
   MethodData* mdo = method->method_data();
   if (mdo == NULL)  return 0;
   return mdo->bci_to_di(bci);
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::profile_method(JavaThread* thread))
+JRT_ENTRY(void, InterpreterRuntime::profile_method(JavaThread* thread))
   // use UnlockFlagSaver to clear and restore the _do_not_unlock_if_synchronized
   // flag, in case this method triggers classloading which will call into Java.
   UnlockFlagSaver fs(thread);
@@ -1138,11 +1138,11 @@
     CLEAR_PENDING_EXCEPTION;
     // and fall through...
   }
-IRT_END
+JRT_END
 
 
 #ifdef ASSERT
-IRT_LEAF(void, InterpreterRuntime::verify_mdp(Method* method, address bcp, address mdp))
+JRT_LEAF(void, InterpreterRuntime::verify_mdp(Method* method, address bcp, address mdp))
   assert(ProfileInterpreter, "must be profiling interpreter");
 
   MethodData* mdo = method->method_data();
@@ -1169,10 +1169,10 @@
     method->print_codes();
   }
   assert(mdp == mdp2, "wrong mdp");
-IRT_END
+JRT_END
 #endif // ASSERT
 
-IRT_ENTRY(void, InterpreterRuntime::update_mdp_for_ret(JavaThread* thread, int return_bci))
+JRT_ENTRY(void, InterpreterRuntime::update_mdp_for_ret(JavaThread* thread, int return_bci))
   assert(ProfileInterpreter, "must be profiling interpreter");
   ResourceMark rm(thread);
   HandleMark hm(thread);
@@ -1191,24 +1191,24 @@
   RetData* rdata = data->as_RetData();
   address new_mdp = rdata->fixup_ret(return_bci, h_mdo);
   last_frame.set_mdp(new_mdp);
-IRT_END
+JRT_END
 
-IRT_ENTRY(MethodCounters*, InterpreterRuntime::build_method_counters(JavaThread* thread, Method* m))
+JRT_ENTRY(MethodCounters*, InterpreterRuntime::build_method_counters(JavaThread* thread, Method* m))
   MethodCounters* mcs = Method::build_method_counters(m, thread);
   if (HAS_PENDING_EXCEPTION) {
     assert((PENDING_EXCEPTION->is_a(SystemDictionary::OutOfMemoryError_klass())), "we expect only an OOM error here");
     CLEAR_PENDING_EXCEPTION;
   }
   return mcs;
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::at_safepoint(JavaThread* thread))
+JRT_ENTRY(void, InterpreterRuntime::at_safepoint(JavaThread* thread))
   // We used to need an explict preserve_arguments here for invoke bytecodes. However,
   // stack traversal automatically takes care of preserving arguments for invoke, so
   // this is no longer needed.
 
-  // IRT_END does an implicit safepoint check, hence we are guaranteed to block
+  // JRT_END does an implicit safepoint check, hence we are guaranteed to block
   // if this is called during a safepoint
 
   if (JvmtiExport::should_post_single_step()) {
@@ -1218,9 +1218,9 @@
     LastFrameAccessor last_frame(thread);
     JvmtiExport::at_single_stepping_point(thread, last_frame.method(), last_frame.bcp());
   }
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread *thread, oopDesc* obj,
+JRT_ENTRY(void, InterpreterRuntime::post_field_access(JavaThread *thread, oopDesc* obj,
 ConstantPoolCacheEntry *cp_entry))
 
   // check the access_flags for the field in the klass
@@ -1241,9 +1241,9 @@
   jfieldID fid = jfieldIDWorkaround::to_jfieldID(cp_entry_f1, cp_entry->f2_as_index(), is_static);
   LastFrameAccessor last_frame(thread);
   JvmtiExport::post_field_access(thread, last_frame.method(), last_frame.bcp(), cp_entry_f1, h_obj, fid);
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread,
+JRT_ENTRY(void, InterpreterRuntime::post_field_modification(JavaThread *thread,
   oopDesc* obj, ConstantPoolCacheEntry *cp_entry, jvalue *value))
 
   Klass* k = cp_entry->f1_as_klass();
@@ -1298,24 +1298,24 @@
   LastFrameAccessor last_frame(thread);
   JvmtiExport::post_raw_field_modification(thread, last_frame.method(), last_frame.bcp(), ik, h_obj,
                                            fid, sig_type, &fvalue);
-IRT_END
+JRT_END
 
-IRT_ENTRY(void, InterpreterRuntime::post_method_entry(JavaThread *thread))
+JRT_ENTRY(void, InterpreterRuntime::post_method_entry(JavaThread *thread))
   LastFrameAccessor last_frame(thread);
   JvmtiExport::post_method_entry(thread, last_frame.method(), last_frame.get_frame());
-IRT_END
+JRT_END
 
 
-IRT_ENTRY(void, InterpreterRuntime::post_method_exit(JavaThread *thread))
+JRT_ENTRY(void, InterpreterRuntime::post_method_exit(JavaThread *thread))
   LastFrameAccessor last_frame(thread);
   JvmtiExport::post_method_exit(thread, last_frame.method(), last_frame.get_frame());
-IRT_END
+JRT_END
 
-IRT_LEAF(int, InterpreterRuntime::interpreter_contains(address pc))
+JRT_LEAF(int, InterpreterRuntime::interpreter_contains(address pc))
 {
   return (Interpreter::contains(pc) ? 1 : 0);
 }
-IRT_END
+JRT_END
 
 
 // Implementation of SignatureHandlerLibrary
@@ -1508,7 +1508,7 @@
 address                  SignatureHandlerLibrary::_buffer       = NULL;
 
 
-IRT_ENTRY(void, InterpreterRuntime::prepare_native_call(JavaThread* thread, Method* method))
+JRT_ENTRY(void, InterpreterRuntime::prepare_native_call(JavaThread* thread, Method* method))
   methodHandle m(thread, method);
   assert(m->is_native(), "sanity check");
   // lookup native function entry point if it doesn't exist
@@ -1522,10 +1522,10 @@
   // before trying to fetch the native entry point and klass mirror.
   // We must set the signature handler last, so that multiple processors
   // preparing the same method will be sure to see non-null entry & mirror.
-IRT_END
+JRT_END
 
 #if defined(IA32) || defined(AMD64) || defined(ARM)
-IRT_LEAF(void, InterpreterRuntime::popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address))
+JRT_LEAF(void, InterpreterRuntime::popframe_move_outgoing_args(JavaThread* thread, void* src_address, void* dest_address))
   if (src_address == dest_address) {
     return;
   }
@@ -1541,7 +1541,7 @@
   int size_of_arguments = (asc.size() + (invoke.has_receiver() ? 1 : 0)); // receiver
   Copy::conjoint_jbytes(src_address, dest_address,
                        size_of_arguments * Interpreter::stackElementSize);
-IRT_END
+JRT_END
 #endif
 
 #if INCLUDE_JVMTI
@@ -1551,7 +1551,7 @@
 // The member_name argument is a saved reference (in local#0) to the member_name.
 // For backward compatibility with some JDK versions (7, 8) it can also be a direct method handle.
 // FIXME: remove DMH case after j.l.i.InvokerBytecodeGenerator code shape is updated.
-IRT_ENTRY(void, InterpreterRuntime::member_name_arg_or_null(JavaThread* thread, address member_name,
+JRT_ENTRY(void, InterpreterRuntime::member_name_arg_or_null(JavaThread* thread, address member_name,
                                                             Method* method, address bcp))
   Bytecodes::Code code = Bytecodes::code_at(method, bcp);
   if (code != Bytecodes::_invokestatic) {
@@ -1572,19 +1572,19 @@
   } else {
     thread->set_vm_result(NULL);
   }
-IRT_END
+JRT_END
 #endif // INCLUDE_JVMTI
 
 #ifndef PRODUCT
-// This must be a IRT_LEAF function because the interpreter must save registers on x86 to
+// This must be a JRT_LEAF function because the interpreter must save registers on x86 to
 // call this, which changes rsp and makes the interpreter's expression stack not walkable.
 // The generated code still uses call_VM because that will set up the frame pointer for
 // bcp and method.
-IRT_LEAF(intptr_t, InterpreterRuntime::trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2))
+JRT_LEAF(intptr_t, InterpreterRuntime::trace_bytecode(JavaThread* thread, intptr_t preserve_this_value, intptr_t tos, intptr_t tos2))
   LastFrameAccessor last_frame(thread);
   assert(last_frame.is_interpreted_frame(), "must be an interpreted frame");
   methodHandle mh(thread, last_frame.method());
   BytecodeTracer::trace(mh, last_frame.bcp(), tos, tos2);
   return preserve_this_value;
-IRT_END
+JRT_END
 #endif // !PRODUCT
--- a/src/hotspot/share/runtime/interfaceSupport.inline.hpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/runtime/interfaceSupport.inline.hpp	Sat Apr 13 07:52:21 2019 -0400
@@ -422,30 +422,6 @@
   /* begin of body */
 
 
-// Definitions for IRT (Interpreter Runtime)
-// (thread is an argument passed in to all these routines)
-
-#define IRT_ENTRY(result_type, header)                               \
-  result_type header {                                               \
-    ThreadInVMfromJava __tiv(thread);                                \
-    VM_ENTRY_BASE(result_type, header, thread)                       \
-    debug_only(VMEntryWrapper __vew;)
-
-
-#define IRT_LEAF(result_type, header)                                \
-  result_type header {                                               \
-    VM_LEAF_BASE(result_type, header)                                \
-    debug_only(NoSafepointVerifier __nspv(true);)
-
-
-#define IRT_ENTRY_NO_ASYNC(result_type, header)                      \
-  result_type header {                                               \
-    ThreadInVMfromJavaNoAsyncException __tiv(thread);                \
-    VM_ENTRY_BASE(result_type, header, thread)                       \
-    debug_only(VMEntryWrapper __vew;)
-
-#define IRT_END }
-
 #define JRT_ENTRY(result_type, header)                               \
   result_type header {                                               \
     ThreadInVMfromJava __tiv(thread);                                \
--- a/src/hotspot/share/runtime/sharedRuntime.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/runtime/sharedRuntime.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1918,7 +1918,7 @@
 // where we went int -> i2c -> c2i and so the caller could in fact be
 // interpreted. If the caller is compiled we attempt to patch the caller
 // so he no longer calls into the interpreter.
-IRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address caller_pc))
+JRT_LEAF(void, SharedRuntime::fixup_callers_callsite(Method* method, address caller_pc))
   Method* moop(method);
 
   address entry_point = moop->from_compiled_entry_no_trampoline();
@@ -1987,7 +1987,7 @@
       }
     }
   }
-IRT_END
+JRT_END
 
 
 // same as JVM_Arraycopy, but called directly from compiled code
--- a/src/hotspot/share/runtime/threadSMR.cpp	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/hotspot/share/runtime/threadSMR.cpp	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -590,12 +590,9 @@
 }
 
 void ThreadsList::dec_nested_handle_cnt() {
-  // The decrement needs to be MO_ACQ_REL. At the moment, the Atomic::dec
-  // backend on PPC does not yet conform to these requirements. Therefore
-  // the decrement is simulated with an Atomic::sub(1, &addr).
-  // Without this MO_ACQ_REL Atomic::dec simulation, the nested SMR mechanism
-  // is not generally safe to use.
-  Atomic::sub(1, &_nested_handle_cnt);
+  // The decrement only needs to be MO_ACQ_REL since the reference
+  // counter is volatile (and the hazard ptr is already NULL).
+  Atomic::dec(&_nested_handle_cnt);
 }
 
 int ThreadsList::find_index_of_JavaThread(JavaThread *target) {
@@ -626,19 +623,9 @@
 }
 
 void ThreadsList::inc_nested_handle_cnt() {
-  // The increment needs to be MO_SEQ_CST. At the moment, the Atomic::inc
-  // backend on PPC does not yet conform to these requirements. Therefore
-  // the increment is simulated with a load phi; cas phi + 1; loop.
-  // Without this MO_SEQ_CST Atomic::inc simulation, the nested SMR mechanism
-  // is not generally safe to use.
-  intx sample = OrderAccess::load_acquire(&_nested_handle_cnt);
-  for (;;) {
-    if (Atomic::cmpxchg(sample + 1, &_nested_handle_cnt, sample) == sample) {
-      return;
-    } else {
-      sample = OrderAccess::load_acquire(&_nested_handle_cnt);
-    }
-  }
+  // The increment needs to be MO_SEQ_CST so that the reference counter
+  // update is seen before the subsequent hazard ptr update.
+  Atomic::inc(&_nested_handle_cnt);
 }
 
 bool ThreadsList::includes(const JavaThread * const p) const {
--- a/src/java.base/share/classes/java/lang/Class.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/java.base/share/classes/java/lang/Class.java	Sat Apr 13 07:52:21 2019 -0400
@@ -277,8 +277,7 @@
                           .collect(Collectors.joining(",", "<", ">")));
             }
 
-            for (int i = 0; i < arrayDepth; i++)
-                sb.append("[]");
+            if (arrayDepth > 0) sb.append("[]".repeat(arrayDepth));
 
             return sb.toString();
         }
@@ -1589,12 +1588,7 @@
                     dimensions++;
                     cl = cl.getComponentType();
                 } while (cl.isArray());
-                StringBuilder sb = new StringBuilder();
-                sb.append(cl.getName());
-                for (int i = 0; i < dimensions; i++) {
-                    sb.append("[]");
-                }
-                return sb.toString();
+                return cl.getName() + "[]".repeat(dimensions);
             } catch (Throwable e) { /*FALLTHRU*/ }
         }
         return getName();
@@ -3418,15 +3412,12 @@
      * Helper method to get the method name from arguments.
      */
     private String methodToString(String name, Class<?>[] argTypes) {
-        StringBuilder sb = new StringBuilder();
-        sb.append(getName() + "." + name + "(");
-        if (argTypes != null) {
-            sb.append(Arrays.stream(argTypes)
-                      .map(c -> (c == null) ? "null" : c.getName())
-                      .collect(Collectors.joining(",")));
-        }
-        sb.append(")");
-        return sb.toString();
+        return getName() + '.' + name +
+                ((argTypes == null || argTypes.length == 0) ?
+                "()" :
+                Arrays.stream(argTypes)
+                        .map(c -> c == null ? "null" : c.getName())
+                        .collect(Collectors.joining(",", "(", ")")));
     }
 
     /** use serialVersionUID from JDK 1.1 for interoperability */
--- a/src/java.base/windows/native/common/version.rc	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/java.base/windows/native/common/version.rc	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 //
-// Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
+// Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 //
 // This code is free software; you can redistribute it and/or modify it
@@ -55,15 +55,15 @@
     BEGIN
         BLOCK "000004b0"
         BEGIN
-            VALUE "CompanyName",      XSTR(JDK_COMPANY)       "\0"
-            VALUE "FileDescription",  XSTR(JDK_COMPONENT)     "\0"
-            VALUE "FileVersion",      XSTR(JDK_VER)           "\0"
+            VALUE "CompanyName",      XSTR(JDK_COMPANY)        "\0"
+            VALUE "FileDescription",  XSTR(JDK_FILEDESC)       "\0"
+            VALUE "FileVersion",      XSTR(JDK_VER)            "\0"
             VALUE "Full Version",     XSTR(JDK_VERSION_STRING) "\0"
-	    VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME) "\0"
-            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)     "\0"
-            VALUE "OriginalFilename", XSTR(JDK_FNAME)         "\0"
-            VALUE "ProductName",      XSTR(JDK_NAME)          "\0"
-            VALUE "ProductVersion",   XSTR(JDK_VER)           "\0"
+            VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME)  "\0"
+            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)      "\0"
+            VALUE "OriginalFilename", XSTR(JDK_FNAME)          "\0"
+            VALUE "ProductName",      XSTR(JDK_NAME)           "\0"
+            VALUE "ProductVersion",   XSTR(JDK_VER)            "\0"
         END
     END
     BLOCK "VarFileInfo"
--- a/src/java.desktop/windows/native/libawt/windows/awt.rc	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/java.desktop/windows/native/libawt/windows/awt.rc	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 // 
-// Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+// Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
 // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 //
 // This code is free software; you can redistribute it and/or modify it
@@ -65,15 +65,15 @@
     BEGIN
         BLOCK "040904b0"
         BEGIN
-            VALUE "CompanyName",      XSTR(JDK_COMPANY)       "\0"
-            VALUE "FileDescription",  XSTR(JDK_COMPONENT)     "\0"
-            VALUE "FileVersion",      XSTR(JDK_VER)           "\0"
+            VALUE "CompanyName",      XSTR(JDK_COMPANY)        "\0"
+            VALUE "FileDescription",  XSTR(JDK_FILEDESC)       "\0"
+            VALUE "FileVersion",      XSTR(JDK_VER)            "\0"
             VALUE "Full Version",     XSTR(JDK_VERSION_STRING) "\0"
-	    VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME) "\0"
-            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)     "\0"
-            VALUE "OriginalFilename", XSTR(JDK_FNAME)         "\0"
-            VALUE "ProductName",      XSTR(JDK_NAME)          "\0"
-            VALUE "ProductVersion",   XSTR(JDK_VER)           "\0"
+            VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME)  "\0"
+            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)      "\0"
+            VALUE "OriginalFilename", XSTR(JDK_FNAME)          "\0"
+            VALUE "ProductName",      XSTR(JDK_NAME)           "\0"
+            VALUE "ProductVersion",   XSTR(JDK_VER)            "\0"
         END
     END
     BLOCK "VarFileInfo"
--- a/src/jdk.accessibility/windows/native/common/AccessBridgeStatusWindow.RC	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,174 +0,0 @@
-//Microsoft Developer Studio generated resource script.
-//
-#include "resource.h"
-#include "accessBridgeResource.h"
-
-#define XSTR(x) STR(x)
-#define STR(x)  #x
-
-#define APSTUDIO_READONLY_SYMBOLS
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 2 resource.
-//
-#define APSTUDIO_HIDDEN_SYMBOLS
-#include "windows.h"
-#undef APSTUDIO_HIDDEN_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-#undef APSTUDIO_READONLY_SYMBOLS
-
-/////////////////////////////////////////////////////////////////////////////
-// English (U.S.) resources
-
-#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
-#ifdef _WIN32
-LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
-#pragma code_page(1252)
-#endif //_WIN32
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// Dialog
-//
-
-ACCESSBRIDGESTATUSWINDOW DIALOGEX 160, 78, 209, 163
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-EXSTYLE WS_EX_CLIENTEDGE
-CAPTION "Access Bridge status"
-FONT 8, "MS Sans Serif", 0, 0, 0x1
-BEGIN
-    EDITTEXT        cVMID,67,23,121,13,ES_READONLY
-    EDITTEXT        cStatusText,40,147,162,13,ES_READONLY
-    LTEXT           "Java VM ID:",IDC_STATIC,23,25,40,8
-    LTEXT           "Status:",IDC_STATIC,11,149,23,8
-    EDITTEXT        cWindowsID,67,39,121,13,ES_READONLY
-    LTEXT           "Windows ID:",IDC_STATIC,21,41,42,8
-    EDITTEXT        cCallInfo,12,65,184,75,ES_MULTILINE | ES_AUTOVSCROLL |
-                    ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL
-    GROUPBOX        "Call info",IDC_STATIC,4,55,197,90
-    EDITTEXT        cInvokedByText,67,1,121,13,ES_READONLY
-    LTEXT           "Invoked by:",IDC_STATIC,25,3,38,8
-END
-
-IDD_DIALOG1 DIALOG DISCARDABLE  0, 0, 186, 95
-STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
-CAPTION "Dialog"
-FONT 8, "MS Sans Serif"
-BEGIN
-    DEFPUSHBUTTON   "OK",IDOK,129,7,50,14
-    PUSHBUTTON      "Cancel",IDCANCEL,129,24,50,14
-END
-
-
-#ifdef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// TEXTINCLUDE
-//
-
-1 TEXTINCLUDE DISCARDABLE
-BEGIN
-    "resource.h\0"
-END
-
-2 TEXTINCLUDE DISCARDABLE
-BEGIN
-    "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
-    "#include ""windows.h""\r\n"
-    "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
-    "\0"
-END
-
-3 TEXTINCLUDE DISCARDABLE
-BEGIN
-    "\r\n"
-    "\0"
-END
-
-#endif    // APSTUDIO_INVOKED
-
-
-/////////////////////////////////////////////////////////////////////////////
-//
-// DESIGNINFO
-//
-
-#ifdef APSTUDIO_INVOKED
-GUIDELINES DESIGNINFO DISCARDABLE
-BEGIN
-    "ACCESSBRIDGESTATUSWINDOW", DIALOG
-    BEGIN
-        LEFTMARGIN, 4
-        RIGHTMARGIN, 202
-        BOTTOMMARGIN, 160
-    END
-
-    "IDD_DIALOG1", DIALOG
-    BEGIN
-        LEFTMARGIN, 7
-        RIGHTMARGIN, 179
-        TOPMARGIN, 7
-        BOTTOMMARGIN, 88
-    END
-END
-#endif    // APSTUDIO_INVOKED
-
-
-#ifndef _MAC
-/////////////////////////////////////////////////////////////////////////////
-//
-// Version
-//
-
-VS_VERSION_INFO VERSIONINFO
- FILEVERSION    JDK_FVER
- PRODUCTVERSION JDK_FVER
- FILEFLAGSMASK 0x3fL
-#ifdef DEBUG
- FILEFLAGS 0x1L
-#else
- FILEFLAGS 0x0L
-#endif
- FILEOS 0x40004L
- FILETYPE JDK_FTYPE
- FILESUBTYPE 0x0L
-BEGIN
-    BLOCK "StringFileInfo"
-    BEGIN
-        BLOCK "040904b0"
-        BEGIN
-            VALUE "Comments", "Java Access Bridge\0"
-            VALUE "CompanyName", XSTR(JDK_COMPANY) "\0"
-            VALUE "FileDescription", XSTR(JDK_COMPONENT) "\0"
-            VALUE "FileVersion", XSTR(JDK_VER) "\0"
-            VALUE "Full Version", XSTR(JDK_VERSION_STRING) "\0"
-            VALUE "InternalName", XSTR(JDK_INTERNAL_NAME) "\0"
-            VALUE "LegalCopyright", XSTR(JDK_COPYRIGHT) "\0"
-            VALUE "OriginalFilename", XSTR(JDK_FNAME) "\0"
-            VALUE "ProductName",  XSTR(JDK_NAME) "\0"
-            VALUE "ProductVersion", XSTR(JDK_VER) "\0"
-        END
-    END
-    BLOCK "VarFileInfo"
-    BEGIN
-        VALUE "Translation", 0x409, 1200
-    END
-END
-
-#endif    // !_MAC
-
-#endif    // English (U.S.) resources
-/////////////////////////////////////////////////////////////////////////////
-
-
-
-#ifndef APSTUDIO_INVOKED
-/////////////////////////////////////////////////////////////////////////////
-//
-// Generated from the TEXTINCLUDE 3 resource.
-//
-
-
-/////////////////////////////////////////////////////////////////////////////
-#endif    // not APSTUDIO_INVOKED
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.accessibility/windows/native/common/AccessBridgeStatusWindow.rc	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,174 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+#include "accessBridgeResource.h"
+
+#define XSTR(x) STR(x)
+#define STR(x)  #x
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#define APSTUDIO_HIDDEN_SYMBOLS
+#include "windows.h"
+#undef APSTUDIO_HIDDEN_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (U.S.) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+#pragma code_page(1252)
+#endif //_WIN32
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Dialog
+//
+
+ACCESSBRIDGESTATUSWINDOW DIALOGEX 160, 78, 209, 163
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+EXSTYLE WS_EX_CLIENTEDGE
+CAPTION "Access Bridge status"
+FONT 8, "MS Sans Serif", 0, 0, 0x1
+BEGIN
+    EDITTEXT        cVMID,67,23,121,13,ES_READONLY
+    EDITTEXT        cStatusText,40,147,162,13,ES_READONLY
+    LTEXT           "Java VM ID:",IDC_STATIC,23,25,40,8
+    LTEXT           "Status:",IDC_STATIC,11,149,23,8
+    EDITTEXT        cWindowsID,67,39,121,13,ES_READONLY
+    LTEXT           "Windows ID:",IDC_STATIC,21,41,42,8
+    EDITTEXT        cCallInfo,12,65,184,75,ES_MULTILINE | ES_AUTOVSCROLL |
+                    ES_AUTOHSCROLL | ES_READONLY | WS_VSCROLL
+    GROUPBOX        "Call info",IDC_STATIC,4,55,197,90
+    EDITTEXT        cInvokedByText,67,1,121,13,ES_READONLY
+    LTEXT           "Invoked by:",IDC_STATIC,25,3,38,8
+END
+
+IDD_DIALOG1 DIALOG DISCARDABLE  0, 0, 186, 95
+STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+CAPTION "Dialog"
+FONT 8, "MS Sans Serif"
+BEGIN
+    DEFPUSHBUTTON   "OK",IDOK,129,7,50,14
+    PUSHBUTTON      "Cancel",IDCANCEL,129,24,50,14
+END
+
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE DISCARDABLE
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE DISCARDABLE
+BEGIN
+    "#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
+    "#include ""windows.h""\r\n"
+    "#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE DISCARDABLE
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// DESIGNINFO
+//
+
+#ifdef APSTUDIO_INVOKED
+GUIDELINES DESIGNINFO DISCARDABLE
+BEGIN
+    "ACCESSBRIDGESTATUSWINDOW", DIALOG
+    BEGIN
+        LEFTMARGIN, 4
+        RIGHTMARGIN, 202
+        BOTTOMMARGIN, 160
+    END
+
+    "IDD_DIALOG1", DIALOG
+    BEGIN
+        LEFTMARGIN, 7
+        RIGHTMARGIN, 179
+        TOPMARGIN, 7
+        BOTTOMMARGIN, 88
+    END
+END
+#endif    // APSTUDIO_INVOKED
+
+
+#ifndef _MAC
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION    JDK_FVER
+ PRODUCTVERSION JDK_FVER
+ FILEFLAGSMASK 0x3fL
+#ifdef DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE JDK_FTYPE
+ FILESUBTYPE 0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "Comments",         "Java Access Bridge"     "\0"
+            VALUE "CompanyName",      XSTR(JDK_COMPANY)        "\0"
+            VALUE "FileDescription",  XSTR(JDK_FILEDESC)       "\0"
+            VALUE "FileVersion",      XSTR(JDK_VER)            "\0"
+            VALUE "Full Version",     XSTR(JDK_VERSION_STRING) "\0"
+            VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME)  "\0"
+            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)      "\0"
+            VALUE "OriginalFilename", XSTR(JDK_FNAME)          "\0"
+            VALUE "ProductName",      XSTR(JDK_NAME)           "\0"
+            VALUE "ProductVersion",   XSTR(JDK_VER)            "\0"
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
+#endif    // !_MAC
+
+#endif    // English (U.S.) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
--- a/src/jdk.accessibility/windows/native/common/resource.h	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.accessibility/windows/native/common/resource.h	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
  * 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 @@
 
 //{{NO_DEPENDENCIES}}
 // Microsoft Developer Studio generated include file.
-// Used by AccessBridgeStatusWindow.RC
+// Used by AccessBridgeStatusWindow.rc
 //
 //#define IDB_BITMAP1                     102
 
--- a/src/jdk.accessibility/windows/native/jaccessinspector/jaccessinspectorWindow.rc	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.accessibility/windows/native/jaccessinspector/jaccessinspectorWindow.rc	Sat Apr 13 07:52:21 2019 -0400
@@ -199,15 +199,15 @@
     BEGIN
         BLOCK "000004b0"
         BEGIN
-            VALUE "CompanyName",      XSTR(JDK_COMPANY)       "\0"
-            VALUE "FileDescription",  XSTR(JDK_COMPONENT)     "\0"
-            VALUE "FileVersion",      XSTR(JDK_VER)           "\0"
+            VALUE "CompanyName",      XSTR(JDK_COMPANY)        "\0"
+            VALUE "FileDescription",  XSTR(JDK_FILEDESC)       "\0"
+            VALUE "FileVersion",      XSTR(JDK_VER)            "\0"
             VALUE "Full Version",     XSTR(JDK_VERSION_STRING) "\0"
-            VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME) "\0"
-            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)     "\0"
-            VALUE "OriginalFilename", XSTR(JDK_FNAME)         "\0"
-            VALUE "ProductName",      XSTR(JDK_NAME)          "\0"
-            VALUE "ProductVersion",   XSTR(JDK_VER)           "\0"
+            VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME)  "\0"
+            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)      "\0"
+            VALUE "OriginalFilename", XSTR(JDK_FNAME)          "\0"
+            VALUE "ProductName",      XSTR(JDK_NAME)           "\0"
+            VALUE "ProductVersion",   XSTR(JDK_VER)            "\0"
         END
     END
     BLOCK "VarFileInfo"
--- a/src/jdk.accessibility/windows/native/jaccesswalker/jaccesswalkerWindow.rc	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.accessibility/windows/native/jaccesswalker/jaccesswalkerWindow.rc	Sat Apr 13 07:52:21 2019 -0400
@@ -164,15 +164,15 @@
     BEGIN
         BLOCK "000004b0"
         BEGIN
-            VALUE "CompanyName",      XSTR(JDK_COMPANY)       "\0"
-            VALUE "FileDescription",  XSTR(JDK_COMPONENT)     "\0"
-            VALUE "FileVersion",      XSTR(JDK_VER)           "\0"
+            VALUE "CompanyName",      XSTR(JDK_COMPANY)        "\0"
+            VALUE "FileDescription",  XSTR(JDK_FILEDESC)       "\0"
+            VALUE "FileVersion",      XSTR(JDK_VER)            "\0"
             VALUE "Full Version",     XSTR(JDK_VERSION_STRING) "\0"
-            VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME) "\0"
-            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)     "\0"
-            VALUE "OriginalFilename", XSTR(JDK_FNAME)         "\0"
-            VALUE "ProductName",      XSTR(JDK_NAME)          "\0"
-            VALUE "ProductVersion",   XSTR(JDK_VER)           "\0"
+            VALUE "InternalName",     XSTR(JDK_INTERNAL_NAME)  "\0"
+            VALUE "LegalCopyright",   XSTR(JDK_COPYRIGHT)      "\0"
+            VALUE "OriginalFilename", XSTR(JDK_FNAME)          "\0"
+            VALUE "ProductName",      XSTR(JDK_NAME)           "\0"
+            VALUE "ProductVersion",   XSTR(JDK_VER)            "\0"
         END
     END
     BLOCK "VarFileInfo"
--- a/src/jdk.compiler/share/classes/com/sun/source/util/JavacTask.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/JavacTask.java	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
  * 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,6 +29,7 @@
 
 import javax.annotation.processing.ProcessingEnvironment;
 import javax.lang.model.element.Element;
+import javax.lang.model.element.VariableElement;
 import javax.lang.model.type.TypeMirror;
 import javax.lang.model.util.Elements;
 import javax.lang.model.util.Types;
@@ -137,6 +138,27 @@
     public abstract void removeTaskListener(TaskListener taskListener);
 
     /**
+     * Sets the specified {@link ParameterNameProvider}. It may be used when
+     * {@link VariableElement#getSimpleName()} is called for a method parameter
+     * for which an authoritative name is not found. The given
+     * {@code ParameterNameProvider} may infer a user-friendly name
+     * for the method parameter.
+     *
+     * Setting a new {@code ParameterNameProvider} will clear any previously set
+     * {@code ParameterNameProvider}, which won't be queried any more.
+     *
+     * When no {@code ParameterNameProvider} is set, or when it returns null from
+     * {@link ParameterNameProvider#getParameterName(javax.lang.model.element.VariableElement)},
+     * an automatically synthesized name is returned from {@code VariableElement.getSimpleName()}.
+     *
+     * @implSpec The default implementation of this method does nothing.
+     *
+     * @param provider the provider.
+     * @since 13
+     */
+    public void setParameterNameProvider(ParameterNameProvider provider) {}
+
+    /**
      * Returns a type mirror of the tree node determined by the specified path.
      * This method has been superceded by methods on
      * {@link com.sun.source.util.Trees Trees}.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/ParameterNameProvider.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+package com.sun.source.util;
+
+import javax.lang.model.element.VariableElement;
+
+/**
+ * A provider for parameter names when the parameter names are not determined from
+ * a reliable source, like a classfile.
+ *
+ * @since 13
+ */
+public interface ParameterNameProvider {
+
+    /**
+     * Infer a parameter name for the given parameter. The implementations of this method
+     * should infer parameter names in such a way that the parameter names are distinct
+     * for any given owning method.
+     *
+     * If the implementation of this method returns null, an automatically synthesized name is used.
+     *
+     * @param parameter the parameter for which the name should be inferred.
+     * @return a user-friendly name for the parameter, or null if unknown
+     */
+    public CharSequence getParameterName(VariableElement parameter);
+
+}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/BasicJavacTask.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/BasicJavacTask.java	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,9 +43,11 @@
 import com.sun.source.tree.CompilationUnitTree;
 import com.sun.source.tree.Tree;
 import com.sun.source.util.JavacTask;
+import com.sun.source.util.ParameterNameProvider;
 import com.sun.source.util.Plugin;
 import com.sun.source.util.TaskListener;
 import com.sun.tools.doclint.DocLint;
+import com.sun.tools.javac.code.MissingInfoHandler;
 import com.sun.tools.javac.main.JavaCompiler;
 import com.sun.tools.javac.model.JavacElements;
 import com.sun.tools.javac.model.JavacTypes;
@@ -123,6 +125,11 @@
         mtl.remove(taskListener);
     }
 
+    @Override
+    public void setParameterNameProvider(ParameterNameProvider handler) {
+        MissingInfoHandler.instance(context).setDelegate(handler);
+    }
+
     public Collection<TaskListener> getTaskListeners() {
         MultiTaskListener mtl = MultiTaskListener.instance(context);
         return mtl.getTaskListeners();
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Flags.java	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -319,6 +319,11 @@
      */
     public static final long BODY_ONLY_FINALIZE = 1L<<17; //blocks only
 
+    /**
+     * Flag to indicate the given ParamSymbol has a user-friendly name filled.
+     */
+    public static final long NAME_FILLED = 1L<<58; //ParamSymbols only
+
     /** Modifier masks.
      */
     public static final int
@@ -435,7 +440,8 @@
         DEPRECATED_REMOVAL(Flags.DEPRECATED_REMOVAL),
         HAS_RESOURCE(Flags.HAS_RESOURCE),
         POTENTIALLY_AMBIGUOUS(Flags.POTENTIALLY_AMBIGUOUS),
-        ANONCONSTR_BASED(Flags.ANONCONSTR_BASED);
+        ANONCONSTR_BASED(Flags.ANONCONSTR_BASED),
+        NAME_FILLED(Flags.NAME_FILLED);
 
         Flag(long flag) {
             this.value = flag;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/MissingInfoHandler.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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.
+ */
+
+package com.sun.tools.javac.code;
+
+import com.sun.source.util.ParameterNameProvider;
+import com.sun.tools.javac.code.Symbol.ParamSymbol;
+import com.sun.tools.javac.util.Context;
+import com.sun.tools.javac.util.Name;
+import com.sun.tools.javac.util.Names;
+
+/**
+ * A Context class, that can return additional useful information for Symbols, currently
+ * parameter names. It does so by calling user-supplied {@link ParameterNameProvider}.
+ *
+ * <p><b>This is NOT part of any supported API.
+ * If you write code that depends on this, you do so at your own risk.
+ * This code and its internal interfaces are subject to change or
+ * deletion without notice.</b>
+ */
+public class MissingInfoHandler {
+    protected static final Context.Key<MissingInfoHandler> missingInfoHandlerWrapperKey = new Context.Key<>();
+
+    public static MissingInfoHandler instance(Context context) {
+        MissingInfoHandler instance = context.get(missingInfoHandlerWrapperKey);
+        if (instance == null)
+            instance = new MissingInfoHandler(context);
+        return instance;
+    }
+
+    private final Names names;
+    private ParameterNameProvider parameterNameProvider;
+
+    protected MissingInfoHandler(Context context) {
+        context.put(missingInfoHandlerWrapperKey, this);
+        names = Names.instance(context);
+    }
+
+    public Name getParameterName(ParamSymbol parameter) {
+        if (parameterNameProvider != null) {
+            CharSequence name = parameterNameProvider.getParameterName(parameter);
+            if (name != null) {
+                return names.fromString(name.toString());
+            }
+        }
+
+        return null;
+    }
+
+    public void setDelegate(ParameterNameProvider delegate) {
+        this.parameterNameProvider = delegate;
+    }
+}
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symbol.java	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -65,9 +65,12 @@
 import static com.sun.tools.javac.code.Flags.*;
 import static com.sun.tools.javac.code.Kinds.*;
 import static com.sun.tools.javac.code.Kinds.Kind.*;
+import com.sun.tools.javac.code.MissingInfoHandler;
 import static com.sun.tools.javac.code.Scope.LookupKind.NON_RECURSIVE;
 import com.sun.tools.javac.code.Scope.WriteableScope;
+import com.sun.tools.javac.code.Symbol;
 import static com.sun.tools.javac.code.Symbol.OperatorSymbol.AccessCode.FIRSTASGOP;
+import com.sun.tools.javac.code.Type;
 import static com.sun.tools.javac.code.TypeTag.CLASS;
 import static com.sun.tools.javac.code.TypeTag.FORALL;
 import static com.sun.tools.javac.code.TypeTag.TYPEVAR;
@@ -76,6 +79,7 @@
 import static com.sun.tools.javac.jvm.ByteCodes.lushrl;
 import static com.sun.tools.javac.jvm.ByteCodes.lxor;
 import static com.sun.tools.javac.jvm.ByteCodes.string_add;
+import com.sun.tools.javac.util.Name;
 
 /** Root class for Java symbols. It contains subclasses
  *  for specific sorts of symbols, such as variables, methods and operators,
@@ -1189,6 +1193,16 @@
 
     }
 
+    public static class RootPackageSymbol extends PackageSymbol {
+        public final MissingInfoHandler missingInfoHandler;
+
+        public RootPackageSymbol(Name name, Symbol owner, MissingInfoHandler missingInfoHandler) {
+            super(name, owner);
+            this.missingInfoHandler = missingInfoHandler;
+        }
+
+    }
+
     /** A class for class symbols
      */
     public static class ClassSymbol extends TypeSymbol implements TypeElement {
@@ -1634,6 +1648,32 @@
         }
     }
 
+    public static class ParamSymbol extends VarSymbol {
+        public ParamSymbol(long flags, Name name, Type type, Symbol owner) {
+            super(flags, name, type, owner);
+        }
+
+        @Override
+        public Name getSimpleName() {
+            if ((flags_field & NAME_FILLED) == 0) {
+                flags_field |= NAME_FILLED;
+                Symbol rootPack = this;
+                while (rootPack != null && !(rootPack instanceof RootPackageSymbol)) {
+                    rootPack = rootPack.owner;
+                }
+                if (rootPack != null) {
+                    Name inferredName =
+                            ((RootPackageSymbol) rootPack).missingInfoHandler.getParameterName(this);
+                    if (inferredName != null) {
+                        this.name = inferredName;
+                    }
+                }
+            }
+            return super.getSimpleName();
+        }
+
+    }
+
     /** A class for method symbols.
      */
     public static class MethodSymbol extends Symbol implements ExecutableElement {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -42,6 +42,7 @@
 import com.sun.tools.javac.code.Symbol.MethodSymbol;
 import com.sun.tools.javac.code.Symbol.ModuleSymbol;
 import com.sun.tools.javac.code.Symbol.PackageSymbol;
+import com.sun.tools.javac.code.Symbol.RootPackageSymbol;
 import com.sun.tools.javac.code.Symbol.TypeSymbol;
 import com.sun.tools.javac.code.Symbol.VarSymbol;
 import com.sun.tools.javac.code.Type.BottomType;
@@ -382,7 +383,9 @@
 
         messages = JavacMessages.instance(context);
 
-        rootPackage = new PackageSymbol(names.empty, null);
+        MissingInfoHandler missingInfoHandler = MissingInfoHandler.instance(context);
+
+        rootPackage = new RootPackageSymbol(names.empty, null, missingInfoHandler);
 
         // create the basic builtin symbols
         unnamedModule = new ModuleSymbol(names.empty, null) {
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/ClassReader.java	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1502,6 +1502,10 @@
 
     // See java.lang.Class
     private Name simpleBinaryName(Name self, Name enclosing) {
+        if (!self.startsWith(enclosing)) {
+            throw badClassFile("bad.enclosing.method", self);
+        }
+
         String simpleBinaryName = self.toString().substring(enclosing.toString().length());
         if (simpleBinaryName.length() < 1 || simpleBinaryName.charAt(0) != '$')
             throw badClassFile("bad.enclosing.method", self);
@@ -2553,14 +2557,12 @@
                 firstParam += skip;
             }
         }
-        List<Name> paramNames = List.nil();
+        Set<Name> paramNames = new HashSet<>();
         ListBuffer<VarSymbol> params = new ListBuffer<>();
         int nameIndex = firstParam;
         int annotationIndex = 0;
         for (Type t: sym.type.getParameterTypes()) {
-            Name name = parameterName(nameIndex, paramNames);
-            paramNames = paramNames.prepend(name);
-            VarSymbol param = new VarSymbol(PARAMETER, name, t, sym);
+            VarSymbol param = parameter(nameIndex, t, sym, paramNames);
             params.append(param);
             if (parameterAnnotations != null) {
                 ParameterAnnotations annotations = parameterAnnotations[annotationIndex];
@@ -2585,18 +2587,24 @@
     // Returns the name for the parameter at position 'index', either using
     // names read from the MethodParameters, or by synthesizing a name that
     // is not on the 'exclude' list.
-    private Name parameterName(int index, List<Name> exclude) {
+    private VarSymbol parameter(int index, Type t, MethodSymbol owner, Set<Name> exclude) {
+        long flags = PARAMETER;
+        Name argName;
         if (parameterNameIndices != null && index < parameterNameIndices.length
                 && parameterNameIndices[index] != 0) {
-            return readName(parameterNameIndices[index]);
+            argName = readName(parameterNameIndices[index]);
+            flags |= NAME_FILLED;
+        } else {
+            String prefix = "arg";
+            while (true) {
+                argName = names.fromString(prefix + exclude.size());
+                if (!exclude.contains(argName))
+                    break;
+                prefix += "$";
+            }
         }
-        String prefix = "arg";
-        while (true) {
-            Name argName = names.fromString(prefix + exclude.size());
-            if (!exclude.contains(argName))
-                return argName;
-            prefix += "$";
-        }
+        exclude.add(argName);
+        return new ParamSymbol(flags, argName, t, owner);
     }
 
     /**
--- a/src/jdk.rmic/share/classes/sun/tools/java/BinaryClass.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.rmic/share/classes/sun/tools/java/BinaryClass.java	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -122,6 +122,13 @@
                            sun.tools.javac.Main.getText(
                                "javac.err.version.too.old",
                                String.valueOf(version)));
+        } else if ((version >= JAVA_MIN_PREVIEW_MAJOR_VERSION)
+                     && (minor_version == JAVA_PREVIEW_MINOR_VERSION)) {
+            // reject all class files that have preview features enabled
+            throw new ClassFormatError(
+                           sun.tools.javac.Main.getText(
+                               "javac.err.version.preview",
+                               version+"."+minor_version));
         } else if ((version > JAVA_MAX_SUPPORTED_VERSION)
                      || (version == JAVA_MAX_SUPPORTED_VERSION
                   && minor_version > JAVA_MAX_SUPPORTED_MINOR_VERSION)) {
--- a/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.rmic/share/classes/sun/tools/java/RuntimeConstants.java	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,6 +69,8 @@
     int JAVA_MIN_SUPPORTED_VERSION   = 45;
     int JAVA_MAX_SUPPORTED_VERSION   = 57;
     int JAVA_MAX_SUPPORTED_MINOR_VERSION = 0;
+    int JAVA_MIN_PREVIEW_MAJOR_VERSION = 55; // preview intro'd in JDK 11
+    int JAVA_PREVIEW_MINOR_VERSION   = 0xffff;
 
     /* Generate class file version for 1.1  by default */
     int JAVA_DEFAULT_VERSION         = 45;
--- a/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties	Sat Apr 13 07:47:23 2019 -0400
+++ b/src/jdk.rmic/share/classes/sun/tools/javac/resources/javac.properties	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -579,6 +579,9 @@
 javac.err.version.too.recent=\
 	The major.minor version ''{0}'' is too recent for this tool \
 	to understand.
+javac.err.version.preview=\
+	The major.minor version ''{0}'' indicates the class was compiled with \
+	preview features enabled, which this tool does not support.
 #
 benv.parsed_in=[parsed {0} in {1} ms]
 benv.loaded_in=[loaded {0} in {1} ms]
--- a/test/hotspot/jtreg/ProblemList-graal.txt	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/hotspot/jtreg/ProblemList-graal.txt	Sat Apr 13 07:52:21 2019 -0400
@@ -38,8 +38,6 @@
 compiler/compilercontrol/mixed/RandomValidCommandsTest.java     8181753   generic-all
 compiler/compilercontrol/mixed/RandomCommandsTest.java          8181753   generic-all
 
-compiler/graalunit/JttThreadsTest.java                          8208066   generic-all
-
 compiler/jvmci/SecurityRestrictionsTest.java                    8181837   generic-all
 
 compiler/unsafe/UnsafeGetConstantField.java                     8181833   generic-all
--- a/test/hotspot/jtreg/ProblemList.txt	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/hotspot/jtreg/ProblemList.txt	Sat Apr 13 07:52:21 2019 -0400
@@ -79,7 +79,7 @@
 # :hotspot_runtime
 
 runtime/SharedArchiveFile/SASymbolTableTest.java 8193639 solaris-all
-runtime/containers/docker/TestCPUSets.java 8220672 generic-all
+containers/docker/TestCPUSets.java 8220672 generic-all
 runtime/jni/terminatedThread/TestTerminatedThread.java 8219652 aix-ppc64
 
 #############################################################################
--- a/test/hotspot/jtreg/TEST.groups	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/hotspot/jtreg/TEST.groups	Sat Apr 13 07:52:21 2019 -0400
@@ -43,6 +43,7 @@
   gc \
   -gc/nvdimm
 
+# By design this group should include ALL tests under runtime sub-directory
 hotspot_runtime = \
   runtime
 
@@ -65,6 +66,9 @@
 hotspot_native_sanity = \
   native_sanity
 
+hotspot_containers = \
+  containers
+
 tier1_common = \
   sanity/BasicVMTest.java \
   gtest/GTestWrapper.java
@@ -296,7 +300,6 @@
  -runtime/Thread/CancellableThreadTest.java \
  -runtime/Thread/TestThreadDumpMonitorContention.java \
  -runtime/Unsafe/RangeCheck.java \
- -runtime/containers/ \
   sanity/ \
   testlibrary_tests/TestMutuallyExclusivePlatformPredicates.java \
  -:tier1_runtime_appcds_exclude \
@@ -365,7 +368,6 @@
  -runtime/CommandLine/OptionsValidation/TestOptionsWithRanges.java \
  -runtime/CompressedOops/UseCompressedOops.java \
  -runtime/Thread/TestThreadDumpMonitorContention.java \
- -runtime/containers/ \
  -:tier1_runtime \
  -:tier1_serviceability \
  -:hotspot_tier2_runtime_platform_agnostic \
@@ -379,7 +381,6 @@
 hotspot_tier3_runtime = \
   runtime/ \
   serviceability/ \
- -runtime/containers/ \
  -:tier1_runtime \
  -:tier1_serviceability \
  -:hotspot_tier2_runtime_platform_agnostic \
--- a/test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/hotspot/jtreg/compiler/graalunit/common/GraalUnitTestLauncher.java	Sat Apr 13 07:52:21 2019 -0400
@@ -241,7 +241,8 @@
         javaFlags.add("-ea");
         // Make sure exception message is never null
         javaFlags.add("-XX:-OmitStackTraceInFastThrow");
-
+        // set timeout factor based on jtreg harness settings
+        javaFlags.add("-Dgraaltest.timeout.factor=" + System.getProperty("test.timeout.factor", "1.0"));
 
         // generate class path
         ArrayList<String> graalJars = new ArrayList<String>(Arrays.asList(GRAAL_EXTRA_JARS));
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/cgroup/PlainRead.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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 PlainRead
+ * @requires os.family == "linux"
+ * @library /testlibrary /test/lib
+ * @build sun.hotspot.WhiteBox
+ * @run driver ClassFileInstaller sun.hotspot.WhiteBox
+ *                              sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI PlainRead
+ */
+
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.Platform;
+import sun.hotspot.WhiteBox;
+
+public class PlainRead {
+
+    static public void match(OutputAnalyzer oa, String what, String value) {
+       oa.shouldMatch("^.*" + what + " *" + value + ".*$");
+    }
+
+    static public void noMatch(OutputAnalyzer oa, String what, String value) {
+       oa.shouldNotMatch("^.*" + what + " *" + value + ".*$");
+    }
+
+    static final String good_value = "(\\d+|-1|Unlimited)";
+    static final String bad_value = "(failed)";
+
+    static final String[] variables = {"Memory Limit is:", "CPU Shares is:", "CPU Quota is:", "CPU Period is:", "active_processor_count:"};
+
+    static public void isContainer(OutputAnalyzer oa) {
+        for (String v: variables) {
+            match(oa, v, good_value);
+        }
+        for (String v: variables) {
+            noMatch(oa, v, bad_value);
+        }
+    }
+
+    static public void isNotContainer(OutputAnalyzer oa) {
+       oa.shouldMatch("^.*Can't open /proc/self/mountinfo.*$");
+    }
+
+    public static void main(String[] args) throws Exception {
+        WhiteBox wb = WhiteBox.getWhiteBox();
+        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+container=trace", "-version");
+        OutputAnalyzer output = new OutputAnalyzer(pb.start());
+
+        if (wb.isContainerized()) {
+            System.out.println("Inside a cgroup, testing...");
+            isContainer(output);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/AttemptOOM.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+
+public class AttemptOOM {
+    private static MyObj[] data;
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("Entering AttemptOOM main");
+
+        // each MyObj will allocate 1024 byte array
+        int sizeInMb = Integer.parseInt(args[0]);
+        data = new MyObj[sizeInMb*1024];
+
+        System.out.println("data.length = " + data.length);
+
+        for (int i=0; i < data.length; i++) {
+            data[i] = new MyObj(1024);
+        }
+
+        System.out.println("AttemptOOM allocation successful");
+    }
+
+    private static class MyObj {
+        private byte[] myData;
+        MyObj(int size) {
+            myData = new byte[size];
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/CheckContainerized.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,43 @@
+/*
+ * 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 sun.hotspot.WhiteBox;
+
+public class CheckContainerized {
+    public static String OUTSIDE_OF_CONTAINER =
+        "CheckContainerized: Running outside of a container";
+    public static String INSIDE_A_CONTAINER =
+        "CheckContainerized: Running inside a container";
+
+    public static void main(String[] args) {
+        System.out.println("CheckContainerized: Entering");
+        WhiteBox wb = WhiteBox.getWhiteBox();
+
+        if (wb.isContainerized()) {
+            System.out.println(INSIDE_A_CONTAINER);
+
+        } else {
+            System.out.println(OUTSIDE_OF_CONTAINER);
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/DockerBasicTest.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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
+ * @summary Basic (sanity) test for JDK-under-test inside a docker image.
+ * @requires docker.support
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ *          jdk.jartool/sun.tools.jar
+ * @build HelloDocker
+ * @run driver DockerBasicTest
+ */
+import jdk.test.lib.containers.docker.Common;
+import jdk.test.lib.containers.docker.DockerRunOptions;
+import jdk.test.lib.containers.docker.DockerTestUtils;
+import jdk.test.lib.Platform;
+import jdk.test.lib.Utils;
+
+
+public class DockerBasicTest {
+    private static final String imageNameAndTag = Common.imageName("basic");
+
+    public static void main(String[] args) throws Exception {
+        if (!DockerTestUtils.canTestDocker()) {
+            return;
+        }
+
+        DockerTestUtils.buildJdkDockerImage(imageNameAndTag, "Dockerfile-BasicTest", "jdk-docker");
+
+        try {
+            testJavaVersion();
+            testHelloDocker();
+        } finally {
+            if (!DockerTestUtils.RETAIN_IMAGE_AFTER_TEST) {
+                DockerTestUtils.removeDockerImage(imageNameAndTag);
+            }
+        }
+    }
+
+
+    private static void testJavaVersion() throws Exception {
+        DockerRunOptions opts =
+            new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", "-version");
+
+        DockerTestUtils.dockerRunJava(opts)
+            .shouldHaveExitValue(0)
+            .shouldContain(Platform.vmName);
+    }
+
+
+    private static void testHelloDocker() throws Exception {
+        DockerRunOptions opts =
+            new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", "HelloDocker")
+            .addJavaOpts("-cp", "/test-classes/")
+            .addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/");
+
+        DockerTestUtils.dockerRunJava(opts)
+            .shouldHaveExitValue(0)
+            .shouldContain("Hello Docker");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/HelloDocker.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,28 @@
+/*
+ * 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.
+ */
+
+public class HelloDocker {
+    public static void main(String args[]) {
+        System.out.println("Hello Docker");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/JfrReporter.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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.nio.file.Paths;
+import jdk.jfr.Recording;
+import jdk.jfr.consumer.RecordedEvent;
+import jdk.jfr.consumer.RecordingFile;
+
+
+// This class is intended to run inside a container
+public class JfrReporter {
+    public static final String TEST_REPORTED_CORES="TEST_REPORTED_CORES";
+    public static final String TEST_REPORTED_MEMORY="TEST_REPORTED_MEMORY";
+    public static final String TEST_REPORTED_PID="TEST_REPORTED_PID";
+    public static final String TESTCASE_CPU="cpu";
+    public static final String TESTCASE_MEMORY="memory";
+    public static final String TESTCASE_PROCESS="process";
+
+    public static void main(String[] args) throws Exception {
+        String testCase = args[0];
+        System.out.println("Testcase: " + testCase);
+        switch (testCase) {
+        case TESTCASE_CPU:
+            RecordedEvent event = testEvent("jdk.CPUInformation", "cpu.jfr");
+            System.out.println(TEST_REPORTED_CORES + "=" + event.getInt("cores"));
+            break;
+        case TESTCASE_MEMORY:
+            event = testEvent("jdk.PhysicalMemory", "memory.jfr");
+            System.out.println(TEST_REPORTED_MEMORY + "=" + event.getLong("totalSize"));
+            break;
+        case TESTCASE_PROCESS:
+            event = testEvent("jdk.SystemProcess", "process.jfr");
+            System.out.println(TEST_REPORTED_PID + "=" + event.getString("pid"));
+            break;
+        default:
+            throw new IllegalArgumentException("Invalid test case");
+        }
+    }
+
+    private static RecordedEvent testEvent(String event, String recordingPath) throws Exception {
+        System.out.println("========= Testing event: " + event);
+        Recording r = new Recording();
+        r.enable(event);
+        r.setDestination(Paths.get("tmp", recordingPath));
+        r.start();
+        r.stop();
+
+        RecordedEvent recordedEvent = RecordingFile.readAllEvents(r.getDestination()).get(0);
+        System.out.println("RecordedEvent: " + recordedEvent);
+        return recordedEvent;
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/PrintContainerInfo.java	Sat Apr 13 07:52:21 2019 -0400
@@ -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 sun.hotspot.WhiteBox;
+
+public class PrintContainerInfo {
+
+    public static void main(String[] args) {
+        System.out.println("PrintContainerInfo: Entering");
+        WhiteBox wb = WhiteBox.getWhiteBox();
+
+        wb.printOsInfo();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/TEST.properties	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,1 @@
+exclusiveAccess.dirs=.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/TestCPUAwareness.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,209 @@
+/*
+ * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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
+ * @summary Test JVM's CPU resource awareness when running inside docker container
+ * @requires docker.support
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ *          jdk.jartool/sun.tools.jar
+ * @run driver TestCPUAwareness
+ */
+import java.util.List;
+import jdk.test.lib.containers.docker.Common;
+import jdk.test.lib.containers.docker.DockerRunOptions;
+import jdk.test.lib.containers.docker.DockerTestUtils;
+import jdk.test.lib.containers.cgroup.CPUSetsReader;
+
+public class TestCPUAwareness {
+    private static final String imageName = Common.imageName("cpu");
+    private static final int availableCPUs = Runtime.getRuntime().availableProcessors();
+
+    public static void main(String[] args) throws Exception {
+        if (!DockerTestUtils.canTestDocker()) {
+            return;
+        }
+
+        System.out.println("Test Environment: detected availableCPUs = " + availableCPUs);
+        DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
+
+        try {
+            // cpuset, period, shares, expected Active Processor Count
+            testComboWithCpuSets();
+
+            // cpu shares - it should be safe to use CPU shares exceeding available CPUs
+            testCpuShares(256, 1);
+            testCpuShares(2048, 2);
+            testCpuShares(4096, 4);
+
+            // leave one CPU for system and tools, otherwise this test may be unstable
+            int maxNrOfAvailableCpus =  availableCPUs - 1;
+            for (int i=1; i < maxNrOfAvailableCpus; i = i * 2) {
+                testCpus(i, i);
+            }
+
+            // If ActiveProcessorCount is set, the VM should use it, regardless of other
+            // container settings, host settings or available CPUs on the host.
+            testActiveProcessorCount(1, 1);
+            testActiveProcessorCount(2, 2);
+
+            // cpu quota and period
+            testCpuQuotaAndPeriod(50*1000, 100*1000);
+            testCpuQuotaAndPeriod(100*1000, 100*1000);
+            testCpuQuotaAndPeriod(150*1000, 100*1000);
+            testCpuQuotaAndPeriod(400*1000, 100*1000);
+
+        } finally {
+            DockerTestUtils.removeDockerImage(imageName);
+        }
+    }
+
+
+    private static void testComboWithCpuSets() throws Exception {
+        String cpuSetStr = CPUSetsReader.readFromProcStatus("Cpus_allowed_list");
+        System.out.println("cpuSetStr = " + cpuSetStr);
+
+        if (cpuSetStr == null) {
+            System.out.printf("The cpuset test cases are skipped");
+        } else {
+            List<Integer> cpuSet = CPUSetsReader.parseCpuSet(cpuSetStr);
+
+            // Test subset of cpuset with one element
+            if (cpuSet.size() >= 1) {
+                String testCpuSet = CPUSetsReader.listToString(cpuSet, 1);
+                testAPCCombo(testCpuSet, 200*1000, 100*1000,   4*1024, true, 1);
+            }
+
+            // Test subset of cpuset with two elements
+            if (cpuSet.size() >= 2) {
+                String testCpuSet = CPUSetsReader.listToString(cpuSet, 2);
+                testAPCCombo(testCpuSet, 200*1000, 100*1000, 4*1024, true, 2);
+                testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   true, 2);
+                testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   false,  1);
+            }
+
+            // Test subset of cpuset with three elements
+            if (cpuSet.size() >= 3) {
+                String testCpuSet = CPUSetsReader.listToString(cpuSet, 3);
+                testAPCCombo(testCpuSet, 100*1000, 100*1000, 2*1024, true, 1);
+                testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   true, 2);
+                testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   false,  1);
+            }
+        }
+    }
+
+
+    private static void testActiveProcessorCount(int valueToSet, int expectedValue) throws Exception {
+        Common.logNewTestCase("Test ActiveProcessorCount: valueToSet = " + valueToSet);
+
+        DockerRunOptions opts = Common.newOpts(imageName)
+            .addJavaOpts("-XX:ActiveProcessorCount=" + valueToSet, "-Xlog:os=trace");
+        Common.run(opts)
+            .shouldMatch("active processor count set by user.*" + expectedValue);
+    }
+
+
+    private static void testCpus(int valueToSet, int expectedTraceValue) throws Exception {
+        Common.logNewTestCase("test cpus: " + valueToSet);
+        DockerRunOptions opts = Common.newOpts(imageName)
+            .addDockerOpts("--cpu-period=" + 10000)
+            .addDockerOpts("--cpu-quota=" + valueToSet * 10000);
+        Common.run(opts)
+            .shouldMatch("active_processor_count.*" + expectedTraceValue);
+    }
+
+
+    // Expected active processor count can not exceed available CPU count
+    private static int adjustExpectedAPCForAvailableCPUs(int expectedAPC) {
+        if (expectedAPC > availableCPUs) {
+            expectedAPC = availableCPUs;
+            System.out.println("Adjusted expectedAPC = " + expectedAPC);
+        }
+        return expectedAPC;
+    }
+
+
+    private static void testCpuQuotaAndPeriod(int quota, int period)
+        throws Exception {
+        Common.logNewTestCase("test cpu quota and period: ");
+        System.out.println("quota = " + quota);
+        System.out.println("period = " + period);
+
+        int expectedAPC = (int) Math.ceil((float) quota / (float) period);
+        System.out.println("expectedAPC = " + expectedAPC);
+        expectedAPC = adjustExpectedAPCForAvailableCPUs(expectedAPC);
+
+        DockerRunOptions opts = Common.newOpts(imageName)
+            .addDockerOpts("--cpu-period=" + period)
+            .addDockerOpts("--cpu-quota=" + quota);
+
+        Common.run(opts)
+            .shouldMatch("CPU Period is.*" + period)
+            .shouldMatch("CPU Quota is.*" + quota)
+            .shouldMatch("active_processor_count.*" + expectedAPC);
+    }
+
+
+    // Test correctess of automatically selected active processor cound
+    private static void testAPCCombo(String cpuset, int quota, int period, int shares,
+                                     boolean usePreferContainerQuotaForCPUCount,
+                                     int expectedAPC) throws Exception {
+        Common.logNewTestCase("test APC Combo");
+        System.out.println("cpuset = " + cpuset);
+        System.out.println("quota = " + quota);
+        System.out.println("period = " + period);
+        System.out.println("shares = " + shares);
+        System.out.println("usePreferContainerQuotaForCPUCount = " + usePreferContainerQuotaForCPUCount);
+        System.out.println("expectedAPC = " + expectedAPC);
+
+        expectedAPC = adjustExpectedAPCForAvailableCPUs(expectedAPC);
+
+        DockerRunOptions opts = Common.newOpts(imageName)
+            .addDockerOpts("--cpuset-cpus", "" + cpuset)
+            .addDockerOpts("--cpu-period=" + period)
+            .addDockerOpts("--cpu-quota=" + quota)
+            .addDockerOpts("--cpu-shares=" + shares);
+
+        if (!usePreferContainerQuotaForCPUCount) opts.addJavaOpts("-XX:-PreferContainerQuotaForCPUCount");
+
+        Common.run(opts)
+            .shouldMatch("active_processor_count.*" + expectedAPC);
+    }
+
+
+    private static void testCpuShares(int shares, int expectedAPC) throws Exception {
+        Common.logNewTestCase("test cpu shares, shares = " + shares);
+        System.out.println("expectedAPC = " + expectedAPC);
+
+        expectedAPC = adjustExpectedAPCForAvailableCPUs(expectedAPC);
+
+        DockerRunOptions opts = Common.newOpts(imageName)
+            .addDockerOpts("--cpu-shares=" + shares);
+        Common.run(opts)
+            .shouldMatch("CPU Shares is.*" + shares)
+            .shouldMatch("active_processor_count.*" + expectedAPC);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/TestCPUSets.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,142 @@
+/*
+ * 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
+ * @summary Test JVM's awareness of cpu sets (cpus and mems)
+ * @requires docker.support
+ * @requires (os.arch != "s390x")
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ *          jdk.jartool/sun.tools.jar
+ * @build AttemptOOM sun.hotspot.WhiteBox PrintContainerInfo
+ * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run driver TestCPUSets
+ */
+import java.util.List;
+import jdk.test.lib.containers.docker.Common;
+import jdk.test.lib.containers.docker.DockerRunOptions;
+import jdk.test.lib.containers.docker.DockerTestUtils;
+import jdk.test.lib.containers.cgroup.CPUSetsReader;
+import jdk.test.lib.Asserts;
+import jdk.test.lib.Platform;
+import jdk.test.lib.Utils;
+import jdk.test.lib.process.OutputAnalyzer;
+
+
+public class TestCPUSets {
+    private static final String imageName = Common.imageName("cpusets");
+
+    public static void main(String[] args) throws Exception {
+        if (!DockerTestUtils.canTestDocker()) {
+            return;
+        }
+
+        Common.prepareWhiteBox();
+        DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
+
+        try {
+            // Sanity test the cpu sets reader and parser
+            CPUSetsReader.test();
+            testTheSet("Cpus_allowed_list");
+            testTheSet("Mems_allowed_list");
+        } finally {
+            DockerTestUtils.removeDockerImage(imageName);
+        }
+    }
+
+
+    private static void testTheSet(String setType) throws Exception {
+        String cpuSetStr = CPUSetsReader.readFromProcStatus(setType);
+
+        if (cpuSetStr == null) {
+            System.out.printf("The %s test is skipped %n", setType);
+        } else {
+            List<Integer> cpuSet = CPUSetsReader.parseCpuSet(cpuSetStr);
+
+            // Test subset of one, full subset, and half of the subset
+            testCpuSet(CPUSetsReader.listToString(cpuSet, 1));
+            if (cpuSet.size() > 1) {
+                testCpuSet(CPUSetsReader.listToString(cpuSet));
+            }
+            if (cpuSet.size() > 2) {
+                testCpuSet(CPUSetsReader.listToString(cpuSet, cpuSet.size()/2 ));
+            }
+        }
+    }
+
+
+    private static DockerRunOptions commonOpts() {
+        DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java",
+                                                     "PrintContainerInfo");
+        opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/");
+        opts.addJavaOpts("-Xlog:os+container=trace", "-cp", "/test-classes/");
+        Common.addWhiteBoxOpts(opts);
+        return opts;
+    }
+
+
+    private static void checkResult(List<String> lines, String lineMarker, String value) {
+        boolean lineMarkerFound = false;
+
+        for (String line : lines) {
+            if (line.contains(lineMarker)) {
+                lineMarkerFound = true;
+                String[] parts = line.split(":");
+                System.out.println("DEBUG: line = " + line);
+                System.out.println("DEBUG: parts.length = " + parts.length);
+
+                Asserts.assertEquals(parts.length, 2);
+                String set = parts[1].replaceAll("\\s","");
+                String actual = CPUSetsReader.listToString(CPUSetsReader.parseCpuSet(set));
+                Asserts.assertEquals(actual, value);
+                break;
+            }
+        }
+        Asserts.assertTrue(lineMarkerFound);
+    }
+
+
+    private static void testCpuSet(String value) throws Exception {
+        Common.logNewTestCase("cpusets.cpus, value = " + value);
+
+        DockerRunOptions opts = commonOpts();
+        opts.addDockerOpts("--cpuset-cpus=" + value);
+
+        List<String> lines = Common.run(opts).asLines();
+        checkResult(lines, "cpuset.cpus is:", value);
+    }
+
+    private static void testMemSet(String value) throws Exception {
+        Common.logNewTestCase("cpusets.mems, value = " + value);
+
+        DockerRunOptions opts = commonOpts();
+        opts.addDockerOpts("--cpuset-mems=" + value);
+
+        List<String> lines = Common.run(opts).asLines();
+        checkResult(lines, "cpuset.mems is:", value);
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/TestJFREvents.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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
+ * @summary Ensure that certain JFR events return correct results for resource values
+ *          when run inside Docker container, such as available CPU and memory.
+ *          Also make sure that PIDs are based on value provided by container,
+ *          not by the host system.
+ * @requires (docker.support & os.maxMemory >= 2g)
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ *          jdk.jartool/sun.tools.jar
+ * @build JfrReporter
+ * @run driver TestJFREvents
+ */
+import jdk.test.lib.containers.docker.Common;
+import jdk.test.lib.containers.docker.DockerRunOptions;
+import jdk.test.lib.containers.docker.DockerTestUtils;
+import jdk.test.lib.Utils;
+
+
+public class TestJFREvents {
+    private static final String imageName = Common.imageName("jfr-events");
+    private static final int availableCPUs = Runtime.getRuntime().availableProcessors();
+
+    public static void main(String[] args) throws Exception {
+        System.out.println("Test Environment: detected availableCPUs = " + availableCPUs);
+        if (!DockerTestUtils.canTestDocker()) {
+            return;
+        }
+
+        DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
+
+        try {
+            // leave one CPU for system and tools, otherwise this test may be unstable
+            int maxNrOfAvailableCpus =  availableCPUs - 1;
+            for (int i=1; i < maxNrOfAvailableCpus; i = i * 2) {
+                testCPUInfo(i, i);
+            }
+
+            long MB = 1024*1024;
+            testMemory("200m", "" + 200*MB);
+            testMemory("500m", "" + 500*MB);
+            testMemory("1g", "" + 1024*MB);
+
+            testProcessInfo();
+
+        } finally {
+            DockerTestUtils.removeDockerImage(imageName);
+        }
+    }
+
+
+    private static void testCPUInfo(int valueToSet, int expectedValue) throws Exception {
+        Common.logNewTestCase("CPUInfo: --cpus = " + valueToSet);
+        DockerTestUtils.dockerRunJava(
+                                      commonDockerOpts()
+                                      .addDockerOpts("--cpus=" + valueToSet)
+                                      .addClassOptions(JfrReporter.TESTCASE_CPU))
+            .shouldHaveExitValue(0)
+            .shouldContain(JfrReporter.TEST_REPORTED_CORES);
+
+        // The following assertion is currently disabled due to JFR reporting incorrect values.
+        // JFR reports values for the host system as opposed to values for the container.
+        // @ignore 8219999
+        // .shouldContain(JfrReporter.TEST_REPORTED_CORES + "=" + expectedValue);
+    }
+
+
+    private static void testMemory(String valueToSet, String expectedValue) throws Exception {
+        Common.logNewTestCase("Memory: --memory = " + valueToSet);
+        DockerTestUtils.dockerRunJava(
+                                      commonDockerOpts()
+                                      .addDockerOpts("--memory=" + valueToSet)
+                                      .addClassOptions(JfrReporter.TESTCASE_MEMORY))
+            .shouldHaveExitValue(0)
+            .shouldContain(JfrReporter.TEST_REPORTED_MEMORY + "=" + expectedValue);
+    }
+
+
+    private static void testProcessInfo() throws Exception {
+        Common.logNewTestCase("ProcessInfo");
+        DockerTestUtils.dockerRunJava(
+                                      commonDockerOpts()
+                                      .addClassOptions(JfrReporter.TESTCASE_PROCESS))
+            .shouldHaveExitValue(0)
+            .shouldContain(JfrReporter.TEST_REPORTED_PID + "=1");
+
+    }
+
+
+    private static DockerRunOptions commonDockerOpts() {
+        return new DockerRunOptions(imageName, "/jdk/bin/java", "JfrReporter")
+            .addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
+            .addJavaOpts("-cp", "/test-classes/");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/TestMemoryAwareness.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,112 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
+ * @summary Test JVM's memory resource awareness when running inside docker container
+ * @requires docker.support
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ *          jdk.jartool/sun.tools.jar
+ * @build AttemptOOM sun.hotspot.WhiteBox PrintContainerInfo
+ * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run driver TestMemoryAwareness
+ */
+import jdk.test.lib.containers.docker.Common;
+import jdk.test.lib.containers.docker.DockerRunOptions;
+import jdk.test.lib.containers.docker.DockerTestUtils;
+
+
+public class TestMemoryAwareness {
+    private static final String imageName = Common.imageName("memory");
+
+    public static void main(String[] args) throws Exception {
+        if (!DockerTestUtils.canTestDocker()) {
+            return;
+        }
+
+        Common.prepareWhiteBox();
+        DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
+
+        try {
+            testMemoryLimit("100m", "104857600");
+            testMemoryLimit("500m", "524288000");
+            testMemoryLimit("1g", "1073741824");
+            testMemoryLimit("4g", "4294967296");
+
+            testMemorySoftLimit("500m", "524288000");
+            testMemorySoftLimit("1g", "1073741824");
+
+            // Add extra 10 Mb to allocator limit, to be sure to cause OOM
+            testOOM("256m", 256 + 10);
+
+        } finally {
+            DockerTestUtils.removeDockerImage(imageName);
+        }
+    }
+
+
+    private static void testMemoryLimit(String valueToSet, String expectedTraceValue)
+            throws Exception {
+
+        Common.logNewTestCase("memory limit: " + valueToSet);
+
+        DockerRunOptions opts = Common.newOpts(imageName)
+            .addDockerOpts("--memory", valueToSet);
+
+        Common.run(opts)
+            .shouldMatch("Memory Limit is:.*" + expectedTraceValue);
+    }
+
+
+    private static void testMemorySoftLimit(String valueToSet, String expectedTraceValue)
+            throws Exception {
+        Common.logNewTestCase("memory soft limit: " + valueToSet);
+
+        DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo");
+        Common.addWhiteBoxOpts(opts);
+        opts.addDockerOpts("--memory-reservation=" + valueToSet);
+
+        Common.run(opts)
+            .shouldMatch("Memory Soft Limit.*" + expectedTraceValue);
+    }
+
+
+    // provoke OOM inside the container, see how VM reacts
+    private static void testOOM(String dockerMemLimit, int sizeToAllocInMb) throws Exception {
+        Common.logNewTestCase("OOM");
+
+        DockerRunOptions opts = Common.newOpts(imageName, "AttemptOOM")
+            .addDockerOpts("--memory", dockerMemLimit, "--memory-swap", dockerMemLimit);
+        opts.classParams.add("" + sizeToAllocInMb);
+
+        DockerTestUtils.dockerRunJava(opts)
+            .shouldHaveExitValue(1)
+            .shouldContain("Entering AttemptOOM main")
+            .shouldNotContain("AttemptOOM allocation successful")
+            .shouldContain("java.lang.OutOfMemoryError");
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hotspot/jtreg/containers/docker/TestMisc.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
+ * 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
+ * @summary Test miscellanous functionality related to JVM running in docker container
+ * @requires docker.support
+ * @library /test/lib
+ * @modules java.base/jdk.internal.misc
+ *          java.management
+ *          jdk.jartool/sun.tools.jar
+ * @build CheckContainerized sun.hotspot.WhiteBox PrintContainerInfo
+ * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
+ * @run driver TestMisc
+ */
+import jdk.test.lib.containers.docker.Common;
+import jdk.test.lib.containers.docker.DockerTestUtils;
+import jdk.test.lib.containers.docker.DockerRunOptions;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+
+public class TestMisc {
+    private static final String imageName = Common.imageName("misc");
+
+    public static void main(String[] args) throws Exception {
+        if (!DockerTestUtils.canTestDocker()) {
+            return;
+        }
+
+        Common.prepareWhiteBox();
+        DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
+
+        try {
+            testMinusContainerSupport();
+            testIsContainerized();
+            testPrintContainerInfo();
+        } finally {
+            DockerTestUtils.removeDockerImage(imageName);
+        }
+    }
+
+
+    private static void testMinusContainerSupport() throws Exception {
+        Common.logNewTestCase("Test related flags: '-UseContainerSupport'");
+        DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java", "-version");
+        opts.addJavaOpts("-XX:-UseContainerSupport", "-Xlog:os+container=trace");
+
+        Common.run(opts)
+            .shouldContain("Container Support not enabled");
+    }
+
+
+    private static void testIsContainerized() throws Exception {
+        Common.logNewTestCase("Test is_containerized() inside a docker container");
+
+        DockerRunOptions opts = Common.newOpts(imageName, "CheckContainerized");
+        Common.addWhiteBoxOpts(opts);
+
+        Common.run(opts)
+            .shouldContain(CheckContainerized.INSIDE_A_CONTAINER);
+    }
+
+
+    private static void testPrintContainerInfo() throws Exception {
+        Common.logNewTestCase("Test print_container_info()");
+
+        DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo");
+        Common.addWhiteBoxOpts(opts);
+
+        checkContainerInfo(Common.run(opts));
+    }
+
+
+    private static void checkContainerInfo(OutputAnalyzer out) throws Exception {
+        String[] expectedToContain = new String[] {
+            "cpuset.cpus",
+            "cpuset.mems",
+            "CPU Shares",
+            "CPU Quota",
+            "CPU Period",
+            "OSContainer::active_processor_count",
+            "Memory Limit",
+            "Memory Soft Limit",
+            "Memory Usage",
+            "Maximum Memory Usage",
+            "memory_max_usage_in_bytes"
+        };
+
+        for (String s : expectedToContain) {
+            out.shouldContain(s);
+        }
+    }
+
+}
--- a/test/hotspot/jtreg/runtime/containers/cgroup/PlainRead.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,77 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * 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 PlainRead
- * @requires os.family == "linux"
- * @library /testlibrary /test/lib
- * @build sun.hotspot.WhiteBox
- * @run driver ClassFileInstaller sun.hotspot.WhiteBox
- *                              sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI PlainRead
- */
-
-import jdk.test.lib.process.ProcessTools;
-import jdk.test.lib.process.OutputAnalyzer;
-import jdk.test.lib.Platform;
-import sun.hotspot.WhiteBox;
-
-public class PlainRead {
-
-    static public void match(OutputAnalyzer oa, String what, String value) {
-       oa.shouldMatch("^.*" + what + " *" + value + ".*$");
-    }
-
-    static public void noMatch(OutputAnalyzer oa, String what, String value) {
-       oa.shouldNotMatch("^.*" + what + " *" + value + ".*$");
-    }
-
-    static final String good_value = "(\\d+|-1|Unlimited)";
-    static final String bad_value = "(failed)";
-
-    static final String[] variables = {"Memory Limit is:", "CPU Shares is:", "CPU Quota is:", "CPU Period is:", "active_processor_count:"};
-
-    static public void isContainer(OutputAnalyzer oa) {
-        for (String v: variables) {
-            match(oa, v, good_value);
-        }
-        for (String v: variables) {
-            noMatch(oa, v, bad_value);
-        }
-    }
-
-    static public void isNotContainer(OutputAnalyzer oa) {
-       oa.shouldMatch("^.*Can't open /proc/self/mountinfo.*$");
-    }
-
-    public static void main(String[] args) throws Exception {
-        WhiteBox wb = WhiteBox.getWhiteBox();
-        ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-Xlog:os+container=trace", "-version");
-        OutputAnalyzer output = new OutputAnalyzer(pb.start());
-
-        if (wb.isContainerized()) {
-            System.out.println("Inside a cgroup, testing...");
-            isContainer(output);
-        }
-    }
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/AttemptOOM.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +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.
- */
-
-public class AttemptOOM {
-    private static MyObj[] data;
-
-    public static void main(String[] args) throws Exception {
-        System.out.println("Entering AttemptOOM main");
-
-        // each MyObj will allocate 1024 byte array
-        int sizeInMb = Integer.parseInt(args[0]);
-        data = new MyObj[sizeInMb*1024];
-
-        System.out.println("data.length = " + data.length);
-
-        for (int i=0; i < data.length; i++) {
-            data[i] = new MyObj(1024);
-        }
-
-        System.out.println("AttemptOOM allocation successful");
-    }
-
-    private static class MyObj {
-        private byte[] myData;
-        MyObj(int size) {
-            myData = new byte[size];
-        }
-    }
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/CheckContainerized.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +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.
- */
-
-import sun.hotspot.WhiteBox;
-
-public class CheckContainerized {
-    public static String OUTSIDE_OF_CONTAINER =
-        "CheckContainerized: Running outside of a container";
-    public static String INSIDE_A_CONTAINER =
-        "CheckContainerized: Running inside a container";
-
-    public static void main(String[] args) {
-        System.out.println("CheckContainerized: Entering");
-        WhiteBox wb = WhiteBox.getWhiteBox();
-
-        if (wb.isContainerized()) {
-            System.out.println(INSIDE_A_CONTAINER);
-
-        } else {
-            System.out.println(OUTSIDE_OF_CONTAINER);
-        }
-    }
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/DockerBasicTest.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
- * 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
- * @summary Basic (sanity) test for JDK-under-test inside a docker image.
- * @requires docker.support
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- *          java.management
- *          jdk.jartool/sun.tools.jar
- * @build HelloDocker
- * @run driver DockerBasicTest
- */
-import jdk.test.lib.containers.docker.Common;
-import jdk.test.lib.containers.docker.DockerRunOptions;
-import jdk.test.lib.containers.docker.DockerTestUtils;
-import jdk.test.lib.Platform;
-import jdk.test.lib.Utils;
-
-
-public class DockerBasicTest {
-    private static final String imageNameAndTag = Common.imageName("basic");
-
-    public static void main(String[] args) throws Exception {
-        if (!DockerTestUtils.canTestDocker()) {
-            return;
-        }
-
-        DockerTestUtils.buildJdkDockerImage(imageNameAndTag, "Dockerfile-BasicTest", "jdk-docker");
-
-        try {
-            testJavaVersion();
-            testHelloDocker();
-        } finally {
-            if (!DockerTestUtils.RETAIN_IMAGE_AFTER_TEST) {
-                DockerTestUtils.removeDockerImage(imageNameAndTag);
-            }
-        }
-    }
-
-
-    private static void testJavaVersion() throws Exception {
-        DockerRunOptions opts =
-            new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", "-version");
-
-        DockerTestUtils.dockerRunJava(opts)
-            .shouldHaveExitValue(0)
-            .shouldContain(Platform.vmName);
-    }
-
-
-    private static void testHelloDocker() throws Exception {
-        DockerRunOptions opts =
-            new DockerRunOptions(imageNameAndTag, "/jdk/bin/java", "HelloDocker")
-            .addJavaOpts("-cp", "/test-classes/")
-            .addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/");
-
-        DockerTestUtils.dockerRunJava(opts)
-            .shouldHaveExitValue(0)
-            .shouldContain("Hello Docker");
-    }
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/HelloDocker.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,28 +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.
- */
-
-public class HelloDocker {
-    public static void main(String args[]) {
-        System.out.println("Hello Docker");
-    }
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/JfrReporter.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
- * 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.nio.file.Paths;
-import jdk.jfr.Recording;
-import jdk.jfr.consumer.RecordedEvent;
-import jdk.jfr.consumer.RecordingFile;
-
-
-// This class is intended to run inside a container
-public class JfrReporter {
-    public static final String TEST_REPORTED_CORES="TEST_REPORTED_CORES";
-    public static final String TEST_REPORTED_MEMORY="TEST_REPORTED_MEMORY";
-    public static final String TEST_REPORTED_PID="TEST_REPORTED_PID";
-    public static final String TESTCASE_CPU="cpu";
-    public static final String TESTCASE_MEMORY="memory";
-    public static final String TESTCASE_PROCESS="process";
-
-    public static void main(String[] args) throws Exception {
-        String testCase = args[0];
-        System.out.println("Testcase: " + testCase);
-        switch (testCase) {
-        case TESTCASE_CPU:
-            RecordedEvent event = testEvent("jdk.CPUInformation", "cpu.jfr");
-            System.out.println(TEST_REPORTED_CORES + "=" + event.getInt("cores"));
-            break;
-        case TESTCASE_MEMORY:
-            event = testEvent("jdk.PhysicalMemory", "memory.jfr");
-            System.out.println(TEST_REPORTED_MEMORY + "=" + event.getLong("totalSize"));
-            break;
-        case TESTCASE_PROCESS:
-            event = testEvent("jdk.SystemProcess", "process.jfr");
-            System.out.println(TEST_REPORTED_PID + "=" + event.getString("pid"));
-            break;
-        default:
-            throw new IllegalArgumentException("Invalid test case");
-        }
-    }
-
-    private static RecordedEvent testEvent(String event, String recordingPath) throws Exception {
-        System.out.println("========= Testing event: " + event);
-        Recording r = new Recording();
-        r.enable(event);
-        r.setDestination(Paths.get("tmp", recordingPath));
-        r.start();
-        r.stop();
-
-        RecordedEvent recordedEvent = RecordingFile.readAllEvents(r.getDestination()).get(0);
-        System.out.println("RecordedEvent: " + recordedEvent);
-        return recordedEvent;
-    }
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/PrintContainerInfo.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +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.
- */
-
-import sun.hotspot.WhiteBox;
-
-public class PrintContainerInfo {
-
-    public static void main(String[] args) {
-        System.out.println("PrintContainerInfo: Entering");
-        WhiteBox wb = WhiteBox.getWhiteBox();
-
-        wb.printOsInfo();
-    }
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/TEST.properties	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-exclusiveAccess.dirs=.
--- a/test/hotspot/jtreg/runtime/containers/docker/TestCPUAwareness.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,209 +0,0 @@
-/*
- * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
- * 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
- * @summary Test JVM's CPU resource awareness when running inside docker container
- * @requires docker.support
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- *          java.management
- *          jdk.jartool/sun.tools.jar
- * @run driver TestCPUAwareness
- */
-import java.util.List;
-import jdk.test.lib.containers.docker.Common;
-import jdk.test.lib.containers.docker.DockerRunOptions;
-import jdk.test.lib.containers.docker.DockerTestUtils;
-import jdk.test.lib.containers.cgroup.CPUSetsReader;
-
-public class TestCPUAwareness {
-    private static final String imageName = Common.imageName("cpu");
-    private static final int availableCPUs = Runtime.getRuntime().availableProcessors();
-
-    public static void main(String[] args) throws Exception {
-        if (!DockerTestUtils.canTestDocker()) {
-            return;
-        }
-
-        System.out.println("Test Environment: detected availableCPUs = " + availableCPUs);
-        DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
-
-        try {
-            // cpuset, period, shares, expected Active Processor Count
-            testComboWithCpuSets();
-
-            // cpu shares - it should be safe to use CPU shares exceeding available CPUs
-            testCpuShares(256, 1);
-            testCpuShares(2048, 2);
-            testCpuShares(4096, 4);
-
-            // leave one CPU for system and tools, otherwise this test may be unstable
-            int maxNrOfAvailableCpus =  availableCPUs - 1;
-            for (int i=1; i < maxNrOfAvailableCpus; i = i * 2) {
-                testCpus(i, i);
-            }
-
-            // If ActiveProcessorCount is set, the VM should use it, regardless of other
-            // container settings, host settings or available CPUs on the host.
-            testActiveProcessorCount(1, 1);
-            testActiveProcessorCount(2, 2);
-
-            // cpu quota and period
-            testCpuQuotaAndPeriod(50*1000, 100*1000);
-            testCpuQuotaAndPeriod(100*1000, 100*1000);
-            testCpuQuotaAndPeriod(150*1000, 100*1000);
-            testCpuQuotaAndPeriod(400*1000, 100*1000);
-
-        } finally {
-            DockerTestUtils.removeDockerImage(imageName);
-        }
-    }
-
-
-    private static void testComboWithCpuSets() throws Exception {
-        String cpuSetStr = CPUSetsReader.readFromProcStatus("Cpus_allowed_list");
-        System.out.println("cpuSetStr = " + cpuSetStr);
-
-        if (cpuSetStr == null) {
-            System.out.printf("The cpuset test cases are skipped");
-        } else {
-            List<Integer> cpuSet = CPUSetsReader.parseCpuSet(cpuSetStr);
-
-            // Test subset of cpuset with one element
-            if (cpuSet.size() >= 1) {
-                String testCpuSet = CPUSetsReader.listToString(cpuSet, 1);
-                testAPCCombo(testCpuSet, 200*1000, 100*1000,   4*1024, true, 1);
-            }
-
-            // Test subset of cpuset with two elements
-            if (cpuSet.size() >= 2) {
-                String testCpuSet = CPUSetsReader.listToString(cpuSet, 2);
-                testAPCCombo(testCpuSet, 200*1000, 100*1000, 4*1024, true, 2);
-                testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   true, 2);
-                testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   false,  1);
-            }
-
-            // Test subset of cpuset with three elements
-            if (cpuSet.size() >= 3) {
-                String testCpuSet = CPUSetsReader.listToString(cpuSet, 3);
-                testAPCCombo(testCpuSet, 100*1000, 100*1000, 2*1024, true, 1);
-                testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   true, 2);
-                testAPCCombo(testCpuSet, 200*1000, 100*1000, 1023,   false,  1);
-            }
-        }
-    }
-
-
-    private static void testActiveProcessorCount(int valueToSet, int expectedValue) throws Exception {
-        Common.logNewTestCase("Test ActiveProcessorCount: valueToSet = " + valueToSet);
-
-        DockerRunOptions opts = Common.newOpts(imageName)
-            .addJavaOpts("-XX:ActiveProcessorCount=" + valueToSet, "-Xlog:os=trace");
-        Common.run(opts)
-            .shouldMatch("active processor count set by user.*" + expectedValue);
-    }
-
-
-    private static void testCpus(int valueToSet, int expectedTraceValue) throws Exception {
-        Common.logNewTestCase("test cpus: " + valueToSet);
-        DockerRunOptions opts = Common.newOpts(imageName)
-            .addDockerOpts("--cpu-period=" + 10000)
-            .addDockerOpts("--cpu-quota=" + valueToSet * 10000);
-        Common.run(opts)
-            .shouldMatch("active_processor_count.*" + expectedTraceValue);
-    }
-
-
-    // Expected active processor count can not exceed available CPU count
-    private static int adjustExpectedAPCForAvailableCPUs(int expectedAPC) {
-        if (expectedAPC > availableCPUs) {
-            expectedAPC = availableCPUs;
-            System.out.println("Adjusted expectedAPC = " + expectedAPC);
-        }
-        return expectedAPC;
-    }
-
-
-    private static void testCpuQuotaAndPeriod(int quota, int period)
-        throws Exception {
-        Common.logNewTestCase("test cpu quota and period: ");
-        System.out.println("quota = " + quota);
-        System.out.println("period = " + period);
-
-        int expectedAPC = (int) Math.ceil((float) quota / (float) period);
-        System.out.println("expectedAPC = " + expectedAPC);
-        expectedAPC = adjustExpectedAPCForAvailableCPUs(expectedAPC);
-
-        DockerRunOptions opts = Common.newOpts(imageName)
-            .addDockerOpts("--cpu-period=" + period)
-            .addDockerOpts("--cpu-quota=" + quota);
-
-        Common.run(opts)
-            .shouldMatch("CPU Period is.*" + period)
-            .shouldMatch("CPU Quota is.*" + quota)
-            .shouldMatch("active_processor_count.*" + expectedAPC);
-    }
-
-
-    // Test correctess of automatically selected active processor cound
-    private static void testAPCCombo(String cpuset, int quota, int period, int shares,
-                                     boolean usePreferContainerQuotaForCPUCount,
-                                     int expectedAPC) throws Exception {
-        Common.logNewTestCase("test APC Combo");
-        System.out.println("cpuset = " + cpuset);
-        System.out.println("quota = " + quota);
-        System.out.println("period = " + period);
-        System.out.println("shares = " + shares);
-        System.out.println("usePreferContainerQuotaForCPUCount = " + usePreferContainerQuotaForCPUCount);
-        System.out.println("expectedAPC = " + expectedAPC);
-
-        expectedAPC = adjustExpectedAPCForAvailableCPUs(expectedAPC);
-
-        DockerRunOptions opts = Common.newOpts(imageName)
-            .addDockerOpts("--cpuset-cpus", "" + cpuset)
-            .addDockerOpts("--cpu-period=" + period)
-            .addDockerOpts("--cpu-quota=" + quota)
-            .addDockerOpts("--cpu-shares=" + shares);
-
-        if (!usePreferContainerQuotaForCPUCount) opts.addJavaOpts("-XX:-PreferContainerQuotaForCPUCount");
-
-        Common.run(opts)
-            .shouldMatch("active_processor_count.*" + expectedAPC);
-    }
-
-
-    private static void testCpuShares(int shares, int expectedAPC) throws Exception {
-        Common.logNewTestCase("test cpu shares, shares = " + shares);
-        System.out.println("expectedAPC = " + expectedAPC);
-
-        expectedAPC = adjustExpectedAPCForAvailableCPUs(expectedAPC);
-
-        DockerRunOptions opts = Common.newOpts(imageName)
-            .addDockerOpts("--cpu-shares=" + shares);
-        Common.run(opts)
-            .shouldMatch("CPU Shares is.*" + shares)
-            .shouldMatch("active_processor_count.*" + expectedAPC);
-    }
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/TestCPUSets.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,142 +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.
- */
-
-
-/*
- * @test
- * @summary Test JVM's awareness of cpu sets (cpus and mems)
- * @requires docker.support
- * @requires (os.arch != "s390x")
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- *          java.management
- *          jdk.jartool/sun.tools.jar
- * @build AttemptOOM sun.hotspot.WhiteBox PrintContainerInfo
- * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run driver TestCPUSets
- */
-import java.util.List;
-import jdk.test.lib.containers.docker.Common;
-import jdk.test.lib.containers.docker.DockerRunOptions;
-import jdk.test.lib.containers.docker.DockerTestUtils;
-import jdk.test.lib.containers.cgroup.CPUSetsReader;
-import jdk.test.lib.Asserts;
-import jdk.test.lib.Platform;
-import jdk.test.lib.Utils;
-import jdk.test.lib.process.OutputAnalyzer;
-
-
-public class TestCPUSets {
-    private static final String imageName = Common.imageName("cpusets");
-
-    public static void main(String[] args) throws Exception {
-        if (!DockerTestUtils.canTestDocker()) {
-            return;
-        }
-
-        Common.prepareWhiteBox();
-        DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
-
-        try {
-            // Sanity test the cpu sets reader and parser
-            CPUSetsReader.test();
-            testTheSet("Cpus_allowed_list");
-            testTheSet("Mems_allowed_list");
-        } finally {
-            DockerTestUtils.removeDockerImage(imageName);
-        }
-    }
-
-
-    private static void testTheSet(String setType) throws Exception {
-        String cpuSetStr = CPUSetsReader.readFromProcStatus(setType);
-
-        if (cpuSetStr == null) {
-            System.out.printf("The %s test is skipped %n", setType);
-        } else {
-            List<Integer> cpuSet = CPUSetsReader.parseCpuSet(cpuSetStr);
-
-            // Test subset of one, full subset, and half of the subset
-            testCpuSet(CPUSetsReader.listToString(cpuSet, 1));
-            if (cpuSet.size() > 1) {
-                testCpuSet(CPUSetsReader.listToString(cpuSet));
-            }
-            if (cpuSet.size() > 2) {
-                testCpuSet(CPUSetsReader.listToString(cpuSet, cpuSet.size()/2 ));
-            }
-        }
-    }
-
-
-    private static DockerRunOptions commonOpts() {
-        DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java",
-                                                     "PrintContainerInfo");
-        opts.addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/");
-        opts.addJavaOpts("-Xlog:os+container=trace", "-cp", "/test-classes/");
-        Common.addWhiteBoxOpts(opts);
-        return opts;
-    }
-
-
-    private static void checkResult(List<String> lines, String lineMarker, String value) {
-        boolean lineMarkerFound = false;
-
-        for (String line : lines) {
-            if (line.contains(lineMarker)) {
-                lineMarkerFound = true;
-                String[] parts = line.split(":");
-                System.out.println("DEBUG: line = " + line);
-                System.out.println("DEBUG: parts.length = " + parts.length);
-
-                Asserts.assertEquals(parts.length, 2);
-                String set = parts[1].replaceAll("\\s","");
-                String actual = CPUSetsReader.listToString(CPUSetsReader.parseCpuSet(set));
-                Asserts.assertEquals(actual, value);
-                break;
-            }
-        }
-        Asserts.assertTrue(lineMarkerFound);
-    }
-
-
-    private static void testCpuSet(String value) throws Exception {
-        Common.logNewTestCase("cpusets.cpus, value = " + value);
-
-        DockerRunOptions opts = commonOpts();
-        opts.addDockerOpts("--cpuset-cpus=" + value);
-
-        List<String> lines = Common.run(opts).asLines();
-        checkResult(lines, "cpuset.cpus is:", value);
-    }
-
-    private static void testMemSet(String value) throws Exception {
-        Common.logNewTestCase("cpusets.mems, value = " + value);
-
-        DockerRunOptions opts = commonOpts();
-        opts.addDockerOpts("--cpuset-mems=" + value);
-
-        List<String> lines = Common.run(opts).asLines();
-        checkResult(lines, "cpuset.mems is:", value);
-    }
-
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/TestJFREvents.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,120 +0,0 @@
-/*
- * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
- * 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
- * @summary Ensure that certain JFR events return correct results for resource values
- *          when run inside Docker container, such as available CPU and memory.
- *          Also make sure that PIDs are based on value provided by container,
- *          not by the host system.
- * @requires (docker.support & os.maxMemory >= 2g)
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- *          java.management
- *          jdk.jartool/sun.tools.jar
- * @build JfrReporter
- * @run driver TestJFREvents
- */
-import jdk.test.lib.containers.docker.Common;
-import jdk.test.lib.containers.docker.DockerRunOptions;
-import jdk.test.lib.containers.docker.DockerTestUtils;
-import jdk.test.lib.Utils;
-
-
-public class TestJFREvents {
-    private static final String imageName = Common.imageName("jfr-events");
-    private static final int availableCPUs = Runtime.getRuntime().availableProcessors();
-
-    public static void main(String[] args) throws Exception {
-        System.out.println("Test Environment: detected availableCPUs = " + availableCPUs);
-        if (!DockerTestUtils.canTestDocker()) {
-            return;
-        }
-
-        DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
-
-        try {
-            // leave one CPU for system and tools, otherwise this test may be unstable
-            int maxNrOfAvailableCpus =  availableCPUs - 1;
-            for (int i=1; i < maxNrOfAvailableCpus; i = i * 2) {
-                testCPUInfo(i, i);
-            }
-
-            long MB = 1024*1024;
-            testMemory("200m", "" + 200*MB);
-            testMemory("500m", "" + 500*MB);
-            testMemory("1g", "" + 1024*MB);
-
-            testProcessInfo();
-
-        } finally {
-            DockerTestUtils.removeDockerImage(imageName);
-        }
-    }
-
-
-    private static void testCPUInfo(int valueToSet, int expectedValue) throws Exception {
-        Common.logNewTestCase("CPUInfo: --cpus = " + valueToSet);
-        DockerTestUtils.dockerRunJava(
-                                      commonDockerOpts()
-                                      .addDockerOpts("--cpus=" + valueToSet)
-                                      .addClassOptions(JfrReporter.TESTCASE_CPU))
-            .shouldHaveExitValue(0)
-            .shouldContain(JfrReporter.TEST_REPORTED_CORES);
-
-        // The following assertion is currently disabled due to JFR reporting incorrect values.
-        // JFR reports values for the host system as opposed to values for the container.
-        // @ignore 8219999
-        // .shouldContain(JfrReporter.TEST_REPORTED_CORES + "=" + expectedValue);
-    }
-
-
-    private static void testMemory(String valueToSet, String expectedValue) throws Exception {
-        Common.logNewTestCase("Memory: --memory = " + valueToSet);
-        DockerTestUtils.dockerRunJava(
-                                      commonDockerOpts()
-                                      .addDockerOpts("--memory=" + valueToSet)
-                                      .addClassOptions(JfrReporter.TESTCASE_MEMORY))
-            .shouldHaveExitValue(0)
-            .shouldContain(JfrReporter.TEST_REPORTED_MEMORY + "=" + expectedValue);
-    }
-
-
-    private static void testProcessInfo() throws Exception {
-        Common.logNewTestCase("ProcessInfo");
-        DockerTestUtils.dockerRunJava(
-                                      commonDockerOpts()
-                                      .addClassOptions(JfrReporter.TESTCASE_PROCESS))
-            .shouldHaveExitValue(0)
-            .shouldContain(JfrReporter.TEST_REPORTED_PID + "=1");
-
-    }
-
-
-    private static DockerRunOptions commonDockerOpts() {
-        return new DockerRunOptions(imageName, "/jdk/bin/java", "JfrReporter")
-            .addDockerOpts("--volume", Utils.TEST_CLASSES + ":/test-classes/")
-            .addJavaOpts("-cp", "/test-classes/");
-    }
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/TestMemoryAwareness.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * 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
- * @summary Test JVM's memory resource awareness when running inside docker container
- * @requires docker.support
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- *          java.management
- *          jdk.jartool/sun.tools.jar
- * @build AttemptOOM sun.hotspot.WhiteBox PrintContainerInfo
- * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run driver TestMemoryAwareness
- */
-import jdk.test.lib.containers.docker.Common;
-import jdk.test.lib.containers.docker.DockerRunOptions;
-import jdk.test.lib.containers.docker.DockerTestUtils;
-
-
-public class TestMemoryAwareness {
-    private static final String imageName = Common.imageName("memory");
-
-    public static void main(String[] args) throws Exception {
-        if (!DockerTestUtils.canTestDocker()) {
-            return;
-        }
-
-        Common.prepareWhiteBox();
-        DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
-
-        try {
-            testMemoryLimit("100m", "104857600");
-            testMemoryLimit("500m", "524288000");
-            testMemoryLimit("1g", "1073741824");
-            testMemoryLimit("4g", "4294967296");
-
-            testMemorySoftLimit("500m", "524288000");
-            testMemorySoftLimit("1g", "1073741824");
-
-            // Add extra 10 Mb to allocator limit, to be sure to cause OOM
-            testOOM("256m", 256 + 10);
-
-        } finally {
-            DockerTestUtils.removeDockerImage(imageName);
-        }
-    }
-
-
-    private static void testMemoryLimit(String valueToSet, String expectedTraceValue)
-            throws Exception {
-
-        Common.logNewTestCase("memory limit: " + valueToSet);
-
-        DockerRunOptions opts = Common.newOpts(imageName)
-            .addDockerOpts("--memory", valueToSet);
-
-        Common.run(opts)
-            .shouldMatch("Memory Limit is:.*" + expectedTraceValue);
-    }
-
-
-    private static void testMemorySoftLimit(String valueToSet, String expectedTraceValue)
-            throws Exception {
-        Common.logNewTestCase("memory soft limit: " + valueToSet);
-
-        DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo");
-        Common.addWhiteBoxOpts(opts);
-        opts.addDockerOpts("--memory-reservation=" + valueToSet);
-
-        Common.run(opts)
-            .shouldMatch("Memory Soft Limit.*" + expectedTraceValue);
-    }
-
-
-    // provoke OOM inside the container, see how VM reacts
-    private static void testOOM(String dockerMemLimit, int sizeToAllocInMb) throws Exception {
-        Common.logNewTestCase("OOM");
-
-        DockerRunOptions opts = Common.newOpts(imageName, "AttemptOOM")
-            .addDockerOpts("--memory", dockerMemLimit, "--memory-swap", dockerMemLimit);
-        opts.classParams.add("" + sizeToAllocInMb);
-
-        DockerTestUtils.dockerRunJava(opts)
-            .shouldHaveExitValue(1)
-            .shouldContain("Entering AttemptOOM main")
-            .shouldNotContain("AttemptOOM allocation successful")
-            .shouldContain("java.lang.OutOfMemoryError");
-    }
-
-}
--- a/test/hotspot/jtreg/runtime/containers/docker/TestMisc.java	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-/*
- * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved.
- * 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
- * @summary Test miscellanous functionality related to JVM running in docker container
- * @requires docker.support
- * @library /test/lib
- * @modules java.base/jdk.internal.misc
- *          java.management
- *          jdk.jartool/sun.tools.jar
- * @build CheckContainerized sun.hotspot.WhiteBox PrintContainerInfo
- * @run driver ClassFileInstaller -jar whitebox.jar sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
- * @run driver TestMisc
- */
-import jdk.test.lib.containers.docker.Common;
-import jdk.test.lib.containers.docker.DockerTestUtils;
-import jdk.test.lib.containers.docker.DockerRunOptions;
-import jdk.test.lib.process.OutputAnalyzer;
-import jdk.test.lib.process.ProcessTools;
-
-
-public class TestMisc {
-    private static final String imageName = Common.imageName("misc");
-
-    public static void main(String[] args) throws Exception {
-        if (!DockerTestUtils.canTestDocker()) {
-            return;
-        }
-
-        Common.prepareWhiteBox();
-        DockerTestUtils.buildJdkDockerImage(imageName, "Dockerfile-BasicTest", "jdk-docker");
-
-        try {
-            testMinusContainerSupport();
-            testIsContainerized();
-            testPrintContainerInfo();
-        } finally {
-            DockerTestUtils.removeDockerImage(imageName);
-        }
-    }
-
-
-    private static void testMinusContainerSupport() throws Exception {
-        Common.logNewTestCase("Test related flags: '-UseContainerSupport'");
-        DockerRunOptions opts = new DockerRunOptions(imageName, "/jdk/bin/java", "-version");
-        opts.addJavaOpts("-XX:-UseContainerSupport", "-Xlog:os+container=trace");
-
-        Common.run(opts)
-            .shouldContain("Container Support not enabled");
-    }
-
-
-    private static void testIsContainerized() throws Exception {
-        Common.logNewTestCase("Test is_containerized() inside a docker container");
-
-        DockerRunOptions opts = Common.newOpts(imageName, "CheckContainerized");
-        Common.addWhiteBoxOpts(opts);
-
-        Common.run(opts)
-            .shouldContain(CheckContainerized.INSIDE_A_CONTAINER);
-    }
-
-
-    private static void testPrintContainerInfo() throws Exception {
-        Common.logNewTestCase("Test print_container_info()");
-
-        DockerRunOptions opts = Common.newOpts(imageName, "PrintContainerInfo");
-        Common.addWhiteBoxOpts(opts);
-
-        checkContainerInfo(Common.run(opts));
-    }
-
-
-    private static void checkContainerInfo(OutputAnalyzer out) throws Exception {
-        String[] expectedToContain = new String[] {
-            "cpuset.cpus",
-            "cpuset.mems",
-            "CPU Shares",
-            "CPU Quota",
-            "CPU Period",
-            "OSContainer::active_processor_count",
-            "Memory Limit",
-            "Memory Soft Limit",
-            "Memory Usage",
-            "Maximum Memory Usage",
-            "memory_max_usage_in_bytes"
-        };
-
-        for (String s : expectedToContain) {
-            out.shouldContain(s);
-        }
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/AlgOptions.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 5094028 6219522
+ * @summary test new jarsigner -sigalg and -digestalg options
+ * @author Sean Mullan
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.List;
+
+public class AlgOptions {
+    public static void main(String[] args) throws Exception {
+
+        // copy jar file into writeable location
+        Files.copy(Path.of(System.getProperty("test.src"), "AlgOptions.jar"),
+                Path.of("AlgOptionsTmp.jar"));
+
+        // test missing signature algorithm arg
+        sign("-sigalg").shouldNotHaveExitValue(0);
+
+        // test missing digest algorithm arg
+        sign("-digestalg").shouldNotHaveExitValue(0);
+
+        // test BOGUS signature algorithm
+        sign("-sigalg", "BOGUS").shouldNotHaveExitValue(0);
+
+        // test BOGUS digest algorithm
+        sign("-digestalg", "BOGUS").shouldNotHaveExitValue(0);
+
+        // test incompatible signature algorithm
+        sign("-sigalg", "SHA1withDSA").shouldNotHaveExitValue(0);
+
+        // test compatible signature algorithm
+        sign("-sigalg", "SHA512withRSA").shouldHaveExitValue(0);
+        verify();
+
+        // test non-default digest algorithm
+        sign("-digestalg", "SHA-1").shouldHaveExitValue(0);
+        verify();
+
+        // test SHA-512 digest algorithm (creates long lines)
+        sign("-digestalg", "SHA-512", "-sigalg", "SHA512withRSA")
+                .shouldHaveExitValue(0);
+        verify();
+    }
+
+    static OutputAnalyzer sign(String... options) throws Exception {
+        List<String> args = new ArrayList<>();
+        args.add("-keystore");
+        args.add(Path.of(System.getProperty("test.src"), "JarSigning.keystore")
+                .toString());
+        args.add("-storepass");
+        args.add("bbbbbb");
+        for (String option : options) {
+            args.add(option);
+        }
+        args.add("AlgOptionsTmp.jar");
+        args.add("c");
+        return SecurityTools.jarsigner(args);
+    }
+
+    static void verify() throws Exception {
+        SecurityTools.jarsigner(
+                "-verify", "AlgOptionsTmp.jar")
+                .shouldHaveExitValue(0);
+    }
+}
--- a/test/jdk/sun/security/tools/jarsigner/AlgOptions.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,224 +0,0 @@
-#
-# 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.
-#
-
-# @test
-# @bug 5094028 6219522
-# @summary test new jarsigner -sigalg and -digestalg options
-# @author Sean Mullan
-#
-# @run shell AlgOptions.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 )
-    NULL=/dev/null
-    PS=":"
-    FS="/"
-    CP="${FS}bin${FS}cp -f"
-    ;;
-  CYGWIN* )
-    NULL=/dev/null
-    PS=";"
-    FS="/"
-    CP="cp -f"
-    ;;
-  Windows_* )
-    NULL=NUL
-    PS=";"
-    FS="\\"
-    CP="cp -f"
-    ;;
-  * )
-    echo "Unrecognized operating system!"
-    exit 1;
-    ;;
-esac
-
-# copy jar file into writeable location
-${CP} ${TESTSRC}${FS}AlgOptions.jar ${TESTCLASSES}${FS}AlgOptionsTmp.jar
-
-failed=0
-# test missing signature algorithm arg
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -sigalg \
-    ${TESTCLASSES}${FS}AlgOptionsTmp.jar c
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 1 failed"
-    failed=1
-else
-    echo "test 1 passed"
-fi
-
-# test missing digest algorithm arg
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -digestalg \
-    ${TESTCLASSES}${FS}AlgOptionsTmp.jar c
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 2 failed"
-    failed=1
-else
-    echo "test 2 passed"
-fi
-
-# test BOGUS signature algorithm
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -sigalg BOGUS \
-    ${TESTCLASSES}${FS}AlgOptionsTmp.jar c
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 3 failed"
-    failed=1
-else
-    echo "test 3 passed"
-fi
-
-# test BOGUS digest algorithm
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -digestalg BOGUS \
-    ${TESTCLASSES}${FS}AlgOptionsTmp.jar c
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 4 failed"
-    failed=1
-else
-    echo "test 4 passed"
-fi
-
-# test incompatible signature algorithm
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -sigalg SHA1withDSA \
-    ${TESTCLASSES}${FS}AlgOptionsTmp.jar c
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 5 failed"
-    failed=1
-else
-    echo "test 5 passed"
-fi
-
-# test compatible signature algorithm
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -sigalg SHA512withRSA \
-    ${TESTCLASSES}${FS}AlgOptionsTmp.jar c
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 6 passed"
-else
-    echo "test 6 failed"
-    failed=1
-fi
-
-# verify it
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -verify ${TESTCLASSES}${FS}AlgOptionsTmp.jar
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 7 passed"
-else
-    echo "test 7 failed"
-    failed=1
-fi
-
-# test non-default digest algorithm
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -digestalg SHA-256 \
-    ${TESTCLASSES}${FS}AlgOptionsTmp.jar c
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 8 passed"
-else
-    echo "test 8 failed"
-    failed=1
-fi
-
-# verify it
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -verify ${TESTCLASSES}${FS}AlgOptionsTmp.jar
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 9 passed"
-else
-    echo "test 9 failed"
-    failed=1
-fi
-
-# test SHA-512 digest algorithm (creates long lines)
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -digestalg SHA-512 \
-    -sigalg SHA512withRSA \
-    ${TESTCLASSES}${FS}AlgOptionsTmp.jar c
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 10 passed"
-else
-    echo "test 10 failed"
-    failed=1
-fi
-
-# verify it
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -verify ${TESTCLASSES}${FS}AlgOptionsTmp.jar
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    echo "test 11 passed"
-else
-    echo "test 11 failed"
-    failed=1
-fi
-
-if [ $failed -eq 1 ]; then
-    exit 1
-else
-    exit 0
-fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/CertPolicy.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8036709
+ * @summary Java 7 jarsigner displays warning about cert policy tree
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.util.JarUtils;
+
+import java.io.FileOutputStream;
+import java.io.PrintStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class CertPolicy {
+    static OutputAnalyzer keytool(String cmd) throws Exception {
+        return SecurityTools.keytool("-keypass changeit -storepass changeit "
+                + "-keystore ks -keyalg rsa " + cmd);
+    }
+
+    static OutputAnalyzer jarsigner(String cmd) throws Exception {
+        return SecurityTools.jarsigner("-storepass changeit -keystore ks " + cmd);
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        keytool("-genkeypair -alias ca -dname CN=CA -ext bc");
+        keytool("-genkeypair -alias int -dname CN=Int");
+        keytool("-genkeypair -alias ee -dname CN=EE");
+
+        // CertificatePolicies [[PolicyId: [1.2.3]], [PolicyId: [1.2.4]]]
+        // PolicyConstraints: [Require: 0; Inhibit: unspecified]
+        keytool("-certreq -alias int -file int.req");
+        keytool("-gencert -rfc -alias ca "
+                + "-ext 2.5.29.32=300C300406022A03300406022A04 "
+                + "-ext 2.5.29.36=3003800100 "
+                + "-ext bc -infile int.req -outfile int.cert");
+        keytool("-import -alias int -file int.cert");
+
+        // CertificatePolicies [[PolicyId: [1.2.3]]]
+        keytool("-certreq -alias ee -file ee.req");
+        keytool("-gencert -rfc -alias int -ext 2.5.29.32=3006300406022A03 "
+                + "-infile ee.req -outfile ee.cert");
+        keytool("-import -alias ee -file ee.cert");
+
+        Files.write(Path.of("cc"), List.of(
+                keytool("-export -alias ee -rfc").getOutput(),
+                keytool("-export -alias int -rfc").getOutput(),
+                keytool("-export -alias ca -rfc").getOutput()));
+
+        keytool("-delete -alias int");
+
+        JarUtils.createJarFile(Path.of("a.jar"), Path.of("."), Path.of("cc"));
+
+        // Make sure the certchain in the signed jar contains all 3 certs
+        jarsigner("-strict -certchain cc a.jar ee -debug")
+                .shouldHaveExitValue(0);
+
+        jarsigner("-strict -verify a.jar -debug")
+                .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/CheckUsage.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,99 @@
+/*
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 7004168
+ * @summary jarsigner -verify checks for KeyUsage codesigning ext on all certs
+ *  instead of just signing cert
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.util.JarUtils;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class CheckUsage {
+
+    static OutputAnalyzer keytool(String cmd) throws Exception {
+        return SecurityTools.keytool("-keypass changeit -storepass changeit "
+                + "-keyalg rsa " + cmd);
+    }
+
+    public static void main(String[] args) throws Exception {
+        Files.write(Path.of("x"), List.of("x"));
+        JarUtils.createJarFile(Path.of("a.jar"), Path.of("."), Path.of("x"));
+
+        // ################### 3 Keystores #######################
+
+        // Keystore js.jks: including CA and Publisher
+        // CA contains a non-empty KeyUsage
+        keytool("-keystore js.jks -genkeypair -alias ca -dname CN=CA "
+                + "-ext KU=kCS -ext bc -validity 365");
+        keytool("-keystore js.jks -genkeypair -alias pub -dname CN=Publisher");
+
+        // Publisher contains the correct KeyUsage
+        keytool("-keystore js.jks -certreq -alias pub -file pub.req");
+        keytool("-keystore js.jks -gencert -alias ca -ext KU=dig -validity 365 "
+                + "-infile pub.req -outfile pub.cert");
+        keytool("-keystore js.jks -importcert -alias pub -file pub.cert");
+
+        // Keystore trust.jks: including CA only
+        keytool("-keystore js.jks -exportcert -alias ca -file ca.cert");
+        keytool("-keystore trust.jks -importcert -alias ca -noprompt -file ca.cert");
+
+        // Keystore unrelated.jks: unrelated
+        keytool("-keystore unrelated.jks -genkeypair -alias nothing "
+                + "-dname CN=Nothing -validity 365");
+
+        // ################### 4 Tests #######################
+
+        // Test 1: Sign should be OK
+
+        SecurityTools.jarsigner("-keystore js.jks -storepass changeit a.jar pub")
+                .shouldHaveExitValue(0);
+
+        // Test 2: Verify should be OK
+
+        SecurityTools.jarsigner("-keystore trust.jks -storepass changeit "
+                + "-strict -verify a.jar")
+                .shouldHaveExitValue(0);
+
+        // Test 3: When no keystore is specified, the error is only
+        // "chain invalid"
+
+        SecurityTools.jarsigner("-strict -verify a.jar")
+                .shouldHaveExitValue(4);
+
+        // Test 4: When unrelated keystore is specified, the error is
+        // "chain invalid" and "not alias in keystore"
+
+        SecurityTools.jarsigner("-keystore unrelated.jks -storepass changeit "
+                + "-strict -verify a.jar")
+                .shouldHaveExitValue(36);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/Collator.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8021789
+ * @summary jarsigner parses alias as command line option (depending on locale)
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.util.JarUtils;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class Collator {
+    public static void main(String[] args) throws Exception {
+
+        Files.write(Path.of("collator"), List.of("12345"));
+        JarUtils.createJarFile(
+                Path.of("collator.jar"), Path.of("."), Path.of("collator"));
+
+        SecurityTools.keytool("-storepass changeit -keypass changeit "
+                + "-keyalg rsa -keystore collator.jks -alias debug "
+                + "-dname CN=debug -genkey -validity 300")
+                .shouldHaveExitValue(0);
+
+        // use "debug" as alias name
+        SecurityTools.jarsigner("-keystore collator.jks "
+                + "-storepass changeit collator.jar debug")
+                .shouldHaveExitValue(0);
+
+        // use "" as alias name (although there will be a warning)
+        SecurityTools.jarsigner("-keystore", "collator.jks",
+                "-storepass", "changeit", "-verify", "collator.jar", "")
+                .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/ConciseJarsigner.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,273 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6802846 8172529
+ * @summary jarsigner needs enhanced cert validation(options)
+ * @library /test/lib
+ * @run main/timeout=240 ConciseJarsigner
+ */
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Calendar;
+import java.util.List;
+
+public class ConciseJarsigner {
+
+    static OutputAnalyzer kt(String cmd) throws Exception {
+        // Choose 1024-bit RSA to make sure it runs fine and fast. In
+        // fact, every keyalg/keysize combination is OK for this test.
+        return SecurityTools.keytool("-storepass changeit -keypass changeit "
+                + "-keystore ks -keyalg rsa -keysize 1024 " + cmd);
+    }
+
+    static void gencert(String owner, String cmd) throws Exception {
+        kt("-certreq -alias " + owner + " -file tmp.req");
+        kt("-gencert -infile tmp.req -outfile tmp.cert " + cmd);
+        kt("-import -alias " + owner + " -file tmp.cert");
+    }
+
+    static OutputAnalyzer js(String cmd) throws Exception {
+        return SecurityTools.jarsigner("-debug " + cmd);
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        Files.write(Path.of("A1"), List.of("a1"));
+        Files.write(Path.of("A2"), List.of("a2"));
+        Files.write(Path.of("A3"), List.of("a3"));
+        Files.write(Path.of("A4"), List.of("a4"));
+        Files.write(Path.of("A5"), List.of("a5"));
+        Files.write(Path.of("A6"), List.of("a6"));
+
+        String year = "" + Calendar.getInstance().get(Calendar.YEAR);
+
+        // ==========================================================
+        // First part: output format
+        // ==========================================================
+
+        kt("-genkeypair -alias a1 -dname CN=a1 -validity 366");
+        kt("-genkeypair -alias a2 -dname CN=a2 -validity 366");
+
+        // a.jar includes 8 unsigned, 2 signed by a1 and a2, 2 signed by a3
+        SecurityTools.jar("cvf a.jar A1 A2");
+        js("-keystore ks -storepass changeit a.jar a1");
+        SecurityTools.jar("uvf a.jar A3 A4");
+        js("-keystore ks -storepass changeit a.jar a2");
+        SecurityTools.jar("uvf a.jar A5 A6");
+
+        // Verify OK
+        js("-verify a.jar").shouldHaveExitValue(0);
+
+        // 4(chainNotValidated)+16(hasUnsignedEntry)
+        js("-verify a.jar -strict").shouldHaveExitValue(20);
+
+        // 16(hasUnsignedEntry)
+        js("-verify a.jar -strict -keystore ks -storepass changeit")
+                .shouldHaveExitValue(16);
+
+        // 16(hasUnsignedEntry)+32(notSignedByAlias)
+        js("-verify a.jar a1 -strict -keystore ks -storepass changeit")
+                .shouldHaveExitValue(48);
+
+        // 16(hasUnsignedEntry)
+        js("-verify a.jar a1 a2 -strict -keystore ks -storepass changeit")
+                .shouldHaveExitValue(16);
+
+        // 12 entries all together
+        Asserts.assertTrue(js("-verify a.jar -verbose")
+                .asLines().stream()
+                .filter(s -> s.contains(year))
+                .count() == 12);
+
+        // 12 entries all listed
+        Asserts.assertTrue(js("-verify a.jar -verbose:grouped")
+                .asLines().stream()
+                .filter(s -> s.contains(year))
+                .count() == 12);
+
+        // 4 groups: MANIFST, unrelated, signed, unsigned
+        Asserts.assertTrue(js("-verify a.jar -verbose:summary")
+                .asLines().stream()
+                .filter(s -> s.contains(year))
+                .count() == 4);
+
+        // still 4 groups, but MANIFEST group has no other file
+        Asserts.assertTrue(js("-verify a.jar -verbose:summary")
+                .asLines().stream()
+                .filter(s -> s.contains("more)"))
+                .count() == 3);
+
+        // 5 groups: MANIFEST, unrelated, signed by a1/a2, signed by a2, unsigned
+        Asserts.assertTrue(js("-verify a.jar -verbose:summary -certs")
+                .asLines().stream()
+                .filter(s -> s.contains(year))
+                .count() == 5);
+
+        // 2 for MANIFEST, 2*2 for A1/A2, 2 for A3/A4
+        Asserts.assertTrue(js("-verify a.jar -verbose -certs")
+                .asLines().stream()
+                .filter(s -> s.contains("[certificate"))
+                .count() == 8);
+
+        // a1,a2 for MANIFEST, a1,a2 for A1/A2, a2 for A3/A4
+        Asserts.assertTrue(js("-verify a.jar -verbose:grouped -certs")
+                .asLines().stream()
+                .filter(s -> s.contains("[certificate"))
+                .count() == 5);
+
+        // a1,a2 for MANIFEST, a1,a2 for A1/A2, a2 for A3/A4
+        Asserts.assertTrue(js("-verify a.jar -verbose:summary -certs")
+                .asLines().stream()
+                .filter(s -> s.contains("[certificate"))
+                .count() == 5);
+
+        // still 5 groups, but MANIFEST group has no other file
+        Asserts.assertTrue(js("-verify a.jar -verbose:summary -certs")
+                .asLines().stream()
+                .filter(s -> s.contains("more)"))
+                .count() == 4);
+
+        // ==========================================================
+        // Second part: exit code 2, 4, 8.
+        // 16 and 32 already covered in the first part
+        // ==========================================================
+
+        kt("-genkeypair -alias ca -dname CN=ca -ext bc -validity 365");
+        kt("-genkeypair -alias expired -dname CN=expired");
+        gencert("expired", "-alias ca -startdate -10m");
+        kt("-genkeypair -alias notyetvalid -dname CN=notyetvalid");
+        gencert("notyetvalid", "-alias ca -startdate +1m");
+        kt("-genkeypair -alias badku -dname CN=badku");
+        gencert("badku", "-alias ca -ext KU=cRLSign -validity 365");
+        kt("-genkeypair -alias badeku -dname CN=badeku");
+        gencert("badeku", "-alias ca -ext EKU=sa -validity 365");
+        kt("-genkeypair -alias goodku -dname CN=goodku");
+        gencert("goodku", "-alias ca -ext KU=dig -validity 365");
+        kt("-genkeypair -alias goodeku -dname CN=goodeku");
+        gencert("goodeku", "-alias ca -ext EKU=codesign -validity 365");
+
+        js("-strict -keystore ks -storepass changeit a.jar expired")
+                .shouldHaveExitValue(4);
+
+        js("-strict -keystore ks -storepass changeit a.jar notyetvalid")
+                .shouldHaveExitValue(4);
+
+        js("-strict -keystore ks -storepass changeit a.jar badku")
+                .shouldHaveExitValue(8);
+
+        js("-strict -keystore ks -storepass changeit a.jar badeku")
+                .shouldHaveExitValue(8);
+
+        js("-strict -keystore ks -storepass changeit a.jar goodku")
+                .shouldHaveExitValue(0);
+
+        js("-strict -keystore ks -storepass changeit a.jar goodeku")
+                .shouldHaveExitValue(0);
+
+        // badchain signed by ca1, but ca1 is removed later
+        kt("-genkeypair -alias badchain -dname CN=badchain -validity 365");
+        kt("-genkeypair -alias ca1 -dname CN=ca1 -ext bc -validity 365");
+        gencert("badchain", "-alias ca1 -validity 365");
+
+        // save ca1.cert for easy replay
+        kt("-exportcert -file ca1.cert -alias ca1");
+        kt("-delete -alias ca1");
+
+        js("-strict -keystore ks -storepass changeit a.jar badchain")
+                .shouldHaveExitValue(4);
+
+        js("-verify a.jar").shouldHaveExitValue(0);
+
+        // ==========================================================
+        // Third part: -certchain test
+        // ==========================================================
+
+        // altchain signed by ca2
+        kt("-genkeypair -alias altchain -dname CN=altchain -validity 365");
+        kt("-genkeypair -alias ca2 -dname CN=ca2 -ext bc -validity 365");
+        kt("-certreq -alias altchain -file altchain.req");
+        Files.write(Path.of("certchain"), List.of(
+                kt("-gencert -alias ca2 -validity 365 -rfc -infile altchain.req")
+                        .getOutput(),
+                kt("-exportcert -alias ca2 -rfc").getOutput()));
+
+        // Self-signed cert does not work
+        js("-strict -keystore ks -storepass changeit a.jar altchain")
+                .shouldHaveExitValue(4);
+
+        // -certchain works
+        js("-strict -keystore ks -storepass changeit -certchain certchain "
+                + "a.jar altchain")
+                .shouldHaveExitValue(0);
+
+        // if ca2 is removed, -certchain still work because altchain is a
+        // self-signed entry and it is trusted by jarsigner
+        // save ca2.cert for easy replay
+        kt("-exportcert -file ca2.cert -alias ca2");
+        kt("-delete -alias ca2");
+        js("-strict -keystore ks -storepass changeit "
+                + "-certchain certchain a.jar altchain")
+                .shouldHaveExitValue(0);
+
+        // if cert is imported, -certchain won't work because this
+        // certificate entry is not trusted
+        kt("-importcert -file certchain -alias altchain -noprompt");
+        js("-strict -keystore ks -storepass changeit "
+                + "-certchain certchain a.jar altchain")
+                .shouldHaveExitValue(4);
+
+        js("-verify a.jar").shouldHaveExitValue(0);
+
+        // ==========================================================
+        // 8172529
+        // ==========================================================
+
+        kt("-genkeypair -alias ee -dname CN=ee");
+        kt("-genkeypair -alias caone -dname CN=caone");
+        kt("-genkeypair -alias catwo -dname CN=catwo");
+
+        kt("-certreq -alias ee -file ee.req");
+        kt("-certreq -alias catwo -file catwo.req");
+
+        // This certchain contains a cross-signed weak catwo.cert
+        Files.write(Path.of("ee2"), List.of(
+                kt("-gencert -alias catwo -rfc -infile ee.req").getOutput(),
+                kt("-gencert -alias caone -sigalg MD5withRSA -rfc "
+                        + "-infile catwo.req").getOutput()));
+
+        kt("-importcert -alias ee -file ee2");
+
+        SecurityTools.jar("cvf a.jar A1");
+        js("-strict -keystore ks -storepass changeit a.jar ee")
+                .shouldHaveExitValue(0);
+        js("-strict -keystore ks -storepass changeit -verify a.jar")
+                .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/Crl.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6890876 6950931
+ * @summary jarsigner can add CRL info into signed jar (updated)
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class Crl {
+    static OutputAnalyzer kt(String cmd) throws Exception {
+        return SecurityTools.keytool("-storepass changeit -keypass changeit "
+                + "-keystore ks -keyalg rsa " + cmd);
+    }
+
+    public static void main(String[] args) throws Exception {
+        kt("-alias a -dname CN=a -keyalg rsa -genkey -validity 300");
+        kt("-alias a -gencrl -id 1:1 -id 2:2 -file crl1")
+                .shouldHaveExitValue(0);
+        kt("-alias a -gencrl -id 3:3 -id 4:4 -file crl2")
+                .shouldHaveExitValue(0);
+        kt("-alias a -gencrl -id 5:1 -id 6:2 -file crl3")
+                .shouldHaveExitValue(0);
+
+        // Test keytool -printcrl
+
+        kt("-printcrl -file crl1").shouldHaveExitValue(0);
+        kt("-printcrl -file crl2").shouldHaveExitValue(0);
+        kt("-printcrl -file crl3").shouldHaveExitValue(0);
+
+        // Test keytool -ext crl
+
+        kt("-alias b -dname CN=c -keyalg rsa -genkey -validity 300 "
+                + "-ext crl=uri:http://www.example.com/crl")
+                .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/DefaultOptions.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8049834
+ * @summary Two security tools tests do not run with only JRE
+ * @library /test/lib
+ */
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.util.JarUtils;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+import java.util.jar.JarFile;
+
+public class DefaultOptions {
+
+    static OutputAnalyzer jarsigner(String cmd) throws Throwable {
+        ProcessBuilder pb = SecurityTools.getProcessBuilder(
+                "jarsigner", List.of(cmd.trim().split("\\s+")));
+        pb.environment().put("PASS", "changeit");
+        return ProcessTools.executeCommand(pb);
+    }
+
+    static OutputAnalyzer keytool(String cmd) throws Throwable {
+        cmd = "-storepass:env PASS -keypass:env PASS -keystore ks " + cmd;
+        ProcessBuilder pb = SecurityTools.getProcessBuilder(
+                "keytool", List.of(cmd.trim().split("\\s+")));
+        pb.environment().put("PASS", "changeit");
+        return ProcessTools.executeCommand(pb);
+    }
+
+    public static void main(String[] args) throws Throwable {
+        keytool("-genkeypair -dname CN=A -alias a -keyalg rsa")
+                .shouldHaveExitValue(0);
+        keytool("-genkeypair -dname CN=CA -alias ca -keyalg rsa")
+                .shouldHaveExitValue(0);
+        keytool("-alias a -certreq -file a.req");
+        keytool("-alias ca -gencert -infile a.req -outfile a.cert");
+        keytool("-alias a -import -file a.cert").shouldHaveExitValue(0);
+
+        Files.write(Path.of("js.conf"), List.of(
+                "jarsigner.all = -keystore ${user.dir}/ks -storepass:env PASS "
+                        + "-debug -strict",
+                "jarsigner.sign = -digestalg SHA1",
+                "jarsigner.verify = -verbose:summary"));
+
+        JarUtils.createJarFile(Path.of("a.jar"), Path.of("."),
+                Path.of("ks"), Path.of("js.conf"));
+
+        jarsigner("-conf js.conf a.jar a").shouldHaveExitValue(0);
+        jarsigner("-conf js.conf -verify a.jar").shouldHaveExitValue(0)
+                .shouldContain("and 1 more");
+
+        try (JarFile jf = new JarFile("a.jar")) {
+            Asserts.assertTrue(jf.getManifest().getAttributes("ks").keySet()
+                    .stream()
+                    .anyMatch(s -> s.toString().contains("SHA1-Digest")));
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/DiffEnd.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6948909
+ * @summary Jarsigner removes MANIFEST.MF info for badly packages jar's
+ * @library /test/lib
+ */
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import java.io.FileOutputStream;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class DiffEnd {
+
+    static void check() throws Exception {
+        SecurityTools.jarsigner("-keystore "
+                + Path.of(System.getProperty("test.src"), "JarSigning.keystore")
+                .toString()
+                + " -storepass bbbbbb -digestalg SHA1"
+                + " -signedjar diffend.new.jar diffend.jar c");
+
+        try (JarFile jf = new JarFile("diffend.new.jar")) {
+            Asserts.assertTrue(jf.getManifest().getMainAttributes()
+                    .containsKey(new Attributes.Name("Today")));
+        }
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        // A MANIFEST.MF using \n as newlines and no double newlines at the end
+        byte[] manifest =
+                ("Manifest-Version: 1.0\n"
+                        + "Created-By: 1.7.0-internal (Sun Microsystems Inc.)\n"
+                        + "Today: Monday\n").getBytes(StandardCharsets.UTF_8);
+
+        // With the fake .RSA file, to trigger the if (wasSigned) block
+        try (FileOutputStream fos = new FileOutputStream("diffend.jar");
+             ZipOutputStream zos = new ZipOutputStream(fos)) {
+            zos.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF"));
+            zos.write(manifest);
+            zos.putNextEntry(new ZipEntry("META-INF/x.RSA"));
+            zos.putNextEntry(new ZipEntry("1"));
+            zos.write(new byte[10]);
+        }
+
+        check();
+
+        // Without the fake .RSA file, to trigger the else block
+        try (FileOutputStream fos = new FileOutputStream("diffend.jar");
+             ZipOutputStream zos = new ZipOutputStream(fos)) {
+            zos.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF"));
+            zos.write(manifest);
+            zos.putNextEntry(new ZipEntry("1"));
+            zos.write(new byte[10]);
+        }
+
+        check();
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/EC.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6870812
+ * @summary enhance security tools to use ECC algorithm
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.util.JarUtils;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class EC {
+    static OutputAnalyzer kt(String cmd) throws Exception {
+        return SecurityTools.keytool("-storepass changeit "
+                + "-keypass changeit -keystore ks " + cmd);
+    }
+
+    static void gencert(String owner, String cmd) throws Exception {
+        kt("-certreq -alias " + owner + " -file tmp.req")
+                .shouldHaveExitValue(0);
+        kt("-gencert -infile tmp.req -outfile tmp.cert " + cmd)
+                .shouldHaveExitValue(0);
+        kt("-import -alias " + owner + " -file tmp.cert")
+                .shouldHaveExitValue(0);
+    }
+
+    static OutputAnalyzer js(String cmd) throws Exception {
+        return SecurityTools.jarsigner("-keystore ks -storepass changeit " + cmd);
+    }
+
+    public static void main(String[] args) throws Exception {
+        Files.write(Path.of("A"), List.of("A"));
+        JarUtils.createJarFile(Path.of("a.jar"), Path.of("."), Path.of("A"));
+
+        kt("-alias ca -dname CN=ca -keyalg ec -genkey -validity 300")
+                .shouldHaveExitValue(0);
+        kt("-alias a -dname CN=a -keyalg ec -genkey")
+                .shouldHaveExitValue(0);
+        gencert("a", "-alias ca -validity 300");
+
+        kt("-alias b -dname CN=b -keyalg ec -genkey")
+                .shouldHaveExitValue(0);
+        gencert("b", "-alias ca -validity 300");
+
+        // Ensure key length sufficient for intended hash (SHA512withECDSA)
+        kt("-alias c -dname CN=c -keyalg ec -genkey -keysize 521")
+                .shouldHaveExitValue(0);
+        gencert("c", "-alias ca -validity 300");
+
+        kt("-alias x -dname CN=x -keyalg ec -genkey -validity 300")
+                .shouldHaveExitValue(0);
+        gencert("x", "-alias ca -validity 300");
+
+        js("a.jar a -debug -strict").shouldHaveExitValue(0);
+        js("a.jar b -debug -strict -sigalg SHA1withECDSA").shouldHaveExitValue(0);
+        js("a.jar c -debug -strict -sigalg SHA512withECDSA").shouldHaveExitValue(0);
+
+        js("-verify a.jar a -debug -strict").shouldHaveExitValue(0);
+        js("-verify a.jar b -debug -strict").shouldHaveExitValue(0);
+        js("-verify a.jar c -debug -strict").shouldHaveExitValue(0);
+
+        // Not signed by x, should exit with non-zero
+        js("-verify a.jar x -debug -strict").shouldNotHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/EmptyManifest.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6712755
+ * @summary jarsigner fails to sign itextasian.jar since 1.5.0_b14,
+ *          it works with 1.5.0_13
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+
+import java.io.FileOutputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+public class EmptyManifest {
+
+    public static void main(String[] args) throws Exception {
+
+        try (FileOutputStream fos = new FileOutputStream("em.jar");
+             ZipOutputStream zos = new ZipOutputStream(fos)) {
+            zos.putNextEntry(new ZipEntry("META-INF/MANIFEST.MF"));
+            zos.write(new byte[]{'\r', '\n'});
+            zos.putNextEntry(new ZipEntry("A"));
+            zos.write(new byte[10]);
+            zos.putNextEntry(new ZipEntry("B"));
+            zos.write(new byte[0]);
+        }
+
+        SecurityTools.keytool("-keystore ks -storepass changeit "
+                + "-keypass changeit -alias a -dname CN=a -keyalg rsa "
+                + "-genkey -validity 300");
+
+        SecurityTools.jarsigner("-keystore ks -storepass changeit em.jar a")
+                .shouldHaveExitValue(0);
+        SecurityTools.jarsigner("-keystore ks -storepass changeit -verify "
+                + "-debug -strict em.jar")
+                .shouldHaveExitValue(0);
+    }
+}
--- a/test/jdk/sun/security/tools/jarsigner/EntriesOrder.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/jdk/sun/security/tools/jarsigner/EntriesOrder.java	Sat Apr 13 07:52:21 2019 -0400
@@ -64,9 +64,9 @@
         // directory ignored), we can get 2 signed ones (inf, a).
 
         // Prepares raw files
-        Files.write(Paths.get("a"), "a".getBytes());
+        Files.write(Paths.get("a"), List.of("a"));
         Files.createDirectory(Paths.get("META-INF/"));
-        Files.write(Paths.get("META-INF/inf"), "inf".getBytes());
+        Files.write(Paths.get("META-INF/inf"), List.of("inf"));
 
         // Pack, sign, and extract to get all files
         sun.tools.jar.Main m =
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/JvIndex.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8022761
+ * @summary regression: SecurityException is NOT thrown while trying
+ *          to pack a wrongly signed Indexed Jar file
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.util.JarUtils;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class JvIndex {
+    public static void main(String[] args) throws Exception {
+
+        Files.write(Path.of("abcde"), List.of("12345"));
+        JarUtils.createJarFile(Path.of("jvindex.jar"), Path.of("."),
+                Path.of("abcde"));
+        SecurityTools.keytool("-storepass changeit -keypass changeit "
+                + "-keystore ks -keyalg rsa -alias a -dname CN=a "
+                + "-genkey -validity 300")
+                .shouldHaveExitValue(0);
+        SecurityTools.jarsigner("-keystore ks -storepass changeit jvindex.jar a")
+                .shouldHaveExitValue(0);
+
+        SecurityTools.jar("i jvindex.jar");
+
+        // Make sure the $F line has "sm" (signed and in manifest)
+        SecurityTools.jarsigner("-keystore ks -storepass changeit -verify "
+                + "-verbose jvindex.jar")
+                .shouldHaveExitValue(0)
+                .shouldMatch("sm.*abcde");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/NameClash.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6876328
+ * @summary different names for the same digest algorithms breaks jarsigner
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.util.JarUtils;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class NameClash {
+    public static void main(String[] args) throws Exception {
+        String common = "-storepass changeit -keypass changeit -keystore ks ";
+
+        SecurityTools.keytool(common + "-alias a -dname CN=a -keyalg rsa "
+                + "-genkey -validity 300");
+        SecurityTools.keytool(common + "-alias b -dname CN=b -keyalg rsa "
+                + "-genkey -validity 300");
+
+        Files.write(Path.of("A"), List.of("A"));
+        JarUtils.createJarFile(Path.of("a.jar"), Path.of("."), Path.of("A"));
+
+        SecurityTools.jarsigner(common + "a.jar a -digestalg SHA1")
+                .shouldHaveExitValue(0);
+        SecurityTools.jarsigner(common + "a.jar b -digestalg SHA-1")
+                .shouldHaveExitValue(0);
+
+        SecurityTools.jarsigner(common + "-verify -debug -strict a.jar")
+                .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/NewSize7.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6561126
+ * @summary keytool should use larger default keysize for keypairs
+ * @library /test/lib
+ */
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.util.JarUtils;
+
+import java.io.InputStream;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+public class NewSize7 {
+    public static void main(String[] args) throws Exception {
+        String common = "-storepass changeit -keypass changeit -keystore ks ";
+        SecurityTools.keytool(common
+                + "-keyalg rsa -genkeypair -alias me -dname CN=Me");
+        Files.write(Path.of("ns7.txt"), new byte[0]);
+        JarUtils.createJarFile(Path.of("ns7.jar"), Path.of("."),
+                Path.of("ns7.txt"));
+        SecurityTools.jarsigner(common + "ns7.jar me");
+
+        try (JarFile jf = new JarFile("ns7.jar")) {
+            try (InputStream is = jf.getInputStream(
+                    jf.getEntry("META-INF/MANIFEST.MF"))) {
+                Asserts.assertTrue(new Manifest(is).getAttributes("ns7.txt")
+                        .keySet().stream()
+                        .anyMatch(s -> s.toString().contains("SHA-256")));
+            }
+            try (InputStream is = jf.getInputStream(
+                    jf.getEntry("META-INF/ME.SF"))) {
+                Asserts.assertTrue(new Manifest(is).getAttributes("ns7.txt")
+                        .keySet().stream()
+                        .anyMatch(s -> s.toString().contains("SHA-256")));
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/OldSig.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6543940 6868865
+ * @summary Exception thrown when signing a jarfile in java 1.5
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.util.JarUtils;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class OldSig {
+    public static void main(String[] args) throws Exception {
+        Path src = Path.of(System.getProperty("test.src"));
+        // copy jar file into writeable location
+        Files.copy(src.resolve("oldsig/A.jar"), Path.of("B.jar"));
+        Files.copy(src.resolve("oldsig/A.class"), Path.of("B.class"));
+
+        JarUtils.updateJarFile(Path.of("B.jar"), Path.of("."),
+                Path.of("B.class"));
+
+        SecurityTools.jarsigner("-keystore " + src.resolve("JarSigning.keystore")
+                + " -storepass bbbbbb -digestalg SHA1 B.jar c");
+        SecurityTools.jarsigner("-verify B.jar");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/OnlyManifest.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 7004035
+ * @summary signed jar with only META-INF/* inside is not verifiable
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class OnlyManifest {
+    static OutputAnalyzer kt(String cmd) throws Exception {
+        return SecurityTools.keytool("-storepass changeit -keypass changeit "
+                + "-keystore ks -keyalg rsa " + cmd);
+    }
+
+    static void gencert(String owner, String cmd) throws Exception {
+        kt("-certreq -alias " + owner + " -file tmp.req");
+        kt("-gencert -infile tmp.req -outfile tmp.cert " + cmd);
+        kt("-import -alias " + owner + " -file tmp.cert");
+    }
+
+    public static void main(String[] args) throws Exception {
+        // Create an empty jar file with only MANIFEST.MF
+        Files.write(Path.of("manifest"), List.of("Key: Value"));
+        SecurityTools.jar("cvfm a.jar manifest");
+
+        kt("-alias ca -dname CN=ca -genkey -validity 300")
+                .shouldHaveExitValue(0);
+        kt("-alias a -dname CN=a -genkey -validity 300")
+                .shouldHaveExitValue(0);
+        gencert("a", "-alias ca -validity 300");
+
+        SecurityTools.jarsigner("-keystore ks -storepass changeit"
+                + " a.jar a -debug -strict")
+                .shouldHaveExitValue(0);
+        SecurityTools.jarsigner("-keystore ks -storepass changeit"
+                + " -verify a.jar a -debug -strict")
+                .shouldHaveExitValue(0)
+                .shouldNotContain("unsigned");
+    }
+}
--- a/test/jdk/sun/security/tools/jarsigner/Options.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/jdk/sun/security/tools/jarsigner/Options.java	Sat Apr 13 07:52:21 2019 -0400
@@ -58,7 +58,7 @@
     public static void main(String[] args) throws Exception {
 
         // Prepares raw file
-        Files.write(Paths.get("a"), "a".getBytes());
+        Files.write(Paths.get("a"), List.of("a"));
 
         // Pack
         JarUtils.createJar("a.jar", "a");
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/PassType.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6868579
+ * @summary RFE: jarsigner to support reading password from environment variable
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.util.JarUtils;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class PassType {
+
+    static OutputAnalyzer jarsignerWithEnv(String cmd) throws Throwable {
+        ProcessBuilder pb = SecurityTools.getProcessBuilder(
+                "jarsigner", List.of(cmd.trim().split("\\s+")));
+        pb.environment().put("PASSENV", "test12");
+        return ProcessTools.executeCommand(pb);
+    }
+
+    static OutputAnalyzer keytoolWithEnv(String cmd) throws Throwable {
+        ProcessBuilder pb = SecurityTools.getProcessBuilder(
+                "keytool", List.of(cmd.trim().split("\\s+")));
+        pb.environment().put("PASSENV", "test12");
+        return ProcessTools.executeCommand(pb);
+    }
+
+    public static void main(String[] args) throws Throwable {
+
+        SecurityTools.keytool("-keystore ks -validity 300 -keyalg rsa "
+                + "-alias a -dname CN=a -keyalg rsa -genkey "
+                + "-storepass test12 -keypass test12")
+                .shouldHaveExitValue(0);
+        keytoolWithEnv("-keystore ks -validity 300 -keyalg rsa "
+                + "-alias b -dname CN=b -keyalg rsa -genkey "
+                + "-storepass:env PASSENV -keypass:env PASSENV")
+                .shouldHaveExitValue(0);
+        Files.write(Path.of("passfile"), List.of("test12"));
+        SecurityTools.keytool("-keystore ks -validity 300 -keyalg rsa "
+                + "-alias c -dname CN=c -keyalg rsa -genkey "
+                + "-storepass:file passfile -keypass:file passfile")
+                .shouldHaveExitValue(0);
+
+        Files.write(Path.of("A"), List.of("A"));
+        JarUtils.createJarFile(Path.of("a.jar"), Path.of("."), Path.of("A"));
+
+        // Sign
+        SecurityTools.jarsigner("-keystore ks -storepass test12 a.jar a")
+                .shouldHaveExitValue(0);
+        jarsignerWithEnv("-keystore ks -storepass:env PASSENV a.jar b")
+                .shouldHaveExitValue(0);
+        SecurityTools.jarsigner("-keystore ks -storepass:file passfile a.jar c")
+                .shouldHaveExitValue(0);
+
+        // Verify
+        SecurityTools.jarsigner("-keystore ks -storepass test12 "
+                + "-verify -debug -strict a.jar")
+                .shouldHaveExitValue(0);
+        jarsignerWithEnv("-keystore ks -storepass:env PASSENV "
+                + "-verify -debug -strict a.jar")
+                .shouldHaveExitValue(0);
+        SecurityTools.jarsigner("-keystore ks -storepass:file passfile "
+                + "-verify -debug -strict a.jar")
+                .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/PercentSign.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2007, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6522933
+ * @summary jarsigner fails in a directory with a path containing a % sign
+ * @author Wang Weijun
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+
+public class PercentSign {
+    public static void main(String[] args) throws Exception {
+
+        //  copy jar file into writeable location
+        Files.copy(Path.of(System.getProperty("test.src"), "AlgOptions.jar"),
+                Path.of("AlgOptionsTmp.jar"));
+
+        SecurityTools.jarsigner("-keystore "
+                + Path.of(System.getProperty("test.src"), "a%b", "percent.keystore")
+                + " -storepass changeit AlgOptionsTmp.jar ok")
+                .shouldHaveExitValue(0);
+    }
+}
--- a/test/jdk/sun/security/tools/jarsigner/PercentSign.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-#
-# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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 6522933
-# @summary jarsigner fails in a directory with a path contianing a % sign
-# @author Wang Weijun
-#
-# @run shell PercentSign.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 )
-    NULL=/dev/null
-    PS=":"
-    FS="/"
-    CP="${FS}bin${FS}cp -f"
-    ;;
-  CYGWIN* )
-    NULL=/dev/null
-    PS=";"
-    FS="/"
-    CP="cp -f"
-    ;;
-  Windows_* )
-    NULL=NUL
-    PS=";"
-    FS="\\"
-    CP="cp -f"
-    ;;
-  * )
-    echo "Unrecognized operating system!"
-    exit 1;
-    ;;
-esac
-
-# copy jar file into writeable location
-${CP} ${TESTSRC}${FS}AlgOptions.jar ${TESTCLASSES}${FS}AlgOptionsTmp.jar
-
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}a%b${FS}percent.keystore \
-    -storepass changeit \
-    ${TESTCLASSES}${FS}AlgOptionsTmp.jar ok
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/SameName.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6866479
+ * @summary libzip.so caused JVM to crash when running jarsigner
+ * @library /test/lib
+ */
+
+import jdk.test.lib.Platform;
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.util.JarUtils;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class SameName {
+    public static void main(String[] args) throws Exception {
+
+        String signedJar = Platform.isWindows() ? "EM.jar" : "em.jar";
+
+        Files.write(Path.of("A"), List.of("A"));
+        JarUtils.createJarFile(Path.of("em.jar"), Path.of("."), Path.of("A"));
+
+        SecurityTools.keytool("-storepass changeit -keypass changeit "
+                + "-keystore ks -keyalg rsa  -alias a -dname CN=a "
+                + "-keyalg rsa -genkey -validity 300")
+                .shouldHaveExitValue(0);
+
+        SecurityTools.jarsigner("-keystore ks -storepass changeit "
+                + "-signedjar " + signedJar + " em.jar a")
+                .shouldHaveExitValue(0);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/jarsigner/WeakSize.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,69 @@
+/*
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8044755
+ * @summary Add a test for algorithm constraints check in jarsigner
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.util.JarUtils;
+
+import java.nio.file.Path;
+
+public class WeakSize {
+
+    static OutputAnalyzer kt(String cmd) throws Exception {
+        // The sigalg used is MD2withRSA, which is obsolete.
+        return SecurityTools.keytool("-storepass changeit -keypass changeit "
+                + "-keystore ks -keyalg rsa -sigalg MD2withRSA " + cmd);
+    }
+
+    static void gencert(String owner, String cmd) throws Exception {
+        kt("-certreq -alias " + owner + " -file tmp.req");
+        kt("-gencert -infile tmp.req -outfile tmp.cert " + cmd);
+        kt("-import -alias " + owner + " -file tmp.cert");
+    }
+
+    public static void main(String[] args) throws Exception {
+
+        kt("-genkeypair -alias ca -dname CN=CA -ext bc");
+        kt("-genkeypair -alias signer -dname CN=Signer");
+        gencert("signer", "-alias ca -ext ku=dS -rfc");
+
+        JarUtils.createJarFile(Path.of("a.jar"), Path.of("."), Path.of("ks"));
+
+        // We always trust a TrustedCertificateEntry
+        SecurityTools.jarsigner("-keystore ks -storepass changeit "
+                + "-strict -debug a.jar ca")
+                .shouldNotContain("chain is invalid");
+
+        // An end-entity cert must follow algorithm constraints
+        SecurityTools.jarsigner("-keystore ks -storepass changeit "
+                + "-strict -debug a.jar signer")
+                .shouldContain("chain is invalid");
+    }
+}
--- a/test/jdk/sun/security/tools/jarsigner/certpolicy.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +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.
-#
-# 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 8036709
-# @summary Java 7 jarsigner displays warning about cert policy tree
-#
-# @run shell certpolicy.sh
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-KT="$TESTJAVA/bin/keytool $TESTTOOLVMOPTS \
-        -keypass changeit -storepass changeit -keystore ks -keyalg rsa"
-JS="$TESTJAVA/bin/jarsigner $TESTTOOLVMOPTS -storepass changeit -keystore ks"
-JAR="$TESTJAVA/bin/jar $TESTTOOLVMOPTS"
-
-rm ks 2> /dev/null
-$KT -genkeypair -alias ca -dname CN=CA -ext bc
-$KT -genkeypair -alias int -dname CN=Int
-$KT -genkeypair -alias ee -dname CN=EE
-
-# CertificatePolicies [[PolicyId: [1.2.3]], [PolicyId: [1.2.4]]]
-# PolicyConstraints: [Require: 0; Inhibit: unspecified]
-$KT -certreq -alias int | \
-        $KT -gencert -rfc -alias ca \
-                -ext 2.5.29.32="30 0C 30 04 06 02 2A 03 30 04 06 02 2A 04" \
-                -ext "2.5.29.36=30 03 80 01 00" -ext bc | \
-        $KT -import -alias int
-
-# CertificatePolicies [[PolicyId: [1.2.3]]]
-$KT -certreq -alias ee | \
-        $KT -gencert -rfc -alias int \
-                -ext 2.5.29.32="30 06 30 04 06 02 2A 03" | \
-        $KT -import -alias ee
-
-$KT -export -alias ee -rfc > cc
-$KT -export -alias int -rfc >> cc
-$KT -export -alias ca -rfc >> cc
-
-$KT -delete -alias int
-
-ERR=''
-$JAR cvf a.jar cc
-
-# Make sure the certchain in the signed jar contains all 3 certs
-$JS -strict -certchain cc a.jar ee -debug || ERR="sign"
-$JS -strict -verify a.jar -debug || ERR="$ERR verify"
-
-if [ "$ERR" = "" ]; then
-    echo "Success"
-    exit 0
-else
-    echo "Failed: $ERR"
-    exit 1
-fi
-
--- a/test/jdk/sun/security/tools/jarsigner/checkusage.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-#
-# Copyright (c) 2010, 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 7004168
-# @summary jarsigner -verify checks for KeyUsage codesigning ext on all certs
-#  instead of just signing cert
-#
-# @run shell checkusage.sh
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keyalg rsa"
-JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
-
-rm js.jks trust.jks unrelated.jks 2> /dev/null
-
-echo x > x
-$JAR cvf a.jar x
-
-################### 3 Keystores #######################
-
-# Keystore js.jks: including CA and Publisher
-# CA contains a non-empty KeyUsage
-$KT -keystore js.jks -genkeypair -alias ca -dname CN=CA -ext KU=kCS -ext bc -validity 365
-$KT -keystore js.jks -genkeypair -alias pub -dname CN=Publisher
-
-# Publisher contains the correct KeyUsage
-$KT -keystore js.jks -certreq -alias pub | \
-        $KT -keystore js.jks -gencert -alias ca -ext KU=dig -validity 365 | \
-        $KT -keystore js.jks -importcert -alias pub
-
-# Keystore trust.jks: including CA only
-$KT -keystore js.jks -exportcert -alias ca | \
-        $KT -keystore trust.jks -importcert -alias ca -noprompt
-
-# Keystore unrelated.jks: unrelated
-$KT -keystore unrelated.jks -genkeypair -alias nothing -dname CN=Nothing -validity 365
-
-
-################### 4 Tests #######################
-
-# Test 1: Sign should be OK
-
-$JARSIGNER -keystore js.jks -storepass changeit a.jar pub
-RESULT=$?
-echo $RESULT
-#[ $RESULT = 0 ] || exit 1
-
-# Test 2: Verify should be OK
-
-$JARSIGNER -keystore trust.jks -strict -verify a.jar
-RESULT=$?
-echo $RESULT
-#[ $RESULT = 0 ] || exit 2
-
-# Test 3: When no keystore is specified, the error is only
-# "chain invalid"
-
-$JARSIGNER -strict -verify a.jar
-RESULT=$?
-echo $RESULT
-#[ $RESULT = 4 ] || exit 3
-
-# Test 4: When unrelated keystore is specified, the error is
-# "chain invalid" and "not alias in keystore"
-
-$JARSIGNER -keystore unrelated.jks -strict -verify a.jar
-RESULT=$?
-echo $RESULT
-#[ $RESULT = 36 ] || exit 4
-
-exit 0
--- a/test/jdk/sun/security/tools/jarsigner/collator.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-#
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 8021789
-# @summary jarsigner parses alias as command line option (depending on locale)
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-F=collator
-KS=collator.jks
-JFILE=collator.jar
-
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit \
-        -keyalg rsa -keystore $KS"
-JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore $KS -storepass changeit"
-
-rm $F $KS $JFILE 2> /dev/null
-
-echo 12345 > $F
-$JAR cvf $JFILE $F
-
-ERR=""
-
-$KT -alias debug -dname CN=debug -genkey -validity 300 || ERR="$ERR 1"
-
-# use "debug" as alias name
-$JARSIGNER $JFILE debug || ERR="$ERR 2"
-
-# use "" as alias name (although there will be a warning)
-$JARSIGNER -verify $JFILE "" || ERR="$ERR 3"
-
-if [ "$ERR" = "" ]; then
-    exit 0
-else
-    echo "ERR is $ERR"
-    exit 1
-fi
--- a/test/jdk/sun/security/tools/jarsigner/concise_jarsigner.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,247 +0,0 @@
-#
-# Copyright (c) 2009, 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.
-#
-# 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 6802846 8172529
-# @summary jarsigner needs enhanced cert validation(options)
-#
-# @run shell/timeout=240 concise_jarsigner.sh
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-# Choose 1024-bit RSA to make sure it runs fine and fast on all platforms. In
-# fact, every keyalg/keysize combination is OK for this test.
-
-TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US"
-
-KS=js.ks
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa -keysize 1024"
-JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -debug"
-JAVAC="$TESTJAVA${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS}"
-
-rm $KS
-
-echo class A1 {} > A1.java
-echo class A2 {} > A2.java
-echo class A3 {} > A3.java
-echo class A4 {} > A4.java
-echo class A5 {} > A5.java
-echo class A6 {} > A6.java
-
-$JAVAC A1.java A2.java A3.java A4.java A5.java A6.java
-YEAR=`date +%Y`
-
-# ==========================================================
-# First part: output format
-# ==========================================================
-
-$KT -genkeypair -alias a1 -dname CN=a1 -validity 366
-$KT -genkeypair -alias a2 -dname CN=a2 -validity 366
-
-# a.jar includes 8 unsigned, 2 signed by a1 and a2, 2 signed by a3
-$JAR cvf a.jar A1.class A2.class
-$JARSIGNER -keystore $KS -storepass changeit a.jar a1
-$JAR uvf a.jar A3.class A4.class
-$JARSIGNER -keystore $KS -storepass changeit a.jar a2
-$JAR uvf a.jar A5.class A6.class
-
-# Verify OK
-$JARSIGNER -verify a.jar
-[ $? = 0 ] || exit $LINENO
-
-# 4(chainNotValidated)+16(hasUnsignedEntry)
-$JARSIGNER -verify a.jar -strict
-[ $? = 20 ] || exit $LINENO
-
-# 16(hasUnsignedEntry)
-$JARSIGNER -verify a.jar -strict -keystore $KS -storepass changeit
-[ $? = 16 ] || exit $LINENO
-
-# 16(hasUnsignedEntry)+32(notSignedByAlias)
-$JARSIGNER -verify a.jar a1 -strict -keystore $KS -storepass changeit
-[ $? = 48 ] || exit $LINENO
-
-# 16(hasUnsignedEntry)
-$JARSIGNER -verify a.jar a1 a2 -strict -keystore $KS -storepass changeit
-[ $? = 16 ] || exit $LINENO
-
-# 12 entries all together
-LINES=`$JARSIGNER -verify a.jar -verbose | grep $YEAR | wc -l`
-[ $LINES = 12 ] || exit $LINENO
-
-# 12 entries all listed
-LINES=`$JARSIGNER -verify a.jar -verbose:grouped | grep $YEAR | wc -l`
-[ $LINES = 12 ] || exit $LINENO
-
-# 4 groups: MANIFST, unrelated, signed, unsigned
-LINES=`$JARSIGNER -verify a.jar -verbose:summary | grep $YEAR | wc -l`
-[ $LINES = 4 ] || exit $LINENO
-
-# still 4 groups, but MANIFEST group has no other file
-LINES=`$JARSIGNER -verify a.jar -verbose:summary | grep "more)" | wc -l`
-[ $LINES = 3 ] || exit $LINENO
-
-# 5 groups: MANIFEST, unrelated, signed by a1/a2, signed by a2, unsigned
-LINES=`$JARSIGNER -verify a.jar -verbose:summary -certs | grep $YEAR | wc -l`
-[ $LINES = 5 ] || exit $LINENO
-
-# 2 for MANIFEST, 2*2 for A1/A2, 2 for A3/A4
-LINES=`$JARSIGNER -verify a.jar -verbose -certs | grep "\[certificate" | wc -l`
-[ $LINES = 8 ] || exit $LINENO
-
-# a1,a2 for MANIFEST, a1,a2 for A1/A2, a2 for A3/A4
-LINES=`$JARSIGNER -verify a.jar -verbose:grouped -certs | grep "\[certificate" | wc -l`
-[ $LINES = 5 ] || exit $LINENO
-
-# a1,a2 for MANIFEST, a1,a2 for A1/A2, a2 for A3/A4
-LINES=`$JARSIGNER -verify a.jar -verbose:summary -certs | grep "\[certificate" | wc -l`
-[ $LINES = 5 ] || exit $LINENO
-
-# still 5 groups, but MANIFEST group has no other file
-LINES=`$JARSIGNER -verify a.jar -verbose:summary -certs | grep "more)" | wc -l`
-[ $LINES = 4 ] || exit $LINENO
-
-# ==========================================================
-# Second part: exit code 2, 4, 8.
-# 16 and 32 already covered in the first part
-# ==========================================================
-
-$KT -genkeypair -alias ca -dname CN=ca -ext bc -validity 365
-$KT -genkeypair -alias expired -dname CN=expired
-$KT -certreq -alias expired | $KT -gencert -alias ca -startdate -10m | $KT -import -alias expired
-$KT -genkeypair -alias notyetvalid -dname CN=notyetvalid
-$KT -certreq -alias notyetvalid | $KT -gencert -alias ca -startdate +1m | $KT -import -alias notyetvalid
-$KT -genkeypair -alias badku -dname CN=badku
-$KT -certreq -alias badku | $KT -gencert -alias ca -ext KU=cRLSign -validity 365 | $KT -import -alias badku
-$KT -genkeypair -alias badeku -dname CN=badeku
-$KT -certreq -alias badeku | $KT -gencert -alias ca -ext EKU=sa -validity 365 | $KT -import -alias badeku
-$KT -genkeypair -alias goodku -dname CN=goodku
-$KT -certreq -alias goodku | $KT -gencert -alias ca -ext KU=dig -validity 365 | $KT -import -alias goodku
-$KT -genkeypair -alias goodeku -dname CN=goodeku
-$KT -certreq -alias goodeku | $KT -gencert -alias ca -ext EKU=codesign -validity 365 | $KT -import -alias goodeku
-
-$JARSIGNER -strict -keystore $KS -storepass changeit a.jar expired
-[ $? = 4 ] || exit $LINENO
-
-$JARSIGNER -strict -keystore $KS -storepass changeit a.jar notyetvalid
-[ $? = 4 ] || exit $LINENO
-
-$JARSIGNER -strict -keystore $KS -storepass changeit a.jar badku
-[ $? = 8 ] || exit $LINENO
-
-$JARSIGNER -strict -keystore $KS -storepass changeit a.jar badeku
-[ $? = 8 ] || exit $LINENO
-
-$JARSIGNER -strict -keystore $KS -storepass changeit a.jar goodku
-[ $? = 0 ] || exit $LINENO
-
-$JARSIGNER -strict -keystore $KS -storepass changeit a.jar goodeku
-[ $? = 0 ] || exit $LINENO
-
-# badchain signed by ca1, but ca1 is removed later
-$KT -genkeypair -alias badchain -dname CN=badchain -validity 365
-$KT -genkeypair -alias ca1 -dname CN=ca1 -ext bc -validity 365
-$KT -certreq -alias badchain | $KT -gencert -alias ca1 -validity 365 | \
-        $KT -importcert -alias badchain
-# save ca1.cert for easy replay
-$KT -exportcert -file ca1.cert -alias ca1
-$KT -delete -alias ca1
-
-$JARSIGNER -strict -keystore $KS -storepass changeit a.jar badchain
-[ $? = 4 ] || exit $LINENO
-
-$JARSIGNER -verify a.jar
-[ $? = 0 ] || exit $LINENO
-
-# ==========================================================
-# Third part: -certchain test
-# ==========================================================
-
-# altchain signed by ca2
-$KT -genkeypair -alias altchain -dname CN=altchain -validity 365
-$KT -genkeypair -alias ca2 -dname CN=ca2 -ext bc -validity 365
-$KT -certreq -alias altchain | $KT -gencert -alias ca2 -validity 365 -rfc > certchain
-$KT -exportcert -alias ca2 -rfc >> certchain
-
-# Self-signed cert does not work
-$JARSIGNER -strict -keystore $KS -storepass changeit a.jar altchain
-[ $? = 4 ] || exit $LINENO
-
-# -certchain works
-$JARSIGNER -strict -keystore $KS -storepass changeit -certchain certchain a.jar altchain
-[ $? = 0 ] || exit $LINENO
-
-# if ca2 is removed, -certchain still work because altchain is a self-signed entry and
-# it is trusted by jarsigner
-# save ca2.cert for easy replay
-$KT -exportcert -file ca2.cert -alias ca2
-$KT -delete -alias ca2
-$JARSIGNER -strict -keystore $KS -storepass changeit -certchain certchain a.jar altchain
-[ $? = 0 ] || exit $LINENO
-
-# if cert is imported, -certchain won't work because this certificate entry is not trusted
-$KT -importcert -file certchain -alias altchain -noprompt
-$JARSIGNER -strict -keystore $KS -storepass changeit -certchain certchain a.jar altchain
-[ $? = 4 ] || exit $LINENO
-
-$JARSIGNER -verify a.jar
-[ $? = 0 ] || exit $LINENO
-
-# ==========================================================
-# 8172529
-# ==========================================================
-
-$KT -genkeypair -alias ee -dname CN=ee
-$KT -genkeypair -alias caone -dname CN=caone
-$KT -genkeypair -alias catwo -dname CN=catwo
-
-$KT -certreq -alias ee | $KT -gencert -alias catwo -rfc > ee.cert
-$KT -certreq -alias catwo | $KT -gencert -alias caone -sigalg MD5withRSA -rfc > catwo.cert
-
-# This certchain contains a cross-signed weak catwo.cert
-cat ee.cert catwo.cert | $KT -importcert -alias ee
-
-$JAR cvf a.jar A1.class
-$JARSIGNER -strict -keystore $KS -storepass changeit a.jar ee
-[ $? = 0 ] || exit $LINENO
-$JARSIGNER -strict -keystore $KS -storepass changeit -verify a.jar
-[ $? = 0 ] || exit $LINENO
-
-echo OK
-exit 0
--- a/test/jdk/sun/security/tools/jarsigner/crl.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#
-# Copyright (c) 2010, 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 6890876 6950931
-# @summary jarsigner can add CRL info into signed jar (updated)
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-
-OS=`uname -s`
-case "$OS" in
-  Windows* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KS=crl.jks
-
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
-
-rm $KS 2> /dev/null
-
-# Test keytool -gencrl
-
-$KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
-$KT -alias a -gencrl -id 1:1 -id 2:2 -file crl1 || exit 1
-$KT -alias a -gencrl -id 3:3 -id 4:4 -file crl2 || exit 2
-$KT -alias a -gencrl -id 5:1 -id 6:2 -file crl3 || exit 4
-
-# Test keytool -printcrl
-
-$KT -printcrl -file crl1 || exit 5
-$KT -printcrl -file crl2 || exit 6
-$KT -printcrl -file crl3 || exit 7
-
-
-# Test keytool -ext crl
-
-$KT -alias b -dname CN=c -keyalg rsa -genkey -validity 300 \
-    -ext crl=uri:http://www.example.com/crl || exit 10
-
-exit 0
--- a/test/jdk/sun/security/tools/jarsigner/default_options.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +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.
-#
-# 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 8049834
-# @summary Two security tools tests do not run with only JRE
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-PASS=changeit
-export PASS
-
-TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US"
-
-KS=ks
-KEYTOOL="$TESTJAVA/bin/keytool ${TESTTOOLVMOPTS} -storepass:env PASS -keypass:env PASS -keystore $KS"
-JAR="$TESTJAVA/bin/jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA/bin/jarsigner ${TESTTOOLVMOPTS}"
-
-rm $KS 2> /dev/null
-
-$KEYTOOL -genkeypair -dname CN=A -alias a -keyalg rsa || exit 1
-$KEYTOOL -genkeypair -dname CN=CA -alias ca -keyalg rsa || exit 2
-$KEYTOOL -alias a -certreq |
-    $KEYTOOL -alias ca -gencert |
-    $KEYTOOL -alias a -import || exit 3
-
-cat <<EOF > js.conf
-jarsigner.all = -keystore \${user.dir}/$KS -storepass:env PASS -debug -strict
-jarsigner.sign = -digestalg SHA1
-jarsigner.verify = -verbose:summary
-
-EOF
-
-$JAR cvf a.jar ks js.conf
-
-$JARSIGNER -conf js.conf a.jar a || exit 21
-$JARSIGNER -conf js.conf -verify a.jar > jarsigner.out || exit 22
-grep "and 1 more" jarsigner.out || exit 23
-$JAR xvf a.jar META-INF/MANIFEST.MF
-grep "SHA1-Digest" META-INF/MANIFEST.MF || exit 24
-
-echo Done
-exit 0
--- a/test/jdk/sun/security/tools/jarsigner/diffend.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,110 +0,0 @@
-#
-# Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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 6948909
-# @summary Jarsigner removes MANIFEST.MF info for badly packages jar's
-#
-
-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 )
-    NULL=/dev/null
-    PS=":"
-    FS="/"
-    CP="${FS}bin${FS}cp -f"
-    ;;
-  CYGWIN* )
-    NULL=/dev/null
-    PS=";"
-    FS="/"
-    CP="cp -f"
-    ;;
-  Windows_* )
-    NULL=NUL
-    PS=";"
-    FS="\\"
-    CP="cp -f"
-    ;;
-  * )
-    echo "Unrecognized operating system!"
-    exit 1;
-    ;;
-esac
-
-echo 1 > 1
-mkdir META-INF
-
-# Create a fake .RSA file so that jarsigner believes it's signed
-
-touch META-INF/x.RSA
-
-# A MANIFEST.MF using \n as newlines and no double newlines at the end
-
-cat > META-INF/MANIFEST.MF <<EOF
-Manifest-Version: 1.0
-Created-By: 1.7.0-internal (Sun Microsystems Inc.)
-Today: Monday
-EOF
-
-# With the fake .RSA file, to trigger the if (wasSigned) block
-
-rm diffend.jar
-zip diffend.jar META-INF/MANIFEST.MF META-INF/x.RSA 1
-
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -digestalg SHA1 \
-    -signedjar diffend.new.jar \
-    diffend.jar c
-
-unzip -p diffend.new.jar META-INF/MANIFEST.MF | grep Today || exit 1
-
-# Without the fake .RSA file, to trigger the else block
-
-rm diffend.jar
-zip diffend.jar META-INF/MANIFEST.MF 1
-
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -digestalg SHA1 \
-    -signedjar diffend.new.jar \
-    diffend.jar c
-
-unzip -p diffend.new.jar META-INF/MANIFEST.MF | grep Today || exit 2
-
--- a/test/jdk/sun/security/tools/jarsigner/ec.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-#
-# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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 6870812
-# @summary enhance security tools to use ECC algorithm
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KS=ec.jks
-JFILE=ec.jar
-
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS"
-JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
-
-rm $KS $JFILE
-echo A > A
-$JAR cvf $JFILE A
-
-$KT -alias ca -dname CN=ca -keyalg ec -genkey -validity 300 || exit 11
-
-$KT -alias a -dname CN=a -keyalg ec -genkey || exit 11
-$KT -alias a -certreq | $KT -gencert -alias ca -validity 300 | $KT -import -alias a || exit 111
-
-$KT -alias b -dname CN=b -keyalg ec -genkey || exit 12
-$KT -alias b -certreq | $KT -gencert -alias ca -validity 300 | $KT -import -alias b || exit 121
-
-# Ensure that key length is sufficient for the intended hash (SHA512withECDSA)
-$KT -alias c -dname CN=c -keyalg ec -genkey -keysize 521 || exit 13
-$KT -alias c -certreq | $KT -gencert -alias ca -validity 300 | $KT -import -alias c || exit 131
-
-$KT -alias x -dname CN=x -keyalg ec -genkey -validity 300 || exit 14
-$KT -alias x -certreq | $KT -gencert -alias ca -validity 300 | $KT -import -alias x || exit 141
-
-$JARSIGNER -keystore $KS -storepass changeit $JFILE a -debug -strict || exit 21
-$JARSIGNER -keystore $KS -storepass changeit $JFILE b -debug -strict -sigalg SHA1withECDSA || exit 22
-$JARSIGNER -keystore $KS -storepass changeit $JFILE c -debug -strict -sigalg SHA512withECDSA || exit 23
-
-$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE a -debug -strict || exit 31
-$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE b -debug -strict || exit 32
-$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE c -debug -strict || exit 33
-
-# Not signed by x, should exit with non-zero
-$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE x -debug -strict && exit 34
-
-exit 0
-
--- a/test/jdk/sun/security/tools/jarsigner/emptymanifest.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#
-# Copyright (c) 2009, 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.
-#
-# 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 6712755
-# @summary jarsigner fails to sign itextasian.jar since 1.5.0_b14, it works with 1.5.0_13
-#
-# @run shell emptymanifest.sh
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KS=emptymanifest.ks
-JFILE=em.jar
-
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS"
-JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JAVA="$TESTJAVA${FS}bin${FS}java ${TESTVMOPTS}"
-JAVAC="$TESTJAVA${FS}bin${FS}javac ${TESTTOOLVMOPTS} ${TESTJAVACOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore $KS -storepass changeit"
-
-rm $KS $JFILE
-echo A > A
-echo B > B
-mkdir META-INF
-cat <<EOF > CrLf.java
-class CrLf {
-  public static void main(String[] args) throws Exception {
-    System.out.write(new byte[] {'\r', '\n'});
-  }
-}
-EOF
-$JAVAC CrLf.java
-$JAVA CrLf > META-INF${FS}MANIFEST.MF
-zip $JFILE META-INF${FS}MANIFEST.MF A B
-
-$KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
-
-$JARSIGNER $JFILE a || exit 1
-$JARSIGNER -verify -debug -strict $JFILE || exit 2
-
-exit 0
--- a/test/jdk/sun/security/tools/jarsigner/jvindex.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-#
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 8022761
-# @summary regression: SecurityException is NOT thrown while trying to pack a wrongly signed Indexed Jar file
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-F=abcde
-KS=jvindex.jks
-JFILE=jvindex.jar
-
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit \
-        -keystore $KS -keyalg rsa"
-JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore $KS -storepass changeit"
-
-rm $F $KS $JFILE 2> /dev/null
-
-echo 12345 > $F
-$JAR cvf $JFILE $F
-
-ERR=""
-
-$KT -alias a -dname CN=a -genkey -validity 300 || ERR="$ERR 1"
-
-$JARSIGNER $JFILE a || ERR="$ERR 2"
-$JAR i $JFILE
-
-# Make sure the $F line has "sm" (signed and in manifest)
-$JARSIGNER -verify -verbose $JFILE | grep $F | grep sm || ERR="$ERR 3"
-
-if [ "$ERR" = "" ]; then
-    exit 0
-else
-    echo "ERR is $ERR"
-    exit 1
-fi
--- a/test/jdk/sun/security/tools/jarsigner/nameclash.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#
-# Copyright (c) 2009, 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.
-#
-# 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 6876328
-# @summary different names for the same digest algorithms breaks jarsigner
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KS=nc.ks
-JFILE=nc.jar
-
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS"
-JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore $KS -storepass changeit"
-
-rm $KS $JFILE
-
-$KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
-$KT -alias b -dname CN=b -keyalg rsa -genkey -validity 300
-
-echo A > A
-$JAR cvf $JFILE A
-
-$JARSIGNER $JFILE a -digestalg SHA1 || exit 1
-$JARSIGNER $JFILE b -digestalg SHA-1 || exit 2
-
-$JARSIGNER -verify -debug -strict $JFILE || exit 3
-
-exit 0
--- a/test/jdk/sun/security/tools/jarsigner/newsize7.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-#
-# Copyright (c) 2009, 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 6561126
-# @summary keytool should use larger default keysize for keypairs
-#
-# @run shell newsize7.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 [ "${TESTJAVA}" = "" ] ; then
-  JAVA_CMD=`which java`
-  TESTJAVA=`dirname $JAVA_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KSFILE=ns7.jks
-
-KT="${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keystore ns7.jks -storepass changeit -keypass changeit -keyalg rsa"
-JAR="${TESTJAVA}${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JS="${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -keystore ns7.jks -storepass changeit"
-
-rm ns7.*
-
-$KT -genkeypair -alias me -dname CN=Me
-
-touch ns7.txt
-$JAR cvf ns7.jar ns7.txt
-
-$JS ns7.jar me
-$JAR xvf ns7.jar
-
-grep SHA-256 META-INF/MANIFEST.MF || exit 1
-grep SHA-256 META-INF/ME.SF || exit 2
-
-#rm -rf META-INF
-
-exit 0
--- a/test/jdk/sun/security/tools/jarsigner/oldsig.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-#
-# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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 6543940 6868865
-# @summary Exception thrown when signing a jarfile in java 1.5
-#
-# @run shell oldsig.sh
-
-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 )
-    NULL=/dev/null
-    PS=":"
-    FS="/"
-    CP="${FS}bin${FS}cp -f"
-    ;;
-  CYGWIN* )
-    NULL=/dev/null
-    PS=";"
-    FS="/"
-    CP="cp -f"
-    ;;
-  Windows_* )
-    NULL=NUL
-    PS=";"
-    FS="\\"
-    CP="cp -f"
-    ;;
-  * )
-    echo "Unrecognized operating system!"
-    exit 1;
-    ;;
-esac
-
-# copy jar file into writeable location
-${CP} ${TESTSRC}${FS}oldsig${FS}A.jar B.jar
-${CP} ${TESTSRC}${FS}oldsig${FS}A.class B.class
-
-${TESTJAVA}${FS}bin${FS}jar ${TESTTOOLVMOPTS} uvf B.jar B.class
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} \
-    -keystore ${TESTSRC}${FS}JarSigning.keystore \
-    -storepass bbbbbb \
-    -digestalg SHA1 \
-    B.jar c
-${TESTJAVA}${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS} -verify B.jar
--- a/test/jdk/sun/security/tools/jarsigner/onlymanifest.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,70 +0,0 @@
-#
-# Copyright (c) 2010, 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 7004035
-# @summary signed jar with only META-INF/* inside is not verifiable
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KS=onlymanifest.jks
-JFILE=onlymanifest.jar
-
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit \
-        -keystore $KS -keyalg rsa"
-JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
-
-rm $KS $JFILE 2> /dev/null
-
-# Create an empty jar file with only MANIFEST.MF
-
-echo "Key: Value" > manifest
-$JAR cvfm $JFILE manifest
-
-$KT -alias ca -dname CN=ca -genkey -validity 300 || exit 1
-$KT -alias a -dname CN=a -genkey -validity 300 || exit 2
-$KT -alias a -certreq | $KT -gencert -alias ca -validity 300 | $KT -import -alias a || exit 3
-$JARSIGNER -keystore $KS -storepass changeit $JFILE a -debug -strict || exit 4
-$JARSIGNER -keystore $KS -storepass changeit -verify $JFILE a -debug -strict \
-        > onlymanifest.out || exit 5
-
-grep unsigned onlymanifest.out && exit 6
-
-exit 0
-
--- a/test/jdk/sun/security/tools/jarsigner/passtype.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-#
-# Copyright (c) 2009, 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.
-#
-# 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 6868579
-# @summary RFE: jarsigner to support reading password from environment variable
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KS=pt.ks
-JFILE=pt.jar
-
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keystore $KS -validity 300 -keyalg rsa"
-JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
-
-rm $KS $JFILE
-
-$KT -alias a -dname CN=a -keyalg rsa -genkey \
-        -storepass test12 -keypass test12 || exit 1
-PASSENV=test12 $KT -alias b -dname CN=b -keyalg rsa -genkey \
-        -storepass:env PASSENV -keypass:env PASSENV || exit 2
-echo test12 > passfile
-$KT -alias c -dname CN=c -keyalg rsa -genkey \
-        -storepass:file passfile -keypass:file passfile || exit 3
-
-echo A > A
-$JAR cvf $JFILE A
-
-# Sign
-$JARSIGNER -keystore $KS -storepass test12 $JFILE a || exit 4
-PASSENV=test12 $JARSIGNER -keystore $KS -storepass:env PASSENV $JFILE b || exit 5
-$JARSIGNER -keystore $KS -storepass:file passfile $JFILE b || exit 6
-
-# Verify
-$JARSIGNER -keystore $KS -storepass test12 -verify -debug -strict $JFILE || exit 7
-PASSENV=test12 $JARSIGNER -keystore $KS -storepass:env PASSENV -verify -debug -strict $JFILE || exit 8
-$JARSIGNER -keystore $KS -storepass:file passfile -verify -debug -strict $JFILE || exit 9
-
-exit 0
-
--- a/test/jdk/sun/security/tools/jarsigner/samename.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,61 +0,0 @@
-#
-# Copyright (c) 2009, 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 6866479
-# @summary libzip.so caused JVM to crash when running jarsigner
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* | CYGWIN* )
-    SIGNEDJAR=EM.jar
-    FS="\\"
-    ;;
-  * )
-    SIGNEDJAR=em.jar
-    FS="/"
-    ;;
-esac
-
-KS=samename.jks
-JFILE=em.jar
-
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
-JAR="$TESTJAVA${FS}bin${FS}jar ${TESTTOOLVMOPTS}"
-JARSIGNER="$TESTJAVA${FS}bin${FS}jarsigner ${TESTTOOLVMOPTS}"
-
-rm $KS $JFILE $SIGNEDJAR
-echo A > A
-$JAR cvf $JFILE A
-
-$KT -alias a -dname CN=a -keyalg rsa -genkey -validity 300
-
-$JARSIGNER -keystore $KS -storepass changeit -signedjar $SIGNEDJAR $JFILE a
-
--- a/test/jdk/sun/security/tools/jarsigner/weaksize.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-#
-# 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
-# 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 8044755
-# @summary Add a test for algorithm constraints check in jarsigner
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US"
-
-# The sigalg used is MD2withRSA, which is obsolete.
-
-KT="$TESTJAVA/bin/keytool ${TESTTOOLVMOPTS} -keystore ks
-    -storepass changeit -keypass changeit
-    -keyalg rsa -sigalg MD2withRSA -debug"
-JS="$TESTJAVA/bin/jarsigner ${TESTTOOLVMOPTS} -keystore ks
-    -storepass changeit -strict -debug"
-JAR="$TESTJAVA/bin/jar ${TESTTOOLVMOPTS}"
-
-rm ks 2> /dev/null
-
-$KT -genkeypair -alias ca -dname CN=CA -ext bc
-$KT -genkeypair -alias signer -dname CN=Signer
-
-$KT -certreq -alias signer | \
-        $KT -gencert -alias ca -ext ku=dS -rfc | \
-        $KT -importcert -alias signer
-
-$JAR cvf a.jar ks
-
-# We always trust a TrustedCertificateEntry
-$JS a.jar ca | grep "chain is invalid" && exit 1
-
-# An end-entity cert must follow algorithm constraints
-$JS a.jar signer | grep "chain is invalid" || exit 2
-
-exit 0
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/CloneKeyAskPassword.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6178366
+ * @library /test/lib
+ * @summary confirm that keytool correctly finds (and clones) a private key
+ *          when the user is prompted for the key's password.
+ */
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+
+import java.io.File;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.security.KeyStore;
+
+public class CloneKeyAskPassword {
+    public static void main(String[] args) throws Exception {
+
+        // Different storepass and keypass
+        Files.copy(Path.of(
+                    System.getProperty("test.src"), "CloneKeyAskPassword.jks"),
+                Path.of("CloneKeyAskPassword.jks"));
+
+        // Clone with original keypass
+        SecurityTools.setResponse("test456", "");
+        SecurityTools.keytool(
+                "-keyclone",
+                "-alias", "mykey",
+                "-dest", "myclone1",
+                "-keystore", "CloneKeyAskPassword.jks",
+                "-storepass", "test123").shouldHaveExitValue(0);
+
+        // Clone with new keypass
+        SecurityTools.setResponse("test456", "test789", "test789");
+        SecurityTools.keytool(
+                "-keyclone",
+                "-alias", "mykey",
+                "-dest", "myclone2",
+                "-keystore", "CloneKeyAskPassword.jks",
+                "-storepass", "test123").shouldHaveExitValue(0);
+
+        KeyStore ks = KeyStore.getInstance(
+                new File("CloneKeyAskPassword.jks"), "test123".toCharArray());
+        Asserts.assertNotNull(ks.getKey("myclone1", "test456".toCharArray()));
+        Asserts.assertNotNull(ks.getKey("myclone2", "test789".toCharArray()));
+    }
+}
--- a/test/jdk/sun/security/tools/keytool/CloneKeyAskPassword.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-#
-# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 6178366
-# @summary confirm that keytool correctly finds (and clones) a private key
-#          when the user is prompted for the key's password.
-#
-# @run shell CloneKeyAskPassword.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 )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  Linux )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  Darwin )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  AIX )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  CYGWIN* )
-    PATHSEP=";"
-    FILESEP="/"
-    ;;
-  Windows* )
-    PATHSEP=";"
-    FILESEP="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-# get a writeable keystore
-cp ${TESTSRC}${FILESEP}CloneKeyAskPassword.jks .
-chmod 644 CloneKeyAskPassword.jks
-
-# run the test: attempt to clone the private key
-${TESTJAVA}${FILESEP}bin${FILESEP}keytool ${TESTTOOLVMOPTS} \
-        -keyclone \
-        -alias mykey \
-        -dest myclone \
-        -keystore CloneKeyAskPassword.jks \
-        -storepass test123 <<EOF
-test456
-EOF
-
-exit $?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/DefaultOptions.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,109 @@
+/*
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8023197
+ * @summary Pre-configured command line options for keytool and jarsigner
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+import jdk.test.lib.process.ProcessTools;
+
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.List;
+
+public class DefaultOptions {
+
+    public static void main(String[] args) throws Throwable {
+
+        Files.write(Path.of("kt.conf"), List.of(
+                "# A Pre-configured options file",
+                "keytool.all = -storepass:env PASS -keypass:env PASS "
+                        + "-keystore ${user.dir}/ks -debug",
+                "keytool.genkey = -keyalg ec -ext bc",
+                "keytool.delete = -keystore nothing"));
+
+        // kt.conf is read
+        keytool("-conf kt.conf -genkeypair -dname CN=A -alias a")
+                .shouldHaveExitValue(0);
+        keytool("-conf kt.conf -list -alias a -v")
+                .shouldHaveExitValue(0)
+                .shouldMatch("Signature algorithm name.*ECDSA")
+                .shouldContain("BasicConstraints");
+
+        // kt.conf is read, and dup multi-valued options processed as expected
+        keytool("-conf kt.conf -genkeypair -dname CN=B -alias b -ext ku=ds")
+                .shouldHaveExitValue(0);
+        keytool("-conf kt.conf -list -alias b -v")
+                .shouldHaveExitValue(0)
+                .shouldContain("BasicConstraints")
+                .shouldContain("DigitalSignature");
+
+        // Single-valued option in command section override all
+        keytool("-conf kt.conf -delete -alias a")
+                .shouldNotHaveExitValue(0);
+
+        // Single-valued option on command line overrides again
+        keytool("-conf kt.conf -delete -alias b -keystore ks")
+                .shouldHaveExitValue(0);
+
+        // Error cases
+
+        // File does not exist
+        keytool("-conf no-such-file -help -list")
+                .shouldNotHaveExitValue(0);
+
+        // Cannot have both standard name (-genkeypair) and legacy name (-genkey)
+        Files.write(Path.of("bad.conf"), List.of(
+                "keytool.all = -storepass:env PASS -keypass:env PASS -keystore ks",
+                "keytool.genkeypair = -keyalg rsa",
+                "keytool.genkey = -keyalg ec"));
+
+        keytool("-conf bad.conf -genkeypair -alias me -dname cn=me")
+                .shouldNotHaveExitValue(0);
+
+        // Unknown options are rejected by tool
+        Files.write(Path.of("bad.conf"), List.of(
+                "keytool.all=-unknown"));
+
+        keytool("-conf bad.conf -help -list").shouldNotHaveExitValue(0);
+
+        // System property must be present
+        Files.write(Path.of("bad.conf"), List.of(
+                "keytool.all = -keystore ${no.such.prop}"));
+
+        keytool("-conf bad.conf -help -list").shouldNotHaveExitValue(0);
+    }
+
+    // Run keytool with one environment variable PASS=changeit
+    static OutputAnalyzer keytool(String cmd) throws Throwable {
+        ProcessBuilder pb = SecurityTools.getProcessBuilder(
+                "keytool", List.of(cmd.trim().split("\\s+")));
+        pb.environment().put("PASS", "changeit");
+        return ProcessTools.executeCommand(pb);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/EmptySubject.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6847026
+ * @summary keytool should be able to generate certreq and cert without subject name
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class EmptySubject{
+    static final String KS = "emptysubject.jks";
+    public static void main(String[] args) throws Exception {
+        kt("-alias", "ca", "-dname", "CN=CA", "-genkeypair");
+        kt("-alias", "me", "-dname", "CN=Me", "-genkeypair");
+
+        // When -dname is recognized, SAN must be specified, otherwise,
+        // -printcert fails.
+        kt("-alias", "me", "-certreq", "-dname", "", "-file", "me1.req")
+                .shouldHaveExitValue(0);
+        kt("-alias", "ca", "-gencert",
+                "-infile", "me1.req", "-outfile", "me1.crt")
+                .shouldHaveExitValue(0);
+        kt("-printcert", "-file", "me1.crt").shouldNotHaveExitValue(0);
+
+        kt("-alias", "me", "-certreq", "-file", "me2.req")
+                .shouldHaveExitValue(0);
+        kt("-alias", "ca", "-gencert", "-dname", "",
+                "-infile", "me2.req", "-outfile", "me2.crt")
+                .shouldHaveExitValue(0);
+        kt("-printcert", "-file", "me2.crt").shouldNotHaveExitValue(0);
+
+        kt("-alias", "me", "-certreq", "-dname", "", "-file", "me3.req")
+                .shouldHaveExitValue(0);
+        kt("-alias", "ca", "-gencert", "-ext", "san:c=email:me@me.com",
+                "-infile", "me3.req", "-outfile", "me3.crt")
+                .shouldHaveExitValue(0);
+        kt("-printcert", "-file", "me3.crt").shouldHaveExitValue(0);
+
+        kt("-alias", "me", "-certreq", "-file", "me4.req")
+                .shouldHaveExitValue(0);
+        kt("-alias", "ca", "-gencert", "-dname", "",
+                "-ext", "san:c=email:me@me.com",
+                "-infile", "me4.req", "-outfile", "me4.crt")
+                .shouldHaveExitValue(0);
+        kt("-printcert", "-file", "me4.crt").shouldHaveExitValue(0);
+    }
+
+    static OutputAnalyzer kt(String... s) throws Exception {
+        List<String> cmd = new ArrayList<>();
+        cmd.addAll(Arrays.asList(
+                "-storepass", "changeit",
+                "-keypass", "changeit",
+                "-keystore", KS,
+                "-keyalg", "rsa"));
+        cmd.addAll(Arrays.asList(s));
+        return SecurityTools.keytool(cmd);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/FileInHelp.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2010, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6922482
+ * @summary keytool's help on -file always shows 'output file'
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+
+public class FileInHelp {
+    public static void main(String[] args) throws Exception {
+        SecurityTools.keytool("-printcertreq -help")
+                .shouldHaveExitValue(0)
+                .shouldContain("input file");
+        SecurityTools.keytool("-exportcert -help")
+                .shouldHaveExitValue(0)
+                .shouldContain("output file");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/ImportReadAll.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6819272
+ * @summary keytool -importcert should read the whole input
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class ImportReadAll {
+    public static void main(String[] args) throws Exception {
+        keytool("-genkeypair -alias a -dname CN=a").shouldHaveExitValue(0);
+        keytool("-genkeypair -alias ca -dname CN=ca").shouldHaveExitValue(0);
+
+        keytool("-certreq -alias a -file a.req").shouldHaveExitValue(0);
+        keytool("-gencert -alias ca -infile a.req -outfile a.crt")
+                .shouldHaveExitValue(0);
+        keytool("-importcert -alias a -file a.crt").shouldHaveExitValue(0);
+    }
+
+    static OutputAnalyzer keytool(String s) throws Exception {
+        return SecurityTools.keytool(
+                "-keystore importreadall.jks "
+                + "-storepass changeit -keypass changeit -keyalg rsa " + s);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/KeyAlg.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8029659
+ * @summary Keytool, print key algorithm of certificate or key entry
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class KeyAlg {
+    public static void main(String[] args) throws Exception {
+        keytool("-genkeypair -alias ca -dname CN=CA -keyalg EC")
+                .shouldHaveExitValue(0);
+        keytool("-genkeypair -alias user -dname CN=User -keyalg RSA -keysize 1024")
+                .shouldHaveExitValue(0);
+        keytool("-certreq -alias user -file user.req").shouldHaveExitValue(0);
+        keytool("-gencert -alias ca -rfc -sigalg SHA1withECDSA"
+                + " -infile user.req -outfile user.crt")
+                .shouldHaveExitValue(0);
+        keytool("-printcert -file user.crt")
+                .shouldHaveExitValue(0)
+                .shouldMatch("Signature algorithm name:.*SHA1withECDSA")
+                .shouldMatch("Subject Public Key Algorithm:.*1024.*RSA");
+    }
+
+    static OutputAnalyzer keytool(String s) throws Exception {
+        return SecurityTools.keytool(
+                "-keystore ks -storepass changeit -keypass changeit " + s);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/NewHelp.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6324292
+ * @summary keytool -help is unhelpful
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+
+public class NewHelp {
+    public static void main(String[] args) throws Exception {
+        SecurityTools.keytool("-help")
+                .shouldHaveExitValue(0)
+                .shouldContain("Commands:");
+        SecurityTools.keytool("-help -list")
+                .shouldHaveExitValue(0)
+                .shouldContain("Options:");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/NoExtNPE.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6813402
+ * @summary keytool cannot -printcert entries without extensions
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+
+import java.nio.file.Path;
+
+public class NoExtNPE {
+    public static void main(String[] args) throws Exception {
+        SecurityTools.keytool("-list -v -keystore " +
+                Path.of(System.getProperty("test.src"), "CloneKeyAskPassword.jks")
+                + " -storepass test123").shouldHaveExitValue(0);
+    }
+}
--- a/test/jdk/sun/security/tools/keytool/NoExtNPE.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,75 +0,0 @@
-#
-# Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# 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 6813402
-# @summary keytool cannot -printcert entries without extensions
-#
-# @run shell NoExtNPE.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 [ "${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 )
-    FILESEP="/"
-    ;;
-  Linux )
-    FILESEP="/"
-    ;;
-  Darwin )
-    FILESEP="/"
-    ;;
-  AIX )
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  CYGWIN* )
-    FILESEP="/"
-    ;;
-  Windows* )
-    FILESEP="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-${TESTJAVA}${FILESEP}bin${FILESEP}keytool ${TESTTOOLVMOPTS} \
-        -list -v \
-        -keystore ${TESTSRC}${FILESEP}CloneKeyAskPassword.jks \
-        -storepass test123
-
-exit $?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/Resource.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6239297
+ * @summary keytool usage is broken after changing Resources.java
+ * @author Max Wang
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+
+public class Resource {
+    public static void main(String[] args) throws Exception {
+        SecurityTools.keytool()
+                .shouldNotContain("MissingResourceException");
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/SecretKeyKS.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2002, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 4694076
+ * @summary KeyTool throws ArrayIndexOutOfBoundsException for listing
+ *          SecretKey entries in non-verbose mode.
+ * @author Valerie Peng
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+
+import java.nio.file.Path;
+
+public class SecretKeyKS {
+    public static void main(String[] args) throws Exception {
+        SecurityTools.keytool("-list -keystore " +
+                Path.of(System.getProperty("test.src"), "SecretKeyKS.jks") +
+                " -storepass password").shouldHaveExitValue(0);
+    }
+}
--- a/test/jdk/sun/security/tools/keytool/SecretKeyKS.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-#
-# Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 4694076
-# @summary KeyTool throws ArrayIndexOutOfBoundsException for listing
-#          SecretKey entries in non-verbose mode.
-# @author Valerie Peng
-#
-# @run shell SecretKeyKS.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 )
-    NULL=/dev/null
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    NULL=/dev/null
-    PS=";"
-    FS="/"
-    ;;
-  Windows_* )
-    NULL=NUL
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized operating system!"
-    exit 1;
-    ;;
-esac
-
-# the test code
-
-${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -list -keystore ${TESTSRC}${FS}SecretKeyKS.jks -storepass password
-
-exit $?
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/SecurityToolsTest.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8180573
+ * @summary Enhance SecurityTools input line parsing
+ * @library /test/lib
+ */
+
+import jdk.test.lib.Asserts;
+import jdk.test.lib.SecurityTools;
+
+import java.util.List;
+
+public class SecurityToolsTest {
+    public static void main(String[] args) {
+        Asserts.assertEQ(SecurityTools.makeList("a b c"),
+                List.of("a", "b", "c"));
+        Asserts.assertEQ(SecurityTools.makeList("  a b c  "),
+                List.of("a", "b", "c"));
+        Asserts.assertEQ(SecurityTools.makeList("a\tb\nc"),
+                List.of("a", "b", "c"));
+        Asserts.assertEQ(SecurityTools.makeList("a `b` c"),
+                List.of("a", "b", "c"));
+        Asserts.assertEQ(SecurityTools.makeList("`a` b c"),
+                List.of("a", "b", "c"));
+        Asserts.assertEQ(SecurityTools.makeList("a b `c`"),
+                List.of("a", "b", "c"));
+        Asserts.assertEQ(SecurityTools.makeList("`a b` b c"),
+                List.of("a b", "b", "c"));
+        Asserts.assertEQ(SecurityTools.makeList("`a b c`"),
+                List.of("a b c"));
+        Asserts.assertEQ(SecurityTools.makeList("a ` b ` c"),
+                List.of("a", " b ", "c"));
+        Asserts.assertEQ(SecurityTools.makeList("a`b c"),
+                List.of("a`b", "c"));
+        Asserts.assertEQ(SecurityTools.makeList("a `\"b\"` c"),
+                List.of("a", "\"b\"", "c"));
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/SelfIssued.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 6825352 6937978
+ * @summary support self-issued certificate in keytool and let -gencert generate the chain
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class SelfIssued {
+    public static void main(String[] args) throws Exception {
+        keytool("-alias ca -dname CN=CA -genkeypair");
+        keytool("-alias ca1 -dname CN=CA1 -genkeypair");
+        keytool("-alias ca2 -dname CN=CA2 -genkeypair");
+        keytool("-alias e1 -dname CN=E1 -genkeypair");
+
+        // ca signs ca1, ca1 signs ca2, all self-issued
+        keytool("-alias ca1 -certreq -file ca1.req");
+        keytool("-alias ca -gencert -ext san=dns:ca1 "
+                + "-infile ca1.req -outfile ca1.crt");
+        keytool("-alias ca1 -importcert -file ca1.crt");
+
+        keytool("-alias ca2 -certreq -file ca2.req");
+        keytool("-alias ca1 -gencert -ext san=dns:ca2 "
+                + "-infile ca2.req -outfile ca2.crt");
+        keytool("-alias ca2 -importcert -file ca2.crt");
+
+        // Import e1 signed by ca2, should add ca2 and ca1, at least 3 certs in the chain
+        keytool("-alias e1 -certreq -file e1.req");
+        keytool("-alias ca2 -gencert -infile e1.req -outfile e1.crt");
+
+        keytool("-alias ca1 -delete");
+        keytool("-alias ca2 -delete");
+        keytool("-alias e1 -importcert -file e1.crt");
+        keytool("-alias e1 -list -v")
+                .shouldContain("[3]");
+    }
+
+    static OutputAnalyzer keytool(String s) throws Exception {
+        return SecurityTools.keytool("-storepass changeit -keypass changeit "
+                + "-keystore ks -keyalg rsa " + s);
+    }
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/StandardAlgName.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2004, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 4909889
+ * @summary KeyTool accepts any input that user make as long as we can make some
+ *          sense out of it, but when comes to present the info the user, it
+ *          promotes a standard look.
+ * @author Andrew Fan
+ * @library /test/lib
+ * @run main/timeout=240 StandardAlgName
+ */
+
+import jdk.test.lib.SecurityTools;
+
+public class StandardAlgName {
+    public static void main(String[] args) throws Exception {
+        // CA
+        SecurityTools.keytool("-genkey", "-v", "-alias", "pkcs12testCA",
+                "-keyalg", "RsA", "-keysize", "2048",
+                "-sigalg", "ShA1wItHRSA",
+                "-dname", "cn=PKCS12 Test CA, ou = Security SQE, o = JavaSoft, c = US",
+                "-validity", "3650",
+                "-keypass", "storepass", "-keystore", "keystoreCA.jceks.data",
+                "-storepass", "storepass", "-storetype", "jceKS")
+                .shouldHaveExitValue(0)
+                .shouldNotContain("RsA")
+                .shouldNotContain("ShA1wItHRSA")
+                .shouldContain("RSA")
+                .shouldContain("SHA1withRSA");
+
+        // Lead
+        SecurityTools.keytool("-genkey", "-v", "-alias", "pkcs12testLead",
+                "-keyalg", "rSA", "-keysize", "1024",
+                "-sigalg", "mD5withRSA",
+                "-dname", "cn=PKCS12 Test Lead, ou=Security SQE, o=JavaSoft, c=US",
+                "-validity", "3650",
+                "-keypass", "storepass", "-keystore", "keystoreLead.jceks.data",
+                "-storepass", "storepass", "-storetype", "jCeks")
+                .shouldHaveExitValue(0)
+                .shouldNotContain("rSA")
+                .shouldNotContain("mD5withRSA")
+                .shouldContain("RSA")
+                .shouldContain("MD5withRSA");
+
+        // End User 1
+        SecurityTools.keytool("-genkey", "-v", "-alias", "pkcs12testEndUser1",
+                "-keyalg", "RSa", "-keysize", "1024",
+                "-sigalg", "sHa1wIThRSA",
+                "-dname", "cn=PKCS12 Test End User 1, ou=Security SQE, o=JavaSoft, c=US",
+                "-validity", "3650",
+                "-keypass", "storepass", "-keystore", "keystoreEndUser1.jceks.data",
+                "-storepass", "storepass", "-storetype", "Jceks")
+                .shouldHaveExitValue(0)
+                .shouldNotContain("RSa")
+                .shouldNotContain("sHa1wIThRSA")
+                .shouldContain("RSA")
+                .shouldContain("SHA1withRSA");
+    }
+}
--- a/test/jdk/sun/security/tools/keytool/StandardAlgName.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,94 +0,0 @@
-#
-# 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 1.1 04/11/12
-# @bug 4909889
-# @summary KeyTool accepts any input that user make as long as we can make some
-#          sense out of it, but when comes to present the info the user, it
-#          promotes a standard look.
-# @author Andrew Fan
-#
-# @run shell/timeout=240 StandardAlgName.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 )
-    NULL=/dev/null
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    NULL=/dev/null
-    PS=";"
-    FS="/"
-    ;;
-  Windows_* )
-    NULL=NUL
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized operating system!"
-    exit 1;
-    ;;
-esac
-
-# the test code
-#CA
-${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -genkey -v -alias pkcs12testCA -keyalg "RsA" -keysize 2048 -sigalg "ShA1wItHRSA" -dname "cn=PKCS12 Test CA, ou=Security SQE, o=JavaSoft, c=US" -validity 3650 -keypass storepass -keystore keystoreCA.jceks.data -storepass storepass -storetype jceKS 2>&1 | egrep 'RsA|ShA1wItHRSA'
-
-RESULT=$?
-if [ $RESULT -eq 0 ]; then
-    exit 1
-else
-    #Lead
-    ${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -genkey -v -alias pkcs12testLead -keyalg "rSA" -keysize 1024 -sigalg "mD5withRSA" -dname "cn=PKCS12 Test Lead, ou=Security SQE, o=JavaSoft, c=US" -validity 3650 -keypass storepass -keystore keystoreLead.jceks.data -storepass storepass -storetype jCeks 2>&1 | egrep 'rSA|mD5withRSA'
-    RESULT=$?
-    if [ $RESULT -eq 0 ]; then
-        exit 1
-    else
-        #End User 1
-        ${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -genkey -v -alias pkcs12testEndUser1 -keyalg "RSa" -keysize 1024 -sigalg "sHa1wIThRSA" -dname "cn=PKCS12 Test End User 1, ou=Security SQE, o=JavaSoft, c=US" -validity 3650 -keypass storepass -keystore keystoreEndUser1.jceks.data -storepass storepass -storetype Jceks 2>&1 | egrep 'RSa|sHa1wIThRSA'
-        RESULT=$?
-        if [ $RESULT -eq 0 ]; then
-            exit 1
-        else
-            exit 0
-        fi
-    fi
-fi
-
--- a/test/jdk/sun/security/tools/keytool/StorePasswords.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/jdk/sun/security/tools/keytool/StorePasswords.java	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 2019, Oracle and/or its affiliates. All rights reserved.
  * 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,12 @@
  * @test
  * @bug 8008296
  * @summary Store and retrieve user passwords using PKCS#12 keystore
+ * @library /test/lib
  */
 
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
 import java.io.*;
 import java.security.*;
 import java.util.*;
@@ -79,6 +83,18 @@
             "recovered " + recoverCount + " user passwords");
 
         new File(KEYSTORE).delete();
+
+        storeCount = storeByShell();
+        recoverCount = recoverByShell();
+
+        if (recoverCount != storeCount || storeCount < 11) {
+            throw new Exception("Stored " + storeCount + " user passwords, " +
+                    "recovered " + recoverCount + " user passwords");
+        }
+        System.out.println("\nStored " + storeCount + " user passwords, " +
+                "recovered " + recoverCount + " user passwords");
+
+        new File(KEYSTORE).delete();
     }
 
     private static int store() throws Exception {
@@ -189,4 +205,35 @@
 
         return count;
     }
+
+    private static int storeByShell() throws Exception {
+        int count = 0;
+        for (String algorithm : PBE_ALGORITHMS) {
+            System.out.println("Storing user password (protected by " + algorithm + " )");
+            String importCmd = count < 5 ? "-importpassword" : "-importpass";
+            String keyAlg = algorithm.equals("default PBE algorithm")
+                    ? "" : (" -keyalg " + algorithm);
+            SecurityTools.setResponse("hello1");
+            OutputAnalyzer oa = SecurityTools.keytool(importCmd
+                    + " -storetype pkcs12 -keystore mykeystore.p12"
+                    + " -storepass changeit -alias `this entry is protected by "
+                    + algorithm + "`" + keyAlg);
+            if (oa.getExitValue() == 0) {
+                System.out.println("OK");
+                count++;
+            } else {
+                System.out.println("ERROR");
+            }
+        }
+        return count;
+    }
+
+    private static int recoverByShell() throws Exception {
+        return (int)SecurityTools.keytool("-list -storetype pkcs12"
+                + " -keystore mykeystore.p12 -storepass changeit")
+                .shouldHaveExitValue(0)
+                .asLines().stream()
+                .filter(s -> s.contains("this entry is protected by"))
+                .count();
+    }
 }
--- a/test/jdk/sun/security/tools/keytool/StorePasswordsByShell.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,132 +0,0 @@
-#
-# Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
-# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
-#
-# This code is free software; you can redistribute it and/or modify it
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-
-# @test
-# @bug 8008296
-# @summary confirm that keytool correctly imports user passwords
-#
-# @run shell StorePasswordsByShell.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)
-    PATHSEP=":"
-    FILESEP="/"
-    ;;
-  CYGWIN* )
-    PATHSEP=";"
-    FILESEP="/"
-    ;;
-  Windows* )
-    PATHSEP=";"
-    FILESEP="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-
-PBE_ALGORITHMS="\
- default-PBE-algorithm \
- PBEWithMD5AndDES \
- PBEWithSHA1AndDESede \
- PBEWithSHA1AndRC2_40 \
- PBEWithSHA1AndRC2_128 
- PBEWithSHA1AndRC4_40 \
- PBEWithSHA1AndRC4_128 \
- PBEWithHmacSHA1AndAES_128 \
- PBEWithHmacSHA224AndAES_128 \
- PBEWithHmacSHA256AndAES_128 \
- PBEWithHmacSHA384AndAES_128 \
- PBEWithHmacSHA512AndAES_128 \
- PBEWithHmacSHA1AndAES_256 \
- PBEWithHmacSHA224AndAES_256 \
- PBEWithHmacSHA256AndAES_256 \
- PBEWithHmacSHA384AndAES_256 \
- PBEWithHmacSHA512AndAES_256"
-
-USER_PWD="hello1\n"
-ALIAS_PREFIX="this entry is protected by "
-COUNTER=0
-
-# cleanup
-rm mykeystore.p12 > /dev/null 2>&1
-
-echo
-for i in $PBE_ALGORITHMS; do
-
-    if [ $i = "default-PBE-algorithm" ]; then
-        KEYALG=""
-    else
-        KEYALG="-keyalg ${i}"
-    fi
-
-    if [ $COUNTER -lt 5 ]; then
-        IMPORTPASSWORD="-importpassword"
-    else
-        IMPORTPASSWORD="-importpass"
-    fi
-
-    echo "Storing user password (protected by ${i})"
-    echo "${USER_PWD}" | \
-        ${TESTJAVA}${FILESEP}bin${FILESEP}keytool ${TESTTOOLVMOPTS} ${IMPORTPASSWORD} \
-            -storetype pkcs12 -keystore mykeystore.p12 -storepass changeit \
-            -alias "${ALIAS_PREFIX}${i}" ${KEYALG} > /dev/null 2>&1
-    if [ $? -ne 0 ]; then
-        echo Error
-    else
-        echo OK
-        COUNTER=`expr ${COUNTER} + 1`
-    fi
-done
-echo
-
-COUNTER2=`${TESTJAVA}${FILESEP}bin${FILESEP}keytool ${TESTTOOLVMOPTS} -list -storetype pkcs12 \
-  -keystore mykeystore.p12 -storepass changeit | grep -c "${ALIAS_PREFIX}"`
-
-RESULT="stored ${COUNTER} user passwords, detected ${COUNTER2} user passwords"
-if [ $COUNTER -ne $COUNTER2 -o $COUNTER -lt 11 ]; then
-    echo "ERROR: $RESULT"
-    exit 1
-else
-    echo "OK: $RESULT"
-    exit 0
-fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/tools/keytool/TryStore.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2011, 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 7047200
+ * @summary keytool can try save to a byte array before overwrite the file
+ * @library /test/lib
+ */
+
+import jdk.test.lib.SecurityTools;
+import jdk.test.lib.process.OutputAnalyzer;
+
+public class TryStore {
+    public static void main(String[] args) throws Exception {
+        keytool("-genkeypair -alias a -dname CN=A -storepass changeit -keypass changeit");
+        keytool("-genkeypair -alias b -dname CN=B -storepass changeit -keypass changeit");
+
+        // We use -protected for JKS keystore. This is illegal so the command should
+        // fail. Then we can check if the keystore is damaged.
+
+        keytool("-genkeypair -protected -alias b -delete -debug")
+                .shouldNotHaveExitValue(0);
+
+        keytool("-list -storepass changeit")
+                .shouldHaveExitValue(0);
+    }
+
+    static OutputAnalyzer keytool(String s) throws Exception {
+        return SecurityTools.keytool(
+                "-storetype jks -keystore trystore.jks -keyalg rsa " + s);
+    }
+}
--- a/test/jdk/sun/security/tools/keytool/default_options.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +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.
-#
-# 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 8023197
-# @summary Pre-configured command line options for keytool and jarsigner
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US"
-
-KS=ks
-KEYTOOL="$TESTJAVA/bin/keytool ${TESTTOOLVMOPTS}"
-
-rm $KS 2> /dev/null
-
-PASS=changeit
-export PASS
-
-cat <<EOF > kt.conf
-# A Pre-configured options file
-keytool.all = -storepass:env PASS -keypass:env PASS -keystore \${user.dir}/$KS -debug
-keytool.genkey = -keyalg ec -ext bc
-keytool.delete = -keystore nothing
-EOF
-
-# kt.conf is read
-$KEYTOOL -conf kt.conf -genkeypair -dname CN=A -alias a || exit 1
-$KEYTOOL -conf kt.conf -list -alias a -v > a_certinfo || exit 2
-grep "Signature algorithm name" a_certinfo | grep ECDSA || exit 3
-grep "BasicConstraints" a_certinfo || exit 4
-
-# kt.conf is read, and dup multi-valued options processed as expected
-$KEYTOOL -conf kt.conf -genkeypair -dname CN=B -alias b -ext ku=ds \
-        || exit 11
-$KEYTOOL -conf kt.conf -list -alias b -v > b_certinfo || exit 12
-grep "BasicConstraints" b_certinfo || exit 14
-grep "DigitalSignature" b_certinfo || exit 15
-
-# Single-valued option in command section override all
-$KEYTOOL -conf kt.conf -delete -alias a && exit 16
-
-# Single-valued option on command line overrides again
-$KEYTOOL -conf kt.conf -delete -alias b -keystore $KS || exit 17
-
-# Error cases
-
-# File does not exist
-$KEYTOOL -conf no-such-file -help -list && exit 31
-
-# Cannot have both standard name (-genkeypair) and legacy name (-genkey)
-cat <<EOF > bad.conf
-keytool.all = -storepass:env PASS -keypass:env PASS -keystore ks
-keytool.genkeypair = -keyalg rsa
-keytool.genkey = -keyalg ec
-EOF
-
-$KEYTOOL -conf bad.conf -genkeypair -alias me -dname "cn=me" && exit 32
-
-# Unknown options are rejected by tool
-cat <<EOF > bad.conf
-keytool.all=-unknown
-EOF
-
-$KEYTOOL -conf bad.conf -help -list && exit 33
-
-# System property must be present
-cat <<EOF > bad.conf
-keytool.all = -keystore \${no.such.prop}
-EOF
-
-$KEYTOOL -conf bad.conf -help -list && exit 34
-
-echo Done
-exit 0
--- a/test/jdk/sun/security/tools/keytool/emptysubject.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +0,0 @@
-#
-# Copyright (c) 2009, 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 6847026
-# @summary keytool should be able to generate certreq and cert without subject name
-#
-# @run shell emptysubject.sh
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KS=emptysubject.jks
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
-
-rm $KS
-
-$KT -alias ca -dname CN=CA -genkeypair
-$KT -alias me -dname CN=Me -genkeypair
-
-# When -dname is recognized, SAN must be specfied, otherwise, -printcert fails.
-$KT -alias me -certreq -dname "" | \
-        $KT -alias ca -gencert | $KT -printcert && exit 1
-$KT -alias me -certreq | \
-        $KT -alias ca -gencert -dname "" | $KT -printcert && exit 2
-$KT -alias me -certreq -dname "" | \
-        $KT -alias ca -gencert -ext san:c=email:me@me.com | \
-        $KT -printcert || exit 3
-$KT -alias me -certreq | \
-        $KT -alias ca -gencert -dname "" -ext san:c=email:me@me.com | \
-        $KT -printcert || exit 4
-
-exit 0
-
--- a/test/jdk/sun/security/tools/keytool/file-in-help.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#
-# Copyright (c) 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 6922482
-# @summary keytool's help on -file always shows 'output file'
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US"
-
-$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -printcertreq -help 2> h1 || exit 1
-$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -exportcert -help 2> h2 || exit 2
-
-grep "input file" h1 || exit 3
-grep "output file" h2 || exit 4
-
-exit 0
-
--- a/test/jdk/sun/security/tools/keytool/i18n.html	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/jdk/sun/security/tools/keytool/i18n.html	Sat Apr 13 07:52:21 2019 -0400
@@ -1,11 +1,7 @@
 <html>
 <body>
 
-<applet width=100 height=100 code=i18n.class>
-</applet>
-
-This is a multi-stage test.  Click on "done" when you have completed
-reading these instructions.  For each instruction, make sure the output
+This is a multi-stage test.  For each instruction, make sure the output
 from keytool is correct (you can read everything in english fine).
 
 <ol>
@@ -115,7 +111,5 @@
 If all the output (english) is correct, then the test passed.
 Otherwise, the test failed.
 
-Press "Pass" if ... press "Fail" otherwise.
-
 </body>
 </html>
--- a/test/jdk/sun/security/tools/keytool/i18n.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/jdk/sun/security/tools/keytool/i18n.java	Sat Apr 13 07:52:21 2019 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
  * 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,19 @@
  * questions.
  */
 
-// This trivial file is only necessary to display instructions and "pass/fail"
-// buttons for a manual test.
-public class i18n extends java.applet.Applet
-{
+/*
+ * @test
+ * @bug 4348369 8076069
+ * @summary keytool not i18n compliant
+ * @author charlie lai
+ * @run main/manual i18n
+ */
+
+import java.nio.file.Path;
+
+public class i18n{
+    public static void main(String[] args) throws Exception {
+        System.out.println("see i18n.html");
+        System.out.println(Path.of(System.getProperty("test.jdk"), "bin", "keytool"));
+    }
 }
--- a/test/jdk/sun/security/tools/keytool/i18n.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,73 +0,0 @@
-#
-# Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
-# 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 4348369 8076069
-# @summary keytool not i18n compliant
-# @author charlie lai
-# @run shell/manual i18n.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
-  AIX | Darwin | Linux | SunOS )
-    NULL=/dev/null
-    PS=":"
-    FS="/"
-    ;;
-  CYGWIN* )
-    NULL=/dev/null
-    PS=";"
-    FS="/"
-    ;;
-  Windows* )
-    NULL=NUL
-    PS=";"
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized system!"
-    exit 1;
-    ;;
-esac
-KEYTOOL=${TESTJAVA}${FS}bin${FS}keytool
-
-# the test code
-
-# see i18n.html
-
-exit $?
--- a/test/jdk/sun/security/tools/keytool/importreadall.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-#
-# Copyright (c) 2009, 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 6819272
-# @summary keytool -importcert should read the whole input
-#
-# @run shell importreadall.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 [ "${TESTJAVA}" = "" ] ; then
-  JAVA_CMD=`which java`
-  TESTJAVA=`dirname $JAVA_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KEYTOOL="${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -keystore importreadall.jks -storepass changeit -keypass changeit -keyalg rsa"
-
-# In case the test is run twice in the same directory
-
-$KEYTOOL -delete -alias a
-$KEYTOOL -delete -alias ca
-$KEYTOOL -genkeypair -alias a -dname CN=a || exit 1
-$KEYTOOL -genkeypair -alias ca -dname CN=ca || exit 2
-$KEYTOOL -certreq -alias a | $KEYTOOL -gencert -alias ca | $KEYTOOL -importcert -alias a
-
-exit $?
--- a/test/jdk/sun/security/tools/keytool/keyalg.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,49 +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.
-#
-# 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 8029659
-# @summary Keytool, print key algorithm of certificate or key entry
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US"
-
-KS=ks
-KEYTOOL="$TESTJAVA/bin/keytool ${TESTTOOLVMOPTS} -keystore ks -storepass changeit -keypass changeit"
-
-rm $KS 2> /dev/null
-
-$KEYTOOL -genkeypair -alias ca -dname CN=CA -keyalg EC || exit 1
-$KEYTOOL -genkeypair -alias user -dname CN=User -keyalg RSA -keysize 1024 || exit 2
-$KEYTOOL -certreq -alias user |
-        $KEYTOOL -gencert -alias ca -rfc -sigalg SHA1withECDSA |
-        $KEYTOOL -printcert > user.dump || exit 3
-
-cat user.dump | grep "Signature algorithm name:" | grep SHA1withECDSA || exit 4
-cat user.dump | grep "Subject Public Key Algorithm:" | grep RSA | grep 1024 || exit 5
-
--- a/test/jdk/sun/security/tools/keytool/newhelp.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-#
-# 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.
-#
-
-# @test
-# @bug 6324292
-# @summary keytool -help is unhelpful
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-TESTTOOLVMOPTS="$TESTTOOLVMOPTS -J-Duser.language=en -J-Duser.country=US"
-
-$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -help 2> h1 || exit 1
-$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -help -list 2> h2 || exit 2
-
-grep Commands: h1 || exit 3
-grep Options: h2 || exit 4
-
-exit 0
-
--- a/test/jdk/sun/security/tools/keytool/resource.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,72 +0,0 @@
-#
-# 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.
-#
-
-# @test
-# @bug 6239297
-# @summary keytool usage is broken after changing Resources.java
-# @author Max Wang
-#
-# @run shell resource.sh
-
-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 )
-    NULL=/dev/null
-    FS="/"
-    ;;
-  CYGWIN* )
-    NULL=/dev/null
-    FS="/"
-    ;;
-  Windows_* )
-    NULL=NUL
-    FS="\\"
-    ;;
-  * )
-    echo "Unrecognized operating system!"
-    exit 1;
-    ;;
-esac
-
-# the test code
-${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} > temp_file_40875602475 2> ${NULL}
-grep MissingResourceException temp_file_40875602475
-
-if [ $? -eq 0 ]; then
-    exit 1
-fi
-
-exit 0
--- a/test/jdk/sun/security/tools/keytool/selfissued.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,71 +0,0 @@
-#
-# Copyright (c) 2009, 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.
-#
-# 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 6825352 6937978
-# @summary support self-issued certificate in keytool and let -gencert generate the chain
-#
-# @run shell selfissued.sh
-#
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-KS=selfsigned.ks
-KT="$TESTJAVA${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storepass changeit -keypass changeit -keystore $KS -keyalg rsa"
-
-rm $KS
-
-$KT -alias ca -dname CN=CA -genkeypair
-$KT -alias ca1 -dname CN=CA1 -genkeypair
-$KT -alias ca2 -dname CN=CA2 -genkeypair
-$KT -alias e1 -dname CN=E1 -genkeypair
-
-# ca signs ca1, ca1 signs ca2, all self-issued
-$KT -alias ca1 -certreq | $KT -alias ca -gencert -ext san=dns:ca1 \
-        | $KT -alias ca1 -importcert
-$KT -alias ca2 -certreq | $KT -alias ca1 -gencert -ext san=dns:ca2 \
-        | $KT -alias ca2 -importcert
-
-# Import e1 signed by ca2, should add ca2 and ca1, at least 3 certs in the chain
-$KT -alias e1 -certreq | $KT -alias ca2 -gencert > e1.cert
-$KT -alias ca1 -delete
-$KT -alias ca2 -delete
-cat e1.cert | $KT -alias e1 -importcert
-$KT -alias e1 -list -v | grep '\[3\]' || { echo Bad E1; exit 1; }
-
-echo Good
-
--- a/test/jdk/sun/security/tools/keytool/trystore.sh	Sat Apr 13 07:47:23 2019 -0400
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,65 +0,0 @@
-#
-# Copyright (c) 2011, 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 7047200
-# @summary keytool can try save to a byte array before overwrite the file
-
-if [ "${TESTJAVA}" = "" ] ; then
-  JAVAC_CMD=`which javac`
-  TESTJAVA=`dirname $JAVAC_CMD`/..
-fi
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
-  Windows_* )
-    FS="\\"
-    ;;
-  * )
-    FS="/"
-    ;;
-esac
-
-rm trystore.jks 2> /dev/null
-
-KEYTOOL="${TESTJAVA}${FS}bin${FS}keytool ${TESTTOOLVMOPTS} -storetype jks -keystore trystore.jks -keyalg rsa"
-$KEYTOOL -genkeypair -alias a -dname CN=A -storepass changeit -keypass changeit
-$KEYTOOL -genkeypair -alias b -dname CN=B -storepass changeit -keypass changeit
-
-# We use -protected for JKS keystore. This is illegal so the command should
-# fail. Then we can check if the keystore is damaged.
-
-$KEYTOOL -genkeypair -protected -alias b -delete -debug
-
-if [ $? = 0 ]; then
-    echo "What? -protected works for JKS?"
-    exit 1
-fi
-
-$KEYTOOL -list -storepass changeit
-
-if [ $? != 0 ]; then
-    echo "Keystore file damaged"
-    exit 2
-fi
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/api/lazy/LoadParameterNamesLazily.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,138 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8217047
+ * @summary Verify the parameter names can be injected using ParameterNameProvider.
+ * @library /tools/lib
+ * @modules jdk.compiler/com.sun.tools.javac.api
+ *          jdk.compiler/com.sun.tools.javac.main
+ * @build toolbox.JavacTask toolbox.TestRunner toolbox.ToolBox
+ * @run main LoadParameterNamesLazily
+ */
+
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+import javax.lang.model.element.ExecutableElement;
+import javax.lang.model.element.Name;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.util.ElementFilter;
+
+import com.sun.source.util.*;
+
+import toolbox.JavacTask;
+import toolbox.Task;
+import toolbox.TestRunner;
+import toolbox.ToolBox;
+
+public class LoadParameterNamesLazily extends TestRunner {
+
+    public static void main(String... args) throws Exception {
+        LoadParameterNamesLazily t = new LoadParameterNamesLazily();
+        t.runTests();
+    }
+
+    private static final String libClass =
+            "package lib;" +
+            "/**Lib javadoc.*/" +
+            "public class Lib {" +
+            "    /**Lib method javadoc.*/" +
+            "    public static void m(int param, int other) {}" +
+            "}";
+    private final ToolBox tb = new ToolBox();
+
+    LoadParameterNamesLazily() throws IOException {
+        super(System.err);
+    }
+
+    @Test
+    public void testLoadTreesLazily() throws IOException {
+        Path libSrc = Paths.get("lib-src");
+        tb.writeJavaFiles(libSrc, libClass);
+        Path libClasses = Paths.get("lib-classes");
+        Files.createDirectories(libClasses);
+
+        new JavacTask(tb)
+              .outdir(libClasses)
+              .options()
+              .files(tb.findJavaFiles(libSrc))
+              .run(Task.Expect.SUCCESS)
+              .writeAll();
+
+        Path src = Paths.get("src");
+        tb.writeJavaFiles(src,
+                          "class Use {" +
+                          " lib.Lib lib;" +
+                          "}");
+        Path classes = Paths.get("classes");
+        Files.createDirectories(classes);
+
+        new JavacTask(tb)
+              .outdir(classes)
+              .options("-classpath", libClasses.toString())
+              .files(tb.findJavaFiles(src))
+              .callback(task -> {
+                  task.setParameterNameProvider(parameter -> {
+                      ExecutableElement method = (ExecutableElement) parameter.getEnclosingElement();
+                      TypeElement clazz =
+                              (TypeElement) method.getEnclosingElement();
+                      if (clazz.getQualifiedName().contentEquals("lib.Lib")) {
+                          if (method.getParameters().indexOf(parameter) == 0) {
+                              return "testName";
+                          } else {
+                              return null;
+                          }
+                      }
+                      return null;
+                  });
+                  task.addTaskListener(new TaskListener() {
+                      @Override
+                      public void finished(TaskEvent e) {
+                          if (e.getKind() == TaskEvent.Kind.ANALYZE) {
+                              TypeElement lib = task.getElements().getTypeElement("lib.Lib");
+                              lib.getClass(); //not null
+                              ExecutableElement method =
+                                      ElementFilter.methodsIn(lib.getEnclosedElements()).get(0);
+                              Name paramName0 = method.getParameters().get(0).getSimpleName();
+                              if (!paramName0.contentEquals("testName")) {
+                                  throw new IllegalStateException("Unexpected parameter name: " +
+                                                                  paramName0);
+                              }
+                              Name paramName1 = method.getParameters().get(1).getSimpleName();
+                              if (!paramName1.contentEquals("arg1")) {
+                                  throw new IllegalStateException("Unexpected parameter name: " +
+                                                                  paramName1);
+                              }
+                          }
+                      }
+                  });
+              })
+              .run(Task.Expect.SUCCESS)
+              .writeAll();
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/classreader/8215407/BrokenEnclosingClass.java	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
+ * 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 8215407
+ * @summary Verify broken EnclosingMethod attribute does not break ClassReader.
+ * @library /tools/javac/lib
+ * @modules java.compiler
+ * @build JavacTestingAbstractProcessor
+ * @compile BrokenEnclosingClass.java UnrelatedClass.jcod Enclosing$1.jcod
+ * @compile -processor BrokenEnclosingClass BrokenEnclosingClass.java
+ */
+
+import java.util.Set;
+
+import javax.annotation.processing.RoundEnvironment;
+import javax.lang.model.element.TypeElement;
+
+public class BrokenEnclosingClass extends JavacTestingAbstractProcessor {
+
+    @Override
+    public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+        if (processingEnv.getElementUtils().getTypeElement("UnrelatedClass") == null) {
+            throw new AssertionError("Cannot find UnrelatedClass.");
+        }
+        if (processingEnv.getElementUtils().getTypeElement("Enclosing$1") != null) {
+            throw new AssertionError("Enclosing$1 was found.");
+        }
+        return false;
+    }
+
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/classreader/8215407/Enclosing$1.jcod	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,91 @@
+class Enclosing$1 {
+  0xCAFEBABE;
+  0; // minor version
+  52; // version
+  [] { // Constant Pool
+    ; // first element is empty
+    Field #3 #16; // #1
+    Method #4 #17; // #2
+    class #18; // #3
+    class #20; // #4
+    Utf8 "this$0"; // #5
+    Utf8 "LUnrelatedClass;"; // #6
+    Utf8 "<init>"; // #7
+    Utf8 "(LUnrelatedClass;)V"; // #8
+    Utf8 "Code"; // #9
+    Utf8 "LineNumberTable"; // #10
+    Utf8 "SourceFile"; // #11
+    Utf8 "Enclosing.java"; // #12
+    Utf8 "EnclosingMethod"; // #13
+    class #21; // #14
+    NameAndType #22 #23; // #15
+    NameAndType #5 #6; // #16
+    NameAndType #7 #23; // #17
+    Utf8 "Enclosing$1"; // #18
+    Utf8 "InnerClasses"; // #19
+    Utf8 "java/lang/Object"; // #20
+    Utf8 "UnrelatedClass"; // #21
+    Utf8 "t"; // #22
+    Utf8 "()V"; // #23
+  } // Constant Pool
+
+  0x0020; // access
+  #3;// this_cpx
+  #4;// super_cpx
+
+  [] { // Interfaces
+  } // Interfaces
+
+  [] { // fields
+    { // Member
+      0x1010; // access
+      #5; // name_cpx
+      #6; // sig_cpx
+      [] { // Attributes
+      } // Attributes
+    } // Member
+  } // fields
+
+  [] { // methods
+    { // Member
+      0x0000; // access
+      #7; // name_cpx
+      #8; // sig_cpx
+      [] { // Attributes
+        Attr(#9) { // Code
+          2; // max_stack
+          2; // max_locals
+          Bytes[]{
+            0x2A2BB500012AB700;
+            0x02B1;
+          }
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#10) { // LineNumberTable
+              [] { // LineNumberTable
+                0  3;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [] { // Attributes
+    Attr(#11) { // SourceFile
+      #12;
+    } // end SourceFile
+    ;
+    Attr(#13) { // EnclosingMethod
+      #14; #15;
+    } // end EnclosingMethod
+    ;
+    Attr(#19) { // InnerClasses
+      [] { // InnerClasses
+        #3 #0 #0 0;
+      }
+    } // end InnerClasses
+  } // Attributes
+} // end class Enclosing$1
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/langtools/tools/javac/classreader/8215407/UnrelatedClass.jcod	Sat Apr 13 07:52:21 2019 -0400
@@ -0,0 +1,101 @@
+class UnrelatedClass {
+  0xCAFEBABE;
+  0; // minor version
+  52; // version
+  [] { // Constant Pool
+    ; // first element is empty
+    Method #5 #14; // #1
+    class #15; // #2
+    Method #2 #16; // #3
+    class #17; // #4
+    class #18; // #5
+    Utf8 "InnerClasses"; // #6
+    Utf8 "<init>"; // #7
+    Utf8 "()V"; // #8
+    Utf8 "Code"; // #9
+    Utf8 "LineNumberTable"; // #10
+    Utf8 "t"; // #11
+    Utf8 "SourceFile"; // #12
+    Utf8 "Enclosing.java"; // #13
+    NameAndType #7 #8; // #14
+    Utf8 "Enclosing$1"; // #15
+    NameAndType #7 #19; // #16
+    Utf8 "UnrelatedClass"; // #17
+    Utf8 "java/lang/Object"; // #18
+    Utf8 "(LUnrelatedClass;)V"; // #19
+  } // Constant Pool
+
+  0x0021; // access
+  #4;// this_cpx
+  #5;// super_cpx
+
+  [] { // Interfaces
+  } // Interfaces
+
+  [] { // fields
+  } // fields
+
+  [] { // methods
+    { // Member
+      0x0001; // access
+      #7; // name_cpx
+      #8; // sig_cpx
+      [] { // Attributes
+        Attr(#9) { // Code
+          1; // max_stack
+          1; // max_locals
+          Bytes[]{
+            0x2AB70001B1;
+          }
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#10) { // LineNumberTable
+              [] { // LineNumberTable
+                0  1;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+    ;
+    { // Member
+      0x0001; // access
+      #11; // name_cpx
+      #8; // sig_cpx
+      [] { // Attributes
+        Attr(#9) { // Code
+          3; // max_stack
+          1; // max_locals
+          Bytes[]{
+            0xBB0002592AB70003;
+            0x57B1;
+          }
+          [] { // Traps
+          } // end Traps
+          [] { // Attributes
+            Attr(#10) { // LineNumberTable
+              [] { // LineNumberTable
+                0  3;
+                9  4;
+              }
+            } // end LineNumberTable
+          } // Attributes
+        } // end Code
+      } // Attributes
+    } // Member
+  } // methods
+
+  [] { // Attributes
+    Attr(#12) { // SourceFile
+      #13;
+    } // end SourceFile
+    ;
+    Attr(#6) { // InnerClasses
+      [] { // InnerClasses
+        #2 #0 #0 0;
+      }
+    } // end InnerClasses
+  } // Attributes
+} // end class UnrelatedClass
--- a/test/lib/jdk/test/lib/SecurityTools.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/lib/jdk/test/lib/SecurityTools.java	Sat Apr 13 07:52:21 2019 -0400
@@ -28,6 +28,7 @@
 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.stream.Collectors;
 import java.util.stream.Stream;
@@ -52,7 +53,7 @@
 
     private SecurityTools() {}
 
-    private static ProcessBuilder getProcessBuilder(String tool, List<String> args) {
+    public static ProcessBuilder getProcessBuilder(String tool, List<String> args) {
         JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK(tool)
                 .addVMArg("-Duser.language=en")
                 .addVMArg("-Duser.country=US");
@@ -62,6 +63,9 @@
         for (String arg : args) {
             if (arg.startsWith("-J")) {
                 launcher.addVMArg(arg.substring(2));
+            } else if (Platform.isWindows() && arg.isEmpty()) {
+                // JDK-6518827: special handling for empty argument on Windows
+                launcher.addToolArg("\"\"");
             } else {
                 launcher.addToolArg(arg);
             }
@@ -97,14 +101,13 @@
     /**
      * Runs keytool.
      *
-     * @param args arguments to keytool in a single string. Only call this if
-     *             there is no white space inside an argument. This string will
-     *             be split with {@code \s+}.
+     * @param args arguments to keytool in a single string. The string is
+     *             converted to be List with makeList.
      * @return an {@link OutputAnalyzer} object
      * @throws Exception if there is an error
      */
     public static OutputAnalyzer keytool(String args) throws Exception {
-        return keytool(args.split("\\s+"));
+        return keytool(makeList(args));
     }
 
     /**
@@ -174,15 +177,14 @@
     /**
      * Runs jarsigner.
      *
-     * @param args arguments to jarsigner in a single string. Only call this if
-     *             there is no white space inside an argument. This string will
-     *             be split with {@code \s+}.
+     * @param args arguments to jarsigner in a single string. The string is
+     *             converted to be List with makeList.
      * @return an {@link OutputAnalyzer} object
      * @throws Exception if there is an error
      */
     public static OutputAnalyzer jarsigner(String args) throws Exception {
 
-        return jarsigner(args.split("\\s+"));
+        return jarsigner(makeList(args));
     }
 
     /**
@@ -199,29 +201,79 @@
     /**
      * Runs ktab.
      *
-     * @param args arguments to ktab in a single string. Only call this if
-     *             there is no white space inside an argument. This string will
-     *             be split with {@code \s+}.
+     * @param args arguments to ktab in a single string. The string is
+     *             converted to be List with makeList.
      * @return an {@link OutputAnalyzer} object
      * @throws Exception if there is an error
      */
     public static OutputAnalyzer ktab(String args) throws Exception {
-        return execute(getProcessBuilder(
-                "ktab", List.of(args.trim().split("\\s+"))));
+        return execute(getProcessBuilder("ktab", makeList(args)));
     }
 
     /**
      * Runs klist.
      *
-     * @param args arguments to klist in a single string. Only call this if
-     *             there is no white space inside an argument. This string will
-     *             be split with {@code \s+}.
+     * @param args arguments to klist in a single string. The string is
+     *             converted to be List with makeList.
      * @return an {@link OutputAnalyzer} object
      * @throws Exception if there is an error
      */
     public static OutputAnalyzer klist(String args) throws Exception {
-        return execute(getProcessBuilder(
-                "klist", List.of(args.trim().split("\\s+"))));
+        return execute(getProcessBuilder("klist", makeList(args)));
+    }
+
+    /**
+     * Runs jar.
+     *
+     * @param args arguments to jar in a single string. The string is
+     *             converted to be List with makeList.
+     * @return an {@link OutputAnalyzer} object
+     * @throws Exception if there is an error
+     */
+    public static OutputAnalyzer jar(String args) throws Exception {
+        return execute(getProcessBuilder("jar", makeList(args)));
+    }
+
+    /**
+     * Split a line to a list of string. All whitespaces are treated as
+     * delimiters unless quoted between ` and `.
+     *
+     * @param line the input
+     * @return the list
+     */
+    public static List<String> makeList(String line) {
+        List<String> result = new ArrayList<>();
+        StringBuilder sb = new StringBuilder();
+        boolean inBackTick = false;
+        for (char c : line.toCharArray()) {
+            if (inBackTick) {
+                if (c == '`') {
+                    result.add(sb.toString());
+                    sb.setLength(0);
+                    inBackTick = false;
+                } else {
+                    sb.append(c);
+                }
+            } else {
+                if (sb.length() == 0 && c == '`') {
+                    // Allow ` inside a string
+                    inBackTick = true;
+                } else {
+                    if (Character.isWhitespace(c)) {
+                        if (sb.length() != 0) {
+                            result.add(sb.toString());
+                            sb.setLength(0);
+                        }
+                    } else {
+                        sb.append(c);
+                    }
+                }
+            }
+        }
+        if (sb.length() != 0) {
+            result.add(sb.toString());
+        }
+        return result;
     }
 }
 
--- a/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java	Sat Apr 13 07:47:23 2019 -0400
+++ b/test/lib/jdk/test/lib/containers/docker/DockerTestUtils.java	Sat Apr 13 07:52:21 2019 -0400
@@ -169,11 +169,17 @@
         generateDockerFile(buildDir.resolve("Dockerfile"),
                            DockerfileConfig.getBaseImageName(),
                            DockerfileConfig.getBaseImageVersion());
-
-        // Build the docker
-        execute(DOCKER_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString())
-            .shouldHaveExitValue(0)
-            .shouldContain("Successfully built");
+        try {
+            // Build the docker
+            execute(DOCKER_COMMAND, "build", "--no-cache", "--tag", imageName, buildDir.toString())
+                .shouldHaveExitValue(0)
+                .shouldContain("Successfully built");
+        } catch (Exception e) {
+            // If docker image building fails there is a good chance it happens due to environment and/or
+            // configuration other than product failure. Throw jtreg skipped exception in such case
+            // instead of failing the test.
+            throw new SkippedException("Building docker image failed. Details: \n" + e.getMessage());
+        }
     }