changeset 39262:ec2d5ec5571c

Merge
author thartmann
date Tue, 07 Jun 2016 09:11:32 +0000
parents 18f007610de6 10fcac2a233a
children d139a133ba27
files common/autoconf/hotspot-spec.gmk.in hotspot/test/runtime/Unsafe/GetKlassPointerGetJavaMirror.java jdk/src/java.base/share/classes/jdk/Version.java jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColorTrue2Index.c jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageColormap.h jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageConv2x2_f.c jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BC.c jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageAffineIndex_BL.c jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.c jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageBlendTable.h jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1.h jdk/src/java.desktop/share/native/libmlib_image/mlib_c_ImageThresh1_U8.c jdk/src/java.desktop/share/native/libmlib_image/mlib_image_blend_proto.h jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy.c jdk/src/java.desktop/unix/native/libawt/awt/medialib/mlib_v_ImageCopy_blk.s jdk/src/java.desktop/unix/native/libawt/awt/medialib/vis_asi.h jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageAffineIndex_BC.c jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract.c jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelExtract_f.c jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert.c jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageChannelInsert_34.c jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_16nw.c jdk/src/java.desktop/unix/native/libmlib_image/mlib_v_ImageConvIndex3_8_8nw.c jdk/src/java.httpclient/share/classes/java/net/http/HttpHeaders1.java jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProvider.java jdk/src/jdk.jcmd/share/classes/jdk/internal/vm/agent/spi/ToolProviderFinder.java jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PluginContextImpl.java jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PoolImpl.java jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/PluginContext.java jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/plugin/Pool.java jdk/src/jdk.unsupported/share/classes/sun/misc/SoftCache.java jdk/src/jdk.unsupported/unix/classes/sun/misc/GThreadHelper.java jdk/test/java/awt/dnd/Button2DragTest/Button2DragTest.html jdk/test/java/awt/print/Dialog/RestoreActiveWindowTest/RestoreActiveWindowTest.html jdk/test/java/util/ResourceBundle/RestrictedBundleTest.html jdk/test/java/util/ResourceBundle/RestrictedBundleTest.java jdk/test/javax/sound/sampled/spi/AudioFileReader/RecognizeHugeWaveFloatFiles.java jdk/test/javax/xml/bind/xjc/8032884/compile-schema.sh jdk/test/jdk/Version/Basic.java jdk/test/jdk/modules/scenarios/overlappingpackages/src/misc/sun/misc/Unsafe.java jdk/test/sun/tools/jinfo/JInfoHelper.java jdk/test/sun/tools/jinfo/JInfoLauncherTest.java jdk/test/sun/tools/jinfo/JInfoRunningProcessFlagTest.java jdk/test/sun/tools/jinfo/JInfoRunningProcessTest.java jdk/test/sun/tools/jinfo/JInfoSanityTest.java jdk/test/sun/tools/jmap/heapconfig/JMapHeapConfigTest.java jdk/test/sun/tools/jmap/heapconfig/TmtoolTestScenario.java jdk/test/tools/launcher/modules/patch/PatchTest.java jdk/test/tools/launcher/modules/patch/src/test/jdk/test/Main.java jdk/test/tools/launcher/modules/patch/src/test/module-info.java jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/Annotation.java jdk/test/tools/launcher/modules/patch/src1/java.base/java/text/AnnotationBuddy.java jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/Main.java jdk/test/tools/launcher/modules/patch/src1/jdk.compiler/com/sun/tools/javac/MainBuddy.java jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClient.java jdk/test/tools/launcher/modules/patch/src1/jdk.naming.dns/com/sun/jndi/dns/DnsClientBuddy.java jdk/test/tools/launcher/modules/patch/src2/java.base/java/lang2/Object.java jdk/test/tools/launcher/modules/patch/src2/jdk.compiler/com/sun/tools/javac2/Main.java jdk/test/tools/launcher/modules/patch/src2/jdk.naming.dns/com/sun/jndi/dns2/Zone.java langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/ModuleWrappers.java langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeps/ModulePaths.java langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/remote/RemoteResolutionException.java langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/EditingHistory.java langtools/src/jdk.jshell/share/classes/jdk/jshell/ClassTracker.java langtools/src/jdk.jshell/share/classes/jdk/jshell/ExecutionControl.java langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIConnection.java langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIEnv.java langtools/src/jdk.jshell/share/classes/jdk/jshell/JDIEventHandler.java langtools/src/jdk.jshell/share/classes/jdk/jshell/JDINotConnectedException.java langtools/test/tools/jdeps/CompilerUtils.java make/HotspotWrapper.gmk nashorn/test/script/nosecurity/JDK-8144221.js nashorn/test/script/nosecurity/JDK-8144221.js.EXPECTED
diffstat 1697 files changed, 115538 insertions(+), 54769 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Mon Jun 06 23:24:46 2016 -0700
+++ b/.hgtags	Tue Jun 07 09:11:32 2016 +0000
@@ -361,3 +361,5 @@
 84aba7335005a3a47751dcf1f37935f97df9f99a jdk-9+116
 82b8d12a553f5617737c238cec060281d52e351c jdk-9+117
 7c04fcb12bd4a31570a238e663fa846dfa5ec3b8 jdk-9+118
+caf97b37ebec84288c112d21d3a60cb628cba1e8 jdk-9+119
+9330543436402b8f3bd070524846a464d8143557 jdk-9+120
--- a/.hgtags-top-repo	Mon Jun 06 23:24:46 2016 -0700
+++ b/.hgtags-top-repo	Tue Jun 07 09:11:32 2016 +0000
@@ -361,3 +361,5 @@
 6743a8e0cab7b5f6f4a0575f6664892f0ab740af jdk-9+116
 e882bcdbdac436523f3d5681611d3118a3804ea7 jdk-9+117
 047f95de8f918d8ff5e8cd2636a2abb5c3c8adb8 jdk-9+118
+3463a3f14f0f0e8a68f29ac6405454f2fa2f598a jdk-9+119
+647e0142a5a52749db572b5e6638d561def6479e jdk-9+120
--- a/common/autoconf/basics.m4	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/autoconf/basics.m4	Tue Jun 07 09:11:32 2016 +0000
@@ -484,6 +484,8 @@
   BASIC_REQUIRE_PROGS(FILE, file)
   BASIC_REQUIRE_PROGS(FIND, find)
   BASIC_REQUIRE_PROGS(HEAD, head)
+  BASIC_REQUIRE_PROGS(GUNZIP, gunzip)
+  BASIC_REQUIRE_PROGS(GZIP, pigz gzip)
   BASIC_REQUIRE_PROGS(LN, ln)
   BASIC_REQUIRE_PROGS(LS, ls)
   BASIC_REQUIRE_PROGS(MKDIR, mkdir)
@@ -496,7 +498,7 @@
   BASIC_REQUIRE_PROGS(SH, sh)
   BASIC_REQUIRE_PROGS(SORT, sort)
   BASIC_REQUIRE_PROGS(TAIL, tail)
-  BASIC_REQUIRE_PROGS(TAR, tar)
+  BASIC_REQUIRE_PROGS(TAR, gtar tar)
   BASIC_REQUIRE_PROGS(TEE, tee)
   BASIC_REQUIRE_PROGS(TOUCH, touch)
   BASIC_REQUIRE_PROGS(TR, tr)
@@ -839,8 +841,6 @@
 
   # The spec.gmk file contains all variables for the make system.
   AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in])
-  # The hotspot-spec.gmk file contains legacy variables for the hotspot make system.
-  AC_CONFIG_FILES([$OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in])
   # The bootcycle-spec.gmk file contains support for boot cycle builds.
   AC_CONFIG_FILES([$OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in])
   # The buildjdk-spec.gmk file contains support for building a buildjdk when cross compiling.
@@ -1009,11 +1009,36 @@
   AC_SUBST(FIND_DELETE)
 ])
 
+AC_DEFUN([BASIC_CHECK_TAR],
+[
+  # Test which kind of tar was found
+  if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then
+    TAR_TYPE="gnu"
+  elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then
+    TAR_TYPE="bsd"
+  elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
+    TAR_TYPE="solaris"
+  fi
+  AC_MSG_CHECKING([what type of tar was found])
+  AC_MSG_RESULT([$TAR_TYPE])
+
+  if test "x$TAR_TYPE" = "xgnu"; then
+    TAR_INCLUDE_PARAM="T"
+    TAR_SUPPORTS_TRANSFORM="true"
+  else
+    TAR_INCLUDE_PARAM="I"
+    TAR_SUPPORTS_TRANSFORM="false"
+  fi
+  AC_SUBST(TAR_INCLUDE_PARAM)
+  AC_SUBST(TAR_SUPPORTS_TRANSFORM)
+])
+
 AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
 [
   BASIC_CHECK_GNU_MAKE
 
   BASIC_CHECK_FIND_DELETE
+  BASIC_CHECK_TAR
 
   # These tools might not be installed by default,
   # need hint on how to install them.
--- a/common/autoconf/buildjdk-spec.gmk.in	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/autoconf/buildjdk-spec.gmk.in	Tue Jun 07 09:11:32 2016 +0000
@@ -134,8 +134,9 @@
 endif
 
 HOTSPOT_MAKE_ARGS := product docs export_product
-# Control wether Hotspot runs Queens test after building
-TEST_IN_BUILD := false
+
+# Control wether Hotspot builds gtest tests
+BUILD_GTEST := false
 
 USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@
 
--- a/common/autoconf/compare.sh.in	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/autoconf/compare.sh.in	Tue Jun 07 09:11:32 2016 +0000
@@ -48,6 +48,7 @@
 export FILE="@FILE@"
 export FIND="@FIND@"
 export GREP="@GREP@"
+export GUNZIP="@GUNZIP@"
 export LDD="@LDD@"
 export LN="@LN@"
 export MKDIR="@MKDIR@"
@@ -63,10 +64,11 @@
 export SORT="@SORT@"
 export STAT="@STAT@"
 export STRIP="@STRIP@ @STRIPFLAGS@"
+export TAR="@TAR@"
 export TEE="@TEE@"
 export UNIQ="@UNIQ@"
 export UNPACK200="@FIXPATH@ @BOOT_JDK@/bin/unpack200"
-export UNARCHIVE="@UNZIP@ -q"
+export UNARCHIVE="@UNZIP@ -q -o"
 
 export SRC_ROOT="@TOPDIR@"
 export OUTPUT_ROOT="@OUTPUT_ROOT@"
--- a/common/autoconf/configure.ac	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/autoconf/configure.ac	Tue Jun 07 09:11:32 2016 +0000
@@ -207,6 +207,7 @@
 # Need toolchain to setup dtrace
 HOTSPOT_SETUP_DTRACE
 HOTSPOT_SETUP_JVM_FEATURES
+HOTSPOT_ENABLE_DISABLE_GTEST
 
 ###############################################################################
 #
@@ -226,9 +227,9 @@
 #
 ###############################################################################
 
-HOTSPOT_SETUP_LEGACY_BUILD
 JDKOPT_DETECT_INTREE_EC
 JDKOPT_ENABLE_DISABLE_FAILURE_HANDLER
+JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST
 
 ###############################################################################
 #
--- a/common/autoconf/generated-configure.sh	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/autoconf/generated-configure.sh	Tue Jun 07 09:11:32 2016 +0000
@@ -650,23 +650,10 @@
 JOBS
 MEMORY_SIZE
 NUM_CORES
+ENABLE_GENERATE_CLASSLIST
 BUILD_FAILURE_HANDLER
 ENABLE_INTREE_EC
-JVM_VARIANT_CORE
-JVM_VARIANT_ZEROSHARK
-JVM_VARIANT_ZERO
-JVM_VARIANT_HOTSPOT
-JVM_VARIANT_MINIMAL1
-JVM_VARIANT_CLIENT
-JVM_VARIANT_SERVER
-JVM_VARIANTS_COMMA
-TEST_IN_BUILD
-HOTSPOT_MAKE_ARGS
-MACOSX_UNIVERSAL
-DEBUG_CLASSFILES
-FASTDEBUG
-VARIANT
-USE_NEW_HOTSPOT_BUILD
+STLPORT_LIB
 LIBZIP_CAN_USE_MMAP
 LIBDL
 LIBM
@@ -702,6 +689,7 @@
 STATIC_CXX_SETTING
 FIXPATH_DETACH_FLAG
 FIXPATH
+BUILD_GTEST
 VALID_JVM_FEATURES
 JVM_FEATURES_custom
 JVM_FEATURES_zeroshark
@@ -963,6 +951,8 @@
 LDD
 ZIP
 UNZIP
+TAR_SUPPORTS_TRANSFORM
+TAR_INCLUDE_PARAM
 FIND_DELETE
 OUTPUT_SYNC
 OUTPUT_SYNC_SUPPORTED
@@ -995,6 +985,9 @@
 HOTSPOT_BUILD_CPU
 HOTSPOT_BUILD_OS_TYPE
 HOTSPOT_BUILD_OS
+OPENJDK_BUILD_BUNDLE_PLATFORM
+OPENJDK_BUILD_CPU_BUNDLE
+OPENJDK_BUILD_OS_BUNDLE
 OPENJDK_BUILD_OS_EXPORT_DIR
 OPENJDK_BUILD_CPU_JLI_CFLAGS
 OPENJDK_BUILD_CPU_OSARCH
@@ -1009,6 +1002,9 @@
 HOTSPOT_TARGET_OS
 DEFINE_CROSS_COMPILE_ARCH
 LP64
+OPENJDK_TARGET_BUNDLE_PLATFORM
+OPENJDK_TARGET_CPU_BUNDLE
+OPENJDK_TARGET_OS_BUNDLE
 OPENJDK_TARGET_OS_EXPORT_DIR
 OPENJDK_TARGET_CPU_JLI_CFLAGS
 OPENJDK_TARGET_CPU_OSARCH
@@ -1078,6 +1074,8 @@
 MKDIR
 LS
 LN
+GZIP
+GUNZIP
 HEAD
 FIND
 FILE
@@ -1202,6 +1200,7 @@
 enable_dtrace
 with_jvm_features
 with_jvm_interpreter
+enable_hotspot_gtest
 with_stdc__lib
 with_msvcr_dll
 with_msvcp_dll
@@ -1227,9 +1226,8 @@
 with_dxsdk
 with_dxsdk_lib
 with_dxsdk_include
-enable_new_hotspot_build
-enable_hotspot_test_in_build
 enable_jtreg_failure_handler
+enable_generate_classlist
 with_num_cores
 with_memory_size
 with_jobs
@@ -1262,6 +1260,8 @@
 FILE
 FIND
 HEAD
+GUNZIP
+GZIP
 LN
 LS
 MKDIR
@@ -1996,21 +1996,21 @@
   --enable-dtrace[=yes/no/auto]
                           enable dtrace. Default is auto, where dtrace is
                           enabled if all dependencies are present.
+  --disable-hotspot-gtest Disables building of the Hotspot unit tests
   --disable-freetype-bundling
                           disable bundling of the freetype library with the
                           build result [enabled on Windows or when using
                           --with-freetype, disabled otherwise]
-  --disable-new-hotspot-build
-                          disable the new hotspot build system (use the old)
-                          [enabled]
-  --enable-hotspot-test-in-build
-                          run the Queens test after Hotspot build [disabled]
   --enable-jtreg-failure-handler
                           forces build of the jtreg failure handler to be
                           enabled, missing dependencies become fatal errors.
                           Default is auto, where the failure handler is built
                           if all dependencies are present and otherwise just
                           disabled.
+  --disable-generate-classlist
+                          forces enabling or disabling of the generation of a
+                          CDS classlist at build time. Default is to generate
+                          it when either the server or client JVMs are built.
   --enable-sjavac         use sjavac to do fast incremental compiles
                           [disabled]
   --disable-javac-server  disable javac server [enabled]
@@ -2205,6 +2205,8 @@
   FILE        Override default value for FILE
   FIND        Override default value for FIND
   HEAD        Override default value for HEAD
+  GUNZIP      Override default value for GUNZIP
+  GZIP        Override default value for GZIP
   LN          Override default value for LN
   LS          Override default value for LS
   MKDIR       Override default value for MKDIR
@@ -3707,6 +3709,8 @@
 
 
 
+
+
 # Check if build directory is on local disk. If not possible to determine,
 # we prefer to claim it's local.
 # Argument 1: directory to test
@@ -4303,9 +4307,8 @@
 #
 
 
-###############################################################################
-# Support for old hotspot build. Remove once new hotspot build has proven
-# to work satisfactory.
+################################################################################
+# Check if gtest should be built
 #
 
 
@@ -4394,6 +4397,12 @@
 #
 
 
+################################################################################
+#
+# Enable or disable generation of the classlist at build time
+#
+
+
 #
 # Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -4732,6 +4741,13 @@
 ################################################################################
 
 
+################################################################################
+# libstlport.so.1 is needed for running gtest on Solaris. Find it to
+# redistribute it in the test image.
+################################################################################
+
+
+
 #
 # Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -5076,7 +5092,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1462970869
+DATE_WHEN_GENERATED=1464173584
 
 ###############################################################################
 #
@@ -8404,6 +8420,414 @@
   # Publish this variable in the help.
 
 
+  if [ -z "${GUNZIP+x}" ]; then
+    # The variable is not set by user, try to locate tool using the code snippet
+    for ac_prog in gunzip
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_GUNZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GUNZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GUNZIP="$GUNZIP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_GUNZIP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+GUNZIP=$ac_cv_path_GUNZIP
+if test -n "$GUNZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUNZIP" >&5
+$as_echo "$GUNZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GUNZIP" && break
+done
+
+  else
+    # The variable is set, but is it from the command line or the environment?
+
+    # Try to remove the string !GUNZIP! from our list.
+    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!GUNZIP!/}
+    if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
+      # If it failed, the variable was not from the command line. Ignore it,
+      # but warn the user (except for BASH, which is always set by the calling BASH).
+      if test "xGUNZIP" != xBASH; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of GUNZIP from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of GUNZIP from the environment. Use command line variables instead." >&2;}
+      fi
+      # Try to locate tool using the code snippet
+      for ac_prog in gunzip
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_GUNZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GUNZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GUNZIP="$GUNZIP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_GUNZIP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+GUNZIP=$ac_cv_path_GUNZIP
+if test -n "$GUNZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUNZIP" >&5
+$as_echo "$GUNZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GUNZIP" && break
+done
+
+    else
+      # If it succeeded, then it was overridden by the user. We will use it
+      # for the tool.
+
+      # First remove it from the list of overridden variables, so we can test
+      # for unknown variables in the end.
+      CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
+
+      # Check if we try to supply an empty value
+      if test "x$GUNZIP" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool GUNZIP= (no value)" >&5
+$as_echo "$as_me: Setting user supplied tool GUNZIP= (no value)" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GUNZIP" >&5
+$as_echo_n "checking for GUNZIP... " >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
+$as_echo "disabled" >&6; }
+      else
+        # Check if the provided tool contains a complete path.
+        tool_specified="$GUNZIP"
+        tool_basename="${tool_specified##*/}"
+        if test "x$tool_basename" = "x$tool_specified"; then
+          # A command without a complete path is provided, search $PATH.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool GUNZIP=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool GUNZIP=$tool_basename" >&6;}
+          # Extract the first word of "$tool_basename", so it can be a program name with args.
+set dummy $tool_basename; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_GUNZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GUNZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GUNZIP="$GUNZIP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_GUNZIP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+GUNZIP=$ac_cv_path_GUNZIP
+if test -n "$GUNZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GUNZIP" >&5
+$as_echo "$GUNZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+          if test "x$GUNZIP" = x; then
+            as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
+          fi
+        else
+          # Otherwise we believe it is a complete path. Use it as it is.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool GUNZIP=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool GUNZIP=$tool_specified" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GUNZIP" >&5
+$as_echo_n "checking for GUNZIP... " >&6; }
+          if test ! -x "$tool_specified"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+            as_fn_error $? "User supplied tool GUNZIP=$tool_specified does not exist or is not executable" "$LINENO" 5
+          fi
+          { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
+$as_echo "$tool_specified" >&6; }
+        fi
+      fi
+    fi
+
+  fi
+
+
+
+  if test "x$GUNZIP" = x; then
+    as_fn_error $? "Could not find required tool for GUNZIP" "$LINENO" 5
+  fi
+
+
+
+
+
+  # Publish this variable in the help.
+
+
+  if [ -z "${GZIP+x}" ]; then
+    # The variable is not set by user, try to locate tool using the code snippet
+    for ac_prog in pigz gzip
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_GZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+GZIP=$ac_cv_path_GZIP
+if test -n "$GZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5
+$as_echo "$GZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GZIP" && break
+done
+
+  else
+    # The variable is set, but is it from the command line or the environment?
+
+    # Try to remove the string !GZIP! from our list.
+    try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!GZIP!/}
+    if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
+      # If it failed, the variable was not from the command line. Ignore it,
+      # but warn the user (except for BASH, which is always set by the calling BASH).
+      if test "xGZIP" != xBASH; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of GZIP from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of GZIP from the environment. Use command line variables instead." >&2;}
+      fi
+      # Try to locate tool using the code snippet
+      for ac_prog in pigz gzip
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_GZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+GZIP=$ac_cv_path_GZIP
+if test -n "$GZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5
+$as_echo "$GZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$GZIP" && break
+done
+
+    else
+      # If it succeeded, then it was overridden by the user. We will use it
+      # for the tool.
+
+      # First remove it from the list of overridden variables, so we can test
+      # for unknown variables in the end.
+      CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
+
+      # Check if we try to supply an empty value
+      if test "x$GZIP" = x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool GZIP= (no value)" >&5
+$as_echo "$as_me: Setting user supplied tool GZIP= (no value)" >&6;}
+        { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GZIP" >&5
+$as_echo_n "checking for GZIP... " >&6; }
+        { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
+$as_echo "disabled" >&6; }
+      else
+        # Check if the provided tool contains a complete path.
+        tool_specified="$GZIP"
+        tool_basename="${tool_specified##*/}"
+        if test "x$tool_basename" = "x$tool_specified"; then
+          # A command without a complete path is provided, search $PATH.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool GZIP=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool GZIP=$tool_basename" >&6;}
+          # Extract the first word of "$tool_basename", so it can be a program name with args.
+set dummy $tool_basename; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_GZIP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $GZIP in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_GZIP="$GZIP" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_GZIP="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+GZIP=$ac_cv_path_GZIP
+if test -n "$GZIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GZIP" >&5
+$as_echo "$GZIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+          if test "x$GZIP" = x; then
+            as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
+          fi
+        else
+          # Otherwise we believe it is a complete path. Use it as it is.
+          { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool GZIP=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool GZIP=$tool_specified" >&6;}
+          { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GZIP" >&5
+$as_echo_n "checking for GZIP... " >&6; }
+          if test ! -x "$tool_specified"; then
+            { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+            as_fn_error $? "User supplied tool GZIP=$tool_specified does not exist or is not executable" "$LINENO" 5
+          fi
+          { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
+$as_echo "$tool_specified" >&6; }
+        fi
+      fi
+    fi
+
+  fi
+
+
+
+  if test "x$GZIP" = x; then
+    as_fn_error $? "Could not find required tool for GZIP" "$LINENO" 5
+  fi
+
+
+
+
+
+  # Publish this variable in the help.
+
+
   if [ -z "${LN+x}" ]; then
     # The variable is not set by user, try to locate tool using the code snippet
     for ac_prog in ln
@@ -10854,7 +11278,7 @@
 
   if [ -z "${TAR+x}" ]; then
     # The variable is not set by user, try to locate tool using the code snippet
-    for ac_prog in tar
+    for ac_prog in gtar tar
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -10912,7 +11336,7 @@
 $as_echo "$as_me: WARNING: Ignoring value of TAR from the environment. Use command line variables instead." >&2;}
       fi
       # Try to locate tool using the code snippet
-      for ac_prog in tar
+      for ac_prog in gtar tar
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -15428,6 +15852,23 @@
   fi
 
 
+  # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
+  # Macosx is osx and x86_64 is x64
+  if test "x$OPENJDK_TARGET_OS" = xmacosx; then
+    OPENJDK_TARGET_OS_BUNDLE="osx"
+  else
+    OPENJDK_TARGET_OS_BUNDLE="$OPENJDK_TARGET_OS"
+  fi
+  if test "x$OPENJDK_TARGET_CPU" = xx86_64; then
+    OPENJDK_TARGET_CPU_BUNDLE="x64"
+  else
+    OPENJDK_TARGET_CPU_BUNDLE="$OPENJDK_TARGET_CPU"
+  fi
+  OPENJDK_TARGET_BUNDLE_PLATFORM="${OPENJDK_TARGET_OS_BUNDLE}-${OPENJDK_TARGET_CPU_BUNDLE}"
+
+
+
+
   if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
     A_LP64="LP64:="
     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
@@ -15584,6 +16025,23 @@
   fi
 
 
+  # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
+  # Macosx is osx and x86_64 is x64
+  if test "x$OPENJDK_BUILD_OS" = xmacosx; then
+    OPENJDK_BUILD_OS_BUNDLE="osx"
+  else
+    OPENJDK_BUILD_OS_BUNDLE="$OPENJDK_TARGET_OS"
+  fi
+  if test "x$OPENJDK_BUILD_CPU" = xx86_64; then
+    OPENJDK_BUILD_CPU_BUNDLE="x64"
+  else
+    OPENJDK_BUILD_CPU_BUNDLE="$OPENJDK_BUILD_CPU"
+  fi
+  OPENJDK_BUILD_BUNDLE_PLATFORM="${OPENJDK_BUILD_OS_BUNDLE}-${OPENJDK_BUILD_CPU_BUNDLE}"
+
+
+
+
   if test "x$OPENJDK_BUILD_CPU_BITS" = x64; then
     A_LP64="LP64:="
     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
@@ -16297,7 +16755,10 @@
   # Check that the selected variants are valid
 
   # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326
-  INVALID_VARIANTS=`$GREP -Fvx "${VALID_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"`
+  # Notice that the original variant failes on SLES 10 and 11
+  NEEDLE=${VALID_JVM_VARIANTS// /$'\n'}
+  STACK=${JVM_VARIANTS// /$'\n'}
+  INVALID_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
   if test "x$INVALID_VARIANTS" != x; then
     { $as_echo "$as_me:${as_lineno-$LINENO}: Unknown variant(s) specified: $INVALID_VARIANTS" >&5
 $as_echo "$as_me: Unknown variant(s) specified: $INVALID_VARIANTS" >&6;}
@@ -16306,7 +16767,9 @@
 
   # All "special" variants share the same output directory ("server")
   VALID_MULTIPLE_JVM_VARIANTS="server client minimal"
-  INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"`
+  NEEDLE=${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}
+  STACK=${JVM_VARIANTS// /$'\n'}
+  INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
   if  test "x$INVALID_MULTIPLE_VARIANTS" != x && test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = xtrue; then
     as_fn_error $? "You cannot build multiple variants with anything else than $VALID_MULTIPLE_JVM_VARIANTS." "$LINENO" 5
   fi
@@ -17016,9 +17479,6 @@
   # The spec.gmk file contains all variables for the make system.
   ac_config_files="$ac_config_files $OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in"
 
-  # The hotspot-spec.gmk file contains legacy variables for the hotspot make system.
-  ac_config_files="$ac_config_files $OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in"
-
   # The bootcycle-spec.gmk file contains support for boot cycle builds.
   ac_config_files="$ac_config_files $OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in"
 
@@ -20699,6 +21159,30 @@
 
 
 
+  # Test which kind of tar was found
+  if test "x$($TAR --version | $GREP "GNU tar")" != "x"; then
+    TAR_TYPE="gnu"
+  elif test "x$($TAR -v | $GREP "bsdtar")" != "x"; then
+    TAR_TYPE="bsd"
+  elif test "x$OPENJDK_BUILD_OS" = "xsolaris"; then
+    TAR_TYPE="solaris"
+  fi
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking what type of tar was found" >&5
+$as_echo_n "checking what type of tar was found... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $TAR_TYPE" >&5
+$as_echo "$TAR_TYPE" >&6; }
+
+  if test "x$TAR_TYPE" = "xgnu"; then
+    TAR_INCLUDE_PARAM="T"
+    TAR_SUPPORTS_TRANSFORM="true"
+  else
+    TAR_INCLUDE_PARAM="I"
+    TAR_SUPPORTS_TRANSFORM="false"
+  fi
+
+
+
+
   # These tools might not be installed by default,
   # need hint on how to install them.
 
@@ -23790,9 +24274,6 @@
   if test "x$OPENJDK_TARGET_OS" = xaix ; then
     INCLUDE_SA=false
   fi
-  if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
-    INCLUDE_SA=false
-  fi
 
 
   # Compress jars
@@ -52948,6 +53429,49 @@
 
 
 
+  # Check whether --enable-hotspot-gtest was given.
+if test "${enable_hotspot_gtest+set}" = set; then :
+  enableval=$enable_hotspot_gtest;
+fi
+
+
+  if test -e "$HOTSPOT_TOPDIR/test/native"; then
+    GTEST_DIR_EXISTS="true"
+  else
+    GTEST_DIR_EXISTS="false"
+  fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Hotspot gtest unit tests should be built" >&5
+$as_echo_n "checking if Hotspot gtest unit tests should be built... " >&6; }
+  if test "x$enable_hotspot_gtest" = "xyes"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, forced" >&5
+$as_echo "yes, forced" >&6; }
+      BUILD_GTEST="true"
+    else
+      as_fn_error $? "Cannot build gtest without the test source" "$LINENO" 5
+    fi
+  elif test "x$enable_hotspot_gtest" = "xno"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, forced" >&5
+$as_echo "no, forced" >&6; }
+    BUILD_GTEST="false"
+  elif test "x$enable_hotspot_gtest" = "x"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+      BUILD_GTEST="true"
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+      BUILD_GTEST="false"
+    fi
+  else
+    as_fn_error $? "--enable-gtest must be either yes or no" "$LINENO" 5
+  fi
+
+
+
+
 ###############################################################################
 #
 # Check dependencies for external and internal libraries.
@@ -64076,6 +64600,157 @@
 
 
 
+  if test "$OPENJDK_TARGET_OS" = "solaris"; then
+    # Find the root of the Solaris Studio installation from the compiler path
+    SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
+    STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libstlport.so.1" >&5
+$as_echo_n "checking for libstlport.so.1... " >&6; }
+    if test -f "$STLPORT_LIB"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, $STLPORT_LIB" >&5
+$as_echo "yes, $STLPORT_LIB" >&6; }
+
+  # Only process if variable expands to non-empty
+
+  if test "x$STLPORT_LIB" != x; then
+    if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+  # Input might be given as Windows format, start by converting to
+  # unix format.
+  path="$STLPORT_LIB"
+  new_path=`$CYGPATH -u "$path"`
+
+  # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+  # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+  # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+  # "foo.exe" is OK but "foo" is an error.
+  #
+  # This test is therefore slightly more accurate than "test -f" to check for file precense.
+  # It is also a way to make sure we got the proper file name for the real test later on.
+  test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+  if test "x$test_shortpath" = x; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STLPORT_LIB, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of STLPORT_LIB, which resolves as \"$path\", is invalid." >&6;}
+    as_fn_error $? "Cannot locate the the path of STLPORT_LIB" "$LINENO" 5
+  fi
+
+  # Call helper function which possibly converts this using DOS-style short mode.
+  # If so, the updated path is stored in $new_path.
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+    path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+    if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+      # Going to short mode and back again did indeed matter. Since short mode is
+      # case insensitive, let's make it lowercase to improve readability.
+      shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+      # Now convert it back to Unix-style (cygpath)
+      input_path=`$CYGPATH -u "$shortmode_path"`
+      new_path="$input_path"
+    fi
+  fi
+
+  test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+  if test "x$test_cygdrive_prefix" = x; then
+    # As a simple fix, exclude /usr/bin since it's not a real path.
+    if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+      # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+      # a path prefixed by /cygdrive for fixpath to work.
+      new_path="$CYGWIN_ROOT_PATH$input_path"
+    fi
+  fi
+
+
+  if test "x$path" != "x$new_path"; then
+    STLPORT_LIB="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting STLPORT_LIB to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting STLPORT_LIB to \"$new_path\"" >&6;}
+  fi
+
+    elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+  path="$STLPORT_LIB"
+  has_colon=`$ECHO $path | $GREP ^.:`
+  new_path="$path"
+  if test "x$has_colon" = x; then
+    # Not in mixed or Windows style, start by that.
+    new_path=`cmd //c echo $path`
+  fi
+
+
+  input_path="$new_path"
+  # Check if we need to convert this using DOS-style short mode. If the path
+  # contains just simple characters, use it. Otherwise (spaces, weird characters),
+  # take no chances and rewrite it.
+  # Note: m4 eats our [], so we need to use [ and ] instead.
+  has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+  if test "x$has_forbidden_chars" != x; then
+    # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+    new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+  fi
+
+
+  windows_path="$new_path"
+  if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+    unix_path=`$CYGPATH -u "$windows_path"`
+    new_path="$unix_path"
+  elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+    unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+    new_path="$unix_path"
+  fi
+
+  if test "x$path" != "x$new_path"; then
+    STLPORT_LIB="$new_path"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting STLPORT_LIB to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting STLPORT_LIB to \"$new_path\"" >&6;}
+  fi
+
+  # Save the first 10 bytes of this path to the storage, so fixpath can work.
+  all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+    else
+      # We're on a unix platform. Hooray! :)
+      path="$STLPORT_LIB"
+      has_space=`$ECHO "$path" | $GREP " "`
+      if test "x$has_space" != x; then
+        { $as_echo "$as_me:${as_lineno-$LINENO}: The path of STLPORT_LIB, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of STLPORT_LIB, which resolves as \"$path\", is invalid." >&6;}
+        as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+      fi
+
+      # Use eval to expand a potential ~
+      eval path="$path"
+      if test ! -f "$path" && test ! -d "$path"; then
+        as_fn_error $? "The path of STLPORT_LIB, which resolves as \"$path\", is not found." "$LINENO" 5
+      fi
+
+      if test -d "$path"; then
+        STLPORT_LIB="`cd "$path"; $THEPWDCMD -L`"
+      else
+        dir="`$DIRNAME "$path"`"
+        base="`$BASENAME "$path"`"
+        STLPORT_LIB="`cd "$dir"; $THEPWDCMD -L`/$base"
+      fi
+    fi
+  fi
+
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, not found at $STLPORT_LIB" >&5
+$as_echo "no, not found at $STLPORT_LIB" >&6; }
+      as_fn_error $? "Failed to find libstlport.so.1, cannot build Hotspot gtests" "$LINENO" 5
+    fi
+
+  fi
+
+
+
 
 
 
@@ -64094,144 +64769,6 @@
 ###############################################################################
 
 
-  # Check whether --enable-new-hotspot-build was given.
-if test "${enable_new_hotspot_build+set}" = set; then :
-  enableval=$enable_new_hotspot_build;
-fi
-
-
-   if test "x$enable_new_hotspot_build" = "x" || test "x$enable_new_hotspot_build" = "xyes"; then
-     USE_NEW_HOTSPOT_BUILD=true
-   else
-     USE_NEW_HOTSPOT_BUILD=false
-   fi
-
-
-  case $HOTSPOT_DEBUG_LEVEL in
-    product )
-      VARIANT="OPT"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="false"
-      ;;
-    fastdebug )
-      VARIANT="DBG"
-      FASTDEBUG="true"
-      DEBUG_CLASSFILES="true"
-      ;;
-    debug )
-      VARIANT="DBG"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="true"
-      ;;
-    optimized )
-      VARIANT="OPT"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="false"
-      ;;
-  esac
-
-
-
-
-  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
-    MACOSX_UNIVERSAL="true"
-  fi
-
-
-
-  # Make sure JVM_VARIANTS_COMMA use minimal1 for backwards compatibility
-  JVM_VARIANTS_COMMA=`$ECHO ,$JVM_VARIANTS_OPT, | $SED -e 's/,minimal,/,minimal1,/'`
-
-  JVM_VARIANT_SERVER=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,server,/!s/.*/false/g' -e '/,server,/s/.*/true/g'`
-  JVM_VARIANT_CLIENT=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,client,/!s/.*/false/g' -e '/,client,/s/.*/true/g'`
-  JVM_VARIANT_MINIMAL1=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,minimal1\?,/!s/.*/false/g' -e '/,minimal1\?,/s/.*/true/g'`
-  JVM_VARIANT_CORE=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,core,/!s/.*/false/g' -e '/,core,/s/.*/true/g'`
-  JVM_VARIANT_ZERO=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zero,/!s/.*/false/g' -e '/,zero,/s/.*/true/g'`
-  JVM_VARIANT_ZEROSHARK=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zeroshark,/!s/.*/false/g' -e '/,zeroshark,/s/.*/true/g'`
-  JVM_VARIANT_CUSTOM=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,custom,/!s/.*/false/g' -e '/,custom,/s/.*/true/g'`
-
-  #####
-  # Generate the legacy makefile targets for hotspot.
-  HOTSPOT_TARGET=""
-
-  if test "x$JVM_VARIANT_SERVER" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL} "
-  fi
-
-  if test "x$JVM_VARIANT_CLIENT" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}1 "
-  fi
-
-  if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}minimal1 "
-  fi
-
-  if test "x$JVM_VARIANT_ZERO" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}zero "
-  fi
-
-  if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}shark "
-  fi
-
-  if test "x$JVM_VARIANT_CORE" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}core "
-  fi
-
-  HOTSPOT_TARGET="$HOTSPOT_TARGET docs export_$HOTSPOT_DEBUG_LEVEL"
-
-  # On Macosx universal binaries are produced, but they only contain
-  # 64 bit intel. This invalidates control of which jvms are built
-  # from configure, but only server is valid anyway. Fix this
-  # when hotspot makefiles are rewritten.
-  if test "x$MACOSX_UNIVERSAL" = xtrue; then
-    HOTSPOT_TARGET=universal_${HOTSPOT_DEBUG_LEVEL}
-  fi
-
-  HOTSPOT_MAKE_ARGS="$HOTSPOT_TARGET"
-
-
-  # Control wether Hotspot runs Queens test after build.
-  # Check whether --enable-hotspot-test-in-build was given.
-if test "${enable_hotspot_test_in_build+set}" = set; then :
-  enableval=$enable_hotspot_test_in_build;
-else
-  enable_hotspot_test_in_build=no
-fi
-
-  if test "x$enable_hotspot_test_in_build" = "xyes"; then
-    TEST_IN_BUILD=true
-  else
-    TEST_IN_BUILD=false
-  fi
-
-
-  if test "x$USE_NEW_HOTSPOT_BUILD" = xfalse; then
-    if test "x$JVM_VARIANT_CLIENT" = xtrue; then
-      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        as_fn_error $? "You cannot build a client JVM for a 64-bit machine." "$LINENO" 5
-      fi
-    fi
-    if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
-      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        as_fn_error $? "You cannot build a minimal JVM for a 64-bit machine." "$LINENO" 5
-      fi
-    fi
-    if test "x$JVM_VARIANT_CUSTOM" = xtrue; then
-        as_fn_error $? "You cannot build a custom JVM using the old hotspot build system." "$LINENO" 5
-    fi
-  fi
-
-
-
-
-
-
-
-
-
-
-
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if elliptic curve crypto implementation is present" >&5
 $as_echo_n "checking if elliptic curve crypto implementation is present... " >&6; }
 
@@ -64287,6 +64824,51 @@
 
 
 
+  # Check whether --enable-generate-classlist was given.
+if test "${enable_generate_classlist+set}" = set; then :
+  enableval=$enable_generate_classlist;
+fi
+
+
+  # Check if it's likely that it's possible to generate the classlist. Depending
+  # on exact jvm configuration it could be possible anyway.
+  if   [[ " $JVM_VARIANTS " =~ " server " ]]   ||   [[ " $JVM_VARIANTS " =~ " client " ]]  ; then
+    ENABLE_GENERATE_CLASSLIST_POSSIBLE="true"
+  else
+    ENABLE_GENERATE_CLASSLIST_POSSIBLE="false"
+  fi
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if the CDS classlist generation should be enabled" >&5
+$as_echo_n "checking if the CDS classlist generation should be enabled... " >&6; }
+  if test "x$enable_generate_classlist" = "xyes"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, forced" >&5
+$as_echo "yes, forced" >&6; }
+    ENABLE_GENERATE_CLASSLIST="true"
+    if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xfalse"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS" >&5
+$as_echo "$as_me: WARNING: Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS" >&2;}
+    fi
+  elif test "x$enable_generate_classlist" = "xno"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, forced" >&5
+$as_echo "no, forced" >&6; }
+    ENABLE_GENERATE_CLASSLIST="false"
+  elif test "x$enable_generate_classlist" = "x"; then
+    if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xtrue"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+      ENABLE_GENERATE_CLASSLIST="true"
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+      ENABLE_GENERATE_CLASSLIST="false"
+    fi
+  else
+    as_fn_error $? "Invalid value for --enable-generate-classlist: $enable_generate_classlist" "$LINENO" 5
+  fi
+
+
+
+
 ###############################################################################
 #
 # Configure parts of the build that only affect the build performance,
@@ -65977,7 +66559,9 @@
     JVM_FEATURES_TO_TEST=${!features_var_name}
     { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JVM_FEATURES_TO_TEST" >&5
 $as_echo "$JVM_FEATURES_TO_TEST" >&6; }
-    INVALID_FEATURES=`$GREP -Fvx "${VALID_JVM_FEATURES// /$'\n'}" <<< "${JVM_FEATURES_TO_TEST// /$'\n'}"`
+    NEEDLE=${VALID_JVM_FEATURES// /$'\n'}
+    STACK=${JVM_FEATURES_TO_TEST// /$'\n'}
+    INVALID_FEATURES=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
     if test "x$INVALID_FEATURES" != x; then
       as_fn_error $? "Invalid JVM feature(s): $INVALID_FEATURES" "$LINENO" 5
     fi
@@ -66697,7 +67281,6 @@
 do
   case $ac_config_target in
     "$OUTPUT_ROOT/spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in" ;;
-    "$OUTPUT_ROOT/hotspot-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/hotspot-spec.gmk:$AUTOCONF_DIR/hotspot-spec.gmk.in" ;;
     "$OUTPUT_ROOT/bootcycle-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in" ;;
     "$OUTPUT_ROOT/buildjdk-spec.gmk") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/buildjdk-spec.gmk:$AUTOCONF_DIR/buildjdk-spec.gmk.in" ;;
     "$OUTPUT_ROOT/compare.sh") CONFIG_FILES="$CONFIG_FILES $OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in" ;;
--- a/common/autoconf/hotspot-spec.gmk.in	Mon Jun 06 23:24:46 2016 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,158 +0,0 @@
-#
-# Copyright (c) 2011, 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.
-#
-
-
-# Chaining of spec files
-HOTSPOT_SPEC:=$(dir $(SPEC))hotspot-spec.gmk
-override SPEC=$(HOTSPOT_SPEC)
-# Now include the base spec.gmk file
-include $(BASE_SPEC)
-
-# Additional legacy variables defined for Hotspot
-
-@SET_OPENJDK@
-@HOTSPOT_SET_WARNINGS_AS_ERRORS@
-
-# Legacy defines controlled by the SUPPORT_HEADLESS and SUPPORT_HEADFUL options.
-@BUILD_HEADLESS@
-
-JVM_VARIANTS:=@JVM_VARIANTS_COMMA@
-
-JVM_VARIANT_SERVER:=@JVM_VARIANT_SERVER@
-JVM_VARIANT_CLIENT:=@JVM_VARIANT_CLIENT@
-JVM_VARIANT_MINIMAL1:=@JVM_VARIANT_MINIMAL1@
-JVM_VARIANT_CORE:=@JVM_VARIANT_CORE@
-JVM_VARIANT_ZERO:=@JVM_VARIANT_ZERO@
-JVM_VARIANT_ZEROSHARK:=@JVM_VARIANT_ZEROSHARK@
-JVM_VARIANT_CUSTOM:=@JVM_VARIANT_HOTSPOT@
-
-# Legacy setting: OPT or DBG
-VARIANT:=@VARIANT@
-# Legacy setting: true or false
-FASTDEBUG:=@FASTDEBUG@
-# Legacy setting: debugging the class files?
-DEBUG_CLASSFILES:=@DEBUG_CLASSFILES@
-
-ALT_CUPS_HEADERS_PATH:=$(patsubst -I%,%,$(filter -I%,@CUPS_CFLAGS@))
-
-# The HOSTCC/HOSTCXX is Hotspot terminology for the BUILD_CC/BUILD_CXX, i.e. the
-# compiler that produces code that can be run on the build platform.
-HOSTCC:=@FIXPATH@ @BUILD_ICECC@ @BUILD_CC@ $(BUILD_SYSROOT_CFLAGS)
-HOSTCXX:=@FIXPATH@ @BUILD_ICECC@ @BUILD_CXX@ $(BUILD_SYSROOT_CFLAGS)
-
-####################################################
-#
-# Legacy Hotspot support
-
-# If cross compiling, then define CROSS_COMPILE_ARCH:=cpu_name here.
-@DEFINE_CROSS_COMPILE_ARCH@
-
-# Old name for OPENJDK_TARGET_OS (aix,bsd,hpux,linux,macosx,solaris,windows etc)
-PLATFORM=$(OPENJDK_TARGET_OS)
-# 32 or 64 bit
-ARCH_DATA_MODEL=$(OPENJDK_TARGET_CPU_BITS)
-
-ALT_BOOTDIR=$(BOOT_JDK)
-# Can be /sparcv9 or /amd64 on Solaris
-ISA_DIR=$(OPENJDK_TARGET_CPU_ISADIR)
-# Yet another name for arch used for an extra subdir below the jvm lib.
-# Uses i386 and amd64, instead of x86 and x86_64.
-LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB)
-# Set the cpu architecture
-ARCH=$(OPENJDK_TARGET_CPU_ARCH)
-# Legacy setting for building for a 64 bit machine.
-# If yes then this expands to _LP64:=1
-@LP64@
-
-# Legacy settings for zero
-ZERO_ENDIANNESS=$(OPENJDK_TARGET_CPU_ENDIAN)
-ZERO_LIBARCH=$(OPENJDK_TARGET_CPU_LEGACY_LIB)
-ZERO_ARCHDEF=@ZERO_ARCHDEF@
-ZERO_ARCHFLAG=@ZERO_ARCHFLAG@
-LIBFFI_CFLAGS=@LIBFFI_CFLAGS@
-LIBFFI_LIBS=@LIBFFI_LIBS@
-
-# Legacy settings for zeroshark
-LLVM_CFLAGS=@LLVM_CFLAGS@
-LLVM_LIBS=@LLVM_LIBS@
-LLVM_LDFLAGS=@LLVM_LDFLAGS@
-
-ALT_OUTPUTDIR=$(HOTSPOT_OUTPUTDIR)
-ALT_EXPORT_PATH=$(HOTSPOT_DIST)
-
-ifeq ($(HOTSPOT_TARGET_CPU), zero)
-  CC_INTERP=true
-endif
-
-HOTSPOT_MAKE_ARGS:=@HOTSPOT_MAKE_ARGS@ @STATIC_CXX_SETTING@
-# Control wether Hotspot runs Queens test after building
-TEST_IN_BUILD=@TEST_IN_BUILD@
-
-USE_CLANG := @USE_CLANG@
-
-# For hotspot, override compiler/tools definition to not include FIXPATH prefix.
-# Hotspot has its own handling on the Windows path situation.
-CXX:=@CCACHE@ @ICECC@ @HOTSPOT_CXX@
-LD:=@HOTSPOT_LD@
-MT:=@HOTSPOT_MT@
-RC:=@HOTSPOT_RC@
-
-EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ $(CFLAGS_CCACHE) $(NO_NULL_POINTER_CHECK_FLAG) \
-				   $(NO_LIFETIME_DSE_CFLAG) $(CXXSTD_CXXFLAG)
-EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@ $(CFLAGS_CCACHE)
-EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@
-
-USE_PRECOMPILED_HEADER=@USE_PRECOMPILED_HEADER@
-
-# Hotspot expects the variable FULL_DEBUG_SYMBOLS=1/0 to control debug symbols
-# creation.
-ifeq ($(COPY_DEBUG_SYMBOLS), true)
-  FULL_DEBUG_SYMBOLS=1
-  # Ensure hotspot uses the objcopy that configure located
-  ALT_OBJCOPY:=$(OBJCOPY)
-else
-  FULL_DEBUG_SYMBOLS=0
-endif
-
-# Hotspot expects the variable ZIP_DEBUGINFO_FILES=1/0 and not true/false.
-ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
-  ZIP_DEBUGINFO_FILES:=1
-else
-  ZIP_DEBUGINFO_FILES:=0
-endif
-
-DEBUG_BINARIES := @DEBUG_BINARIES@
-STRIP_POLICY := @STRIP_POLICY@
-
-ifeq ($(OPENJDK_TARGET_OS), windows)
-  # On Windows, the Visual Studio toolchain needs the LIB and INCLUDE
-  # environment variables (in Windows path style).
-  export INCLUDE:=@VS_INCLUDE@
-  export LIB:=@VS_LIB@
-endif
-
-# Sneak this in via the spec.gmk file, since we don't want to mess around too much with the Hotspot make files.
-# This is needed to get the LOG setting to work properly.
-include $(SRC_ROOT)/make/common/MakeBase.gmk
--- a/common/autoconf/hotspot.m4	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/autoconf/hotspot.m4	Tue Jun 07 09:11:32 2016 +0000
@@ -93,7 +93,10 @@
   # Check that the selected variants are valid
 
   # grep filter function inspired by a comment to http://stackoverflow.com/a/1617326
-  INVALID_VARIANTS=`$GREP -Fvx "${VALID_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"`
+  # Notice that the original variant failes on SLES 10 and 11
+  NEEDLE=${VALID_JVM_VARIANTS// /$'\n'}
+  STACK=${JVM_VARIANTS// /$'\n'}
+  INVALID_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
   if test "x$INVALID_VARIANTS" != x; then
     AC_MSG_NOTICE([Unknown variant(s) specified: $INVALID_VARIANTS])
     AC_MSG_ERROR([The available JVM variants are: $VALID_JVM_VARIANTS])
@@ -101,7 +104,9 @@
 
   # All "special" variants share the same output directory ("server")
   VALID_MULTIPLE_JVM_VARIANTS="server client minimal"
-  INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}" <<< "${JVM_VARIANTS// /$'\n'}"`
+  NEEDLE=${VALID_MULTIPLE_JVM_VARIANTS// /$'\n'}
+  STACK=${JVM_VARIANTS// /$'\n'}
+  INVALID_MULTIPLE_VARIANTS=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
   if  test "x$INVALID_MULTIPLE_VARIANTS" != x && test "x$BUILDING_MULTIPLE_JVM_VARIANTS" = xtrue; then
     AC_MSG_ERROR([You cannot build multiple variants with anything else than $VALID_MULTIPLE_JVM_VARIANTS.])
   fi
@@ -293,146 +298,51 @@
     features_var_name=JVM_FEATURES_$variant
     JVM_FEATURES_TO_TEST=${!features_var_name}
     AC_MSG_RESULT([$JVM_FEATURES_TO_TEST])
-    INVALID_FEATURES=`$GREP -Fvx "${VALID_JVM_FEATURES// /$'\n'}" <<< "${JVM_FEATURES_TO_TEST// /$'\n'}"`
+    NEEDLE=${VALID_JVM_FEATURES// /$'\n'}
+    STACK=${JVM_FEATURES_TO_TEST// /$'\n'}
+    INVALID_FEATURES=`$GREP -Fvx "${NEEDLE}" <<< "${STACK}"`
     if test "x$INVALID_FEATURES" != x; then
       AC_MSG_ERROR([Invalid JVM feature(s): $INVALID_FEATURES])
     fi
   done
 ])
 
-###############################################################################
-# Support for old hotspot build. Remove once new hotspot build has proven
-# to work satisfactory.
+################################################################################
+# Check if gtest should be built
 #
-AC_DEFUN_ONCE([HOTSPOT_SETUP_LEGACY_BUILD],
+AC_DEFUN_ONCE([HOTSPOT_ENABLE_DISABLE_GTEST],
 [
-  AC_ARG_ENABLE(new-hotspot-build, [AS_HELP_STRING([--disable-new-hotspot-build],
-      [disable the new hotspot build system (use the old) @<:@enabled@:>@])])
+  AC_ARG_ENABLE([hotspot-gtest], [AS_HELP_STRING([--disable-hotspot-gtest],
+      [Disables building of the Hotspot unit tests])])
 
-   if test "x$enable_new_hotspot_build" = "x" || test "x$enable_new_hotspot_build" = "xyes"; then
-     USE_NEW_HOTSPOT_BUILD=true
-   else
-     USE_NEW_HOTSPOT_BUILD=false
-   fi
-  AC_SUBST(USE_NEW_HOTSPOT_BUILD)
-
-  case $HOTSPOT_DEBUG_LEVEL in
-    product )
-      VARIANT="OPT"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="false"
-      ;;
-    fastdebug )
-      VARIANT="DBG"
-      FASTDEBUG="true"
-      DEBUG_CLASSFILES="true"
-      ;;
-    debug )
-      VARIANT="DBG"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="true"
-      ;;
-    optimized )
-      VARIANT="OPT"
-      FASTDEBUG="false"
-      DEBUG_CLASSFILES="false"
-      ;;
-  esac
-  AC_SUBST(VARIANT)
-  AC_SUBST(FASTDEBUG)
-  AC_SUBST(DEBUG_CLASSFILES)
-
-  if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
-    MACOSX_UNIVERSAL="true"
+  if test -e "$HOTSPOT_TOPDIR/test/native"; then
+    GTEST_DIR_EXISTS="true"
+  else
+    GTEST_DIR_EXISTS="false"
   fi
 
-  AC_SUBST(MACOSX_UNIVERSAL)
-
-  # Make sure JVM_VARIANTS_COMMA use minimal1 for backwards compatibility
-  JVM_VARIANTS_COMMA=`$ECHO ,$JVM_VARIANTS_OPT, | $SED -e 's/,minimal,/,minimal1,/'`
-
-  JVM_VARIANT_SERVER=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,server,/!s/.*/false/g' -e '/,server,/s/.*/true/g'`
-  JVM_VARIANT_CLIENT=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,client,/!s/.*/false/g' -e '/,client,/s/.*/true/g'`
-  JVM_VARIANT_MINIMAL1=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,minimal1\?,/!s/.*/false/g' -e '/,minimal1\?,/s/.*/true/g'`
-  JVM_VARIANT_CORE=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,core,/!s/.*/false/g' -e '/,core,/s/.*/true/g'`
-  JVM_VARIANT_ZERO=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zero,/!s/.*/false/g' -e '/,zero,/s/.*/true/g'`
-  JVM_VARIANT_ZEROSHARK=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,zeroshark,/!s/.*/false/g' -e '/,zeroshark,/s/.*/true/g'`
-  JVM_VARIANT_CUSTOM=`$ECHO "$JVM_VARIANTS_COMMA" | $SED -e '/,custom,/!s/.*/false/g' -e '/,custom,/s/.*/true/g'`
-
-  #####
-  # Generate the legacy makefile targets for hotspot.
-  HOTSPOT_TARGET=""
-
-  if test "x$JVM_VARIANT_SERVER" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL} "
+  AC_MSG_CHECKING([if Hotspot gtest unit tests should be built])
+  if test "x$enable_hotspot_gtest" = "xyes"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      AC_MSG_RESULT([yes, forced])
+      BUILD_GTEST="true"
+    else
+      AC_MSG_ERROR([Cannot build gtest without the test source])
+    fi
+  elif test "x$enable_hotspot_gtest" = "xno"; then
+    AC_MSG_RESULT([no, forced])
+    BUILD_GTEST="false"
+  elif test "x$enable_hotspot_gtest" = "x"; then
+    if test "x$GTEST_DIR_EXISTS" = "xtrue"; then
+      AC_MSG_RESULT([yes])
+      BUILD_GTEST="true"
+    else
+      AC_MSG_RESULT([no])
+      BUILD_GTEST="false"
+    fi
+  else
+    AC_MSG_ERROR([--enable-gtest must be either yes or no])
   fi
 
-  if test "x$JVM_VARIANT_CLIENT" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}1 "
-  fi
-
-  if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}minimal1 "
-  fi
-
-  if test "x$JVM_VARIANT_ZERO" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}zero "
-  fi
-
-  if test "x$JVM_VARIANT_ZEROSHARK" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}shark "
-  fi
-
-  if test "x$JVM_VARIANT_CORE" = xtrue; then
-    HOTSPOT_TARGET="$HOTSPOT_TARGET${HOTSPOT_DEBUG_LEVEL}core "
-  fi
-
-  HOTSPOT_TARGET="$HOTSPOT_TARGET docs export_$HOTSPOT_DEBUG_LEVEL"
-
-  # On Macosx universal binaries are produced, but they only contain
-  # 64 bit intel. This invalidates control of which jvms are built
-  # from configure, but only server is valid anyway. Fix this
-  # when hotspot makefiles are rewritten.
-  if test "x$MACOSX_UNIVERSAL" = xtrue; then
-    HOTSPOT_TARGET=universal_${HOTSPOT_DEBUG_LEVEL}
-  fi
-
-  HOTSPOT_MAKE_ARGS="$HOTSPOT_TARGET"
-  AC_SUBST(HOTSPOT_MAKE_ARGS)
-
-  # Control wether Hotspot runs Queens test after build.
-  AC_ARG_ENABLE([hotspot-test-in-build], [AS_HELP_STRING([--enable-hotspot-test-in-build],
-      [run the Queens test after Hotspot build @<:@disabled@:>@])],,
-      [enable_hotspot_test_in_build=no])
-  if test "x$enable_hotspot_test_in_build" = "xyes"; then
-    TEST_IN_BUILD=true
-  else
-    TEST_IN_BUILD=false
-  fi
-  AC_SUBST(TEST_IN_BUILD)
-
-  if test "x$USE_NEW_HOTSPOT_BUILD" = xfalse; then
-    if test "x$JVM_VARIANT_CLIENT" = xtrue; then
-      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        AC_MSG_ERROR([You cannot build a client JVM for a 64-bit machine.])
-      fi
-    fi
-    if test "x$JVM_VARIANT_MINIMAL1" = xtrue; then
-      if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
-        AC_MSG_ERROR([You cannot build a minimal JVM for a 64-bit machine.])
-      fi
-    fi
-    if test "x$JVM_VARIANT_CUSTOM" = xtrue; then
-        AC_MSG_ERROR([You cannot build a custom JVM using the old hotspot build system.])
-    fi
-  fi
-
-  AC_SUBST(JVM_VARIANTS_COMMA)
-  AC_SUBST(JVM_VARIANT_SERVER)
-  AC_SUBST(JVM_VARIANT_CLIENT)
-  AC_SUBST(JVM_VARIANT_MINIMAL1)
-  AC_SUBST(JVM_VARIANT_HOTSPOT)
-  AC_SUBST(JVM_VARIANT_ZERO)
-  AC_SUBST(JVM_VARIANT_ZEROSHARK)
-  AC_SUBST(JVM_VARIANT_CORE)
+  AC_SUBST(BUILD_GTEST)
 ])
--- a/common/autoconf/jdk-options.m4	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/autoconf/jdk-options.m4	Tue Jun 07 09:11:32 2016 +0000
@@ -209,9 +209,6 @@
   if test "x$OPENJDK_TARGET_OS" = xaix ; then
     INCLUDE_SA=false
   fi
-  if test "x$OPENJDK_TARGET_CPU" = xaarch64; then
-    INCLUDE_SA=false
-  fi
   AC_SUBST(INCLUDE_SA)
 
   # Compress jars
@@ -494,3 +491,46 @@
 
   AC_SUBST(BUILD_FAILURE_HANDLER)
 ])
+
+################################################################################
+#
+# Enable or disable generation of the classlist at build time
+#
+AC_DEFUN_ONCE([JDKOPT_ENABLE_DISABLE_GENERATE_CLASSLIST],
+[
+  AC_ARG_ENABLE([generate-classlist], [AS_HELP_STRING([--disable-generate-classlist],
+      [forces enabling or disabling of the generation of a CDS classlist at build time.
+      Default is to generate it when either the server or client JVMs are built.])])
+
+  # Check if it's likely that it's possible to generate the classlist. Depending
+  # on exact jvm configuration it could be possible anyway.
+  if HOTSPOT_CHECK_JVM_VARIANT(server) || HOTSPOT_CHECK_JVM_VARIANT(client); then
+    ENABLE_GENERATE_CLASSLIST_POSSIBLE="true"
+  else
+    ENABLE_GENERATE_CLASSLIST_POSSIBLE="false"
+  fi
+
+  AC_MSG_CHECKING([if the CDS classlist generation should be enabled])
+  if test "x$enable_generate_classlist" = "xyes"; then
+    AC_MSG_RESULT([yes, forced])
+    ENABLE_GENERATE_CLASSLIST="true"
+    if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xfalse"; then
+      AC_MSG_WARN([Generation of classlist might not be possible with JVM Variants $JVM_VARIANTS])
+    fi
+  elif test "x$enable_generate_classlist" = "xno"; then
+    AC_MSG_RESULT([no, forced])
+    ENABLE_GENERATE_CLASSLIST="false"
+  elif test "x$enable_generate_classlist" = "x"; then
+    if test "x$ENABLE_GENERATE_CLASSLIST_POSSIBLE" = "xtrue"; then
+      AC_MSG_RESULT([yes])
+      ENABLE_GENERATE_CLASSLIST="true"
+    else
+      AC_MSG_RESULT([no])
+      ENABLE_GENERATE_CLASSLIST="false"
+    fi
+  else
+    AC_MSG_ERROR([Invalid value for --enable-generate-classlist: $enable_generate_classlist])
+  fi
+
+  AC_SUBST([ENABLE_GENERATE_CLASSLIST])
+])
--- a/common/autoconf/libraries.m4	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/autoconf/libraries.m4	Tue Jun 07 09:11:32 2016 +0000
@@ -95,6 +95,7 @@
   LIB_SETUP_LLVM
   LIB_SETUP_BUNDLED_LIBS
   LIB_SETUP_MISC_LIBS
+  LIB_SETUP_SOLARIS_STLPORT
 ])
 
 ################################################################################
@@ -189,3 +190,26 @@
   LIBZIP_CAN_USE_MMAP=true
   AC_SUBST(LIBZIP_CAN_USE_MMAP)
 ])
+
+################################################################################
+# libstlport.so.1 is needed for running gtest on Solaris. Find it to
+# redistribute it in the test image.
+################################################################################
+AC_DEFUN_ONCE([LIB_SETUP_SOLARIS_STLPORT],
+[
+  if test "$OPENJDK_TARGET_OS" = "solaris"; then
+    # Find the root of the Solaris Studio installation from the compiler path
+    SOLARIS_STUDIO_DIR="$(dirname $CC)/.."
+    STLPORT_LIB="$SOLARIS_STUDIO_DIR/lib/stlport4$OPENJDK_TARGET_CPU_ISADIR/libstlport.so.1"
+    AC_MSG_CHECKING([for libstlport.so.1])
+    if test -f "$STLPORT_LIB"; then
+      AC_MSG_RESULT([yes, $STLPORT_LIB])
+      BASIC_FIXUP_PATH([STLPORT_LIB])
+    else
+      AC_MSG_RESULT([no, not found at $STLPORT_LIB])
+      AC_MSG_ERROR([Failed to find libstlport.so.1, cannot build Hotspot gtests])
+    fi
+    AC_SUBST(STLPORT_LIB)
+  fi
+])
+
--- a/common/autoconf/platform.m4	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/autoconf/platform.m4	Tue Jun 07 09:11:32 2016 +0000
@@ -366,6 +366,23 @@
   fi
   AC_SUBST(OPENJDK_$1_OS_EXPORT_DIR)
 
+  # The new version string in JDK 9 also defined new naming of OS and ARCH for bundles
+  # Macosx is osx and x86_64 is x64
+  if test "x$OPENJDK_$1_OS" = xmacosx; then
+    OPENJDK_$1_OS_BUNDLE="osx"
+  else
+    OPENJDK_$1_OS_BUNDLE="$OPENJDK_TARGET_OS"
+  fi
+  if test "x$OPENJDK_$1_CPU" = xx86_64; then
+    OPENJDK_$1_CPU_BUNDLE="x64"
+  else
+    OPENJDK_$1_CPU_BUNDLE="$OPENJDK_$1_CPU"
+  fi
+  OPENJDK_$1_BUNDLE_PLATFORM="${OPENJDK_$1_OS_BUNDLE}-${OPENJDK_$1_CPU_BUNDLE}"
+  AC_SUBST(OPENJDK_$1_OS_BUNDLE)
+  AC_SUBST(OPENJDK_$1_CPU_BUNDLE)
+  AC_SUBST(OPENJDK_$1_BUNDLE_PLATFORM)
+
   if test "x$OPENJDK_$1_CPU_BITS" = x64; then
     A_LP64="LP64:="
     # -D_LP64=1 is only set on linux and mac. Setting on windows causes diff in
--- a/common/autoconf/spec.gmk.in	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/autoconf/spec.gmk.in	Tue Jun 07 09:11:32 2016 +0000
@@ -89,6 +89,10 @@
 HOTSPOT_TARGET_CPU_ARCH := @HOTSPOT_TARGET_CPU_ARCH@
 HOTSPOT_TARGET_CPU_DEFINE := @HOTSPOT_TARGET_CPU_DEFINE@
 
+OPENJDK_TARGET_CPU_BUNDLE:=@OPENJDK_TARGET_CPU_BUNDLE@
+OPENJDK_TARGET_OS_BUNDLE:=@OPENJDK_TARGET_OS_BUNDLE@
+OPENJDK_TARGET_BUNDLE_PLATFORM:=@OPENJDK_TARGET_BUNDLE_PLATFORM@
+
 # We are building on this build system.
 # When not cross-compiling, it is the same as the target.
 OPENJDK_BUILD_OS:=@OPENJDK_BUILD_OS@
@@ -232,6 +236,9 @@
 VALID_JVM_FEATURES := @VALID_JVM_FEATURES@
 VALID_JVM_VARIANTS := @VALID_JVM_VARIANTS@
 
+# Control wether Hotspot builds gtest tests
+BUILD_GTEST := @BUILD_GTEST@
+
 # Control use of precompiled header in hotspot libjvm build
 USE_PRECOMPILED_HEADER := @USE_PRECOMPILED_HEADER@
 
@@ -265,6 +272,7 @@
 HOTSPOT_OUTPUTDIR=$(BUILD_OUTPUT)/hotspot
 JDK_OUTPUTDIR=$(BUILD_OUTPUT)/jdk
 IMAGES_OUTPUTDIR=$(BUILD_OUTPUT)/images
+BUNDLES_OUTPUTDIR=$(BUILD_OUTPUT)/bundles
 TESTMAKE_OUTPUTDIR=$(BUILD_OUTPUT)/test-make
 MAKESUPPORT_OUTPUTDIR=$(BUILD_OUTPUT)/make-support
 # This does not get overridden in a bootcycle build
@@ -277,6 +285,8 @@
 
 BUILD_FAILURE_HANDLER := @BUILD_FAILURE_HANDLER@
 
+ENABLE_GENERATE_CLASSLIST := @ENABLE_GENERATE_CLASSLIST@
+
 # The boot jdk to use. This is overridden in bootcycle-spec.gmk. Make sure to keep
 # it in sync.
 BOOT_JDK:=@BOOT_JDK@
@@ -629,6 +639,7 @@
 EGREP:=@EGREP@
 FGREP:=@FGREP@
 GREP:=@GREP@
+GZIP:=@GZIP@
 HEAD:=@HEAD@
 LS:=@LS@
 LN:=@LN@
@@ -676,6 +687,9 @@
 DTRACE := @DTRACE@
 FIXPATH:=@FIXPATH@
 
+TAR_INCLUDE_PARAM:=@TAR_INCLUDE_PARAM@
+TAR_SUPPORTS_TRANSFORM:=@TAR_SUPPORTS_TRANSFORM@
+
 # Build setup
 ENABLE_JFR=@ENABLE_JFR@
 ENABLE_INTREE_EC=@ENABLE_INTREE_EC@
@@ -685,6 +699,7 @@
 LIBZIP_CAN_USE_MMAP:=@LIBZIP_CAN_USE_MMAP@
 MSVCR_DLL:=@MSVCR_DLL@
 MSVCP_DLL:=@MSVCP_DLL@
+STLPORT_LIB:=@STLPORT_LIB@
 
 ####################################################
 #
@@ -781,11 +796,46 @@
 # Interim image
 INTERIM_IMAGE_DIR := $(SUPPORT_OUTPUTDIR)/interim-image
 
+# Docs image
+DOCS_IMAGE_SUBDIR := docs
+DOCS_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/$(DOCS_IMAGE_SUBDIR)
+
 # Macosx bundles directory definitions
-JDK_MACOSX_BUNDLE_SUBDIR=jdk-bundle/jdk-$(VERSION_NUMBER).jdk/Contents
-JRE_MACOSX_BUNDLE_SUBDIR=jre-bundle/jre-$(VERSION_NUMBER).jre/Contents
+JDK_MACOSX_BUNDLE_SUBDIR=jdk-bundle
+JRE_MACOSX_BUNDLE_SUBDIR=jre-bundle
 JDK_MACOSX_BUNDLE_DIR=$(IMAGES_OUTPUTDIR)/$(JDK_MACOSX_BUNDLE_SUBDIR)
 JRE_MACOSX_BUNDLE_DIR=$(IMAGES_OUTPUTDIR)/$(JRE_MACOSX_BUNDLE_SUBDIR)
+JDK_MACOSX_CONTENTS_SUBDIR=jdk-$(VERSION_NUMBER).jdk/Contents
+JRE_MACOSX_CONTENTS_SUBDIR=jre-$(VERSION_NUMBER).jre/Contents
+JDK_MACOSX_CONTENTS_DIR=$(JDK_MACOSX_BUNDLE_DIR)/$(JDK_MACOSX_CONTENTS_SUBDIR)
+JRE_MACOSX_CONTENTS_DIR=$(JRE_MACOSX_BUNDLE_DIR)/$(JRE_MACOSX_CONTENTS_SUBDIR)
+
+# Bundle names
+BASE_NAME := $(VERSION_SHORT)+$(VERSION_BUILD)_$(OPENJDK_TARGET_BUNDLE_PLATFORM)
+ifeq ($(DEBUG_LEVEL), fastdebug)
+  DEBUG_PART := -debug
+else ifneq ($(DEBUG_LEVEL), release)
+  DEBUG_PART := -$(DEBUG_LEVEL)
+endif
+JDK_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz
+JRE_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART).tar.gz
+JDK_SYMBOLS_BUNDLE_NAME := jdk-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz
+JRE_SYMBOLS_BUNDLE_NAME := jre-$(BASE_NAME)_bin$(DEBUG_PART)-symbols.tar.gz
+ifeq ($(OPENJDK_TARGET_OS), windows)
+  DEMOS_BUNDLE_NAME := jdk-$(BASE_NAME)_demo$(DEBUG_PART).zip
+else
+  DEMOS_BUNDLE_NAME := jdk-$(BASE_NAME)_demo$(DEBUG_PART).tar.gz
+endif
+TEST_BUNDLE_NAME := jdk-$(BASE_NAME)_bin-tests$(DEBUG_PART).tar.gz
+DOCS_BUNDLE_NAME := jdk-$(BASE_NAME)_doc-api-spec$(DEBUG_PART).tar.gz
+
+JDK_BUNDLE := $(BUNDLES_OUTPUTDIR)/$(JDK_BUNDLE_NAME)
+JRE_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(JRE_BUNDLE_NAME)
+JDK_SYMBOLS_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(JDK_SYMBOLS_BUNDLE_NAME)
+JRE_SYMBOLS_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(JRE_SYMBOLS_BUNDLE_NAME)
+DEMOS_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(DEMOS_BUNDLE_NAME)
+TEST_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(TEST_BUNDLE_NAME)
+DOCS_BUNDLE :=  $(BUNDLES_OUTPUTDIR)/$(DOCS_BUNDLE_NAME)
 
 # This macro is called to allow inclusion of closed source counterparts.
 # Unless overridden in closed sources, it expands to nothing.
--- a/common/bin/compare.sh	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/bin/compare.sh	Tue Jun 07 09:11:32 2016 +0000
@@ -274,14 +274,19 @@
 
     $MKDIR -p $WORK_DIR
 
+    FILE_TYPES_FILTER="$SED \
+        -e 's/BuildID[^,]*//' \
+        -e 's/last modified: .*//' \
+        "
+
     echo -n File types...
     found=""
     for f in `cd $OTHER_DIR && $FIND . ! -type d`
     do
         if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
         if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
-        OF=`cd ${OTHER_DIR} && $FILE -h $f | $SED 's/BuildID[^,]*//g'`
-        TF=`cd ${THIS_DIR} && $FILE -h $f | $SED 's/BuildID[^,]*//g'`
+        OF=$(cd ${OTHER_DIR} && $FILE -h $f | eval $FILE_TYPES_FILTER)
+        TF=$(cd ${THIS_DIR} && $FILE -h $f | eval $FILE_TYPES_FILTER)
         if [ "$OF" != "$TF" ]
         then
             if [ "`echo $OF | $GREP -c 'Zip archive data'`" -gt 0 ] \
@@ -320,7 +325,7 @@
         ! -name "*.obj" ! -name "*.o" ! -name "JavaControlPanelHelper" \
         ! -name "JavaUpdater" ! -name "JavaWSApplicationStub" \
         ! -name "jspawnhelper" ! -name "JavawsLauncher" ! -name "*.a" \
-        ! -name "finish_installation" ! -name "Sparkle" \
+        ! -name "finish_installation" ! -name "Sparkle" ! -name "*.tar.gz" \
         | $GREP -v "./bin/"  | $SORT | $FILTER)
 
     echo Other files with binary differences...
@@ -423,6 +428,10 @@
     then
         (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP)
         (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP)
+    elif [ "$TYPE" = "gz" ]
+    then
+        (cd $THIS_UNZIPDIR && $GUNZIP -c $THIS_ZIP | $TAR xf -)
+        (cd $OTHER_UNZIPDIR && $GUNZIP -c $OTHER_ZIP | $TAR xf -)
     else
         (cd $THIS_UNZIPDIR && $JIMAGE extract $THIS_ZIP)
         (cd $OTHER_UNZIPDIR && $JIMAGE extract $OTHER_ZIP)
@@ -526,10 +535,11 @@
     OTHER_DIR=$2
     WORK_DIR=$3
 
-    ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" | $SORT | $FILTER )
+    ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" -o -name "*.tar.gz" \
+        | $SORT | $FILTER )
 
     if [ -n "$ZIPS" ]; then
-        echo Zip files...
+        echo Zip/tar.gz files...
 
         return_value=0
         for f in $ZIPS; do
@@ -913,7 +923,7 @@
             FULLDUMP_MSG="          "
             DIFF_FULLDUMP=
             if [[ "$KNOWN_FULLDUMP_DIFF $ACCEPTED_FULLDUMP_DIFF" = *"$BIN_FILE"* ]]; then
-                FULLDUMP_MSG="    !     "
+                FULLDUMP_MSG="    !    "
             fi
         fi
     fi
--- a/common/bin/idea.sh	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/bin/idea.sh	Tue Jun 07 09:11:32 2016 +0000
@@ -155,6 +155,14 @@
   printf "%s\n" "$mn" >> $IDEA_ANT
 }
 
+JTREG_HOME="        <property name=\"jtreg.home\" value=\"####\" />"
+
+addJtregHome() {
+  DIR=`dirname $SPEC`
+  mn="`echo "$JTREG_HOME" | sed -e s@"\(.*\)####\(.*\)"@"\1$JT_HOME\2"@`"
+  printf "%s\n" "$mn" >> $IDEA_ANT
+}
+
 ### Generate ant.xml
 
 rm -f $IDEA_ANT
@@ -162,6 +170,8 @@
 do
   if echo "$line" | egrep "^ .* <property name=\"module.name\"" > /dev/null ; then
     addModuleName
+  elif echo "$line" | egrep "^ .* <property name=\"jtreg.home\"" > /dev/null ; then
+    addJtregHome
   elif echo "$line" | egrep "^ .* <property name=\"build.target.dir\"" > /dev/null ; then
     addBuildDir
   else
--- a/common/conf/jib-profiles.js	Mon Jun 06 23:24:46 2016 -0700
+++ b/common/conf/jib-profiles.js	Tue Jun 07 09:11:32 2016 +0000
@@ -215,11 +215,11 @@
     var common = {};
 
     common.dependencies = ["boot_jdk", "gnumake", "jtreg"],
-    common.default_make_targets = ["product-images", "test-image"],
+    common.default_make_targets = ["product-bundles", "test-bundles"],
     common.default_make_targets_debug = common.default_make_targets;
     common.default_make_targets_slowdebug = common.default_make_targets;
     common.configure_args = ["--enable-jtreg-failure-handler"],
-    common.configure_args_32bit = ["--with-target-bits=32", "--with-jvm-variants=client,server"],
+    common.configure_args_32bit = ["--with-target-bits=32"],
     common.configure_args_debug = ["--enable-debug"],
     common.configure_args_slowdebug = ["--with-debug-level=slowdebug"],
     common.organization = "jpg.infra.builddeps"
@@ -245,7 +245,7 @@
             target_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit"),
             configure_args: concat(common.configure_args, "--with-zlib=system"),
-            default_make_targets: concat(common.default_make_targets, "docs-image")
+            default_make_targets: concat(common.default_make_targets, "docs-bundles")
         },
 
         "linux-x86": {
@@ -254,7 +254,7 @@
             build_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit"),
             configure_args: concat(common.configure_args, common.configure_args_32bit,
-                "--with-zlib=system"),
+                "--with-jvm-variants=minimal,client,server", "--with-zlib=system"),
             default_make_targets: common.default_make_targets
         },
 
@@ -295,7 +295,8 @@
             target_cpu: "x86",
             build_cpu: "x64",
             dependencies: concat(common.dependencies, "devkit", "freetype"),
-            configure_args: concat(common.configure_args, common.configure_args_32bit),
+            configure_args: concat(common.configure_args,
+                "--with-jvm-variants=client,server", common.configure_args_32bit),
             default_make_targets: common.default_make_targets
         }
     };
--- a/corba/.hgtags	Mon Jun 06 23:24:46 2016 -0700
+++ b/corba/.hgtags	Tue Jun 07 09:11:32 2016 +0000
@@ -361,3 +361,5 @@
 7dfa7377a5e601b8f740741a9a80e04c72dd04d6 jdk-9+116
 7a1b36bf2fe55a9a7732489ccdd326c910329a7e jdk-9+117
 8c2c2d17f7ce92a31c9ccb44a122ec62f5a85ace jdk-9+118
+daf533920b1266603b5cbdab31908d2a931c5361 jdk-9+119
+5943b791e131e79b969d4cea053aecda34801723 jdk-9+120
--- a/hotspot/.hgtags	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/.hgtags	Tue Jun 07 09:11:32 2016 +0000
@@ -522,3 +522,4 @@
 88170d3642905b9e6cac03e8efcc976885a7e6da jdk-9+117
 9b1075cac08dc836ec32e7b368415cbe3aceaf8c jdk-9+118
 15f3fe264872766bcb205696198f0c1502420e17 jdk-9+119
+0be6f4f5d18671184e62583668cb1d783dffa128 jdk-9+120
--- a/hotspot/LICENSE	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/LICENSE	Tue Jun 07 09:11:32 2016 +0000
@@ -3,7 +3,7 @@
 Version 2, June 1991
 
 Copyright (C) 1989, 1991 Free Software Foundation, Inc.
-59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
 Everyone is permitted to copy and distribute verbatim copies of this license
 document, but changing it is not allowed.
@@ -287,8 +287,8 @@
     more details.
 
     You should have received a copy of the GNU General Public License along
-    with this program; if not, write to the Free Software Foundation, Inc., 59
-    Temple Place, Suite 330, Boston, MA 02111-1307 USA
+    with this program; if not, write to the Free Software Foundation, Inc.,
+    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 Also add information on how to contact you by electronic and paper mail.
 
--- a/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016 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
@@ -1547,6 +1547,10 @@
   inline void ld(   Register d, int si16,    Register s1);
   inline void ldu(  Register d, int si16,    Register s1);
 
+  // For convenience. Load pointer into d from b+s1.
+  inline void ld_ptr(Register d, int b, Register s1);
+  DEBUG_ONLY(inline void ld_ptr(Register d, ByteSize b, Register s1);)
+
   //  PPC 1, section 3.3.3 Fixed-Point Store Instructions
   inline void stwx( Register d, Register s1, Register s2);
   inline void stw(  Register d, int si16,    Register s1);
@@ -2215,7 +2219,8 @@
   void add( Register d, RegisterOrConstant roc, Register s1);
   void subf(Register d, RegisterOrConstant roc, Register s1);
   void cmpd(ConditionRegister d, RegisterOrConstant roc, Register s1);
-
+  // Load pointer d from s1+roc.
+  void ld_ptr(Register d, RegisterOrConstant roc, Register s1 = noreg) { ld(d, roc, s1); }
 
   // Emit several instructions to load a 64 bit constant. This issues a fixed
   // instruction pattern so that the constant can be patched later on.
--- a/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/assembler_ppc.inline.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
+ * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016 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
@@ -328,6 +328,9 @@
 inline void Assembler::ldx(  Register d, Register s1, Register s2) { emit_int32(LDX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));}
 inline void Assembler::ldu(  Register d, int si16,    Register s1) { assert(d != s1, "according to ibm manual"); emit_int32(LDU_OPCODE | rt(d) | ds(si16) | rta0mem(s1));}
 
+inline void Assembler::ld_ptr(Register d, int b, Register s1) { ld(d, b, s1); }
+DEBUG_ONLY(inline void Assembler::ld_ptr(Register d, ByteSize b, Register s1) { ld(d, in_bytes(b), s1); })
+
 //  PPC 1, section 3.3.3 Fixed-Point Store Instructions
 inline void Assembler::stwx( Register d, Register s1, Register s2) { emit_int32(STWX_OPCODE | rs(d) | ra0mem(s1) | rb(s2));}
 inline void Assembler::stw(  Register d, int si16,    Register s1) { emit_int32(STW_OPCODE  | rs(d) | d1(si16)   | ra0mem(s1));}
--- a/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/c1_LIRAssembler_ppc.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
+ * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016 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
@@ -1242,7 +1242,7 @@
 
 
 void LIR_Assembler::return_op(LIR_Opr result) {
-  const Register return_pc        = R11;
+  const Register return_pc        = R31;  // Must survive C-call to enable_stack_reserved_zone().
   const Register polling_page     = R12;
 
   // Pop the stack before the safepoint code.
@@ -1265,6 +1265,10 @@
   // Move return pc to LR.
   __ mtlr(return_pc);
 
+  if (StackReservedPages > 0 && compilation()->has_reserved_stack_access()) {
+    __ reserved_stack_check(return_pc);
+  }
+
   // We need to mark the code position where the load from the safepoint
   // polling page was emitted as relocInfo::poll_return_type here.
   __ relocate(relocInfo::poll_return_type);
--- a/hotspot/src/cpu/ppc/vm/globalDefinitions_ppc.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/globalDefinitions_ppc.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,6 +1,6 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
+ * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2016 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
@@ -52,4 +52,6 @@
 #define INCLUDE_RTM_OPT 1
 #endif
 
+#define SUPPORT_RESERVED_STACK_AREA
+
 #endif // CPU_PPC_VM_GLOBALDEFINITIONS_PPC_HPP
--- a/hotspot/src/cpu/ppc/vm/globals_ppc.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/globals_ppc.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -43,7 +43,7 @@
 #define DEFAULT_STACK_YELLOW_PAGES (6)
 #define DEFAULT_STACK_RED_PAGES (1)
 #define DEFAULT_STACK_SHADOW_PAGES (6 DEBUG_ONLY(+2))
-#define DEFAULT_STACK_RESERVED_PAGES (0)
+#define DEFAULT_STACK_RESERVED_PAGES (1)
 
 #define MIN_STACK_YELLOW_PAGES DEFAULT_STACK_YELLOW_PAGES
 #define MIN_STACK_RED_PAGES DEFAULT_STACK_RED_PAGES
--- a/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/interp_masm_ppc_64.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
+ * Copyright (c) 2012, 2016 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
@@ -480,6 +480,7 @@
 
 void InterpreterMacroAssembler::generate_stack_overflow_check_with_compare_and_throw(Register Rmem_frame_size, Register Rscratch1) {
   Label done;
+  BLOCK_COMMENT("stack_overflow_check_with_compare_and_throw {");
   sub(Rmem_frame_size, R1_SP, Rmem_frame_size);
   ld(Rscratch1, thread_(stack_overflow_limit));
   cmpld(CCR0/*is_stack_overflow*/, Rmem_frame_size, Rscratch1);
@@ -501,6 +502,7 @@
 
   align(32, 12);
   bind(done);
+  BLOCK_COMMENT("} stack_overflow_check_with_compare_and_throw");
 }
 
 // Separate these two to allow for delay slot in middle.
@@ -805,16 +807,41 @@
 void InterpreterMacroAssembler::remove_activation(TosState state,
                                                   bool throw_monitor_exception,
                                                   bool install_monitor_exception) {
+  BLOCK_COMMENT("remove_activation {");
   unlock_if_synchronized_method(state, throw_monitor_exception, install_monitor_exception);
 
   // Save result (push state before jvmti call and pop it afterwards) and notify jvmti.
   notify_method_exit(false, state, NotifyJVMTI, true);
 
+  BLOCK_COMMENT("reserved_stack_check:");
+  if (StackReservedPages > 0) {
+    // Test if reserved zone needs to be enabled.
+    Label no_reserved_zone_enabling;
+
+    // Compare frame pointers. There is no good stack pointer, as with stack
+    // frame compression we can get different SPs when we do calls. A subsequent
+    // call could have a smaller SP, so that this compare succeeds for an
+    // inner call of the method annotated with ReservedStack.
+    ld_ptr(R0, JavaThread::reserved_stack_activation_offset(), R16_thread);
+    ld_ptr(R11_scratch1, _abi(callers_sp), R1_SP); // Load frame pointer.
+    cmpld(CCR0, R11_scratch1, R0);
+    blt_predict_taken(CCR0, no_reserved_zone_enabling);
+
+    // Enable reserved zone again, throw stack overflow exception.
+    call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), R16_thread);
+    call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_delayed_StackOverflowError));
+
+    should_not_reach_here();
+
+    bind(no_reserved_zone_enabling);
+  }
+
   verify_oop(R17_tos, state);
   verify_thread();
 
   merge_frames(/*top_frame_sp*/ R21_sender_SP, /*return_pc*/ R0, R11_scratch1, R12_scratch2);
   mtlr(R0);
+  BLOCK_COMMENT("} remove_activation");
 }
 
 // Lock object
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1400,6 +1400,28 @@
 #endif
 }
 
+void MacroAssembler::reserved_stack_check(Register return_pc) {
+  // Test if reserved zone needs to be enabled.
+  Label no_reserved_zone_enabling;
+
+  ld_ptr(R0, JavaThread::reserved_stack_activation_offset(), R16_thread);
+  cmpld(CCR0, R1_SP, R0);
+  blt_predict_taken(CCR0, no_reserved_zone_enabling);
+
+  // Enable reserved zone again, throw stack overflow exception.
+  push_frame_reg_args(0, R0);
+  call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::enable_stack_reserved_zone), R16_thread);
+  pop_frame();
+  mtlr(return_pc);
+  load_const_optimized(R0, StubRoutines::throw_delayed_StackOverflowError_entry());
+  mtctr(R0);
+  bctr();
+
+  should_not_reach_here();
+
+  bind(no_reserved_zone_enabling);
+}
+
 // CmpxchgX sets condition register to cmpX(current, compare).
 void MacroAssembler::cmpxchgw(ConditionRegister flag, Register dest_current_value,
                               Register compare_value, Register exchange_value,
--- a/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/macroAssembler_ppc.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -411,6 +411,10 @@
   // stdux, return the banged address. Otherwise, return 0.
   static address get_stack_bang_address(int instruction, void* ucontext);
 
+  // Check for reserved stack access in method being exited. If the reserved
+  // stack area was accessed, protect it again and throw StackOverflowError.
+  void reserved_stack_check(Register return_pc);
+
   // Atomics
   // CmpxchgX sets condition register to cmpX(current, compare).
   // (flag == ne) => (dest_current_value != compare_value), (!swapped)
--- a/hotspot/src/cpu/ppc/vm/ppc.ad	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/ppc.ad	Tue Jun 07 09:11:32 2016 +0000
@@ -1432,7 +1432,7 @@
 
   const bool method_needs_polling = do_polling() && C->is_method_compilation();
   const bool method_is_frameless  = false /* TODO: PPC port C->is_frameless_method()*/;
-  const Register return_pc        = R11;
+  const Register return_pc        = R31;  // Must survive C-call to enable_stack_reserved_zone().
   const Register polling_page     = R12;
 
   if (!method_is_frameless) {
@@ -1456,6 +1456,10 @@
     __ addi(R1_SP, R1_SP, (int)framesize);
   }
 
+  if (StackReservedPages > 0 && C->has_reserved_stack_access()) {
+    __ reserved_stack_check(return_pc);
+  }
+
   if (method_needs_polling) {
     // We need to mark the code position where the load from the safepoint
     // polling page was emitted as relocInfo::poll_return_type here.
--- a/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/stubGenerator_ppc.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -3123,6 +3123,9 @@
     StubRoutines::_throw_StackOverflowError_entry   =
       generate_throw_exception("StackOverflowError throw_exception",
                                CAST_FROM_FN_PTR(address, SharedRuntime::throw_StackOverflowError), false);
+    StubRoutines::_throw_delayed_StackOverflowError_entry =
+      generate_throw_exception("delayed StackOverflowError throw_exception",
+                               CAST_FROM_FN_PTR(address, SharedRuntime::throw_delayed_StackOverflowError), false);
 
     // CRC32 Intrinsics.
     if (UseCRC32Intrinsics) {
--- a/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/cpu/ppc/vm/templateInterpreterGenerator_ppc.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2015 SAP SE. All rights reserved.
+ * Copyright (c) 2015, 2016 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
@@ -562,10 +562,16 @@
   return NULL;
 }
 
-// Actually we should never reach here since we do stack overflow checks before pushing any frame.
 address TemplateInterpreterGenerator::generate_StackOverflowError_handler() {
   address entry = __ pc();
-  __ unimplemented("generate_StackOverflowError_handler");
+
+  // Expression stack must be empty before entering the VM if an
+  // exception happened.
+  __ empty_expression_stack();
+  // Throw exception.
+  __ call_VM(noreg,
+             CAST_FROM_FN_PTR(address,
+                              InterpreterRuntime::throw_StackOverflowError));
   return entry;
 }
 
@@ -944,7 +950,7 @@
 // The top most frame needs an abi space of 112 bytes. This space is needed,
 // since we call to c. The c function may spill their arguments to the caller
 // frame. When we call to java, we don't need these spill slots. In order to save
-// space on the stack, we resize the caller. However, java local reside in
+// space on the stack, we resize the caller. However, java locals reside in
 // the caller frame and the frame has to be increased. The frame_size for the
 // current frame was calculated based on max_stack as size for the expression
 // stack. At the call, just a part of the expression stack might be used.
@@ -1007,7 +1013,7 @@
   // parent_frame_resize = (locals-parameters) - (ESP-SP-ABI48) Rounded to frame alignment size.
   // Enlarge by locals-parameters (not in case of native_call), shrink by ESP-SP-ABI48.
 
-  {
+  if (!native_call) {
     // --------------------------------------------------------------------------
     // Stack overflow check
 
@@ -1047,7 +1053,7 @@
   __ addi(R26_monitor, R1_SP, - frame::ijava_state_size);
   __ addi(R15_esp, R26_monitor, - Interpreter::stackElementSize);
 
-  // Get mirror and store it in the frame as GC root for this Method*
+  // Get mirror and store it in the frame as GC root for this Method*.
   __ load_mirror(R12_scratch2, R19_method);
 
   // Store values.
@@ -1133,6 +1139,29 @@
   return entry;
 }
 
+void TemplateInterpreterGenerator::bang_stack_shadow_pages(bool native_call) {
+  // Quick & dirty stack overflow checking: bang the stack & handle trap.
+  // Note that we do the banging after the frame is setup, since the exception
+  // handling code expects to find a valid interpreter frame on the stack.
+  // Doing the banging earlier fails if the caller frame is not an interpreter
+  // frame.
+  // (Also, the exception throwing code expects to unlock any synchronized
+  // method receiever, so do the banging after locking the receiver.)
+
+  // Bang each page in the shadow zone. We can't assume it's been done for
+  // an interpreter frame with greater than a page of locals, so each page
+  // needs to be checked.  Only true for non-native.
+  if (UseStackBanging) {
+    const int page_size = os::vm_page_size();
+    const int n_shadow_pages = ((int)JavaThread::stack_shadow_zone_size()) / page_size;
+    const int start_page = native_call ? n_shadow_pages : 1;
+    BLOCK_COMMENT("bang_stack_shadow_pages:");
+    for (int pages = start_page; pages <= n_shadow_pages; pages++) {
+      __ bang_stack_with_offset(pages*page_size);
+    }
+  }
+}
+
 // Interpreter stub for calling a native method. (asm interpreter)
 // This sets up a somewhat different looking stack for calling the
 // native method than the typical interpreter frame setup.
@@ -1156,7 +1185,7 @@
   // This is not a full-blown interpreter frame, but in particular, the
   // following registers are valid after this:
   // - R19_method
-  // - R18_local (points to start of argumuments to native function)
+  // - R18_local (points to start of arguments to native function)
   //
   //   abstract stack (grows up)
   //     [  IJava (caller of JNI callee)  ]  <-- ASP
@@ -1207,6 +1236,11 @@
     generate_counter_incr(&invocation_counter_overflow, NULL, NULL);
 
     BIND(continue_after_compile);
+  }
+
+  bang_stack_shadow_pages(true);
+
+  if (inc_counter) {
     // Reset the _do_not_unlock_if_synchronized flag.
     if (synchronized) {
       __ li(R0, 0);
@@ -1595,6 +1629,7 @@
   Register Rsize_of_parameters = R4_ARG2, // Written by generate_fixed_frame.
            Rsize_of_locals     = R5_ARG3; // Written by generate_fixed_frame.
 
+  // Does also a stack check to assure this frame fits on the stack.
   generate_fixed_frame(false, Rsize_of_parameters, Rsize_of_locals);
 
   // --------------------------------------------------------------------------
@@ -1651,7 +1686,11 @@
     }
 
     __ bind(profile_method_continue);
+  }
 
+  bang_stack_shadow_pages(false);
+
+  if (inc_counter || ProfileInterpreter) {
     // Reset the _do_not_unlock_if_synchronized flag.
     if (synchronized) {
       __ li(R0, 0);
--- a/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/CommandProcessor.java	Tue Jun 07 09:11:32 2016 +0000
@@ -1712,7 +1712,8 @@
     // called after debuggee attach
     private void postAttach() {
         // create JavaScript engine and start it
-        jsengine = new JSJavaScriptEngine() {
+        try {
+            jsengine = new JSJavaScriptEngine() {
                         private ObjectReader reader = new ObjectReader();
                         private JSJavaFactory factory = new JSJavaFactoryImpl();
                         public ObjectReader getObjectReader() {
@@ -1735,17 +1736,24 @@
                             return err;
                         }
                    };
-        try {
-            jsengine.defineFunction(this,
+            try {
+                jsengine.defineFunction(this,
                      this.getClass().getMethod("registerCommand",
                                 new Class[] {
                                      String.class, String.class, String.class
                                 }));
-        } catch (NoSuchMethodException exp) {
-            // should not happen, see below...!!
-            exp.printStackTrace();
+            } catch (NoSuchMethodException exp) {
+                  // should not happen, see below...!!
+                  exp.printStackTrace();
+            }
+            jsengine.start();
         }
-        jsengine.start();
+        catch (Exception ex) {
+            System.out.println("Warning! JS Engine can't start, some commands will not be available.");
+            if (verboseExceptions) {
+                ex.printStackTrace(out);
+            }
+        }
     }
 
     public void registerCommand(String cmd, String usage, final String func) {
--- a/hotspot/src/os/aix/vm/os_aix.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/os/aix/vm/os_aix.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2013, 2015 SAP SE. All rights reserved.
+ * Copyright (c) 2013, 2016 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
@@ -128,6 +128,8 @@
   // Set PC into context. Needed for continuation after signal.
   static void ucontext_set_pc(ucontext_t* uc, address pc);
 
+  static bool get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr);
+
   // This boolean allows users to forward their own non-matching signals
   // to JVM_handle_aix_signal, harmlessly.
   static bool signal_handlers_are_installed;
--- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2014 SAP SE. All rights reserved.
+ * Copyright (c) 2012, 2016 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
@@ -24,7 +24,7 @@
  */
 
 // no precompiled headers
-#include "assembler_ppc.inline.hpp"
+#include "asm/assembler.inline.hpp"
 #include "classfile/classLoader.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
@@ -145,6 +145,41 @@
   return fr;
 }
 
+bool os::Aix::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) {
+  address pc = (address) os::Aix::ucontext_get_pc(uc);
+  if (Interpreter::contains(pc)) {
+    // Interpreter performs stack banging after the fixed frame header has
+    // been generated while the compilers perform it before. To maintain
+    // semantic consistency between interpreted and compiled frames, the
+    // method returns the Java sender of the current frame.
+    *fr = os::fetch_frame_from_context(uc);
+    if (!fr->is_first_java_frame()) {
+      assert(fr->safe_for_sender(thread), "Safety check");
+      *fr = fr->java_sender();
+    }
+  } else {
+    // More complex code with compiled code.
+    assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
+    CodeBlob* cb = CodeCache::find_blob(pc);
+    if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
+      // Not sure where the pc points to, fallback to default
+      // stack overflow handling. In compiled code, we bang before
+      // the frame is complete.
+      return false;
+    } else {
+      intptr_t* sp = os::Aix::ucontext_get_sp(uc);
+      *fr = frame(sp, (address)*sp);
+      if (!fr->is_java_frame()) {
+        assert(fr->safe_for_sender(thread), "Safety check");
+        assert(!fr->is_first_frame(), "Safety check");
+        *fr = fr->java_sender();
+      }
+    }
+  }
+  assert(fr->is_java_frame(), "Safety check");
+  return true;
+}
+
 frame os::get_sender_for_C_frame(frame* fr) {
   if (*fr->sp() == NULL) {
     // fr is the last C frame
@@ -246,14 +281,32 @@
       // to continue with yellow zone disabled, but that doesn't buy us much and prevents
       // hs_err_pid files.
       if (thread->in_stack_yellow_reserved_zone(addr)) {
-        thread->disable_stack_yellow_reserved_zone();
         if (thread->thread_state() == _thread_in_Java) {
+            if (thread->in_stack_reserved_zone(addr)) {
+              frame fr;
+              if (os::Aix::get_frame_at_stack_banging_point(thread, uc, &fr)) {
+                assert(fr.is_java_frame(), "Must be a Javac frame");
+                frame activation =
+                  SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
+                if (activation.sp() != NULL) {
+                  thread->disable_stack_reserved_zone();
+                  if (activation.is_interpreted_frame()) {
+                    thread->set_reserved_stack_activation((address)activation.fp());
+                  } else {
+                    thread->set_reserved_stack_activation((address)activation.unextended_sp());
+                  }
+                  return 1;
+                }
+              }
+            }
           // Throw a stack overflow exception.
           // Guard pages will be reenabled while unwinding the stack.
+          thread->disable_stack_yellow_reserved_zone();
           stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
           goto run_stub;
         } else {
           // Thread was in the vm or native code. Return and try to finish.
+          thread->disable_stack_yellow_reserved_zone();
           return 1;
         }
       } else if (thread->in_stack_red_zone(addr)) {
--- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2012, 2015 SAP SE. All rights reserved.
+ * Copyright (c) 2012, 2016 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
@@ -24,7 +24,7 @@
  */
 
 // no precompiled headers
-#include "assembler_ppc.inline.hpp"
+#include "asm/assembler.inline.hpp"
 #include "classfile/classLoader.hpp"
 #include "classfile/systemDictionary.hpp"
 #include "classfile/vmSymbols.hpp"
@@ -157,6 +157,42 @@
   return frame(sp, epc.pc());
 }
 
+bool os::Linux::get_frame_at_stack_banging_point(JavaThread* thread, ucontext_t* uc, frame* fr) {
+  address pc = (address) os::Linux::ucontext_get_pc(uc);
+  if (Interpreter::contains(pc)) {
+    // Interpreter performs stack banging after the fixed frame header has
+    // been generated while the compilers perform it before. To maintain
+    // semantic consistency between interpreted and compiled frames, the
+    // method returns the Java sender of the current frame.
+    *fr = os::fetch_frame_from_context(uc);
+    if (!fr->is_first_java_frame()) {
+      assert(fr->safe_for_sender(thread), "Safety check");
+      *fr = fr->java_sender();
+    }
+  } else {
+    // More complex code with compiled code.
+    assert(!Interpreter::contains(pc), "Interpreted methods should have been handled above");
+    CodeBlob* cb = CodeCache::find_blob(pc);
+    if (cb == NULL || !cb->is_nmethod() || cb->is_frame_complete_at(pc)) {
+      // Not sure where the pc points to, fallback to default
+      // stack overflow handling. In compiled code, we bang before
+      // the frame is complete.
+      return false;
+    } else {
+      intptr_t* fp = os::Linux::ucontext_get_fp(uc);
+      intptr_t* sp = os::Linux::ucontext_get_sp(uc);
+      *fr = frame(sp, (address)*sp);
+      if (!fr->is_java_frame()) {
+        assert(fr->safe_for_sender(thread), "Safety check");
+        assert(!fr->is_first_frame(), "Safety check");
+        *fr = fr->java_sender();
+      }
+    }
+  }
+  assert(fr->is_java_frame(), "Safety check");
+  return true;
+}
+
 frame os::get_sender_for_C_frame(frame* fr) {
   if (*fr->sp() == 0) {
     // fr is the last C frame
@@ -243,13 +279,31 @@
       if (thread->on_local_stack(addr)) {
         // stack overflow
         if (thread->in_stack_yellow_reserved_zone(addr)) {
-          thread->disable_stack_yellow_reserved_zone();
           if (thread->thread_state() == _thread_in_Java) {
+            if (thread->in_stack_reserved_zone(addr)) {
+              frame fr;
+              if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) {
+                assert(fr.is_java_frame(), "Must be a Javac frame");
+                frame activation =
+                  SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
+                if (activation.sp() != NULL) {
+                  thread->disable_stack_reserved_zone();
+                  if (activation.is_interpreted_frame()) {
+                    thread->set_reserved_stack_activation((address)activation.fp());
+                  } else {
+                    thread->set_reserved_stack_activation((address)activation.unextended_sp());
+                  }
+                  return 1;
+                }
+              }
+            }
             // Throw a stack overflow exception.
             // Guard pages will be reenabled while unwinding the stack.
+            thread->disable_stack_yellow_reserved_zone();
             stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW);
           } else {
             // Thread was in the vm or native code. Return and try to finish.
+            thread->disable_stack_yellow_reserved_zone();
             return 1;
           }
         } else if (thread->in_stack_red_zone(addr)) {
--- a/hotspot/src/share/vm/ci/ciEnv.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/ci/ciEnv.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -704,13 +704,14 @@
                                InstanceKlass*  holder,
                                Symbol*       name,
                                Symbol*       sig,
-                               Bytecodes::Code bc) {
+                               Bytecodes::Code bc,
+                               constantTag    tag) {
   EXCEPTION_CONTEXT;
   KlassHandle h_accessor(THREAD, accessor);
   KlassHandle h_holder(THREAD, holder);
   LinkResolver::check_klass_accessability(h_accessor, h_holder, KILL_COMPILE_ON_FATAL_(NULL));
   methodHandle dest_method;
-  LinkInfo link_info(h_holder, name, sig, h_accessor, /*check_access*/true);
+  LinkInfo link_info(h_holder, name, sig, h_accessor, LinkInfo::needs_access_check, tag);
   switch (bc) {
   case Bytecodes::_invokestatic:
     dest_method =
@@ -796,7 +797,9 @@
 
     if (holder_is_accessible) {  // Our declared holder is loaded.
       InstanceKlass* lookup = declared_holder->get_instanceKlass();
-      Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc);
+      constantTag tag = cpool->tag_ref_at(index);
+      assert(accessor->get_instanceKlass() == cpool->pool_holder(), "not the pool holder?");
+      Method* m = lookup_method(accessor->get_instanceKlass(), lookup, name_sym, sig_sym, bc, tag);
       if (m != NULL &&
           (bc == Bytecodes::_invokestatic
            ?  m->method_holder()->is_not_initialized()
--- a/hotspot/src/share/vm/ci/ciEnv.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/ci/ciEnv.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -156,7 +156,8 @@
                            InstanceKlass*  holder,
                            Symbol*         name,
                            Symbol*         sig,
-                           Bytecodes::Code bc);
+                           Bytecodes::Code bc,
+                           constantTag     tag);
 
   // Get a ciObject from the object factory.  Ensures uniqueness
   // of ciObjects.
--- a/hotspot/src/share/vm/ci/ciMethod.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/ci/ciMethod.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -789,7 +789,8 @@
    Symbol* h_name      = name()->get_symbol();
    Symbol* h_signature = signature()->get_symbol();
 
-   LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass, check_access);
+   LinkInfo link_info(h_resolved, h_name, h_signature, caller_klass,
+                      check_access ? LinkInfo::needs_access_check : LinkInfo::skip_access_check);
    methodHandle m;
    // Only do exact lookup if receiver klass has been linked.  Otherwise,
    // the vtable has not been setup, and the LinkResolver will fail.
--- a/hotspot/src/share/vm/classfile/classLoader.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/classLoader.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -657,7 +657,7 @@
   int num_of_entries = xpatch_args->length();
 
   // Set up the boot loader's xpatch_entries list
-  _xpatch_entries = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
+  _xpatch_entries = new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleClassPathList*>(num_of_entries, true);
 
   for (int i = 0; i < num_of_entries; i++) {
     const char* module_name = (xpatch_args->at(i))->module_name();
@@ -1069,9 +1069,9 @@
   char* begin_ptr = char_buf;
   char* end_ptr = strchr(begin_ptr, '\n');
   bool process_boot_modules = false;
-  _boot_modules_array = new (ResourceObj::C_HEAP, mtInternal)
+  _boot_modules_array = new (ResourceObj::C_HEAP, mtModule)
     GrowableArray<char*>(INITIAL_BOOT_MODULES_ARRAY_SIZE, true);
-  _platform_modules_array = new (ResourceObj::C_HEAP, mtInternal)
+  _platform_modules_array = new (ResourceObj::C_HEAP, mtModule)
     GrowableArray<char*>(INITIAL_PLATFORM_MODULES_ARRAY_SIZE, true);
   while (end_ptr != NULL && (end_ptr - char_buf) < buflen) {
     // Allocate a buffer from the C heap to be appended to the _boot_modules_array
--- a/hotspot/src/share/vm/classfile/classLoaderData.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -67,6 +67,7 @@
 #include "runtime/javaCalls.hpp"
 #include "runtime/jniHandles.hpp"
 #include "runtime/mutex.hpp"
+#include "runtime/orderAccess.hpp"
 #include "runtime/safepoint.hpp"
 #include "runtime/synchronizer.hpp"
 #include "utilities/growableArray.hpp"
@@ -76,6 +77,11 @@
 #include "trace/tracing.hpp"
 #endif
 
+// helper function to avoid in-line casts
+template <typename T> static T* load_ptr_acquire(T* volatile *p) {
+  return static_cast<T*>(OrderAccess::load_ptr_acquire(p));
+}
+
 ClassLoaderData * ClassLoaderData::_the_null_class_loader_data = NULL;
 
 ClassLoaderData::ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies) :
@@ -147,20 +153,23 @@
 }
 
 void ClassLoaderData::classes_do(KlassClosure* klass_closure) {
-  for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
+  // Lock-free access requires load_ptr_acquire
+  for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
     klass_closure->do_klass(k);
     assert(k != k->next_link(), "no loops!");
   }
 }
 
 void ClassLoaderData::classes_do(void f(Klass * const)) {
+  assert_locked_or_safepoint(_metaspace_lock);
   for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
     f(k);
   }
 }
 
 void ClassLoaderData::methods_do(void f(Method*)) {
-  for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
+  // Lock-free access requires load_ptr_acquire
+  for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
     if (k->is_instance_klass()) {
       InstanceKlass::cast(k)->methods_do(f);
     }
@@ -179,7 +188,8 @@
 }
 
 void ClassLoaderData::classes_do(void f(InstanceKlass*)) {
-  for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
+  // Lock-free access requires load_ptr_acquire
+  for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
     if (k->is_instance_klass()) {
       f(InstanceKlass::cast(k));
     }
@@ -188,6 +198,7 @@
 }
 
 void ClassLoaderData::modules_do(void f(ModuleEntry*)) {
+  assert_locked_or_safepoint(Module_lock);
   if (_modules != NULL) {
     for (int i = 0; i < _modules->table_size(); i++) {
       for (ModuleEntry* entry = _modules->bucket(i);
@@ -200,9 +211,11 @@
 }
 
 void ClassLoaderData::packages_do(void f(PackageEntry*)) {
-  if (_packages != NULL) {
-    for (int i = 0; i < _packages->table_size(); i++) {
-      for (PackageEntry* entry = _packages->bucket(i);
+  // Lock-free access requires load_ptr_acquire
+  PackageEntryTable* packages = load_ptr_acquire(&_packages);
+  if (packages != NULL) {
+    for (int i = 0; i < packages->table_size(); i++) {
+      for (PackageEntry* entry = packages->bucket(i);
                               entry != NULL;
                               entry = entry->next()) {
         f(entry);
@@ -325,10 +338,9 @@
     MutexLockerEx ml(metaspace_lock(), Mutex::_no_safepoint_check_flag);
     Klass* old_value = _klasses;
     k->set_next_link(old_value);
-    // Make sure linked class is stable, since the class list is walked without a lock
-    OrderAccess::storestore();
-    // link the new item into the list
-    _klasses = k;
+    // Link the new item into the list, making sure the linked class is stable
+    // since the list can be walked without a lock
+    OrderAccess::release_store_ptr(&_klasses, k);
   }
 
   if (publicize && k->class_loader_data() != NULL) {
@@ -343,11 +355,10 @@
   }
 }
 
-// This is called by InstanceKlass::deallocate_contents() to remove the
-// scratch_class for redefine classes.  We need a lock because there it may not
-// be called at a safepoint if there's an error.
+// Remove a klass from the _klasses list for scratch_class during redefinition
+// or parsed class in the case of an error.
 void ClassLoaderData::remove_class(Klass* scratch_class) {
-  MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
+  assert(SafepointSynchronize::is_at_safepoint(), "only called at safepoint");
   Klass* prev = NULL;
   for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
     if (k == scratch_class) {
@@ -390,42 +401,46 @@
 
 PackageEntryTable* ClassLoaderData::packages() {
   // Lazily create the package entry table at first request.
-  if (_packages == NULL) {
+  // Lock-free access requires load_ptr_acquire.
+  PackageEntryTable* packages = load_ptr_acquire(&_packages);
+  if (packages == NULL) {
     MutexLockerEx m1(metaspace_lock(), Mutex::_no_safepoint_check_flag);
     // Check if _packages got allocated while we were waiting for this lock.
-    if (_packages == NULL) {
-      _packages = new PackageEntryTable(PackageEntryTable::_packagetable_entry_size);
+    if ((packages = _packages) == NULL) {
+      packages = new PackageEntryTable(PackageEntryTable::_packagetable_entry_size);
+      // Ensure _packages is stable, since it is examined without a lock
+      OrderAccess::release_store_ptr(&_packages, packages);
     }
   }
-  return _packages;
+  return packages;
 }
 
 ModuleEntryTable* ClassLoaderData::modules() {
   // Lazily create the module entry table at first request.
-  if (_modules == NULL) {
+  // Lock-free access requires load_ptr_acquire.
+  ModuleEntryTable* modules = load_ptr_acquire(&_modules);
+  if (modules == NULL) {
     MutexLocker m1(Module_lock);
-    // Check again if _modules has been allocated while we were getting this lock.
-    if (_modules != NULL) {
-      return _modules;
-    }
+    // Check if _modules got allocated while we were waiting for this lock.
+    if ((modules = _modules) == NULL) {
+      modules = new ModuleEntryTable(ModuleEntryTable::_moduletable_entry_size);
+      // Each loader has one unnamed module entry. Create it before
+      // any classes, loaded by this loader, are defined in case
+      // they end up being defined in loader's unnamed module.
+      modules->create_unnamed_module(this);
 
-    ModuleEntryTable* temp_table = new ModuleEntryTable(ModuleEntryTable::_moduletable_entry_size);
-    // Each loader has one unnamed module entry. Create it before
-    // any classes, loaded by this loader, are defined in case
-    // they end up being defined in loader's unnamed module.
-    temp_table->create_unnamed_module(this);
-
-    {
-      MutexLockerEx m1(metaspace_lock(), Mutex::_no_safepoint_check_flag);
-      // Ensure _modules is stable, since it is examined without a lock
-      OrderAccess::storestore();
-      _modules = temp_table;
+      {
+        MutexLockerEx m1(metaspace_lock(), Mutex::_no_safepoint_check_flag);
+        // Ensure _modules is stable, since it is examined without a lock
+        OrderAccess::release_store_ptr(&_modules, modules);
+      }
     }
   }
-  return _modules;
+  return modules;
 }
 
 oop ClassLoaderData::keep_alive_object() const {
+  assert_locked_or_safepoint(_metaspace_lock);
   assert(!keep_alive(), "Don't use with CLDs that are artificially kept alive");
   return is_anonymous() ? _klasses->java_mirror() : class_loader();
 }
@@ -499,30 +514,33 @@
   // to create smaller arena for Reflection class loaders also.
   // The reason for the delayed allocation is because some class loaders are
   // simply for delegating with no metadata of their own.
-  if (_metaspace == NULL) {
-    MutexLockerEx ml(metaspace_lock(),  Mutex::_no_safepoint_check_flag);
-    // Check again if metaspace has been allocated while we were getting this lock.
-    if (_metaspace != NULL) {
-      return _metaspace;
-    }
-    if (this == the_null_class_loader_data()) {
-      assert (class_loader() == NULL, "Must be");
-      set_metaspace(new Metaspace(_metaspace_lock, Metaspace::BootMetaspaceType));
-    } else if (is_anonymous()) {
-      if (class_loader() != NULL) {
-        log_trace(class, loader, data)("is_anonymous: %s", class_loader()->klass()->internal_name());
+  // Lock-free access requires load_ptr_acquire.
+  Metaspace* metaspace = load_ptr_acquire(&_metaspace);
+  if (metaspace == NULL) {
+    MutexLockerEx ml(_metaspace_lock,  Mutex::_no_safepoint_check_flag);
+    // Check if _metaspace got allocated while we were waiting for this lock.
+    if ((metaspace = _metaspace) == NULL) {
+      if (this == the_null_class_loader_data()) {
+        assert (class_loader() == NULL, "Must be");
+        metaspace = new Metaspace(_metaspace_lock, Metaspace::BootMetaspaceType);
+      } else if (is_anonymous()) {
+        if (class_loader() != NULL) {
+          log_trace(class, loader, data)("is_anonymous: %s", class_loader()->klass()->internal_name());
+        }
+        metaspace = new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType);
+      } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
+        if (class_loader() != NULL) {
+          log_trace(class, loader, data)("is_reflection: %s", class_loader()->klass()->internal_name());
+        }
+        metaspace = new Metaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType);
+      } else {
+        metaspace = new Metaspace(_metaspace_lock, Metaspace::StandardMetaspaceType);
       }
-      set_metaspace(new Metaspace(_metaspace_lock, Metaspace::AnonymousMetaspaceType));
-    } else if (class_loader()->is_a(SystemDictionary::reflect_DelegatingClassLoader_klass())) {
-      if (class_loader() != NULL) {
-        log_trace(class, loader, data)("is_reflection: %s", class_loader()->klass()->internal_name());
-      }
-      set_metaspace(new Metaspace(_metaspace_lock, Metaspace::ReflectionMetaspaceType));
-    } else {
-      set_metaspace(new Metaspace(_metaspace_lock, Metaspace::StandardMetaspaceType));
+      // Ensure _metaspace is stable, since it is examined without a lock
+      OrderAccess::release_store_ptr(&_metaspace, metaspace);
     }
   }
-  return _metaspace;
+  return metaspace;
 }
 
 JNIHandleBlock* ClassLoaderData::handles() const           { return _handles; }
@@ -638,6 +656,7 @@
 #endif // PRODUCT
 
 void ClassLoaderData::verify() {
+  assert_locked_or_safepoint(_metaspace_lock);
   oop cl = class_loader();
 
   guarantee(this == class_loader_data(cl) || is_anonymous(), "Must be the same");
@@ -656,7 +675,8 @@
 }
 
 bool ClassLoaderData::contains_klass(Klass* klass) {
-  for (Klass* k = _klasses; k != NULL; k = k->next_link()) {
+  // Lock-free access requires load_ptr_acquire
+  for (Klass* k = load_ptr_acquire(&_klasses); k != NULL; k = k->next_link()) {
     if (k == klass) return true;
   }
   return false;
@@ -1046,6 +1066,7 @@
 
   // Find the first klass in the CLDG.
   while (cld != NULL) {
+    assert_locked_or_safepoint(cld->metaspace_lock());
     klass = cld->_klasses;
     if (klass != NULL) {
       _next_klass = klass;
@@ -1063,6 +1084,7 @@
 
   // No more klasses in the current CLD. Time to find a new CLD.
   ClassLoaderData* cld = klass->class_loader_data();
+  assert_locked_or_safepoint(cld->metaspace_lock());
   while (next == NULL) {
     cld = cld->next();
     if (cld == NULL) {
--- a/hotspot/src/share/vm/classfile/classLoaderData.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -171,8 +171,8 @@
   Dependencies _dependencies; // holds dependencies from this class loader
                               // data to others.
 
-  Metaspace * _metaspace;  // Meta-space where meta-data defined by the
-                           // classes in the class loader are allocated.
+  Metaspace * volatile _metaspace;  // Meta-space where meta-data defined by the
+                                    // classes in the class loader are allocated.
   Mutex* _metaspace_lock;  // Locks the metaspace for allocations and setup.
   bool _unloading;         // true if this class loader goes away
   bool _is_anonymous;      // if this CLD is for an anonymous class
@@ -186,9 +186,9 @@
   JNIHandleBlock* _handles; // Handles to constant pool arrays, Modules, etc, which
                             // have the same life cycle of the corresponding ClassLoader.
 
-  Klass* _klasses;         // The classes defined by the class loader.
-  PackageEntryTable* _packages; // The packages defined by the class loader.
-  ModuleEntryTable* _modules;   // The modules defined by the class loader.
+  Klass* volatile _klasses;              // The classes defined by the class loader.
+  PackageEntryTable* volatile _packages; // The packages defined by the class loader.
+  ModuleEntryTable* volatile _modules;   // The modules defined by the class loader.
 
   // These method IDs are created for the class loader and set to NULL when the
   // class loader is unloaded.  They are rarely freed, only for redefine classes
@@ -216,8 +216,6 @@
   ClassLoaderData(Handle h_class_loader, bool is_anonymous, Dependencies dependencies);
   ~ClassLoaderData();
 
-  void set_metaspace(Metaspace* m) { _metaspace = m; }
-
   JNIHandleBlock* handles() const;
   void set_handles(JNIHandleBlock* handles);
 
--- a/hotspot/src/share/vm/classfile/javaClasses.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/javaClasses.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -848,7 +848,7 @@
     if (!ModuleEntryTable::javabase_defined()) {
       if (fixup_module_field_list() == NULL) {
         GrowableArray<Klass*>* list =
-          new (ResourceObj::C_HEAP, mtClass) GrowableArray<Klass*>(500, true);
+          new (ResourceObj::C_HEAP, mtModule) GrowableArray<Klass*>(500, true);
         set_fixup_module_field_list(list);
       }
       k->class_loader_data()->inc_keep_alive();
--- a/hotspot/src/share/vm/classfile/moduleEntry.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/moduleEntry.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -113,7 +113,7 @@
   } else {
     if (_reads == NULL) {
       // Lazily create a module's reads list
-      _reads = new (ResourceObj::C_HEAP, mtClass)GrowableArray<ModuleEntry*>(MODULE_READS_SIZE, true);
+      _reads = new (ResourceObj::C_HEAP, mtModule)GrowableArray<ModuleEntry*>(MODULE_READS_SIZE, true);
     }
     _reads->append_if_missing(m);
   }
@@ -159,7 +159,7 @@
 }
 
 ModuleEntryTable::ModuleEntryTable(int table_size)
-  : Hashtable<Symbol*, mtClass>(table_size, sizeof(ModuleEntry)), _unnamed_module(NULL)
+  : Hashtable<Symbol*, mtModule>(table_size, sizeof(ModuleEntry)), _unnamed_module(NULL)
 {
 }
 
@@ -228,7 +228,7 @@
                                          Symbol* version, Symbol* location,
                                          ClassLoaderData* loader_data) {
   assert_locked_or_safepoint(Module_lock);
-  ModuleEntry* entry = (ModuleEntry*) NEW_C_HEAP_ARRAY(char, entry_size(), mtClass);
+  ModuleEntry* entry = (ModuleEntry*) NEW_C_HEAP_ARRAY(char, entry_size(), mtModule);
 
   // Initialize everything BasicHashtable would
   entry->set_next(NULL);
@@ -259,7 +259,7 @@
 
 void ModuleEntryTable::add_entry(int index, ModuleEntry* new_entry) {
   assert_locked_or_safepoint(Module_lock);
-  Hashtable<Symbol*, mtClass>::add_entry(index, (HashtableEntry<Symbol*, mtClass>*)new_entry);
+  Hashtable<Symbol*, mtModule>::add_entry(index, (HashtableEntry<Symbol*, mtModule>*)new_entry);
 }
 
 ModuleEntry* ModuleEntryTable::locked_create_entry_or_null(Handle module_handle,
--- a/hotspot/src/share/vm/classfile/moduleEntry.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/moduleEntry.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -49,7 +49,7 @@
 //
 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either
 // data structure.
-class ModuleEntry : public HashtableEntry<Symbol*, mtClass> {
+class ModuleEntry : public HashtableEntry<Symbol*, mtModule> {
 private:
   jobject _module;                     // java.lang.reflect.Module
   jobject _pd;                         // java.security.ProtectionDomain, cached
@@ -127,10 +127,10 @@
   }
 
   ModuleEntry* next() const {
-    return (ModuleEntry*)HashtableEntry<Symbol*, mtClass>::next();
+    return (ModuleEntry*)HashtableEntry<Symbol*, mtModule>::next();
   }
   ModuleEntry** next_addr() {
-    return (ModuleEntry**)HashtableEntry<Symbol*, mtClass>::next_addr();
+    return (ModuleEntry**)HashtableEntry<Symbol*, mtModule>::next_addr();
   }
 
   // iteration support for readability
@@ -166,7 +166,7 @@
 //
 // The ModuleEntryTable's lookup is lock free.
 //
-class ModuleEntryTable : public Hashtable<Symbol*, mtClass> {
+class ModuleEntryTable : public Hashtable<Symbol*, mtModule> {
   friend class VMStructs;
 public:
   enum Constants {
@@ -181,10 +181,10 @@
                          Symbol* location, ClassLoaderData* class_loader);
   void add_entry(int index, ModuleEntry* new_entry);
 
-  int entry_size() const { return BasicHashtable<mtClass>::entry_size(); }
+  int entry_size() const { return BasicHashtable<mtModule>::entry_size(); }
 
   ModuleEntry** bucket_addr(int i) {
-    return (ModuleEntry**)Hashtable<Symbol*, mtClass>::bucket_addr(i);
+    return (ModuleEntry**)Hashtable<Symbol*, mtModule>::bucket_addr(i);
   }
 
   static unsigned int compute_hash(Symbol* name) { return ((name == NULL) ? 0 : (unsigned int)(name->identity_hash())); }
@@ -195,7 +195,7 @@
   ~ModuleEntryTable();
 
   ModuleEntry* bucket(int i) {
-    return (ModuleEntry*)Hashtable<Symbol*, mtClass>::bucket(i);
+    return (ModuleEntry*)Hashtable<Symbol*, mtModule>::bucket(i);
   }
 
   // Create module in loader's module entry table, if already exists then
--- a/hotspot/src/share/vm/classfile/modules.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/modules.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -145,7 +145,7 @@
 
   const char* home = Arguments::get_java_home();
   size_t len = strlen(home) + module_len + 32;
-  char* path = NEW_C_HEAP_ARRAY(char, len, mtInternal);
+  char* path = NEW_C_HEAP_ARRAY(char, len, mtModule);
   jio_snprintf(path, len, "%s%cmodules%c%s", home, file_sep, file_sep, module_name);
   struct stat st;
   // See if exploded module path exists
@@ -237,35 +237,40 @@
   // Ensure java.base's ModuleEntry has been created
   assert(ModuleEntryTable::javabase_module() != NULL, "No ModuleEntry for java.base");
 
+  bool duplicate_javabase = false;
   {
     MutexLocker m1(Module_lock, THREAD);
 
     if (ModuleEntryTable::javabase_defined()) {
-      THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
-                "Module java.base is already defined");
+      duplicate_javabase = true;
+    } else {
+
+      // Verify that all java.base packages created during bootstrapping are in
+      // pkg_list.  If any are not in pkg_list, than a non-java.base class was
+      // loaded erroneously pre java.base module definition.
+      package_table->verify_javabase_packages(pkg_list);
+
+      // loop through and add any new packages for java.base
+      PackageEntry* pkg;
+      for (int x = 0; x < pkg_list->length(); x++) {
+        // Some of java.base's packages were added early in bootstrapping, ignore duplicates.
+        if (package_table->lookup_only(pkg_list->at(x)) == NULL) {
+          pkg = package_table->locked_create_entry_or_null(pkg_list->at(x), ModuleEntryTable::javabase_module());
+          assert(pkg != NULL, "Unable to create a java.base package entry");
+        }
+        // Unable to have a GrowableArray of TempNewSymbol.  Must decrement the refcount of
+        // the Symbol* that was created above for each package. The refcount was incremented
+        // by SymbolTable::new_symbol and as well by the PackageEntry creation.
+        pkg_list->at(x)->decrement_refcount();
+      }
+
+      // Finish defining java.base's ModuleEntry
+      ModuleEntryTable::finalize_javabase(module_handle, version_symbol, location_symbol);
     }
-
-    // Verify that all java.base packages created during bootstrapping are in
-    // pkg_list.  If any are not in pkg_list, than a non-java.base class was
-    // loaded erroneously pre java.base module definition.
-    package_table->verify_javabase_packages(pkg_list);
-
-    // loop through and add any new packages for java.base
-    PackageEntry* pkg;
-    for (int x = 0; x < pkg_list->length(); x++) {
-      // Some of java.base's packages were added early in bootstrapping, ignore duplicates.
-      if (package_table->lookup_only(pkg_list->at(x)) == NULL) {
-        pkg = package_table->locked_create_entry_or_null(pkg_list->at(x), ModuleEntryTable::javabase_module());
-        assert(pkg != NULL, "Unable to create a java.base package entry");
-      }
-      // Unable to have a GrowableArray of TempNewSymbol.  Must decrement the refcount of
-      // the Symbol* that was created above for each package. The refcount was incremented
-      // by SymbolTable::new_symbol and as well by the PackageEntry creation.
-      pkg_list->at(x)->decrement_refcount();
-    }
-
-    // Finish defining java.base's ModuleEntry
-    ModuleEntryTable::finalize_javabase(module_handle, version_symbol, location_symbol);
+  }
+  if (duplicate_javabase) {
+    THROW_MSG(vmSymbols::java_lang_IllegalArgumentException(),
+              "Module java.base is already defined");
   }
 
   log_debug(modules)("define_javabase_module(): Definition of module: java.base,"
--- a/hotspot/src/share/vm/classfile/packageEntry.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/packageEntry.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -34,15 +34,13 @@
 #include "utilities/hashtable.inline.hpp"
 #include "utilities/ostream.hpp"
 
-// Return true if this package is exported to m.
+// Returns true if this package specifies m as a qualified export, including through an unnamed export
 bool PackageEntry::is_qexported_to(ModuleEntry* m) const {
   assert(m != NULL, "No module to lookup in this package's qualified exports list");
   MutexLocker m1(Module_lock);
-  if (!_is_exported) {
-    return false;
-  } else if (_is_exported_allUnnamed && !m->is_named()) {
+  if (is_exported_allUnnamed() && !m->is_named()) {
     return true;
-  } else if (_qualified_exports == NULL) {
+  } else if (!has_qual_exports_list()) {
     return false;
   } else {
     return _qualified_exports->contains(m);
@@ -52,17 +50,16 @@
 // Add a module to the package's qualified export list.
 void PackageEntry::add_qexport(ModuleEntry* m) {
   assert_locked_or_safepoint(Module_lock);
-  assert(_is_exported == true, "Adding a qualified export to a package that is not exported");
-  if (_qualified_exports == NULL) {
+  if (!has_qual_exports_list()) {
     // Lazily create a package's qualified exports list.
     // Initial size is small, do not anticipate export lists to be large.
     _qualified_exports =
-      new (ResourceObj::C_HEAP, mtClass) GrowableArray<ModuleEntry*>(QUAL_EXP_SIZE, true);
+      new (ResourceObj::C_HEAP, mtModule) GrowableArray<ModuleEntry*>(QUAL_EXP_SIZE, true);
   }
   _qualified_exports->append_if_missing(m);
 }
 
-// Set the package's exported state based on the value of the ModuleEntry.
+// Set the package's exported states based on the value of the ModuleEntry.
 void PackageEntry::set_exported(ModuleEntry* m) {
   MutexLocker m1(Module_lock);
   if (is_unqual_exported()) {
@@ -73,7 +70,7 @@
 
   if (m == NULL) {
     // NULL indicates the package is being unqualifiedly exported
-    if (_is_exported && _qualified_exports != NULL) {
+    if (has_qual_exports_list()) {
       // Legit to transition a package from being qualifiedly exported
       // to unqualified.  Clean up the qualified lists at the next
       // safepoint.
@@ -85,11 +82,17 @@
 
   } else {
     // Add the exported module
-    _is_exported = true;
     add_qexport(m);
   }
 }
 
+void PackageEntry::set_is_exported_allUnnamed() {
+  MutexLocker m1(Module_lock);
+  if (!is_unqual_exported()) {
+   _is_exported_allUnnamed = true;
+  }
+}
+
 // Remove dead module entries within the package's exported list.
 void PackageEntry::purge_qualified_exports() {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
@@ -124,7 +127,7 @@
 }
 
 PackageEntryTable::PackageEntryTable(int table_size)
-  : Hashtable<Symbol*, mtClass>(table_size, sizeof(PackageEntry))
+  : Hashtable<Symbol*, mtModule>(table_size, sizeof(PackageEntry))
 {
 }
 
@@ -155,7 +158,7 @@
 
 PackageEntry* PackageEntryTable::new_entry(unsigned int hash, Symbol* name, ModuleEntry* module) {
   assert_locked_or_safepoint(Module_lock);
-  PackageEntry* entry = (PackageEntry*) NEW_C_HEAP_ARRAY(char, entry_size(), mtClass);
+  PackageEntry* entry = (PackageEntry*) NEW_C_HEAP_ARRAY(char, entry_size(), mtModule);
 
   // Initialize everything BasicHashtable would
   entry->set_next(NULL);
@@ -170,7 +173,7 @@
   if (!module->is_named()) {
     // Set the exported state to true because all packages
     // within the unnamed module are unqualifiedly exported
-    entry->set_exported(true);
+    entry->set_unqual_exported();
   }
   entry->set_module(module);
   return entry;
@@ -178,7 +181,7 @@
 
 void PackageEntryTable::add_entry(int index, PackageEntry* new_entry) {
   assert_locked_or_safepoint(Module_lock);
-  Hashtable<Symbol*, mtClass>::add_entry(index, (HashtableEntry<Symbol*, mtClass>*)new_entry);
+  Hashtable<Symbol*, mtModule>::add_entry(index, (HashtableEntry<Symbol*, mtModule>*)new_entry);
 }
 
 // Create package in loader's package entry table and return the entry.
@@ -248,6 +251,20 @@
 
 }
 
+// iteration of qualified exports
+void PackageEntry::package_exports_do(ModuleClosure* const f) {
+  assert_locked_or_safepoint(Module_lock);
+  assert(f != NULL, "invariant");
+
+  if (has_qual_exports_list()) {
+    int qe_len = _qualified_exports->length();
+
+    for (int i = 0; i < qe_len; ++i) {
+      f->do_module(_qualified_exports->at(i));
+    }
+  }
+}
+
 // Remove dead entries from all packages' exported list
 void PackageEntryTable::purge_all_package_exports() {
   assert(SafepointSynchronize::is_at_safepoint(), "must be at safepoint");
@@ -281,10 +298,10 @@
 void PackageEntry::print(outputStream* st) {
   ResourceMark rm;
   st->print_cr("package entry "PTR_FORMAT" name %s module %s classpath_index "
-               INT32_FORMAT " is_exported %d is_exported_allUnnamed %d " "next "PTR_FORMAT,
+               INT32_FORMAT " is_exported_unqualified %d is_exported_allUnnamed %d " "next "PTR_FORMAT,
                p2i(this), name()->as_C_string(),
                (module()->is_named() ? module()->name()->as_C_string() : UNNAMED_MODULE),
-               _classpath_index, _is_exported, _is_exported_allUnnamed, p2i(next()));
+               _classpath_index, _is_exported_unqualified, _is_exported_allUnnamed, p2i(next()));
 }
 
 void PackageEntryTable::verify() {
@@ -305,17 +322,3 @@
 void PackageEntry::verify() {
   guarantee(name() != NULL, "A package entry must have a corresponding symbol name.");
 }
-
-// iteration of qualified exports
-void PackageEntry::package_exports_do(ModuleClosure* const f) {
-  assert_locked_or_safepoint(Module_lock);
-  assert(f != NULL, "invariant");
-
-  if (is_qual_exported()) {
-    int qe_len = _qualified_exports->length();
-
-    for (int i = 0; i < qe_len; ++i) {
-      f->do_module(_qualified_exports->at(i));
-    }
-  }
-}
--- a/hotspot/src/share/vm/classfile/packageEntry.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/packageEntry.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -34,20 +34,36 @@
 // A PackageEntry basically represents a Java package.  It contains:
 //   - Symbol* containing the package's name.
 //   - ModuleEntry* for this package's containing module.
-//   - a flag indicating if package is exported, either qualifiedly or
-//     unqualifiedly.
+//   - a flag indicating if package is exported unqualifiedly
 //   - a flag indicating if this package is exported to all unnamed modules.
 //   - a growable array containing other module entries that this
 //     package is exported to.
 //
-// Packages that are:
-//   - not exported:        _qualified_exports = NULL  && _is_exported is false
-//   - qualified exports:   (_qualified_exports != NULL || _is_exported_allUnnamed is true) && _is_exported is true
-//   - unqualified exports: (_qualified_exports = NULL && _is_exported_allUnnamed is false) && _is_exported is true
+// Packages can be exported in the following 3 ways:
+//   - not exported:        the package has not been explicitly qualified to a
+//                            particular module nor has it been specified to be
+//                            unqualifiedly exported to all modules. If all states
+//                            of exportedness are false, the package is considered
+//                            not exported.
+//   - qualified exports:   the package has been explicitly qualified to at least
+//                            one particular module or has been qualifiedly exported
+//                            to all unnamed modules.
+//                            Note: _is_exported_allUnnamed is a form of a qualified
+//                            export. It is equivalent to the package being
+//                            explicitly exported to all current and future unnamed modules.
+//   - unqualified exports: the package is exported to all modules.
+//
+// A package can transition from:
+//   - being not exported, to being exported either in a qualified or unqualified manner
+//   - being qualifiedly exported, to unqualifiedly exported. Its exported scope is widened.
+//
+// A package cannot transition from:
+//   - being unqualifiedly exported, to exported qualifiedly to a specific module.
+//       This transition attempt is silently ignored in set_exported.
 //
 // The Mutex Module_lock is shared between ModuleEntry and PackageEntry, to lock either
 // data structure.
-class PackageEntry : public HashtableEntry<Symbol*, mtClass> {
+class PackageEntry : public HashtableEntry<Symbol*, mtModule> {
 private:
   ModuleEntry* _module;
   // Used to indicate for packages with classes loaded by the boot loader that
@@ -55,7 +71,7 @@
   // loaded by the boot loader from -Xbootclasspath/a in an unnamed module, it
   // indicates from which class path entry.
   s2 _classpath_index;
-  bool _is_exported;
+  bool _is_exported_unqualified;
   bool _is_exported_allUnnamed;
   GrowableArray<ModuleEntry*>* _exported_pending_delete; // transitioned from qualified to unqualified, delete at safepoint
   GrowableArray<ModuleEntry*>* _qualified_exports;
@@ -68,7 +84,7 @@
   void init() {
     _module = NULL;
     _classpath_index = -1;
-    _is_exported = false;
+    _is_exported_unqualified = false;
     _is_exported_allUnnamed = false;
     _exported_pending_delete = NULL;
     _qualified_exports = NULL;
@@ -83,34 +99,41 @@
   void               set_module(ModuleEntry* m) { _module = m; }
 
   // package's export state
-  bool is_exported() const { return _is_exported; } // qualifiedly or unqualifiedly exported
+  bool is_exported() const { // qualifiedly or unqualifiedly exported
+      return (is_unqual_exported() || has_qual_exports_list() || is_exported_allUnnamed());
+  }
+  // Returns true if the package has any explicit qualified exports or is exported to all unnamed
   bool is_qual_exported() const {
-    return (_is_exported && (_qualified_exports != NULL || _is_exported_allUnnamed));
+    return (has_qual_exports_list() || is_exported_allUnnamed());
+  }
+  // Returns true if there are any explicit qualified exports
+  bool has_qual_exports_list() const {
+    assert(!(_qualified_exports != NULL && _is_exported_unqualified),
+           "_qualified_exports set at same time as _is_exported_unqualified");
+    return (_qualified_exports != NULL);
+  }
+  bool is_exported_allUnnamed() const {
+    assert(!(_is_exported_allUnnamed && _is_exported_unqualified),
+           "_is_exported_allUnnamed set at same time as _is_exported_unqualified");
+    return _is_exported_allUnnamed;
   }
   bool is_unqual_exported() const {
-    return (_is_exported && (_qualified_exports == NULL && !_is_exported_allUnnamed));
+    assert(!(_qualified_exports != NULL && _is_exported_unqualified),
+           "_qualified_exports set at same time as _is_exported_unqualified");
+    assert(!(_is_exported_allUnnamed && _is_exported_unqualified),
+           "_is_exported_allUnnamed set at same time as _is_exported_unqualified");
+    return _is_exported_unqualified;
   }
   void set_unqual_exported() {
-    _is_exported = true;
+    _is_exported_unqualified = true;
     _is_exported_allUnnamed = false;
     _qualified_exports = NULL;
   }
   bool exported_pending_delete() const     { return (_exported_pending_delete != NULL); }
 
-  void set_exported(bool e)                { _is_exported = e; }
   void set_exported(ModuleEntry* m);
 
-  void set_is_exported_allUnnamed() {
-    if (!is_unqual_exported()) {
-     _is_exported_allUnnamed = true;
-     _is_exported = true;
-    }
-  }
-  bool is_exported_allUnnamed() const {
-    assert(_is_exported || !_is_exported_allUnnamed,
-           "is_allUnnamed set without is_exported being set");
-    return _is_exported_allUnnamed;
-  }
+  void set_is_exported_allUnnamed();
 
   void set_classpath_index(s2 classpath_index) {
     _classpath_index = classpath_index;
@@ -122,18 +145,18 @@
   // returns true if the package is defined in the unnamed module
   bool in_unnamed_module() const  { return !_module->is_named(); }
 
-  // returns true if the package specifies m as a qualified export
+  // returns true if the package specifies m as a qualified export, including through an unnamed export
   bool is_qexported_to(ModuleEntry* m) const;
 
   // add the module to the package's qualified exports
   void add_qexport(ModuleEntry* m);
 
   PackageEntry* next() const {
-    return (PackageEntry*)HashtableEntry<Symbol*, mtClass>::next();
+    return (PackageEntry*)HashtableEntry<Symbol*, mtModule>::next();
   }
 
   PackageEntry** next_addr() {
-    return (PackageEntry**)HashtableEntry<Symbol*, mtClass>::next_addr();
+    return (PackageEntry**)HashtableEntry<Symbol*, mtModule>::next_addr();
   }
 
   // iteration of qualified exports
@@ -153,7 +176,7 @@
 // by a particular class loader.  Each package is represented as a PackageEntry node.
 // The PackageEntryTable's lookup is lock free.
 //
-class PackageEntryTable : public Hashtable<Symbol*, mtClass> {
+class PackageEntryTable : public Hashtable<Symbol*, mtModule> {
   friend class VMStructs;
 public:
   enum Constants {
@@ -164,10 +187,10 @@
   PackageEntry* new_entry(unsigned int hash, Symbol* name, ModuleEntry* module);
   void add_entry(int index, PackageEntry* new_entry);
 
-  int entry_size() const { return BasicHashtable<mtClass>::entry_size(); }
+  int entry_size() const { return BasicHashtable<mtModule>::entry_size(); }
 
   PackageEntry** bucket_addr(int i) {
-    return (PackageEntry**)Hashtable<Symbol*, mtClass>::bucket_addr(i);
+    return (PackageEntry**)Hashtable<Symbol*, mtModule>::bucket_addr(i);
   }
 
   static unsigned int compute_hash(Symbol* name) { return (unsigned int)(name->identity_hash()); }
@@ -178,7 +201,7 @@
   ~PackageEntryTable();
 
   PackageEntry* bucket(int i) {
-    return (PackageEntry*)Hashtable<Symbol*, mtClass>::bucket(i);
+    return (PackageEntry*)Hashtable<Symbol*, mtModule>::bucket(i);
   }
 
   // Create package in loader's package entry table and return the entry.
--- a/hotspot/src/share/vm/classfile/systemDictionary.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1336,9 +1336,12 @@
       return nh;
     }
 
-    // Found the class, now load the superclass and interfaces.  If they
-    // are shared, add them to the main system dictionary and reset
-    // their hierarchy references (supers, subs, and interfaces).
+    // Resolve the superclass and interfaces. They must be the same
+    // as in dump time, because the layout of <ik> depends on
+    // the specific layout of ik->super() and ik->local_interfaces().
+    //
+    // If unexpected superclass or interfaces are found, we cannot
+    // load <ik> from the shared archive.
 
     if (ik->super() != NULL) {
       Symbol*  cn = ik->super()->name();
@@ -1348,6 +1351,8 @@
         // The dynamically resolved super class is not the same as the one we used during dump time,
         // so we cannot use ik.
         return nh;
+      } else {
+        assert(s->is_shared(), "must be");
       }
     }
 
@@ -1366,6 +1371,8 @@
         // The dynamically resolved interface class is not the same as the one we used during dump time,
         // so we cannot use ik.
         return nh;
+      } else {
+        assert(i->is_shared(), "must be");
       }
     }
 
--- a/hotspot/src/share/vm/classfile/systemDictionary.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -420,9 +420,9 @@
   // Initialization
   static void initialize(TRAPS);
 
-  // Fast access to commonly used classes (preloaded)
+  // Checked fast access to commonly used classes - mostly preloaded
   static InstanceKlass* check_klass(InstanceKlass* k) {
-    assert(k != NULL, "preloaded klass not initialized");
+    assert(k != NULL, "klass not loaded");
     return k;
   }
 
--- a/hotspot/src/share/vm/interpreter/bytecodes.hpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/interpreter/bytecodes.hpp	Tue Jun 07 09:11:32 2016 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -386,15 +386,16 @@
   static Code       non_breakpoint_code_at(const Method* method, address bcp);
 
   // Bytecode attributes
-  static bool        is_defined     (int  code)    { return 0 <= code && code < number_of_codes && flags(code, false) != 0; }
+  static bool        is_valid       (int  code)    { return 0 <= code && code < number_of_codes; }
+  static bool        is_defined     (int  code)    { return is_valid(code) && flags(code, false) != 0; }
   static bool        wide_is_defined(int  code)    { return is_defined(code) && flags(code, true) != 0; }
   static const char* name           (Code code)    { check(code);      return _name          [code]; }
   static BasicType   result_type    (Code code)    { check(code);      return _result_type   [code]; }
   static int         depth          (Code code)    { check(code);      return _depth         [code]; }
   // Note: Length functions must return <=0 for invalid bytecodes.
   // Calling check(code) in length functions would throw an unwanted assert.
-  static int         length_for     (Code code)    { /*no check*/      return _lengths       [code] & 0xF; }
-  static int         wide_length_for(Code code)    { /*no check*/      return _lengths       [code] >> 4; }
+  static int         length_for     (Code code)    { return is_valid(code) ? _lengths[code] & 0xF : -1; }
+  static int         wide_length_for(Code code)    { return is_valid(code) ? _lengths[code]  >> 4 : -1; }
   static bool        can_trap       (Code code)    { check(code);      return has_all_flags(code, _bc_can_trap, false); }
   static Code        java_code      (Code code)    { check(code);      return _java_code     [code]; }
   static bool        can_rewrite    (Code code)    { check(code);      return has_all_flags(code, _bc_can_rewrite, false); }
--- a/hotspot/src/share/vm/interpreter/linkResolver.cpp	Mon Jun 06 23:24:46 2016 -0700
+++ b/hotspot/src/share/vm/interpreter/linkResolver.cpp	Tue Jun 07 09:11:32 2016 +0000
@@ -231,6 +231,7 @@
   // Get name, signature, and static klass
   _name          = pool->name_ref_at(index);
   _signature     = pool->signature_ref_at(index);
+  _tag           = pool->tag_ref_at(index);
   _current_klass = KlassHandle(THREAD, pool->pool_holder());
 
   // Coming from the constant pool always checks access
@@ -573,7 +574,7 @@
     Symbol* method_signature = pool->signature_ref_at(index);
     KlassHandle  current_klass(THREAD, pool->pool_holder());
     LinkInfo link_info(resolved_klass, method_name, method_signature, current_klass);
-    return resolve_method(link_info, /*require_methodref*/false, THREAD);
+    return resolve_method(link_info, code, THREAD);
   }
 
   LinkInfo link_info(pool, index, CHECK_NULL);
@@ -591,9 +592,9 @@
   if (code == Bytecodes::_invokeinterface) {
     return resolve_interface_method(link_info, code, THREAD);
   } else if (code == Bytecodes::_invokevirtual) {
-    return resolve_method(link_info, /*require_methodref*/true, THREAD);
+    return resolve_method(link_info, code, THREAD);
   } else if (!resolved_klass->is_interface()) {
-    return resolve_method(link_info, /*require_methodref*/false, THREAD);
+    return resolve_method(link_info, code, THREAD);
   } else {
     return resolve_interface_method(link_info, code, THREAD);
   }
@@ -663,13 +664,13 @@
 }
 
 methodHandle LinkResolver::resolve_method(const LinkInfo& link_info,
-                                          bool require_methodref, TRAPS) {
+                                          Bytecodes::Code code, TRAPS) {
 
   Handle nested_exception;
   KlassHandle resolved_klass = link_info.resolved_klass();
 
-  // 1. check if methodref required, that resolved_klass is not interfacemethodref
-  if (require_methodref && resolved_klass->is_interface()) {
+  // 1. For invokevirtual, cannot call an interface method
+  if (code == Bytecodes::_invokevirtual && resolved_klass->is_interface()) {
     ResourceMark rm(THREAD);
     char buf[200];
     jio_snprintf(buf, sizeof(buf), "Found interface %s, but class was expected",
@@ -677,11 +678,20 @@
     THROW_MSG_NULL(vmSymbols::java_lang_IncompatibleClassChangeError(), buf);
   }
 
-  // 2. lookup method in resolved klass and its super klasses
+  // 2. check constant pool tag for called method - must be JVM_CONSTANT_Methodref
+  if (!link_info.tag().is_invalid() && !link_info.tag().is_method()) {
+    ResourceMark rm(THREAD);
+    char buf[200];
+    jio_snprintf(buf, sizeof