changeset 48672:1dab70e20292

Merge
author lana
date Thu, 18 Jan 2018 18:58:46 +0000
parents 7fc3d62481ba db044d7e9885
children be4d948d1299
files .hgtags make/autoconf/generated-configure.sh make/autoconf/jdk-version.m4 make/autoconf/spec.gmk.in make/hotspot/lib/CompileJvm.gmk src/hotspot/cpu/ppc/macroAssembler_ppc.cpp src/hotspot/cpu/ppc/macroAssembler_ppc.hpp src/hotspot/cpu/ppc/templateTable_ppc_64.cpp src/hotspot/cpu/sparc/templateTable_sparc.cpp src/hotspot/cpu/x86/templateTable_x86.cpp src/hotspot/share/classfile/vmSymbols.hpp src/hotspot/share/code/compiledIC.hpp src/hotspot/share/code/nmethod.cpp src/hotspot/share/jvmci/jvmciCompilerToVM.cpp src/hotspot/share/oops/cpCache.cpp src/hotspot/share/oops/klassVtable.cpp src/hotspot/share/runtime/arguments.cpp src/java.base/share/classes/java/util/ArraysSupport.java src/java.base/share/classes/module-info.java src/java.base/share/classes/sun/security/tools/keytool/Main.java src/java.base/share/conf/security/java.security src/java.base/share/native/include/classfile_constants.h src/java.base/share/native/libjava/System.c src/java.compiler/share/classes/javax/tools/FileManagerUtils.java src/jdk.compiler/share/classes/com/sun/tools/javac/resources/compiler.properties src/jdk.compiler/share/classes/com/sun/tools/javac/util/JDK9Wrappers.java src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CodeGenerator.java src/jdk.unsupported/share/classes/sun/reflect/Reflection.java test/jdk/jdk/internal/reflect/Reflection/GetCallerClassWithDepth.java test/jdk/sun/reflect/Reflection/GetCallerClassWithDepth.java test/jdk/sun/security/pkcs11/PKCS11Test.java
diffstat 611 files changed, 8613 insertions(+), 4385 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Jan 18 09:01:00 2018 -0800
+++ b/.hgtags	Thu Jan 18 18:58:46 2018 +0000
@@ -460,7 +460,8 @@
 bbd692ad4fa300ecca7939ffbe3b1d5e52a28cc6 jdk-10+33
 89deac44e51517841491ba86ff44aa82a5ca96b3 jdk-10+34
 d8c634b016c628622c9abbdc6bf50509e5dedbec jdk-10+35
-cb54a299aa91419cb7caef3992592e7b22488163 jdk-10+36
+0ee20aad71c4f33c426372b4c8bcc1235ce2ec08 jdk-11+0
+959f2f7cbaa6d2ee45d50029744efb219721576c jdk-10+36
 4f830b447edf04fb4a52151a5ad44d9bb60723cd jdk-10+37
 e569e83139fdfbecfeb3cd9014d560917787f158 jdk-10+38
 5b834ec962366e00d4445352a999a3ac14e26f64 jdk-10+39
--- a/make/Main.gmk	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/Main.gmk	Thu Jan 18 18:58:46 2018 +0000
@@ -637,7 +637,7 @@
   # Declare dependencies between hotspot-<variant>* targets
   $(foreach v, $(JVM_VARIANTS), \
       $(eval hotspot-$v: hotspot-$v-gensrc hotspot-$v-libs) \
-      $(eval hotspot-$v-libs: hotspot-$v-gensrc) \
+      $(eval hotspot-$v-libs: hotspot-$v-gensrc java.base-copy) \
   )
 
   hotspot-ide-project: hotspot exploded-image
@@ -691,8 +691,9 @@
   jdk.jdwp.agent-libs: jdk.jdwp.agent-gensrc
 
   # The swing beans need to have java base properly generated to avoid errors
-  # in javadoc.
-  java.desktop-gensrc-src: java.base-gensrc
+  # in javadoc. The X11 wrappers need the java.base include files to have been
+  # copied and processed.
+  java.desktop-gensrc-src: java.base-gensrc java.base-copy
 
   # The annotation processing for jdk.internal.vm.ci and jdk.internal.vm.compiler
   # needs classes from the current JDK.
--- a/make/autoconf/buildjdk-spec.gmk.in	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/autoconf/buildjdk-spec.gmk.in	Thu Jan 18 18:58:46 2018 +0000
@@ -55,6 +55,7 @@
 OPENJDK_TARGET_CPU_BITS := @OPENJDK_BUILD_CPU_BITS@
 OPENJDK_TARGET_CPU_ENDIAN := @OPENJDK_BUILD_CPU_ENDIAN@
 OPENJDK_TARGET_CPU_LEGACY := @OPENJDK_BUILD_CPU_LEGACY@
+OPENJDK_TARGET_OS_INCLUDE_SUBDIR := @OPENJDK_BUILD_OS_INCLUDE_SUBDIR@
 
 HOTSPOT_TARGET_OS := @HOTSPOT_BUILD_OS@
 HOTSPOT_TARGET_OS_TYPE := @HOTSPOT_BUILD_OS_TYPE@
--- a/make/autoconf/flags.m4	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/autoconf/flags.m4	Thu Jan 18 18:58:46 2018 +0000
@@ -1162,9 +1162,7 @@
   # Setup some hard coded includes
   $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \
       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
-      -I${TOPDIR}/src/java.base/share/native/include \
-      -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS/native/include \
-      -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/include \
+      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
       -I${TOPDIR}/src/java.base/share/native/libjava \
       -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/libjava \
       -I${TOPDIR}/src/hotspot/share/include \
--- a/make/autoconf/generated-configure.sh	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/autoconf/generated-configure.sh	Thu Jan 18 18:58:46 2018 +0000
@@ -886,6 +886,8 @@
 BOOT_JDK
 JAVA_CHECK
 JAVAC_CHECK
+VERSION_CLASSFILE_MINOR
+VERSION_CLASSFILE_MAJOR
 VENDOR_VERSION_STRING
 VERSION_DATE
 VERSION_IS_GA
@@ -970,6 +972,7 @@
 USERNAME
 TOPDIR
 PATH_SEP
+OPENJDK_BUILD_OS_INCLUDE_SUBDIR
 HOTSPOT_BUILD_CPU_DEFINE
 HOTSPOT_BUILD_CPU_ARCH
 HOTSPOT_BUILD_CPU
@@ -980,6 +983,7 @@
 OPENJDK_BUILD_CPU_ISADIR
 OPENJDK_BUILD_CPU_LEGACY_LIB
 OPENJDK_BUILD_CPU_LEGACY
+OPENJDK_TARGET_OS_INCLUDE_SUBDIR
 HOTSPOT_TARGET_CPU_DEFINE
 HOTSPOT_TARGET_CPU_ARCH
 HOTSPOT_TARGET_CPU
@@ -16318,6 +16322,14 @@
   fi
 
 
+  # For historical reasons, the OS include directories have odd names.
+  OPENJDK_TARGET_OS_INCLUDE_SUBDIR="$OPENJDK_TARGET_OS"
+  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+    OPENJDK_TARGET_OS_INCLUDE_SUBDIR="win32"
+  elif test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
+    OPENJDK_TARGET_OS_INCLUDE_SUBDIR="darwin"
+  fi
+
 
 
   # Also store the legacy naming of the cpu.
@@ -16469,6 +16481,14 @@
   fi
 
 
+  # For historical reasons, the OS include directories have odd names.
+  OPENJDK_BUILD_OS_INCLUDE_SUBDIR="$OPENJDK_TARGET_OS"
+  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+    OPENJDK_BUILD_OS_INCLUDE_SUBDIR="win32"
+  elif test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
+    OPENJDK_BUILD_OS_INCLUDE_SUBDIR="darwin"
+  fi
+
 
 
 
@@ -25524,6 +25544,10 @@
     VENDOR_VERSION_STRING="$with_vendor_version_string"
   fi
 
+  # We could define --with flags for these, if really needed
+  VERSION_CLASSFILE_MAJOR="$DEFAULT_VERSION_CLASSFILE_MAJOR"
+  VERSION_CLASSFILE_MINOR="$DEFAULT_VERSION_CLASSFILE_MINOR"
+
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version string" >&5
 $as_echo_n "checking for version string... " >&6; }
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: $VERSION_STRING" >&5
@@ -25545,6 +25569,9 @@
 
 
 
+
+
+
 ###############################################################################
 #
 # Setup BootJDK, used to bootstrap the build.
@@ -52817,9 +52844,7 @@
   # Setup some hard coded includes
   COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \
       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
-      -I${TOPDIR}/src/java.base/share/native/include \
-      -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS/native/include \
-      -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/include \
+      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
       -I${TOPDIR}/src/java.base/share/native/libjava \
       -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \
       -I${TOPDIR}/src/hotspot/share/include \
@@ -53700,9 +53725,7 @@
   # Setup some hard coded includes
   OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK \
       -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
-      -I${TOPDIR}/src/java.base/share/native/include \
-      -I${TOPDIR}/src/java.base/$OPENJDK_BUILD_OS/native/include \
-      -I${TOPDIR}/src/java.base/$OPENJDK_BUILD_OS_TYPE/native/include \
+      -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
       -I${TOPDIR}/src/java.base/share/native/libjava \
       -I${TOPDIR}/src/java.base/$OPENJDK_BUILD_OS_TYPE/native/libjava \
       -I${TOPDIR}/src/hotspot/share/include \
--- a/make/autoconf/jdk-version.m4	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/autoconf/jdk-version.m4	Thu Jan 18 18:58:46 2018 +0000
@@ -381,6 +381,10 @@
     VENDOR_VERSION_STRING="$with_vendor_version_string"
   fi
 
+  # We could define --with flags for these, if really needed
+  VERSION_CLASSFILE_MAJOR="$DEFAULT_VERSION_CLASSFILE_MAJOR"
+  VERSION_CLASSFILE_MINOR="$DEFAULT_VERSION_CLASSFILE_MINOR"
+
   AC_MSG_CHECKING([for version string])
   AC_MSG_RESULT([$VERSION_STRING])
 
@@ -398,4 +402,7 @@
   AC_SUBST(VERSION_IS_GA)
   AC_SUBST(VERSION_DATE)
   AC_SUBST(VENDOR_VERSION_STRING)
+  AC_SUBST(VERSION_CLASSFILE_MAJOR)
+  AC_SUBST(VERSION_CLASSFILE_MINOR)
+
 ])
--- a/make/autoconf/platform.m4	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/autoconf/platform.m4	Thu Jan 18 18:58:46 2018 +0000
@@ -478,6 +478,14 @@
   fi
   AC_SUBST(HOTSPOT_$1_CPU_DEFINE)
 
+  # For historical reasons, the OS include directories have odd names.
+  OPENJDK_$1_OS_INCLUDE_SUBDIR="$OPENJDK_TARGET_OS"
+  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+    OPENJDK_$1_OS_INCLUDE_SUBDIR="win32"
+  elif test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
+    OPENJDK_$1_OS_INCLUDE_SUBDIR="darwin"
+  fi
+  AC_SUBST(OPENJDK_$1_OS_INCLUDE_SUBDIR)
 ])
 
 AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES],
--- a/make/autoconf/spec.gmk.in	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/autoconf/spec.gmk.in	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 #
-# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -78,6 +78,7 @@
 OPENJDK_TARGET_CPU_LEGACY:=@OPENJDK_TARGET_CPU_LEGACY@
 OPENJDK_TARGET_CPU_LEGACY_LIB:=@OPENJDK_TARGET_CPU_LEGACY_LIB@
 OPENJDK_TARGET_CPU_OSARCH:=@OPENJDK_TARGET_CPU_OSARCH@
+OPENJDK_TARGET_OS_INCLUDE_SUBIDR:=@OPENJDK_TARGET_OS_INCLUDE_SUBDIR@
 
 HOTSPOT_TARGET_OS := @HOTSPOT_TARGET_OS@
 HOTSPOT_TARGET_OS_TYPE := @HOTSPOT_TARGET_OS_TYPE@
@@ -100,6 +101,8 @@
 OPENJDK_BUILD_CPU_BITS:=@OPENJDK_BUILD_CPU_BITS@
 OPENJDK_BUILD_CPU_ENDIAN:=@OPENJDK_BUILD_CPU_ENDIAN@
 
+OPENJDK_BUILD_OS_INCLUDE_SUBIDR:=@OPENJDK_TARGET_OS_INCLUDE_SUBDIR@
+
 # Target platform value in ModuleTarget class file attribute.
 OPENJDK_MODULE_TARGET_PLATFORM:=@OPENJDK_MODULE_TARGET_PLATFORM@
 
@@ -189,6 +192,10 @@
 # Vendor version string
 VENDOR_VERSION_STRING := @VENDOR_VERSION_STRING@
 
+# Class-file version
+VERSION_CLASSFILE_MAJOR := @VERSION_CLASSFILE_MAJOR@
+VERSION_CLASSFILE_MINOR := @VERSION_CLASSFILE_MINOR@
+
 # Convenience CFLAGS settings for passing version information into native programs.
 VERSION_CFLAGS := \
     -DVERSION_FEATURE=$(VERSION_FEATURE) \
@@ -204,6 +211,8 @@
     -DVERSION_SPECIFICATION='"$(VERSION_SPECIFICATION)"' \
     -DVERSION_DATE='"$(VERSION_DATE)"' \
     -DVENDOR_VERSION_STRING='"$(VENDOR_VERSION_STRING)"' \
+    -DVERSION_CLASSFILE_MAJOR=$(VERSION_CLASSFILE_MAJOR) \
+    -DVERSION_CLASSFILE_MINOR=$(VERSION_CLASSFILE_MINOR) \
     #
 
 ifneq ($(COMPANY_NAME),)
@@ -604,6 +613,8 @@
 INTERIM_LANGTOOLS_MODULES := $(addsuffix .interim, $(INTERIM_LANGTOOLS_BASE_MODULES))
 INTERIM_LANGTOOLS_ADD_EXPORTS := \
     --add-exports java.base/sun.reflect.annotation=jdk.compiler.interim \
+    --add-exports java.base/jdk.internal.jmod=jdk.compiler.interim \
+    --add-exports java.base/jdk.internal.misc=jdk.compiler.interim \
     #
 INTERIM_LANGTOOLS_MODULES_COMMA := $(strip $(subst $(SPACE),$(COMMA),$(strip \
     $(INTERIM_LANGTOOLS_MODULES))))
--- a/make/autoconf/version-numbers	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/autoconf/version-numbers	Thu Jan 18 18:58:46 2018 +0000
@@ -30,6 +30,8 @@
 DEFAULT_VERSION_UPDATE=0
 DEFAULT_VERSION_PATCH=0
 DEFAULT_VERSION_DATE=2018-03-20
+DEFAULT_VERSION_CLASSFILE_MAJOR=55  # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`"
+DEFAULT_VERSION_CLASSFILE_MINOR=0
 
 LAUNCHER_NAME=openjdk
 PRODUCT_NAME=OpenJDK
--- a/make/common/SetupJavaCompilers.gmk	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/common/SetupJavaCompilers.gmk	Thu Jan 18 18:58:46 2018 +0000
@@ -69,7 +69,7 @@
 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \
     JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 10 -target 10 --doclint-format html5 \
+    FLAGS := -source 11 -target 11 --doclint-format html5 \
         -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
@@ -79,7 +79,7 @@
 $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \
     JVM := $(JAVA_JAVAC), \
     JAVAC := $(NEW_JAVAC), \
-    FLAGS := -source 10 -target 10 \
+    FLAGS := -source 11 -target 11 \
         -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS), \
     SERVER_DIR := $(SJAVAC_SERVER_DIR), \
     SERVER_JVM := $(SJAVAC_SERVER_JAVA)))
--- a/make/conf/jib-profiles.js	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/conf/jib-profiles.js	Thu Jan 18 18:58:46 2018 +0000
@@ -829,7 +829,7 @@
         jtreg: {
             server: "javare",
             revision: "4.2",
-            build_number: "b10",
+            build_number: "b11",
             checksum_file: "MD5_VALUES",
             file: "jtreg_bin-4.2.zip",
             environment_name: "JT_HOME",
--- a/make/copy/Copy-java.base.gmk	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/copy/Copy-java.base.gmk	Thu Jan 18 18:58:46 2018 +0000
@@ -24,6 +24,7 @@
 #
 
 include CopyCommon.gmk
+include TextFileProcessing.gmk
 
 $(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk))
 
@@ -244,3 +245,16 @@
 endif
 
 ################################################################################
+# Generate classfile_constants.h
+
+$(eval $(call SetupTextFileProcessing, CREATE_CLASSFILE_CONSTANTS_H, \
+    SOURCE_FILES := $(TOPDIR)/src/java.base/share/native/include/classfile_constants.h.template, \
+    OUTPUT_FILE := $(SUPPORT_OUTPUTDIR)/modules_include/java.base/classfile_constants.h, \
+    REPLACEMENTS := \
+        @@VERSION_CLASSFILE_MAJOR@@ => $(VERSION_CLASSFILE_MAJOR) ; \
+        @@VERSION_CLASSFILE_MINOR@@ => $(VERSION_CLASSFILE_MINOR) ; , \
+))
+
+TARGETS += $(CREATE_CLASSFILE_CONSTANTS_H)
+
+################################################################################
--- a/make/copy/CopyCommon.gmk	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/copy/CopyCommon.gmk	Thu Jan 18 18:58:46 2018 +0000
@@ -39,20 +39,12 @@
   $(eval $(call SetupCopyFiles, COPY_EXPORTED_INCLUDE, \
       SRC := $(INCLUDE_SOURCE_DIR), \
       DEST := $(INCLUDE_TARGET_DIR), \
-      FILES := $(shell $(FIND) $(INCLUDE_SOURCE_DIR) -type f), \
+      FILES := $(filter %.h, $(call CacheFind, $(INCLUDE_SOURCE_DIR))), \
   ))
 
   TARGETS += $(COPY_EXPORTED_INCLUDE)
 endif
 
-# For historical reasons, the OS include directories have odd names.
-INCLUDE_TARGET_OS_SUBDIR := $(OPENJDK_TARGET_OS)
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  INCLUDE_TARGET_OS_SUBDIR := win32
-else ifeq ($(OPENJDK_TARGET_OS), macosx)
-  INCLUDE_TARGET_OS_SUBDIR := darwin
-endif
-
 # Use the most specific of OS and OS_TYPE.
 INCLUDE_SOURCE_OS_DIR := $(TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS)/native/include
 ifeq ($(wildcard $(INCLUDE_SOURCE_OS_DIR)/*), )
@@ -62,8 +54,8 @@
 ifneq ($(wildcard $(INCLUDE_SOURCE_OS_DIR)/*), )
   $(eval $(call SetupCopyFiles, COPY_EXPORTED_INCLUDE_OS, \
       SRC := $(INCLUDE_SOURCE_OS_DIR), \
-      DEST := $(INCLUDE_TARGET_DIR)/$(INCLUDE_TARGET_OS_SUBDIR), \
-      FILES := $(shell $(FIND) $(INCLUDE_SOURCE_OS_DIR) -type f), \
+      DEST := $(INCLUDE_TARGET_DIR)/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR), \
+      FILES := $(filter %.h, $(call CacheFind, $(INCLUDE_SOURCE_OS_DIR))), \
   ))
 
   TARGETS += $(COPY_EXPORTED_INCLUDE_OS)
--- a/make/gensrc/GensrcX11Wrappers.gmk	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/gensrc/GensrcX11Wrappers.gmk	Thu Jan 18 18:58:46 2018 +0000
@@ -92,10 +92,10 @@
   endif
 
   SIZER_CFLAGS := \
-      -I${TOPDIR}/src/hotspot/share/include \
-      -I${TOPDIR}/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \
-      -I$(TOPDIR)/src/java.base/share/native/include \
-      -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/include \
+      -I$(TOPDIR)/src/hotspot/share/include \
+      -I$(TOPDIR)/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \
+      -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
+      -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
       -I$(TOPDIR)/src/java.base/share/native/libjava \
       -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \
       -I$(TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \
--- a/make/hotspot/lib/CompileJvm.gmk	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/hotspot/lib/CompileJvm.gmk	Thu Jan 18 18:58:46 2018 +0000
@@ -59,8 +59,8 @@
     -I$(TOPDIR)/src/hotspot/share/precompiled \
     -I$(TOPDIR)/src/hotspot/share/include \
     -I$(TOPDIR)/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \
-    -I$(TOPDIR)/src/java.base/share/native/include \
-    -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/include \
+    -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base \
+    -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \
     -I$(TOPDIR)/src/java.base/share/native/libjimage \
     #
 
--- a/make/mapfiles/libjava/mapfile-vers	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/mapfiles/libjava/mapfile-vers	Thu Jan 18 18:58:46 2018 +0000
@@ -258,7 +258,6 @@
 		Java_jdk_internal_reflect_NativeConstructorAccessorImpl_newInstance0;
 		Java_jdk_internal_reflect_NativeMethodAccessorImpl_invoke0;
 		Java_jdk_internal_reflect_Reflection_getCallerClass__;
-		Java_jdk_internal_reflect_Reflection_getCallerClass__I;
 		Java_jdk_internal_reflect_Reflection_getClassAccessFlags;
 		Java_jdk_internal_misc_VM_latestUserDefinedLoader0;
                 Java_jdk_internal_misc_VM_getuid;
--- a/make/mapfiles/libjava/reorder-sparc	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/mapfiles/libjava/reorder-sparc	Thu Jan 18 18:58:46 2018 +0000
@@ -27,7 +27,6 @@
 text: .text%Java_java_io_FileOutputStream_initIDs;
 text: .text%Java_java_lang_System_setIn0;
 text: .text%Java_sun_reflect_Reflection_getCallerClass__;
-text: .text%Java_sun_reflect_Reflection_getCallerClass__I;
 text: .text%Java_java_lang_Class_forName0;
 text: .text%Java_java_lang_Object_getClass;
 text: .text%Java_sun_reflect_Reflection_getClassAccessFlags;
--- a/make/mapfiles/libjava/reorder-sparcv9	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/mapfiles/libjava/reorder-sparcv9	Thu Jan 18 18:58:46 2018 +0000
@@ -26,7 +26,6 @@
 text: .text%Java_java_io_FileOutputStream_initIDs;
 text: .text%Java_java_lang_System_setIn0;
 text: .text%Java_sun_reflect_Reflection_getCallerClass__;
-text: .text%Java_sun_reflect_Reflection_getCallerClass__I;
 text: .text%Java_java_lang_Class_forName0;
 text: .text%Java_java_lang_String_intern;
 text: .text%Java_java_lang_StringUTF16_isBigEndian;
--- a/make/mapfiles/libjava/reorder-x86	Thu Jan 18 09:01:00 2018 -0800
+++ b/make/mapfiles/libjava/reorder-x86	Thu Jan 18 18:58:46 2018 +0000
@@ -27,7 +27,6 @@
 text: .text%Java_java_io_FileOutputStream_initIDs;
 text: .text%Java_java_lang_System_setIn0;
 text: .text%Java_sun_reflect_Reflection_getCallerClass__;
-text: .text%Java_sun_reflect_Reflection_getCallerClass__I;
 text: .text%Java_java_lang_Class_forName0;
 text: .text%Java_java_lang_String_intern;
 text: .text%Java_java_lang_StringUTF16_isBigEndian;
--- a/src/hotspot/cpu/aarch64/aarch64.ad	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/aarch64/aarch64.ad	Thu Jan 18 18:58:46 2018 +0000
@@ -5844,8 +5844,8 @@
 operand immByteMapBase()
 %{
   // Get base of card map
-  predicate((jbyte*)n->get_ptr() ==
-        ((CardTableModRefBS*)(Universe::heap()->barrier_set()))->byte_map_base);
+  predicate(Universe::heap()->barrier_set()->is_a(BarrierSet::CardTableModRef) &&
+    (jbyte*)n->get_ptr() == ((CardTableModRefBS*)(Universe::heap()->barrier_set()))->byte_map_base);
   match(ConP);
 
   op_cost(0);
--- a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -848,7 +848,7 @@
   // architecture.  In debug mode we shrink it in order to test
   // trampolines, but not so small that branches in the interpreter
   // are out of range.
-  static const unsigned long branch_range = INCLUDE_JVMCI ? 128 * M : NOT_DEBUG(128 * M) DEBUG_ONLY(2 * M);
+  static const unsigned long branch_range = NOT_DEBUG(128 * M) DEBUG_ONLY(2 * M);
 
   static bool reachable_from_branch_at(address branch, address target) {
     return uabs(target - branch) < branch_range;
--- a/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -71,6 +71,13 @@
   return 7 * NativeInstruction::instruction_size;
 }
 
+int CompiledStaticCall::to_trampoline_stub_size() {
+  // Somewhat pessimistically, we count 3 instructions here (although
+  // there are only two) because we sometimes emit an alignment nop.
+  // Trampoline stubs are always word aligned.
+  return 3 * NativeInstruction::instruction_size + wordSize;
+}
+
 // Relocation entries for call stub, compiled java to interpreter.
 int CompiledStaticCall::reloc_to_interp_stub() {
   return 4; // 3 in emit_to_interp_stub + 1 in emit_call
--- a/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -109,7 +109,7 @@
   TRACE_jvmci_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst));
 }
 
-void CodeInstaller::pd_relocate_JavaMethod(Handle hotspot_method, jint pc_offset, TRAPS) {
+void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &cbuf, Handle hotspot_method, jint pc_offset, TRAPS) {
 #ifdef ASSERT
   Method* method = NULL;
   // we need to check, this might also be an unresolved method
@@ -124,22 +124,22 @@
     case INVOKEINTERFACE: {
       assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface");
       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
-      call->set_destination(SharedRuntime::get_resolve_virtual_call_stub());
       _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc));
+      call->trampoline_jump(cbuf, SharedRuntime::get_resolve_virtual_call_stub());
       break;
     }
     case INVOKESTATIC: {
       assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic");
       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
-      call->set_destination(SharedRuntime::get_resolve_static_call_stub());
       _instructions->relocate(call->instruction_address(), relocInfo::static_call_type);
+      call->trampoline_jump(cbuf, SharedRuntime::get_resolve_static_call_stub());
       break;
     }
     case INVOKESPECIAL: {
       assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial");
       NativeCall* call = nativeCall_at(_instructions->start() + pc_offset);
-      call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub());
       _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type);
+      call->trampoline_jump(cbuf, SharedRuntime::get_resolve_opt_virtual_call_stub());
       break;
     }
     default:
--- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -801,7 +801,7 @@
   assert(is_NativeCallTrampolineStub_at(stub_start_addr), "doesn't look like a trampoline");
 
   end_a_stub();
-  return stub;
+  return stub_start_addr;
 }
 
 address MacroAssembler::ic_call(address entry, jint method_index) {
--- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -367,3 +367,24 @@
   set_ptr_at(data_offset, new_destination);
   OrderAccess::release();
 }
+
+// Generate a trampoline for a branch to dest.  If there's no need for a
+// trampoline, simply patch the call directly to dest.
+address NativeCall::trampoline_jump(CodeBuffer &cbuf, address dest) {
+  MacroAssembler a(&cbuf);
+  address stub = NULL;
+
+  if (a.far_branches()
+      && ! is_NativeCallTrampolineStub_at(instruction_address() + displacement())) {
+    stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest);
+  }
+
+  if (stub == NULL) {
+    // If we generated no stub, patch this call directly to dest.
+    // This will happen if we don't need far branches or if there
+    // already was a trampoline.
+    set_destination(dest);
+  }
+
+  return stub;
+}
--- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -61,7 +61,7 @@
     return uint_at(0);
   }
 
-  bool is_blr()                      const { return (encoding() & 0xfffffc1f) == 0xd63f0000; }
+  bool is_blr()                      const { return (encoding() & 0xff9ffc1f) == 0xd61f0000; } // blr(register) or br(register)
   bool is_adr_aligned()              const { return (encoding() & 0xff000000) == 0x10000000; } // adr Xn, <label>, where label is aligned to 4 bytes (address of instruction).
 
   inline bool is_nop();
@@ -143,8 +143,9 @@
 }
 
 inline NativeCall* nativeCall_at(address address);
-// The NativeCall is an abstraction for accessing/manipulating native call imm32/rel32off
-// instructions (used to manipulate inline caches, primitive & dll calls, etc.).
+// The NativeCall is an abstraction for accessing/manipulating native
+// call instructions (used to manipulate inline caches, primitive &
+// DSO calls, etc.).
 
 class NativeCall: public NativeInstruction {
  public:
@@ -155,7 +156,6 @@
     return_address_offset       =    4
   };
 
-  enum { cache_line_size = BytesPerWord };  // conservative estimate!
   address instruction_address() const       { return addr_at(instruction_offset); }
   address next_instruction_address() const  { return addr_at(return_address_offset); }
   int   displacement() const                { return (int_at(displacement_offset) << 6) >> 4; }
@@ -206,6 +206,7 @@
   void set_destination_mt_safe(address dest, bool assert_lock = true);
 
   address get_trampoline();
+  address trampoline_jump(CodeBuffer &cbuf, address dest);
 };
 
 inline NativeCall* nativeCall_at(address address) {
--- a/src/hotspot/cpu/aarch64/relocInfo_aarch64.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/aarch64/relocInfo_aarch64.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -35,4 +35,10 @@
     format_width       =  0
   };
 
+ public:
+
+  // This platform has no oops in the code that are not also
+  // listed in the oop section.
+  static bool mustIterateImmediateOopsInCode() { return false; }
+
 #endif // CPU_AARCH64_VM_RELOCINFO_AARCH64_HPP
--- a/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/aarch64/templateTable_aarch64.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -3404,7 +3404,6 @@
   Label done;
   Label initialize_header;
   Label initialize_object; // including clearing the fields
-  Label allocate_shared;
 
   __ get_cpool_and_tags(r4, r0);
   // Make sure the class we're about to instantiate has been resolved.
@@ -3433,18 +3432,24 @@
   // test to see if it has a finalizer or is malformed in some way
   __ tbnz(r3, exact_log2(Klass::_lh_instance_slow_path_bit), slow_case);
 
-  // Allocate the instance
-  // 1) Try to allocate in the TLAB
-  // 2) if fail and the object is large allocate in the shared Eden
-  // 3) if the above fails (or is not applicable), go to a slow case
-  // (creates a new TLAB, etc.)
-
+  // Allocate the instance:
+  //  If TLAB is enabled:
+  //    Try to allocate in the TLAB.
+  //    If fails, go to the slow path.
+  //  Else If inline contiguous allocations are enabled:
+  //    Try to allocate in eden.
+  //    If fails due to heap end, go to slow path.
+  //
+  //  If TLAB is enabled OR inline contiguous is enabled:
+  //    Initialize the allocation.
+  //    Exit.
+  //
+  //  Go to slow path.
   const bool allow_shared_alloc =
     Universe::heap()->supports_inline_contig_alloc();
 
   if (UseTLAB) {
-    __ tlab_allocate(r0, r3, 0, noreg, r1,
-                     allow_shared_alloc ? allocate_shared : slow_case);
+    __ tlab_allocate(r0, r3, 0, noreg, r1, slow_case);
 
     if (ZeroTLAB) {
       // the fields have been already cleared
@@ -3453,19 +3458,19 @@
       // initialize both the header and fields
       __ b(initialize_object);
     }
+  } else {
+    // Allocation in the shared Eden, if allowed.
+    //
+    // r3: instance size in bytes
+    if (allow_shared_alloc) {
+      __ eden_allocate(r0, r3, 0, r10, slow_case);
+      __ incr_allocated_bytes(rthread, r3, 0, rscratch1);
+    }
   }
 
-  // Allocation in the shared Eden, if allowed.
-  //
-  // r3: instance size in bytes
-  if (allow_shared_alloc) {
-    __ bind(allocate_shared);
-
-    __ eden_allocate(r0, r3, 0, r10, slow_case);
-    __ incr_allocated_bytes(rthread, r3, 0, rscratch1);
-  }
-
-  if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
+  // If UseTLAB or allow_shared_alloc are true, the object is created above and
+  // there is an initialize need. Otherwise, skip and go to the slow path.
+  if (UseTLAB || allow_shared_alloc) {
     // The object is initialized before the header.  If the object size is
     // zero, go directly to the header initialization.
     __ bind(initialize_object);
--- a/src/hotspot/cpu/arm/relocInfo_arm.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/arm/relocInfo_arm.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -32,4 +32,10 @@
     format_width = 0
   };
 
+ public:
+
+  // This platform has no oops in the code that are not also
+  // listed in the oop section.
+  static bool mustIterateImmediateOopsInCode() { return false; }
+
 #endif // CPU_ARM_VM_RELOCINFO_ARM_HPP
--- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -5604,12 +5604,17 @@
 
 #endif // !PRODUCT
 
-SkipIfEqualZero::SkipIfEqualZero(MacroAssembler* masm, Register temp, const bool* flag_addr) : _masm(masm), _label() {
+void SkipIfEqualZero::skip_to_label_if_equal_zero(MacroAssembler* masm, Register temp,
+                                                  const bool* flag_addr, Label& label) {
   int simm16_offset = masm->load_const_optimized(temp, (address)flag_addr, R0, true);
   assert(sizeof(bool) == 1, "PowerPC ABI");
   masm->lbz(temp, simm16_offset, temp);
   masm->cmpwi(CCR0, temp, 0);
-  masm->beq(CCR0, _label);
+  masm->beq(CCR0, label);
+}
+
+SkipIfEqualZero::SkipIfEqualZero(MacroAssembler* masm, Register temp, const bool* flag_addr) : _masm(masm), _label() {
+  skip_to_label_if_equal_zero(masm, temp, flag_addr, _label);
 }
 
 SkipIfEqualZero::~SkipIfEqualZero() {
--- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -980,6 +980,8 @@
  public:
    // 'Temp' is a temp register that this object can use (and trash).
    explicit SkipIfEqualZero(MacroAssembler*, Register temp, const bool* flag_addr);
+   static void skip_to_label_if_equal_zero(MacroAssembler*, Register temp,
+                                           const bool* flag_addr, Label& label);
    ~SkipIfEqualZero();
 };
 
--- a/src/hotspot/cpu/ppc/relocInfo_ppc.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/ppc/relocInfo_ppc.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2013 SAP SE. All rights reserved.
+ * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2018 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -43,4 +43,10 @@
 #endif
   };
 
+ public:
+
+  // This platform has no oops in the code that are not also
+  // listed in the oop section.
+  static bool mustIterateImmediateOopsInCode() { return false; }
+
 #endif // CPU_PPC_VM_RELOCINFO_PPC_HPP
--- a/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/ppc/templateTable_ppc_64.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -3637,10 +3637,7 @@
   transition(vtos, atos);
 
   Label Lslow_case,
-        Ldone,
-        Linitialize_header,
-        Lallocate_shared,
-        Linitialize_object;  // Including clearing the fields.
+        Ldone;
 
   const Register RallocatedObject = R17_tos,
                  RinstanceKlass   = R9_ARG7,
@@ -3651,8 +3648,6 @@
                  Rtags            = R3_ARG1,
                  Rindex           = R5_ARG3;
 
-  const bool allow_shared_alloc = Universe::heap()->supports_inline_contig_alloc();
-
   // --------------------------------------------------------------------------
   // Check if fast case is possible.
 
@@ -3661,6 +3656,8 @@
   // Load index of constant pool entry.
   __ get_2_byte_integer_at_bcp(1, Rindex, InterpreterMacroAssembler::Unsigned);
 
+  // Note: compared to other architectures, PPC's implementation always goes
+  // to the slow path if TLAB is used and fails.
   if (UseTLAB) {
     // Make sure the class we're about to instantiate has been resolved
     // This is done before loading instanceKlass to be consistent with the order
@@ -3690,8 +3687,7 @@
     // Fast case:
     // Allocate the instance.
     // 1) Try to allocate in the TLAB.
-    // 2) If fail, and the TLAB is not full enough to discard, allocate in the shared Eden.
-    // 3) If the above fails (or is not applicable), go to a slow case (creates a new TLAB, etc.).
+    // 2) If the above fails (or is not applicable), go to a slow case (creates a new TLAB, etc.).
 
     Register RoldTopValue = RallocatedObject; // Object will be allocated here if it fits.
     Register RnewTopValue = R6_ARG4;
@@ -3705,53 +3701,13 @@
 
     // If there is enough space, we do not CAS and do not clear.
     __ cmpld(CCR0, RnewTopValue, RendValue);
-    __ bgt(CCR0, allow_shared_alloc ? Lallocate_shared : Lslow_case);
+    __ bgt(CCR0, Lslow_case);
 
     __ std(RnewTopValue, in_bytes(JavaThread::tlab_top_offset()), R16_thread);
 
-    if (ZeroTLAB) {
-      // The fields have already been cleared.
-      __ b(Linitialize_header);
-    } else {
-      // Initialize both the header and fields.
-      __ b(Linitialize_object);
-    }
-
-    // Fall through: TLAB was too small.
-    if (allow_shared_alloc) {
-      Register RtlabWasteLimitValue = R10_ARG8;
-      Register RfreeValue = RnewTopValue;
-
-      __ bind(Lallocate_shared);
-      // Check if tlab should be discarded (refill_waste_limit >= free).
-      __ ld(RtlabWasteLimitValue, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), R16_thread);
-      __ subf(RfreeValue, RoldTopValue, RendValue);
-      __ srdi(RfreeValue, RfreeValue, LogHeapWordSize); // in dwords
-      __ cmpld(CCR0, RtlabWasteLimitValue, RfreeValue);
-      __ bge(CCR0, Lslow_case);
-
-      // Increment waste limit to prevent getting stuck on this slow path.
-      __ add_const_optimized(RtlabWasteLimitValue, RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment());
-      __ std(RtlabWasteLimitValue, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), R16_thread);
-    }
-    // else: No allocation in the shared eden. // fallthru: __ b(Lslow_case);
-  }
-  // else: Always go the slow path.
-
-  // --------------------------------------------------------------------------
-  // slow case
-  __ bind(Lslow_case);
-  call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), Rcpool, Rindex);
-
-  if (UseTLAB) {
-    __ b(Ldone);
-    // --------------------------------------------------------------------------
-    // Init1: Zero out newly allocated memory.
-
-    if (!ZeroTLAB || allow_shared_alloc) {
-      // Clear object fields.
-      __ bind(Linitialize_object);
-
+    if (!ZeroTLAB) {
+      // --------------------------------------------------------------------------
+      // Init1: Zero out newly allocated memory.
       // Initialize remaining object fields.
       Register Rbase = Rtags;
       __ addi(Rinstance_size, Rinstance_size, 7 - (int)sizeof(oopDesc));
@@ -3760,13 +3716,10 @@
 
       // Clear out object skipping header. Takes also care of the zero length case.
       __ clear_memory_doubleword(Rbase, Rinstance_size);
-      // fallthru: __ b(Linitialize_header);
     }
 
     // --------------------------------------------------------------------------
     // Init2: Initialize the header: mark, klass
-    __ bind(Linitialize_header);
-
     // Init mark.
     if (UseBiasedLocking) {
       __ ld(Rscratch, in_bytes(Klass::prototype_header_offset()), RinstanceKlass);
@@ -3780,14 +3733,19 @@
     __ store_klass(RallocatedObject, RinstanceKlass, Rscratch); // klass (last for cms)
 
     // Check and trigger dtrace event.
-    {
-      SkipIfEqualZero skip_if(_masm, Rscratch, &DTraceAllocProbes);
-      __ push(atos);
-      __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc));
-      __ pop(atos);
-    }
+    SkipIfEqualZero::skip_to_label_if_equal_zero(_masm, Rscratch, &DTraceAllocProbes, Ldone);
+    __ push(atos);
+    __ call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_object_alloc));
+    __ pop(atos);
+
+    __ b(Ldone);
   }
 
+  // --------------------------------------------------------------------------
+  // slow case
+  __ bind(Lslow_case);
+  call_VM(R17_tos, CAST_FROM_FN_PTR(address, InterpreterRuntime::_new), Rcpool, Rindex);
+
   // continue
   __ bind(Ldone);
 
--- a/src/hotspot/cpu/s390/relocInfo_s390.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/s390/relocInfo_s390.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2016 SAP SE. All rights reserved.
+ * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2016, 2018 SAP SE. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -110,6 +110,10 @@
     pcrel_data_format   = 3   // Relocation is for the target data of a pc-relative instruction.
   };
 
+  // This platform has no oops in the code that are not also
+  // listed in the oop section.
+  static bool mustIterateImmediateOopsInCode() { return false; }
+
   // Store the new target address into an oop_Relocation cell, if any.
   // Return indication if update happened.
   static bool update_oop_pool(address begin, address end, address newTarget, CodeBlob* cb);
--- a/src/hotspot/cpu/sparc/compiledIC_sparc.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/sparc/compiledIC_sparc.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -73,6 +73,11 @@
 }
 #undef __
 
+int CompiledStaticCall::to_trampoline_stub_size() {
+  // SPARC doesn't use trampolines.
+  return 0;
+}
+
 int CompiledStaticCall::to_interp_stub_size() {
   // This doesn't need to be accurate but it must be larger or equal to
   // the real size of the stub.
--- a/src/hotspot/cpu/sparc/jvmciCodeInstaller_sparc.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/sparc/jvmciCodeInstaller_sparc.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -115,7 +115,7 @@
   TRACE_jvmci_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst));
 }
 
-void CodeInstaller::pd_relocate_JavaMethod(Handle hotspot_method, jint pc_offset, TRAPS) {
+void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &, Handle hotspot_method, jint pc_offset, TRAPS) {
 #ifdef ASSERT
   Method* method = NULL;
   // we need to check, this might also be an unresolved method
--- a/src/hotspot/cpu/sparc/relocInfo_sparc.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/sparc/relocInfo_sparc.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -38,6 +38,11 @@
     format_width       =  1
   };
 
+ public:
+
+  // This platform has no oops in the code that are not also
+  // listed in the oop section.
+  static bool mustIterateImmediateOopsInCode() { return false; }
 
 //Reconciliation History
 // 1.3 97/10/15 15:38:36 relocInfo_i486.hpp
--- a/src/hotspot/cpu/sparc/templateTable_sparc.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/sparc/templateTable_sparc.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -3259,11 +3259,19 @@
   __ br(Assembler::notZero, false, Assembler::pn, slow_case);
   __ delayed()->nop();
 
-  // allocate the instance
-  // 1) Try to allocate in the TLAB
-  // 2) if fail, and the TLAB is not full enough to discard, allocate in the shared Eden
-  // 3) if the above fails (or is not applicable), go to a slow case
-  // (creates a new TLAB, etc.)
+  // Allocate the instance:
+  //  If TLAB is enabled:
+  //    Try to allocate in the TLAB.
+  //    If fails, go to the slow path.
+  //  Else If inline contiguous allocations are enabled:
+  //    Try to allocate in eden.
+  //    If fails due to heap end, go to slow path.
+  //
+  //  If TLAB is enabled OR inline contiguous is enabled:
+  //    Initialize the allocation.
+  //    Exit.
+  //
+  //  Go to slow path.
 
   const bool allow_shared_alloc =
     Universe::heap()->supports_inline_contig_alloc();
@@ -3291,61 +3299,43 @@
     }
     __ delayed()->st_ptr(RnewTopValue, G2_thread, in_bytes(JavaThread::tlab_top_offset()));
 
+    // Allocation does not fit in the TLAB.
+    __ ba_short(slow_case);
+  } else {
+    // Allocation in the shared Eden
     if (allow_shared_alloc) {
-      // Check if tlab should be discarded (refill_waste_limit >= free)
-      __ ld_ptr(G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()), RtlabWasteLimitValue);
-      __ sub(RendValue, RoldTopValue, RfreeValue);
-      __ srlx(RfreeValue, LogHeapWordSize, RfreeValue);
-      __ cmp_and_brx_short(RtlabWasteLimitValue, RfreeValue, Assembler::greaterEqualUnsigned, Assembler::pt, slow_case); // tlab waste is small
-
-      // increment waste limit to prevent getting stuck on this slow path
-      if (Assembler::is_simm13(ThreadLocalAllocBuffer::refill_waste_limit_increment())) {
-        __ add(RtlabWasteLimitValue, ThreadLocalAllocBuffer::refill_waste_limit_increment(), RtlabWasteLimitValue);
-      } else {
-        // set64 does not use the temp register if the given constant is 32 bit. So
-        // we can just use any register; using G0 results in ignoring of the upper 32 bit
-        // of that value.
-        __ set64(ThreadLocalAllocBuffer::refill_waste_limit_increment(), G4_scratch, G0);
-        __ add(RtlabWasteLimitValue, G4_scratch, RtlabWasteLimitValue);
-      }
-      __ st_ptr(RtlabWasteLimitValue, G2_thread, in_bytes(JavaThread::tlab_refill_waste_limit_offset()));
-    } else {
-      // No allocation in the shared eden.
-      __ ba_short(slow_case);
+      Register RoldTopValue = G1_scratch;
+      Register RtopAddr = G3_scratch;
+      Register RnewTopValue = RallocatedObject;
+      Register RendValue = Rscratch;
+
+      __ set((intptr_t)Universe::heap()->top_addr(), RtopAddr);
+
+      Label retry;
+      __ bind(retry);
+      __ set((intptr_t)Universe::heap()->end_addr(), RendValue);
+      __ ld_ptr(RendValue, 0, RendValue);
+      __ ld_ptr(RtopAddr, 0, RoldTopValue);
+      __ add(RoldTopValue, Roffset, RnewTopValue);
+
+      // RnewTopValue contains the top address after the new object
+      // has been allocated.
+      __ cmp_and_brx_short(RnewTopValue, RendValue, Assembler::greaterUnsigned, Assembler::pn, slow_case);
+
+      __ cas_ptr(RtopAddr, RoldTopValue, RnewTopValue);
+
+      // if someone beat us on the allocation, try again, otherwise continue
+      __ cmp_and_brx_short(RoldTopValue, RnewTopValue, Assembler::notEqual, Assembler::pn, retry);
+
+      // bump total bytes allocated by this thread
+      // RoldTopValue and RtopAddr are dead, so can use G1 and G3
+      __ incr_allocated_bytes(Roffset, G1_scratch, G3_scratch);
     }
   }
 
-  // Allocation in the shared Eden
-  if (allow_shared_alloc) {
-    Register RoldTopValue = G1_scratch;
-    Register RtopAddr = G3_scratch;
-    Register RnewTopValue = RallocatedObject;
-    Register RendValue = Rscratch;
-
-    __ set((intptr_t)Universe::heap()->top_addr(), RtopAddr);
-
-    Label retry;
-    __ bind(retry);
-    __ set((intptr_t)Universe::heap()->end_addr(), RendValue);
-    __ ld_ptr(RendValue, 0, RendValue);
-    __ ld_ptr(RtopAddr, 0, RoldTopValue);
-    __ add(RoldTopValue, Roffset, RnewTopValue);
-
-    // RnewTopValue contains the top address after the new object
-    // has been allocated.
-    __ cmp_and_brx_short(RnewTopValue, RendValue, Assembler::greaterUnsigned, Assembler::pn, slow_case);
-
-    __ cas_ptr(RtopAddr, RoldTopValue, RnewTopValue);
-
-    // if someone beat us on the allocation, try again, otherwise continue
-    __ cmp_and_brx_short(RoldTopValue, RnewTopValue, Assembler::notEqual, Assembler::pn, retry);
-
-    // bump total bytes allocated by this thread
-    // RoldTopValue and RtopAddr are dead, so can use G1 and G3
-    __ incr_allocated_bytes(Roffset, G1_scratch, G3_scratch);
-  }
-
-  if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
+  // If UseTLAB or allow_shared_alloc are true, the object is created above and
+  // there is an initialize need. Otherwise, skip and go to the slow path.
+  if (UseTLAB || allow_shared_alloc) {
     // clear object fields
     __ bind(initialize_object);
     __ deccc(Roffset, sizeof(oopDesc));
--- a/src/hotspot/cpu/x86/assembler_x86.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/x86/assembler_x86.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -3167,6 +3167,89 @@
     return;
   }
 
+  if (UseAddressNop && VM_Version::is_zx()) {
+    //
+    // Using multi-bytes nops "0x0F 0x1F [address]" for ZX
+    //  1: 0x90
+    //  2: 0x66 0x90
+    //  3: 0x66 0x66 0x90 (don't use "0x0F 0x1F 0x00" - need patching safe padding)
+    //  4: 0x0F 0x1F 0x40 0x00
+    //  5: 0x0F 0x1F 0x44 0x00 0x00
+    //  6: 0x66 0x0F 0x1F 0x44 0x00 0x00
+    //  7: 0x0F 0x1F 0x80 0x00 0x00 0x00 0x00
+    //  8: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
+    //  9: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
+    // 10: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
+    // 11: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00
+
+    // The rest coding is ZX specific - don't use consecutive address nops
+
+    // 12: 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
+    // 13: 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
+    // 14: 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
+    // 15: 0x66 0x66 0x66 0x0F 0x1F 0x84 0x00 0x00 0x00 0x00 0x00 0x66 0x66 0x66 0x90
+
+    while (i >= 15) {
+      // For ZX don't generate consecutive addess nops (mix with regular nops)
+      i -= 15;
+      emit_int8(0x66);   // size prefix
+      emit_int8(0x66);   // size prefix
+      emit_int8(0x66);   // size prefix
+      addr_nop_8();
+      emit_int8(0x66);   // size prefix
+      emit_int8(0x66);   // size prefix
+      emit_int8(0x66);   // size prefix
+      emit_int8((unsigned char)0x90);
+                         // nop
+    }
+    switch (i) {
+      case 14:
+        emit_int8(0x66); // size prefix
+      case 13:
+        emit_int8(0x66); // size prefix
+      case 12:
+        addr_nop_8();
+        emit_int8(0x66); // size prefix
+        emit_int8(0x66); // size prefix
+        emit_int8(0x66); // size prefix
+        emit_int8((unsigned char)0x90);
+                         // nop
+        break;
+      case 11:
+        emit_int8(0x66); // size prefix
+      case 10:
+        emit_int8(0x66); // size prefix
+      case 9:
+        emit_int8(0x66); // size prefix
+      case 8:
+        addr_nop_8();
+        break;
+      case 7:
+        addr_nop_7();
+        break;
+      case 6:
+        emit_int8(0x66); // size prefix
+      case 5:
+        addr_nop_5();
+        break;
+      case 4:
+        addr_nop_4();
+        break;
+      case 3:
+        // Don't use "0x0F 0x1F 0x00" - need patching safe padding
+        emit_int8(0x66); // size prefix
+      case 2:
+        emit_int8(0x66); // size prefix
+      case 1:
+        emit_int8((unsigned char)0x90);
+                         // nop
+        break;
+      default:
+        assert(i == 0, " ");
+    }
+    return;
+  }
+
   // Using nops with size prefixes "0x66 0x90".
   // From AMD Optimization Guide:
   //  1: 0x90
--- a/src/hotspot/cpu/x86/compiledIC_x86.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/x86/compiledIC_x86.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -73,6 +73,11 @@
          LP64_ONLY(15);  // movq (1+1+8); jmp (1+4)
 }
 
+int CompiledStaticCall::to_trampoline_stub_size() {
+  // x86 doesn't use trampolines.
+  return 0;
+}
+
 // Relocation entries for call stub, compiled java to interpreter.
 int CompiledStaticCall::reloc_to_interp_stub() {
   return 4; // 3 in emit_to_interp_stub + 1 in emit_call
--- a/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -144,7 +144,7 @@
   TRACE_jvmci_3("relocating (foreign call)  at " PTR_FORMAT, p2i(inst));
 }
 
-void CodeInstaller::pd_relocate_JavaMethod(Handle hotspot_method, jint pc_offset, TRAPS) {
+void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &, Handle hotspot_method, jint pc_offset, TRAPS) {
 #ifdef ASSERT
   Method* method = NULL;
   // we need to check, this might also be an unresolved method
--- a/src/hotspot/cpu/x86/relocInfo_x86.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/x86/relocInfo_x86.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -40,4 +40,10 @@
 #endif
   };
 
+ public:
+
+  // Instruct loadConP of x86_64.ad places oops in code that are not also
+  // listed in the oop section.
+  static bool mustIterateImmediateOopsInCode() { return true; }
+
 #endif // CPU_X86_VM_RELOCINFO_X86_HPP
--- a/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_32.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -433,7 +433,7 @@
 
 
   //----------------------------------------------------------------------------------------------------
-  // Support for jint Atomic::xchg(jint exchange_value, volatile jint* dest)
+  // Support for int32_t Atomic::xchg(int32_t exchange_value, volatile int32_t* dest)
   //
   // xchg exists as far back as 8086, lock needed for MP only
   // Stack layout immediately after call:
--- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -611,8 +611,8 @@
     return start;
   }
 
-  // Support for jbyte atomic::atomic_cmpxchg(jbyte exchange_value, volatile jbyte* dest,
-  //                                          jbyte compare_value)
+  // Support for int8_t atomic::atomic_cmpxchg(int8_t exchange_value, volatile int8_t* dest,
+  //                                           int8_t compare_value)
   //
   // Arguments :
   //    c_rarg0: exchange_value
@@ -637,9 +637,9 @@
     return start;
   }
 
-  // Support for jlong atomic::atomic_cmpxchg(jlong exchange_value,
-  //                                          volatile jlong* dest,
-  //                                          jlong compare_value)
+  // Support for int64_t atomic::atomic_cmpxchg(int64_t exchange_value,
+  //                                            volatile int64_t* dest,
+  //                                            int64_t compare_value)
   // Arguments :
   //    c_rarg0: exchange_value
   //    c_rarg1: dest
@@ -694,8 +694,8 @@
   // Result:
   //    *dest += add_value
   //    return *dest;
-  address generate_atomic_add_ptr() {
-    StubCodeMark mark(this, "StubRoutines", "atomic_add_ptr");
+  address generate_atomic_add_long() {
+    StubCodeMark mark(this, "StubRoutines", "atomic_add_long");
     address start = __ pc();
 
     __ movptr(rax, c_rarg0); // Copy to eax we need a return value anyhow
@@ -5015,14 +5015,14 @@
     StubRoutines::_catch_exception_entry = generate_catch_exception();
 
     // atomic calls
-    StubRoutines::_atomic_xchg_entry         = generate_atomic_xchg();
-    StubRoutines::_atomic_xchg_long_entry    = generate_atomic_xchg_long();
-    StubRoutines::_atomic_cmpxchg_entry      = generate_atomic_cmpxchg();
-    StubRoutines::_atomic_cmpxchg_byte_entry = generate_atomic_cmpxchg_byte();
-    StubRoutines::_atomic_cmpxchg_long_entry = generate_atomic_cmpxchg_long();
-    StubRoutines::_atomic_add_entry          = generate_atomic_add();
-    StubRoutines::_atomic_add_ptr_entry      = generate_atomic_add_ptr();
-    StubRoutines::_fence_entry               = generate_orderaccess_fence();
+    StubRoutines::_atomic_xchg_entry          = generate_atomic_xchg();
+    StubRoutines::_atomic_xchg_long_entry     = generate_atomic_xchg_long();
+    StubRoutines::_atomic_cmpxchg_entry       = generate_atomic_cmpxchg();
+    StubRoutines::_atomic_cmpxchg_byte_entry  = generate_atomic_cmpxchg_byte();
+    StubRoutines::_atomic_cmpxchg_long_entry  = generate_atomic_cmpxchg_long();
+    StubRoutines::_atomic_add_entry           = generate_atomic_add();
+    StubRoutines::_atomic_add_long_entry      = generate_atomic_add_long();
+    StubRoutines::_fence_entry                = generate_orderaccess_fence();
 
     // platform dependent
     StubRoutines::x86::_get_previous_fp_entry = generate_get_previous_fp();
--- a/src/hotspot/cpu/x86/templateTable_x86.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/x86/templateTable_x86.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -3869,7 +3869,6 @@
   Label done;
   Label initialize_header;
   Label initialize_object;  // including clearing the fields
-  Label allocate_shared;
 
   __ get_cpool_and_tags(rcx, rax);
 
@@ -3895,12 +3894,19 @@
   __ testl(rdx, Klass::_lh_instance_slow_path_bit);
   __ jcc(Assembler::notZero, slow_case);
 
+  // Allocate the instance:
+  //  If TLAB is enabled:
+  //    Try to allocate in the TLAB.
+  //    If fails, go to the slow path.
+  //  Else If inline contiguous allocations are enabled:
+  //    Try to allocate in eden.
+  //    If fails due to heap end, go to slow path.
   //
-  // Allocate the instance
-  // 1) Try to allocate in the TLAB
-  // 2) if fail and the object is large allocate in the shared Eden
-  // 3) if the above fails (or is not applicable), go to a slow case
-  // (creates a new TLAB, etc.)
+  //  If TLAB is enabled OR inline contiguous is enabled:
+  //    Initialize the allocation.
+  //    Exit.
+  //
+  //  Go to slow path.
 
   const bool allow_shared_alloc =
     Universe::heap()->supports_inline_contig_alloc();
@@ -3916,7 +3922,7 @@
     __ movptr(rax, Address(thread, in_bytes(JavaThread::tlab_top_offset())));
     __ lea(rbx, Address(rax, rdx, Address::times_1));
     __ cmpptr(rbx, Address(thread, in_bytes(JavaThread::tlab_end_offset())));
-    __ jcc(Assembler::above, allow_shared_alloc ? allocate_shared : slow_case);
+    __ jcc(Assembler::above, slow_case);
     __ movptr(Address(thread, in_bytes(JavaThread::tlab_top_offset())), rbx);
     if (ZeroTLAB) {
       // the fields have been already cleared
@@ -3925,40 +3931,40 @@
       // initialize both the header and fields
       __ jmp(initialize_object);
     }
+  } else {
+    // Allocation in the shared Eden, if allowed.
+    //
+    // rdx: instance size in bytes
+    if (allow_shared_alloc) {
+      ExternalAddress heap_top((address)Universe::heap()->top_addr());
+      ExternalAddress heap_end((address)Universe::heap()->end_addr());
+
+      Label retry;
+      __ bind(retry);
+      __ movptr(rax, heap_top);
+      __ lea(rbx, Address(rax, rdx, Address::times_1));
+      __ cmpptr(rbx, heap_end);
+      __ jcc(Assembler::above, slow_case);
+
+      // Compare rax, with the top addr, and if still equal, store the new
+      // top addr in rbx, at the address of the top addr pointer. Sets ZF if was
+      // equal, and clears it otherwise. Use lock prefix for atomicity on MPs.
+      //
+      // rax,: object begin
+      // rbx,: object end
+      // rdx: instance size in bytes
+      __ locked_cmpxchgptr(rbx, heap_top);
+
+      // if someone beat us on the allocation, try again, otherwise continue
+      __ jcc(Assembler::notEqual, retry);
+
+      __ incr_allocated_bytes(thread, rdx, 0);
+    }
   }
 
-  // Allocation in the shared Eden, if allowed.
-  //
-  // rdx: instance size in bytes
-  if (allow_shared_alloc) {
-    __ bind(allocate_shared);
-
-    ExternalAddress heap_top((address)Universe::heap()->top_addr());
-    ExternalAddress heap_end((address)Universe::heap()->end_addr());
-
-    Label retry;
-    __ bind(retry);
-    __ movptr(rax, heap_top);
-    __ lea(rbx, Address(rax, rdx, Address::times_1));
-    __ cmpptr(rbx, heap_end);
-    __ jcc(Assembler::above, slow_case);
-
-    // Compare rax, with the top addr, and if still equal, store the new
-    // top addr in rbx, at the address of the top addr pointer. Sets ZF if was
-    // equal, and clears it otherwise. Use lock prefix for atomicity on MPs.
-    //
-    // rax,: object begin
-    // rbx,: object end
-    // rdx: instance size in bytes
-    __ locked_cmpxchgptr(rbx, heap_top);
-
-    // if someone beat us on the allocation, try again, otherwise continue
-    __ jcc(Assembler::notEqual, retry);
-
-    __ incr_allocated_bytes(thread, rdx, 0);
-  }
-
-  if (UseTLAB || Universe::heap()->supports_inline_contig_alloc()) {
+  // If UseTLAB or allow_shared_alloc are true, the object is created above and
+  // there is an initialize need. Otherwise, skip and go to the slow path.
+  if (UseTLAB || allow_shared_alloc) {
     // The object is initialized before the header.  If the object size is
     // zero, go directly to the header initialization.
     __ bind(initialize_object);
--- a/src/hotspot/cpu/x86/vm_version_x86.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/x86/vm_version_x86.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -628,6 +628,11 @@
   if (UseSSE < 1)
     _features &= ~CPU_SSE;
 
+  //since AVX instructions is slower than SSE in some ZX cpus, force USEAVX=0.
+  if (is_zx() && ((cpu_family() == 6) || (cpu_family() == 7))) {
+    UseAVX = 0;
+  }
+
   // first try initial setting and detect what we can support
   int use_avx_limit = 0;
   if (UseAVX > 0) {
@@ -1078,6 +1083,66 @@
   // UseXmmRegToRegMoveAll == true  --> movaps(xmm, xmm), movapd(xmm, xmm).
   // UseXmmRegToRegMoveAll == false --> movss(xmm, xmm),  movsd(xmm, xmm).
 
+
+  if (is_zx()) { // ZX cpus specific settings
+    if (FLAG_IS_DEFAULT(UseStoreImmI16)) {
+      UseStoreImmI16 = false; // don't use it on ZX cpus
+    }
+    if ((cpu_family() == 6) || (cpu_family() == 7)) {
+      if (FLAG_IS_DEFAULT(UseAddressNop)) {
+        // Use it on all ZX cpus
+        UseAddressNop = true;
+      }
+    }
+    if (FLAG_IS_DEFAULT(UseXmmLoadAndClearUpper)) {
+      UseXmmLoadAndClearUpper = true; // use movsd on all ZX cpus
+    }
+    if (FLAG_IS_DEFAULT(UseXmmRegToRegMoveAll)) {
+      if (supports_sse3()) {
+        UseXmmRegToRegMoveAll = true; // use movaps, movapd on new ZX cpus
+      } else {
+        UseXmmRegToRegMoveAll = false;
+      }
+    }
+    if (((cpu_family() == 6) || (cpu_family() == 7)) && supports_sse3()) { // new ZX cpus
+#ifdef COMPILER2
+      if (FLAG_IS_DEFAULT(MaxLoopPad)) {
+        // For new ZX cpus do the next optimization:
+        // don't align the beginning of a loop if there are enough instructions
+        // left (NumberOfLoopInstrToAlign defined in c2_globals.hpp)
+        // in current fetch line (OptoLoopAlignment) or the padding
+        // is big (> MaxLoopPad).
+        // Set MaxLoopPad to 11 for new ZX cpus to reduce number of
+        // generated NOP instructions. 11 is the largest size of one
+        // address NOP instruction '0F 1F' (see Assembler::nop(i)).
+        MaxLoopPad = 11;
+      }
+#endif // COMPILER2
+      if (FLAG_IS_DEFAULT(UseXMMForArrayCopy)) {
+        UseXMMForArrayCopy = true; // use SSE2 movq on new ZX cpus
+      }
+      if (supports_sse4_2()) { // new ZX cpus
+        if (FLAG_IS_DEFAULT(UseUnalignedLoadStores)) {
+          UseUnalignedLoadStores = true; // use movdqu on newest ZX cpus
+        }
+      }
+      if (supports_sse4_2()) {
+        if (FLAG_IS_DEFAULT(UseSSE42Intrinsics)) {
+          FLAG_SET_DEFAULT(UseSSE42Intrinsics, true);
+        }
+      } else {
+        if (UseSSE42Intrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) {
+          warning("SSE4.2 intrinsics require SSE4.2 instructions or higher. Intrinsics will be disabled.");
+        }
+        FLAG_SET_DEFAULT(UseSSE42Intrinsics, false);
+      }
+    }
+
+    if (FLAG_IS_DEFAULT(AllocatePrefetchInstr) && supports_3dnow_prefetch()) {
+      FLAG_SET_DEFAULT(AllocatePrefetchInstr, 3);
+    }
+  }
+
   if( is_amd() ) { // AMD cpus specific settings
     if( supports_sse2() && FLAG_IS_DEFAULT(UseAddressNop) ) {
       // Use it on new AMD cpus starting from Opteron.
@@ -1374,6 +1439,14 @@
 #endif
   }
 
+  if (is_zx() && ((cpu_family() == 6) || (cpu_family() == 7)) && supports_sse4_2()) {
+#ifdef COMPILER2
+    if (FLAG_IS_DEFAULT(UseFPUForSpilling)) {
+      FLAG_SET_DEFAULT(UseFPUForSpilling, true);
+    }
+#endif
+  }
+
 #ifdef _LP64
   // Prefetch settings
 
--- a/src/hotspot/cpu/x86/vm_version_x86.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/x86/vm_version_x86.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -305,6 +305,9 @@
   enum Extended_Family {
     // AMD
     CPU_FAMILY_AMD_11H       = 0x11,
+    // ZX
+    CPU_FAMILY_ZX_CORE_F6    = 6,
+    CPU_FAMILY_ZX_CORE_F7    = 7,
     // Intel
     CPU_FAMILY_INTEL_CORE    = 6,
     CPU_MODEL_NEHALEM        = 0x1e,
@@ -549,6 +552,16 @@
       }
     }
 
+    // ZX features.
+    if (is_zx()) {
+      if (_cpuid_info.ext_cpuid1_ecx.bits.lzcnt_intel != 0)
+        result |= CPU_LZCNT;
+      // for ZX, ecx.bits.misalignsse bit (bit 8) indicates support for prefetchw
+      if (_cpuid_info.ext_cpuid1_ecx.bits.misalignsse != 0) {
+        result |= CPU_3DNOW_PREFETCH;
+      }
+    }
+
     return result;
   }
 
@@ -657,6 +670,7 @@
   static bool is_P6()             { return cpu_family() >= 6; }
   static bool is_amd()            { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x68747541; } // 'htuA'
   static bool is_intel()          { assert_is_initialized(); return _cpuid_info.std_vendor_name_0 == 0x756e6547; } // 'uneG'
+  static bool is_zx()             { assert_is_initialized(); return (_cpuid_info.std_vendor_name_0 == 0x746e6543) || (_cpuid_info.std_vendor_name_0 == 0x68532020); } // 'tneC'||'hS  '
   static bool is_atom_family()    { return ((cpu_family() == 0x06) && ((extended_cpu_model() == 0x36) || (extended_cpu_model() == 0x37) || (extended_cpu_model() == 0x4D))); } //Silvermont and Centerton
   static bool is_knights_family() { return ((cpu_family() == 0x06) && ((extended_cpu_model() == 0x57) || (extended_cpu_model() == 0x85))); } // Xeon Phi 3200/5200/7200 and Future Xeon Phi
 
@@ -680,6 +694,15 @@
       }
     } else if (is_amd()) {
       result = (_cpuid_info.ext_cpuid8_ecx.bits.cores_per_cpu + 1);
+    } else if (is_zx()) {
+      bool supports_topology = supports_processor_topology();
+      if (supports_topology) {
+        result = _cpuid_info.tpl_cpuidB1_ebx.bits.logical_cpus /
+                 _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus;
+      }
+      if (!supports_topology || result == 0) {
+        result = (_cpuid_info.dcp_cpuid4_eax.bits.cores_per_cpu + 1);
+      }
     }
     return result;
   }
@@ -688,6 +711,8 @@
     uint result = 1;
     if (is_intel() && supports_processor_topology()) {
       result = _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus;
+    } else if (is_zx() && supports_processor_topology()) {
+      result = _cpuid_info.tpl_cpuidB0_ebx.bits.logical_cpus;
     } else if (_cpuid_info.std_cpuid1_edx.bits.ht != 0) {
       if (cpu_family() >= 0x17) {
         result = _cpuid_info.ext_cpuid1E_ebx.bits.threads_per_core + 1;
@@ -705,6 +730,8 @@
       result = (_cpuid_info.dcp_cpuid4_ebx.bits.L1_line_size + 1);
     } else if (is_amd()) {
       result = _cpuid_info.ext_cpuid5_ecx.bits.L1_line_size;
+    } else if (is_zx()) {
+      result = (_cpuid_info.dcp_cpuid4_ebx.bits.L1_line_size + 1);
     }
     if (result < 32) // not defined ?
       result = 32;   // 32 bytes by default on x86 and other x64
--- a/src/hotspot/cpu/zero/relocInfo_zero.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/zero/relocInfo_zero.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -34,4 +34,8 @@
     format_width =  1
   };
 
+ public:
+
+  static bool mustIterateImmediateOopsInCode() { return true; }
+
 #endif // CPU_ZERO_VM_RELOCINFO_ZERO_HPP
--- a/src/hotspot/cpu/zero/stubGenerator_zero.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/cpu/zero/stubGenerator_zero.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -258,7 +258,7 @@
     StubRoutines::_atomic_cmpxchg_byte_entry = ShouldNotCallThisStub();
     StubRoutines::_atomic_cmpxchg_long_entry = ShouldNotCallThisStub();
     StubRoutines::_atomic_add_entry          = ShouldNotCallThisStub();
-    StubRoutines::_atomic_add_ptr_entry      = ShouldNotCallThisStub();
+    StubRoutines::_atomic_add_long_entry     = ShouldNotCallThisStub();
     StubRoutines::_fence_entry               = ShouldNotCallThisStub();
   }
 
--- a/src/hotspot/os_cpu/bsd_x86/atomic_bsd_x86.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/bsd_x86/atomic_bsd_x86.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -132,8 +132,8 @@
 
 extern "C" {
   // defined in bsd_x86.s
-  jlong _Atomic_cmpxchg_long(jlong, volatile jlong*, jlong, bool);
-  void _Atomic_move_long(const volatile jlong* src, volatile jlong* dst);
+  int64_t _Atomic_cmpxchg_long(int64_t, volatile int64_t*, int64_t, bool);
+  void _Atomic_move_long(const volatile int64_t* src, volatile int64_t* dst);
 }
 
 template<>
@@ -143,15 +143,15 @@
                                                 T compare_value,
                                                 cmpxchg_memory_order order) const {
   STATIC_ASSERT(8 == sizeof(T));
-  return cmpxchg_using_helper<jlong>(_Atomic_cmpxchg_long, exchange_value, dest, compare_value);
+  return cmpxchg_using_helper<int64_t>(_Atomic_cmpxchg_long, exchange_value, dest, compare_value);
 }
 
 template<>
 template<typename T>
 inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
   STATIC_ASSERT(8 == sizeof(T));
-  volatile jlong dest;
-  _Atomic_move_long(reinterpret_cast<const volatile jlong*>(src), reinterpret_cast<volatile jlong*>(&dest));
+  volatile int64_t dest;
+  _Atomic_move_long(reinterpret_cast<const volatile int64_t*>(src), reinterpret_cast<volatile int64_t*>(&dest));
   return PrimitiveConversions::cast<T>(dest);
 }
 
@@ -160,7 +160,7 @@
 inline void Atomic::PlatformStore<8>::operator()(T store_value,
                                                  T volatile* dest) const {
   STATIC_ASSERT(8 == sizeof(T));
-  _Atomic_move_long(reinterpret_cast<const volatile jlong*>(&store_value), reinterpret_cast<volatile jlong*>(dest));
+  _Atomic_move_long(reinterpret_cast<const volatile int64_t*>(&store_value), reinterpret_cast<volatile int64_t*>(dest));
 }
 
 #endif // AMD64
--- a/src/hotspot/os_cpu/bsd_x86/bsd_x86_32.s	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/bsd_x86/bsd_x86_32.s	Thu Jan 18 18:58:46 2018 +0000
@@ -633,10 +633,10 @@
         ret
 
 
-        # Support for jlong Atomic::cmpxchg(jlong exchange_value,
-        #                                   volatile jlong* dest,
-        #                                   jlong compare_value,
-        #                                   bool is_MP)
+        # Support for int64_t Atomic::cmpxchg(int64_t exchange_value,
+        #                                     volatile int64_t* dest,
+        #                                     int64_t compare_value,
+        #                                     bool is_MP)
         #
         .p2align 4,,15
         ELF_TYPE(_Atomic_cmpxchg_long,@function)
@@ -658,8 +658,8 @@
         ret
 
 
-        # Support for jlong Atomic::load and Atomic::store.
-        # void _Atomic_move_long(const volatile jlong* src, volatile jlong* dst)
+        # Support for int64_t Atomic::load and Atomic::store.
+        # void _Atomic_move_long(const volatile int64_t* src, volatile int64_t* dst)
         .p2align 4,,15
         ELF_TYPE(_Atomic_move_long,@function)
 SYMBOL(_Atomic_move_long):
--- a/src/hotspot/os_cpu/bsd_zero/atomic_bsd_zero.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/bsd_zero/atomic_bsd_zero.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -265,8 +265,8 @@
 template<typename T>
 inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
   STATIC_ASSERT(8 == sizeof(T));
-  volatile jlong dest;
-  os::atomic_copy64(reinterpret_cast<const volatile jlong*>(src), reinterpret_cast<volatile jlong*>(&dest));
+  volatile int64_t dest;
+  os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(src), reinterpret_cast<volatile int64_t*>(&dest));
   return PrimitiveConversions::cast<T>(dest);
 }
 
@@ -275,7 +275,7 @@
 inline void Atomic::PlatformStore<8>::operator()(T store_value,
                                                  T volatile* dest) const {
   STATIC_ASSERT(8 == sizeof(T));
-  os::atomic_copy64(reinterpret_cast<const volatile jlong*>(&store_value), reinterpret_cast<volatile jlong*>(dest));
+  os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(&store_value), reinterpret_cast<volatile int64_t*>(dest));
 }
 
 #endif // OS_CPU_BSD_ZERO_VM_ATOMIC_BSD_ZERO_HPP
--- a/src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -50,7 +50,7 @@
 inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
   STATIC_ASSERT(8 == sizeof(T));
   return PrimitiveConversions::cast<T>(
-    (*os::atomic_load_long_func)(reinterpret_cast<const volatile jlong*>(src)));
+    (*os::atomic_load_long_func)(reinterpret_cast<const volatile int64_t*>(src)));
 }
 
 template<>
@@ -59,7 +59,7 @@
                                                  T volatile* dest) const {
   STATIC_ASSERT(8 == sizeof(T));
   (*os::atomic_store_long_func)(
-    PrimitiveConversions::cast<jlong>(store_value), reinterpret_cast<volatile jlong*>(dest));
+    PrimitiveConversions::cast<int64_t>(store_value), reinterpret_cast<volatile int64_t*>(dest));
 }
 #endif
 
@@ -103,7 +103,7 @@
     : "memory");
   return val;
 #else
-  return add_using_helper<jint>(os::atomic_add_func, add_value, dest);
+  return add_using_helper<int32_t>(os::atomic_add_func, add_value, dest);
 #endif
 }
 
@@ -146,7 +146,7 @@
     : "memory");
   return old_val;
 #else
-  return xchg_using_helper<jint>(os::atomic_xchg_func, exchange_value, dest);
+  return xchg_using_helper<int32_t>(os::atomic_xchg_func, exchange_value, dest);
 #endif
 }
 
@@ -178,17 +178,17 @@
 
 #ifndef AARCH64
 
-inline jint reorder_cmpxchg_func(jint exchange_value,
-                                 jint volatile* dest,
-                                 jint compare_value) {
+inline int32_t reorder_cmpxchg_func(int32_t exchange_value,
+                                    int32_t volatile* dest,
+                                    int32_t compare_value) {
   // Warning:  Arguments are swapped to avoid moving them for kernel call
   return (*os::atomic_cmpxchg_func)(compare_value, exchange_value, dest);
 }
 
-inline jlong reorder_cmpxchg_long_func(jlong exchange_value,
-                                       jlong volatile* dest,
-                                       jlong compare_value) {
-  assert(VM_Version::supports_cx8(), "Atomic compare and exchange jlong not supported on this architecture!");
+inline int64_t reorder_cmpxchg_long_func(int64_t exchange_value,
+                                         int64_t volatile* dest,
+                                         int64_t compare_value) {
+  assert(VM_Version::supports_cx8(), "Atomic compare and exchange int64_t not supported on this architecture!");
   // Warning:  Arguments are swapped to avoid moving them for kernel call
   return (*os::atomic_cmpxchg_long_func)(compare_value, exchange_value, dest);
 }
@@ -221,7 +221,7 @@
     : "memory");
   return rv;
 #else
-  return cmpxchg_using_helper<jint>(reorder_cmpxchg_func, exchange_value, dest, compare_value);
+  return cmpxchg_using_helper<int32_t>(reorder_cmpxchg_func, exchange_value, dest, compare_value);
 #endif
 }
 
@@ -251,7 +251,7 @@
     : "memory");
   return rv;
 #else
-  return cmpxchg_using_helper<jlong>(reorder_cmpxchg_long_func, exchange_value, dest, compare_value);
+  return cmpxchg_using_helper<int64_t>(reorder_cmpxchg_long_func, exchange_value, dest, compare_value);
 #endif
 }
 
--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -598,11 +598,11 @@
 
 #ifndef AARCH64
 
-typedef jlong cmpxchg_long_func_t(jlong, jlong, volatile jlong*);
+typedef int64_t cmpxchg_long_func_t(int64_t, int64_t, volatile int64_t*);
 
 cmpxchg_long_func_t* os::atomic_cmpxchg_long_func = os::atomic_cmpxchg_long_bootstrap;
 
-jlong os::atomic_cmpxchg_long_bootstrap(jlong compare_value, jlong exchange_value, volatile jlong* dest) {
+int64_t os::atomic_cmpxchg_long_bootstrap(int64_t compare_value, int64_t exchange_value, volatile int64_t* dest) {
   // try to use the stub:
   cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry());
 
@@ -612,16 +612,16 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  jlong old_value = *dest;
+  int64_t old_value = *dest;
   if (old_value == compare_value)
     *dest = exchange_value;
   return old_value;
 }
-typedef jlong load_long_func_t(const volatile jlong*);
+typedef int64_t load_long_func_t(const volatile int64_t*);
 
 load_long_func_t* os::atomic_load_long_func = os::atomic_load_long_bootstrap;
 
-jlong os::atomic_load_long_bootstrap(const volatile jlong* src) {
+int64_t os::atomic_load_long_bootstrap(const volatile int64_t* src) {
   // try to use the stub:
   load_long_func_t* func = CAST_TO_FN_PTR(load_long_func_t*, StubRoutines::atomic_load_long_entry());
 
@@ -631,15 +631,15 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  jlong old_value = *src;
+  int64_t old_value = *src;
   return old_value;
 }
 
-typedef void store_long_func_t(jlong, volatile jlong*);
+typedef void store_long_func_t(int64_t, volatile int64_t*);
 
 store_long_func_t* os::atomic_store_long_func = os::atomic_store_long_bootstrap;
 
-void os::atomic_store_long_bootstrap(jlong val, volatile jlong* dest) {
+void os::atomic_store_long_bootstrap(int64_t val, volatile int64_t* dest) {
   // try to use the stub:
   store_long_func_t* func = CAST_TO_FN_PTR(store_long_func_t*, StubRoutines::atomic_store_long_entry());
 
@@ -652,11 +652,11 @@
   *dest = val;
 }
 
-typedef jint  atomic_add_func_t(jint add_value, volatile jint *dest);
+typedef int32_t  atomic_add_func_t(int32_t add_value, volatile int32_t *dest);
 
 atomic_add_func_t * os::atomic_add_func = os::atomic_add_bootstrap;
 
-jint  os::atomic_add_bootstrap(jint add_value, volatile jint *dest) {
+int32_t  os::atomic_add_bootstrap(int32_t add_value, volatile int32_t *dest) {
   atomic_add_func_t * func = CAST_TO_FN_PTR(atomic_add_func_t*,
                                             StubRoutines::atomic_add_entry());
   if (func != NULL) {
@@ -664,16 +664,16 @@
     return (*func)(add_value, dest);
   }
 
-  jint old_value = *dest;
+  int32_t old_value = *dest;
   *dest = old_value + add_value;
   return (old_value + add_value);
 }
 
-typedef jint  atomic_xchg_func_t(jint exchange_value, volatile jint *dest);
+typedef int32_t  atomic_xchg_func_t(int32_t exchange_value, volatile int32_t *dest);
 
 atomic_xchg_func_t * os::atomic_xchg_func = os::atomic_xchg_bootstrap;
 
-jint  os::atomic_xchg_bootstrap(jint exchange_value, volatile jint *dest) {
+int32_t  os::atomic_xchg_bootstrap(int32_t exchange_value, volatile int32_t *dest) {
   atomic_xchg_func_t * func = CAST_TO_FN_PTR(atomic_xchg_func_t*,
                                             StubRoutines::atomic_xchg_entry());
   if (func != NULL) {
@@ -681,16 +681,16 @@
     return (*func)(exchange_value, dest);
   }
 
-  jint old_value = *dest;
+  int32_t old_value = *dest;
   *dest = exchange_value;
   return (old_value);
 }
 
-typedef jint cmpxchg_func_t(jint, jint, volatile jint*);
+typedef int32_t cmpxchg_func_t(int32_t, int32_t, volatile int32_t*);
 
 cmpxchg_func_t* os::atomic_cmpxchg_func = os::atomic_cmpxchg_bootstrap;
 
-jint os::atomic_cmpxchg_bootstrap(jint compare_value, jint exchange_value, volatile jint* dest) {
+int32_t os::atomic_cmpxchg_bootstrap(int32_t compare_value, int32_t exchange_value, volatile int32_t* dest) {
   // try to use the stub:
   cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
 
@@ -700,7 +700,7 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  jint old_value = *dest;
+  int32_t old_value = *dest;
   if (old_value == compare_value)
     *dest = exchange_value;
   return old_value;
--- a/src/hotspot/os_cpu/linux_arm/os_linux_arm.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/linux_arm/os_linux_arm.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -45,35 +45,35 @@
   static bool register_code_area(char *low, char *high) { return true; }
 
 #ifndef AARCH64
-  static jlong (*atomic_cmpxchg_long_func)(jlong compare_value,
-                                           jlong exchange_value,
-                                           volatile jlong *dest);
+  static int64_t (*atomic_cmpxchg_long_func)(int64_t compare_value,
+                                             int64_t exchange_value,
+                                             volatile int64_t *dest);
 
-  static jlong (*atomic_load_long_func)(const volatile jlong*);
+  static int64_t (*atomic_load_long_func)(const volatile int64_t*);
 
-  static void (*atomic_store_long_func)(jlong, volatile jlong*);
+  static void (*atomic_store_long_func)(int64_t, volatile int64_t*);
 
-  static jint  (*atomic_add_func)(jint add_value, volatile jint *dest);
+  static int32_t  (*atomic_add_func)(int32_t add_value, volatile int32_t *dest);
 
-  static jint  (*atomic_xchg_func)(jint exchange_value, volatile jint *dest);
+  static int32_t  (*atomic_xchg_func)(int32_t exchange_value, volatile int32_t *dest);
 
-  static jint  (*atomic_cmpxchg_func)(jint compare_value,
-                                      jint exchange_value,
-                                      volatile jint *dest);
+  static int32_t  (*atomic_cmpxchg_func)(int32_t compare_value,
+                                         int32_t exchange_value,
+                                         volatile int32_t *dest);
 
-  static jlong atomic_cmpxchg_long_bootstrap(jlong, jlong, volatile jlong*);
+  static int64_t atomic_cmpxchg_long_bootstrap(int64_t, int64_t, volatile int64_t*);
 
-  static jlong atomic_load_long_bootstrap(const volatile jlong*);
+  static int64_t atomic_load_long_bootstrap(const volatile int64_t*);
 
-  static void atomic_store_long_bootstrap(jlong, volatile jlong*);
+  static void atomic_store_long_bootstrap(int64_t, volatile int64_t*);
 
-  static jint  atomic_add_bootstrap(jint add_value, volatile jint *dest);
+  static int32_t  atomic_add_bootstrap(int32_t add_value, volatile int32_t *dest);
 
-  static jint  atomic_xchg_bootstrap(jint exchange_value, volatile jint *dest);
+  static int32_t  atomic_xchg_bootstrap(int32_t exchange_value, volatile int32_t *dest);
 
-  static jint  atomic_cmpxchg_bootstrap(jint compare_value,
-                                        jint exchange_value,
-                                        volatile jint *dest);
+  static int32_t  atomic_cmpxchg_bootstrap(int32_t compare_value,
+                                           int32_t exchange_value,
+                                           volatile int32_t *dest);
 #endif // !AARCH64
 
 #endif // OS_CPU_LINUX_ARM_VM_OS_LINUX_ARM_HPP
--- a/src/hotspot/os_cpu/linux_sparc/os_linux_sparc.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/linux_sparc/os_linux_sparc.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,15 +28,15 @@
   //
   // NOTE: we are back in class os here, not Linux
   //
-  static jint  (*atomic_xchg_func)        (jint,  volatile jint*);
-  static jint  (*atomic_cmpxchg_func)     (jint,  volatile jint*,  jint);
-  static jlong (*atomic_cmpxchg_long_func)(jlong, volatile jlong*, jlong);
-  static jint  (*atomic_add_func)         (jint,  volatile jint*);
+  static int32_t  (*atomic_xchg_func)        (int32_t,  volatile int32_t*);
+  static int32_t  (*atomic_cmpxchg_func)     (int32_t,  volatile int32_t*, int32_t);
+  static int64_t  (*atomic_cmpxchg_long_func)(int64_t,  volatile int64_t*, int64_t);
+  static int32_t  (*atomic_add_func)         (int32_t,  volatile int32_t*);
 
-  static jint  atomic_xchg_bootstrap        (jint,  volatile jint*);
-  static jint  atomic_cmpxchg_bootstrap     (jint,  volatile jint*,  jint);
-  static jlong atomic_cmpxchg_long_bootstrap(jlong, volatile jlong*, jlong);
-  static jint  atomic_add_bootstrap         (jint,  volatile jint*);
+  static int32_t  atomic_xchg_bootstrap        (int32_t,  volatile int32_t*);
+  static int32_t  atomic_cmpxchg_bootstrap     (int32_t,  volatile int32_t*, int32_t);
+  static int64_t  atomic_cmpxchg_long_bootstrap(int64_t,  volatile int64_t*, int64_t);
+  static int32_t  atomic_add_bootstrap         (int32_t,  volatile int32_t*);
 
   static void setup_fpu() {}
 
--- a/src/hotspot/os_cpu/linux_x86/atomic_linux_x86.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/linux_x86/atomic_linux_x86.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -133,8 +133,8 @@
 
 extern "C" {
   // defined in linux_x86.s
-  jlong _Atomic_cmpxchg_long(jlong, volatile jlong*, jlong);
-  void _Atomic_move_long(const volatile jlong* src, volatile jlong* dst);
+  int64_t _Atomic_cmpxchg_long(int64_t, volatile int64_t*, int64_t);
+  void _Atomic_move_long(const volatile int64_t* src, volatile int64_t* dst);
 }
 
 template<>
@@ -144,15 +144,15 @@
                                                 T compare_value,
                                                 cmpxchg_memory_order order) const {
   STATIC_ASSERT(8 == sizeof(T));
-  return cmpxchg_using_helper<jlong>(_Atomic_cmpxchg_long, exchange_value, dest, compare_value);
+  return cmpxchg_using_helper<int64_t>(_Atomic_cmpxchg_long, exchange_value, dest, compare_value);
 }
 
 template<>
 template<typename T>
 inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
   STATIC_ASSERT(8 == sizeof(T));
-  volatile jlong dest;
-  _Atomic_move_long(reinterpret_cast<const volatile jlong*>(src), reinterpret_cast<volatile jlong*>(&dest));
+  volatile int64_t dest;
+  _Atomic_move_long(reinterpret_cast<const volatile int64_t*>(src), reinterpret_cast<volatile int64_t*>(&dest));
   return PrimitiveConversions::cast<T>(dest);
 }
 
@@ -161,7 +161,7 @@
 inline void Atomic::PlatformStore<8>::operator()(T store_value,
                                                  T volatile* dest) const {
   STATIC_ASSERT(8 == sizeof(T));
-  _Atomic_move_long(reinterpret_cast<const volatile jlong*>(&store_value), reinterpret_cast<volatile jlong*>(dest));
+  _Atomic_move_long(reinterpret_cast<const volatile int64_t*>(&store_value), reinterpret_cast<volatile int64_t*>(dest));
 }
 
 #endif // AMD64
--- a/src/hotspot/os_cpu/linux_zero/atomic_linux_zero.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/linux_zero/atomic_linux_zero.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -30,67 +30,6 @@
 
 // Implementation of class atomic
 
-#ifdef ARM
-
-/*
- * __kernel_cmpxchg
- *
- * Atomically store newval in *ptr if *ptr is equal to oldval for user space.
- * Return zero if *ptr was changed or non-zero if no exchange happened.
- * The C flag is also set if *ptr was changed to allow for assembly
- * optimization in the calling code.
- *
- */
-
-typedef int (__kernel_cmpxchg_t)(int oldval, int newval, volatile int *ptr);
-#define __kernel_cmpxchg (*(__kernel_cmpxchg_t *) 0xffff0fc0)
-
-
-
-/* Perform an atomic compare and swap: if the current value of `*PTR'
-   is OLDVAL, then write NEWVAL into `*PTR'.  Return the contents of
-   `*PTR' before the operation.*/
-static inline int arm_compare_and_swap(int newval,
-                                       volatile int *ptr,
-                                       int oldval) {
-  for (;;) {
-      int prev = *ptr;
-      if (prev != oldval)
-        return prev;
-
-      if (__kernel_cmpxchg (prev, newval, ptr) == 0)
-        // Success.
-        return prev;
-
-      // We failed even though prev == oldval.  Try again.
-    }
-}
-
-/* Atomically add an int to memory.  */
-static inline int arm_add_and_fetch(int add_value, volatile int *ptr) {
-  for (;;) {
-      // Loop until a __kernel_cmpxchg succeeds.
-
-      int prev = *ptr;
-
-      if (__kernel_cmpxchg (prev, prev + add_value, ptr) == 0)
-        return prev + add_value;
-    }
-}
-
-/* Atomically write VALUE into `*PTR' and returns the previous
-   contents of `*PTR'.  */
-static inline int arm_lock_test_and_set(int newval, volatile int *ptr) {
-  for (;;) {
-      // Loop until a __kernel_cmpxchg succeeds.
-      int prev = *ptr;
-
-      if (__kernel_cmpxchg (prev, newval, ptr) == 0)
-        return prev;
-    }
-}
-#endif // ARM
-
 template<size_t byte_size>
 struct Atomic::PlatformAdd
   : Atomic::AddAndFetch<Atomic::PlatformAdd<byte_size> >
@@ -105,11 +44,7 @@
   STATIC_ASSERT(4 == sizeof(I));
   STATIC_ASSERT(4 == sizeof(D));
 
-#ifdef ARM
-  return add_using_helper<int>(arm_add_and_fetch, add_value, dest);
-#else
   return __sync_add_and_fetch(dest, add_value);
-#endif // ARM
 }
 
 template<>
@@ -117,7 +52,6 @@
 inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const {
   STATIC_ASSERT(8 == sizeof(I));
   STATIC_ASSERT(8 == sizeof(D));
-
   return __sync_add_and_fetch(dest, add_value);
 }
 
@@ -126,9 +60,6 @@
 inline T Atomic::PlatformXchg<4>::operator()(T exchange_value,
                                              T volatile* dest) const {
   STATIC_ASSERT(4 == sizeof(T));
-#ifdef ARM
-  return xchg_using_helper<int>(arm_lock_test_and_set, exchange_value, dest);
-#else
   // __sync_lock_test_and_set is a bizarrely named atomic exchange
   // operation.  Note that some platforms only support this with the
   // limitation that the only valid value to store is the immediate
@@ -140,7 +71,6 @@
   // barrier.
   __sync_synchronize();
   return result;
-#endif // ARM
 }
 
 template<>
@@ -164,11 +94,7 @@
                                                 T compare_value,
                                                 cmpxchg_memory_order order) const {
   STATIC_ASSERT(4 == sizeof(T));
-#ifdef ARM
-  return cmpxchg_using_helper<int>(arm_compare_and_swap, exchange_value, dest, compare_value);
-#else
   return __sync_val_compare_and_swap(dest, compare_value, exchange_value);
-#endif // ARM
 }
 
 template<>
@@ -185,8 +111,8 @@
 template<typename T>
 inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
   STATIC_ASSERT(8 == sizeof(T));
-  volatile jlong dest;
-  os::atomic_copy64(reinterpret_cast<const volatile jlong*>(src), reinterpret_cast<volatile jlong*>(&dest));
+  volatile int64_t dest;
+  os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(src), reinterpret_cast<volatile int64_t*>(&dest));
   return PrimitiveConversions::cast<T>(dest);
 }
 
@@ -195,7 +121,7 @@
 inline void Atomic::PlatformStore<8>::operator()(T store_value,
                                                  T volatile* dest) const {
   STATIC_ASSERT(8 == sizeof(T));
-  os::atomic_copy64(reinterpret_cast<const volatile jlong*>(&store_value), reinterpret_cast<volatile jlong*>(dest));
+  os::atomic_copy64(reinterpret_cast<const volatile int64_t*>(&store_value), reinterpret_cast<volatile int64_t*>(dest));
 }
 
 #endif // OS_CPU_LINUX_ZERO_VM_ATOMIC_LINUX_ZERO_HPP
--- a/src/hotspot/os_cpu/solaris_sparc/os_solaris_sparc.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/solaris_sparc/os_solaris_sparc.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,15 +28,15 @@
   //
   // NOTE: we are back in class os here, not Solaris
   //
-  static jint  (*atomic_xchg_func)        (jint,  volatile jint*);
-  static jint  (*atomic_cmpxchg_func)     (jint,  volatile jint*,  jint);
-  static jlong (*atomic_cmpxchg_long_func)(jlong, volatile jlong*, jlong);
-  static jint  (*atomic_add_func)         (jint,  volatile jint*);
+  static int32_t  (*atomic_xchg_func)        (int32_t,  volatile int32_t*);
+  static int32_t  (*atomic_cmpxchg_func)     (int32_t,  volatile int32_t*,  int32_t);
+  static int64_t  (*atomic_cmpxchg_long_func)(int64_t,  volatile int64_t*,  int64_t);
+  static int32_t  (*atomic_add_func)         (int32_t,  volatile int32_t*);
 
-  static jint  atomic_xchg_bootstrap        (jint,  volatile jint*);
-  static jint  atomic_cmpxchg_bootstrap     (jint,  volatile jint*,  jint);
-  static jlong atomic_cmpxchg_long_bootstrap(jlong, volatile jlong*, jlong);
-  static jint  atomic_add_bootstrap         (jint,  volatile jint*);
+  static int32_t  atomic_xchg_bootstrap        (int32_t,  volatile int32_t*);
+  static int32_t  atomic_cmpxchg_bootstrap     (int32_t,  volatile int32_t*,  int32_t);
+  static int64_t  atomic_cmpxchg_long_bootstrap(int64_t,  volatile int64_t*,  int64_t);
+  static int32_t  atomic_add_bootstrap         (int32_t,  volatile int32_t*);
 
   static void setup_fpu() {}
 
--- a/src/hotspot/os_cpu/solaris_x86/atomic_solaris_x86.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/solaris_x86/atomic_solaris_x86.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -28,16 +28,16 @@
 // For Sun Studio - implementation is in solaris_x86_64.il.
 
 extern "C" {
-  jint _Atomic_add(jint add_value, volatile jint* dest);
-  jlong _Atomic_add_long(jlong add_value, volatile jlong* dest);
+  int32_t _Atomic_add(int32_t add_value, volatile int32_t* dest);
+  int64_t _Atomic_add_long(int64_t add_value, volatile int64_t* dest);
 
-  jint _Atomic_xchg(jint exchange_value, volatile jint* dest);
-  jbyte _Atomic_cmpxchg_byte(jbyte exchange_value, volatile jbyte* dest,
-                             jbyte compare_value);
-  jint _Atomic_cmpxchg(jint exchange_value, volatile jint* dest,
-                       jint compare_value);
-  jlong _Atomic_cmpxchg_long(jlong exchange_value, volatile jlong* dest,
-                             jlong compare_value);
+  int32_t _Atomic_xchg(int32_t exchange_value, volatile int32_t* dest);
+  int8_t  _Atomic_cmpxchg_byte(int8_t exchange_value, volatile int8_t* dest,
+                               int8_t compare_value);
+  int32_t _Atomic_cmpxchg(int32_t exchange_value, volatile int32_t* dest,
+                          int32_t compare_value);
+  int64_t _Atomic_cmpxchg_long(int64_t exchange_value, volatile int64_t* dest,
+                               int64_t compare_value);
 }
 
 template<size_t byte_size>
@@ -55,8 +55,8 @@
   STATIC_ASSERT(4 == sizeof(I));
   STATIC_ASSERT(4 == sizeof(D));
   return PrimitiveConversions::cast<D>(
-    _Atomic_add(PrimitiveConversions::cast<jint>(add_value),
-                reinterpret_cast<jint volatile*>(dest)));
+    _Atomic_add(PrimitiveConversions::cast<int32_t>(add_value),
+                reinterpret_cast<int32_t volatile*>(dest)));
 }
 
 // Not using add_using_helper; see comment for cmpxchg.
@@ -66,8 +66,8 @@
   STATIC_ASSERT(8 == sizeof(I));
   STATIC_ASSERT(8 == sizeof(D));
   return PrimitiveConversions::cast<D>(
-    _Atomic_add_long(PrimitiveConversions::cast<jlong>(add_value),
-                     reinterpret_cast<jlong volatile*>(dest)));
+    _Atomic_add_long(PrimitiveConversions::cast<int64_t>(add_value),
+                     reinterpret_cast<int64_t volatile*>(dest)));
 }
 
 template<>
@@ -76,11 +76,11 @@
                                              T volatile* dest) const {
   STATIC_ASSERT(4 == sizeof(T));
   return PrimitiveConversions::cast<T>(
-    _Atomic_xchg(PrimitiveConversions::cast<jint>(exchange_value),
-                 reinterpret_cast<jint volatile*>(dest)));
+    _Atomic_xchg(PrimitiveConversions::cast<int32_t>(exchange_value),
+                 reinterpret_cast<int32_t volatile*>(dest)));
 }
 
-extern "C" jlong _Atomic_xchg_long(jlong exchange_value, volatile jlong* dest);
+extern "C" int64_t _Atomic_xchg_long(int64_t exchange_value, volatile int64_t* dest);
 
 template<>
 template<typename T>
@@ -88,8 +88,8 @@
                                              T volatile* dest) const {
   STATIC_ASSERT(8 == sizeof(T));
   return PrimitiveConversions::cast<T>(
-    _Atomic_xchg_long(PrimitiveConversions::cast<jlong>(exchange_value),
-                      reinterpret_cast<jlong volatile*>(dest)));
+    _Atomic_xchg_long(PrimitiveConversions::cast<int64_t>(exchange_value),
+                      reinterpret_cast<int64_t volatile*>(dest)));
 }
 
 // Not using cmpxchg_using_helper here, because some configurations of
@@ -106,9 +106,9 @@
                                                 cmpxchg_memory_order order) const {
   STATIC_ASSERT(1 == sizeof(T));
   return PrimitiveConversions::cast<T>(
-    _Atomic_cmpxchg_byte(PrimitiveConversions::cast<jbyte>(exchange_value),
-                         reinterpret_cast<jbyte volatile*>(dest),
-                         PrimitiveConversions::cast<jbyte>(compare_value)));
+    _Atomic_cmpxchg_byte(PrimitiveConversions::cast<int8_t>(exchange_value),
+                         reinterpret_cast<int8_t volatile*>(dest),
+                         PrimitiveConversions::cast<int8_t>(compare_value)));
 }
 
 template<>
@@ -119,9 +119,9 @@
                                                 cmpxchg_memory_order order) const {
   STATIC_ASSERT(4 == sizeof(T));
   return PrimitiveConversions::cast<T>(
-    _Atomic_cmpxchg(PrimitiveConversions::cast<jint>(exchange_value),
-                    reinterpret_cast<jint volatile*>(dest),
-                    PrimitiveConversions::cast<jint>(compare_value)));
+    _Atomic_cmpxchg(PrimitiveConversions::cast<int32_t>(exchange_value),
+                    reinterpret_cast<int32_t volatile*>(dest),
+                    PrimitiveConversions::cast<int32_t>(compare_value)));
 }
 
 template<>
@@ -132,9 +132,9 @@
                                                 cmpxchg_memory_order order) const {
   STATIC_ASSERT(8 == sizeof(T));
   return PrimitiveConversions::cast<T>(
-    _Atomic_cmpxchg_long(PrimitiveConversions::cast<jlong>(exchange_value),
-                         reinterpret_cast<jlong volatile*>(dest),
-                         PrimitiveConversions::cast<jlong>(compare_value)));
+    _Atomic_cmpxchg_long(PrimitiveConversions::cast<int64_t>(exchange_value),
+                         reinterpret_cast<int64_t volatile*>(dest),
+                         PrimitiveConversions::cast<int64_t>(compare_value)));
 }
 
 #endif // OS_CPU_SOLARIS_X86_VM_ATOMIC_SOLARIS_X86_HPP
--- a/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -904,12 +904,12 @@
 // until initialization is complete.
 // TODO - replace with .il implementation when compiler supports it.
 
-typedef jint  xchg_func_t        (jint,  volatile jint*);
-typedef jint  cmpxchg_func_t     (jint,  volatile jint*,  jint);
-typedef jlong cmpxchg_long_func_t(jlong, volatile jlong*, jlong);
-typedef jint  add_func_t         (jint,  volatile jint*);
+typedef int32_t  xchg_func_t        (int32_t,  volatile int32_t*);
+typedef int32_t  cmpxchg_func_t     (int32_t,  volatile int32_t*,  int32_t);
+typedef int64_t  cmpxchg_long_func_t(int64_t,  volatile int64_t*,  int64_t);
+typedef int32_t  add_func_t         (int32_t,  volatile int32_t*);
 
-jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) {
+int32_t os::atomic_xchg_bootstrap(int32_t exchange_value, volatile int32_t* dest) {
   // try to use the stub:
   xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry());
 
@@ -919,12 +919,12 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  jint old_value = *dest;
+  int32_t old_value = *dest;
   *dest = exchange_value;
   return old_value;
 }
 
-jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) {
+int32_t os::atomic_cmpxchg_bootstrap(int32_t exchange_value, volatile int32_t* dest, int32_t compare_value) {
   // try to use the stub:
   cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
 
@@ -934,13 +934,13 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  jint old_value = *dest;
+  int32_t old_value = *dest;
   if (old_value == compare_value)
     *dest = exchange_value;
   return old_value;
 }
 
-jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) {
+int64_t os::atomic_cmpxchg_long_bootstrap(int64_t exchange_value, volatile int64_t* dest, int64_t compare_value) {
   // try to use the stub:
   cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry());
 
@@ -950,13 +950,13 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  jlong old_value = *dest;
+  int64_t old_value = *dest;
   if (old_value == compare_value)
     *dest = exchange_value;
   return old_value;
 }
 
-jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) {
+int32_t os::atomic_add_bootstrap(int32_t add_value, volatile int32_t* dest) {
   // try to use the stub:
   add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry());
 
--- a/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/solaris_x86/os_solaris_x86.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,15 +31,15 @@
 #ifdef AMD64
   static void setup_fpu() {}
 #else
-  static jint  (*atomic_xchg_func)        (jint,  volatile jint*);
-  static jint  (*atomic_cmpxchg_func)     (jint,  volatile jint*,  jint);
-  static jlong (*atomic_cmpxchg_long_func)(jlong, volatile jlong*, jlong);
-  static jint  (*atomic_add_func)         (jint,  volatile jint*);
+  static int32_t  (*atomic_xchg_func)        (int32_t,  volatile int32_t*);
+  static int32_t  (*atomic_cmpxchg_func)     (int32_t,  volatile int32_t*, int32_t);
+  static int64_t  (*atomic_cmpxchg_long_func)(int64_t,  volatile int64_t*, int64_t);
+  static int32_t  (*atomic_add_func)         (int32_t,  volatile int32_t*);
 
-  static jint  atomic_xchg_bootstrap        (jint,  volatile jint*);
-  static jint  atomic_cmpxchg_bootstrap     (jint,  volatile jint*,  jint);
-  static jlong atomic_cmpxchg_long_bootstrap(jlong, volatile jlong*, jlong);
-  static jint  atomic_add_bootstrap         (jint,  volatile jint*);
+  static int32_t  atomic_xchg_bootstrap        (int32_t,  volatile int32_t*);
+  static int32_t  atomic_cmpxchg_bootstrap     (int32_t,  volatile int32_t*, int32_t);
+  static int64_t  atomic_cmpxchg_long_bootstrap(int64_t,  volatile int64_t*, int64_t);
+  static int32_t  atomic_add_bootstrap         (int32_t,  volatile int32_t*);
 
   static void setup_fpu();
 #endif // AMD64
--- a/src/hotspot/os_cpu/windows_x86/atomic_windows_x86.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/windows_x86/atomic_windows_x86.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -54,13 +54,13 @@
 template<>
 template<typename I, typename D>
 inline D Atomic::PlatformAdd<4>::add_and_fetch(I add_value, D volatile* dest) const {
-  return add_using_helper<jint>(os::atomic_add_func, add_value, dest);
+  return add_using_helper<int32_t>(os::atomic_add_func, add_value, dest);
 }
 
 template<>
 template<typename I, typename D>
 inline D Atomic::PlatformAdd<8>::add_and_fetch(I add_value, D volatile* dest) const {
-  return add_using_helper<intptr_t>(os::atomic_add_ptr_func, add_value, dest);
+  return add_using_helper<int64_t>(os::atomic_add_long_func, add_value, dest);
 }
 
 #define DEFINE_STUB_XCHG(ByteSize, StubType, StubName)                  \
@@ -72,8 +72,8 @@
     return xchg_using_helper<StubType>(StubName, exchange_value, dest); \
   }
 
-DEFINE_STUB_XCHG(4, jint, os::atomic_xchg_func)
-DEFINE_STUB_XCHG(8, jlong, os::atomic_xchg_long_func)
+DEFINE_STUB_XCHG(4, int32_t, os::atomic_xchg_func)
+DEFINE_STUB_XCHG(8, int64_t, os::atomic_xchg_long_func)
 
 #undef DEFINE_STUB_XCHG
 
@@ -88,9 +88,9 @@
     return cmpxchg_using_helper<StubType>(StubName, exchange_value, dest, compare_value); \
   }
 
-DEFINE_STUB_CMPXCHG(1, jbyte, os::atomic_cmpxchg_byte_func)
-DEFINE_STUB_CMPXCHG(4, jint,  os::atomic_cmpxchg_func)
-DEFINE_STUB_CMPXCHG(8, jlong, os::atomic_cmpxchg_long_func)
+DEFINE_STUB_CMPXCHG(1, int8_t,  os::atomic_cmpxchg_byte_func)
+DEFINE_STUB_CMPXCHG(4, int32_t, os::atomic_cmpxchg_func)
+DEFINE_STUB_CMPXCHG(8, int64_t, os::atomic_cmpxchg_long_func)
 
 #undef DEFINE_STUB_CMPXCHG
 
@@ -162,10 +162,10 @@
                                                 T compare_value,
                                                 cmpxchg_memory_order order) const {
   STATIC_ASSERT(8 == sizeof(T));
-  jint ex_lo  = (jint)exchange_value;
-  jint ex_hi  = *( ((jint*)&exchange_value) + 1 );
-  jint cmp_lo = (jint)compare_value;
-  jint cmp_hi = *( ((jint*)&compare_value) + 1 );
+  int32_t ex_lo  = (int32_t)exchange_value;
+  int32_t ex_hi  = *( ((int32_t*)&exchange_value) + 1 );
+  int32_t cmp_lo = (int32_t)compare_value;
+  int32_t cmp_hi = *( ((int32_t*)&compare_value) + 1 );
   __asm {
     push ebx
     push edi
--- a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -218,17 +218,17 @@
 
 // Atomics and Stub Functions
 
-typedef jint      xchg_func_t            (jint,     volatile jint*);
-typedef intptr_t  xchg_long_func_t       (jlong,    volatile jlong*);
-typedef jint      cmpxchg_func_t         (jint,     volatile jint*,  jint);
-typedef jbyte     cmpxchg_byte_func_t    (jbyte,    volatile jbyte*, jbyte);
-typedef jlong     cmpxchg_long_func_t    (jlong,    volatile jlong*, jlong);
-typedef jint      add_func_t             (jint,     volatile jint*);
-typedef intptr_t  add_ptr_func_t         (intptr_t, volatile intptr_t*);
+typedef int32_t   xchg_func_t            (int32_t,  volatile int32_t*);
+typedef int64_t   xchg_long_func_t       (int64_t,  volatile int64_t*);
+typedef int32_t   cmpxchg_func_t         (int32_t,  volatile int32_t*, int32_t);
+typedef int8_t    cmpxchg_byte_func_t    (int8_t,   volatile int8_t*,  int8_t);
+typedef int64_t   cmpxchg_long_func_t    (int64_t,  volatile int64_t*, int64_t);
+typedef int32_t   add_func_t             (int32_t,  volatile int32_t*);
+typedef int64_t   add_long_func_t        (int64_t,  volatile int64_t*);
 
 #ifdef AMD64
 
-jint os::atomic_xchg_bootstrap(jint exchange_value, volatile jint* dest) {
+int32_t os::atomic_xchg_bootstrap(int32_t exchange_value, volatile int32_t* dest) {
   // try to use the stub:
   xchg_func_t* func = CAST_TO_FN_PTR(xchg_func_t*, StubRoutines::atomic_xchg_entry());
 
@@ -238,12 +238,12 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  jint old_value = *dest;
+  int32_t old_value = *dest;
   *dest = exchange_value;
   return old_value;
 }
 
-intptr_t os::atomic_xchg_long_bootstrap(jlong exchange_value, volatile jlong* dest) {
+int64_t os::atomic_xchg_long_bootstrap(int64_t exchange_value, volatile int64_t* dest) {
   // try to use the stub:
   xchg_long_func_t* func = CAST_TO_FN_PTR(xchg_long_func_t*, StubRoutines::atomic_xchg_long_entry());
 
@@ -253,13 +253,13 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  intptr_t old_value = *dest;
+  int64_t old_value = *dest;
   *dest = exchange_value;
   return old_value;
 }
 
 
-jint os::atomic_cmpxchg_bootstrap(jint exchange_value, volatile jint* dest, jint compare_value) {
+int32_t os::atomic_cmpxchg_bootstrap(int32_t exchange_value, volatile int32_t* dest, int32_t compare_value) {
   // try to use the stub:
   cmpxchg_func_t* func = CAST_TO_FN_PTR(cmpxchg_func_t*, StubRoutines::atomic_cmpxchg_entry());
 
@@ -269,13 +269,13 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  jint old_value = *dest;
+  int32_t old_value = *dest;
   if (old_value == compare_value)
     *dest = exchange_value;
   return old_value;
 }
 
-jbyte os::atomic_cmpxchg_byte_bootstrap(jbyte exchange_value, volatile jbyte* dest, jbyte compare_value) {
+int8_t os::atomic_cmpxchg_byte_bootstrap(int8_t exchange_value, volatile int8_t* dest, int8_t compare_value) {
   // try to use the stub:
   cmpxchg_byte_func_t* func = CAST_TO_FN_PTR(cmpxchg_byte_func_t*, StubRoutines::atomic_cmpxchg_byte_entry());
 
@@ -285,7 +285,7 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  jbyte old_value = *dest;
+  int8_t old_value = *dest;
   if (old_value == compare_value)
     *dest = exchange_value;
   return old_value;
@@ -293,7 +293,7 @@
 
 #endif // AMD64
 
-jlong os::atomic_cmpxchg_long_bootstrap(jlong exchange_value, volatile jlong* dest, jlong compare_value) {
+int64_t os::atomic_cmpxchg_long_bootstrap(int64_t exchange_value, volatile int64_t* dest, int64_t compare_value) {
   // try to use the stub:
   cmpxchg_long_func_t* func = CAST_TO_FN_PTR(cmpxchg_long_func_t*, StubRoutines::atomic_cmpxchg_long_entry());
 
@@ -303,7 +303,7 @@
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
 
-  jlong old_value = *dest;
+  int64_t old_value = *dest;
   if (old_value == compare_value)
     *dest = exchange_value;
   return old_value;
@@ -311,7 +311,7 @@
 
 #ifdef AMD64
 
-jint os::atomic_add_bootstrap(jint add_value, volatile jint* dest) {
+int32_t os::atomic_add_bootstrap(int32_t add_value, volatile int32_t* dest) {
   // try to use the stub:
   add_func_t* func = CAST_TO_FN_PTR(add_func_t*, StubRoutines::atomic_add_entry());
 
@@ -324,12 +324,12 @@
   return (*dest) += add_value;
 }
 
-intptr_t os::atomic_add_ptr_bootstrap(intptr_t add_value, volatile intptr_t* dest) {
+int64_t os::atomic_add_long_bootstrap(int64_t add_value, volatile int64_t* dest) {
   // try to use the stub:
-  add_ptr_func_t* func = CAST_TO_FN_PTR(add_ptr_func_t*, StubRoutines::atomic_add_ptr_entry());
+  add_long_func_t* func = CAST_TO_FN_PTR(add_long_func_t*, StubRoutines::atomic_add_long_entry());
 
   if (func != NULL) {
-    os::atomic_add_ptr_func = func;
+    os::atomic_add_long_func = func;
     return (*func)(add_value, dest);
   }
   assert(Threads::number_of_threads() == 0, "for bootstrap only");
@@ -342,7 +342,7 @@
 cmpxchg_func_t*      os::atomic_cmpxchg_func      = os::atomic_cmpxchg_bootstrap;
 cmpxchg_byte_func_t* os::atomic_cmpxchg_byte_func = os::atomic_cmpxchg_byte_bootstrap;
 add_func_t*          os::atomic_add_func          = os::atomic_add_bootstrap;
-add_ptr_func_t*      os::atomic_add_ptr_func      = os::atomic_add_ptr_bootstrap;
+add_long_func_t*     os::atomic_add_long_func     = os::atomic_add_long_bootstrap;
 
 #endif // AMD64
 
--- a/src/hotspot/os_cpu/windows_x86/os_windows_x86.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/os_cpu/windows_x86/os_windows_x86.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -29,32 +29,32 @@
   // NOTE: we are back in class os here, not win32
   //
 #ifdef AMD64
-  static jint      (*atomic_xchg_func)          (jint,      volatile jint*);
-  static intptr_t  (*atomic_xchg_long_func)     (jlong,     volatile jlong*);
+  static int32_t   (*atomic_xchg_func)          (int32_t, volatile int32_t*);
+  static int64_t   (*atomic_xchg_long_func)     (int64_t, volatile int64_t*);
 
-  static jint      (*atomic_cmpxchg_func)       (jint,      volatile jint*,  jint);
-  static jbyte     (*atomic_cmpxchg_byte_func)  (jbyte,     volatile jbyte*, jbyte);
-  static jlong     (*atomic_cmpxchg_long_func)  (jlong,     volatile jlong*, jlong);
+  static int32_t   (*atomic_cmpxchg_func)       (int32_t,  volatile int32_t*, int32_t);
+  static int8_t    (*atomic_cmpxchg_byte_func)  (int8_t,   volatile int8_t*,  int8_t);
+  static int64_t   (*atomic_cmpxchg_long_func)  (int64_t,  volatile int64_t*, int64_t);
 
-  static jint      (*atomic_add_func)           (jint,      volatile jint*);
-  static intptr_t  (*atomic_add_ptr_func)       (intptr_t,  volatile intptr_t*);
+  static int32_t   (*atomic_add_func)           (int32_t,  volatile int32_t*);
+  static int64_t   (*atomic_add_long_func)      (int64_t,  volatile int64_t*);
 
-  static jint      atomic_xchg_bootstrap        (jint,      volatile jint*);
-  static intptr_t  atomic_xchg_long_bootstrap   (jlong,     volatile jlong*);
+  static int32_t   atomic_xchg_bootstrap        (int32_t,  volatile int32_t*);
+  static int64_t   atomic_xchg_long_bootstrap   (int64_t,  volatile int64_t*);
 
-  static jint      atomic_cmpxchg_bootstrap     (jint,      volatile jint*,  jint);
-  static jbyte     atomic_cmpxchg_byte_bootstrap(jbyte,     volatile jbyte*, jbyte);
+  static int32_t   atomic_cmpxchg_bootstrap     (int32_t,  volatile int32_t*, int32_t);
+  static int8_t    atomic_cmpxchg_byte_bootstrap(int8_t,   volatile int8_t*,  int8_t);
 #else
 
-  static jlong (*atomic_cmpxchg_long_func)  (jlong, volatile jlong*, jlong);
+  static int64_t (*atomic_cmpxchg_long_func)  (int64_t, volatile int64_t*, int64_t);
 
 #endif // AMD64
 
-  static jlong atomic_cmpxchg_long_bootstrap(jlong, volatile jlong*, jlong);
+  static int64_t atomic_cmpxchg_long_bootstrap(int64_t, volatile int64_t*, int64_t);
 
 #ifdef AMD64
-  static jint      atomic_add_bootstrap         (jint,      volatile jint*);
-  static intptr_t  atomic_add_ptr_bootstrap     (intptr_t,  volatile intptr_t*);
+  static int32_t  atomic_add_bootstrap         (int32_t,  volatile int32_t*);
+  static int64_t  atomic_add_long_bootstrap    (int64_t,  volatile int64_t*);
 #endif // AMD64
 
   static void setup_fpu();
--- a/src/hotspot/share/classfile/classFileParser.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/classfile/classFileParser.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -86,8 +86,6 @@
 
 #define JAVA_CLASSFILE_MAGIC              0xCAFEBABE
 #define JAVA_MIN_SUPPORTED_VERSION        45
-#define JAVA_MAX_SUPPORTED_VERSION        54
-#define JAVA_MAX_SUPPORTED_MINOR_VERSION  0
 
 // Used for two backward compatibility reasons:
 // - to check for new additions to the class file format in JDK1.5
@@ -110,6 +108,8 @@
 
 #define JAVA_10_VERSION                   54
 
+#define JAVA_11_VERSION                   55
+
 void ClassFileParser::set_class_bad_constant_seen(short bad_constant) {
   assert((bad_constant == 19 || bad_constant == 20) && _major_version >= JAVA_9_VERSION,
          "Unexpected bad constant pool entry");
@@ -4642,11 +4642,11 @@
 }
 
 static bool is_supported_version(u2 major, u2 minor){
-  const u2 max_version = JAVA_MAX_SUPPORTED_VERSION;
+  const u2 max_version = JVM_CLASSFILE_MAJOR_VERSION;
   return (major >= JAVA_MIN_SUPPORTED_VERSION) &&
          (major <= max_version) &&
          ((major != max_version) ||
-          (minor <= JAVA_MAX_SUPPORTED_MINOR_VERSION));
+          (minor <= JVM_CLASSFILE_MINOR_VERSION));
 }
 
 void ClassFileParser::verify_legal_field_modifiers(jint flags,
@@ -5808,8 +5808,8 @@
       _class_name->as_C_string(),
       _major_version,
       _minor_version,
-      JAVA_MAX_SUPPORTED_VERSION,
-      JAVA_MAX_SUPPORTED_MINOR_VERSION);
+      JVM_CLASSFILE_MAJOR_VERSION,
+      JVM_CLASSFILE_MINOR_VERSION);
     return;
   }
 
--- a/src/hotspot/share/classfile/classLoader.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/classfile/classLoader.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -802,6 +802,14 @@
   int end = 0;
   bool set_base_piece = true;
 
+#if INCLUDE_CDS
+  if (DumpSharedSpaces) {
+    if (!Arguments::has_jimage()) {
+      vm_exit_during_initialization("CDS is not supported in exploded JDK build", NULL);
+    }
+  }
+#endif
+
   // Iterate over class path entries
   for (int start = 0; start < len; start = end) {
     while (class_path[end] && class_path[end] != os::path_separator()[0]) {
--- a/src/hotspot/share/classfile/defaultMethods.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/classfile/defaultMethods.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -26,6 +26,7 @@
 #include "classfile/bytecodeAssembler.hpp"
 #include "classfile/defaultMethods.hpp"
 #include "classfile/symbolTable.hpp"
+#include "classfile/systemDictionary.hpp"
 #include "logging/log.hpp"
 #include "logging/logStream.hpp"
 #include "memory/allocation.hpp"
@@ -683,10 +684,11 @@
   Symbol* _method_name;
   Symbol* _method_signature;
   StatefulMethodFamily*  _family;
+  bool _cur_class_is_interface;
 
  public:
-  FindMethodsByErasedSig(Symbol* name, Symbol* signature) :
-      _method_name(name), _method_signature(signature),
+  FindMethodsByErasedSig(Symbol* name, Symbol* signature, bool is_interf) :
+      _method_name(name), _method_signature(signature), _cur_class_is_interface(is_interf),
       _family(NULL) {}
 
   void get_discovered_family(MethodFamily** family) {
@@ -709,14 +711,17 @@
     InstanceKlass* iklass = current_class();
 
     Method* m = iklass->find_method(_method_name, _method_signature);
-    // private interface methods are not candidates for default methods
-    // invokespecial to private interface methods doesn't use default method logic
-    // private class methods are not candidates for default methods,
-    // private methods do not override default methods, so need to perform
-    // default method inheritance without including private methods
-    // The overpasses are your supertypes' errors, we do not include them
-    // future: take access controls into account for superclass methods
-    if (m != NULL && !m->is_static() && !m->is_overpass() && !m->is_private()) {
+    // Private interface methods are not candidates for default methods.
+    // invokespecial to private interface methods doesn't use default method logic.
+    // Private class methods are not candidates for default methods.
+    // Private methods do not override default methods, so need to perform
+    // default method inheritance without including private methods.
+    // The overpasses are your supertypes' errors, we do not include them.
+    // Non-public methods in java.lang.Object are not candidates for default
+    // methods.
+    // Future: take access controls into account for superclass methods
+    if (m != NULL && !m->is_static() && !m->is_overpass() && !m->is_private() &&
+     (!_cur_class_is_interface || !SystemDictionary::is_nonpublic_Object_method(m))) {
       if (_family == NULL) {
         _family = new StatefulMethodFamily();
       }
@@ -726,8 +731,8 @@
         scope->add_mark(restorer);
       } else {
         // This is the rule that methods in classes "win" (bad word) over
-        // methods in interfaces. This works because of single inheritance
-        // private methods in classes do not "win", they will be found
+        // methods in interfaces. This works because of single inheritance.
+        // Private methods in classes do not "win", they will be found
         // first on searching, but overriding for invokevirtual needs
         // to find default method candidates for the same signature
         _family->set_target_if_empty(m);
@@ -745,10 +750,10 @@
 
 static void generate_erased_defaults(
      InstanceKlass* klass, GrowableArray<EmptyVtableSlot*>* empty_slots,
-     EmptyVtableSlot* slot, TRAPS) {
+     EmptyVtableSlot* slot, bool is_intf, TRAPS) {
 
   // sets up a set of methods with the same exact erased signature
-  FindMethodsByErasedSig visitor(slot->name(), slot->signature());
+  FindMethodsByErasedSig visitor(slot->name(), slot->signature(), is_intf);
   visitor.run(klass);
 
   MethodFamily* family;
@@ -817,7 +822,7 @@
       slot->print_on(&ls);
       ls.cr();
     }
-    generate_erased_defaults(klass, empty_slots, slot, CHECK);
+    generate_erased_defaults(klass, empty_slots, slot, klass->is_interface(), CHECK);
   }
   log_debug(defaultmethods)("Creating defaults and overpasses...");
   create_defaults_and_exceptions(empty_slots, klass, CHECK);
--- a/src/hotspot/share/classfile/systemDictionary.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/classfile/systemDictionary.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -654,6 +654,12 @@
   static bool is_platform_class_loader(oop class_loader);
   static void clear_invoke_method_table();
 
+  // Returns TRUE if the method is a non-public member of class java.lang.Object.
+  static bool is_nonpublic_Object_method(Method* m) {
+    assert(m != NULL, "Unexpected NULL Method*");
+    return !m->is_public() && m->method_holder() == SystemDictionary::Object_klass();
+  }
+
 protected:
   static InstanceKlass* find_shared_class(Symbol* class_name);
 
--- a/src/hotspot/share/classfile/vmSymbols.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/classfile/vmSymbols.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -997,8 +997,8 @@
    do_name(     montgomerySquare_name,                             "implMontgomerySquare")                              \
    do_signature(montgomerySquare_signature,                        "([I[IIJ[I)[I")                                      \
                                                                                                                         \
-  do_class(java_util_ArraysSupport, "java/util/ArraysSupport")                                                          \
-  do_intrinsic(_vectorizedMismatch, java_util_ArraysSupport, vectorizedMismatch_name, vectorizedMismatch_signature, F_S)\
+  do_class(jdk_internal_util_ArraysSupport, "jdk/internal/util/ArraysSupport")                                                          \
+  do_intrinsic(_vectorizedMismatch, jdk_internal_util_ArraysSupport, vectorizedMismatch_name, vectorizedMismatch_signature, F_S)\
    do_name(vectorizedMismatch_name, "vectorizedMismatch")                                                               \
    do_signature(vectorizedMismatch_signature, "(Ljava/lang/Object;JLjava/lang/Object;JII)I")                            \
                                                                                                                         \
--- a/src/hotspot/share/code/compiledIC.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/code/compiledIC.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -344,6 +344,7 @@
   // Code
   static address emit_to_interp_stub(CodeBuffer &cbuf, address mark = NULL);
   static int to_interp_stub_size();
+  static int to_trampoline_stub_size();
   static int reloc_to_interp_stub();
   static void emit_to_aot_stub(CodeBuffer &cbuf, address mark = NULL);
   static int to_aot_stub_size();
--- a/src/hotspot/share/code/nmethod.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/code/nmethod.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -1485,16 +1485,18 @@
 
 bool nmethod::do_unloading_oops(address low_boundary, BoolObjectClosure* is_alive, bool unloading_occurred) {
   // Compiled code
-  {
-  RelocIterator iter(this, low_boundary);
-  while (iter.next()) {
-    if (iter.type() == relocInfo::oop_type) {
-      if (unload_if_dead_at(&iter, is_alive, unloading_occurred)) {
-        return true;
+
+  // Prevent extra code cache walk for platforms that don't have immediate oops.
+  if (relocInfo::mustIterateImmediateOopsInCode()) {
+    RelocIterator iter(this, low_boundary);
+    while (iter.next()) {
+      if (iter.type() == relocInfo::oop_type) {
+        if (unload_if_dead_at(&iter, is_alive, unloading_occurred)) {
+          return true;
+        }
       }
     }
   }
-  }
 
   return do_unloading_scopes(is_alive, unloading_occurred);
 }
@@ -1584,18 +1586,21 @@
     // (See comment above.)
   }
 
-  RelocIterator iter(this, low_boundary);
+  // Prevent extra code cache walk for platforms that don't have immediate oops.
+  if (relocInfo::mustIterateImmediateOopsInCode()) {
+    RelocIterator iter(this, low_boundary);
 
-  while (iter.next()) {
-    if (iter.type() == relocInfo::oop_type ) {
-      oop_Relocation* r = iter.oop_reloc();
-      // In this loop, we must only follow those oops directly embedded in
-      // the code.  Other oops (oop_index>0) are seen as part of scopes_oops.
-      assert(1 == (r->oop_is_immediate()) +
-                   (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()),
-             "oop must be found in exactly one place");
-      if (r->oop_is_immediate() && r->oop_value() != NULL) {
-        f->do_oop(r->oop_addr());
+    while (iter.next()) {
+      if (iter.type() == relocInfo::oop_type ) {
+        oop_Relocation* r = iter.oop_reloc();
+        // In this loop, we must only follow those oops directly embedded in
+        // the code.  Other oops (oop_index>0) are seen as part of scopes_oops.
+        assert(1 == (r->oop_is_immediate()) +
+               (r->oop_addr() >= oops_begin() && r->oop_addr() < oops_end()),
+               "oop must be found in exactly one place");
+        if (r->oop_is_immediate() && r->oop_value() != NULL) {
+          f->do_oop(r->oop_addr());
+        }
       }
     }
   }
@@ -1620,7 +1625,7 @@
   assert(nmethod::oops_do_marking_is_active(), "oops_do_marking_prologue must be called");
   if (_oops_do_mark_link == NULL) {
     // Claim this nmethod for this thread to mark.
-    if (Atomic::cmpxchg(NMETHOD_SENTINEL, &_oops_do_mark_link, (nmethod*)NULL) == NULL) {
+    if (Atomic::replace_if_null(NMETHOD_SENTINEL, &_oops_do_mark_link)) {
       // Atomically append this nmethod (now claimed) to the head of the list:
       nmethod* observed_mark_nmethods = _oops_do_mark_nmethods;
       for (;;) {
--- a/src/hotspot/share/code/relocInfo.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/code/relocInfo.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -910,6 +910,10 @@
   }
   // an oop in the instruction stream
   static RelocationHolder spec_for_immediate() {
+    // If no immediate oops are generated, we can skip some walks over nmethods.
+    // Assert that they don't get generated accidently!
+    assert(relocInfo::mustIterateImmediateOopsInCode(),
+           "Must return true so we will search for oops as roots etc. in the code.");
     const int oop_index = 0;
     const int offset    = 0;    // if you want an offset, use the oop pool
     RelocationHolder rh = newHolder();
--- a/src/hotspot/share/gc/parallel/gcTaskThread.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/gc/parallel/gcTaskThread.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -77,7 +77,7 @@
   if (_time_stamps == NULL) {
     // We allocate the _time_stamps array lazily since logging can be enabled dynamically
     GCTaskTimeStamp* time_stamps = NEW_C_HEAP_ARRAY(GCTaskTimeStamp, GCTaskTimeStampEntries, mtGC);
-    if (Atomic::cmpxchg(time_stamps, &_time_stamps, (GCTaskTimeStamp*)NULL) != NULL) {
+    if (!Atomic::replace_if_null(time_stamps, &_time_stamps)) {
       // Someone already setup the time stamps
       FREE_C_HEAP_ARRAY(GCTaskTimeStamp, time_stamps);
     }
--- a/src/hotspot/share/include/jvm.h	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/include/jvm.h	Thu Jan 18 18:58:46 2018 +0000
@@ -317,23 +317,18 @@
 JNIEXPORT jobject JNICALL
 JVM_NewMultiArray(JNIEnv *env, jclass eltClass, jintArray dim);
 
-/*
- * java.lang.Class and java.lang.ClassLoader
- */
-
-#define JVM_CALLER_DEPTH -1
 
 /*
  * Returns the immediate caller class of the native method invoking
  * JVM_GetCallerClass.  The Method.invoke and other frames due to
  * reflection machinery are skipped.
  *
- * The depth parameter must be -1 (JVM_DEPTH). The caller is expected
- * to be marked with sun.reflect.CallerSensitive.  The JVM will throw
- * an error if it is not marked propertly.
+ * The caller is expected to be marked with
+ * jdk.internal.reflect.CallerSensitive. The JVM will throw an
+ * error if it is not marked properly.
  */
 JNIEXPORT jclass JNICALL
-JVM_GetCallerClass(JNIEnv *env, int depth);
+JVM_GetCallerClass(JNIEnv *env);
 
 
 /*
--- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -699,6 +699,7 @@
   // Estimate the number of static and aot call stubs that might be emitted.
   int static_call_stubs = 0;
   int aot_call_stubs = 0;
+  int trampoline_stubs = 0;
   objArrayOop sites = this->sites();
   for (int i = 0; i < sites->length(); i++) {
     oop site = sites->obj_at(i);
@@ -710,8 +711,18 @@
             JVMCI_ERROR_0("expected Integer id, got %s", id_obj->klass()->signature_name());
           }
           jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT));
-          if (id == INVOKESTATIC || id == INVOKESPECIAL) {
+          switch (id) {
+          case INVOKEINTERFACE:
+          case INVOKEVIRTUAL:
+            trampoline_stubs++;
+            break;
+          case INVOKESTATIC:
+          case INVOKESPECIAL:
             static_call_stubs++;
+            trampoline_stubs++;
+            break;
+          default:
+            break;
           }
         }
       }
@@ -726,6 +737,7 @@
     }
   }
   int size = static_call_stubs * CompiledStaticCall::to_interp_stub_size();
+  size += trampoline_stubs * CompiledStaticCall::to_trampoline_stub_size();
 #if INCLUDE_AOT
   size += aot_call_stubs * CompiledStaticCall::to_aot_stub_size();
 #endif
@@ -1171,7 +1183,7 @@
     }
 
     TRACE_jvmci_3("method call");
-    CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset, CHECK);
+    CodeInstaller::pd_relocate_JavaMethod(buffer, hotspot_method, pc_offset, CHECK);
     if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) {
       // Need a static call stub for transitions from compiled to interpreted.
       CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset);
@@ -1282,4 +1294,3 @@
     }
   }
 }
-
--- a/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -185,7 +185,7 @@
   void pd_patch_MetaspaceConstant(int pc_offset, Handle constant, TRAPS);
   void pd_patch_DataSectionReference(int pc_offset, int data_offset, TRAPS);
   void pd_relocate_ForeignCall(NativeInstruction* inst, jlong foreign_call_destination, TRAPS);
-  void pd_relocate_JavaMethod(Handle method, jint pc_offset, TRAPS);
+  void pd_relocate_JavaMethod(CodeBuffer &cbuf, Handle method, jint pc_offset, TRAPS);
   void pd_relocate_poll(address pc, jint mark, TRAPS);
 
   objArrayOop sites() { return (objArrayOop) JNIHandles::resolve(_sites_handle); }
--- a/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/jvmci/jvmciCompilerToVM.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -749,8 +749,13 @@
 C2V_END
 
 C2V_VMENTRY(jobject, getImplementor, (JNIEnv *, jobject, jobject jvmci_type))
-  InstanceKlass* klass = (InstanceKlass*) CompilerToVM::asKlass(jvmci_type);
-  oop implementor = CompilerToVM::get_jvmci_type(klass->implementor(), CHECK_NULL);
+  Klass* klass = CompilerToVM::asKlass(jvmci_type);
+  if (!klass->is_interface()) {
+    THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(),
+        err_msg("Expected interface type, got %s", klass->external_name()));
+  }
+  InstanceKlass* iklass = InstanceKlass::cast(klass);
+  oop implementor = CompilerToVM::get_jvmci_type(iklass->implementor(), CHECK_NULL);
   return JNIHandles::make_local(THREAD, implementor);
 C2V_END
 
@@ -989,8 +994,12 @@
 C2V_END
 
 C2V_VMENTRY(jobject, getClassInitializer, (JNIEnv *, jobject, jobject jvmci_type))
-  InstanceKlass* klass = (InstanceKlass*) CompilerToVM::asKlass(jvmci_type);
-  oop result = CompilerToVM::get_jvmci_method(klass->class_initializer(), CHECK_NULL);
+  Klass* klass = CompilerToVM::asKlass(jvmci_type);
+  if (!klass->is_instance_klass()) {
+    return NULL;
+  }
+  InstanceKlass* iklass = InstanceKlass::cast(klass);
+  oop result = CompilerToVM::get_jvmci_method(iklass->class_initializer(), CHECK_NULL);
   return JNIHandles::make_local(THREAD, result);
 C2V_END
 
--- a/src/hotspot/share/oops/cpCache.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/oops/cpCache.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -177,6 +177,7 @@
       // instruction somehow links to a non-interface method (in Object).
       // In that case, the method has no itable index and must be invoked as a virtual.
       // Set a flag to keep track of this corner case.
+      assert(method->is_public(), "Calling non-public method in Object with invokeinterface");
       change_to_virtual = true;
 
       // ...and fall through as if we were handling invokevirtual:
--- a/src/hotspot/share/oops/klassVtable.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/oops/klassVtable.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -86,13 +86,14 @@
 
   GrowableArray<Method*> new_mirandas(20);
   // compute the number of mirandas methods that must be added to the end
-  get_mirandas(&new_mirandas, all_mirandas, super, methods, NULL, local_interfaces);
+  get_mirandas(&new_mirandas, all_mirandas, super, methods, NULL, local_interfaces,
+               class_flags.is_interface());
   *num_new_mirandas = new_mirandas.length();
 
   // Interfaces do not need interface methods in their vtables
   // This includes miranda methods and during later processing, default methods
   if (!class_flags.is_interface()) {
-    vtable_length += *num_new_mirandas * vtableEntry::size();
+     vtable_length += *num_new_mirandas * vtableEntry::size();
   }
 
   if (Universe::is_bootstrapping() && vtable_length == 0) {
@@ -454,8 +455,13 @@
     } else {
       super_method = method_at(i);
     }
-    // Check if method name matches
-    if (super_method->name() == name && super_method->signature() == signature) {
+    // Check if method name matches.  Ignore match if klass is an interface and the
+    // matching method is a non-public java.lang.Object method.  (See JVMS 5.4.3.4)
+    // This is safe because the method at this slot should never get invoked.
+    // (TBD: put in a method to throw NoSuchMethodError if this slot is ever used.)
+    if (super_method->name() == name && super_method->signature() == signature &&
+        (!_klass->is_interface() ||
+         !SystemDictionary::is_nonpublic_Object_method(super_method))) {
 
       // get super_klass for method_holder for the found method
       InstanceKlass* super_klass =  super_method->method_holder();
@@ -713,7 +719,7 @@
   if (mhk->is_interface()) {
     assert(m->is_public(), "should be public");
     assert(ik()->implements_interface(method_holder) , "this class should implement the interface");
-    if (is_miranda(m, ik()->methods(), ik()->default_methods(), ik()->super())) {
+    if (is_miranda(m, ik()->methods(), ik()->default_methods(), ik()->super(), klass()->is_interface())) {
       return true;
     }
   }
@@ -738,7 +744,10 @@
 // During the first run, the current instanceKlass has not yet been
 // created, the superclasses and superinterfaces do have instanceKlasses
 // but may not have vtables, the default_methods list is empty, no overpasses.
-// This is seen by default method creation.
+// Default method generation uses the all_mirandas array as the starter set for
+// maximally-specific default method calculation.  So, for both classes and
+// interfaces, it is necessary that the first pass will find all non-private
+// interface instance methods, whether or not they are concrete.
 //
 // Pass 2: recalculated during vtable initialization: only include abstract methods.
 // The goal of pass 2 is to walk through the superinterfaces to see if any of
@@ -772,7 +781,8 @@
 // Part of the Miranda Rights in the US mean that if you do not have
 // an attorney one will be appointed for you.
 bool klassVtable::is_miranda(Method* m, Array<Method*>* class_methods,
-                             Array<Method*>* default_methods, const Klass* super) {
+                             Array<Method*>* default_methods, const Klass* super,
+                             bool is_interface) {
   if (m->is_static() || m->is_private() || m->is_overpass()) {
     return false;
   }
@@ -800,8 +810,11 @@
 
   for (const Klass* cursuper = super; cursuper != NULL; cursuper = cursuper->super())
   {
-     if (InstanceKlass::cast(cursuper)->find_local_method(name, signature,
-           Klass::find_overpass, Klass::skip_static, Klass::skip_private) != NULL) {
+     Method* found_mth = InstanceKlass::cast(cursuper)->find_local_method(name, signature,
+       Klass::find_overpass, Klass::skip_static, Klass::skip_private);
+     // Ignore non-public methods in java.lang.Object if klass is an interface.
+     if (found_mth != NULL && (!is_interface ||
+         !SystemDictionary::is_nonpublic_Object_method(found_mth))) {
        return false;
      }
   }
@@ -820,7 +833,7 @@
 void klassVtable::add_new_mirandas_to_lists(
     GrowableArray<Method*>* new_mirandas, GrowableArray<Method*>* all_mirandas,
     Array<Method*>* current_interface_methods, Array<Method*>* class_methods,
-    Array<Method*>* default_methods, const Klass* super) {
+    Array<Method*>* default_methods, const Klass* super, bool is_interface) {
 
   // iterate thru the current interface's method to see if it a miranda
   int num_methods = current_interface_methods->length();
@@ -839,7 +852,7 @@
     }
 
     if (!is_duplicate) { // we don't want duplicate miranda entries in the vtable
-      if (is_miranda(im, class_methods, default_methods, super)) { // is it a miranda at all?
+      if (is_miranda(im, class_methods, default_methods, super, is_interface)) { // is it a miranda at all?
         const InstanceKlass *sk = InstanceKlass::cast(super);
         // check if it is a duplicate of a super's miranda
         if (sk->lookup_method_in_all_interfaces(im->name(), im->signature(), Klass::find_defaults) == NULL) {
@@ -858,7 +871,8 @@
                                const Klass* super,
                                Array<Method*>* class_methods,
                                Array<Method*>* default_methods,
-                               Array<Klass*>* local_interfaces) {
+                               Array<Klass*>* local_interfaces,
+                               bool is_interface) {
   assert((new_mirandas->length() == 0) , "current mirandas must be 0");
 
   // iterate thru the local interfaces looking for a miranda
@@ -867,7 +881,7 @@
     InstanceKlass *ik = InstanceKlass::cast(local_interfaces->at(i));
     add_new_mirandas_to_lists(new_mirandas, all_mirandas,
                               ik->methods(), class_methods,
-                              default_methods, super);
+                              default_methods, super, is_interface);
     // iterate thru each local's super interfaces
     Array<Klass*>* super_ifs = ik->transitive_interfaces();
     int num_super_ifs = super_ifs->length();
@@ -875,7 +889,7 @@
       InstanceKlass *sik = InstanceKlass::cast(super_ifs->at(j));
       add_new_mirandas_to_lists(new_mirandas, all_mirandas,
                                 sik->methods(), class_methods,
-                                default_methods, super);
+                                default_methods, super, is_interface);
     }
   }
 }
@@ -888,7 +902,8 @@
 int klassVtable::fill_in_mirandas(int initialized) {
   GrowableArray<Method*> mirandas(20);
   get_mirandas(&mirandas, NULL, ik()->super(), ik()->methods(),
-               ik()->default_methods(), ik()->local_interfaces());
+               ik()->default_methods(), ik()->local_interfaces(),
+               klass()->is_interface());
   for (int i = 0; i < mirandas.length(); i++) {
     if (log_develop_is_enabled(Trace, vtables)) {
       Method* meth = mirandas.at(i);
--- a/src/hotspot/share/oops/klassVtable.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/oops/klassVtable.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -144,21 +144,24 @@
   bool is_miranda_entry_at(int i);
   int fill_in_mirandas(int initialized);
   static bool is_miranda(Method* m, Array<Method*>* class_methods,
-                         Array<Method*>* default_methods, const Klass* super);
+                         Array<Method*>* default_methods, const Klass* super,
+                         bool is_interface);
   static void add_new_mirandas_to_lists(
       GrowableArray<Method*>* new_mirandas,
       GrowableArray<Method*>* all_mirandas,
       Array<Method*>* current_interface_methods,
       Array<Method*>* class_methods,
       Array<Method*>* default_methods,
-      const Klass* super);
+      const Klass* super,
+      bool is_interface);
   static void get_mirandas(
       GrowableArray<Method*>* new_mirandas,
       GrowableArray<Method*>* all_mirandas,
       const Klass* super,
       Array<Method*>* class_methods,
       Array<Method*>* default_methods,
-      Array<Klass*>* local_interfaces);
+      Array<Klass*>* local_interfaces,
+      bool is_interface);
   void verify_against(outputStream* st, klassVtable* vt, int index);
   inline InstanceKlass* ik() const;
   // When loading a class from CDS archive at run time, and no class redefintion
--- a/src/hotspot/share/oops/method.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/oops/method.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -446,7 +446,7 @@
 
 bool Method::init_method_counters(MethodCounters* counters) {
   // Try to install a pointer to MethodCounters, return true on success.
-  return Atomic::cmpxchg(counters, &_method_counters, (MethodCounters*)NULL) == NULL;
+  return Atomic::replace_if_null(counters, &_method_counters);
 }
 
 void Method::cleanup_inline_caches() {
--- a/src/hotspot/share/prims/jvm.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/prims/jvm.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -678,17 +678,9 @@
 // Misc. class handling ///////////////////////////////////////////////////////////
 
 
-JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env, int depth))
+JVM_ENTRY(jclass, JVM_GetCallerClass(JNIEnv* env))
   JVMWrapper("JVM_GetCallerClass");
 
-  // Pre-JDK 8 and early builds of JDK 8 don't have a CallerSensitive annotation; or
-  // sun.reflect.Reflection.getCallerClass with a depth parameter is provided
-  // temporarily for existing code to use until a replacement API is defined.
-  if (SystemDictionary::reflect_CallerSensitive_klass() == NULL || depth != JVM_CALLER_DEPTH) {
-    Klass* k = thread->security_get_caller_class(depth);
-    return (k == NULL) ? NULL : (jclass) JNIHandles::make_local(env, k->java_mirror());
-  }
-
   // Getting the class of the caller frame.
   //
   // The call stack at this point looks something like this:
--- a/src/hotspot/share/prims/jvmtiRawMonitor.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/prims/jvmtiRawMonitor.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -127,7 +127,7 @@
 
 int JvmtiRawMonitor::SimpleEnter (Thread * Self) {
   for (;;) {
-    if (Atomic::cmpxchg(Self, &_owner, (void*)NULL) == NULL) {
+    if (Atomic::replace_if_null(Self, &_owner)) {
        return OS_OK ;
     }
 
@@ -139,7 +139,7 @@
     Node._next  = _EntryList ;
     _EntryList  = &Node ;
     OrderAccess::fence() ;
-    if (_owner == NULL && Atomic::cmpxchg(Self, &_owner, (void*)NULL) == NULL) {
+    if (_owner == NULL && Atomic::replace_if_null(Self, &_owner)) {
         _EntryList = Node._next ;
         RawMonitor_lock->unlock() ;
         return OS_OK ;
--- a/src/hotspot/share/prims/whitebox.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/prims/whitebox.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -1727,10 +1727,16 @@
 
 WB_ENTRY(jboolean, WB_IsCDSIncludedInVmBuild(JNIEnv* env))
 #if INCLUDE_CDS
+# ifdef _LP64
+    if (!UseCompressedOops || !UseCompressedClassPointers) {
+      // On 64-bit VMs, CDS is supported only with compressed oops/pointers
+      return false;
+    }
+# endif // _LP64
   return true;
 #else
   return false;
-#endif
+#endif // INCLUDE_CDS
 WB_END
 
 
--- a/src/hotspot/share/runtime/arguments.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/arguments.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -204,7 +204,9 @@
   _writeable = writeable;
 }
 
-AgentLibrary::AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib) {
+AgentLibrary::AgentLibrary(const char* name, const char* options,
+               bool is_absolute_path, void* os_lib,
+               bool instrument_lib) {
   _name = AllocateHeap(strlen(name)+1, mtArguments);
   strcpy(_name, name);
   if (options == NULL) {
@@ -218,6 +220,7 @@
   _next = NULL;
   _state = agent_invalid;
   _is_static_lib = false;
+  _is_instrument_lib = instrument_lib;
 }
 
 // Check if head of 'option' matches 'name', and sets 'tail' to the remaining
@@ -294,6 +297,10 @@
   _agentList.add(new AgentLibrary(name, options, absolute_path, NULL));
 }
 
+void Arguments::add_instrument_agent(const char* name, char* options, bool absolute_path) {
+  _agentList.add(new AgentLibrary(name, options, absolute_path, NULL, true));
+}
+
 // Late-binding agents not started via arguments
 void Arguments::add_loaded_agent(AgentLibrary *agentLib) {
   _agentList.add(agentLib);
@@ -501,7 +508,7 @@
   { "MaxRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
   { "MinRAMFraction",               JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
   { "InitialRAMFraction",           JDK_Version::jdk(10),  JDK_Version::undefined(), JDK_Version::undefined() },
-  { "UseMembar",                    JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
+  { "UseMembar",                    JDK_Version::jdk(10), JDK_Version::undefined(), JDK_Version::undefined() },
   { "FastTLABRefill",               JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
   { "SafepointSpinBeforeYield",     JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
   { "DeferThrSuspendLoopCount",     JDK_Version::jdk(10), JDK_Version::jdk(11), JDK_Version::jdk(12) },
@@ -678,6 +685,14 @@
   return false;
 }
 
+// Verifies the correctness of the entries in the special_jvm_flags table.
+// If there is a semantic error (i.e. a bug in the table) such as the obsoletion
+// version being earlier than the deprecation version, then a warning is issued
+// and verification fails - by returning false. If it is detected that the table
+// is out of date, with respect to the current version, then a warning is issued
+// but verification does not fail. This allows the VM to operate when the version
+// is first updated, without needing to update all the impacted flags at the
+// same time.
 static bool verify_special_jvm_flags() {
   bool success = true;
   for (size_t i = 0; special_jvm_flags[i].name != NULL; i++) {
@@ -714,7 +729,6 @@
       if (!version_less_than(JDK_Version::current(), flag.obsolete_in)) {
         if (Flag::find_flag(flag.name) != NULL) {
           warning("Global variable for obsolete special flag entry \"%s\" should be removed", flag.name);
-          success = false;
         }
       }
     }
@@ -724,7 +738,6 @@
       if (!version_less_than(JDK_Version::current(), flag.expired_in)) {
         if (Flag::find_flag(flag.name) != NULL) {
           warning("Global variable for expired flag entry \"%s\" should be removed", flag.name);
-          success = false;
         }
       }
     }
@@ -2795,7 +2808,7 @@
         size_t length = strlen(tail) + 1;
         char *options = NEW_C_HEAP_ARRAY(char, length, mtArguments);
         jio_snprintf(options, length, "%s", tail);
-        add_init_agent("instrument", options, false);
+        add_instrument_agent("instrument", options, false);
         // java agents need module java.instrument
         if (!create_numbered_property("jdk.module.addmods", "java.instrument", addmods_count++)) {
           return JNI_ENOMEM;
--- a/src/hotspot/share/runtime/arguments.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/arguments.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -142,6 +142,7 @@
   void*           _os_lib;
   bool            _is_absolute_path;
   bool            _is_static_lib;
+  bool            _is_instrument_lib;
   AgentState      _state;
   AgentLibrary*   _next;
 
@@ -154,13 +155,15 @@
   void set_os_lib(void* os_lib)             { _os_lib = os_lib; }
   AgentLibrary* next() const                { return _next; }
   bool is_static_lib() const                { return _is_static_lib; }
+  bool is_instrument_lib() const            { return _is_instrument_lib; }
   void set_static_lib(bool is_static_lib)   { _is_static_lib = is_static_lib; }
   bool valid()                              { return (_state == agent_valid); }
   void set_valid()                          { _state = agent_valid; }
   void set_invalid()                        { _state = agent_invalid; }
 
   // Constructor
-  AgentLibrary(const char* name, const char* options, bool is_absolute_path, void* os_lib);
+  AgentLibrary(const char* name, const char* options, bool is_absolute_path,
+               void* os_lib, bool instrument_lib=false);
 };
 
 // maintain an order of entry list of AgentLibrary
@@ -337,6 +340,7 @@
   // -agentlib and -agentpath arguments
   static AgentLibraryList _agentList;
   static void add_init_agent(const char* name, char* options, bool absolute_path);
+  static void add_instrument_agent(const char* name, char* options, bool absolute_path);
 
   // Late-binding agents not started via arguments
   static void add_loaded_agent(AgentLibrary *agentLib);
--- a/src/hotspot/share/runtime/atomic.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/atomic.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -45,8 +45,8 @@
 
 class Atomic : AllStatic {
 public:
-  // Atomic operations on jlong types are not available on all 32-bit
-  // platforms. If atomic ops on jlongs are defined here they must only
+  // Atomic operations on int64 types are not available on all 32-bit
+  // platforms. If atomic ops on int64 are defined here they must only
   // be used from code that verifies they are available at runtime and
   // can provide an alternative action if not - see supports_cx8() for
   // a means to test availability.
@@ -639,16 +639,16 @@
 //
 // Use the ATOMIC_SHORT_PAIR macro (see macros.hpp) to get the desired alignment.
 template<>
-struct Atomic::AddImpl<jshort, jshort> VALUE_OBJ_CLASS_SPEC {
-  jshort operator()(jshort add_value, jshort volatile* dest) const {
+struct Atomic::AddImpl<short, short> VALUE_OBJ_CLASS_SPEC {
+  short operator()(short add_value, short volatile* dest) const {
 #ifdef VM_LITTLE_ENDIAN
     assert((intx(dest) & 0x03) == 0x02, "wrong alignment");
-    jint new_value = Atomic::add(add_value << 16, (volatile jint*)(dest-1));
+    int new_value = Atomic::add(add_value << 16, (volatile int*)(dest-1));
 #else
     assert((intx(dest) & 0x03) == 0x00, "wrong alignment");
-    jint new_value = Atomic::add(add_value << 16, (volatile jint*)(dest));
+    int new_value = Atomic::add(add_value << 16, (volatile int*)(dest));
 #endif
-    return (jshort)(new_value >> 16); // preserves sign
+    return (short)(new_value >> 16); // preserves sign
   }
 };
 
@@ -807,7 +807,7 @@
   do {
     // value to swap in matches current value ...
     uint32_t new_value = cur;
-    // ... except for the one jbyte we want to update
+    // ... except for the one byte we want to update
     reinterpret_cast<uint8_t*>(&new_value)[offset] = canon_exchange_value;
 
     uint32_t res = cmpxchg(new_value, aligned_dest, cur, order);
--- a/src/hotspot/share/runtime/jniHandles.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/jniHandles.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -47,6 +47,7 @@
   } else {
     Thread* thread = Thread::current();
     assert(Universe::heap()->is_in_reserved(obj), "sanity check");
+    assert(!current_thread_in_native(), "must not be in native");
     return thread->active_handles()->allocate_handle(obj);
   }
 }
@@ -59,6 +60,8 @@
     return NULL;                // ignore null handles
   } else {
     assert(Universe::heap()->is_in_reserved(obj), "sanity check");
+    assert(thread->is_Java_thread(), "not a Java thread");
+    assert(!current_thread_in_native(), "must not be in native");
     return thread->active_handles()->allocate_handle(obj);
   }
 }
@@ -70,6 +73,7 @@
   } else {
     JavaThread* thread = JavaThread::thread_from_jni_environment(env);
     assert(Universe::heap()->is_in_reserved(obj), "sanity check");
+    assert(!current_thread_in_native(), "must not be in native");
     return thread->active_handles()->allocate_handle(obj);
   }
 }
@@ -77,6 +81,7 @@
 
 jobject JNIHandles::make_global(Handle obj) {
   assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC");
+  assert(!current_thread_in_native(), "must not be in native");
   jobject res = NULL;
   if (!obj.is_null()) {
     // ignore null handles
@@ -93,6 +98,7 @@
 
 jobject JNIHandles::make_weak_global(Handle obj) {
   assert(!Universe::heap()->is_gc_active(), "can't extend the root set during GC");
+  assert(!current_thread_in_native(), "must not be in native");
   jobject res = NULL;
   if (!obj.is_null()) {
     // ignore null handles
@@ -265,6 +271,13 @@
   weak_oops_do(&verify_handle);
 }
 
+// This method is implemented here to avoid circular includes between
+// jniHandles.hpp and thread.hpp.
+bool JNIHandles::current_thread_in_native() {
+  Thread* thread = Thread::current();
+  return (thread->is_Java_thread() &&
+          JavaThread::current()->thread_state() == _thread_in_native);
+}
 
 
 void jni_handles_init() {
--- a/src/hotspot/share/runtime/jniHandles.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/jniHandles.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -48,6 +48,10 @@
   template<bool external_guard> inline static oop resolve_impl(jobject handle);
   template<bool external_guard> static oop resolve_jweak(jweak handle);
 
+  // This method is not inlined in order to avoid circular includes between
+  // this header file and thread.hpp.
+  static bool current_thread_in_native();
+
  public:
   // Low tag bit in jobject used to distinguish a jweak.  jweak is
   // type equivalent to jobject, but there are places where we need to
@@ -230,6 +234,7 @@
 template<bool external_guard>
 inline oop JNIHandles::resolve_impl(jobject handle) {
   assert(handle != NULL, "precondition");
+  assert(!current_thread_in_native(), "must not be in native");
   oop result;
   if (is_jweak(handle)) {       // Unlikely
     result = resolve_jweak<external_guard>(handle);
--- a/src/hotspot/share/runtime/mutex.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/mutex.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -467,7 +467,7 @@
   OrderAccess::fence();
 
   // Optional optimization ... try barging on the inner lock
-  if ((NativeMonitorFlags & 32) && Atomic::cmpxchg(ESelf, &_OnDeck, (ParkEvent*)NULL) == NULL) {
+  if ((NativeMonitorFlags & 32) && Atomic::replace_if_null(ESelf, &_OnDeck)) {
     goto OnDeck_LOOP;
   }
 
@@ -574,7 +574,7 @@
   // Unlike a normal lock, however, the exiting thread "locks" OnDeck,
   // picks a successor and marks that thread as OnDeck.  That successor
   // thread will then clear OnDeck once it eventually acquires the outer lock.
-  if (Atomic::cmpxchg((ParkEvent*)_LBIT, &_OnDeck, (ParkEvent*)NULL) != NULL) {
+  if (!Atomic::replace_if_null((ParkEvent*)_LBIT, &_OnDeck)) {
     return;
   }
 
--- a/src/hotspot/share/runtime/objectMonitor.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/objectMonitor.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -421,7 +421,7 @@
 int ObjectMonitor::TryLock(Thread * Self) {
   void * own = _owner;
   if (own != NULL) return 0;
-  if (Atomic::cmpxchg(Self, &_owner, (void*)NULL) == NULL) {
+  if (Atomic::replace_if_null(Self, &_owner)) {
     // Either guarantee _recursions == 0 or set _recursions = 0.
     assert(_recursions == 0, "invariant");
     assert(_owner == Self, "invariant");
@@ -529,7 +529,7 @@
   if ((SyncFlags & 16) == 0 && nxt == NULL && _EntryList == NULL) {
     // Try to assume the role of responsible thread for the monitor.
     // CONSIDER:  ST vs CAS vs { if (Responsible==null) Responsible=Self }
-    Atomic::cmpxchg(Self, &_Responsible, (Thread*)NULL);
+    Atomic::replace_if_null(Self, &_Responsible);
   }
 
   // The lock might have been released while this thread was occupied queueing
@@ -553,7 +553,7 @@
     assert(_owner != Self, "invariant");
 
     if ((SyncFlags & 2) && _Responsible == NULL) {
-      Atomic::cmpxchg(Self, &_Responsible, (Thread*)NULL);
+      Atomic::replace_if_null(Self, &_Responsible);
     }
 
     // park self
@@ -1007,7 +1007,7 @@
       // to reacquire the lock the responsibility for ensuring succession
       // falls to the new owner.
       //
-      if (Atomic::cmpxchg(THREAD, &_owner, (void*)NULL) != NULL) {
+      if (!Atomic::replace_if_null(THREAD, &_owner)) {
         return;
       }
       TEVENT(Exit - Reacquired);
@@ -1032,7 +1032,7 @@
         // B.  If the elements forming the EntryList|cxq are TSM
         //     we could simply unpark() the lead thread and return
         //     without having set _succ.
-        if (Atomic::cmpxchg(THREAD, &_owner, (void*)NULL) != NULL) {
+        if (!Atomic::replace_if_null(THREAD, &_owner)) {
           TEVENT(Inflated exit - reacquired succeeded);
           return;
         }
@@ -1714,7 +1714,7 @@
         ObjectWaiter * tail = _cxq;
         if (tail == NULL) {
           iterator->_next = NULL;
-          if (Atomic::cmpxchg(iterator, &_cxq, (ObjectWaiter*)NULL) == NULL) {
+          if (Atomic::replace_if_null(iterator, &_cxq)) {
             break;
           }
         } else {
--- a/src/hotspot/share/runtime/safepoint.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/safepoint.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -103,7 +103,7 @@
 
   int nof_threads = Threads::number_of_threads();
 
-  log_debug(safepoint)("Safepoint synchronization initiated. (%d)", nof_threads);
+  log_debug(safepoint)("Safepoint synchronization initiated. (%d threads)", nof_threads);
 
   RuntimeService::record_safepoint_begin();
 
@@ -407,9 +407,7 @@
   // Update the count of active JNI critical regions
   GCLocker::set_jni_lock_count(_current_jni_active_count);
 
-  if (log_is_enabled(Debug, safepoint)) {
-    log_debug(safepoint)("Entering safepoint region: %s", VMThread::vm_safepoint_description());
-  }
+  log_info(safepoint)("Entering safepoint region: %s", VMThread::vm_safepoint_description());
 
   RuntimeService::record_safepoint_synchronized();
   if (PrintSafepointStatistics) {
@@ -496,14 +494,14 @@
           cur_state->restart(); // TSS _running
           SafepointMechanism::disarm_local_poll(current); // release store, local state -> polling page
         }
-        log_debug(safepoint)("Leaving safepoint region");
+        log_info(safepoint)("Leaving safepoint region");
       } else {
         // Set to not synchronized, so the threads will not go into the signal_thread_blocked method
         // when they get restarted.
         _state = _not_synchronized;
         OrderAccess::fence();
 
-        log_debug(safepoint)("Leaving safepoint region");
+        log_info(safepoint)("Leaving safepoint region");
 
         // Start suspended threads
         jtiwh.rewind();
--- a/src/hotspot/share/runtime/stubRoutines.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/stubRoutines.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -62,12 +62,11 @@
 address StubRoutines::_atomic_xchg_entry                        = NULL;
 address StubRoutines::_atomic_xchg_long_entry                   = NULL;
 address StubRoutines::_atomic_store_entry                       = NULL;
-address StubRoutines::_atomic_store_ptr_entry                   = NULL;
 address StubRoutines::_atomic_cmpxchg_entry                     = NULL;
 address StubRoutines::_atomic_cmpxchg_byte_entry                = NULL;
 address StubRoutines::_atomic_cmpxchg_long_entry                = NULL;
 address StubRoutines::_atomic_add_entry                         = NULL;
-address StubRoutines::_atomic_add_ptr_entry                     = NULL;
+address StubRoutines::_atomic_add_long_entry                    = NULL;
 address StubRoutines::_fence_entry                              = NULL;
 address StubRoutines::_d2i_wrapper                              = NULL;
 address StubRoutines::_d2l_wrapper                              = NULL;
--- a/src/hotspot/share/runtime/stubRoutines.hpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/stubRoutines.hpp	Thu Jan 18 18:58:46 2018 +0000
@@ -103,12 +103,11 @@
   static address _atomic_xchg_entry;
   static address _atomic_xchg_long_entry;
   static address _atomic_store_entry;
-  static address _atomic_store_ptr_entry;
   static address _atomic_cmpxchg_entry;
   static address _atomic_cmpxchg_byte_entry;
   static address _atomic_cmpxchg_long_entry;
   static address _atomic_add_entry;
-  static address _atomic_add_ptr_entry;
+  static address _atomic_add_long_entry;
   static address _fence_entry;
   static address _d2i_wrapper;
   static address _d2l_wrapper;
@@ -277,12 +276,11 @@
   static address atomic_xchg_entry()                       { return _atomic_xchg_entry; }
   static address atomic_xchg_long_entry()                  { return _atomic_xchg_long_entry; }
   static address atomic_store_entry()                      { return _atomic_store_entry; }
-  static address atomic_store_ptr_entry()                  { return _atomic_store_ptr_entry; }
   static address atomic_cmpxchg_entry()                    { return _atomic_cmpxchg_entry; }
   static address atomic_cmpxchg_byte_entry()               { return _atomic_cmpxchg_byte_entry; }
   static address atomic_cmpxchg_long_entry()               { return _atomic_cmpxchg_long_entry; }
   static address atomic_add_entry()                        { return _atomic_add_entry; }
-  static address atomic_add_ptr_entry()                    { return _atomic_add_ptr_entry; }
+  static address atomic_add_long_entry()                   { return _atomic_add_long_entry; }
   static address fence_entry()                             { return _fence_entry; }
 
   static address d2i_wrapper()                             { return _d2i_wrapper; }
--- a/src/hotspot/share/runtime/synchronizer.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/synchronizer.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -238,8 +238,7 @@
     // and last are the inflated Java Monitor (ObjectMonitor) checks.
     lock->set_displaced_header(markOopDesc::unused_mark());
 
-    if (owner == NULL &&
-        Atomic::cmpxchg(Self, &(m->_owner), (void*)NULL) == NULL) {
+    if (owner == NULL && Atomic::replace_if_null(Self, &(m->_owner))) {
       assert(m->_recursions == 0, "invariant");
       assert(m->_owner == Self, "invariant");
       return true;
--- a/src/hotspot/share/runtime/thread.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/runtime/thread.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -4039,9 +4039,16 @@
         }
         if (library == NULL) {
           const char *sub_msg = " on the library path, with error: ";
-          size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) + strlen(ebuf) + 1;
+          const char *sub_msg2 = "\nModule java.instrument may be missing from runtime image.";
+
+          size_t len = strlen(msg) + strlen(name) + strlen(sub_msg) +
+                       strlen(ebuf) + strlen(sub_msg2) + 1;
           char *buf = NEW_C_HEAP_ARRAY(char, len, mtThread);
-          jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf);
+          if (!agent->is_instrument_lib()) {
+            jio_snprintf(buf, len, "%s%s%s%s", msg, name, sub_msg, ebuf);
+          } else {
+            jio_snprintf(buf, len, "%s%s%s%s%s", msg, name, sub_msg, ebuf, sub_msg2);
+          }
           // If we can't find the agent, exit.
           vm_exit_during_initialization(buf, NULL);
           FREE_C_HEAP_ARRAY(char, buf);
--- a/src/hotspot/share/services/mallocSiteTable.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/services/mallocSiteTable.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -147,7 +147,7 @@
     if (entry == NULL) return NULL;
 
     // swap in the head
-    if (Atomic::cmpxchg(entry, &_table[index], (MallocSiteHashtableEntry*)NULL) == NULL) {
+    if (Atomic::replace_if_null(entry, &_table[index])) {
       return entry->data();
     }
 
@@ -259,5 +259,5 @@
 }
 
 bool MallocSiteHashtableEntry::atomic_insert(MallocSiteHashtableEntry* entry) {
-  return Atomic::cmpxchg(entry, &_next, (MallocSiteHashtableEntry*)NULL) == NULL;
+  return Atomic::replace_if_null(entry, &_next);
 }
--- a/src/hotspot/share/utilities/bitMap.cpp	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/hotspot/share/utilities/bitMap.cpp	Thu Jan 18 18:58:46 2018 +0000
@@ -628,7 +628,7 @@
       table[i] = num_set_bits(i);
     }
 
-    if (Atomic::cmpxchg(table, &_pop_count_table, (BitMap::idx_t*)NULL) != NULL) {
+    if (!Atomic::replace_if_null(table, &_pop_count_table)) {
       guarantee(_pop_count_table != NULL, "invariant");
       FREE_C_HEAP_ARRAY(idx_t, table);
     }
--- a/src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/linux/classes/sun/nio/fs/LinuxFileStore.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -66,6 +66,8 @@
         }
 
         // step 2: find mount point
+        List<UnixMountEntry> procMountsEntries =
+            fs.getMountEntries("/proc/mounts");
         UnixPath parent = path.getParent();
         while (parent != null) {
             UnixFileAttributes attrs = null;
@@ -74,16 +76,23 @@
             } catch (UnixException x) {
                 x.rethrowAsIOException(parent);
             }
-            if (attrs.dev() != dev())
-                break;
+            if (attrs.dev() != dev()) {
+                // step 3: lookup mounted file systems (use /proc/mounts to
+                // ensure we find the file system even when not in /etc/mtab)
+                byte[] dir = path.asByteArray();
+                for (UnixMountEntry entry : procMountsEntries) {
+                    if (Arrays.equals(dir, entry.dir()))
+                        return entry;
+                }
+            }
             path = parent;
             parent = parent.getParent();
         }
 
-        // step 3: lookup mounted file systems (use /proc/mounts to ensure we
-        // find the file system even when not in /etc/mtab)
+        // step 3: lookup mounted file systems (use /proc/mounts to
+        // ensure we find the file system even when not in /etc/mtab)
         byte[] dir = path.asByteArray();
-        for (UnixMountEntry entry: fs.getMountEntries("/proc/mounts")) {
+        for (UnixMountEntry entry : procMountsEntries) {
             if (Arrays.equals(dir, entry.dir()))
                 return entry;
         }
--- a/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/linux/classes/sun/nio/fs/LinuxFileSystem.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -75,7 +75,7 @@
     /**
      * Returns object to iterate over the mount entries in the given fstab file.
      */
-    Iterable<UnixMountEntry> getMountEntries(String fstab) {
+    List<UnixMountEntry> getMountEntries(String fstab) {
         ArrayList<UnixMountEntry> entries = new ArrayList<>();
         try {
             long fp = setmntent(Util.toBytes(fstab), Util.toBytes("r"));
@@ -101,7 +101,7 @@
      * Returns object to iterate over the mount entries in /etc/mtab
      */
     @Override
-    Iterable<UnixMountEntry> getMountEntries() {
+    List<UnixMountEntry> getMountEntries() {
         return getMountEntries("/etc/mtab");
     }
 
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Constants.java	Thu Jan 18 18:58:46 2018 +0000
@@ -48,6 +48,7 @@
         1.8 to 1.8.X 52,0
         1.9 to 1.9.X 53,0
         1.10 to 1.10.X 54,0
+        1.11 to 1.11.X 55,0
     */
 
     public static final Package.Version JAVA_MIN_CLASS_VERSION =
@@ -71,6 +72,9 @@
     public static final Package.Version JAVA10_MAX_CLASS_VERSION =
             Package.Version.of(54, 00);
 
+    public static final Package.Version JAVA11_MAX_CLASS_VERSION =
+            Package.Version.of(55, 00);
+
     public static final int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
 
     public static final Package.Version JAVA5_PACKAGE_VERSION =
@@ -87,7 +91,7 @@
 
     // upper limit, should point to the latest class version
     public static final Package.Version JAVA_MAX_CLASS_VERSION =
-            JAVA10_MAX_CLASS_VERSION;
+            JAVA11_MAX_CLASS_VERSION;
 
     // upper limit should point to the latest package version, for version info!.
     public static final Package.Version MAX_PACKAGE_VERSION =
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/Driver.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, 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
@@ -162,11 +162,12 @@
                         engProps.put((String) me.getKey(), (String) me.getValue());
                     }
                 } else if ("--version".equals(state)) {
-                        System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.VERSION), Driver.class.getName(), "1.31, 07/05/05"));
+                        System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.VERSION),
+                                                                Driver.class.getName(), "1.31, 07/05/05"));
                     return;
                 } else if ("--help".equals(state)) {
                     printUsage(doPack, true, System.out);
-                    System.exit(1);
+                    System.exit(0);
                     return;
                 } else {
                     break;
--- a/src/java.base/share/classes/com/sun/java/util/jar/pack/DriverResource.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/com/sun/java/util/jar/pack/DriverResource.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -89,7 +89,7 @@
                 "  -q, --quiet                     set verbosity to lowest level",
                 "  -l{F}, --log-file={F}           output to the given log file, ",
                 "                                  or '-' for System.out",
-                "  -?, -h, --help                  print this message",
+                "  -?, -h, --help                  print this help message",
                 "  -V, --version                   print program version",
                 "  -J{X}                           pass option X to underlying Java VM",
                 "",
@@ -118,7 +118,7 @@
                 "  -q, --quiet                   set verbosity to lowest level",
                 "  -l{F}, --log-file={F}         output to the given log file, or",
                 "                                '-' for System.out",
-                "  -?, -h, --help                print this message",
+                "  -?, -h, --help                print this help message",
                 "  -V, --version                 print program version",
                 "  -J{X}                         pass option X to underlying Java VM"
             }
--- a/src/java.base/share/classes/java/io/ByteArrayOutputStream.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/io/ByteArrayOutputStream.java	Thu Jan 18 18:58:46 2018 +0000
@@ -27,6 +27,7 @@
 
 import java.nio.charset.Charset;
 import java.util.Arrays;
+import java.util.Objects;
 
 /**
  * This class implements an output stream in which the data is
@@ -147,10 +148,7 @@
      * @param   len   the number of bytes to write.
      */
     public synchronized void write(byte b[], int off, int len) {
-        if ((off < 0) || (off > b.length) || (len < 0) ||
-            ((off + len) - b.length > 0)) {
-            throw new IndexOutOfBoundsException();
-        }
+        Objects.checkFromIndexSize(off, len, b.length);
         ensureCapacity(count + len);
         System.arraycopy(b, off, buf, count, len);
         count += len;
--- a/src/java.base/share/classes/java/io/File.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/io/File.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -2256,7 +2256,7 @@
     private transient volatile Path filePath;
 
     /**
-     * Returns a {@link Path java.nio.file.Path} object constructed from the
+     * Returns a {@link Path java.nio.file.Path} object constructed from
      * this abstract path. The resulting {@code Path} is associated with the
      * {@link java.nio.file.FileSystems#getDefault default-filesystem}.
      *
--- a/src/java.base/share/classes/java/io/InputStream.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/io/InputStream.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -25,7 +25,9 @@
 
 package java.io;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -54,6 +56,93 @@
     private static final int DEFAULT_BUFFER_SIZE = 8192;
 
     /**
+     * Returns a new {@code InputStream} that reads no bytes. The returned
+     * stream is initially open.  The stream is closed by calling the
+     * {@code close()} method.  Subsequent calls to {@code close()} have no
+     * effect.
+     *
+     * <p> While the stream is open, the {@code available()}, {@code read()},
+     * {@code read(byte[])}, {@code read(byte[], int, int)},
+     * {@code readAllBytes()}, {@code readNBytes()}, {@code skip()}, and
+     * {@code transferTo()} methods all behave as if end of stream has been
+     * reached.  After the stream has been closed, these methods all throw
+     * {@code IOException}.
+     *
+     * <p> The {@code markSupported()} method returns {@code false}.  The
+     * {@code mark()} method does nothing, and the {@code reset()} method
+     * throws {@code IOException}.
+     *
+     * @return an {@code InputStream} which contains no bytes
+     *
+     * @since 11
+     */
+    public static InputStream nullInputStream() {
+        return new InputStream() {
+            private volatile boolean closed;
+
+            private void ensureOpen() throws IOException {
+                if (closed) {
+                    throw new IOException("Stream closed");
+                }
+            }
+
+            @Override
+            public int available () throws IOException {
+                ensureOpen();
+                return 0;
+            }
+
+            @Override
+            public int read() throws IOException {
+                ensureOpen();
+                return -1;
+            }
+
+            @Override
+            public int read(byte[] b, int off, int len) throws IOException {
+                Objects.checkFromIndexSize(off, len, b.length);
+                if (len == 0) {
+                    return 0;
+                }
+                ensureOpen();
+                return -1;
+            }
+
+            @Override
+            public byte[] readAllBytes() throws IOException {
+                ensureOpen();
+                return new byte[0];
+            }
+
+            @Override
+            public int readNBytes(byte[] b, int off, int len)
+                throws IOException {
+                Objects.checkFromIndexSize(off, len, b.length);
+                ensureOpen();
+                return 0;
+            }
+
+            @Override
+            public long skip(long n) throws IOException {
+                ensureOpen();
+                return 0L;
+            }
+
+            @Override
+            public long transferTo(OutputStream out) throws IOException {
+                Objects.requireNonNull(out);
+                ensureOpen();
+                return 0L;
+            }
+
+            @Override
+            public void close() throws IOException {
+                closed = true;
+            }
+        };
+    }
+
+    /**
      * Reads the next byte of data from the input stream. The value byte is
      * returned as an <code>int</code> in the range <code>0</code> to
      * <code>255</code>. If no byte is available because the end of the stream
@@ -164,7 +253,6 @@
      * @see        java.io.InputStream#read()
      */
     public int read(byte b[], int off, int len) throws IOException {
-        Objects.requireNonNull(b);
         Objects.checkFromIndexSize(off, len, b.length);
         if (len == 0) {
             return 0;
@@ -229,30 +317,55 @@
      * @since 9
      */
     public byte[] readAllBytes() throws IOException {
-        byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
-        int capacity = buf.length;
-        int nread = 0;
+        List<byte[]> bufs = null;
+        byte[] result = null;
+        int total = 0;
         int n;
-        for (;;) {
-            // read to EOF which may read more or less than initial buffer size
-            while ((n = read(buf, nread, capacity - nread)) > 0)
+        do {
+            byte[] buf = new byte[DEFAULT_BUFFER_SIZE];
+            int nread = 0;
+
+            // read to EOF which may read more or less than buffer size
+            while ((n = read(buf, nread, buf.length - nread)) > 0) {
                 nread += n;
+            }
 
-            // if the last call to read returned -1, then we're done
-            if (n < 0)
-                break;
+            if (nread > 0) {
+                if (MAX_BUFFER_SIZE - total < nread) {
+                    throw new OutOfMemoryError("Required array size too large");
+                }
+                total += nread;
+                if (result == null) {
+                    result = buf;
+                } else {
+                    if (bufs == null) {
+                        bufs = new ArrayList<>();
+                        bufs.add(result);
+                    }
+                    bufs.add(buf);
+                }
+            }
+        } while (n >= 0); // if the last call to read returned -1, then break
 
-            // need to allocate a larger buffer
-            if (capacity <= MAX_BUFFER_SIZE - capacity) {
-                capacity = capacity << 1;
-            } else {
-                if (capacity == MAX_BUFFER_SIZE)
-                    throw new OutOfMemoryError("Required array size too large");
-                capacity = MAX_BUFFER_SIZE;
+        if (bufs == null) {
+            if (result == null) {
+                return new byte[0];
             }
-            buf = Arrays.copyOf(buf, capacity);
+            return result.length == total ?
+                result : Arrays.copyOf(result, total);
         }
-        return (capacity == nread) ? buf : Arrays.copyOf(buf, nread);
+
+        result = new byte[total];
+        int offset = 0;
+        int remaining = total;
+        for (byte[] b : bufs) {
+            int len = Math.min(b.length, remaining);
+            System.arraycopy(b, 0, result, offset, len);
+            offset += len;
+            remaining -= len;
+        }
+
+        return result;
     }
 
     /**
@@ -299,7 +412,6 @@
      * @since 9
      */
     public int readNBytes(byte[] b, int off, int len) throws IOException {
-        Objects.requireNonNull(b);
         Objects.checkFromIndexSize(off, len, b.length);
 
         int n = 0;
--- a/src/java.base/share/classes/java/io/ObjectInputStream.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/io/ObjectInputStream.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1296,7 +1296,6 @@
      * @throws InvalidClassException if the filter rejects creation
      */
     private void checkArray(Class<?> arrayType, int arrayLength) throws InvalidClassException {
-        Objects.requireNonNull(arrayType);
         if (! arrayType.isArray()) {
             throw new IllegalArgumentException("not an array type");
         }
--- a/src/java.base/share/classes/java/io/OutputStream.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/io/OutputStream.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1994, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -47,6 +47,51 @@
  */
 public abstract class OutputStream implements Closeable, Flushable {
     /**
+     * Returns a new {@code OutputStream} which discards all bytes.  The
+     * returned stream is initially open.  The stream is closed by calling
+     * the {@code close()} method.  Subsequent calls to {@code close()} have
+     * no effect.
+     *
+     * <p> While the stream is open, the {@code write(int)}, {@code
+     * write(byte[])}, and {@code write(byte[], int, int)} methods do nothing.
+     * After the stream has been closed, these methods all throw {@code
+     * IOException}.
+     *
+     * <p> The {@code flush()} method does nothing.
+     *
+     * @return an {@code OutputStream} which discards all bytes
+     *
+     * @since 11
+     */
+    public static OutputStream nullOutputStream() {
+        return new OutputStream() {
+            private volatile boolean closed;
+
+            private void ensureOpen() throws IOException {
+                if (closed) {
+                    throw new IOException("Stream closed");
+                }
+            }
+
+            @Override
+            public void write(int b) throws IOException {
+                ensureOpen();
+            }
+
+            @Override
+            public void write(byte b[], int off, int len) throws IOException {
+                Objects.checkFromIndexSize(off, len, b.length);
+                ensureOpen();
+            }
+
+            @Override
+            public void close() {
+                closed = true;
+            }
+        };
+    }
+
+    /**
      * Writes the specified byte to this output stream. The general
      * contract for <code>write</code> is that one byte is written
      * to the output stream. The byte to be written is the eight
@@ -106,7 +151,6 @@
      *             stream is closed.
      */
     public void write(byte b[], int off, int len) throws IOException {
-        Objects.requireNonNull(b);
         Objects.checkFromIndexSize(off, len, b.length);
         // len == 0 condition implicitly handled by loop bounds
         for (int i = 0 ; i < len ; i++) {
--- a/src/java.base/share/classes/java/lang/Runtime.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/lang/Runtime.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -1099,16 +1099,23 @@
                     m.group(VersionPattern.OPT_GROUP));
 
             // empty '+'
-            if ((m.group(VersionPattern.PLUS_GROUP) != null)
-                    && !build.isPresent()) {
-                if (optional.isPresent()) {
-                    if (pre.isPresent())
-                        throw new IllegalArgumentException("'+' found with"
-                            + " pre-release and optional components:'" + s
-                            + "'");
+            if (!build.isPresent()) {
+                if (m.group(VersionPattern.PLUS_GROUP) != null) {
+                    if (optional.isPresent()) {
+                        if (pre.isPresent())
+                            throw new IllegalArgumentException("'+' found with"
+                                + " pre-release and optional components:'" + s
+                                + "'");
+                    } else {
+                        throw new IllegalArgumentException("'+' found with neither"
+                            + " build or optional components: '" + s + "'");
+                    }
                 } else {
-                    throw new IllegalArgumentException("'+' found with neither"
-                        + " build or optional components: '" + s + "'");
+                    if (optional.isPresent() && !pre.isPresent()) {
+                        throw new IllegalArgumentException("optional component"
+                            + " must be preceeded by a pre-release component"
+                            + " or '+': '" + s + "'");
+                    }
                 }
             }
             return new Version(List.of(version), pre, build, optional);
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandle.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandle.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1667,6 +1667,7 @@
     /** Craft a LambdaForm customized for this particular MethodHandle */
     /*non-public*/
     void customize() {
+        final LambdaForm form = this.form;
         if (form.customized == null) {
             LambdaForm newForm = form.customize(this);
             updateForm(newForm);
--- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java	Thu Jan 18 18:58:46 2018 +0000
@@ -3766,6 +3766,7 @@
      * specified in the elements of the {@code filters} array.
      * The first element of the filter array corresponds to the {@code pos}
      * argument of the target, and so on in sequence.
+     * The filter functions are invoked in left to right order.
      * <p>
      * Null arguments in the array are treated as identity functions,
      * and the corresponding arguments left unchanged.
@@ -3836,11 +3837,12 @@
     MethodHandle filterArguments(MethodHandle target, int pos, MethodHandle... filters) {
         filterArgumentsCheckArity(target, pos, filters);
         MethodHandle adapter = target;
-        int curPos = pos-1;  // pre-incremented
-        for (MethodHandle filter : filters) {
-            curPos += 1;
+        // process filters in reverse order so that the invocation of
+        // the resulting adapter will invoke the filters in left-to-right order
+        for (int i = filters.length - 1; i >= 0; --i) {
+            MethodHandle filter = filters[i];
             if (filter == null)  continue;  // ignore null elements of filters
-            adapter = filterArgument(adapter, curPos, filter);
+            adapter = filterArgument(adapter, pos + i, filter);
         }
         return adapter;
     }
--- a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java	Thu Jan 18 18:58:46 2018 +0000
@@ -2521,7 +2521,7 @@
      * the {@code packageFinder} throws an {@link UncheckedIOException} then
      * {@link IOException} cause will be re-thrown. </p>
      *
-     * <p> The module descriptor is read from the buffer stating at index
+     * <p> The module descriptor is read from the buffer starting at index
      * {@code p}, where {@code p} is the buffer's {@link ByteBuffer#position()
      * position} when this method is invoked. Upon return the buffer's position
      * will be equal to {@code p + n} where {@code n} is the number of bytes
--- a/src/java.base/share/classes/java/lang/ref/Reference.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/lang/ref/Reference.java	Thu Jan 18 18:58:46 2018 +0000
@@ -141,14 +141,6 @@
     }
 
     /*
-     * system property to disable clearing before enqueuing.
-     */
-    private static final class ClearBeforeEnqueue {
-        static final boolean DISABLE =
-            Boolean.getBoolean("jdk.lang.ref.disableClearBeforeEnqueue");
-    }
-
-    /*
      * Atomically get and clear (set to null) the VM's pending list.
      */
     private static native Reference<Object> getAndClearReferencePendingList();
@@ -299,8 +291,7 @@
      *           it was not registered with a queue when it was created
      */
     public boolean enqueue() {
-        if (!ClearBeforeEnqueue.DISABLE)
-            this.referent = null;
+        this.referent = null;
         return this.queue.enqueue(this);
     }
 
--- a/src/java.base/share/classes/java/net/InetSocketAddress.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/net/InetSocketAddress.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2013, 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
@@ -317,10 +317,9 @@
     }
 
     /**
-     *
      * Gets the {@code InetAddress}.
      *
-     * @return the InetAdress or {@code null} if it is unresolved.
+     * @return the InetAddress or {@code null} if it is unresolved.
      */
     public final InetAddress getAddress() {
         return holder.getAddress();
--- a/src/java.base/share/classes/java/nio/Bits.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/nio/Bits.java	Thu Jan 18 18:58:46 2018 +0000
@@ -63,38 +63,38 @@
 
     // -- Unsafe access --
 
-    private static final Unsafe unsafe = Unsafe.getUnsafe();
+    private static final Unsafe UNSAFE = Unsafe.getUnsafe();
 
     static Unsafe unsafe() {
-        return unsafe;
+        return UNSAFE;
     }
 
 
     // -- Processor and memory-system properties --
 
-    private static final ByteOrder byteOrder
-        = unsafe.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
+    private static final ByteOrder BYTE_ORDER
+        = UNSAFE.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
 
     static ByteOrder byteOrder() {
-        return byteOrder;
+        return BYTE_ORDER;
     }
 
-    private static int pageSize = -1;
+    private static int PAGE_SIZE = -1;
 
     static int pageSize() {
-        if (pageSize == -1)
-            pageSize = unsafe().pageSize();
-        return pageSize;
+        if (PAGE_SIZE == -1)
+            PAGE_SIZE = unsafe().pageSize();
+        return PAGE_SIZE;
     }
 
     static int pageCount(long size) {
         return (int)(size + (long)pageSize() - 1L) / pageSize();
     }
 
-    private static boolean unaligned = unsafe.unalignedAccess();
+    private static boolean UNALIGNED = UNSAFE.unalignedAccess();
 
     static boolean unaligned() {
-        return unaligned;
+        return UNALIGNED;
     }
 
 
@@ -103,11 +103,11 @@
     // A user-settable upper limit on the maximum amount of allocatable
     // direct buffer memory.  This value may be changed during VM
     // initialization if it is launched with "-XX:MaxDirectMemorySize=<size>".
-    private static volatile long maxMemory = VM.maxDirectMemory();
-    private static final AtomicLong reservedMemory = new AtomicLong();
-    private static final AtomicLong totalCapacity = new AtomicLong();
-    private static final AtomicLong count = new AtomicLong();
-    private static volatile boolean memoryLimitSet;
+    private static volatile long MAX_MEMORY = VM.maxDirectMemory();
+    private static final AtomicLong RESERVED_MEMORY = new AtomicLong();
+    private static final AtomicLong TOTAL_CAPACITY = new AtomicLong();
+    private static final AtomicLong COUNT = new AtomicLong();
+    private static volatile boolean MEMORY_LIMIT_SET;
 
     // max. number of sleeps during try-reserving with exponentially
     // increasing delay before throwing OutOfMemoryError:
@@ -120,9 +120,9 @@
     // which a process may access.  All sizes are specified in bytes.
     static void reserveMemory(long size, int cap) {
 
-        if (!memoryLimitSet && VM.initLevel() >= 1) {
-            maxMemory = VM.maxDirectMemory();
-            memoryLimitSet = true;
+        if (!MEMORY_LIMIT_SET && VM.initLevel() >= 1) {
+            MAX_MEMORY = VM.maxDirectMemory();
+            MEMORY_LIMIT_SET = true;
         }
 
         // optimist!
@@ -200,10 +200,10 @@
         // actual memory usage, which will differ when buffers are page
         // aligned.
         long totalCap;
-        while (cap <= maxMemory - (totalCap = totalCapacity.get())) {
-            if (totalCapacity.compareAndSet(totalCap, totalCap + cap)) {
-                reservedMemory.addAndGet(size);
-                count.incrementAndGet();
+        while (cap <= MAX_MEMORY - (totalCap = TOTAL_CAPACITY.get())) {
+            if (TOTAL_CAPACITY.compareAndSet(totalCap, totalCap + cap)) {
+                RESERVED_MEMORY.addAndGet(size);
+                COUNT.incrementAndGet();
                 return true;
             }
         }
@@ -213,9 +213,9 @@
 
 
     static void unreserveMemory(long size, int cap) {
-        long cnt = count.decrementAndGet();
-        long reservedMem = reservedMemory.addAndGet(-size);
-        long totalCap = totalCapacity.addAndGet(-cap);
+        long cnt = COUNT.decrementAndGet();
+        long reservedMem = RESERVED_MEMORY.addAndGet(-size);
+        long totalCap = TOTAL_CAPACITY.addAndGet(-cap);
         assert cnt >= 0 && reservedMem >= 0 && totalCap >= 0;
     }
 
@@ -234,15 +234,15 @@
                         }
                         @Override
                         public long getCount() {
-                            return Bits.count.get();
+                            return Bits.COUNT.get();
                         }
                         @Override
                         public long getTotalCapacity() {
-                            return Bits.totalCapacity.get();
+                            return Bits.TOTAL_CAPACITY.get();
                         }
                         @Override
                         public long getMemoryUsed() {
-                            return Bits.reservedMemory.get();
+                            return Bits.RESERVED_MEMORY.get();
                         }
                     };
                 }
--- a/src/java.base/share/classes/java/nio/Buffer.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/nio/Buffer.java	Thu Jan 18 18:58:46 2018 +0000
@@ -26,6 +26,7 @@
 package java.nio;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.misc.Unsafe;
 
 import java.util.Spliterator;
 
@@ -181,6 +182,8 @@
  */
 
 public abstract class Buffer {
+    // Cached unsafe-access object
+    static final Unsafe UNSAFE = Bits.unsafe();
 
     /**
      * The characteristics of Spliterators that traverse and split elements
@@ -617,6 +620,14 @@
     // -- Package-private methods for bounds checking, etc. --
 
     /**
+     *
+     * @return the base reference, paired with the address
+     * field, which in combination can be used for unsafe access into a heap
+     * buffer or direct byte buffer (and views of).
+     */
+    abstract Object base();
+
+    /**
      * Checks the current position against the limit, throwing a {@link
      * BufferUnderflowException} if it is not smaller than the limit, and then
      * increments the position.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/java/nio/BufferMismatch.java	Thu Jan 18 18:58:46 2018 +0000
@@ -0,0 +1,198 @@
+/*
+ * 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.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package java.nio;
+
+import jdk.internal.util.ArraysSupport;
+
+/**
+ * Mismatch methods for buffers
+ */
+final class BufferMismatch {
+
+    static int mismatch(ByteBuffer a, int aOff, ByteBuffer b, int bOff, int length) {
+        int i = 0;
+        if (length > 7) {
+            i = ArraysSupport.vectorizedMismatch(
+                    a.base(), a.address + aOff,
+                    b.base(), b.address + bOff,
+                    length,
+                    ArraysSupport.LOG2_ARRAY_BYTE_INDEX_SCALE);
+            if (i >= 0) return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a.get(aOff + i) != b.get(bOff + i))
+                return i;
+        }
+        return -1;
+    }
+
+    static int mismatch(CharBuffer a, int aOff, CharBuffer b, int bOff, int length) {
+        int i = 0;
+        // Ensure only heap or off-heap buffer instances use the
+        // vectorized mismatch. If either buffer is a StringCharBuffer
+        // (order is null) then the slow path is taken
+        if (length > 3 && a.charRegionOrder() == b.charRegionOrder()
+            && a.charRegionOrder() != null && b.charRegionOrder() != null) {
+            i = ArraysSupport.vectorizedMismatch(
+                    a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_CHAR_INDEX_SCALE),
+                    b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_CHAR_INDEX_SCALE),
+                    length,
+                    ArraysSupport.LOG2_ARRAY_CHAR_INDEX_SCALE);
+            if (i >= 0) return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a.get(aOff + i) != b.get(bOff + i))
+                return i;
+        }
+        return -1;
+    }
+
+    static int mismatch(ShortBuffer a, int aOff, ShortBuffer b, int bOff, int length) {
+        int i = 0;
+        if (length > 3 && a.order() == b.order()) {
+            i = ArraysSupport.vectorizedMismatch(
+                    a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_SHORT_INDEX_SCALE),
+                    b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_SHORT_INDEX_SCALE),
+                    length,
+                    ArraysSupport.LOG2_ARRAY_SHORT_INDEX_SCALE);
+            if (i >= 0) return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a.get(aOff + i) != b.get(bOff + i))
+                return i;
+        }
+        return -1;
+    }
+
+    static int mismatch(IntBuffer a, int aOff, IntBuffer b, int bOff, int length) {
+        int i = 0;
+        if (length > 1 && a.order() == b.order()) {
+            i = ArraysSupport.vectorizedMismatch(
+                    a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_INT_INDEX_SCALE),
+                    b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_INT_INDEX_SCALE),
+                    length,
+                    ArraysSupport.LOG2_ARRAY_INT_INDEX_SCALE);
+            if (i >= 0) return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a.get(aOff + i) != b.get(bOff + i))
+                return i;
+        }
+        return -1;
+    }
+
+    static int mismatch(FloatBuffer a, int aOff, FloatBuffer b, int bOff, int length) {
+        int i = 0;
+        if (length > 1 && a.order() == b.order()) {
+            i = ArraysSupport.vectorizedMismatch(
+                    a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_FLOAT_INDEX_SCALE),
+                    b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_FLOAT_INDEX_SCALE),
+                    length,
+                    ArraysSupport.LOG2_ARRAY_FLOAT_INDEX_SCALE);
+            // Mismatched
+            if (i >= 0) {
+                // Check if mismatch is not associated with two NaN values; and
+                // is not associated with +0 and -0
+                float av = a.get(aOff + i);
+                float bv = b.get(bOff + i);
+                if (av != bv && (!Float.isNaN(av) || !Float.isNaN(bv)))
+                    return i;
+
+                // Fall back to slow mechanism
+                // ISSUE: Consider looping over vectorizedMismatch adjusting ranges
+                // However, requires that returned value be relative to input ranges
+                i++;
+            }
+            // Matched
+            else {
+                i = length - ~i;
+            }
+        }
+        for (; i < length; i++) {
+            float av = a.get(aOff + i);
+            float bv = b.get(bOff + i);
+            if (av != bv && (!Float.isNaN(av) || !Float.isNaN(bv)))
+                return i;
+        }
+        return -1;
+    }
+
+    static int mismatch(LongBuffer a, int aOff, LongBuffer b, int bOff, int length) {
+        int i = 0;
+        if (length > 0 && a.order() == b.order()) {
+            i = ArraysSupport.vectorizedMismatch(
+                    a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_LONG_INDEX_SCALE),
+                    b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_LONG_INDEX_SCALE),
+                    length,
+                    ArraysSupport.LOG2_ARRAY_LONG_INDEX_SCALE);
+            return i >= 0 ? i : -1;
+        }
+        for (; i < length; i++) {
+            if (a.get(aOff + i) != b.get(bOff + i))
+                return i;
+        }
+        return -1;
+    }
+
+    static int mismatch(DoubleBuffer a, int aOff, DoubleBuffer b, int bOff, int length) {
+        int i = 0;
+        if (length > 0 && a.order() == b.order()) {
+            i = ArraysSupport.vectorizedMismatch(
+                    a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_DOUBLE_INDEX_SCALE),
+                    b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_DOUBLE_INDEX_SCALE),
+                    length,
+                    ArraysSupport.LOG2_ARRAY_DOUBLE_INDEX_SCALE);
+            // Mismatched
+            if (i >= 0) {
+                // Check if mismatch is not associated with two NaN values; and
+                // is not associated with +0 and -0
+                double av = a.get(aOff + i);
+                double bv = b.get(bOff + i);
+                if (av != bv && (!Double.isNaN(av) || !Double.isNaN(bv)))
+                    return i;
+
+                // Fall back to slow mechanism
+                // ISSUE: Consider looping over vectorizedMismatch adjusting ranges
+                // However, requires that returned value be relative to input ranges
+                i++;
+            }
+            // Matched
+            else {
+                return -1;
+            }
+        }
+        for (; i < length; i++) {
+            double av = a.get(aOff + i);
+            double bv = b.get(bOff + i);
+            if (av != bv && (!Double.isNaN(av) || !Double.isNaN(bv)))
+                return i;
+        }
+        return -1;
+    }
+}
--- a/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template	Thu Jan 18 18:58:46 2018 +0000
@@ -36,9 +36,6 @@
 
 #if[rw]
 
-    // Cached unsafe-access object
-    private static final Unsafe unsafe = Bits.unsafe();
-
     protected final ByteBuffer bb;
 
 #end[rw]
@@ -74,6 +71,11 @@
 #end[rw]
     }
 
+    @Override
+    Object base() {
+        return bb.hb;
+    }
+
     public $Type$Buffer slice() {
         int pos = this.position();
         int lim = this.limit();
@@ -117,20 +119,20 @@
     }
 
     public $type$ get() {
-        $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(nextGetIndex()),
+        $memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(nextGetIndex()),
             {#if[boB]?true:false});
         return $fromBits$(x);
     }
 
     public $type$ get(int i) {
-        $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)),
+        $memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)),
             {#if[boB]?true:false});
         return $fromBits$(x);
     }
 
 #if[streamableType]
    $type$ getUnchecked(int i) {
-        $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(i),
+        $memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(i),
             {#if[boB]?true:false});
         return $fromBits$(x);
     }
@@ -141,7 +143,7 @@
     public $Type$Buffer put($type$ x) {
 #if[rw]
         $memtype$ y = $toBits$(x);
-        unsafe.put$Memtype$Unaligned(bb.hb, byteOffset(nextPutIndex()), y,
+        UNSAFE.put$Memtype$Unaligned(bb.hb, byteOffset(nextPutIndex()), y,
             {#if[boB]?true:false});
         return this;
 #else[rw]
@@ -152,7 +154,7 @@
     public $Type$Buffer put(int i, $type$ x) {
 #if[rw]
         $memtype$ y = $toBits$(x);
-        unsafe.put$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), y,
+        UNSAFE.put$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), y,
             {#if[boB]?true:false});
         return this;
 #else[rw]
@@ -241,4 +243,9 @@
 #end[boL]
     }
 
+#if[char]
+    ByteOrder charRegionOrder() {
+        return order();
+    }
+#end[char]
 }
--- a/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template	Thu Jan 18 18:58:46 2018 +0000
@@ -32,7 +32,7 @@
 #if[rw]
 
     private $type$ get$Type$(long a) {
-        $memtype$ x = unsafe.get$Memtype$Unaligned(null, a, bigEndian);
+        $memtype$ x = UNSAFE.get$Memtype$Unaligned(null, a, bigEndian);
         return $fromBits$(x);
     }
 
@@ -49,7 +49,7 @@
     private ByteBuffer put$Type$(long a, $type$ x) {
 #if[rw]
         $memtype$ y = $toBits$(x);
-        unsafe.put$Memtype$Unaligned(null, a, y, bigEndian);
+        UNSAFE.put$Memtype$Unaligned(null, a, y, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -81,7 +81,7 @@
         int rem = (off <= lim ? lim - off : 0);
 
         int size = rem >> $LG_BYTES_PER_VALUE$;
-        if (!unaligned && ((address + off) % $BYTES_PER_VALUE$ != 0)) {
+        if (!UNALIGNED && ((address + off) % $BYTES_PER_VALUE$ != 0)) {
             return (bigEndian
                     ? ($Type$Buffer)(new ByteBufferAs$Type$Buffer$RW$B(this,
                                                                        -1,
--- a/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template	Thu Jan 18 18:58:46 2018 +0000
@@ -28,7 +28,6 @@
 package java.nio;
 
 import java.io.FileDescriptor;
-import jdk.internal.misc.Unsafe;
 import jdk.internal.misc.VM;
 import jdk.internal.ref.Cleaner;
 import sun.nio.ch.DirectBuffer;
@@ -45,14 +44,11 @@
 
 #if[rw]
 
-    // Cached unsafe-access object
-    protected static final Unsafe unsafe = Bits.unsafe();
-
     // Cached array base offset
-    private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset($type$[].class);
+    private static final long ARRAY_BASE_OFFSET = UNSAFE.arrayBaseOffset($type$[].class);
 
     // Cached unaligned-access capability
-    protected static final boolean unaligned = Bits.unaligned();
+    protected static final boolean UNALIGNED = Bits.unaligned();
 
     // Base address, used in all indexing calculations
     // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress
@@ -73,8 +69,6 @@
         implements Runnable
     {
 
-        private static Unsafe unsafe = Unsafe.getUnsafe();
-
         private long address;
         private long size;
         private int capacity;
@@ -91,7 +85,7 @@
                 // Paranoia
                 return;
             }
-            unsafe.freeMemory(address);
+            UNSAFE.freeMemory(address);
             address = 0;
             Bits.unreserveMemory(size, capacity);
         }
@@ -124,12 +118,12 @@
 
         long base = 0;
         try {
-            base = unsafe.allocateMemory(size);
+            base = UNSAFE.allocateMemory(size);
         } catch (OutOfMemoryError x) {
             Bits.unreserveMemory(size, cap);
             throw x;
         }
-        unsafe.setMemory(base, size, (byte) 0);
+        UNSAFE.setMemory(base, size, (byte) 0);
         if (pa && (base % ps != 0)) {
             // Round up to page boundary
             address = base + ps - (base & (ps - 1));
@@ -206,6 +200,11 @@
 #end[rw]
     }
 
+    @Override
+    Object base() {
+        return null;
+    }
+
     public $Type$Buffer slice() {
         int pos = this.position();
         int lim = this.limit();
@@ -258,16 +257,16 @@
     }
 
     public $type$ get() {
-        return $fromBits$($swap$(unsafe.get$Swaptype$(ix(nextGetIndex()))));
+        return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(nextGetIndex()))));
     }
 
     public $type$ get(int i) {
-        return $fromBits$($swap$(unsafe.get$Swaptype$(ix(checkIndex(i)))));
+        return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(checkIndex(i)))));
     }
 
 #if[streamableType]
     $type$ getUnchecked(int i) {
-        return $fromBits$($swap$(unsafe.get$Swaptype$(ix(i))));
+        return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(i))));
     }
 #end[streamableType]
 
@@ -282,10 +281,10 @@
             if (length > rem)
                 throw new BufferUnderflowException();
 
-            long dstOffset = arrayBaseOffset + ((long)offset << $LG_BYTES_PER_VALUE$);
+            long dstOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$);
 #if[!byte]
             if (order() != ByteOrder.nativeOrder())
-                unsafe.copySwapMemory(null,
+                UNSAFE.copySwapMemory(null,
                                       ix(pos),
                                       dst,
                                       dstOffset,
@@ -293,7 +292,7 @@
                                       (long)1 << $LG_BYTES_PER_VALUE$);
             else
 #end[!byte]
-                unsafe.copyMemory(null,
+                UNSAFE.copyMemory(null,
                                   ix(pos),
                                   dst,
                                   dstOffset,
@@ -312,7 +311,7 @@
 
     public $Type$Buffer put($type$ x) {
 #if[rw]
-        unsafe.put$Swaptype$(ix(nextPutIndex()), $swap$($toBits$(x)));
+        UNSAFE.put$Swaptype$(ix(nextPutIndex()), $swap$($toBits$(x)));
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -321,7 +320,7 @@
 
     public $Type$Buffer put(int i, $type$ x) {
 #if[rw]
-        unsafe.put$Swaptype$(ix(checkIndex(i)), $swap$($toBits$(x)));
+        UNSAFE.put$Swaptype$(ix(checkIndex(i)), $swap$($toBits$(x)));
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -347,7 +346,7 @@
 
             if (srem > rem)
                 throw new BufferOverflowException();
-            unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << $LG_BYTES_PER_VALUE$);
+            UNSAFE.copyMemory(sb.ix(spos), ix(pos), (long)srem << $LG_BYTES_PER_VALUE$);
             sb.position(spos + srem);
             position(pos + srem);
         } else if (src.hb != null) {
@@ -380,10 +379,10 @@
             if (length > rem)
                 throw new BufferOverflowException();
 
-            long srcOffset = arrayBaseOffset + ((long)offset << $LG_BYTES_PER_VALUE$);
+            long srcOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$);
 #if[!byte]
             if (order() != ByteOrder.nativeOrder())
-                unsafe.copySwapMemory(src,
+                UNSAFE.copySwapMemory(src,
                                       srcOffset,
                                       null,
                                       ix(pos),
@@ -391,7 +390,7 @@
                                       (long)1 << $LG_BYTES_PER_VALUE$);
             else
 #end[!byte]
-                unsafe.copyMemory(src,
+                UNSAFE.copyMemory(src,
                                   srcOffset,
                                   null,
                                   ix(pos),
@@ -413,7 +412,7 @@
         assert (pos <= lim);
         int rem = (pos <= lim ? lim - pos : 0);
 
-        unsafe.copyMemory(ix(pos), ix(0), (long)rem << $LG_BYTES_PER_VALUE$);
+        UNSAFE.copyMemory(ix(pos), ix(0), (long)rem << $LG_BYTES_PER_VALUE$);
         position(rem);
         limit(capacity());
         discardMark();
@@ -490,17 +489,22 @@
 
 #end[!byte]
 
+#if[char]
+    ByteOrder charRegionOrder() {
+        return order();
+    }
+#end[char]
 
 
 #if[byte]
 
     byte _get(int i) {                          // package-private
-        return unsafe.getByte(address + i);
+        return UNSAFE.getByte(address + i);
     }
 
     void _put(int i, byte b) {                  // package-private
 #if[rw]
-        unsafe.putByte(address + i, b);
+        UNSAFE.putByte(address + i, b);
 #else[rw]
         throw new ReadOnlyBufferException();
 #end[rw]
--- a/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template	Thu Jan 18 18:58:46 2018 +0000
@@ -27,8 +27,6 @@
 
 package java.nio;
 
-import jdk.internal.misc.Unsafe;
-
 /**
 #if[rw]
  * A read/write Heap$Type$Buffer.
@@ -43,6 +41,11 @@
 class Heap$Type$Buffer$RW$
     extends {#if[ro]?Heap}$Type$Buffer
 {
+    // Cached array base offset
+    private static final long ARRAY_BASE_OFFSET = UNSAFE.arrayBaseOffset($type$[].class);
+
+    // Cached array base offset
+    private static final long ARRAY_INDEX_SCALE = UNSAFE.arrayIndexScale($type$[].class);
 
     // For speed these fields are actually declared in X-Buffer;
     // these declarations are here as documentation
@@ -53,16 +56,6 @@
 #end[rw]
     */
 
-#if[byte]
-
-    // Cached unsafe-access object
-    private static final Unsafe unsafe = Bits.unsafe();
-
-    // Cached array base offset
-    private static final long arrayBaseOffset = unsafe.arrayBaseOffset($type$[].class);
-
-#end[byte]
-
     Heap$Type$Buffer$RW$(int cap, int lim) {            // package-private
 #if[rw]
         super(-1, 0, lim, cap, new $type$[cap], 0);
@@ -70,13 +63,11 @@
         hb = new $type$[cap];
         offset = 0;
         */
+        this.address = ARRAY_BASE_OFFSET;
 #else[rw]
         super(cap, lim);
         this.isReadOnly = true;
 #end[rw]
-#if[byte]
-        this.address = arrayBaseOffset;
-#end[byte]
     }
 
     Heap$Type$Buffer$RW$($type$[] buf, int off, int len) { // package-private
@@ -86,13 +77,11 @@
         hb = buf;
         offset = 0;
         */
+        this.address = ARRAY_BASE_OFFSET;
 #else[rw]
         super(buf, off, len);
         this.isReadOnly = true;
 #end[rw]
-#if[byte]
-        this.address = arrayBaseOffset;
-#end[byte]
     }
 
     protected Heap$Type$Buffer$RW$($type$[] buf,
@@ -105,13 +94,11 @@
         hb = buf;
         offset = off;
         */
+        this.address = ARRAY_BASE_OFFSET + off * ARRAY_INDEX_SCALE;
 #else[rw]
         super(buf, mark, pos, lim, cap, off);
         this.isReadOnly = true;
 #end[rw]
-#if[byte]
-        this.address = arrayBaseOffset + off;
-#end[byte]
     }
 
     public $Type$Buffer slice() {
@@ -296,18 +283,18 @@
 #if[rw]
 
     public char getChar() {
-        return unsafe.getCharUnaligned(hb, byteOffset(nextGetIndex(2)), bigEndian);
+        return UNSAFE.getCharUnaligned(hb, byteOffset(nextGetIndex(2)), bigEndian);
     }
 
     public char getChar(int i) {
-        return unsafe.getCharUnaligned(hb, byteOffset(checkIndex(i, 2)), bigEndian);
+        return UNSAFE.getCharUnaligned(hb, byteOffset(checkIndex(i, 2)), bigEndian);
     }
 
 #end[rw]
 
     public $Type$Buffer putChar(char x) {
 #if[rw]
-        unsafe.putCharUnaligned(hb, byteOffset(nextPutIndex(2)), x, bigEndian);
+        UNSAFE.putCharUnaligned(hb, byteOffset(nextPutIndex(2)), x, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -316,7 +303,7 @@
 
     public $Type$Buffer putChar(int i, char x) {
 #if[rw]
-        unsafe.putCharUnaligned(hb, byteOffset(checkIndex(i, 2)), x, bigEndian);
+        UNSAFE.putCharUnaligned(hb, byteOffset(checkIndex(i, 2)), x, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -347,18 +334,18 @@
 #if[rw]
 
     public short getShort() {
-        return unsafe.getShortUnaligned(hb, byteOffset(nextGetIndex(2)), bigEndian);
+        return UNSAFE.getShortUnaligned(hb, byteOffset(nextGetIndex(2)), bigEndian);
     }
 
     public short getShort(int i) {
-        return unsafe.getShortUnaligned(hb, byteOffset(checkIndex(i, 2)), bigEndian);
+        return UNSAFE.getShortUnaligned(hb, byteOffset(checkIndex(i, 2)), bigEndian);
     }
 
 #end[rw]
 
     public $Type$Buffer putShort(short x) {
 #if[rw]
-        unsafe.putShortUnaligned(hb, byteOffset(nextPutIndex(2)), x, bigEndian);
+        UNSAFE.putShortUnaligned(hb, byteOffset(nextPutIndex(2)), x, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -367,7 +354,7 @@
 
     public $Type$Buffer putShort(int i, short x) {
 #if[rw]
-        unsafe.putShortUnaligned(hb, byteOffset(checkIndex(i, 2)), x, bigEndian);
+        UNSAFE.putShortUnaligned(hb, byteOffset(checkIndex(i, 2)), x, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -398,18 +385,18 @@
 #if[rw]
 
     public int getInt() {
-        return unsafe.getIntUnaligned(hb, byteOffset(nextGetIndex(4)), bigEndian);
+        return UNSAFE.getIntUnaligned(hb, byteOffset(nextGetIndex(4)), bigEndian);
     }
 
     public int getInt(int i) {
-        return unsafe.getIntUnaligned(hb, byteOffset(checkIndex(i, 4)), bigEndian);
+        return UNSAFE.getIntUnaligned(hb, byteOffset(checkIndex(i, 4)), bigEndian);
     }
 
 #end[rw]
 
     public $Type$Buffer putInt(int x) {
 #if[rw]
-        unsafe.putIntUnaligned(hb, byteOffset(nextPutIndex(4)), x, bigEndian);
+        UNSAFE.putIntUnaligned(hb, byteOffset(nextPutIndex(4)), x, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -418,7 +405,7 @@
 
     public $Type$Buffer putInt(int i, int x) {
 #if[rw]
-        unsafe.putIntUnaligned(hb, byteOffset(checkIndex(i, 4)), x, bigEndian);
+        UNSAFE.putIntUnaligned(hb, byteOffset(checkIndex(i, 4)), x, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -449,18 +436,18 @@
 #if[rw]
 
     public long getLong() {
-        return unsafe.getLongUnaligned(hb, byteOffset(nextGetIndex(8)), bigEndian);
+        return UNSAFE.getLongUnaligned(hb, byteOffset(nextGetIndex(8)), bigEndian);
     }
 
     public long getLong(int i) {
-        return unsafe.getLongUnaligned(hb, byteOffset(checkIndex(i, 8)), bigEndian);
+        return UNSAFE.getLongUnaligned(hb, byteOffset(checkIndex(i, 8)), bigEndian);
     }
 
 #end[rw]
 
     public $Type$Buffer putLong(long x) {
 #if[rw]
-        unsafe.putLongUnaligned(hb, byteOffset(nextPutIndex(8)), x, bigEndian);
+        UNSAFE.putLongUnaligned(hb, byteOffset(nextPutIndex(8)), x, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -469,7 +456,7 @@
 
     public $Type$Buffer putLong(int i, long x) {
 #if[rw]
-        unsafe.putLongUnaligned(hb, byteOffset(checkIndex(i, 8)), x, bigEndian);
+        UNSAFE.putLongUnaligned(hb, byteOffset(checkIndex(i, 8)), x, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -500,12 +487,12 @@
 #if[rw]
 
     public float getFloat() {
-        int x = unsafe.getIntUnaligned(hb, byteOffset(nextGetIndex(4)), bigEndian);
+        int x = UNSAFE.getIntUnaligned(hb, byteOffset(nextGetIndex(4)), bigEndian);
         return Float.intBitsToFloat(x);
     }
 
     public float getFloat(int i) {
-        int x = unsafe.getIntUnaligned(hb, byteOffset(checkIndex(i, 4)), bigEndian);
+        int x = UNSAFE.getIntUnaligned(hb, byteOffset(checkIndex(i, 4)), bigEndian);
         return Float.intBitsToFloat(x);
     }
 
@@ -514,7 +501,7 @@
     public $Type$Buffer putFloat(float x) {
 #if[rw]
         int y = Float.floatToRawIntBits(x);
-        unsafe.putIntUnaligned(hb, byteOffset(nextPutIndex(4)), y, bigEndian);
+        UNSAFE.putIntUnaligned(hb, byteOffset(nextPutIndex(4)), y, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -524,7 +511,7 @@
     public $Type$Buffer putFloat(int i, float x) {
 #if[rw]
         int y = Float.floatToRawIntBits(x);
-        unsafe.putIntUnaligned(hb, byteOffset(checkIndex(i, 4)), y, bigEndian);
+        UNSAFE.putIntUnaligned(hb, byteOffset(checkIndex(i, 4)), y, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -555,12 +542,12 @@
 #if[rw]
 
     public double getDouble() {
-        long x = unsafe.getLongUnaligned(hb, byteOffset(nextGetIndex(8)), bigEndian);
+        long x = UNSAFE.getLongUnaligned(hb, byteOffset(nextGetIndex(8)), bigEndian);
         return Double.longBitsToDouble(x);
     }
 
     public double getDouble(int i) {
-        long x = unsafe.getLongUnaligned(hb, byteOffset(checkIndex(i, 8)), bigEndian);
+        long x = UNSAFE.getLongUnaligned(hb, byteOffset(checkIndex(i, 8)), bigEndian);
         return Double.longBitsToDouble(x);
     }
 
@@ -569,7 +556,7 @@
     public $Type$Buffer putDouble(double x) {
 #if[rw]
         long y = Double.doubleToRawLongBits(x);
-        unsafe.putLongUnaligned(hb, byteOffset(nextPutIndex(8)), y, bigEndian);
+        UNSAFE.putLongUnaligned(hb, byteOffset(nextPutIndex(8)), y, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -579,7 +566,7 @@
     public $Type$Buffer putDouble(int i, double x) {
 #if[rw]
         long y = Double.doubleToRawLongBits(x);
-        unsafe.putLongUnaligned(hb, byteOffset(checkIndex(i, 8)), y, bigEndian);
+        UNSAFE.putLongUnaligned(hb, byteOffset(checkIndex(i, 8)), y, bigEndian);
         return this;
 #else[rw]
         throw new ReadOnlyBufferException();
@@ -643,7 +630,11 @@
     public ByteOrder order() {
         return ByteOrder.nativeOrder();
     }
+#end[!byte]
+#if[char]
 
-#end[!byte]
-
+    ByteOrder charRegionOrder() {
+        return order();
+    }
+#end[char]
 }
--- a/src/java.base/share/classes/java/nio/StringCharBuffer.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/nio/StringCharBuffer.java	Thu Jan 18 18:58:46 2018 +0000
@@ -127,4 +127,30 @@
         return ByteOrder.nativeOrder();
     }
 
+    ByteOrder charRegionOrder() {
+        return null;
+    }
+
+    public boolean equals(Object ob) {
+        if (this == ob)
+            return true;
+        if (!(ob instanceof CharBuffer))
+            return false;
+        CharBuffer that = (CharBuffer)ob;
+        if (this.remaining() != that.remaining())
+            return false;
+        return BufferMismatch.mismatch(this, this.position(),
+                                       that, that.position(),
+                                       this.remaining()) < 0;
+    }
+
+    public int compareTo(CharBuffer that) {
+        int i = BufferMismatch.mismatch(this, this.position(),
+                                        that, that.position(),
+                                        Math.min(this.remaining(), that.remaining()));
+        if (i >= 0) {
+            return Character.compare(this.get(this.position() + i), that.get(this.position() + i));
+        }
+        return this.remaining() - that.remaining();
+    }
 }
--- a/src/java.base/share/classes/java/nio/X-Buffer.java.template	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template	Thu Jan 18 18:58:46 2018 +0000
@@ -36,6 +36,8 @@
 import java.util.stream.$Streamtype$Stream;
 #end[streamableType]
 
+import jdk.internal.util.ArraysSupport;
+
 /**
  * $A$ $type$ buffer.
  *
@@ -287,6 +289,11 @@
         this(mark, pos, lim, cap, null, 0);
     }
 
+    @Override
+    Object base() {
+        return hb;
+    }
+
 #if[byte]
 
     /**
@@ -1297,19 +1304,9 @@
         $Type$Buffer that = ($Type$Buffer)ob;
         if (this.remaining() != that.remaining())
             return false;
-        int p = this.position();
-        for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--)
-            if (!equals(this.get(i), that.get(j)))
-                return false;
-        return true;
-    }
-
-    private static boolean equals($type$ x, $type$ y) {
-#if[floatingPointType]
-        return (x == y) || ($Fulltype$.isNaN(x) && $Fulltype$.isNaN(y));
-#else[floatingPointType]
-        return x == y;
-#end[floatingPointType]
+        return BufferMismatch.mismatch(this, this.position(),
+                                       that, that.position(),
+                                       this.remaining()) < 0;
     }
 
     /**
@@ -1336,11 +1333,11 @@
      *          is less than, equal to, or greater than the given buffer
      */
     public int compareTo($Type$Buffer that) {
-        int n = this.position() + Math.min(this.remaining(), that.remaining());
-        for (int i = this.position(), j = that.position(); i < n; i++, j++) {
-            int cmp = compare(this.get(i), that.get(j));
-            if (cmp != 0)
-                return cmp;
+        int i = BufferMismatch.mismatch(this, this.position(),
+                                        that, that.position(),
+                                        Math.min(this.remaining(), that.remaining()));
+        if (i >= 0) {
+            return compare(this.get(this.position() + i), that.get(this.position() + i));
         }
         return this.remaining() - that.remaining();
     }
@@ -1571,6 +1568,12 @@
 
 #end[!byte]
 
+#if[char]
+    // The order or null if the buffer does not cover a memory region,
+    // such as StringCharBuffer
+    abstract ByteOrder charRegionOrder();
+#end[char]
+
 #if[byte]
 
     boolean bigEndian                                   // package-private
--- a/src/java.base/share/classes/java/nio/file/Files.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/nio/file/Files.java	Thu Jan 18 18:58:46 2018 +0000
@@ -2955,22 +2955,6 @@
     }
 
     /**
-     * Reads all bytes from an input stream and writes them to an output stream.
-     */
-    private static long copy(InputStream source, OutputStream sink)
-        throws IOException
-    {
-        long nread = 0L;
-        byte[] buf = new byte[BUFFER_SIZE];
-        int n;
-        while ((n = source.read(buf)) > 0) {
-            sink.write(buf, 0, n);
-            nread += n;
-        }
-        return nread;
-    }
-
-    /**
      * Copies all bytes from an input stream to a file. On return, the input
      * stream will be at end of stream.
      *
@@ -3082,7 +3066,7 @@
 
         // do the copy
         try (OutputStream out = ostream) {
-            return copy(in, out);
+            return in.transferTo(out);
         }
     }
 
@@ -3124,7 +3108,7 @@
         Objects.requireNonNull(out);
 
         try (InputStream in = newInputStream(source)) {
-            return copy(in, out);
+            return in.transferTo(out);
         }
     }
 
--- a/src/java.base/share/classes/java/util/ArrayList.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/ArrayList.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1550,7 +1550,6 @@
                     setBit(deathRow, i - beg);
             if (modCount != expectedModCount)
                 throw new ConcurrentModificationException();
-            expectedModCount++;
             modCount++;
             int w = beg;
             for (i = beg; i < end; i++)
--- a/src/java.base/share/classes/java/util/Arrays.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/Arrays.java	Thu Jan 18 18:58:46 2018 +0000
@@ -26,6 +26,7 @@
 package java.util;
 
 import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.util.ArraysSupport;
 
 import java.lang.reflect.Array;
 import java.util.concurrent.ForkJoinPool;
--- a/src/java.base/share/classes/java/util/ArraysSupport.java	Thu Jan 18 09:01:00 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,545 +0,0 @@
-/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package java.util;
-
-import jdk.internal.HotSpotIntrinsicCandidate;
-import jdk.internal.misc.Unsafe;
-
-/**
- * Utility methods to find a mismatch between two primitive arrays.
- *
- * <p>Array equality and lexicographical comparison can be built on top of
- * array mismatch functionality.
- *
- * <p>The mismatch method implementation, {@link #vectorizedMismatch}, leverages
- * vector-based techniques to access and compare the contents of two arrays.
- * The Java implementation uses {@code Unsafe.getLongUnaligned} to access the
- * content of an array, thus access is supported on platforms that do not
- * support unaligned access.  For a byte[] array, 8 bytes (64 bits) can be
- * accessed and compared as a unit rather than individually, which increases
- * the performance when the method is compiled by the HotSpot VM.  On supported
- * platforms the mismatch implementation is intrinsified to leverage SIMD
- * instructions.  So for a byte[] array, 16 bytes (128 bits), 32 bytes
- * (256 bits), and perhaps in the future even 64 bytes (512 bits), platform
- * permitting, can be accessed and compared as a unit, which further increases
- * the performance over the Java implementation.
- *
- * <p>None of the mismatch methods perform array bounds checks.  It is the
- * responsibility of the caller (direct or otherwise) to perform such checks
- * before calling this method.
- */
-class ArraysSupport {
-    static final Unsafe U = Unsafe.getUnsafe();
-
-    private static final boolean BIG_ENDIAN = U.isBigEndian();
-
-    private static final int LOG2_ARRAY_BOOLEAN_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
-    private static final int LOG2_ARRAY_BYTE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BYTE_INDEX_SCALE);
-    private static final int LOG2_ARRAY_CHAR_INDEX_SCALE = exactLog2(Unsafe.ARRAY_CHAR_INDEX_SCALE);
-    private static final int LOG2_ARRAY_SHORT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_SHORT_INDEX_SCALE);
-    private static final int LOG2_ARRAY_INT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_INT_INDEX_SCALE);
-    private static final int LOG2_ARRAY_LONG_INDEX_SCALE = exactLog2(Unsafe.ARRAY_LONG_INDEX_SCALE);
-    private static final int LOG2_ARRAY_FLOAT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_FLOAT_INDEX_SCALE);
-    private static final int LOG2_ARRAY_DOUBLE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_DOUBLE_INDEX_SCALE);
-
-    private static final int LOG2_BYTE_BIT_SIZE = exactLog2(Byte.SIZE);
-
-    private static int exactLog2(int scale) {
-        if ((scale & (scale - 1)) != 0)
-            throw new Error("data type scale not a power of two");
-        return Integer.numberOfTrailingZeros(scale);
-    }
-
-    private ArraysSupport() {}
-
-    /**
-     * Find the relative index of the first mismatching pair of elements in two
-     * primitive arrays of the same component type.  Pairs of elements will be
-     * tested in order relative to given offsets into both arrays.
-     *
-     * <p>This method does not perform type checks or bounds checks.  It is the
-     * responsibility of the caller to perform such checks before calling this
-     * method.
-     *
-     * <p>The given offsets, in bytes, need not be aligned according to the
-     * given log<sub>2</sub> size the array elements.  More specifically, an
-     * offset modulus the size need not be zero.
-     *
-     * @param a the first array to be tested for mismatch, or {@code null} for
-     * direct memory access
-     * @param aOffset the relative offset, in bytes, from the base address of
-     * the first array to test from, otherwise if the first array is
-     * {@code null}, an absolute address pointing to the first element to test.
-     * @param b the second array to be tested for mismatch, or {@code null} for
-     * direct memory access
-     * @param bOffset the relative offset, in bytes, from the base address of
-     * the second array to test from, otherwise if the second array is
-     * {@code null}, an absolute address pointing to the first element to test.
-     * @param length the number of array elements to test
-     * @param log2ArrayIndexScale log<sub>2</sub> of the array index scale, that
-     * corresponds to the size, in bytes, of an array element.
-     * @return if a mismatch is found a relative index, between 0 (inclusive)
-     * and {@code length} (exclusive), of the first mismatching pair of elements
-     * in the two arrays.  Otherwise, if a mismatch is not found the bitwise
-     * compliment of the number of remaining pairs of elements to be checked in
-     * the tail of the two arrays.
-     */
-    @HotSpotIntrinsicCandidate
-    static int vectorizedMismatch(Object a, long aOffset,
-                                  Object b, long bOffset,
-                                  int length,
-                                  int log2ArrayIndexScale) {
-        // assert a.getClass().isArray();
-        // assert b.getClass().isArray();
-        // assert 0 <= length <= sizeOf(a)
-        // assert 0 <= length <= sizeOf(b)
-        // assert 0 <= log2ArrayIndexScale <= 3
-
-        int log2ValuesPerWidth = LOG2_ARRAY_LONG_INDEX_SCALE - log2ArrayIndexScale;
-        int wi = 0;
-        for (; wi < length >> log2ValuesPerWidth; wi++) {
-            long bi = ((long) wi) << LOG2_ARRAY_LONG_INDEX_SCALE;
-            long av = U.getLongUnaligned(a, aOffset + bi);
-            long bv = U.getLongUnaligned(b, bOffset + bi);
-            if (av != bv) {
-                long x = av ^ bv;
-                int o = BIG_ENDIAN
-                        ? Long.numberOfLeadingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale)
-                        : Long.numberOfTrailingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale);
-                return (wi << log2ValuesPerWidth) + o;
-            }
-        }
-
-        // Calculate the tail of remaining elements to check
-        int tail = length - (wi << log2ValuesPerWidth);
-
-        if (log2ArrayIndexScale < LOG2_ARRAY_INT_INDEX_SCALE) {
-            int wordTail = 1 << (LOG2_ARRAY_INT_INDEX_SCALE - log2ArrayIndexScale);
-            // Handle 4 bytes or 2 chars in the tail using int width
-            if (tail >= wordTail) {
-                long bi = ((long) wi) << LOG2_ARRAY_LONG_INDEX_SCALE;
-                int av = U.getIntUnaligned(a, aOffset + bi);
-                int bv = U.getIntUnaligned(b, bOffset + bi);
-                if (av != bv) {
-                    int x = av ^ bv;
-                    int o = BIG_ENDIAN
-                            ? Integer.numberOfLeadingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale)
-                            : Integer.numberOfTrailingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale);
-                    return (wi << log2ValuesPerWidth) + o;
-                }
-                tail -= wordTail;
-            }
-            return ~tail;
-        }
-        else {
-            return ~tail;
-        }
-    }
-
-    // Booleans
-    // Each boolean element takes up one byte
-
-    static int mismatch(boolean[] a,
-                        boolean[] b,
-                        int length) {
-        int i = 0;
-        if (length > 7) {
-            i = vectorizedMismatch(
-                    a, Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
-                    b, Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
-                    length, LOG2_ARRAY_BOOLEAN_INDEX_SCALE);
-            if (i >= 0)
-                return i;
-            i = length - ~i;
-        }
-        for (; i < length; i++) {
-            if (a[i] != b[i])
-                return i;
-        }
-        return -1;
-    }
-
-    static int mismatch(boolean[] a, int aFromIndex,
-                        boolean[] b, int bFromIndex,
-                        int length) {
-        int i = 0;
-        if (length > 7) {
-            int aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex;
-            int bOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + bFromIndex;
-            i = vectorizedMismatch(
-                    a, aOffset,
-                    b, bOffset,
-                    length, LOG2_ARRAY_BOOLEAN_INDEX_SCALE);
-            if (i >= 0)
-                return i;
-            i = length - ~i;
-        }
-        for (; i < length; i++) {
-            if (a[aFromIndex + i] != b[bFromIndex + i])
-                return i;
-        }
-        return -1;
-    }
-
-
-    // Bytes
-
-    /**
-     * Find the index of a mismatch between two arrays.
-     *
-     * <p>This method does not perform bounds checks. It is the responsibility
-     * of the caller to perform such bounds checks before calling this method.
-     *
-     * @param a the first array to be tested for a mismatch
-     * @param b the second array to be tested for a mismatch
-     * @param length the number of bytes from each array to check
-     * @return the index of a mismatch between the two arrays, otherwise -1 if
-     * no mismatch.  The index will be within the range of (inclusive) 0 to
-     * (exclusive) the smaller of the two array lengths.
-     */
-    static int mismatch(byte[] a,
-                        byte[] b,
-                        int length) {
-        // ISSUE: defer to index receiving methods if performance is good
-        // assert length <= a.length
-        // assert length <= b.length
-
-        int i = 0;
-        if (length > 7) {
-            i = vectorizedMismatch(
-                    a, Unsafe.ARRAY_BYTE_BASE_OFFSET,
-                    b, Unsafe.ARRAY_BYTE_BASE_OFFSET,
-                    length, LOG2_ARRAY_BYTE_INDEX_SCALE);
-            if (i >= 0)
-                return i;
-            // Align to tail
-            i = length - ~i;
-//            assert i >= 0 && i <= 7;
-        }
-        // Tail < 8 bytes
-        for (; i < length; i++) {
-            if (a[i] != b[i])
-                return i;
-        }
-        return -1;
-    }
-
-    /**
-     * Find the relative index of a mismatch between two arrays starting from
-     * given indexes.
-     *
-     * <p>This method does not perform bounds checks. It is the responsibility
-     * of the caller to perform such bounds checks before calling this method.
-     *
-     * @param a the first array to be tested for a mismatch
-     * @param aFromIndex the index of the first element (inclusive) in the first
-     * array to be compared
-     * @param b the second array to be tested for a mismatch
-     * @param bFromIndex the index of the first element (inclusive) in the
-     * second array to be compared
-     * @param length the number of bytes from each array to check
-     * @return the relative index of a mismatch between the two arrays,
-     * otherwise -1 if no mismatch.  The index will be within the range of
-     * (inclusive) 0 to (exclusive) the smaller of the two array bounds.
-     */
-    static int mismatch(byte[] a, int aFromIndex,
-                        byte[] b, int bFromIndex,
-                        int length) {
-        // assert 0 <= aFromIndex < a.length
-        // assert 0 <= aFromIndex + length <= a.length
-        // assert 0 <= bFromIndex < b.length
-        // assert 0 <= bFromIndex + length <= b.length
-        // assert length >= 0
-
-        int i = 0;
-        if (length > 7) {
-            int aOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + aFromIndex;
-            int bOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + bFromIndex;
-            i = vectorizedMismatch(
-                    a, aOffset,
-                    b, bOffset,
-                    length, LOG2_ARRAY_BYTE_INDEX_SCALE);
-            if (i >= 0)
-                return i;
-            i = length - ~i;
-        }
-        for (; i < length; i++) {
-            if (a[aFromIndex + i] != b[bFromIndex + i])
-                return i;
-        }
-        return -1;
-    }
-
-
-    // Chars
-
-    static int mismatch(char[] a,
-                        char[] b,
-                        int length) {
-        int i = 0;
-        if (length > 3) {
-            i = vectorizedMismatch(
-                    a, Unsafe.ARRAY_CHAR_BASE_OFFSET,
-                    b, Unsafe.ARRAY_CHAR_BASE_OFFSET,
-                    length, LOG2_ARRAY_CHAR_INDEX_SCALE);
-            if (i >= 0)
-                return i;
-            i = length - ~i;
-        }
-        for (; i < length; i++) {
-            if (a[i] != b[i])
-                return i;
-        }
-        return -1;
-    }
-
-    static int mismatch(char[] a, int aFromIndex,
-                        char[] b, int bFromIndex,
-                        int length) {
-        int i = 0;
-        if (length > 3) {
-            int aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE);
-            int bOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE);
-            i = vectorizedMismatch(
-                    a, aOffset,
-                    b, bOffset,
-                    length, LOG2_ARRAY_CHAR_INDEX_SCALE);
-            if (i >= 0)
-                return i;
-            i = length - ~i;
-        }
-        for (; i < length; i++) {
-            if (a[aFromIndex + i] != b[bFromIndex + i])
-                return i;
-        }
-        return -1;
-    }
-
-
-    // Shorts
-
-    static int mismatch(short[] a,
-                        short[] b,
-                        int length) {
-        int i = 0;
-        if (length > 3) {
-            i = vectorizedMismatch(
-                    a, Unsafe.ARRAY_SHORT_BASE_OFFSET,
-                    b, Unsafe.ARRAY_SHORT_BASE_OFFSET,
-                    length, LOG2_ARRAY_SHORT_INDEX_SCALE);
-            if (i >= 0)
-                return i;
-            i = length - ~i;
-        }
-        for (; i < length; i++) {
-            if (a[i] != b[i])
-                return i;
-        }
-        return -1;
-    }
-
-    static int mismatch(short[] a, int aFromIndex,
-                        short[] b, int bFromIndex,
-                        int length) {
-        int i = 0;
-        if (length > 3) {
-            int aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE);
-            int bOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE);
-            i = vectorizedMismatch(
-                    a, aOffset,
-                    b, bOffset,
-                    length, LOG2_ARRAY_SHORT_INDEX_SCALE);
-            if (i >= 0)
-                return i;
-            i = length - ~i;
-        }
-        for (; i < length; i++) {
-            if (a[aFromIndex + i] != b[bFromIndex + i])
-                return i;
-        }
-        return -1;
-    }
-
-
-    // Ints
-
-    static int mismatch(int[] a,
-                        int[] b,
-                        int length) {
-        int i = 0;
-        if (length > 1) {
-            i = vectorizedMismatch(
-                    a, Unsafe.ARRAY_INT_BASE_OFFSET,
-                    b, Unsafe.ARRAY_INT_BASE_OFFSET,
-                    length, LOG2_ARRAY_INT_INDEX_SCALE);
-            if (i >= 0)
-                return i;
-            i = length - ~i;
-        }
-        for (; i < length; i++) {
-            if (a[i] != b[i])
-                return i;
-        }
-        return -1;
-    }
-
-    static int mismatch(int[] a, int aFromIndex,
-                        int[] b, int bFromIndex,
-                        int length) {
-        int i = 0;
-        if (length > 1) {
-            int aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE);
-            int bOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_INT_INDEX_SCALE);
-            i = vectorizedMismatch(
-                    a, aOffset,
-                    b, bOffset,
-                    length, LOG2_ARRAY_INT_INDEX_SCALE);
-            if (i >= 0)
-                return i;
-            i = length - ~i;
-        }
-        for (; i < length; i++) {
-            if (a[aFromIndex + i] != b[bFromIndex + i])
-                return i;
-        }
-        return -1;
-    }
-
-
-    // Floats
-
-    static int mismatch(float[] a,
-                        float[] b,
-                        int length) {
-        return mismatch(a, 0, b, 0, length);
-    }
-
-    static int mismatch(float[] a, int aFromIndex,
-                        float[] b, int bFromIndex,
-                        int length) {
-        int i = 0;
-        if (length > 1) {
-            int aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE);
-            int bOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE);
-            i = vectorizedMismatch(
-                    a, aOffset,
-                    b, bOffset,
-                    length, LOG2_ARRAY_FLOAT_INDEX_SCALE);
-            // Mismatched
-            if (i >= 0) {
-                // Check if mismatch is not associated with two NaN values
-                if (!Float.isNaN(a[aFromIndex + i]) || !Float.isNaN(b[bFromIndex + i]))
-                    return i;
-
-                // Mismatch on two different NaN values that are normalized to match
-                // Fall back to slow mechanism
-                // ISSUE: Consider looping over vectorizedMismatch adjusting ranges
-                // However, requires that returned value be relative to input ranges
-                i++;
-            }
-            // Matched
-            else {
-                i = length - ~i;
-            }
-        }
-        for (; i < length; i++) {
-            if (Float.floatToIntBits(a[aFromIndex + i]) != Float.floatToIntBits(b[bFromIndex + i]))
-                return i;
-        }
-        return -1;
-    }
-
-    // 64 bit sizes
-
-    // Long
-
-    static int mismatch(long[] a,
-                        long[] b,
-                        int length) {
-        if (length == 0) {
-            return -1;
-        }
-        int i = vectorizedMismatch(
-                a, Unsafe.ARRAY_LONG_BASE_OFFSET,
-                b, Unsafe.ARRAY_LONG_BASE_OFFSET,
-                length, LOG2_ARRAY_LONG_INDEX_SCALE);
-        return i >= 0 ? i : -1;
-    }
-
-    static int mismatch(long[] a, int aFromIndex,
-                        long[] b, int bFromIndex,
-                        int length) {
-        if (length == 0) {
-            return -1;
-        }
-        int aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
-        int bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
-        int i = vectorizedMismatch(
-                a, aOffset,
-                b, bOffset,
-                length, LOG2_ARRAY_LONG_INDEX_SCALE);
-        return i >= 0 ? i : -1;
-    }
-
-
-    // Double
-
-    static int mismatch(double[] a,
-                        double[] b,
-                        int length) {
-        return mismatch(a, 0, b, 0, length);
-    }
-
-    static int mismatch(double[] a, int aFromIndex,
-                        double[] b, int bFromIndex,
-                        int length) {
-        if (length == 0) {
-            return -1;
-        }
-        int aOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE);
-        int bOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE);
-        int i = vectorizedMismatch(
-                a, aOffset,
-                b, bOffset,
-                length, LOG2_ARRAY_DOUBLE_INDEX_SCALE);
-        if (i >= 0) {
-            // Check if mismatch is not associated with two NaN values
-            if (!Double.isNaN(a[aFromIndex + i]) || !Double.isNaN(b[bFromIndex + i]))
-                return i;
-
-            // Mismatch on two different NaN values that are normalized to match
-            // Fall back to slow mechanism
-            // ISSUE: Consider looping over vectorizedMismatch adjusting ranges
-            // However, requires that returned value be relative to input ranges
-            i++;
-            for (; i < length; i++) {
-                if (Double.doubleToLongBits(a[aFromIndex + i]) != Double.doubleToLongBits(b[bFromIndex + i]))
-                    return i;
-            }
-        }
-
-        return -1;
-    }
-}
--- a/src/java.base/share/classes/java/util/Vector.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/Vector.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1023,7 +1023,6 @@
                     setBit(deathRow, i - beg);
             if (modCount != expectedModCount)
                 throw new ConcurrentModificationException();
-            expectedModCount++;
             modCount++;
             int w = beg;
             for (i = beg; i < end; i++)
--- a/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java	Thu Jan 18 18:58:46 2018 +0000
@@ -245,8 +245,7 @@
                 Future<T> f = futures.get(i);
                 if (!f.isDone()) {
                     try { f.get(); }
-                    catch (CancellationException ignore) {}
-                    catch (ExecutionException ignore) {}
+                    catch (CancellationException | ExecutionException ignore) {}
                 }
             }
             return futures;
@@ -283,8 +282,7 @@
                 Future<T> f = futures.get(j);
                 if (!f.isDone()) {
                     try { f.get(deadline - System.nanoTime(), NANOSECONDS); }
-                    catch (CancellationException ignore) {}
-                    catch (ExecutionException ignore) {}
+                    catch (CancellationException | ExecutionException ignore) {}
                     catch (TimeoutException timedOut) {
                         break timedOut;
                     }
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java	Thu Jan 18 18:58:46 2018 +0000
@@ -717,12 +717,12 @@
      */
     static Class<?> comparableClassFor(Object x) {
         if (x instanceof Comparable) {
-            Class<?> c; Type[] ts, as; Type t; ParameterizedType p;
+            Class<?> c; Type[] ts, as; ParameterizedType p;
             if ((c = x.getClass()) == String.class) // bypass checks
                 return c;
             if ((ts = c.getGenericInterfaces()) != null) {
-                for (int i = 0; i < ts.length; ++i) {
-                    if (((t = ts[i]) instanceof ParameterizedType) &&
+                for (Type t : ts) {
+                    if ((t instanceof ParameterizedType) &&
                         ((p = (ParameterizedType)t).getRawType() ==
                          Comparable.class) &&
                         (as = p.getActualTypeArguments()) != null &&
@@ -2328,15 +2328,15 @@
      * @param check if <0, don't check resize, if <= 1 only check if uncontended
      */
     private final void addCount(long x, int check) {
-        CounterCell[] as; long b, s;
-        if ((as = counterCells) != null ||
+        CounterCell[] cs; long b, s;
+        if ((cs = counterCells) != null ||
             !U.compareAndSetLong(this, BASECOUNT, b = baseCount, s = b + x)) {
-            CounterCell a; long v; int m;
+            CounterCell c; long v; int m;
             boolean uncontended = true;
-            if (as == null || (m = as.length - 1) < 0 ||
-                (a = as[ThreadLocalRandom.getProbe() & m]) == null ||
+            if (cs == null || (m = cs.length - 1) < 0 ||
+                (c = cs[ThreadLocalRandom.getProbe() & m]) == null ||
                 !(uncontended =
-                  U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x))) {
+                  U.compareAndSetLong(c, CELLVALUE, v = c.value, v + x))) {
                 fullAddCount(x, uncontended);
                 return;
             }
@@ -2574,13 +2574,12 @@
     }
 
     final long sumCount() {
-        CounterCell[] as = counterCells; CounterCell a;
+        CounterCell[] cs = counterCells;
         long sum = baseCount;
-        if (as != null) {
-            for (int i = 0; i < as.length; ++i) {
-                if ((a = as[i]) != null)
-                    sum += a.value;
-            }
+        if (cs != null) {
+            for (CounterCell c : cs)
+                if (c != null)
+                    sum += c.value;
         }
         return sum;
     }
@@ -2595,9 +2594,9 @@
         }
         boolean collide = false;                // True if last slot nonempty
         for (;;) {
-            CounterCell[] as; CounterCell a; int n; long v;
-            if ((as = counterCells) != null && (n = as.length) > 0) {
-                if ((a = as[(n - 1) & h]) == null) {
+            CounterCell[] cs; CounterCell c; int n; long v;
+            if ((cs = counterCells) != null && (n = cs.length) > 0) {
+                if ((c = cs[(n - 1) & h]) == null) {
                     if (cellsBusy == 0) {            // Try to attach new Cell
                         CounterCell r = new CounterCell(x); // Optimistic create
                         if (cellsBusy == 0 &&
@@ -2623,21 +2622,17 @@
                 }
                 else if (!wasUncontended)       // CAS already known to fail
                     wasUncontended = true;      // Continue after rehash
-                else if (U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x))
+                else if (U.compareAndSetLong(c, CELLVALUE, v = c.value, v + x))
                     break;
-                else if (counterCells != as || n >= NCPU)
+                else if (counterCells != cs || n >= NCPU)
                     collide = false;            // At max size or stale
                 else if (!collide)
                     collide = true;
                 else if (cellsBusy == 0 &&
                          U.compareAndSetInt(this, CELLSBUSY, 0, 1)) {
                     try {
-                        if (counterCells == as) {// Expand table unless stale
-                            CounterCell[] rs = new CounterCell[n << 1];
-                            for (int i = 0; i < n; ++i)
-                                rs[i] = as[i];
-                            counterCells = rs;
-                        }
+                        if (counterCells == cs) // Expand table unless stale
+                            counterCells = Arrays.copyOf(cs, n << 1);
                     } finally {
                         cellsBusy = 0;
                     }
@@ -2646,11 +2641,11 @@
                 }
                 h = ThreadLocalRandom.advanceProbe(h);
             }
-            else if (cellsBusy == 0 && counterCells == as &&
+            else if (cellsBusy == 0 && counterCells == cs &&
                      U.compareAndSetInt(this, CELLSBUSY, 0, 1)) {
                 boolean init = false;
                 try {                           // Initialize table
-                    if (counterCells == as) {
+                    if (counterCells == cs) {
                         CounterCell[] rs = new CounterCell[2];
                         rs[h & 1] = new CounterCell(x);
                         counterCells = rs;
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java	Thu Jan 18 18:58:46 2018 +0000
@@ -2204,9 +2204,7 @@
             Collection<?> c = (Collection<?>) o;
             try {
                 return containsAll(c) && c.containsAll(this);
-            } catch (ClassCastException unused) {
-                return false;
-            } catch (NullPointerException unused) {
+            } catch (ClassCastException | NullPointerException unused) {
                 return false;
             }
         }
@@ -2331,9 +2329,7 @@
             Collection<?> c = (Collection<?>) o;
             try {
                 return containsAll(c) && c.containsAll(this);
-            } catch (ClassCastException unused) {
-                return false;
-            } catch (NullPointerException unused) {
+            } catch (ClassCastException | NullPointerException unused) {
                 return false;
             }
         }
@@ -2453,9 +2449,7 @@
             if (k == null) // pass by markers and headers
                 return true;
             int c = cpr(cmp, k, hi);
-            if (c > 0 || (c == 0 && !hiInclusive))
-                return false;
-            return true;
+            return c < 0 || (c == 0 && hiInclusive);
         }
 
         /**
--- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java	Thu Jan 18 18:58:46 2018 +0000
@@ -309,9 +309,7 @@
         Collection<?> c = (Collection<?>) o;
         try {
             return containsAll(c) && c.containsAll(this);
-        } catch (ClassCastException unused) {
-            return false;
-        } catch (NullPointerException unused) {
+        } catch (ClassCastException | NullPointerException unused) {
             return false;
         }
     }
--- a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java	Thu Jan 18 18:58:46 2018 +0000
@@ -508,7 +508,7 @@
     public boolean remove(Object o) {
         Object[] snapshot = getArray();
         int index = indexOf(o, snapshot, 0, snapshot.length);
-        return (index < 0) ? false : remove(o, snapshot, index);
+        return index >= 0 && remove(o, snapshot, index);
     }
 
     /**
@@ -587,8 +587,8 @@
      */
     public boolean addIfAbsent(E e) {
         Object[] snapshot = getArray();
-        return indexOf(e, snapshot, 0, snapshot.length) >= 0 ? false :
-            addIfAbsent(e, snapshot);
+        return indexOf(e, snapshot, 0, snapshot.length) < 0
+            && addIfAbsent(e, snapshot);
     }
 
     /**
@@ -980,13 +980,10 @@
 
         List<?> list = (List<?>)o;
         Iterator<?> it = list.iterator();
-        Object[] elements = getArray();
-        for (int i = 0, len = elements.length; i < len; i++)
-            if (!it.hasNext() || !Objects.equals(elements[i], it.next()))
+        for (Object element : getArray())
+            if (!it.hasNext() || !Objects.equals(element, it.next()))
                 return false;
-        if (it.hasNext())
-            return false;
-        return true;
+        return !it.hasNext();
     }
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1353,17 +1353,16 @@
     @SuppressWarnings("unchecked")
     private boolean bulkRemove(Predicate<? super E> filter) {
         boolean removed = false;
+        final ReentrantLock lock = this.lock;
         Node<E> p = null;
-        final ReentrantLock lock = this.lock;
         Node<E>[] nodes = null;
         int n, len = 0;
         do {
             // 1. Extract batch of up to 64 elements while holding the lock.
-            long deathRow = 0;          // "bitset" of size 64
             lock.lock();
             try {
-                if (nodes == null) {
-                    if (p == null) p = first;
+                if (nodes == null) {  // first batch; initialize
+                    p = first;
                     for (Node<E> q = p; q != null; q = succ(q))
                         if (q.item != null && ++len == 64)
                             break;
@@ -1376,6 +1375,7 @@
             }
 
             // 2. Run the filter on the elements while lock is free.
+            long deathRow = 0L;       // "bitset" of size 64
             for (int i = 0; i < n; i++) {
                 final E e;
                 if ((e = nodes[i].item) != null && filter.test(e))
@@ -1393,6 +1393,7 @@
                             unlink(q);
                             removed = true;
                         }
+                        nodes[i] = null; // help GC
                     }
                 } finally {
                     lock.unlock();
--- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1060,11 +1060,10 @@
         int n, len = 0;
         do {
             // 1. Extract batch of up to 64 elements while holding the lock.
-            long deathRow = 0;          // "bitset" of size 64
             fullyLock();
             try {
-                if (nodes == null) {
-                    if (p == null) p = head.next;
+                if (nodes == null) {  // first batch; initialize
+                    p = head.next;
                     for (Node<E> q = p; q != null; q = succ(q))
                         if (q.item != null && ++len == 64)
                             break;
@@ -1077,6 +1076,7 @@
             }
 
             // 2. Run the filter on the elements while lock is free.
+            long deathRow = 0L;       // "bitset" of size 64
             for (int i = 0; i < n; i++) {
                 final E e;
                 if ((e = nodes[i].item) != null && filter.test(e))
@@ -1095,6 +1095,7 @@
                             unlink(q, ancestor);
                             removed = true;
                         }
+                        nodes[i] = null; // help GC
                     }
                 } finally {
                     fullyUnlock();
--- a/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java	Thu Jan 18 18:58:46 2018 +0000
@@ -772,9 +772,8 @@
         Node first = null;
         restartFromHead: for (;;) {
             Node h = head, p = h;
-            for (; p != null;) {
-                final Object item;
-                if ((item = p.item) != null) {
+            while (p != null) {
+                if (p.item != null) {
                     if (p.isData) {
                         first = p;
                         break;
@@ -1602,8 +1601,7 @@
         // Read in elements until trailing null sentinel found
         Node h = null, t = null;
         for (Object item; (item = s.readObject()) != null; ) {
-            @SuppressWarnings("unchecked")
-            Node newNode = new Node((E) item);
+            Node newNode = new Node(item);
             if (h == null)
                 h = t = newNode;
             else
--- a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java	Thu Jan 18 18:58:46 2018 +0000
@@ -269,8 +269,8 @@
         if (a.getClass() != Object[].class)
             a = Arrays.copyOf(a, n, Object[].class);
         if (screen && (n == 1 || this.comparator != null)) {
-            for (int i = 0; i < n; ++i)
-                if (a[i] == null)
+            for (Object elt : a)
+                if (elt == null)
                     throw new NullPointerException();
         }
         this.queue = a;
--- a/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java	Thu Jan 18 18:58:46 2018 +0000
@@ -753,8 +753,10 @@
                     else
                         pred.next = next;
                 }
-                else
+                else {
                     subs.add(b.subscriber);
+                    pred = b;
+                }
             }
         }
         return subs;
--- a/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java	Thu Jan 18 18:58:46 2018 +0000
@@ -67,7 +67,7 @@
  * {@code ThreadLocalRandom.current().nextX(...)} (where
  * {@code X} is {@code Int}, {@code Long}, etc).
  * When all usages are of this form, it is never possible to
- * accidently share a {@code ThreadLocalRandom} across multiple threads.
+ * accidentally share a {@code ThreadLocalRandom} across multiple threads.
  *
  * <p>This class also provides additional commonly used bounded random
  * generation methods.
--- a/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java	Thu Jan 18 18:58:46 2018 +0000
@@ -264,13 +264,12 @@
  * assist in storage reclamation when large numbers of queued tasks
  * become cancelled.</dd>
  *
- * <dt>Finalization</dt>
+ * <dt>Reclamation</dt>
  *
  * <dd>A pool that is no longer referenced in a program <em>AND</em>
- * has no remaining threads will be {@code shutdown} automatically. If
- * you would like to ensure that unreferenced pools are reclaimed even
- * if users forget to call {@link #shutdown}, then you must arrange
- * that unused threads eventually die, by setting appropriate
+ * has no remaining threads may be reclaimed (garbage collected)
+ * without being explicity shutdown. You can configure a pool to allow
+ * all unused threads to eventually die by setting appropriate
  * keep-alive times, using a lower bound of zero core threads and/or
  * setting {@link #allowCoreThreadTimeOut(boolean)}.  </dd>
  *
@@ -361,7 +360,7 @@
      * time, but need not hit each state. The transitions are:
      *
      * RUNNING -> SHUTDOWN
-     *    On invocation of shutdown(), perhaps implicitly in finalize()
+     *    On invocation of shutdown()
      * (RUNNING or SHUTDOWN) -> STOP
      *    On invocation of shutdownNow()
      * SHUTDOWN -> TIDYING
@@ -581,9 +580,6 @@
     private static final RuntimePermission shutdownPerm =
         new RuntimePermission("modifyThread");
 
-    /** The context to be used when executing the finalizer, or null. */
-    private final AccessControlContext acc;
-
     /**
      * Class Worker mainly maintains interrupt control state for
      * threads running tasks, along with other minor bookkeeping.
@@ -1300,9 +1296,6 @@
             throw new IllegalArgumentException();
         if (workQueue == null || threadFactory == null || handler == null)
             throw new NullPointerException();
-        this.acc = (System.getSecurityManager() == null)
-            ? null
-            : AccessController.getContext();
         this.corePoolSize = corePoolSize;
         this.maximumPoolSize = maximumPoolSize;
         this.workQueue = workQueue;
@@ -1470,33 +1463,6 @@
     }
 
     /**
-     * Invokes {@code shutdown} when this executor is no longer
-     * referenced and it has no threads.
-     *
-     * <p>This method is invoked with privileges that are restricted by
-     * the security context of the caller that invokes the constructor.
-     *
-     * @deprecated The {@code finalize} method has been deprecated.
-     *     Subclasses that override {@code finalize} in order to perform cleanup
-     *     should be modified to use alternative cleanup mechanisms and
-     *     to remove the overriding {@code finalize} method.
-     *     When overriding the {@code finalize} method, its implementation must explicitly
-     *     ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}.
-     *     See the specification for {@link Object#finalize()} for further
-     *     information about migration options.
-     */
-    @Deprecated(since="9")
-    protected void finalize() {
-        SecurityManager sm = System.getSecurityManager();
-        if (sm == null || acc == null) {
-            shutdown();
-        } else {
-            PrivilegedAction<Void> pa = () -> { shutdown(); return null; };
-            AccessController.doPrivileged(pa, acc);
-        }
-    }
-
-    /**
      * Sets the thread factory used to create new threads.
      *
      * @param threadFactory the new thread factory
--- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java	Thu Jan 18 18:58:46 2018 +0000
@@ -320,7 +320,9 @@
 
         // predNext is the apparent node to unsplice. CASes below will
         // fail if not, in which case, we lost race vs another cancel
-        // or signal, so no further action is necessary.
+        // or signal, so no further action is necessary, although with
+        // a possibility that a cancelled node may transiently remain
+        // reachable.
         Node predNext = pred.next;
 
         // Can use unconditional write instead of CAS here.
@@ -912,13 +914,13 @@
      * at any time, a {@code true} return does not guarantee that any
      * other thread will ever acquire.
      *
-     * <p>In this implementation, this operation returns in
-     * constant time.
-     *
      * @return {@code true} if there may be other threads waiting to acquire
      */
     public final boolean hasQueuedThreads() {
-        return head != tail;
+        for (Node p = tail, h = head; p != h && p != null; p = p.prev)
+            if (p.waitStatus <= 0)
+                return true;
+        return false;
     }
 
     /**
@@ -1067,17 +1069,21 @@
      * @since 1.7
      */
     public final boolean hasQueuedPredecessors() {
-        // The correctness of this depends on head being initialized
-        // before tail and on head.next being accurate if the current
-        // thread is first in queue.
-        Node t = tail; // Read fields in reverse initialization order
-        Node h = head;
-        Node s;
-        return h != t &&
-            ((s = h.next) == null || s.thread != Thread.currentThread());
+        Node h, s;
+        if ((h = head) != null) {
+            if ((s = h.next) == null || s.waitStatus > 0) {
+                s = null; // traverse in case of concurrent cancellation
+                for (Node p = tail; p != h && p != null; p = p.prev) {
+                    if (p.waitStatus <= 0)
+                        s = p;
+                }
+            }
+            if (s != null && s.thread != Thread.currentThread())
+                return true;
+        }
+        return false;
     }
 
-
     // Instrumentation and monitoring methods
 
     /**
--- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java	Thu Jan 18 18:58:46 2018 +0000
@@ -800,7 +800,9 @@
 
         // predNext is the apparent node to unsplice. CASes below will
         // fail if not, in which case, we lost race vs another cancel
-        // or signal, so no further action is necessary.
+        // or signal, so no further action is necessary, although with
+        // a possibility that a cancelled node may transiently remain
+        // reachable.
         Node predNext = pred.next;
 
         // Can use unconditional write instead of CAS here.
@@ -1392,13 +1394,13 @@
      * at any time, a {@code true} return does not guarantee that any
      * other thread will ever acquire.
      *
-     * <p>In this implementation, this operation returns in
-     * constant time.
-     *
      * @return {@code true} if there may be other threads waiting to acquire
      */
     public final boolean hasQueuedThreads() {
-        return head != tail;
+        for (Node p = tail, h = head; p != h && p != null; p = p.prev)
+            if (p.waitStatus <= 0)
+                return true;
+        return false;
     }
 
     /**
@@ -1547,17 +1549,21 @@
      * @since 1.7
      */
     public final boolean hasQueuedPredecessors() {
-        // The correctness of this depends on head being initialized
-        // before tail and on head.next being accurate if the current
-        // thread is first in queue.
-        Node t = tail; // Read fields in reverse initialization order
-        Node h = head;
-        Node s;
-        return h != t &&
-            ((s = h.next) == null || s.thread != Thread.currentThread());
+        Node h, s;
+        if ((h = head) != null) {
+            if ((s = h.next) == null || s.waitStatus > 0) {
+                s = null; // traverse in case of concurrent cancellation
+                for (Node p = tail; p != h && p != null; p = p.prev) {
+                    if (p.waitStatus <= 0)
+                        s = p;
+                }
+            }
+            if (s != null && s.thread != Thread.currentThread())
+                return true;
+        }
+        return false;
     }
 
-
     // Instrumentation and monitoring methods
 
     /**
--- a/src/java.base/share/classes/java/util/regex/Pattern.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/java/util/regex/Pattern.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -954,6 +954,12 @@
     private int flags;
 
     /**
+     * The temporary pattern flags used during compiling. The flags might be turn
+     * on and off by embedded flag.
+     */
+    private transient int flags0;
+
+    /**
      * Boolean indicating this Pattern is compiled; this is necessary in order
      * to lazily compile deserialized Patterns.
      */
@@ -1137,7 +1143,7 @@
      * @return  The match flags specified when this pattern was compiled
      */
     public int flags() {
-        return flags;
+        return flags0;
     }
 
     /**
@@ -1369,6 +1375,9 @@
         // Read in all fields
         s.defaultReadObject();
 
+        // reset the flags
+        flags0 = flags;
+
         // Initialize counts
         capturingGroupCount = 1;
         localCount = 0;
@@ -1400,6 +1409,9 @@
         if ((flags & UNICODE_CHARACTER_CLASS) != 0)
             flags |= UNICODE_CASE;
 
+        // 'flags' for compiling
+        flags0 = flags;
+
         // Reset group index count
         capturingGroupCount = 1;
         localCount = 0;
@@ -1841,7 +1853,7 @@
      * Indicates whether a particular flag is set or not.
      */
     private boolean has(int f) {
-        return (flags & f) != 0;
+        return (flags0 & f) != 0;
     }
 
     /**
@@ -2718,7 +2730,7 @@
                ch == 0x53 || ch == 0x73 ||    //S and s
                ch == 0x4b || ch == 0x6b ||    //K and k
                ch == 0xc5 || ch == 0xe5))) {  //A+ring
-            bits.add(ch, flags());
+            bits.add(ch, flags0);
             return null;
         }
         return single(ch);
@@ -2931,7 +2943,7 @@
         boolean capturingGroup = false;
         Node head = null;
         Node tail = null;
-        int save = flags;
+        int save = flags0;
         int saveTCNCount = topClosureNodes.size();
         root = null;
         int ch = next();
@@ -3032,7 +3044,7 @@
         }
 
         accept(')', "Unclosed group");
-        flags = save;
+        flags0 = save;
 
         // Check for quantifiers
         Node node = closure(head);
@@ -3135,28 +3147,28 @@
         for (;;) {
             switch (ch) {
             case 'i':
-                flags |= CASE_INSENSITIVE;
+                flags0 |= CASE_INSENSITIVE;
                 break;
             case 'm':
-                flags |= MULTILINE;
+                flags0 |= MULTILINE;
                 break;
             case 's':
-                flags |= DOTALL;
+                flags0 |= DOTALL;
                 break;
             case 'd':
-                flags |= UNIX_LINES;
+                flags0 |= UNIX_LINES;
                 break;
             case 'u':
-                flags |= UNICODE_CASE;
+                flags0 |= UNICODE_CASE;
                 break;
             case 'c':
-                flags |= CANON_EQ;
+                flags0 |= CANON_EQ;
                 break;
             case 'x':
-                flags |= COMMENTS;
+                flags0 |= COMMENTS;
                 break;
             case 'U':
-                flags |= (UNICODE_CHARACTER_CLASS | UNICODE_CASE);
+                flags0 |= (UNICODE_CHARACTER_CLASS | UNICODE_CASE);
                 break;
             case '-': // subFlag then fall through
                 ch = next();
@@ -3178,28 +3190,28 @@
         for (;;) {
             switch (ch) {
             case 'i':
-                flags &= ~CASE_INSENSITIVE;
+                flags0 &= ~CASE_INSENSITIVE;
                 break;
             case 'm':
-                flags &= ~MULTILINE;
+                flags0 &= ~MULTILINE;
                 break;
             case 's':
-                flags &= ~DOTALL;
+                flags0 &= ~DOTALL;
                 break;
             case 'd':
-                flags &= ~UNIX_LINES;
+                flags0 &= ~UNIX_LINES;
                 break;
             case 'u':
-                flags &= ~UNICODE_CASE;
+                flags0 &= ~UNICODE_CASE;
                 break;
             case 'c':
-                flags &= ~CANON_EQ;
+                flags0 &= ~CANON_EQ;
                 break;
             case 'x':
-                flags &= ~COMMENTS;
+                flags0 &= ~COMMENTS;
                 break;
             case 'U':
-                flags &= ~(UNICODE_CHARACTER_CLASS | UNICODE_CASE);
+                flags0 &= ~(UNICODE_CHARACTER_CLASS | UNICODE_CASE);
                 break;
             default:
                 return;
--- a/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/jdk/internal/module/ModuleInfo.java	Thu Jan 18 18:58:46 2018 +0000
@@ -64,7 +64,7 @@
 public final class ModuleInfo {
 
     private final int JAVA_MIN_SUPPORTED_VERSION = 53;
-    private final int JAVA_MAX_SUPPORTED_VERSION = 54;
+    private final int JAVA_MAX_SUPPORTED_VERSION = 55;
 
     private static final JavaLangModuleAccess JLMA
         = SharedSecrets.getJavaLangModuleAccess();
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/ClassReader.java	Thu Jan 18 18:58:46 2018 +0000
@@ -185,7 +185,7 @@
     public ClassReader(final byte[] b, final int off, final int len) {
         this.b = b;
         // checks the class version
-        if (readShort(off + 6) > Opcodes.V10) {
+        if (readShort(off + 6) > Opcodes.V11) {
             throw new IllegalArgumentException();
         }
         // parses the constant pool
--- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java	Thu Jan 18 18:58:46 2018 +0000
@@ -90,6 +90,7 @@
     int V1_8 = 0 << 16 | 52;
     int V9 = 0 << 16 | 53;
     int V10 = 0 << 16 | 54;
+    int V11 = 0 << 16 | 55;
 
     // access flags
 
--- a/src/java.base/share/classes/jdk/internal/reflect/Reflection.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/jdk/internal/reflect/Reflection.java	Thu Jan 18 18:58:46 2018 +0000
@@ -64,14 +64,6 @@
     @HotSpotIntrinsicCandidate
     public static native Class<?> getCallerClass();
 
-    /**
-     * @deprecated This method will be removed.
-     * This method is a private JDK API and retained temporarily to
-     * simplify the implementation of sun.misc.Reflection.getCallerClass.
-     */
-    @Deprecated(forRemoval=true)
-    public static native Class<?> getCallerClass(int depth);
-
     /** Retrieves the access flags written to the class file. For
         inner classes these flags may differ from those returned by
         Class.getModifiers(), which searches the InnerClasses
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java	Thu Jan 18 18:58:46 2018 +0000
@@ -0,0 +1,545 @@
+/*
+ * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package jdk.internal.util;
+
+import jdk.internal.HotSpotIntrinsicCandidate;
+import jdk.internal.misc.Unsafe;
+
+/**
+ * Utility methods to find a mismatch between two primitive arrays.
+ *
+ * <p>Array equality and lexicographical comparison can be built on top of
+ * array mismatch functionality.
+ *
+ * <p>The mismatch method implementation, {@link #vectorizedMismatch}, leverages
+ * vector-based techniques to access and compare the contents of two arrays.
+ * The Java implementation uses {@code Unsafe.getLongUnaligned} to access the
+ * content of an array, thus access is supported on platforms that do not
+ * support unaligned access.  For a byte[] array, 8 bytes (64 bits) can be
+ * accessed and compared as a unit rather than individually, which increases
+ * the performance when the method is compiled by the HotSpot VM.  On supported
+ * platforms the mismatch implementation is intrinsified to leverage SIMD
+ * instructions.  So for a byte[] array, 16 bytes (128 bits), 32 bytes
+ * (256 bits), and perhaps in the future even 64 bytes (512 bits), platform
+ * permitting, can be accessed and compared as a unit, which further increases
+ * the performance over the Java implementation.
+ *
+ * <p>None of the mismatch methods perform array bounds checks.  It is the
+ * responsibility of the caller (direct or otherwise) to perform such checks
+ * before calling this method.
+ */
+public class ArraysSupport {
+    static final Unsafe U = Unsafe.getUnsafe();
+
+    private static final boolean BIG_ENDIAN = U.isBigEndian();
+
+    public static final int LOG2_ARRAY_BOOLEAN_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE);
+    public static final int LOG2_ARRAY_BYTE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BYTE_INDEX_SCALE);
+    public static final int LOG2_ARRAY_CHAR_INDEX_SCALE = exactLog2(Unsafe.ARRAY_CHAR_INDEX_SCALE);
+    public static final int LOG2_ARRAY_SHORT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_SHORT_INDEX_SCALE);
+    public static final int LOG2_ARRAY_INT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_INT_INDEX_SCALE);
+    public static final int LOG2_ARRAY_LONG_INDEX_SCALE = exactLog2(Unsafe.ARRAY_LONG_INDEX_SCALE);
+    public static final int LOG2_ARRAY_FLOAT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_FLOAT_INDEX_SCALE);
+    public static final int LOG2_ARRAY_DOUBLE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_DOUBLE_INDEX_SCALE);
+
+    private static final int LOG2_BYTE_BIT_SIZE = exactLog2(Byte.SIZE);
+
+    private static int exactLog2(int scale) {
+        if ((scale & (scale - 1)) != 0)
+            throw new Error("data type scale not a power of two");
+        return Integer.numberOfTrailingZeros(scale);
+    }
+
+    private ArraysSupport() {}
+
+    /**
+     * Find the relative index of the first mismatching pair of elements in two
+     * primitive arrays of the same component type.  Pairs of elements will be
+     * tested in order relative to given offsets into both arrays.
+     *
+     * <p>This method does not perform type checks or bounds checks.  It is the
+     * responsibility of the caller to perform such checks before calling this
+     * method.
+     *
+     * <p>The given offsets, in bytes, need not be aligned according to the
+     * given log<sub>2</sub> size the array elements.  More specifically, an
+     * offset modulus the size need not be zero.
+     *
+     * @param a the first array to be tested for mismatch, or {@code null} for
+     * direct memory access
+     * @param aOffset the relative offset, in bytes, from the base address of
+     * the first array to test from, otherwise if the first array is
+     * {@code null}, an absolute address pointing to the first element to test.
+     * @param b the second array to be tested for mismatch, or {@code null} for
+     * direct memory access
+     * @param bOffset the relative offset, in bytes, from the base address of
+     * the second array to test from, otherwise if the second array is
+     * {@code null}, an absolute address pointing to the first element to test.
+     * @param length the number of array elements to test
+     * @param log2ArrayIndexScale log<sub>2</sub> of the array index scale, that
+     * corresponds to the size, in bytes, of an array element.
+     * @return if a mismatch is found a relative index, between 0 (inclusive)
+     * and {@code length} (exclusive), of the first mismatching pair of elements
+     * in the two arrays.  Otherwise, if a mismatch is not found the bitwise
+     * compliment of the number of remaining pairs of elements to be checked in
+     * the tail of the two arrays.
+     */
+    @HotSpotIntrinsicCandidate
+    public static int vectorizedMismatch(Object a, long aOffset,
+                                         Object b, long bOffset,
+                                         int length,
+                                         int log2ArrayIndexScale) {
+        // assert a.getClass().isArray();
+        // assert b.getClass().isArray();
+        // assert 0 <= length <= sizeOf(a)
+        // assert 0 <= length <= sizeOf(b)
+        // assert 0 <= log2ArrayIndexScale <= 3
+
+        int log2ValuesPerWidth = LOG2_ARRAY_LONG_INDEX_SCALE - log2ArrayIndexScale;
+        int wi = 0;
+        for (; wi < length >> log2ValuesPerWidth; wi++) {
+            long bi = ((long) wi) << LOG2_ARRAY_LONG_INDEX_SCALE;
+            long av = U.getLongUnaligned(a, aOffset + bi);
+            long bv = U.getLongUnaligned(b, bOffset + bi);
+            if (av != bv) {
+                long x = av ^ bv;
+                int o = BIG_ENDIAN
+                        ? Long.numberOfLeadingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale)
+                        : Long.numberOfTrailingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale);
+                return (wi << log2ValuesPerWidth) + o;
+            }
+        }
+
+        // Calculate the tail of remaining elements to check
+        int tail = length - (wi << log2ValuesPerWidth);
+
+        if (log2ArrayIndexScale < LOG2_ARRAY_INT_INDEX_SCALE) {
+            int wordTail = 1 << (LOG2_ARRAY_INT_INDEX_SCALE - log2ArrayIndexScale);
+            // Handle 4 bytes or 2 chars in the tail using int width
+            if (tail >= wordTail) {
+                long bi = ((long) wi) << LOG2_ARRAY_LONG_INDEX_SCALE;
+                int av = U.getIntUnaligned(a, aOffset + bi);
+                int bv = U.getIntUnaligned(b, bOffset + bi);
+                if (av != bv) {
+                    int x = av ^ bv;
+                    int o = BIG_ENDIAN
+                            ? Integer.numberOfLeadingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale)
+                            : Integer.numberOfTrailingZeros(x) >> (LOG2_BYTE_BIT_SIZE + log2ArrayIndexScale);
+                    return (wi << log2ValuesPerWidth) + o;
+                }
+                tail -= wordTail;
+            }
+            return ~tail;
+        }
+        else {
+            return ~tail;
+        }
+    }
+
+    // Booleans
+    // Each boolean element takes up one byte
+
+    public static int mismatch(boolean[] a,
+                               boolean[] b,
+                               int length) {
+        int i = 0;
+        if (length > 7) {
+            i = vectorizedMismatch(
+                    a, Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
+                    b, Unsafe.ARRAY_BOOLEAN_BASE_OFFSET,
+                    length, LOG2_ARRAY_BOOLEAN_INDEX_SCALE);
+            if (i >= 0)
+                return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a[i] != b[i])
+                return i;
+        }
+        return -1;
+    }
+
+    public static int mismatch(boolean[] a, int aFromIndex,
+                               boolean[] b, int bFromIndex,
+                               int length) {
+        int i = 0;
+        if (length > 7) {
+            int aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex;
+            int bOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + bFromIndex;
+            i = vectorizedMismatch(
+                    a, aOffset,
+                    b, bOffset,
+                    length, LOG2_ARRAY_BOOLEAN_INDEX_SCALE);
+            if (i >= 0)
+                return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a[aFromIndex + i] != b[bFromIndex + i])
+                return i;
+        }
+        return -1;
+    }
+
+
+    // Bytes
+
+    /**
+     * Find the index of a mismatch between two arrays.
+     *
+     * <p>This method does not perform bounds checks. It is the responsibility
+     * of the caller to perform such bounds checks before calling this method.
+     *
+     * @param a the first array to be tested for a mismatch
+     * @param b the second array to be tested for a mismatch
+     * @param length the number of bytes from each array to check
+     * @return the index of a mismatch between the two arrays, otherwise -1 if
+     * no mismatch.  The index will be within the range of (inclusive) 0 to
+     * (exclusive) the smaller of the two array lengths.
+     */
+    public static int mismatch(byte[] a,
+                               byte[] b,
+                               int length) {
+        // ISSUE: defer to index receiving methods if performance is good
+        // assert length <= a.length
+        // assert length <= b.length
+
+        int i = 0;
+        if (length > 7) {
+            i = vectorizedMismatch(
+                    a, Unsafe.ARRAY_BYTE_BASE_OFFSET,
+                    b, Unsafe.ARRAY_BYTE_BASE_OFFSET,
+                    length, LOG2_ARRAY_BYTE_INDEX_SCALE);
+            if (i >= 0)
+                return i;
+            // Align to tail
+            i = length - ~i;
+//            assert i >= 0 && i <= 7;
+        }
+        // Tail < 8 bytes
+        for (; i < length; i++) {
+            if (a[i] != b[i])
+                return i;
+        }
+        return -1;
+    }
+
+    /**
+     * Find the relative index of a mismatch between two arrays starting from
+     * given indexes.
+     *
+     * <p>This method does not perform bounds checks. It is the responsibility
+     * of the caller to perform such bounds checks before calling this method.
+     *
+     * @param a the first array to be tested for a mismatch
+     * @param aFromIndex the index of the first element (inclusive) in the first
+     * array to be compared
+     * @param b the second array to be tested for a mismatch
+     * @param bFromIndex the index of the first element (inclusive) in the
+     * second array to be compared
+     * @param length the number of bytes from each array to check
+     * @return the relative index of a mismatch between the two arrays,
+     * otherwise -1 if no mismatch.  The index will be within the range of
+     * (inclusive) 0 to (exclusive) the smaller of the two array bounds.
+     */
+    public static int mismatch(byte[] a, int aFromIndex,
+                               byte[] b, int bFromIndex,
+                               int length) {
+        // assert 0 <= aFromIndex < a.length
+        // assert 0 <= aFromIndex + length <= a.length
+        // assert 0 <= bFromIndex < b.length
+        // assert 0 <= bFromIndex + length <= b.length
+        // assert length >= 0
+
+        int i = 0;
+        if (length > 7) {
+            int aOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + aFromIndex;
+            int bOffset = Unsafe.ARRAY_BYTE_BASE_OFFSET + bFromIndex;
+            i = vectorizedMismatch(
+                    a, aOffset,
+                    b, bOffset,
+                    length, LOG2_ARRAY_BYTE_INDEX_SCALE);
+            if (i >= 0)
+                return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a[aFromIndex + i] != b[bFromIndex + i])
+                return i;
+        }
+        return -1;
+    }
+
+
+    // Chars
+
+    public static int mismatch(char[] a,
+                               char[] b,
+                               int length) {
+        int i = 0;
+        if (length > 3) {
+            i = vectorizedMismatch(
+                    a, Unsafe.ARRAY_CHAR_BASE_OFFSET,
+                    b, Unsafe.ARRAY_CHAR_BASE_OFFSET,
+                    length, LOG2_ARRAY_CHAR_INDEX_SCALE);
+            if (i >= 0)
+                return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a[i] != b[i])
+                return i;
+        }
+        return -1;
+    }
+
+    public static int mismatch(char[] a, int aFromIndex,
+                               char[] b, int bFromIndex,
+                               int length) {
+        int i = 0;
+        if (length > 3) {
+            int aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE);
+            int bOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE);
+            i = vectorizedMismatch(
+                    a, aOffset,
+                    b, bOffset,
+                    length, LOG2_ARRAY_CHAR_INDEX_SCALE);
+            if (i >= 0)
+                return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a[aFromIndex + i] != b[bFromIndex + i])
+                return i;
+        }
+        return -1;
+    }
+
+
+    // Shorts
+
+    public static int mismatch(short[] a,
+                               short[] b,
+                               int length) {
+        int i = 0;
+        if (length > 3) {
+            i = vectorizedMismatch(
+                    a, Unsafe.ARRAY_SHORT_BASE_OFFSET,
+                    b, Unsafe.ARRAY_SHORT_BASE_OFFSET,
+                    length, LOG2_ARRAY_SHORT_INDEX_SCALE);
+            if (i >= 0)
+                return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a[i] != b[i])
+                return i;
+        }
+        return -1;
+    }
+
+    public static int mismatch(short[] a, int aFromIndex,
+                               short[] b, int bFromIndex,
+                               int length) {
+        int i = 0;
+        if (length > 3) {
+            int aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE);
+            int bOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE);
+            i = vectorizedMismatch(
+                    a, aOffset,
+                    b, bOffset,
+                    length, LOG2_ARRAY_SHORT_INDEX_SCALE);
+            if (i >= 0)
+                return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a[aFromIndex + i] != b[bFromIndex + i])
+                return i;
+        }
+        return -1;
+    }
+
+
+    // Ints
+
+    public static int mismatch(int[] a,
+                               int[] b,
+                               int length) {
+        int i = 0;
+        if (length > 1) {
+            i = vectorizedMismatch(
+                    a, Unsafe.ARRAY_INT_BASE_OFFSET,
+                    b, Unsafe.ARRAY_INT_BASE_OFFSET,
+                    length, LOG2_ARRAY_INT_INDEX_SCALE);
+            if (i >= 0)
+                return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a[i] != b[i])
+                return i;
+        }
+        return -1;
+    }
+
+    public static int mismatch(int[] a, int aFromIndex,
+                               int[] b, int bFromIndex,
+                               int length) {
+        int i = 0;
+        if (length > 1) {
+            int aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE);
+            int bOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_INT_INDEX_SCALE);
+            i = vectorizedMismatch(
+                    a, aOffset,
+                    b, bOffset,
+                    length, LOG2_ARRAY_INT_INDEX_SCALE);
+            if (i >= 0)
+                return i;
+            i = length - ~i;
+        }
+        for (; i < length; i++) {
+            if (a[aFromIndex + i] != b[bFromIndex + i])
+                return i;
+        }
+        return -1;
+    }
+
+
+    // Floats
+
+    public static int mismatch(float[] a,
+                               float[] b,
+                               int length) {
+        return mismatch(a, 0, b, 0, length);
+    }
+
+    public static int mismatch(float[] a, int aFromIndex,
+                               float[] b, int bFromIndex,
+                               int length) {
+        int i = 0;
+        if (length > 1) {
+            int aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE);
+            int bOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE);
+            i = vectorizedMismatch(
+                    a, aOffset,
+                    b, bOffset,
+                    length, LOG2_ARRAY_FLOAT_INDEX_SCALE);
+            // Mismatched
+            if (i >= 0) {
+                // Check if mismatch is not associated with two NaN values
+                if (!Float.isNaN(a[aFromIndex + i]) || !Float.isNaN(b[bFromIndex + i]))
+                    return i;
+
+                // Mismatch on two different NaN values that are normalized to match
+                // Fall back to slow mechanism
+                // ISSUE: Consider looping over vectorizedMismatch adjusting ranges
+                // However, requires that returned value be relative to input ranges
+                i++;
+            }
+            // Matched
+            else {
+                i = length - ~i;
+            }
+        }
+        for (; i < length; i++) {
+            if (Float.floatToIntBits(a[aFromIndex + i]) != Float.floatToIntBits(b[bFromIndex + i]))
+                return i;
+        }
+        return -1;
+    }
+
+    // 64 bit sizes
+
+    // Long
+
+    public static int mismatch(long[] a,
+                               long[] b,
+                               int length) {
+        if (length == 0) {
+            return -1;
+        }
+        int i = vectorizedMismatch(
+                a, Unsafe.ARRAY_LONG_BASE_OFFSET,
+                b, Unsafe.ARRAY_LONG_BASE_OFFSET,
+                length, LOG2_ARRAY_LONG_INDEX_SCALE);
+        return i >= 0 ? i : -1;
+    }
+
+    public static int mismatch(long[] a, int aFromIndex,
+                               long[] b, int bFromIndex,
+                               int length) {
+        if (length == 0) {
+            return -1;
+        }
+        int aOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
+        int bOffset = Unsafe.ARRAY_LONG_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_LONG_INDEX_SCALE);
+        int i = vectorizedMismatch(
+                a, aOffset,
+                b, bOffset,
+                length, LOG2_ARRAY_LONG_INDEX_SCALE);
+        return i >= 0 ? i : -1;
+    }
+
+
+    // Double
+
+    public static int mismatch(double[] a,
+                               double[] b,
+                               int length) {
+        return mismatch(a, 0, b, 0, length);
+    }
+
+    public static int mismatch(double[] a, int aFromIndex,
+                               double[] b, int bFromIndex,
+                               int length) {
+        if (length == 0) {
+            return -1;
+        }
+        int aOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE);
+        int bOffset = Unsafe.ARRAY_DOUBLE_BASE_OFFSET + (bFromIndex << LOG2_ARRAY_DOUBLE_INDEX_SCALE);
+        int i = vectorizedMismatch(
+                a, aOffset,
+                b, bOffset,
+                length, LOG2_ARRAY_DOUBLE_INDEX_SCALE);
+        if (i >= 0) {
+            // Check if mismatch is not associated with two NaN values
+            if (!Double.isNaN(a[aFromIndex + i]) || !Double.isNaN(b[bFromIndex + i]))
+                return i;
+
+            // Mismatch on two different NaN values that are normalized to match
+            // Fall back to slow mechanism
+            // ISSUE: Consider looping over vectorizedMismatch adjusting ranges
+            // However, requires that returned value be relative to input ranges
+            i++;
+            for (; i < length; i++) {
+                if (Double.doubleToLongBits(a[aFromIndex + i]) != Double.doubleToLongBits(b[bFromIndex + i]))
+                    return i;
+            }
+        }
+
+        return -1;
+    }
+}
--- a/src/java.base/share/classes/module-info.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/module-info.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014, 2017, 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
@@ -142,7 +142,7 @@
         java.instrument,
         java.logging;
     exports jdk.internal.jmod to
-        jdk.compiler,   // reflective dependency
+        jdk.compiler,
         jdk.jlink;
     exports jdk.internal.logger to
         java.logging;
@@ -172,7 +172,7 @@
         java.xml,
         jdk.attach,
         jdk.charsets,
-        jdk.compiler,   // reflective dependency
+        jdk.compiler,
         jdk.incubator.httpclient,
         jdk.jdeps,
         jdk.jlink,
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -523,9 +523,11 @@
 
             if (c != null) {
                 command = c;
-            } else if (collator.compare(flags, "-help") == 0 ||
-                    collator.compare(flags, "-h") == 0 ||
-                    collator.compare(flags, "-?") == 0) {
+            } else if (collator.compare(flags, "--help") == 0 ||
+                       collator.compare(flags, "-h") == 0 ||
+                       collator.compare(flags, "-?") == 0 ||
+                       // -help: legacy.
+                       collator.compare(flags, "-help") == 0) {
                 help = true;
             } else if (collator.compare(flags, "-conf") == 0) {
                 i++;
@@ -4609,6 +4611,8 @@
             }
             System.err.println();
             System.err.println(rb.getString(
+                    "Use.keytool.help.for.all.available.commands"));
+            System.err.println(rb.getString(
                     "Use.keytool.command.name.help.for.usage.of.command.name"));
         }
     }
--- a/src/java.base/share/classes/sun/security/tools/keytool/Resources.java	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Resources.java	Thu Jan 18 18:58:46 2018 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2017, 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
@@ -45,12 +45,12 @@
         {"option.1.set.twice", "The %s option is specified multiple times. All except the last one will be ignored."},
         {"multiple.commands.1.2", "Only one command is allowed: both %1$s and %2$s were specified."},
         {"Use.keytool.help.for.all.available.commands",
-                 "Use \"keytool -help\" for all available commands"},
+                 "Use \"keytool -?, -h, or --help\" for this help message"},
         {"Key.and.Certificate.Management.Tool",
                  "Key and Certificate Management Tool"},
         {"Commands.", "Commands:"},
         {"Use.keytool.command.name.help.for.usage.of.command.name",
-                "Use \"keytool -command_name -help\" for usage of command_name.\n" +
+                "Use \"keytool -command_name --help\" for usage of command_name.\n" +
                 "Use the -conf <url> option to specify a pre-configured options file."},
         // keytool: help: commands
         {"Generates.a.certificate.request",
@@ -462,7 +462,7 @@
         {"with.weak", "%s (weak)"},
         {"key.bit", "%1$d-bit %2$s key"},
         {"key.bit.weak", "%1$d-bit %2$s key (weak)"},
-        {"unknown.size.1", "unknown size %s key"},
+        {"unknown.size.1", "%s key of unknown size"},
         {".PATTERN.printX509Cert.with.weak",
                 "Owner: {0}\nIssuer: {1}\nSerial number: {2}\nValid from: {3} until: {4}\nCertificate fingerprints:\n\t SHA1: {5}\n\t SHA256: {6}\nSignature algorithm name: {7}\nSubject Public Key Algorithm: {8}\nVersion: {9}"},
         {"PKCS.10.with.weak",
--- a/src/java.base/share/conf/security/java.security	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/conf/security/java.security	Thu Jan 18 18:58:46 2018 +0000
@@ -812,14 +812,14 @@
 #     limited:    These policy files contain more restricted cryptographic
 #                 strengths
 #
-# The default setting is determined by the value of the “crypto.policy”
+# The default setting is determined by the value of the "crypto.policy"
 # Security property below. If your country or usage requires the
-# traditional restrictive policy, the “limited” Java cryptographic
+# traditional restrictive policy, the "limited" Java cryptographic
 # policy is still available and may be appropriate for your environment.
 #
 # If you have restrictions that do not fit either use case mentioned
 # above, Java provides the capability to customize these policy files.
-# The “crypto.policy” security property points to a subdirectory
+# The "crypto.policy" security property points to a subdirectory
 # within <java-home>/conf/security/policy/ which can be customized.
 # Please see the <java-home>/conf/security/policy/README.txt file or consult
 # the Java Security Guide/JCA documentation for more information.
--- a/src/java.base/share/conf/security/policy/README.txt	Thu Jan 18 09:01:00 2018 -0800
+++ b/src/java.base/share/conf/security/policy/README.txt	Thu Jan 18 18:58:46 2018 +0000
@@ -8,7 +8,7 @@
 Import and export control rules on cryptographic software vary from
 country to country.  The Java Cryptography Extension (JCE) architecture
 allows flexible cryptographic key strength to be configured via the
-jurisdiction policy files which are referenced by the “crypto.policy”
+jurisdiction policy files which are referenced by the "crypto.policy"
 security property in the <java-home>/conf/security/java.security file.
 
 By default, Java provides two different sets of cryptographic policy
@@ -20,8 +20,8 @@
     limited:    These policy files contain more restricted cryptographic
                 strengths
 
-These files reside in <java-home>/conf/security/policy in the “unlimited”
-or “limited” subdirectories respectively.
+These files reside in <java-home>/conf/security/policy in the "unlimited"
+or "limited" subdirectories respectively.
 
 Each subdirectory contains a complete policy configuration,
 and subdirectories can be added/edited/removed to reflect your
--- a/src/java.base/share/native/include/classfile_constants.h	Thu Jan 18 09:01:00 2018 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,581 +0,0 @@
-/*
- * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#ifndef CLASSFILE_CONSTANTS_H
-#define CLASSFILE_CONSTANTS_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Classfile version number for this information */
-#define JVM_CLASSFILE_MAJOR_VERSION 54
-#define JVM_CLASSFILE_MINOR_VERSION 0
-
-/* Flags */
-
-enum {
-    JVM_ACC_PUBLIC        = 0x0001,
-    JVM_ACC_PRIVATE       = 0x0002,
-    JVM_ACC_PROTECTED     = 0x0004,
-    JVM_ACC_STATIC        = 0x0008,
-    JVM_ACC_FINAL         = 0x0010,
-    JVM_ACC_SYNCHRONIZED  = 0x0020,
-    JVM_ACC_SUPER         = 0x0020,
-    JVM_ACC_VOLATILE      = 0x0040,
-    JVM_ACC_BRIDGE        = 0x0040,
-    JVM_ACC_TRANSIENT     = 0x0080,
-    JVM_ACC_VARARGS       = 0x0080,
-    JVM_ACC_NATIVE        = 0x0100,
-    JVM_ACC_INTERFACE     = 0x0200,
-    JVM_ACC_ABSTRACT      = 0x0400,
-    JVM_ACC_STRICT        = 0x0800,
-    JVM_ACC_SYNTHETIC     = 0x1000,
-    JVM_ACC_ANNOTATION    = 0x2000,
-    JVM_ACC_ENUM          = 0x4000,
-    JVM_ACC_MODULE        = 0x8000
-};
-
-#define JVM_ACC_PUBLIC_BIT        0
-#define JVM_ACC_PRIVATE_BIT       1
-#define JVM_ACC_PROTECTED_BIT     2
-#define JVM_ACC_STATIC_BIT        3
-#define JVM_ACC_FINAL_BIT         4
-#define JVM_ACC_SYNCHRONIZED_BIT  5
-#define JVM_ACC_SUPER_BIT         5
-#define JVM_ACC_VOLATILE_BIT      6
-#define JVM_ACC_BRIDGE_BIT        6
-#define JVM_ACC_TRANSIENT_BIT     7
-#define JVM_ACC_VARARGS_BIT       7
-#define JVM_ACC_NATIVE_BIT        8
-#define JVM_ACC_INTERFACE_BIT     9
-#define JVM_ACC_ABSTRACT_BIT      10
-#define JVM_ACC_STRICT_BIT        11
-#define JVM_ACC_SYNTHETIC_BIT     12
-#define JVM_ACC_ANNOTATION_BIT    13
-#define JVM_ACC_ENUM_BIT          14
-
-/* Used in newarray instruction. */
-
-enum {
-    JVM_T_BOOLEAN = 4,
-    JVM_T_CHAR    = 5,
-    JVM_T_FLOAT   = 6,
-    JVM_T_DOUBLE  = 7,
-    JVM_T_BYTE    = 8,
-    JVM_T_SHORT   = 9,
-    JVM_T_INT     = 10,
-    JVM_T_LONG    = 11
-};
-
-/* Constant Pool Entries */
-
-enum {
-    JVM_CONSTANT_Utf8                   = 1,
-    JVM_CONSTANT_Unicode                = 2, /* unused */
-    JVM_CONSTANT_Integer                = 3,
-    JVM_CONSTANT_Float                  = 4,
-    JVM_CONSTANT_Long                   = 5,
-    JVM_CONSTANT_Double                 = 6,
-    JVM_CONSTANT_Class                  = 7,
-    JVM_CONSTANT_String                 = 8,
-    JVM_CONSTANT_Fieldref               = 9,
-    JVM_CONSTANT_Methodref              = 10,
-    JVM_CONSTANT_InterfaceMethodref     = 11,
-    JVM_CONSTANT_NameAndType            = 12,
-    JVM_CONSTANT_MethodHandle           = 15,  // JSR 292
-    JVM_CONSTANT_MethodType             = 16,  // JSR 292
-    JVM_CONSTANT_InvokeDynamic          = 18,
-    JVM_CONSTANT_ExternalMax            = 18
-};
-
-/* JVM_CONSTANT_MethodHandle subtypes */
-enum {
-    JVM_REF_getField                = 1,
-    JVM_REF_getStatic               = 2,
-    JVM_REF_putField                = 3,
-    JVM_REF_putStatic               = 4,
-    JVM_REF_invokeVirtual           = 5,
-    JVM_REF_invokeStatic            = 6,
-    JVM_REF_invokeSpecial           = 7,
-    JVM_REF_newInvokeSpecial        = 8,
-    JVM_REF_invokeInterface         = 9
-};
-
-/* StackMapTable type item numbers */
-
-enum {
-    JVM_ITEM_Top                = 0,
-    JVM_ITEM_Integer            = 1,
-    JVM_ITEM_Float              = 2,
-    JVM_ITEM_Double             = 3,
-    JVM_ITEM_Long               = 4,
-    JVM_ITEM_Null               = 5,
-    JVM_ITEM_UninitializedThis  = 6,
-    JVM_ITEM_Object             = 7,
-    JVM_ITEM_Uninitialized      = 8
-};
-
-/* Type signatures */
-
-enum {
-    JVM_SIGNATURE_ARRAY         = '[',
-    JVM_SIGNATURE_BYTE          = 'B',
-    JVM_SIGNATURE_CHAR          = 'C',
-    JVM_SIGNATURE_CLASS         = 'L',
-    JVM_SIGNATURE_ENDCLASS      = ';',
-    JVM_SIGNATURE_ENUM          = 'E',
-    JVM_SIGNATURE_FLOAT         = 'F',
-    JVM_SIGNATURE_DOUBLE        = 'D',
-    JVM_SIGNATURE_FUNC          = '(',
-    JVM_SIGNATURE_ENDFUNC       = ')',
-    JVM_SIGNATURE_INT           = 'I',
-    JVM_SIGNATURE_LONG          = 'J',
-    JVM_SIGNATURE_SHORT         = 'S',
-    JVM_SIGNATURE_VOID          = 'V',
-    JVM_SIGNATURE_BOOLEAN       = 'Z'
-};
-
-/* Opcodes */
-
-enum {
-    JVM_OPC_nop                 = 0,
-    JVM_OPC_aconst_null         = 1,
-    JVM_OPC_iconst_m1           = 2,
-    JVM_OPC_iconst_0            = 3,
-    JVM_OPC_iconst_1            = 4,
-    JVM_OPC_iconst_2            = 5,
-    JVM_OPC_iconst_3            = 6,
-    JVM_OPC_iconst_4            = 7,
-    JVM_OPC_iconst_5            = 8,
-    JVM_OPC_lconst_0            = 9,
-    JVM_OPC_lconst_1            = 10,
-    JVM_OPC_fconst_0            = 11,
-    JVM_OPC_fconst_1            = 12,
-    JVM_OPC_fconst_2            = 13,
-    JVM_OPC_dconst_0            = 14,
-    JVM_OPC_dconst_1            = 15,
-    JVM_OPC_bipush              = 16,
-    JVM_OPC_sipush              = 17,
-    JVM_OPC_ldc                 = 18,
-    JVM_OPC_ldc_w               = 19,
-    JVM_OPC_ldc2_w              = 20,
-    JVM_OPC_iload               = 21,
-    JVM_OPC_lload               = 22,
-    JVM_OPC_fload               = 23,
-    JVM_OPC_dload               = 24,
-    JVM_OPC_aload               = 25,
-    JVM_OPC_iload_0             = 26,
-    JVM_OPC_iload_1             = 27,
-    JVM_OPC_iload_2             = 28,
-    JVM_OPC_iload_3             = 29,
-    JVM_OPC_lload_0             = 30,
-    JVM_OPC_lload_1             = 31,
-    JVM_OPC_lload_2             = 32,
-    JVM_OPC_lload_3             = 33,
-    JVM_OPC_fload_0             = 34,
-    JVM_OPC_fload_1             = 35,
-    JVM_OPC_fload_2             = 36,
-    JVM_OPC_fload_3             = 37,
-    JVM_OPC_dload_0             = 38,
-    JVM_OPC_dload_1             = 39,
-    JVM_OPC_dload_2             = 40,
-    JVM_OPC_dload_3             = 41,
-    JVM_OPC_aload_0             = 42,
-    JVM_OPC_aload_1             = 43,
-    JVM_OPC_aload_2             = 44,
-    JVM_OPC_aload_3             = 45,
-    JVM_OPC_iaload              = 46,
-    JVM_OPC_laload              = 47,
-    JVM_OPC_faload              = 48,
-    JVM_OPC_daload              = 49,
-    JVM_OPC_aaload              = 50,
-    JVM_OPC_baload              = 51,
-    JVM_OPC_caload              = 52,
-    JVM_OPC_saload              = 53,
-    JVM_OPC_istore              = 54,
-    JVM_OPC_lstore              = 55,
-    JVM_OPC_fstore              = 56,
-    JVM_OPC_dstore              = 57,
-    JVM_OPC_astore              = 58,
-    JVM_OPC_istore_0            = 59,
-    JVM_OPC_istore_1            = 60,
-    JVM_OPC_istore_2            = 61,
-    JVM_OPC_istore_3            = 62,
-    JVM_OPC_lstore_0            = 63,
-    JVM_OPC_lstore_1            = 64,
-    JVM_OPC_lstore_2            = 65,
-    JVM_OPC_lstore_3            = 66,
-    JVM_OPC_fstore_0            = 67,
-    JVM_OPC_fstore_1            = 68,
-    JVM_OPC_fstore_2            = 69,
-    JVM_OPC_fstore_3            = 70,
-    JVM_OPC_dstore_0            = 71,
-    JVM_OPC_dstore_1            = 72,
-    JVM_OPC_dstore_2            = 73,
-    JVM_OPC_dstore_3            = 74,
-    JVM_OPC_astore_0            = 75,
-    JVM_OPC_astore_1            = 76,
-    JVM_OPC_astore_2            = 77,
-    JVM_OPC_astore_3            = 78,
-    JVM_OPC_iastore             = 79,
-    JVM_OPC_lastore             = 80,
-    JVM_OPC_fastore             = 81,
-    JVM_OPC_dastore             = 82,
-    JVM_OPC_aastore             = 83,
-    JVM_OPC_bastore             = 84,
-    JVM_OPC_castore             = 85,
-    JVM_OPC_sastore             = 86,
-    JVM_OPC_pop                 = 87,
-    JVM_OPC_pop2                = 88,
-    JVM_OPC_dup                 = 89,
-    JVM_OPC_dup_x1              = 90,
-    JVM_OPC_dup_x2              = 91,
-    JVM_OPC_dup2                = 92,
-    JVM_OPC_dup2_x1             = 93,
-    JVM_OPC_dup2_x2             = 94,
-    JVM_OPC_swap                = 95,
-    JVM_OPC_iadd                = 96,
-    JVM_OPC_ladd                = 97,
-    JVM_OPC_fadd                = 98,
-    JVM_OPC_dadd                = 99,
-    JVM_OPC_isub                = 100,
-    JVM_OPC_lsub                = 101,
-    JVM_OPC_fsub                = 102,
-    JVM_OPC_dsub                = 103,
-    JVM_OPC_imul                = 104,
-    JVM_OPC_lmul                = 105,
-    JVM_OPC_fmul                = 106,
-    JVM_OPC_dmul                = 107,
-    JVM_OPC_idiv                = 108,
-    JVM_OPC_ldiv                = 109,
-    JVM_OPC_fdiv                = 110,
-    JVM_OPC_ddiv                = 111,
-    JVM_OPC_irem                = 112,
-    JVM_OPC_lrem                = 113,
-    JVM_OPC_frem                = 114,
-    JVM_OPC_drem                = 115,
-    JVM_OPC_ineg                = 116,
-    JVM_OPC_lneg                = 117,
-    JVM_OPC_fneg                = 118,
-    JVM_OPC_dneg                = 119,
-    JVM_OPC_ishl                = 120,
-    JVM_OPC_lshl                = 121,
-    JVM_OPC_ishr                = 122,
-    JVM_OPC_lshr                = 123,
-    JVM_OPC_iushr               = 124,
-    JVM_OPC_lushr               = 125,
-    JVM_OPC_iand                = 126,
-    JVM_OPC_land                = 127,
-    JVM_OPC_ior                 = 128,
-    JVM_OPC_lor                 = 129,
-    JVM_OPC_ixor                = 130,
-    JVM_OPC_lxor                = 131,
-    JVM_OPC_iinc                = 132,
-    JVM_OPC_i2l                 = 133,
-    JVM_OPC_i2f                 = 134,
-    JVM_OPC_i2d                 = 135,
-    JVM_OPC_l2i                 = 136,
-    JVM_OPC_l2f                 = 137,
-    JVM_OPC_l2d                 = 138,
-    JVM_OPC_f2i                 = 139,
-    JVM_OPC_f2l                 = 140,
-    JVM_OPC_f2d                 = 141,
-    JVM_OPC_d2i                 = 142,
-    JVM_OPC_d2l                 = 143,
-    JVM_OPC_d2f                 = 144,
-    JVM_OPC_i2b                 = 145,
-    JVM_OPC_i2c                 = 146,
-    JVM_OPC_i2s                 = 147,
-    JVM_OPC_lcmp                = 148,
-    JVM_OPC_fcmpl               = 149,
-    JVM_OPC_fcmpg               = 150,
-    JVM_OPC_dcmpl               = 151,
-    JVM_OPC_dcmpg               = 152,
-    JVM_OPC_ifeq                = 153,
-    JVM_OPC_ifne                = 154,
-    JVM_OPC_iflt                = 155,
-    JVM_OPC_ifge                = 156,
-    JVM_OPC_ifgt                = 157,
-    JVM_OPC_ifle                = 158,
-    JVM_OPC_if_icmpeq           = 159,
-    JVM_OPC_if_icmpne           = 160,
-    JVM_OPC_if_icmplt           = 161,
-    JVM_OPC_if_icmpge           = 162,
-    JVM_OPC_if_icmpgt           = 163,
-    JVM_OPC_if_icmple           = 164,