Merge ihse-testmakefiles-branch
authorihse
Wed, 06 Dec 2017 14:17:44 +0100
branchihse-testmakefiles-branch
changeset 55967 e2c47e2db0a5
parent 55966 07d921cdd7a6 (current diff)
parent 48079 eaa406097d93 (diff)
Merge
make/Help.gmk
make/RunTestsPrebuilt.gmk
make/RunTestsPrebuiltSpec.gmk
make/autoconf/boot-jdk.m4
make/autoconf/generated-configure.sh
make/conf/jib-profiles.js
test/jdk/jdk/internal/misc/JavaLangAccess/NewUnsafeString.java
--- a/make/CompileInterimLangtools.gmk	Wed Dec 06 14:13:50 2017 +0100
+++ b/make/CompileInterimLangtools.gmk	Wed Dec 06 14:17:44 2017 +0100
@@ -69,8 +69,8 @@
           Standard.java, \
       EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/$1.interim/module-info.java, \
       COPY := .gif .png .xml .css .js javax.tools.JavaCompilerTool, \
-      BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_modules/$1.interim, \
-      ADD_JAVAC_FLAGS := --module-path $(BUILDTOOLS_OUTPUTDIR)/interim_modules \
+      BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules/$1.interim, \
+      ADD_JAVAC_FLAGS := --module-path $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules \
           $$(INTERIM_LANGTOOLS_ADD_EXPORTS) \
           -Xlint:-module, \
   ))
--- a/make/CompileInterimRmic.gmk	Wed Dec 06 14:13:50 2017 +0100
+++ b/make/CompileInterimRmic.gmk	Wed Dec 06 14:17:44 2017 +0100
@@ -65,10 +65,10 @@
     EXCLUDE_FILES := $(TOPDIR)/src/jdk.rmic/share/classes/module-info.java, \
     EXTRA_FILES := $(BUILDTOOLS_OUTPUTDIR)/gensrc/jdk.rmic.interim/module-info.java, \
     INCLUDES := $(RMIC_PKGS), \
-    BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_modules/jdk.rmic.interim, \
+    BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_rmic_modules/jdk.rmic.interim, \
     COPY := .properties, \
     ADD_JAVAC_FLAGS := \
-        --module-path $(BUILDTOOLS_OUTPUTDIR)/interim_modules \
+        --module-path $(BUILDTOOLS_OUTPUTDIR)/interim_rmic_modules \
         --add-modules java.corba \
         --add-exports java.corba/com.sun.corba.se.impl.util=jdk.rmic.interim \
         $(INTERIM_RMIC_ADD_EXPORTS), \
--- a/make/CreateJmods.gmk	Wed Dec 06 14:13:50 2017 +0100
+++ b/make/CreateJmods.gmk	Wed Dec 06 14:17:44 2017 +0100
@@ -1,5 +1,4 @@
-
-# Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 #
 # This code is free software; you can redistribute it and/or modify it
@@ -33,6 +32,8 @@
   $(error MODULE must be set when calling CreateJmods.gmk)
 endif
 
+$(eval $(call IncludeCustomExtension, CreateJmods.gmk))
+
 ################################################################################
 
 JMODS_DIR := $(IMAGES_OUTPUTDIR)/jmods
--- a/make/RunTestsPrebuilt.gmk	Wed Dec 06 14:13:50 2017 +0100
+++ b/make/RunTestsPrebuilt.gmk	Wed Dec 06 14:17:44 2017 +0100
@@ -69,7 +69,7 @@
       $1:=$2
     endif
   else
-      ifneq ($$(findstring $$(LOG), info debug trace), )
+    ifneq ($$(findstring $$(LOG), info debug trace), )
       $$(info Prebuilt variable $1=$$($1))
     endif
   endif
@@ -91,8 +91,8 @@
     $(error Internal makefile error: \
       Too many arguments to macro, please update CreateNewSpec in RunTestsPrebuilt.gmk) \
   ) \
-  $(shell rm -f $1) \
-  $(foreach i, 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25, \
+  $(shell $(RM) $1) \
+  $(foreach i, $(call sequence, 2, 25), \
     $(if $(strip $($i)), \
       $(call AppendFile, $(strip $($i)), $1) \
     ) \
@@ -179,7 +179,7 @@
     OPENJDK_TARGET_CPU := $(UNAME_CPU)
   endif
 else
-  # ... all other user uname -m
+  # ... all others use uname -m
   UNAME_CPU := $(shell $(UNAME) -m)
   ifeq ($(UNAME_CPU), i686)
     OPENJDK_TARGET_CPU := x86
--- a/make/autoconf/boot-jdk.m4	Wed Dec 06 14:13:50 2017 +0100
+++ b/make/autoconf/boot-jdk.m4	Wed Dec 06 14:17:44 2017 +0100
@@ -353,9 +353,6 @@
 
   AC_MSG_CHECKING([flags for boot jdk java command] )
 
-  # Disable special log output when a debug build is used as Boot JDK...
-  ADD_JVM_ARG_IF_OK([-XX:-PrintVMOptions -XX:-UnlockDiagnosticVMOptions -XX:-LogVMOutput],boot_jdk_jvmargs,[$JAVA])
-
   # Force en-US environment
   ADD_JVM_ARG_IF_OK([-Duser.language=en -Duser.country=US],boot_jdk_jvmargs,[$JAVA])
 
--- a/make/autoconf/generated-configure.sh	Wed Dec 06 14:13:50 2017 +0100
+++ b/make/autoconf/generated-configure.sh	Wed Dec 06 14:17:44 2017 +0100
@@ -5159,7 +5159,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1512410983
+DATE_WHEN_GENERATED=1512566251
 
 ###############################################################################
 #
@@ -67379,23 +67379,6 @@
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking flags for boot jdk java command " >&5
 $as_echo_n "checking flags for boot jdk java command ... " >&6; }
 
-  # Disable special log output when a debug build is used as Boot JDK...
-
-  $ECHO "Check if jvm arg is ok: -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput" >&5
-  $ECHO "Command: $JAVA -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -version" >&5
-  OUTPUT=`$JAVA -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput -version 2>&1`
-  FOUND_WARN=`$ECHO "$OUTPUT" | $GREP -i warn`
-  FOUND_VERSION=`$ECHO $OUTPUT | $GREP " version \""`
-  if test "x$FOUND_VERSION" != x && test "x$FOUND_WARN" = x; then
-    boot_jdk_jvmargs="$boot_jdk_jvmargs -XX:-PrintVMOptions -XX:+UnlockDiagnosticVMOptions -XX:-LogVMOutput"
-    JVM_ARG_OK=true
-  else
-    $ECHO "Arg failed:" >&5
-    $ECHO "$OUTPUT" >&5
-    JVM_ARG_OK=false
-  fi
-
-
   # Force en-US environment
 
   $ECHO "Check if jvm arg is ok: -Duser.language=en -Duser.country=US" >&5
--- a/make/autoconf/spec.gmk.in	Wed Dec 06 14:13:50 2017 +0100
+++ b/make/autoconf/spec.gmk.in	Wed Dec 06 14:17:44 2017 +0100
@@ -565,6 +565,7 @@
 
 BUILD_JAVA_FLAGS := @BOOTCYCLE_JVM_ARGS_BIG@
 BUILD_JAVA=@FIXPATH@ $(BUILD_JDK)/bin/java $(BUILD_JAVA_FLAGS)
+BUILD_JAR=@FIXPATH@ $(BUILD_JDK)/bin/jar
 
 # Interim langtools and rmic modules and arguments
 INTERIM_LANGTOOLS_BASE_MODULES := java.compiler jdk.compiler jdk.javadoc
@@ -577,7 +578,7 @@
 INTERIM_LANGTOOLS_ARGS := \
     --limit-modules java.base,jdk.zipfs,$(INTERIM_LANGTOOLS_MODULES_COMMA) \
     --add-modules $(INTERIM_LANGTOOLS_MODULES_COMMA) \
-    --module-path $(BUILDTOOLS_OUTPUTDIR)/interim_modules \
+    --module-path $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules \
     $(INTERIM_LANGTOOLS_ADD_EXPORTS) \
     #
 JAVAC_MAIN_CLASS = -m jdk.compiler.interim/com.sun.tools.javac.Main
@@ -588,8 +589,10 @@
 INTERIM_RMIC_ADD_EXPORTS := \
     --add-exports java.corba/com.sun.corba.se.impl.util=jdk.rmic.interim \
     #
-INTERIM_RMIC_ARGS := --limit-modules java.base,jdk.compiler,jdk.javadoc,java.corba \
-    --module-path $(BUILDTOOLS_OUTPUTDIR)/interim_modules \
+# Use = to delay expansion of PathList since it's not available in this file.
+INTERIM_RMIC_ARGS = --limit-modules java.base,jdk.compiler,jdk.javadoc,java.corba \
+    --module-path $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/interim_rmic_modules \
+        $(BUILDTOOLS_OUTPUTDIR)/interim_langtools_modules) \
     $(INTERIM_RMIC_ADD_EXPORTS) \
     #
 
--- a/make/common/JarArchive.gmk	Wed Dec 06 14:13:50 2017 +0100
+++ b/make/common/JarArchive.gmk	Wed Dec 06 14:17:44 2017 +0100
@@ -56,6 +56,7 @@
 #       added to the archive.
 #   EXTRA_MANIFEST_ATTR:=Extra attribute to add to manifest.
 #   CHECK_COMPRESS_JAR Check the COMPRESS_JAR variable
+#   JAR_CMD:=Optionally override the jar command to use when creating the archive.
 SetupJarArchive = $(NamedParamsMacroTemplate)
 define SetupJarArchiveBody
 
@@ -65,6 +66,7 @@
   $1_DELETESS_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletess
   $1_DELETES_FILE:=$$(dir $$($1_JAR))_the.$$($1_JARNAME)_deletes
   $1_BIN:=$$(dir $$($1_JAR))
+  $$(call SetIfEmpty, $1_JAR_CMD, $$(JAR))
 
   ifeq (,$$($1_SUFFIXES))
     # No suffix was set, default to classes.
@@ -109,7 +111,7 @@
 
   # Check if this jar needs to have its index generated.
   ifneq (,$$($1_JARINDEX))
-    $1_JARINDEX = (cd $$(dir $$@) && $(JAR) -i $$(notdir $$@))
+    $1_JARINDEX = (cd $$(dir $$@) && $$($1_JAR_CMD) -i $$(notdir $$@))
   else
     $1_JARINDEX = true
   endif
@@ -189,7 +191,7 @@
   $1_UPDATE_CONTENTS=\
       if [ "`$(WC) -l $$($1_BIN)/_the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'`" -gt "0" ]; then \
         $(ECHO) "  updating" `$(WC) -l $$($1_BIN)/_the.$$($1_JARNAME)_contents | $(AWK) '{ print $$$$1 }'` files && \
-        $(JAR) $$($1_JAR_UPDATE_OPTIONS) $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents; \
+        $$($1_JAR_CMD) $$($1_JAR_UPDATE_OPTIONS) $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents; \
       fi $$(NEWLINE)
   # The s-variants of the above macros are used when the jar is created from scratch.
   # NOTICE: please leave the parentheses space separated otherwise the AIX build will break!
@@ -208,7 +210,7 @@
             | $(SED) 's|$$(src)/|-C $$(src) |g' >> \
         $$($1_BIN)/_the.$$($1_JARNAME)_contents) $$(NEWLINE) )
   endif
-  $1_SUPDATE_CONTENTS=$(JAR) $$($1_JAR_UPDATE_OPTIONS) $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents $$(NEWLINE)
+  $1_SUPDATE_CONTENTS=$$($1_JAR_CMD) $$($1_JAR_UPDATE_OPTIONS) $$@ @$$($1_BIN)/_the.$$($1_JARNAME)_contents $$(NEWLINE)
 
   # Use a slightly shorter name for logging, but with enough path to identify this jar.
   $1_NAME:=$$(subst $$(OUTPUTDIR)/,,$$($1_JAR))
@@ -226,7 +228,7 @@
   endif
 
   # Include all variables of significance in the vardeps file
-  $1_VARDEPS := $(JAR) $$($1_JAR_CREATE_OPTIONS) $$($1_MANIFEST) \
+  $1_VARDEPS := $$($1_JAR_CMD) $$($1_JAR_CREATE_OPTIONS) $$($1_MANIFEST) \
       $$($1_JARMAIN) $$($1_EXTRA_MANIFEST_ATTR) $$($1_ORIG_DEPS) $$($1_SRCS) \
       $$($1_INCLUDES) $$($1_EXCLUDES) $$($1_EXCLUDE_FILES) $$($1_EXTRA_FILES)
   $1_VARDEPS_FILE := $$(call DependOnVariable, $1_VARDEPS, $$(dir $$($1_JAR))_the.$$($1_JARNAME).vardeps)
@@ -250,7 +252,7 @@
 	  $$(if $$($1_EXTRA_MANIFEST_ATTR), \
 	    $(PRINTF) "$$($1_EXTRA_MANIFEST_ATTR)\n" >> $$($1_MANIFEST_FILE) $$(NEWLINE)) \
 	  $(ECHO) Creating $$($1_NAME) $$(NEWLINE) \
-	  $(JAR) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) $$(NEWLINE) \
+	  $$($1_JAR_CMD) $$($1_JAR_CREATE_OPTIONS) $$@ $$($1_MANIFEST_FILE) $$(NEWLINE) \
 	  $$($1_SCAPTURE_CONTENTS) \
 	  $$($1_SCAPTURE_METAINF) \
 	  $$($1_SUPDATE_CONTENTS) \
--- a/make/jdk/src/classes/build/tools/jdwpgen/RootNode.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/make/jdk/src/classes/build/tools/jdwpgen/RootNode.java	Wed Dec 06 14:17:44 2017 +0100
@@ -40,6 +40,7 @@
     }
 
     void document(PrintWriter writer) {
+        writer.println("<!DOCTYPE html>");
         writer.println("<html><head><title>" + comment() + "</title></head>");
         writer.println("<body bgcolor=\"white\">");
         for (Node node : components) {
--- a/src/java.base/share/classes/java/lang/ClassLoader.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/java/lang/ClassLoader.java	Wed Dec 06 14:17:44 2017 +0100
@@ -30,6 +30,7 @@
 import java.io.UncheckedIOException;
 import java.io.File;
 import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
 import java.net.URL;
 import java.security.AccessController;
 import java.security.AccessControlContext;
@@ -1867,7 +1868,7 @@
      * to be the system class loader. During construction, the class loader
      * should take great care to avoid calling {@code getSystemClassLoader()}.
      * If circular initialization of the system class loader is detected then
-     * an unspecified error or exception is thrown.
+     * an {@code IllegalStateException} is thrown.
      *
      * @implNote The system property to override the system class loader is not
      * examined until the VM is almost fully initialized. Code that executes
@@ -1918,8 +1919,8 @@
                 // the system class loader is the built-in app class loader during startup
                 return getBuiltinAppClassLoader();
             case 3:
-                String msg = "getSystemClassLoader should only be called after VM booted";
-                throw new InternalError(msg);
+                String msg = "getSystemClassLoader cannot be called during the system class loader instantiation";
+                throw new IllegalStateException(msg);
             case 4:
                 // system fully initialized
                 assert VM.isBooted() && scl != null;
@@ -1969,7 +1970,17 @@
                                            .getDeclaredConstructor(ClassLoader.class);
                 scl = (ClassLoader) ctor.newInstance(builtinLoader);
             } catch (Exception e) {
-                throw new Error(e);
+                Throwable cause = e;
+                if (e instanceof InvocationTargetException) {
+                    cause = e.getCause();
+                    if (cause instanceof Error) {
+                        throw (Error) cause;
+                    }
+                }
+                if (cause instanceof RuntimeException) {
+                    throw (RuntimeException) cause;
+                }
+                throw new Error(cause.getMessage(), cause);
             }
         } else {
             scl = builtinLoader;
--- a/src/java.base/share/classes/java/lang/ModuleLayer.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/java/lang/ModuleLayer.java	Wed Dec 06 14:17:44 2017 +0100
@@ -322,8 +322,8 @@
      * @return The newly created layer
      *
      * @throws IllegalArgumentException
-     *         If the parent of the given configuration is not the configuration
-     *         for this layer
+     *         If the given configuration has more than one parent or the parent
+     *         of the configuration is not the configuration for this layer
      * @throws LayerInstantiationException
      *         If the layer cannot be created for any of the reasons specified
      *         by the static {@code defineModulesWithOneLoader} method
@@ -364,8 +364,8 @@
      * @return The newly created layer
      *
      * @throws IllegalArgumentException
-     *         If the parent of the given configuration is not the configuration
-     *         for this layer
+     *         If the given configuration has more than one parent or the parent
+     *         of the configuration is not the configuration for this layer
      * @throws LayerInstantiationException
      *         If the layer cannot be created for any of the reasons specified
      *         by the static {@code defineModulesWithManyLoaders} method
@@ -403,8 +403,8 @@
      * @return The newly created layer
      *
      * @throws IllegalArgumentException
-     *         If the parent of the given configuration is not the configuration
-     *         for this layer
+     *         If the given configuration has more than one parent or the parent
+     *         of the configuration is not the configuration for this layer
      * @throws LayerInstantiationException
      *         If the layer cannot be created for any of the reasons specified
      *         by the static {@code defineModules} method
@@ -473,8 +473,8 @@
      * @return A controller that controls the newly created layer
      *
      * @throws IllegalArgumentException
-     *         If the parent configurations do not match the configuration of
-     *         the parent layers, including order
+     *         If the parent(s) of the given configuration do not match the
+     *         configuration of the parent layers, including order
      * @throws LayerInstantiationException
      *         If all modules cannot be defined to the same class loader for any
      *         of the reasons listed above
@@ -546,8 +546,8 @@
      * @return A controller that controls the newly created layer
      *
      * @throws IllegalArgumentException
-     *         If the parent configurations do not match the configuration of
-     *         the parent layers, including order
+     *         If the parent(s) of the given configuration do not match the
+     *         configuration of the parent layers, including order
      * @throws LayerInstantiationException
      *         If the layer cannot be created because the configuration contains
      *         a module named "{@code java.base}" or a module contains a package
@@ -637,8 +637,8 @@
      * @return A controller that controls the newly created layer
      *
      * @throws IllegalArgumentException
-     *         If the parent configurations do not match the configuration of
-     *         the parent layers, including order
+     *         If the parent(s) of the given configuration do not match the
+     *         configuration of the parent layers, including order
      * @throws LayerInstantiationException
      *         If creating the layer fails for any of the reasons listed above
      * @throws SecurityException
--- a/src/java.base/share/classes/java/lang/String.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/java/lang/String.java	Wed Dec 06 14:17:44 2017 +0100
@@ -645,19 +645,6 @@
         this(builder, null);
     }
 
-   /*
-    * Package private constructor which shares value array for speed.
-    * this constructor is always expected to be called with share==true.
-    * a separate constructor is needed because we already have a public
-    * String(char[]) constructor that makes a copy of the given char[].
-    */
-    // TBD: this is kept for package internal use (Thread/System),
-    // should be removed if they all have a byte[] version
-    String(char[] val, boolean share) {
-        // assert share : "unshared not supported";
-        this(val, 0, val.length, null);
-    }
-
     /**
      * Returns the length of this string.
      * The length is equal to the number of <a href="Character.html#unicode">Unicode
--- a/src/java.base/share/classes/java/lang/System.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/java/lang/System.java	Wed Dec 06 14:17:44 2017 +0100
@@ -2109,9 +2109,6 @@
             public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
                 Shutdown.add(slot, registerShutdownInProgress, hook);
             }
-            public String newStringUnsafe(char[] chars) {
-                return new String(chars, true);
-            }
             public Thread newThreadWithAcc(Runnable target, AccessControlContext acc) {
                 return new Thread(target, acc);
             }
--- a/src/java.base/share/classes/java/lang/module/package-info.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/java/lang/module/package-info.java	Wed Dec 06 14:17:44 2017 +0100
@@ -34,7 +34,7 @@
  * will cause a {@code NullPointerException}, unless otherwise specified. </p>
  *
  *
- * <h1><a id="resolution">Resolution</a></h1>
+ * <h1><a id="resolution">{@index "Module Resolution"}</a></h1>
  *
  * <p> Resolution is the process of computing how modules depend on each other.
  * The process occurs at compile time and run time. </p>
--- a/src/java.base/share/classes/java/text/MessageFormat.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/java/text/MessageFormat.java	Wed Dec 06 14:17:44 2017 +0100
@@ -701,6 +701,10 @@
      *            larger than the number of format elements in the pattern string
      */
     public void setFormat(int formatElementIndex, Format newFormat) {
+
+        if (formatElementIndex > maxOffset) {
+            throw new ArrayIndexOutOfBoundsException(formatElementIndex);
+        }
         formats[formatElementIndex] = newFormat;
     }
 
--- a/src/java.base/share/classes/java/util/StringJoiner.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/java/util/StringJoiner.java	Wed Dec 06 14:17:44 2017 +0100
@@ -24,9 +24,6 @@
  */
 package java.util;
 
-import jdk.internal.misc.JavaLangAccess;
-import jdk.internal.misc.SharedSecrets;
-
 /**
  * {@code StringJoiner} is used to construct a sequence of characters separated
  * by a delimiter and optionally starting with a supplied prefix
@@ -86,8 +83,6 @@
      */
     private String emptyValue;
 
-    private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
-
     /**
      * Constructs a {@code StringJoiner} with no characters in it, with no
      * {@code prefix} or {@code suffix}, and a copy of the supplied
@@ -189,7 +184,7 @@
             }
         }
         k += getChars(suffix, chars, k);
-        return jla.newStringUnsafe(chars);
+        return new String(chars);
     }
 
     /**
@@ -252,7 +247,7 @@
                 elts[i] = null;
             } while (++i < size);
             size = 1;
-            elts[0] = jla.newStringUnsafe(chars);
+            elts[0] = new String(chars);
         }
     }
 
--- a/src/java.base/share/classes/java/util/jar/JarFile.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/java/util/jar/JarFile.java	Wed Dec 06 14:17:44 2017 +0100
@@ -43,17 +43,12 @@
 import java.security.cert.Certificate;
 import java.util.ArrayList;
 import java.util.Enumeration;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Locale;
-import java.util.Map;
 import java.util.NoSuchElementException;
 import java.util.Objects;
-import java.util.Spliterator;
-import java.util.Spliterators;
-import java.util.stream.Collector;
+import java.util.function.Function;
 import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipException;
 import java.util.zip.ZipFile;
@@ -566,7 +561,14 @@
      * given entry name or {@code null} if not found.
      */
     private JarFileEntry getEntry0(String name) {
-        return (JarFileEntry)JUZFA.getEntry(this, name, JarFileEntry::new);
+        // Not using a lambda/method reference here to optimize startup time
+        Function<String, JarEntry> newJarFileEntryFn = new Function<>() {
+            @Override
+            public JarEntry apply(String name) {
+                return new JarFileEntry(name);
+            }
+        };
+        return (JarFileEntry)JUZFA.getEntry(this, name, newJarFileEntryFn);
     }
 
     private String getBasename(String name) {
--- a/src/java.base/share/classes/java/util/stream/Stream.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/java/util/stream/Stream.java	Wed Dec 06 14:17:44 2017 +0100
@@ -671,7 +671,8 @@
      * <p>This is a <a href="package-summary.html#StreamOps">terminal
      * operation</a>.
      *
-     * @return an array containing the elements of this stream
+     * @return an array, whose {@linkplain Class#getComponentType runtime component
+     * type} is {@code Object}, containing the elements of this stream
      */
     Object[] toArray();
 
@@ -694,13 +695,13 @@
      *                          .toArray(Person[]::new);
      * }</pre>
      *
-     * @param <A> the element type of the resulting array
+     * @param <A> the component type of the resulting array
      * @param generator a function which produces a new array of the desired
      *                  type and the provided length
      * @return an array containing the elements in this stream
-     * @throws ArrayStoreException if the runtime type of the array returned
-     * from the array generator is not a supertype of the runtime type of every
-     * element in this stream
+     * @throws ArrayStoreException if the runtime type of any element of this
+     *         stream is not assignable to the {@linkplain Class#getComponentType
+     *         runtime component type} of the generated array
      */
     <A> A[] toArray(IntFunction<A[]> generator);
 
--- a/src/java.base/share/classes/jdk/internal/loader/Loader.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/jdk/internal/loader/Loader.java	Wed Dec 06 14:17:44 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,7 +28,6 @@
 import java.io.File;
 import java.io.FilePermission;
 import java.io.IOException;
-import java.io.UncheckedIOException;
 import java.lang.module.Configuration;
 import java.lang.module.ModuleDescriptor;
 import java.lang.module.ModuleReader;
@@ -58,12 +57,8 @@
 import java.util.Map;
 import java.util.Objects;
 import java.util.Optional;
-import java.util.Spliterator;
-import java.util.Spliterators;
 import java.util.concurrent.ConcurrentHashMap;
-import java.util.function.Supplier;
 import java.util.stream.Stream;
-import java.util.stream.StreamSupport;
 
 import jdk.internal.misc.SharedSecrets;
 import jdk.internal.module.Resources;
@@ -403,12 +398,15 @@
 
         // this loader
         URL url = findResource(name);
-        if (url != null) {
-            return url;
-        } else {
+        if (url == null) {
             // parent loader
-            return parent.getResource(name);
+            if (parent != null) {
+                url = parent.getResource(name);
+            } else {
+                url = BootLoader.findResource(name);
+            }
         }
+        return url;
     }
 
     @Override
@@ -419,7 +417,12 @@
         List<URL> urls = findResourcesAsList(name);
 
         // parent loader
-        Enumeration<URL> e = parent.getResources(name);
+        Enumeration<URL> e;
+        if (parent != null) {
+            e = parent.getResources(name);
+        } else {
+            e = BootLoader.findResources(name);
+        }
 
         // concat the URLs with the URLs returned by the parent
         return new Enumeration<>() {
@@ -439,25 +442,6 @@
         };
     }
 
-    @Override
-    public Stream<URL> resources(String name) {
-        Objects.requireNonNull(name);
-        // ordering not specified
-        int characteristics = (Spliterator.NONNULL | Spliterator.IMMUTABLE |
-                               Spliterator.SIZED | Spliterator.SUBSIZED);
-        Supplier<Spliterator<URL>> supplier = () -> {
-            try {
-                List<URL> urls = findResourcesAsList(name);
-                return Spliterators.spliterator(urls, characteristics);
-            } catch (IOException e) {
-                throw new UncheckedIOException(e);
-            }
-        };
-        Stream<URL> s1 = StreamSupport.stream(supplier, characteristics, false);
-        Stream<URL> s2 = parent.resources(name);
-        return Stream.concat(s1, s2);
-    }
-
     /**
      * Finds the resources with the given name in this class loader.
      */
--- a/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.base/share/classes/jdk/internal/misc/JavaLangAccess.java	Wed Dec 06 14:17:44 2017 +0100
@@ -124,16 +124,6 @@
     void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook);
 
     /**
-     * Returns a new string backed by the provided character array. The
-     * character array is not copied and must never be modified after the
-     * String is created, in order to fulfill String's contract.
-     *
-     * @param chars the character array to back the string
-     * @return a newly created string whose content is the character array
-     */
-    String newStringUnsafe(char[] chars);
-
-    /**
      * Returns a new Thread with the given Runnable and an
      * inherited AccessControlContext.
      */
--- a/src/java.sql/share/classes/java/sql/Date.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.sql/share/classes/java/sql/Date.java	Wed Dec 06 14:17:44 2017 +0100
@@ -27,8 +27,6 @@
 
 import java.time.Instant;
 import java.time.LocalDate;
-import jdk.internal.misc.SharedSecrets;
-import jdk.internal.misc.JavaLangAccess;
 
 /**
  * <P>A thin wrapper around a millisecond value that allows
@@ -46,8 +44,6 @@
  */
 public class Date extends java.util.Date {
 
-    private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
-
     /**
      * Constructs a <code>Date</code> object initialized with the given
      * year, month, and day.
@@ -168,7 +164,7 @@
         buf[7] = '-';
         Date.formatDecimalInt(day, buf, 8, 2);
 
-        return jla.newStringUnsafe(buf);
+        return new String(buf);
     }
 
     /**
--- a/src/java.sql/share/classes/java/sql/Time.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.sql/share/classes/java/sql/Time.java	Wed Dec 06 14:17:44 2017 +0100
@@ -27,8 +27,6 @@
 
 import java.time.Instant;
 import java.time.LocalTime;
-import jdk.internal.misc.SharedSecrets;
-import jdk.internal.misc.JavaLangAccess;
 
 /**
  * <P>A thin wrapper around the <code>java.util.Date</code> class that allows the JDBC
@@ -43,8 +41,6 @@
  */
 public class Time extends java.util.Date {
 
-    private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
-
     /**
      * Constructs a <code>Time</code> object initialized with the
      * given values for the hour, minute, and second.
@@ -134,7 +130,7 @@
         buf[5] = ':';
         Date.formatDecimalInt(second, buf, 6, 2);
 
-        return jla.newStringUnsafe(buf);
+        return new String(buf);
     }
 
     // Override all the date operations inherited from java.util.Date;
--- a/src/java.sql/share/classes/java/sql/Timestamp.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/java.sql/share/classes/java/sql/Timestamp.java	Wed Dec 06 14:17:44 2017 +0100
@@ -27,8 +27,6 @@
 
 import java.time.Instant;
 import java.time.LocalDateTime;
-import jdk.internal.misc.SharedSecrets;
-import jdk.internal.misc.JavaLangAccess;
 
 /**
  * <P>A thin wrapper around {@code java.util.Date} that allows
@@ -74,8 +72,6 @@
  */
 public class Timestamp extends java.util.Date {
 
-    private static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
-
     /**
      * Constructs a {@code Timestamp} object initialized
      * with the given values.
@@ -313,7 +309,7 @@
         buf[yearSize + 15] = '.';
         Date.formatDecimalInt(tmpNanos, buf, yearSize + 16, 9 - trailingZeros);
 
-        return jla.newStringUnsafe(buf);
+        return new String(buf);
     }
 
     /**
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/JlinkTask.java	Wed Dec 06 14:17:44 2017 +0100
@@ -430,7 +430,7 @@
                                                Set<String> roots)
     {
         if (Objects.requireNonNull(paths).isEmpty()) {
-             throw new IllegalArgumentException("Empty module path");
+             throw new IllegalArgumentException(taskHelper.getMessage("err.empty.module.path"));
         }
 
         Path[] entries = paths.toArray(new Path[0]);
@@ -447,8 +447,13 @@
 
             // java.base version is different than the current runtime version
             version = Runtime.Version.parse(v.toString());
-            if (Runtime.version().major() != version.major()) {
-                finder = ModulePath.of(version, true, entries);
+            if (Runtime.version().major() != version.major() ||
+                Runtime.version().minor() != version.minor()) {
+                // jlink version and java.base version do not match.
+                // We do not (yet) support this mode.
+                throw new IllegalArgumentException(taskHelper.getMessage("err.jlink.version.mismatch",
+                    Runtime.version().major(), Runtime.version().minor(),
+                    version.major(), version.minor()));
             }
         }
 
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java	Wed Dec 06 14:17:44 2017 +0100
@@ -54,11 +54,8 @@
 public final class GenerateJLIClassesPlugin implements Plugin {
 
     private static final String NAME = "generate-jli-classes";
-    private static final String IGNORE_VERSION = "ignore-version";
 
     private static final String DESCRIPTION = PluginsResourceBundle.getDescription(NAME);
-    private static final String IGNORE_VERSION_WARNING = NAME + ".ignore.version.warn";
-    private static final String VERSION_MISMATCH_WARNING = NAME + ".version.mismatch.warn";
 
     private static final String DEFAULT_TRACE_FILE = "default_jli_trace.txt";
 
@@ -85,8 +82,6 @@
 
     String mainArgument;
 
-    boolean ignoreVersion;
-
     public GenerateJLIClassesPlugin() {
     }
 
@@ -170,7 +165,6 @@
     @Override
     public void configure(Map<String, String> config) {
         mainArgument = config.get(NAME);
-        ignoreVersion = Boolean.parseBoolean(config.get(IGNORE_VERSION));
     }
 
     public void initialize(ResourcePool in) {
@@ -208,26 +202,6 @@
         }
     }
 
-    private boolean checkVersion(Runtime.Version linkedVersion) {
-        Runtime.Version baseVersion = Runtime.version();
-        if (baseVersion.major() != linkedVersion.major() ||
-                baseVersion.minor() != linkedVersion.minor()) {
-            return false;
-        }
-        return true;
-    }
-
-    private Runtime.Version getLinkedVersion(ResourcePool in) {
-        ModuleDescriptor.Version version = in.moduleView()
-                .findModule("java.base")
-                .get()
-                .descriptor()
-                .version()
-                .orElseThrow(() -> new PluginException("No version defined in "
-                        + "the java.base being linked"));
-         return Runtime.Version.parse(version.toString());
-    }
-
     private void readTraceConfig(Stream<String> lines) {
         // Use TreeSet/TreeMap to keep things sorted in a deterministic
         // order to avoid scrambling the layout on small changes and to
@@ -315,24 +289,6 @@
 
     @Override
     public ResourcePool transform(ResourcePool in, ResourcePoolBuilder out) {
-        if (ignoreVersion) {
-            System.out.println(
-                    PluginsResourceBundle
-                            .getMessage(IGNORE_VERSION_WARNING));
-        } else if (!checkVersion(getLinkedVersion(in))) {
-            // The linked images are not version compatible
-            if (mainArgument != null) {
-                // Log a mismatch warning if an argument was specified
-                System.out.println(
-                        PluginsResourceBundle
-                                .getMessage(VERSION_MISMATCH_WARNING,
-                                            getLinkedVersion(in),
-                                            Runtime.version()));
-            }
-            in.transformAndCopy(entry -> entry, out);
-            return out.build();
-        }
-
         initialize(in);
         // Copy all but DMH_ENTRY to out
         in.transformAndCopy(entry -> {
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/jlink.properties	Wed Dec 06 14:17:44 2017 +0100
@@ -107,6 +107,8 @@
 error.prefix=Error:
 warn.prefix=Warning:
 
+err.empty.module.path=empty module path
+err.jlink.version.mismatch=jlink version {0}.{1} does not match target java.base version {2}.{3}
 err.automatic.module:automatic module cannot be used with jlink: {0} from {1}
 err.unknown.byte.order:unknown byte order {0}
 err.launcher.main.class.empty:launcher main class name cannot be empty: {0}
--- a/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Wed Dec 06 14:13:50 2017 +0100
+++ b/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties	Wed Dec 06 14:17:44 2017 +0100
@@ -75,7 +75,7 @@
 exclude-jmod-section.description=\
 Specify a JMOD section to exclude
 
-generate-jli-classes.argument=@filename[:ignore-version=<true|false>]
+generate-jli-classes.argument=@filename
 
 generate-jli-classes.description=\
 Specify a file listing the java.lang.invoke classes to pre-generate. \n\
@@ -84,15 +84,6 @@
 created then code generation will be disabled by default to guarantee \n\
 correctness - add ignore-version=true to override this.
 
-generate-jli-classes.ignore.version.warn=\
-WARNING: --generate-jli-classes set to ignore version mismatch between \n\
-JDK running jlink and target image.
-
-generate-jli-classes.version.mismatch.warn=\
-WARNING: Pre-generation of JLI classes is only supported when linking \n\
-the same version of java.base ({0}) as the JDK running jlink ({1}), \n\
-class generation skipped - specify ignore-version to override.
-
 system-modules.argument=retainModuleTarget
 
 system-modules.description=Fast loading of module descriptors (always enabled)
--- a/test/jdk/ProblemList.txt	Wed Dec 06 14:13:50 2017 +0100
+++ b/test/jdk/ProblemList.txt	Wed Dec 06 14:17:44 2017 +0100
@@ -124,8 +124,6 @@
 
 java/lang/StringCoding/CheckEncodings.sh                        7008363 generic-all
 
-jdk/internal/misc/JavaLangAccess/NewUnsafeString.java           8176188 generic-all
-
 java/lang/String/nativeEncoding/StringPlatformChars.java        8182569 windows-all,solaris-all
 
 ############################################################################
--- a/test/jdk/TEST.groups	Wed Dec 06 14:13:50 2017 +0100
+++ b/test/jdk/TEST.groups	Wed Dec 06 14:17:44 2017 +0100
@@ -89,7 +89,6 @@
 jdk_util_other = \
     java/util \
     sun/util \
-    jdk/internal/util \
     -:jdk_collections \
     -:jdk_concurrent \
     -:jdk_stream
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/lang/ClassLoader/RecursiveSystemLoader.java	Wed Dec 06 14:17:44 2017 +0100
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 8187222
+ * @run main/othervm -Djava.system.class.loader=RecursiveSystemLoader RecursiveSystemLoader
+ * @summary Test for IllegalStateException if a custom system loader recursively calls getSystemClassLoader()
+ */
+public class RecursiveSystemLoader extends ClassLoader {
+    public static void main(String[] args) {
+        ClassLoader sys = ClassLoader.getSystemClassLoader();
+        if (!(sys instanceof RecursiveSystemLoader)) {
+            throw new RuntimeException("Unexpected system classloader: " + sys);
+        }
+    }
+    public RecursiveSystemLoader(ClassLoader classLoader) {
+        super("RecursiveSystemLoader", classLoader);
+
+        // Calling ClassLoader.getSystemClassLoader() before the VM is booted
+        // should throw an IllegalStateException.
+        try {
+            ClassLoader.getSystemClassLoader();
+        } catch(IllegalStateException ise) {
+            System.err.println("Caught expected exception:");
+            ise.printStackTrace();
+            return;
+        }
+        throw new RuntimeException("Expected IllegalStateException was not thrown.");
+    }
+
+    @Override
+    public Class<?> loadClass(String name) throws ClassNotFoundException {
+        return super.loadClass(name);
+    }
+}
--- a/test/jdk/java/lang/ModuleLayer/LayerAndLoadersTest.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/test/jdk/java/lang/ModuleLayer/LayerAndLoadersTest.java	Wed Dec 06 14:17:44 2017 +0100
@@ -52,6 +52,7 @@
 import java.util.ServiceLoader;
 import java.util.Set;
 import java.util.stream.Collectors;
+
 import jdk.test.lib.compiler.CompilerUtils;
 
 import org.testng.annotations.BeforeTest;
@@ -78,7 +79,7 @@
      * Basic test of ModuleLayer.defineModulesWithOneLoader
      *
      * Test scenario:
-     *   m1 requires m2 and m3
+     * m1 requires m2 and m3
      */
     public void testWithOneLoader() throws Exception {
         Configuration cf = resolve("m1");
@@ -105,7 +106,7 @@
      * Basic test of ModuleLayer.defineModulesWithManyLoaders
      *
      * Test scenario:
-     *   m1 requires m2 and m3
+     * m1 requires m2 and m3
      */
     public void testWithManyLoaders() throws Exception {
         Configuration cf = resolve("m1");
@@ -136,9 +137,9 @@
      * modules is a service provider module.
      *
      * Test scenario:
-     *    m1 requires m2 and m3
-     *    m1 uses S
-     *    m4 provides S with ...
+     * m1 requires m2 and m3
+     * m1 uses S
+     * m4 provides S with ...
      */
     public void testServicesWithOneLoader() throws Exception {
         Configuration cf = resolveAndBind("m1");
@@ -175,9 +176,9 @@
      * modules is a service provider module.
      *
      * Test scenario:
-     *    m1 requires m2 and m3
-     *    m1 uses S
-     *    m4 provides S with ...
+     * m1 requires m2 and m3
+     * m1 uses S
+     * m4 provides S with ...
      */
     public void testServicesWithManyLoaders() throws Exception {
         Configuration cf = resolveAndBind("m1");
@@ -234,7 +235,7 @@
         ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, parent);
         testLoad(layer, cn);
 
-         // one loader with boot loader as parent
+        // one loader with boot loader as parent
         layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, null);
         testLoadFail(layer, cn);
 
@@ -252,21 +253,21 @@
      * Test defineModulesWithXXX when modules that have overlapping packages.
      *
      * Test scenario:
-     *   m1 exports p
-     *   m2 exports p
+     * m1 exports p
+     * m2 exports p
      */
     public void testOverlappingPackages() {
         ModuleDescriptor descriptor1
-            = ModuleDescriptor.newModule("m1").exports("p").build();
+                = ModuleDescriptor.newModule("m1").exports("p").build();
 
         ModuleDescriptor descriptor2
-            = ModuleDescriptor.newModule("m2").exports("p").build();
+                = ModuleDescriptor.newModule("m2").exports("p").build();
 
         ModuleFinder finder = ModuleUtils.finderOf(descriptor1, descriptor2);
 
         Configuration cf = ModuleLayer.boot()
-            .configuration()
-            .resolve(finder, ModuleFinder.of(), Set.of("m1", "m2"));
+                .configuration()
+                .resolve(finder, ModuleFinder.of(), Set.of("m1", "m2"));
 
         // cannot define both module m1 and m2 to the same class loader
         try {
@@ -284,35 +285,35 @@
      * Test ModuleLayer.defineModulesWithXXX with split delegation.
      *
      * Test scenario:
-     *   layer1: m1 exports p, m2 exports p
-     *   layer2: m3 reads m1, m4 reads m2
+     * layer1: m1 exports p, m2 exports p
+     * layer2: m3 reads m1, m4 reads m2
      */
     public void testSplitDelegation() {
         ModuleDescriptor descriptor1
-            = ModuleDescriptor.newModule("m1").exports("p").build();
+                = ModuleDescriptor.newModule("m1").exports("p").build();
 
         ModuleDescriptor descriptor2
-            = ModuleDescriptor.newModule("m2").exports("p").build();
+                = ModuleDescriptor.newModule("m2").exports("p").build();
 
         ModuleFinder finder1 = ModuleUtils.finderOf(descriptor1, descriptor2);
 
         Configuration cf1 = ModuleLayer.boot()
-            .configuration()
-            .resolve(finder1, ModuleFinder.of(), Set.of("m1", "m2"));
+                .configuration()
+                .resolve(finder1, ModuleFinder.of(), Set.of("m1", "m2"));
 
         ModuleLayer layer1 = ModuleLayer.boot().defineModulesWithManyLoaders(cf1, null);
         checkLayer(layer1, "m1", "m2");
 
         ModuleDescriptor descriptor3
-            = ModuleDescriptor.newModule("m3").requires("m1").build();
+                = ModuleDescriptor.newModule("m3").requires("m1").build();
 
         ModuleDescriptor descriptor4
-            = ModuleDescriptor.newModule("m4").requires("m2").build();
+                = ModuleDescriptor.newModule("m4").requires("m2").build();
 
         ModuleFinder finder2 = ModuleUtils.finderOf(descriptor3, descriptor4);
 
         Configuration cf2 = cf1.resolve(finder2, ModuleFinder.of(),
-                                                Set.of("m3", "m4"));
+                Set.of("m3", "m4"));
 
         // package p cannot be supplied by two class loaders
         try {
@@ -331,8 +332,8 @@
      * named modules in the parent layer.
      *
      * Test scenario:
-     *   layer1: m1, m2, m3 => same loader
-     *   layer2: m1, m2, m4 => same loader
+     * layer1: m1, m2, m3 => same loader
+     * layer2: m1, m2, m4 => same loader
      */
     public void testOverriding1() throws Exception {
         Configuration cf1 = resolve("m1");
@@ -342,7 +343,7 @@
 
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
         Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
-                                                Set.of("m1"));
+                Set.of("m1"));
 
         ModuleLayer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
         checkLayer(layer2, "m1", "m2", "m3");
@@ -378,8 +379,8 @@
      * named modules in the parent layer.
      *
      * Test scenario:
-     *   layer1: m1, m2, m3 => loader pool
-     *   layer2: m1, m2, m3 => loader pool
+     * layer1: m1, m2, m3 => loader pool
+     * layer2: m1, m2, m3 => loader pool
      */
     public void testOverriding2() throws Exception {
         Configuration cf1 = resolve("m1");
@@ -389,7 +390,7 @@
 
         ModuleFinder finder = ModuleFinder.of(MODS_DIR);
         Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
-                                                Set.of("m1"));
+                Set.of("m1"));
 
         ModuleLayer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
         checkLayer(layer2, "m1", "m2", "m3");
@@ -482,7 +483,7 @@
         ModuleFinder finder = finderFor("m1", "m3");
 
         Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
-                                                Set.of("m1"));
+                Set.of("m1"));
 
         ModuleLayer layer2 = layer1.defineModulesWithOneLoader(cf2, null);
         checkLayer(layer2, "m1", "m3");
@@ -517,7 +518,7 @@
         ModuleFinder finder = finderFor("m1", "m3");
 
         Configuration cf2 = cf1.resolve(finder, ModuleFinder.of(),
-                                                Set.of("m1"));
+                Set.of("m1"));
 
         ModuleLayer layer2 = layer1.defineModulesWithManyLoaders(cf2, null);
         checkLayer(layer2, "m1", "m3");
@@ -550,18 +551,27 @@
         assertTrue(loader6.loadClass("w.Hello").getClassLoader() == loader6);
     }
 
-
     /**
      * Basic test for locating resources with a class loader created by
      * defineModulesWithOneLoader.
      */
     public void testResourcesWithOneLoader() throws Exception {
+        testResourcesWithOneLoader(ClassLoader.getSystemClassLoader());
+        testResourcesWithOneLoader(null);
+    }
+
+    /**
+     * Test locating resources with the class loader created by
+     * defineModulesWithOneLoader. The class loader has the given class
+     * loader as its parent.
+     */
+    void testResourcesWithOneLoader(ClassLoader parent) throws Exception {
         Configuration cf = resolve("m1");
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-        ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, scl);
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithOneLoader(cf, parent);
 
         ClassLoader loader = layer.findLoader("m1");
         assertNotNull(loader);
+        assertTrue(loader.getParent() == parent);
 
         // check that getResource and getResources are consistent
         URL url1 = loader.getResource("module-info.class");
@@ -607,14 +617,24 @@
      * defineModulesWithManyLoaders.
      */
     public void testResourcesWithManyLoaders() throws Exception {
+        testResourcesWithManyLoaders(ClassLoader.getSystemClassLoader());
+        testResourcesWithManyLoaders(null);
+    }
+
+    /**
+     * Test locating resources with class loaders created by
+     * defineModulesWithManyLoaders. The class loaders have the given class
+     * loader as their parent.
+     */
+    void testResourcesWithManyLoaders(ClassLoader parent) throws Exception {
         Configuration cf = resolve("m1");
-        ClassLoader scl = ClassLoader.getSystemClassLoader();
-        ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, scl);
+        ModuleLayer layer = ModuleLayer.boot().defineModulesWithManyLoaders(cf, parent);
 
         for (Module m : layer.modules()) {
             String name = m.getName();
             ClassLoader loader = m.getClassLoader();
             assertNotNull(loader);
+            assertTrue(loader.getParent() == parent);
 
             // getResource should find the module-info.class for the module
             URL url = loader.getResource("module-info.class");
--- a/test/jdk/java/text/Format/MessageFormat/MessageRegression.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/test/jdk/java/text/Format/MessageFormat/MessageRegression.java	Wed Dec 06 14:17:44 2017 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,7 @@
  * @test
  * @bug 4031438 4058973 4074764 4094906 4104976 4105380 4106659 4106660 4106661
  * 4111739 4112104 4113018 4114739 4114743 4116444 4118592 4118594 4120552
- * 4142938 4169959 4232154 4293229
+ * 4142938 4169959 4232154 4293229 8187551
  * @summary Regression tests for MessageFormat and associated classes
  * @library /java/text/testlib
  * @run main MessageRegression
@@ -642,4 +642,44 @@
                     expected + "\", got \"" + result + "\"");
         }
     }
+
+    /**
+     * @bug 8187551
+     * test MessageFormat.setFormat() method to throw AIOOBE on invalid index.
+     */
+    public void test8187551() {
+        //invalid cases ("pattern", "invalid format element index")
+        String[][] invalidCases = {{"The disk \"{1}\" contains {0}.", "2"},
+                {"The disk \"{1}\" contains {0}.", "9"},
+                {"On {1}, there are {0} and {2} folders", "3"}};
+
+        //invalid cases (must throw exception)
+        Arrays.stream(invalidCases).forEach(entry -> messageSetFormat(entry[0],
+                Integer.valueOf(entry[1])));
+    }
+
+    // test MessageFormat.setFormat() method for the given pattern and
+    // format element index
+    private void messageSetFormat(String pattern, int elemIndex) {
+        MessageFormat form = new MessageFormat(pattern);
+
+        double[] fileLimits = {0, 1, 2};
+        String[] filePart = {"no files", "one file", "{0,number} files"};
+        ChoiceFormat fileForm = new ChoiceFormat(fileLimits, filePart);
+
+        boolean AIOOBEThrown = false;
+        try {
+            form.setFormat(elemIndex, fileForm);
+        } catch (ArrayIndexOutOfBoundsException ex) {
+            AIOOBEThrown = true;
+        }
+
+        if (!AIOOBEThrown) {
+            throw new RuntimeException("[FAILED: Must throw" +
+                    " ArrayIndexOutOfBoundsException for" +
+                    " invalid index " + elemIndex + " used in" +
+                    " MessageFormat.setFormat(index, format)]");
+        }
+    }
+
 }
--- a/test/jdk/jdk/internal/misc/JavaLangAccess/NewUnsafeString.java	Wed Dec 06 14:13:50 2017 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * 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.util.Objects;
-import java.util.Comparator;
-import jdk.internal.misc.JavaLangAccess;
-import jdk.internal.misc.SharedSecrets;
-
-/*
- * @test
- * @bug 8013528
- * @summary Test JavaLangAccess.newUnsafeString
- * @modules java.base/jdk.internal.misc
- * @compile -XDignore.symbol.file NewUnsafeString.java
- * @run main NewUnsafeString
- */
-public class NewUnsafeString {
-
-    static final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
-
-    public static void testNewUnsafeString() {
-        String benchmark = "exemplar";
-        String constructorCopy = new String(benchmark);
-        char[] jlaChars = benchmark.toCharArray();
-        String jlaCopy = jla.newStringUnsafe(jlaChars);
-
-        if (benchmark == constructorCopy) {
-            throw new Error("should be different instances");
-        }
-        if (!benchmark.equals(constructorCopy)) {
-            throw new Error("Copy not equal");
-        }
-        if (0 != Objects.compare(benchmark, constructorCopy, Comparator.naturalOrder())) {
-            throw new Error("Copy not equal");
-        }
-
-        if (benchmark == jlaCopy) {
-            throw new Error("should be different instances");
-        }
-        if (!benchmark.equals(jlaCopy)) {
-            throw new Error("Copy not equal");
-        }
-        if (0 != Objects.compare(benchmark, jlaCopy, Comparator.naturalOrder())) {
-            throw new Error("Copy not equal");
-        }
-
-        if (constructorCopy == jlaCopy) {
-            throw new Error("should be different instances");
-        }
-        if (!constructorCopy.equals(jlaCopy)) {
-            throw new Error("Copy not equal");
-        }
-        if (0 != Objects.compare(constructorCopy, jlaCopy, Comparator.naturalOrder())) {
-            throw new Error("Copy not equal");
-        }
-
-        // The following is extremely "evil". Never ever do this in non-test code.
-        jlaChars[0] = 'X';
-        if (!"Xxemplar".equals(jlaCopy)) {
-            throw new Error("jla.newStringUnsafe did not use provided string");
-        }
-
-    }
-
-    public static void main(String[] args) {
-        testNewUnsafeString();
-    }
-}
--- a/test/jdk/tools/jlink/multireleasejar/JLinkMRJavaBaseVersionTest.java	Wed Dec 06 14:13:50 2017 +0100
+++ b/test/jdk/tools/jlink/multireleasejar/JLinkMRJavaBaseVersionTest.java	Wed Dec 06 14:17:44 2017 +0100
@@ -25,6 +25,8 @@
  * @test
  * @bug 8177471
  * @summary  jlink should use the version from java.base.jmod to find modules
+ * @bug 8185130
+ * @summary jlink should throw error if target image and current JDK versions don't match
  * @modules java.base/jdk.internal.module
  * @library /test/lib
  * @build jdk.test.lib.process.* CheckRuntimeVersion
@@ -122,7 +124,9 @@
         System.out.println("Testing jlink with " + getJmods() + " of target version " + version);
 
         // use jlink to build image from multi-release jar
-        jlink("m1.jar", "myimage");
+        if (jlink("m1.jar", "myimage")) {
+            return;
+        }
 
         // validate runtime image
         Path java = Paths.get("myimage", "bin", "java");
@@ -130,12 +134,7 @@
 
         // validate the image linked with the proper MR version
 
-        if (version.equalsIgnoreOptional(Runtime.version())) {
-            ProcessTools.executeProcess(java.toString(), "-cp", System.getProperty("test.classes"),
-                                        "CheckRuntimeVersion", String.valueOf(version.major()),
-                                        "java.base", "java.logging", "m1")
-                .shouldHaveExitValue(0);
-        } else {
+        if (!version.equalsIgnoreOptional(Runtime.version())) {
             ProcessTools.executeProcess(java.toString(), "-cp", System.getProperty("test.classes"),
                                         "CheckRuntimeVersion", String.valueOf(version.major()),
                                         "java.base", "m1")
@@ -151,13 +150,19 @@
         return Runtime.Version.parse(mref.descriptor().version().get().toString());
     }
 
-    private void jlink(String jar, String image) {
+    private boolean jlink(String jar, String image) {
         List<String> args = List.of("--output", image,
                                     "--add-modules", "m1",
                                     "--module-path",
                                     getJmods().toString() + File.pathSeparator + jar);
         System.out.println("jlink " + args.stream().collect(Collectors.joining(" ")));
         int exitCode = JLINK_TOOL.run(System.out, System.err, args.toArray(new String[0]));
-        Assert.assertEquals(exitCode, 0);
+        boolean isJDK9 = System.getProperty("java9.home") != null;
+        if (isJDK9) {
+            Assert.assertNotEquals(exitCode, 0);
+        } else {
+            Assert.assertEquals(exitCode, 0);
+        }
+        return isJDK9;
     }
 }