Merge
authorpsadhukhan
Wed, 05 Dec 2018 15:39:04 +0530
changeset 52845 6419f8d3cc3e
parent 52844 de8be034dbd4 (current diff)
parent 52830 726f6a23f004 (diff)
child 52846 6ed72482de52
child 52964 840d66c98b6c
Merge
test/jdk/java/util/Properties/Compatibility.xml
test/jdk/java/util/Properties/CompatibilityTest.java
--- a/make/common/NativeCompilation.gmk	Tue Dec 04 13:35:04 2018 +0530
+++ b/make/common/NativeCompilation.gmk	Wed Dec 05 15:39:04 2018 +0530
@@ -237,7 +237,7 @@
     $1_SRC_FILE := $$($1_FILE)
 
     ifneq ($$($1_DISABLE_THIS_FILE_DEFINE), true)
-      $1_THIS_FILE = -DTHIS_FILE='"$$(<F)"'
+      $1_THIS_FILE = -DTHIS_FILE='"$$($1_FILENAME)"'
     endif
 
     ifeq ($$($1_OPTIMIZATION), )
--- a/make/gensrc/GensrcMisc.gmk	Tue Dec 04 13:35:04 2018 +0530
+++ b/make/gensrc/GensrcMisc.gmk	Wed Dec 05 15:39:04 2018 +0530
@@ -42,6 +42,7 @@
         @@VERSION_DATE@@ => $(VERSION_DATE) ; \
         @@VERSION_CLASSFILE_MAJOR@@ => $(VERSION_CLASSFILE_MAJOR) ; \
         @@VERSION_CLASSFILE_MINOR@@ => $(VERSION_CLASSFILE_MINOR) ; \
+        @@VERSION_SPECIFICATION@@ => $(VERSION_SPECIFICATION) ; \
         @@VENDOR_VERSION_STRING@@ => $(VENDOR_VERSION_STRING) ; \
         @@VENDOR@@ => $(COMPANY_NAME) ; \
         @@VENDOR_URL@@ => $(VENDOR_URL) ; \
--- a/make/launcher/Launcher-jdk.pack.gmk	Tue Dec 04 13:35:04 2018 +0530
+++ b/make/launcher/Launcher-jdk.pack.gmk	Wed Dec 05 15:39:04 2018 +0530
@@ -39,7 +39,7 @@
 # On Mac, we have always exported all symbols, probably due to oversight
 # and/or misunderstanding. To emulate this, don't hide any symbols
 # by default.
-# On AIX/xlc we need at least xlc 13.1 for the symbol hiding
+# On AIX/xlc we need at least xlc 13.1 for the symbol hiding (see JDK-8214063)
 # Also provide an override for non-conformant libraries.
 ifeq ($(TOOLCHAIN_TYPE), gcc)
   CXXFLAGS_JDKEXE += -fvisibility=hidden
@@ -50,10 +50,6 @@
   endif
 else ifeq ($(TOOLCHAIN_TYPE), solstudio)
   CXXFLAGS_JDKEXE += -xldscope=hidden
-else ifeq ($(TOOLCHAIN_TYPE), xlc)
-  ifneq ($(CC_VERSION_NUMBER), 12.1)
-    CXXFLAGS_JDKEXE += -qvisibility=hidden
-  endif
 endif
 
 UNPACKEXE_SRC := $(TOPDIR)/src/jdk.pack/share/native/common-unpack \
--- a/make/launcher/LauncherCommon.gmk	Tue Dec 04 13:35:04 2018 +0530
+++ b/make/launcher/LauncherCommon.gmk	Wed Dec 05 15:39:04 2018 +0530
@@ -33,7 +33,7 @@
 # On Mac, we have always exported all symbols, probably due to oversight
 # and/or misunderstanding. To emulate this, don't hide any symbols
 # by default.
-# On AIX/xlc we need at least xlc 13.1 for the symbol hiding
+# On AIX/xlc we need at least xlc 13.1 for the symbol hiding (see JDK-8214063)
 # Also provide an override for non-conformant libraries.
 ifeq ($(TOOLCHAIN_TYPE), gcc)
   LAUNCHER_CFLAGS += -fvisibility=hidden
@@ -42,10 +42,6 @@
   LAUNCHER_CFLAGS += -fvisibility=hidden
 else ifeq ($(TOOLCHAIN_TYPE), solstudio)
   LAUNCHER_CFLAGS += -xldscope=hidden
-else ifeq ($(TOOLCHAIN_TYPE), xlc)
-  ifneq ($(CC_VERSION_NUMBER), 12.1)
-    CXXFLAGS_JDKEXE += -qvisibility=hidden
-  endif
 endif
 
 LAUNCHER_SRC := $(TOPDIR)/src/java.base/share/native/launcher
--- a/make/lib/LibCommon.gmk	Tue Dec 04 13:35:04 2018 +0530
+++ b/make/lib/LibCommon.gmk	Wed Dec 05 15:39:04 2018 +0530
@@ -38,7 +38,7 @@
 # On Mac, we have always exported all symbols, probably due to oversight
 # and/or misunderstanding. To emulate this, don't hide any symbols
 # by default.
-# On AIX/xlc we need at least xlc 13.1 for the symbol hiding
+# On AIX/xlc we need at least xlc 13.1 for the symbol hiding (see JDK-8214063)
 # Also provide an override for non-conformant libraries.
 ifeq ($(TOOLCHAIN_TYPE), gcc)
   CFLAGS_JDKLIB += -fvisibility=hidden
@@ -53,12 +53,6 @@
   CFLAGS_JDKLIB += -xldscope=hidden
   CXXFLAGS_JDKLIB += -xldscope=hidden
   EXPORT_ALL_SYMBOLS := -xldscope=global
-else ifeq ($(TOOLCHAIN_TYPE), xlc)
-  ifneq ($(CC_VERSION_NUMBER), 12.1)
-    CFLAGS_JDKLIB += -qvisibility=hidden
-    CXXFLAGS_JDKLIB += -qvisibility=hidden
-    EXPORT_ALL_SYMBOLS := -qvisibility=default
-  endif
 endif
 
 # Put the libraries here.
--- a/src/hotspot/cpu/zero/stack_zero.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/cpu/zero/stack_zero.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -26,7 +26,7 @@
 #include "precompiled.hpp"
 #include "interpreter/bytecodeInterpreter.hpp"
 #include "interpreter/interpreterRuntime.hpp"
-#include "runtime/thread.hpp"
+#include "runtime/thread.inline.hpp"
 #include "stack_zero.hpp"
 #include "stack_zero.inline.hpp"
 #include "runtime/frame.inline.hpp"
--- a/src/hotspot/share/classfile/verifier.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/classfile/verifier.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -2017,8 +2017,7 @@
   if (kls != NULL) {
     current_class()->class_loader_data()->record_dependency(kls);
     if (log_is_enabled(Debug, class, resolve)) {
-      InstanceKlass* cur_class = InstanceKlass::cast(current_class());
-      Verifier::trace_class_resolution(kls, cur_class);
+      Verifier::trace_class_resolution(kls, current_class());
     }
   }
   return kls;
--- a/src/hotspot/share/code/codeCache.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/code/codeCache.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -1411,8 +1411,7 @@
     }
 
     if (heap->full_count() == 0) {
-      LogTarget(Debug, codecache) lt;
-      if (lt.is_enabled()) {
+      if (PrintCodeHeapAnalytics) {
         CompileBroker::print_heapinfo(tty, "all", "4096"); // details, may be a lot!
       }
     }
--- a/src/hotspot/share/code/codeHeapState.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/code/codeHeapState.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -38,7 +38,7 @@
 // Aggregation condenses the information of a piece of the CodeHeap
 // (4096 bytes by default) into an analysis granule. These granules
 // contain enough detail to gain initial insight while keeping the
-// internal sttructure sizes in check.
+// internal structure sizes in check.
 //
 // The CodeHeap is a living thing. Therefore, the aggregate is collected
 // under the CodeCache_lock. The subsequent print steps are only locked
@@ -63,15 +63,12 @@
 //
 // If you are (only) interested in how the CodeHeap looks like after running
 // a sample workload, you can use the command line option
-//   -Xlog:codecache=Trace
+//   -XX:+PrintCodeHeapAnalytics
+// It will cause a full analysis to be written to tty. In addition, a full
+// analysis will be written the first time a "CodeCache full" condition is
+// detected.
 //
-// To see the CodeHeap state in case of a "CodeCache full" condition, start the
-// VM with the
-//   -Xlog:codecache=Debug
-// command line option. It will produce output only for the first time the
-// condition is recognized.
-//
-// Both command line option variants produce output identical to the jcmd function
+// The command line option produces output identical to the jcmd function
 //   jcmd <pid> Compiler.CodeHeap_Analytics all 4096
 // ---------------------------------------------------------------------------------
 
--- a/src/hotspot/share/code/dependencyContext.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/code/dependencyContext.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -35,8 +35,9 @@
 PerfCounter* DependencyContext::_perf_total_buckets_deallocated_count = NULL;
 PerfCounter* DependencyContext::_perf_total_buckets_stale_count       = NULL;
 PerfCounter* DependencyContext::_perf_total_buckets_stale_acc_count   = NULL;
-nmethodBucket* volatile DependencyContext::_purge_list = NULL;
-volatile uint64_t DependencyContext::_cleaning_epoch = 0;
+nmethodBucket* volatile DependencyContext::_purge_list                = NULL;
+volatile uint64_t DependencyContext::_cleaning_epoch                  = 0;
+uint64_t  DependencyContext::_cleaning_epoch_monotonic                = 0;
 
 void dependencyContext_init() {
   DependencyContext::init();
@@ -262,7 +263,7 @@
   return Atomic::sub(1, &_count);
 }
 
-// We use a safepoint counter to track the safepoint counter the last time a given
+// We use a monotonically increasing epoch counter to track the last epoch a given
 // dependency context was cleaned. GC threads claim cleanup tasks by performing
 // a CAS on this value.
 bool DependencyContext::claim_cleanup() {
@@ -311,13 +312,15 @@
 // a purge list to be deleted later.
 void DependencyContext::cleaning_start() {
   assert(SafepointSynchronize::is_at_safepoint(), "must be");
-  uint64_t epoch = SafepointSynchronize::safepoint_counter();
+  uint64_t epoch = ++_cleaning_epoch_monotonic;
   Atomic::store(epoch, &_cleaning_epoch);
 }
 
 // The epilogue marks the end of dependency context cleanup by the GC,
-// and also makes subsequent releases of nmethodBuckets case immediate
-// deletion. It is admitted to end the cleanup in a concurrent phase.
+// and also makes subsequent releases of nmethodBuckets cause immediate
+// deletion. It is okay to delay calling of cleaning_end() to a concurrent
+// phase, subsequent to the safepoint operation in which cleaning_start()
+// was called. That allows dependency contexts to be cleaned concurrently.
 void DependencyContext::cleaning_end() {
   uint64_t epoch = 0;
   Atomic::store(epoch, &_cleaning_epoch);
--- a/src/hotspot/share/code/dependencyContext.hpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/code/dependencyContext.hpp	Wed Dec 05 15:39:04 2018 +0530
@@ -86,11 +86,12 @@
   nmethodBucket* dependencies();
   nmethodBucket* dependencies_not_unloading();
 
-  static PerfCounter* _perf_total_buckets_allocated_count;
-  static PerfCounter* _perf_total_buckets_deallocated_count;
-  static PerfCounter* _perf_total_buckets_stale_count;
-  static PerfCounter* _perf_total_buckets_stale_acc_count;
+  static PerfCounter*            _perf_total_buckets_allocated_count;
+  static PerfCounter*            _perf_total_buckets_deallocated_count;
+  static PerfCounter*            _perf_total_buckets_stale_count;
+  static PerfCounter*            _perf_total_buckets_stale_acc_count;
   static nmethodBucket* volatile _purge_list;
+  static uint64_t                _cleaning_epoch_monotonic;
   static volatile uint64_t       _cleaning_epoch;
 
  public:
--- a/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -995,13 +995,12 @@
 }
 
 bool ZBarrierSetC2::expand_barriers(Compile* C, PhaseIterGVN& igvn) const {
-  PhaseMacroExpand macro(igvn);
   ZBarrierSetC2State* s = state();
   if (s->load_barrier_count() > 0) {
+    PhaseMacroExpand macro(igvn);
 #ifdef ASSERT
     verify_gc_barriers(false);
 #endif
-    igvn.set_delay_transform(true);
     int skipped = 0;
     while (s->load_barrier_count() > skipped) {
       int load_barrier_count = s->load_barrier_count();
--- a/src/hotspot/share/interpreter/interpreterRuntime.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/interpreter/interpreterRuntime.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -728,7 +728,7 @@
   // class is initialized.  This is required so that access to the static
   // field will call the initialization function every time until the class
   // is completely initialized ala. in 2.17.5 in JVM Specification.
-  InstanceKlass* klass = InstanceKlass::cast(info.field_holder());
+  InstanceKlass* klass = info.field_holder();
   bool uninitialized_static = is_static && !klass->is_initialized();
   bool has_initialized_final_update = info.field_holder()->major_version() >= 53 &&
                                       info.has_initialized_final_update();
--- a/src/hotspot/share/interpreter/linkResolver.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/interpreter/linkResolver.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -1151,7 +1151,7 @@
     InstanceKlass* ck = InstanceKlass::cast(current_klass);
     InstanceKlass *klass_to_check = !ck->is_unsafe_anonymous() ?
                                     ck :
-                                    InstanceKlass::cast(ck->unsafe_anonymous_host());
+                                    ck->unsafe_anonymous_host();
     // Disable verification for the dynamically-generated reflection bytecodes.
     bool is_reflect = klass_to_check->is_subclass_of(
                         SystemDictionary::reflect_MagicAccessorImpl_klass());
--- a/src/hotspot/share/prims/methodHandles.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/prims/methodHandles.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -1086,8 +1086,6 @@
 }
 
 void MethodHandles::clean_dependency_context(oop call_site) {
-  assert_locked_or_safepoint(CodeCache_lock);
-
   oop context = java_lang_invoke_CallSite::context_no_keepalive(call_site);
   DependencyContext deps = java_lang_invoke_MethodHandleNatives_CallSiteContext::vmdependencies(context);
   deps.clean_unloading_dependents();
--- a/src/hotspot/share/runtime/globals.hpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/runtime/globals.hpp	Wed Dec 05 15:39:04 2018 +0530
@@ -723,6 +723,9 @@
           "Print the code cache memory usage each time a method is "        \
           "compiled")                                                       \
                                                                             \
+  diagnostic(bool, PrintCodeHeapAnalytics, false,                           \
+          "Print code heap usage statistics on exit and on full condition") \
+                                                                            \
   diagnostic(bool, PrintStubCode, false,                                    \
           "Print generated stub code")                                      \
                                                                             \
--- a/src/hotspot/share/runtime/java.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/runtime/java.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -318,8 +318,7 @@
 
   // CodeHeap State Analytics.
   // Does also call NMethodSweeper::print(tty)
-  LogTarget(Trace, codecache) lt;
-  if (lt.is_enabled()) {
+  if (PrintCodeHeapAnalytics) {
     CompileBroker::print_heapinfo(NULL, "all", "4096"); // details
   } else if (PrintMethodFlushingStatistics) {
     NMethodSweeper::print(tty);
@@ -387,8 +386,7 @@
 
   // CodeHeap State Analytics.
   // Does also call NMethodSweeper::print(tty)
-  LogTarget(Trace, codecache) lt;
-  if (lt.is_enabled()) {
+  if (PrintCodeHeapAnalytics) {
     CompileBroker::print_heapinfo(NULL, "all", "4096"); // details
   } else if (PrintMethodFlushingStatistics) {
     NMethodSweeper::print(tty);
--- a/src/hotspot/share/runtime/thread.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/hotspot/share/runtime/thread.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -3902,6 +3902,9 @@
   // may be attached late and JVMTI must track phases of VM execution
   JvmtiExport::enter_live_phase();
 
+  // Make perfmemory accessible
+  PerfMemory::set_accessible(true);
+
   // Notify JVMTI agents that VM initialization is complete - nop if no agents.
   JvmtiExport::post_vm_initialized();
 
--- a/src/java.base/share/classes/com/sun/crypto/provider/PBES2Parameters.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/java.base/share/classes/com/sun/crypto/provider/PBES2Parameters.java	Wed Dec 05 15:39:04 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -26,7 +26,6 @@
 package com.sun.crypto.provider;
 
 import java.io.*;
-import java.math.BigInteger;
 import java.security.NoSuchAlgorithmException;
 import java.security.AlgorithmParametersSpi;
 import java.security.spec.AlgorithmParameterSpec;
@@ -264,7 +263,20 @@
             throw new IOException("PBE parameter parsing error: "
                 + "not an ASN.1 SEQUENCE tag");
         }
-        kdfAlgo = parseKDF(pBES2_params.data.getDerValue());
+        DerValue kdf = pBES2_params.data.getDerValue();
+
+        // Before JDK-8202837, PBES2-params was mistakenly encoded like
+        // an AlgorithmId which is a sequence of its own OID and the real
+        // PBES2-params. If the first DerValue is an OID instead of a
+        // PBES2-KDFs (which should be a SEQUENCE), we are likely to be
+        // dealing with this buggy encoding. Skip the OID and treat the
+        // next DerValue as the real PBES2-params.
+        if (kdf.getTag() == DerValue.tag_ObjectId) {
+            pBES2_params = pBES2_params.data.getDerValue();
+            kdf = pBES2_params.data.getDerValue();
+        }
+
+        kdfAlgo = parseKDF(kdf);
 
         if (pBES2_params.tag != DerValue.tag_Sequence) {
             throw new IOException("PBE parameter parsing error: "
--- a/src/java.base/share/classes/java/lang/VersionProps.java.template	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/java.base/share/classes/java/lang/VersionProps.java.template	Wed Dec 05 15:39:04 2018 +0530
@@ -51,6 +51,9 @@
     private static final String VERSION_NUMBER =
         "@@VERSION_NUMBER@@";
 
+    private static final String VERSION_SPECIFICATION =
+        "@@VERSION_SPECIFICATION@@";
+
     private static final String VERSION_BUILD =
         "@@VERSION_BUILD@@";
 
@@ -97,7 +100,7 @@
 
         props.setProperty("java.class.version", CLASSFILE_MAJOR_MINOR);
 
-        props.setProperty("java.specification.version", VERSION_NUMBER);
+        props.setProperty("java.specification.version", VERSION_SPECIFICATION);
         props.setProperty("java.specification.name", "Java Platform API Specification");
         props.setProperty("java.specification.vendor", "Oracle Corporation");
 
--- a/src/java.base/share/classes/jdk/internal/org/xml/sax/DTDHandler.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/java.base/share/classes/jdk/internal/org/xml/sax/DTDHandler.java	Wed Dec 05 15:39:04 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -73,7 +73,6 @@
  */
 public interface DTDHandler {
 
-
     /**
      * Receive notification of a notation declaration event.
      *
@@ -136,6 +135,39 @@
                                              String notationName)
         throws SAXException;
 
+    // from SAX2 extension DeclHandler
+    /**
+     * Receive notification of the start of DTD declarations.
+     *
+     * The start/endDTD events appear within the start/endDocument events
+     * from ContentHandler.
+     *
+     * @param name The document type name.
+     * @param publicId The declared public identifier for the
+     *        external DTD subset, or null if none was declared.
+     * @param systemId The declared system identifier for the
+     *        external DTD subset, or null if none was declared.
+     *        (Note that this is not resolved against the document
+     *        base URI.)
+     * @throws SAXException the event receiver may throw an exception during processing
+     */
+    default public void startDTD (String name, String publicId, String systemId)
+        throws SAXException
+    {
+        // no op
+    }
+
+    // Custom API for the Properties
+
+    /**
+     * Receive notification of the start of DTD internal subset.
+     *
+     * @throws SAXException the event receiver may throw an exception during processing
+     */
+    default public void startInternalSub () throws SAXException
+    {
+        // no op
+    }
 }
 
 // end of DTDHandler.java
--- a/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/java.base/share/classes/jdk/internal/util/xml/PropertiesDefaultHandler.java	Wed Dec 05 15:39:04 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -54,11 +54,11 @@
     private static final String ATTR_KEY = "key";
     // The required DTD URI for exported properties
     private static final String PROPS_DTD_DECL =
-            "<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">";
+        "<!DOCTYPE properties SYSTEM \"http://java.sun.com/dtd/properties.dtd\">";
     private static final String PROPS_DTD_URI =
-            "http://java.sun.com/dtd/properties.dtd";
+        "http://java.sun.com/dtd/properties.dtd";
     private static final String PROPS_DTD =
-            "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+        "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
             + "<!-- DTD for properties -->"
             + "<!ELEMENT properties ( comment?, entry* ) >"
             + "<!ATTLIST properties"
@@ -136,15 +136,15 @@
     ////////////////////////////////////////////////////////////////////
     // Validate while parsing
     ////////////////////////////////////////////////////////////////////
-    static final String ALLOWED_ELEMENTS = "properties, comment, entry";
+    static final String ALLOWED_ELEMENTS = "comment, entry";
     static final String ALLOWED_COMMENT = "comment";
     ////////////////////////////////////////////////////////////////////
     // Handler methods
     ////////////////////////////////////////////////////////////////////
-    StringBuffer buf = new StringBuffer();
+    StringBuilder buf = new StringBuilder();
+    boolean sawRoot = false; // whether a valid root element exists
     boolean sawComment = false;
     boolean validEntry = false;
-    int rootElem = 0;
     String key;
     String rootElm;
 
@@ -152,32 +152,38 @@
     public void startElement(String uri, String localName, String qName, Attributes attributes)
         throws SAXException
     {
-        if (rootElem < 2) {
-            rootElem++;
+        if (sawRoot) {
+            if (!ALLOWED_ELEMENTS.contains(qName)) {
+                fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
+            }
+        } else {
+            // check whether the root has been declared in the DTD
+            if (rootElm == null) {
+                fatalError(new SAXParseException("An XML properties document must contain"
+                    + " the DOCTYPE declaration as defined by java.util.Properties.", null));
+            }
+
+            // check whether the element name matches the declaration
+            if (!rootElm.equals(qName)) {
+                fatalError(new SAXParseException("Document root element \"" + qName
+                    + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
+            }
+
+            // this is a valid root element
+            sawRoot = true;
         }
 
-        if (rootElm == null) {
-            fatalError(new SAXParseException("An XML properties document must contain"
-                    + " the DOCTYPE declaration as defined by java.util.Properties.", null));
-        }
-
-        if (rootElem == 1 && !rootElm.equals(qName)) {
-            fatalError(new SAXParseException("Document root element \"" + qName
-                    + "\", must match DOCTYPE root \"" + rootElm + "\"", null));
-        }
-        if (!ALLOWED_ELEMENTS.contains(qName)) {
-            fatalError(new SAXParseException("Element type \"" + qName + "\" must be declared.", null));
-        }
         if (qName.equals(ELEMENT_ENTRY)) {
             validEntry = true;
             key = attributes.getValue(ATTR_KEY);
             if (key == null) {
-                fatalError(new SAXParseException("Attribute \"key\" is required and must be specified for element type \"entry\"", null));
+                fatalError(new SAXParseException("Attribute \"key\" is required and " +
+                    "must be specified for element type \"entry\"", null));
             }
         } else if (qName.equals(ALLOWED_COMMENT)) {
             if (sawComment) {
                 fatalError(new SAXParseException("Only one comment element may be allowed. "
-                        + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
+                    + "The content of element type \"properties\" must match \"(comment?,entry*)\"", null));
             }
             sawComment = true;
         }
@@ -192,8 +198,9 @@
 
     @Override
     public void endElement(String uri, String localName, String qName) throws SAXException {
-        if (!ALLOWED_ELEMENTS.contains(qName)) {
-            fatalError(new SAXParseException("Element: " + qName + " is invalid, must match  \"(comment?,entry*)\".", null));
+        if (!ALLOWED_ELEMENTS.contains(qName) && !ELEMENT_ROOT.equals(qName)) {
+            fatalError(new SAXParseException("Element: " + qName +
+                " is invalid, must match  \"(comment?,entry*)\".", null));
         }
 
         if (validEntry) {
@@ -204,19 +211,12 @@
     }
 
     @Override
-    public void notationDecl(String name, String publicId, String systemId) throws SAXException {
-        rootElm = name;
-    }
-
-    @Override
     public InputSource resolveEntity(String pubid, String sysid)
-            throws SAXException, IOException {
+        throws SAXException, IOException {
         {
             if (sysid.equals(PROPS_DTD_URI)) {
-                InputSource is;
-                is = new InputSource(new StringReader(PROPS_DTD));
-                is.setSystemId(PROPS_DTD_URI);
-                return is;
+                // The properties DTD is known to the handler, no need to parse it
+                return null;
             }
             throw new SAXException("Invalid system identifier: " + sysid);
         }
@@ -236,4 +236,24 @@
     public void warning(SAXParseException x) throws SAXException {
         throw x;
     }
+
+    // SAX2 extension from DTDHandler
+
+    @Override
+    public void startDTD (String name, String publicId, String systemId) throws SAXException
+    {
+        if (!ELEMENT_ROOT.equals(name) || !PROPS_DTD_URI.equals(systemId)) {
+            fatalError(new SAXParseException("An XML properties document must contain"
+                + " the DOCTYPE declaration as defined by java.util.Properties.", null));
+        }
+        rootElm = name;
+    }
+
+    @Override
+    public void startInternalSub () throws SAXException
+    {
+        fatalError(new SAXParseException("Internal DTD subset is not allowed. " +
+            "The Properties XML document must have the following DOCTYPE declaration: \n" +
+            PROPS_DTD_DECL, null));
+    }
 }
--- a/src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/java.base/share/classes/jdk/internal/util/xml/impl/Parser.java	Wed Dec 05 15:39:04 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -650,6 +650,8 @@
      * @exception IOException
      */
     private void dtdsub() throws Exception {
+        startInternalSub(); // reports the event before parsing the subset
+
         char ch;
         for (short st = 0; st >= 0;) {
             ch = getch();
@@ -2231,6 +2233,13 @@
             throws SAXException;
 
     /**
+     * Reports the start of DTD internal subset.
+     *
+     * @throws SAXException if the receiver throws SAXException
+     */
+    public abstract void startInternalSub () throws SAXException;
+
+    /**
      * Reports a comment.
      *
      * @param text The comment text starting from first charcater.
--- a/src/java.base/share/classes/jdk/internal/util/xml/impl/ParserSAX.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/java.base/share/classes/jdk/internal/util/xml/impl/ParserSAX.java	Wed Dec 05 15:39:04 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -551,7 +551,16 @@
      * @param sysid The system identifier of the entity or <code>null</code>.
      */
     protected void docType(String name, String pubid, String sysid) throws SAXException {
-        mHandDtd.notationDecl(name, pubid, sysid);
+        mHandDtd.startDTD(name, pubid, sysid);
+    }
+
+    /**
+     * Reports the start of DTD internal subset.
+     *
+     * @throws SAXException if the receiver throws SAXException
+     */
+    public void startInternalSub () throws SAXException {
+        mHandDtd.startInternalSub();
     }
 
     /**
--- a/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/jdk.attach/aix/classes/sun/tools/attach/VirtualMachineImpl.java	Wed Dec 05 15:39:04 2018 +0530
@@ -268,6 +268,7 @@
         String path = "/proc/" + pid + "/cwd/" + fn;
         File f = new File(path);
         try {
+            f = f.getCanonicalFile();
             f.createNewFile();
         } catch (IOException x) {
             f = new File(tmpdir, fn);
--- a/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/jdk.attach/linux/classes/sun/tools/attach/VirtualMachineImpl.java	Wed Dec 05 15:39:04 2018 +0530
@@ -283,6 +283,7 @@
         String path = "/proc/" + pid + "/cwd/" + fn;
         File f = new File(path);
         try {
+            f = f.getCanonicalFile();
             f.createNewFile();
         } catch (IOException x) {
             String root;
@@ -295,6 +296,7 @@
                 root = tmpdir;
             }
             f = new File(root, fn);
+            f = f.getCanonicalFile();
             f.createNewFile();
         }
         return f;
--- a/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/jdk.attach/solaris/classes/sun/tools/attach/VirtualMachineImpl.java	Wed Dec 05 15:39:04 2018 +0530
@@ -234,6 +234,7 @@
         String path = "/proc/" + pid + "/cwd/" + fn;
         File f = new File(path);
         try {
+            f = f.getCanonicalFile();
             f.createNewFile();
         } catch (IOException x) {
             f = new File(tmpdir, fn);
--- a/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/jdk.jdwp.agent/share/native/libjdwp/debugInit.c	Wed Dec 05 15:39:04 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -647,7 +647,7 @@
         (void)snprintf(buf, sizeof(buf), "JDWP %s, jvmtiError=%s(%d)",
                     msg, jvmtiErrorText(error), error);
     } else {
-        (void)snprintf(buf, sizeof(buf), "JDWP %s", buf);
+        (void)snprintf(buf, sizeof(buf), "JDWP %s", msg);
     }
     if (env != NULL) {
         (*((*env)->FatalError))(env, buf);
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/SystemModulesPlugin.java	Wed Dec 05 15:39:04 2018 +0530
@@ -52,6 +52,7 @@
 import java.util.Objects;
 import java.util.Optional;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.function.IntSupplier;
 import java.util.function.Supplier;
@@ -925,7 +926,7 @@
             mv.visitTypeInsn(ANEWARRAY, "java/util/Map$Entry");
 
             int index = 0;
-            for (Map.Entry<String, Set<String>> e : map.entrySet()) {
+            for (var e : new TreeMap<>(map).entrySet()) {
                 String name = e.getKey();
                 Set<String> s = e.getValue();
 
@@ -971,7 +972,7 @@
                 pushInt(mv, size);
                 mv.visitTypeInsn(ANEWARRAY, "java/lang/String");
                 int i = 0;
-                for (String element : set) {
+                for (String element : sorted(set)) {
                     mv.visitInsn(DUP);
                     pushInt(mv, i);
                     mv.visitLdcInsn(element);
@@ -985,7 +986,7 @@
                         true);
             } else {
                 StringBuilder sb = new StringBuilder("(");
-                for (String element : set) {
+                for (String element : sorted(set)) {
                     mv.visitLdcInsn(element);
                     sb.append("Ljava/lang/Object;");
                 }
@@ -1146,7 +1147,7 @@
                 pushInt(mv, requires.size());
                 mv.visitTypeInsn(ANEWARRAY, "java/lang/module/ModuleDescriptor$Requires");
                 int arrayIndex = 0;
-                for (Requires require : requires) {
+                for (Requires require : sorted(requires)) {
                     String compiledVersion = null;
                     if (require.compiledVersion().isPresent()) {
                         compiledVersion = require.compiledVersion().get().toString();
@@ -1192,7 +1193,7 @@
                 pushInt(mv, exports.size());
                 mv.visitTypeInsn(ANEWARRAY, "java/lang/module/ModuleDescriptor$Exports");
                 int arrayIndex = 0;
-                for (Exports export : exports) {
+                for (Exports export : sorted(exports)) {
                     mv.visitInsn(DUP);    // arrayref
                     pushInt(mv, arrayIndex++);
                     newExports(export.modifiers(), export.source(), export.targets());
@@ -1245,7 +1246,7 @@
                 pushInt(mv, opens.size());
                 mv.visitTypeInsn(ANEWARRAY, "java/lang/module/ModuleDescriptor$Opens");
                 int arrayIndex = 0;
-                for (Opens open : opens) {
+                for (Opens open : sorted(opens)) {
                     mv.visitInsn(DUP);    // arrayref
                     pushInt(mv, arrayIndex++);
                     newOpens(open.modifiers(), open.source(), open.targets());
@@ -1310,7 +1311,7 @@
                 pushInt(mv, provides.size());
                 mv.visitTypeInsn(ANEWARRAY, "java/lang/module/ModuleDescriptor$Provides");
                 int arrayIndex = 0;
-                for (Provides provide : provides) {
+                for (Provides provide : sorted(provides)) {
                     mv.visitInsn(DUP);    // arrayref
                     pushInt(mv, arrayIndex++);
                     newProvides(provide.service(), provide.providers());
@@ -1420,6 +1421,8 @@
                 // Invoke ModuleHashes.Builder::hashForModule
                 recordedHashes
                     .names()
+                    .stream()
+                    .sorted()
                     .forEach(mn -> hashForModule(mn, recordedHashes.hashFor(mn)));
 
                 // Put ModuleHashes into the hashes array
@@ -1600,7 +1603,7 @@
          * it will reuse defaultVarIndex.  For a Set with multiple references,
          * it will use a new local variable retrieved from the nextLocalVar
          */
-        class SetBuilder<T> {
+        class SetBuilder<T extends Comparable<T>> {
             private final Set<T> elements;
             private final int defaultVarIndex;
             private final IntSupplier nextLocalVar;
@@ -1660,7 +1663,7 @@
                 if (elements.size() <= 10) {
                     // call Set.of(e1, e2, ...)
                     StringBuilder sb = new StringBuilder("(");
-                    for (T t : elements) {
+                    for (T t : sorted(elements)) {
                         sb.append("Ljava/lang/Object;");
                         visitElement(t, mv);
                     }
@@ -1672,7 +1675,7 @@
                     pushInt(mv, elements.size());
                     mv.visitTypeInsn(ANEWARRAY, "java/lang/String");
                     int arrayIndex = 0;
-                    for (T t : elements) {
+                    for (T t : sorted(elements)) {
                         mv.visitInsn(DUP);    // arrayref
                         pushInt(mv, arrayIndex);
                         visitElement(t, mv);  // value
@@ -1690,7 +1693,7 @@
          * Generates bytecode to create one single instance of EnumSet
          * for a given set of modifiers and assign to a local variable slot.
          */
-        class EnumSetBuilder<T> extends SetBuilder<T> {
+        class EnumSetBuilder<T extends Comparable<T>> extends SetBuilder<T> {
 
             private final String className;
 
@@ -1788,7 +1791,7 @@
         mv.visitTypeInsn(ANEWARRAY, "java/lang/String");
 
         int index = 0;
-        for (String moduleName : map.keySet()) {
+        for (String moduleName : sorted(map.keySet())) {
             mv.visitInsn(DUP);                  // arrayref
             pushInt(mv, index);
             mv.visitLdcInsn(moduleName);
@@ -1811,7 +1814,7 @@
         mv.visitTypeInsn(ANEWARRAY, "java/lang/String");
 
         index = 0;
-        for (String className : map.values()) {
+        for (String className : sorted(map.values())) {
             mv.visitInsn(DUP);                  // arrayref
             pushInt(mv, index);
             mv.visitLdcInsn(className.replace('/', '.'));
@@ -1832,6 +1835,19 @@
     }
 
     /**
+     * Returns a sorted copy of a collection.
+     *
+     * This is useful to ensure a deterministic iteration order.
+     *
+     * @return a sorted copy of the given collection.
+     */
+    private static <T extends Comparable<T>> List<T> sorted(Collection<T> c) {
+        var l = new ArrayList<T>(c);
+        Collections.sort(l);
+        return l;
+    }
+
+    /**
      * Pushes an int constant
      */
     private static void pushInt(MethodVisitor mv, int value) {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretbase.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretbase.java	Wed Dec 05 15:39:04 2018 +0530
@@ -54,8 +54,7 @@
         }
     }
 
-    native static int doForceEarlyReturn(Class targCls,
-                          Thread earlyretThr, long valToRet);
+    native static int doForceEarlyReturn(Thread earlyretThr, long valToRet);
     native static int suspThread(earlyretThread earlyretThr);
     native static int resThread(earlyretThread earlyretThr);
     native static int check();
@@ -96,8 +95,7 @@
         out.println("Forcing early return...");
 
         // force return from a top frame of the child thread
-        retCode = doForceEarlyReturn(earlyretThread.class,
-                                     earlyretThr, JAVA_BIRTH_YEAR);
+        retCode = doForceEarlyReturn(earlyretThr, JAVA_BIRTH_YEAR);
         earlyretDone = true;
         earlyretThr.letItGo();
         if (retCode != Consts.TEST_PASSED) {
--- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretbase/earlyretbase.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/unit/ForceEarlyReturn/earlyretbase/earlyretbase.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -78,22 +78,29 @@
 JNIEXPORT jint JNICALL
 Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretbase_suspThread(JNIEnv *env,
         jclass cls, jobject earlyretThr) {
-    jvmtiError err;
 
     if (!caps.can_force_early_return || !caps.can_suspend) {
         return PASSED;
     }
 
-    printf(">>>>>>>> Invoke SuspendThread()\n");
-    err = jvmti->SuspendThread(earlyretThr);
-    if (err != JVMTI_ERROR_NONE) {
-        printf("%s: Failed to call SuspendThread(): error=%d: %s\n",
-            __FILE__, err, TranslateError(err));
-        return JNI_ERR;
+    jclass clazz = env->GetObjectClass(earlyretThr);
+    if (clazz == NULL) {
+        printf("Cannot get class of thread object\n");
+        RETURN_FAILED;
     }
-    printf("<<<<<<<< SuspendThread() is successfully done\n");
-    fflush(0);
-    return PASSED;
+
+    midActiveMethod = env->GetMethodID(clazz, name_exp, sig_exp);
+    if (midActiveMethod == NULL) {
+        printf("Cannot find Method ID for method %s\n", name_exp);
+        RETURN_FAILED;
+    }
+
+    int result = suspendThreadAtMethod(jvmti, cls, earlyretThr, midActiveMethod);
+    if( result == NSK_TRUE) {
+        return PASSED;
+    } else {
+        RETURN_FAILED;
+    }
 }
 
 JNIEXPORT jint JNICALL
@@ -119,7 +126,7 @@
 
 JNIEXPORT jint JNICALL
 Java_nsk_jvmti_unit_ForceEarlyReturn_earlyretbase_doForceEarlyReturn(JNIEnv *env,
-        jclass cls, jclass targCls, jthread earlyretThr, jlong valToRet) {
+        jclass cls, jthread earlyretThr, jlong valToRet) {
     jvmtiError err;
 
     if (!caps.can_force_early_return || !caps.can_suspend) {
@@ -160,14 +167,6 @@
     }
     printf(">>>>>>>> Invoke ForceEarlyReturn()\n");
 
-    printf("Before call to GetMethodID(%s, %s)\n", name_exp, sig_exp);
-    midActiveMethod = env->GetMethodID(targCls, name_exp, sig_exp);
-    if (midActiveMethod == NULL) {
-        printf("Cannot find Method ID for method %s\n", name_exp);
-        RETURN_FAILED;
-    }
-    printf("After call to GetMethodID(%s, %s)\n", name_exp, sig_exp);
-
     err = jvmti->ForceEarlyReturnLong(earlyretThr, valToRet);
     if (err != JVMTI_ERROR_NONE) {
         printf("TEST FAILED: the function ForceEarlyReturn()"
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.cpp	Wed Dec 05 15:39:04 2018 +0530
@@ -633,6 +633,69 @@
     return 1;
 }
 
+#define SLEEP_DELAY 10L
+
+int suspendThreadAtMethod(jvmtiEnv *jvmti, jclass cls, jobject thread, jmethodID testMethod) {
+    printf(">>>>>>>> Invoke SuspendThread()\n");
+
+    jvmtiError err = jvmti->SuspendThread(thread);
+    if (err != JVMTI_ERROR_NONE) {
+        printf("%s: Failed to call SuspendThread(): error=%d: %s\n",
+               __FILE__, err, TranslateError(err));
+        return NSK_FALSE;
+    }
+
+    int result = NSK_TRUE;
+    jmethodID method = NULL;
+    jlocation loc;
+
+    // We need to ensure that the thread is suspended at the right place when the top
+    // frame belongs to the test rather than to incidental Java code (classloading,
+    // JVMCI, etc). Below we do resume/suspend in the loop until the target method
+    // is executed in the top frame or the loop counter exceeds the limit.
+    for (int i = 0; i < 10; i++) {
+        err = jvmti->GetFrameLocation(thread, 0, &method, &loc);
+        if (err != JVMTI_ERROR_NONE) {
+            printf("(GetFrameLocation) unexpected error: %s (%d)\n",
+                   TranslateError(err), err);
+            result = NSK_FALSE;
+            break;
+        }
+
+        char *name, *sig, *generic;
+        jvmti->GetMethodName(method, &name, &sig, &generic);
+        printf(">>> Attempt %d to suspend the thread. Top frame: \"%s%s\"\n",
+               i, name, sig);
+        if (method == testMethod) break;
+
+        err = jvmti->ResumeThread(thread);
+        if (err != JVMTI_ERROR_NONE) {
+            printf("(ResumeThread) unexpected error: %s (%d)\n",
+                   TranslateError(err), err);
+            result = NSK_FALSE;
+        }
+
+        mssleep(SLEEP_DELAY);
+
+        err = jvmti->SuspendThread(thread);
+        if (err != JVMTI_ERROR_NONE) {
+            printf("(SuspendThread) unexpected error: %s (%d)\n",
+                   TranslateError(err), err);
+            result = NSK_FALSE;
+        }
+    }
+    if(method == testMethod) {
+        printf("<<<<<<<< SuspendThread() is successfully done\n");
+    } else {
+        char *name, *sig, *generic;
+        jvmti->GetMethodName(testMethod, &name, &sig, &generic);
+        printf("Failed in the suspendThread: was not able to suspend thread "
+               "with required method \"%s%s\" on the top\n", name, sig);
+        result = NSK_FALSE;
+    }
+    return result;
+}
+
 jint createRawMonitor(jvmtiEnv *env, const char *name, jrawMonitorID *monitor) {
     jvmtiError error = env->CreateRawMonitor(name, monitor);
     if (!NSK_JVMTI_VERIFY(error)) {
--- a/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.h	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/hotspot/jtreg/vmTestbase/nsk/share/jvmti/jvmti_tools.h	Wed Dec 05 15:39:04 2018 +0530
@@ -371,6 +371,12 @@
 
 int isThreadExpected(jvmtiEnv *jvmti, jthread thread);
 
+/**
+* This method makes the thread to be suspended at the right place when the top frame
+* belongs to the test rather than to incidental Java code (classloading, JVMCI, etc).
+*/
+int suspendThreadAtMethod(jvmtiEnv *jvmti, jclass cls, jobject thread, jmethodID method);
+
 jint createRawMonitor(jvmtiEnv *env, const char *name, jrawMonitorID *monitor);
 
 void exitOnError(jvmtiError error);
--- a/test/jaxp/javax/xml/jaxp/unittest/transform/CR6551600Test.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jaxp/javax/xml/jaxp/unittest/transform/CR6551600Test.java	Wed Dec 05 15:39:04 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 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
@@ -23,10 +23,11 @@
 
 package transform;
 
-import static jaxp.library.JAXPTestUtilities.getSystemProperty;
-
 import java.io.File;
 import java.io.FilePermission;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
@@ -35,17 +36,18 @@
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
-import jaxp.library.JAXPTestUtilities;
-
 import org.testng.Assert;
 import org.testng.annotations.Listeners;
 import org.testng.annotations.Test;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
+import jaxp.library.JAXPTestUtilities;
+
 /*
  * @test
  * @bug 6551600
+ * @requires os.family == "windows"
  * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest
  * @run testng/othervm -DrunSecMngr=true transform.CR6551600Test
  * @run testng/othervm transform.CR6551600Test
@@ -56,17 +58,22 @@
 
     @Test
     public final void testUNCPath() {
-        boolean isWindows = getSystemProperty("os.name").contains("Windows");
+        var hostName = "";
+        try {
+            hostName = java.net.InetAddress.getLocalHost().getHostName();
+        } catch (java.net.UnknownHostException e) {
+            // falls through
+        }
+
+        var uncPath = "\\\\" + hostName + "\\C$\\temp\\";
+
+        if (!checkAccess(uncPath)) {
+            System.out.println("Cannot access UNC path. Test exits.");
+            return;
+        }
+
+        var uncFilePath = uncPath + "xslt_unc_test.xml";
         JAXPTestUtilities.runWithTmpPermission(() -> {
-            String hostName = "";
-            try {
-                hostName = java.net.InetAddress.getLocalHost().getHostName();
-            } catch (java.net.UnknownHostException e) {
-                // falls through
-            }
-
-            String path = isWindows ? "\\\\" + hostName + "\\C$\\xslt_unc_test.xml" : "///tmp/test.xml";
-
             try {
                 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                 DocumentBuilder builder = factory.newDocumentBuilder();
@@ -75,7 +82,7 @@
                 doc.appendChild(root);
                 // create an identity transform
                 Transformer t = TransformerFactory.newInstance().newTransformer();
-                File f = new File(path);
+                File f = new File(uncFilePath);
                 StreamResult result = new StreamResult(f);
                 DOMSource source = new DOMSource(doc);
                 System.out.println("Writing to " + f);
@@ -86,11 +93,24 @@
                 Assert.fail(e.toString());
             }
 
-            File file = new File(path);
+            File file = new File(uncFilePath);
             if (file.exists()) {
                 file.deleteOnExit();
             }
-        }, isWindows ? new FilePermission("//localhost/C$/xslt_unc_test.xml", "read,write,delete")
-                : new FilePermission("///tmp/test.xml", "read,write,delete"));
+        }, new FilePermission(uncFilePath, "read,write,delete"));
+    }
+
+    private boolean checkAccess(String path) {
+        return JAXPTestUtilities.runWithTmpPermission(() -> {
+            try {
+                Path tmepFile = Files.createTempFile(Paths.get(path), "test", "6551600");
+                Files.deleteIfExists(tmepFile);
+                return true;
+            } catch (Exception e) {
+                System.out.println("Access check failed.");
+                e.printStackTrace();
+                return false;
+            }
+        }, new FilePermission(path + "*", "read,write,delete"));
     }
 }
--- a/test/jdk/java/lang/ProcessBuilder/Basic.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/lang/ProcessBuilder/Basic.java	Wed Dec 05 15:39:04 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -2084,7 +2084,7 @@
 
         //----------------------------------------------------------------
         // Check that reads which are pending when Process.destroy is
-        // called, get EOF, not IOException("Stream closed").
+        // called, get EOF, or IOException("Stream closed").
         //----------------------------------------------------------------
         try {
             final int cases = 4;
@@ -2112,6 +2112,11 @@
                                 default: throw new Error();
                             }
                             equal(-1, r);
+                        } catch (IOException ioe) {
+                            if (!ioe.getMessage().equals("Stream closed")) {
+                                // BufferedInputStream may throw IOE("Stream closed").
+                                unexpected(ioe);
+                            }
                         } catch (Throwable t) { unexpected(t); }}};
 
                 thread.start();
--- a/test/jdk/java/lang/ref/ReachabilityFenceTest.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/lang/ref/ReachabilityFenceTest.java	Wed Dec 05 15:39:04 2018 +0530
@@ -25,6 +25,8 @@
  * @bug 8133348
  * @summary Tests if reachabilityFence is working
  *
+ * @requires vm.opt.DeoptimizeALot != true
+ *
  * @run main/othervm -Xint                   -Dpremature=false ReachabilityFenceTest
  * @run main/othervm -XX:TieredStopAtLevel=1 -Dpremature=true  ReachabilityFenceTest
  * @run main/othervm -XX:TieredStopAtLevel=2 -Dpremature=true  ReachabilityFenceTest
@@ -142,4 +144,4 @@
             finalized.set(true);
         }
     }
-}
\ No newline at end of file
+}
--- a/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/time/test/java/time/format/TestNonIsoFormatter.java	Wed Dec 05 15:39:04 2018 +0530
@@ -191,7 +191,7 @@
         String mdStr = "-01-01";
         DateTimeFormatter dtf = new DateTimeFormatterBuilder()
             .appendPattern("GGGG y-M-d")
-            .toFormatter()
+            .toFormatter(Locale.ROOT)
             .withChronology(chrono);
         DateTimeFormatter dtfLenient = dtf.withResolverStyle(ResolverStyle.LENIENT);
         assertEquals(LocalDate.parse(lenient+mdStr, dtfLenient), LocalDate.parse(strict+mdStr, dtf));
--- a/test/jdk/java/util/Properties/Compatibility.xml	Tue Dec 04 13:35:04 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="no"?>
-<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd" 
- [<!ENTITY intEnt 'value3'> ]>
-<?PITarget PIContent?>
-<properties>
-<comment>Property With Other Encoding</comment>
-<entry key="Key1">value1</entry>
-<entry key="Key2"><![CDATA[<value2>]]></entry>
-<entry key="Key3">&intEnt;</entry>
-</properties>
--- a/test/jdk/java/util/Properties/CompatibilityTest.java	Tue Dec 04 13:35:04 2018 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
- * Copyright (c) 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 8005280 8004371
- * @summary Compatibility test
- */
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.Properties;
-
-/**
- * This is a behavior compatibility test.
- * Although not defined by the properties.dtd, the constructs
- * in Compatibility.xml are supported by the regular JDK XML
- * Provider.
- *
- * @author: Joe Wang
- */
-public class CompatibilityTest {
-
-    public static void main(String[] args) {
-        testInternalDTD();
-    }
-
-    /*
-     * Not in the spec, but the constructs work with the current JDK
-     */
-    static void testInternalDTD() {
-        String src = System.getProperty("test.src");
-        if (src == null) {
-            src = ".";
-        }
-        loadPropertyFile(src + "/Compatibility.xml");
-    }
-
-    /*
-     * 'Store' the populated 'Property' with the specified 'Encoding Type' as an
-     * XML file. Retrieve the same XML file and 'load' onto a new 'Property' object.
-     */
-    static void loadPropertyFile(String filename) {
-        try (InputStream in = new FileInputStream(filename)) {
-            Properties prop = new Properties();
-            prop.loadFromXML(in);
-            verifyProperites(prop);
-        } catch (IOException ex) {
-            fail(ex.getMessage());
-        }
-    }
-
-    /*
-     * This method verifies the first key-value with the original string.
-     */
-    static void verifyProperites(Properties prop) {
-        try {
-            for (String key : prop.stringPropertyNames()) {
-                String val = prop.getProperty(key);
-                if (key.equals("Key1")) {
-                    if (!val.equals("value1")) {
-                        fail("Key:" + key + "'s value: \nExpected: value1\nFound: " + val);
-                    }
-                } else if (key.equals("Key2")) {
-                    if (!val.equals("<value2>")) {
-                        fail("Key:" + key + "'s value: \nExpected: <value2>\nFound: " + val);
-                    }
-                } else if (key.equals("Key3")) {
-                    if (!val.equals("value3")) {
-                        fail("Key:" + key + "'s value: \nExpected: value3\nFound: " + val);
-                    }
-                }
-            }
-        } catch (Exception e) {
-            fail(e.getMessage());
-        }
-
-    }
-
-    static void fail(String err) {
-        throw new RuntimeException(err);
-    }
-
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/Properties/invalidxml/IllegalElement.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf8" standalone="no"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+
+<!-- The dtd requires a properties root, but not element -->
+
+<properties>
+<comment>comment</comment>
+    <properties>
+        <entry key="firstKey">value of the first key</entry>
+    </properties>
+</properties>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/Properties/invalidxml/invalidDTD.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd" 
+ [<!ENTITY intEnt 'value3'> ]>
+<?PITarget PIContent?>
+<properties>
+<comment>Property With Other Encoding</comment>
+<entry key="Key1">value1</entry>
+<entry key="Key2"><![CDATA[<value2>]]></entry>
+<entry key="Key3">&intEnt;</entry>
+</properties>
--- a/test/jdk/java/util/ResourceBundle/Control/XmlRB.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/Control/XmlRB.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -2,15 +2,7 @@
 
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for XMLResourceBundleTest.java</comment>
     <entry key="type">XML</entry>
--- a/test/jdk/java/util/ResourceBundle/Control/XmlRB_ja.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/Control/XmlRB_ja.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -2,15 +2,7 @@
 
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for XMLResourceBundleTest.java</comment>
     <entry key="type">XML</entry>
--- a/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -2,15 +2,7 @@
 
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for ResourceBundle</comment>
     <entry key="key">root: message</entry>
--- a/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_de.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_de.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -2,15 +2,7 @@
 
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for ResourceBundle</comment>
     <entry key="key">de: message</entry>
--- a/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_en.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_en.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -2,15 +2,7 @@
 
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for ResourceBundle</comment>
     <entry key="key">en: message</entry>
--- a/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_fr.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_fr.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -2,15 +2,7 @@
 
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for ResourceBundle</comment>
     <entry key="key">fr: message</entry>
--- a/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_ja.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_ja.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -2,15 +2,7 @@
 
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for ResourceBundle in named modules.</comment>
     <entry key="key">ja: message</entry>
--- a/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_zh.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_zh.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -2,15 +2,7 @@
 
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for ResourceBundle in named modules.</comment>
     <entry key="key">zh: message</entry>
--- a/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_zh_TW.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/ResourceBundle/modules/basic/srcXml/bundles/jdk/test/resources/MyResources_zh_TW.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -2,15 +2,7 @@
 
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for ResourceBundle in named modules.</comment>
     <entry key="key">zh-TW: message</entry>
--- a/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -23,15 +23,7 @@
 -->
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for UserDefaultControlTest.java</comment>
     <entry key="type">XML</entry>
--- a/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB_ja.xml	Tue Dec 04 13:35:04 2018 +0530
+++ b/test/jdk/java/util/spi/ResourceBundleControlProvider/com/foo/XmlRB_ja.xml	Wed Dec 05 15:39:04 2018 +0530
@@ -23,15 +23,7 @@
 -->
 <!---->
 
-<!-- DTD for properties -->
-<!DOCTYPE properties [
-<!ELEMENT properties ( comment?, entry* ) >
-<!ATTLIST properties version CDATA #FIXED "1.0">
-<!ELEMENT comment (#PCDATA) >
-<!ELEMENT entry (#PCDATA) >
-<!ATTLIST entry key CDATA #REQUIRED>
-]>
-
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
 <properties>
     <comment>Test data for UserDefaultControlTest.java</comment>
     <entry key="type">XML</entry>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/sun/security/pkcs12/WrongPBES2.java	Wed Dec 05 15:39:04 2018 +0530
@@ -0,0 +1,159 @@
+/*
+ * Copyright (c) 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 8214513
+ * @summary A PKCS12 keystore from Java 8 using custom PBE parameters cannot be read in Java 11
+ */
+
+import javax.crypto.spec.PBEParameterSpec;
+import java.io.*;
+import java.security.KeyStore;
+import java.security.PrivateKey;
+import java.security.cert.Certificate;
+
+public class WrongPBES2 {
+
+    private static final char[] PASS = "changeit".toCharArray();
+
+    // This is a PKCS 12 file using PBES2 with an incorrect encoding before
+    // JDK-8202837 is fixed. It is generated with these 2 commands:
+    //
+    // keytool -genkeypair -alias a -dname CN=A -keystore ks -storepass changeit
+    // $JDK10/bin/java WrongPBES2 reenc
+    static final String P12_FILE =
+            "308208940201033082084d06092a864886f70d010701a082083e0482083a3082" +
+            "08363082035206092a864886f70d010701a08203430482033f3082033b308203" +
+            "37060b2a864886f70d010c0a0102a08202ee308202ea307406092a864886f70d" +
+            "01050d306706092a864886f70d01050d305a303906092a864886f70d01050c30" +
+            "2c0414000000000000000000000000000000000000000002030186a002012030" +
+            "0c06082a864886f70d020b0500301d060960864801650304012a04105abc352d" +
+            "35d98fd77d8c8cf205d690c6048202703ff97bd4488a6a5569993fb6f89792e7" +
+            "33632b20fdc502bf0801c8ee80683d064c4dae5b8880ade893a87bfdb4427dfd" +
+            "01bc5656fdb50f45f1e8d60b37416d2f3b1be9e8ae145bfe035f9d947fa49a31" +
+            "baef86dec6780a0f96a7ad5d9ef850b15f56d6b6f2f0798c190b01b42d955d36" +
+            "96f1416efb0c246b56e3715c1ccef701f975f6faf7e7640b8edca79f996682d8" +
+            "5a414c8210004f247058c3362f328c12d024ea88de5ab3d6c50a7cf8f32b69de" +
+            "999930ccb29be0d278216db0959d9b142e4c46207edaf91f37708e0250e99262" +
+            "c4acba4b83c2c0affb3bfc2d5bfe210baffe56ba1f667c9e3c33e0c4164d0c16" +
+            "abc89bca2c1af7fc234163a6a17e4852ee08053bdf699c8659ea57f77427ab3b" +
+            "cea357a85ffd80589403bc73ff50490f9b0bfb37fedf495aae8ef8a00da7d1e1" +
+            "62c49dacf82503e803953f48e302d1ae1b7e7870a479c7861ffc236469807f31" +
+            "da0b15a915a62d4f0a42698a4c9779595619effa04765f91342821229752ec6d" +
+            "6e0657ad4e41979847b5903ddb6a6819b859797a2f663898694fe294cc85b9c3" +
+            "d485516659dcd6d89f631903be35367315b131f9f5ec63ee5bf25f3afcf8bc9c" +
+            "d9056a56f951746664cfa3ed0596e005fda6fb753d9c67c92fd1a9f22d06a59e" +
+            "9c7af058dddad3b9265fc29c18122f55c07a1780050251990c221ba2b3767586" +
+            "405def7a1b224135ac4a694f0e3d27666486531aad9e27a3855f54e2916a642a" +
+            "ed06fc5275b675bbf457a26978b0f4306c166119dedc3aedf366cbf34efa647e" +
+            "a65b8451c7b1d083fe1ee3a8493a0330ee7da68552614e50ca7326a25d741e40" +
+            "ccac2149d1ff5cb8778a3b08ed3d9a1774c971525454b7c20b18610b9bc847cc" +
+            "3136301106092a864886f70d01091431041e020061302106092a864886f70d01" +
+            "09153114041254696d652031353433363738383539323632308204dc06092a86" +
+            "4886f70d010706a08204cd308204c9020100308204c206092a864886f70d0107" +
+            "013029060a2a864886f70d010c0106301b0414e6d3162d3b75f103fac6ea3fbf" +
+            "96d08c0225d308020300c3508082048834d05f8953cad673f7de3b5446bcdd31" +
+            "310b376eec04c393f1077cfda8ad69fe0133cf79fbdd204eeca165e1d6e288b9" +
+            "a6625dfe34aa722f230c50da44d463753d3bbd7e762cb0f164b7fbfe4a3aff8c" +
+            "dc664ef2c6afd01232de66d81221e977738b81838cadd0fe1f87bdd7278dcdbd" +
+            "2307bda516e931691e3da46f82f72073ab6502b9f2b23788c620756eedddf21e" +
+            "705a6043d29a8e27285fea79e4a9966f5b08d5f13bc6f4d854f47879ee90e72d" +
+            "3a5cc6eccda9edf60c4d73edf3e4dd6c715c06c53e83ba461e10868e5ef5e218" +
+            "726bc6714f3071b3f17a075ff9d28d2cb48896b785d48551e8410f2bc882ad04" +
+            "88d60c85c3b966e1b484e4190267b38e3179107f3c49abd2b058fb32eab4abfc" +
+            "ee914ee4407954e1edb338042ca04b1561df364139a64a1080c79bfdfa17d15b" +
+            "6fc26b0572427b2f1b9bbea6d1a730a7dd1b08d22093658f9a5665ae8e9a04b8" +
+            "af89a60ea7994d17949b22e2fc6d5d4dd1d280283fd649e1aca6e0e4c90ae509" +
+            "afc01bd92127321798562cf5ba75fed840f8ca9082c8c58334a95593fa5b1b57" +
+            "ea86cb8452136dee7ecd63872d4848d9052e181f6bca0772a4d4dd43817b9005" +
+            "a6314cbd90474a24b6ed9c9896097bba51ca7cd48120b5f9fee3f98dd99bbcd3" +
+            "e0ab43bcbb922bcf48cf710f7a5b9d192f419f607b6ca7937d8ed6f990835b88" +
+            "7f480cc5fad2708c57c674d0e082af60d8b0108df2bf88b321df4d0431d4dfc0" +
+            "4ae21cfd5446715e4af6bcb2224a8d6dc26d71806f21c1e17e8dd2ac57632234" +
+            "1d3e72cbcce4c4e59421fc5202ec6d76c623b81a872ab6b8d53e4215234ee8d9" +
+            "61148b0f42300fc0c89ec91f528698d79a27af593e5fd56484c97763ebc4a797" +
+            "13511ec0e13c59318d1ac444f6121a81a4f505b7e3dca70d6cd74b209fc10003" +
+            "78d5f2016c63acd019a1175e41fe60b88ff5e7238b32ef25243da462cabcd6c7" +
+            "5789c6055ef4999522acb386138f085e9bc2e9b41ecaf3bbb0990ac8b9efde0e" +
+            "eedff4c636bd13ef2dc18bfe5e900d88f4649ce326bc4f8e9bfe058832a595e3" +
+            "5c65415ca9606b0d2c705519eb83995a6da302f53e57a93f2be20dc858d3d5e9" +
+            "e8fdbc10af092b47c108d2e44eed00879626389b35df014e54ea3bf067d2d800" +
+            "b74f67c3576d585e6fedf9634e1ae7941d0de0faed7c76e0296d701728792bf4" +
+            "9bf007738d9273af8981bd71ed4a6360c08a4c5ab83ee337141c37679cf5db7a" +
+            "5aff7353ed6285bab948cac12559ee6ed9f34ee20e01b538975e26c310a33790" +
+            "f8be9fbb907f2585f55d2a456c6be4e46e08edd3aa5392d1c9415a6ded826776" +
+            "b04a3804f9b5f078888320ee5b279a4bba3b5c73ae1e8444b9320b92eb6b8e16" +
+            "75f505bcf79ff0e0cc80326e9bedbc6baebce47725aef3914e4326b924984788" +
+            "1d21d59d71b08ba34283f5784deeeecb9f4a3cfbcb21e48e8a9a94972ee7366e" +
+            "04d1d9c60534fdb7bfe5ec559427b6bbe96d41f551dde0800684226920cbc4f4" +
+            "1f3a7225e0c6a15d3ebee4e87ae4c40fef4d2e5272bb5b0037030665ae1faba7" +
+            "4c41a04277bbe1851e090c8d31e48575bbc96618e3cfeea5a2f80fc1e565adc8" +
+            "ffd84b803877ff9b305a4da59e6f707b3dbe95f7c037fbec303e302130090605" +
+            "2b0e03021a05000414adb4dd32f3ce248ec62e2fd45835255c2316739e041441" +
+            "f87d07019980ef69b635f06017567e36aa3d8802030186a0";
+
+    public static void main(String[] args) throws Exception {
+        if (args.length > 0 && args[0].equals("reenc")) {
+            reEncodeWithPBES2();
+        } else {
+            test();
+        }
+    }
+
+    private static void test() throws Exception {
+        byte[] p12 = new byte[P12_FILE.length() / 2];
+        for (int i = 0; i < p12.length; i++) {
+            p12[i] = Integer.valueOf(P12_FILE.substring(2 * i, 2 * i + 2), 16)
+                    .byteValue();
+        }
+        KeyStore ks = KeyStore.getInstance("pkcs12");
+        ks.load(new ByteArrayInputStream(p12), PASS);
+        System.out.println(ks.getKey("a", PASS));
+    }
+
+    private static void reEncodeWithPBES2() throws Exception {
+        KeyStore keyStore = KeyStore.getInstance(new File("ks"), PASS);
+        KeyStore.PrivateKeyEntry privateKeyEntry = new KeyStore.PrivateKeyEntry(
+                (PrivateKey)keyStore.getKey("a", PASS),
+                new Certificate[] { keyStore.getCertificate("a") });
+        keyStore.setEntry("a", privateKeyEntry, new KeyStore.PasswordProtection(
+                PASS, "PBEWithHmacSHA512AndAES_256",
+                new PBEParameterSpec(new byte[20], 100_000)));
+        ByteArrayOutputStream bout = new ByteArrayOutputStream();
+        keyStore.store(bout, PASS);
+        byte[] p12 = bout.toByteArray();
+        StringBuilder sb = new StringBuilder();
+        for (int i = 0; i < p12.length; i++) {
+            if (i % 32 == 0) {
+                if (i != 0) {
+                    sb.append("\" +\n");
+                }
+                sb.append("\"");
+            }
+            sb.append(String.format("%02x", p12[i] & 0xff));
+        }
+        sb.append("\";\n");
+        System.out.println(sb.toString());
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/tools/jlink/JLinkReproducibleTest.java	Wed Dec 05 15:39:04 2018 +0530
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 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.
+ */
+
+import java.io.File;
+import java.nio.file.*;
+import java.util.*;
+
+import static jdk.test.lib.Asserts.*;
+import jdk.test.lib.JDKToolFinder;
+import jdk.test.lib.process.ProcessTools;
+
+/*
+ * @test
+ * @bug 8214230
+ * @summary Test that jlinks generates reproducible modules files
+ * @library /test/lib
+ * @run driver JLinkReproducibleTest
+ */
+public class JLinkReproducibleTest {
+    private static void run(List<String> cmd) throws Exception {
+        var pb = new ProcessBuilder(cmd.toArray(new String[0]));
+        var res = ProcessTools.executeProcess(pb);
+        res.shouldHaveExitValue(0);
+    }
+
+    private static void jlink(Path image) throws Exception {
+        var cmd = new ArrayList<String>();
+        cmd.add(JDKToolFinder.getJDKTool("jlink"));
+        cmd.addAll(List.of(
+            "--module-path", JMODS_DIR.toString() + File.pathSeparator + CLASS_DIR.toString(),
+            "--add-modules", "main",
+            "--compress=2",
+            "--output", image.toString()
+        ));
+        run(cmd);
+    }
+
+    private static void javac(String... args) throws Exception {
+        var cmd = new ArrayList<String>();
+        cmd.add(JDKToolFinder.getJDKTool("javac"));
+        cmd.addAll(Arrays.asList(args));
+        run(cmd);
+    }
+
+    private static final List<String> MODULE_INFO = List.of(
+        "module main {",
+        "    exports org.test.main;",
+        "}"
+    );
+
+    private static final List<String> MAIN_CLASS = List.of(
+        "package org.test.main;",
+        "public class Main {",
+        "    public static void main(String[] args) {",
+        "        System.out.println(\"Hello, world\");",
+        "    }",
+        "}"
+    );
+
+    private static final Path CLASS_DIR = Path.of("classes");
+    private static final Path JMODS_DIR = Path.of(System.getProperty("java.home"), "jmods");
+
+    public static void main(String[] args) throws Exception {
+        // Write the source code
+        var srcDir = Path.of("main", "org", "test", "main");
+        Files.createDirectories(srcDir.toAbsolutePath());
+
+        var srcFile = srcDir.resolve("Main.java");
+        Files.write(srcFile, MAIN_CLASS);
+
+        var moduleFile = Path.of("main").resolve("module-info.java");
+        Files.write(moduleFile, MODULE_INFO);
+
+        // Compile the source code to class files
+        javac("--module-source-path", ".",
+              "--module", "main",
+              "-d", CLASS_DIR.toString());
+
+        // Link the first image
+        var firstImage = Path.of("image-first");
+        jlink(firstImage);
+        var firstModulesFile = firstImage.resolve("lib")
+                                         .resolve("modules");
+
+        // Link the second image
+        var secondImage = Path.of("image-second");
+        jlink(secondImage);
+        var secondModulesFile = secondImage.resolve("lib")
+                                           .resolve("modules");
+
+        // Ensure module files are identical
+        assertEquals(-1L, Files.mismatch(firstModulesFile, secondModulesFile));
+    }
+}