changeset 2394:4c39c7f924f0

Merge
author lana
date Thu, 08 Dec 2016 21:21:16 +0000
parents 514c1e8d10f2 66b770c85156
children b119012d1c2a
files
diffstat 10 files changed, 632 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/common/autoconf/generated-configure.sh	Thu Dec 08 18:03:34 2016 +0000
+++ b/common/autoconf/generated-configure.sh	Thu Dec 08 21:21:16 2016 +0000
@@ -671,6 +671,8 @@
 LLVM_LDFLAGS
 LLVM_CFLAGS
 LLVM_CONFIG
+LIBFFI_LIB_FILE
+ENABLE_LIBFFI_BUNDLING
 LIBFFI_LIBS
 LIBFFI_CFLAGS
 ALSA_LIBS
@@ -1208,6 +1210,7 @@
 with_libffi
 with_libffi_include
 with_libffi_lib
+enable_libffi_bundling
 with_libjpeg
 with_giflib
 with_libpng
@@ -1990,6 +1993,9 @@
                           disable bundling of the freetype library with the
                           build result [enabled on Windows or when using
                           --with-freetype, disabled otherwise]
+  --enable-libffi-bundling
+                          enable bundling of libffi.so to make the built JDK
+                          runnable on more systems
   --enable-jtreg-failure-handler
                           forces build of the jtreg failure handler to be
                           enabled, missing dependencies become fatal errors.
@@ -4171,7 +4177,7 @@
     ffi)
       PKGHANDLER_COMMAND="sudo apt-get install libffi-dev" ;;
     x11)
-      PKGHANDLER_COMMAND="sudo apt-get install libX11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev" ;;
+      PKGHANDLER_COMMAND="sudo apt-get install libx11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev" ;;
     ccache)
       PKGHANDLER_COMMAND="sudo apt-get install ccache" ;;
     dtrace)
@@ -5082,7 +5088,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1480714260
+DATE_WHEN_GENERATED=1481104795
 
 ###############################################################################
 #
@@ -24451,11 +24457,10 @@
     fi
   else
     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
-      # Default is to calculate a string like this <timestamp>.<username>.<base dir name>
-      timestamp=`$DATE '+%Y-%m-%d-%H%M%S'`
+      # Default is to calculate a string like this 'adhoc.<username>.<base dir name>'
       # Outer [ ] to quote m4.
        basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'`
-      VERSION_OPT="$timestamp.$USERNAME.$basedirname"
+      VERSION_OPT="adhoc.$USERNAME.$basedirname"
     fi
   fi
 
@@ -62634,6 +62639,11 @@
   withval=$with_libffi_lib;
 fi
 
+  # Check whether --enable-libffi-bundling was given.
+if test "${enable_libffi_bundling+set}" = set; then :
+  enableval=$enable_libffi_bundling;
+fi
+
 
   if test "x$NEEDS_LIB_FFI" = xfalse; then
     if (test "x${with_libffi}" != x && test "x${with_libffi}" != xno) || \
@@ -62652,6 +62662,7 @@
     fi
 
     if test "x${with_libffi}" != x; then
+      LIBFFI_LIB_PATH="${with_libffi}/lib"
       LIBFFI_LIBS="-L${with_libffi}/lib -lffi"
       LIBFFI_CFLAGS="-I${with_libffi}/include"
       LIBFFI_FOUND=yes
@@ -62661,6 +62672,7 @@
       LIBFFI_FOUND=yes
     fi
     if test "x${with_libffi_lib}" != x; then
+      LIBFFI_LIB_PATH="${with_libffi_lib}"
       LIBFFI_LIBS="-L${with_libffi_lib} -lffi"
       LIBFFI_FOUND=yes
     fi
@@ -62870,7 +62882,70 @@
 
       as_fn_error $? "Found libffi but could not link and compile with it. $HELP_MSG" "$LINENO" 5
     fi
-  fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libffi should be bundled" >&5
+$as_echo_n "checking if libffi should be bundled... " >&6; }
+    if test "x$enable_libffi_bundling" = "x"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+      ENABLE_LIBFFI_BUNDLING=false
+    elif  test "x$enable_libffi_bundling" = "xno"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, forced" >&5
+$as_echo "no, forced" >&6; }
+      ENABLE_LIBFFI_BUNDLING=false
+    elif  test "x$enable_libffi_bundling" = "xyes"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes, forced" >&5
+$as_echo "yes, forced" >&6; }
+      ENABLE_LIBFFI_BUNDLING=true
+    else
+      as_fn_error $? "Invalid value for --enable-libffi-bundling" "$LINENO" 5
+    fi
+
+    # Find the libffi.so.X to bundle
+    if test "x${ENABLE_LIBFFI_BUNDLING}" = "xtrue"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking for libffi lib file location" >&5
+$as_echo_n "checking for libffi lib file location... " >&6; }
+      if test "x${LIBFFI_LIB_PATH}" != x; then
+        if test -e ${LIBFFI_LIB_PATH}/libffi.so.?; then
+          LIBFFI_LIB_FILE="${LIBFFI_LIB_PATH}/libffi.so.?"
+        else
+          as_fn_error $? "Could not locate libffi.so.? for bundling in ${LIBFFI_LIB_PATH}" "$LINENO" 5
+        fi
+      else
+        # If we don't have an explicit path, look in a few obvious places
+        if test "x${OPENJDK_TARGET_CPU}" = "xx86"; then
+          if test -e ${SYSROOT}/usr/lib/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/libffi.so.?"
+          elif test -e ${SYSROOT}/usr/lib/i386-linux-gnu/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/i386-linux-gnu/libffi.so.?"
+          else
+            as_fn_error $? "Could not locate libffi.so.? for bundling" "$LINENO" 5
+          fi
+        elif test "x${OPENJDK_TARGET_CPU}" = "xx86_64"; then
+          if test -e ${SYSROOT}/usr/lib64/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib64/libffi.so.?"
+          elif test -e ${SYSROOT}/usr/lib/x86_64-linux-gnu/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/x86_64-linux-gnu/libffi.so.?"
+          else
+            as_fn_error $? "Could not locate libffi.so.? for bundling" "$LINENO" 5
+          fi
+        else
+          # Fallback on the default /usr/lib dir
+          if test -e ${SYSROOT}/usr/lib/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/libffi.so.?"
+          else
+            as_fn_error $? "Could not locate libffi.so.? for bundling" "$LINENO" 5
+          fi
+        fi
+      fi
+      # Make sure the wildcard is evaluated
+      LIBFFI_LIB_FILE="$(ls ${LIBFFI_LIB_FILE})"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${LIBFFI_LIB_FILE}" >&5
+$as_echo "${LIBFFI_LIB_FILE}" >&6; }
+    fi
+  fi
+
+
 
 
 
--- a/common/autoconf/help.m4	Thu Dec 08 18:03:34 2016 +0000
+++ b/common/autoconf/help.m4	Thu Dec 08 21:21:16 2016 +0000
@@ -116,7 +116,7 @@
     ffi)
       PKGHANDLER_COMMAND="sudo apt-get install libffi-dev" ;;
     x11)
-      PKGHANDLER_COMMAND="sudo apt-get install libX11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev" ;;
+      PKGHANDLER_COMMAND="sudo apt-get install libx11-dev libxext-dev libxrender-dev libxtst-dev libxt-dev" ;;
     ccache)
       PKGHANDLER_COMMAND="sudo apt-get install ccache" ;;
     dtrace)
--- a/common/autoconf/jdk-version.m4	Thu Dec 08 18:03:34 2016 +0000
+++ b/common/autoconf/jdk-version.m4	Thu Dec 08 21:21:16 2016 +0000
@@ -160,11 +160,10 @@
     fi
   else
     if test "x$NO_DEFAULT_VERSION_PARTS" != xtrue; then
-      # Default is to calculate a string like this <timestamp>.<username>.<base dir name>
-      timestamp=`$DATE '+%Y-%m-%d-%H%M%S'`
+      # Default is to calculate a string like this 'adhoc.<username>.<base dir name>'
       # Outer [ ] to quote m4.
       [ basedirname=`$BASENAME "$TOPDIR" | $TR -d -c '[a-z][A-Z][0-9].-'` ]
-      VERSION_OPT="$timestamp.$USERNAME.$basedirname"
+      VERSION_OPT="adhoc.$USERNAME.$basedirname"
     fi
   fi
 
--- a/common/autoconf/lib-ffi.m4	Thu Dec 08 18:03:34 2016 +0000
+++ b/common/autoconf/lib-ffi.m4	Thu Dec 08 21:21:16 2016 +0000
@@ -35,6 +35,8 @@
       [specify directory for the libffi include files])])
   AC_ARG_WITH(libffi-lib, [AS_HELP_STRING([--with-libffi-lib],
       [specify directory for the libffi library])])
+  AC_ARG_ENABLE(libffi-bundling, [AS_HELP_STRING([--enable-libffi-bundling],
+      [enable bundling of libffi.so to make the built JDK runnable on more systems])])
 
   if test "x$NEEDS_LIB_FFI" = xfalse; then
     if (test "x${with_libffi}" != x && test "x${with_libffi}" != xno) || \
@@ -52,6 +54,7 @@
     fi
 
     if test "x${with_libffi}" != x; then
+      LIBFFI_LIB_PATH="${with_libffi}/lib"
       LIBFFI_LIBS="-L${with_libffi}/lib -lffi"
       LIBFFI_CFLAGS="-I${with_libffi}/include"
       LIBFFI_FOUND=yes
@@ -61,6 +64,7 @@
       LIBFFI_FOUND=yes
     fi
     if test "x${with_libffi_lib}" != x; then
+      LIBFFI_LIB_PATH="${with_libffi_lib}"
       LIBFFI_LIBS="-L${with_libffi_lib} -lffi"
       LIBFFI_FOUND=yes
     fi
@@ -109,8 +113,65 @@
       HELP_MSG_MISSING_DEPENDENCY([ffi])
       AC_MSG_ERROR([Found libffi but could not link and compile with it. $HELP_MSG])
     fi
+
+    AC_MSG_CHECKING([if libffi should be bundled])
+    if test "x$enable_libffi_bundling" = "x"; then
+      AC_MSG_RESULT([no])
+      ENABLE_LIBFFI_BUNDLING=false
+    elif  test "x$enable_libffi_bundling" = "xno"; then
+      AC_MSG_RESULT([no, forced])
+      ENABLE_LIBFFI_BUNDLING=false
+    elif  test "x$enable_libffi_bundling" = "xyes"; then
+      AC_MSG_RESULT([yes, forced])
+      ENABLE_LIBFFI_BUNDLING=true
+    else
+      AC_MSG_ERROR([Invalid value for --enable-libffi-bundling])
+    fi
+
+    # Find the libffi.so.X to bundle
+    if test "x${ENABLE_LIBFFI_BUNDLING}" = "xtrue"; then
+      AC_MSG_CHECKING([for libffi lib file location])
+      if test "x${LIBFFI_LIB_PATH}" != x; then
+        if test -e ${LIBFFI_LIB_PATH}/libffi.so.?; then
+          LIBFFI_LIB_FILE="${LIBFFI_LIB_PATH}/libffi.so.?"
+        else
+          AC_MSG_ERROR([Could not locate libffi.so.? for bundling in ${LIBFFI_LIB_PATH}])
+        fi
+      else
+        # If we don't have an explicit path, look in a few obvious places
+        if test "x${OPENJDK_TARGET_CPU}" = "xx86"; then
+          if test -e ${SYSROOT}/usr/lib/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/libffi.so.?"
+          elif test -e ${SYSROOT}/usr/lib/i386-linux-gnu/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/i386-linux-gnu/libffi.so.?"
+          else
+            AC_MSG_ERROR([Could not locate libffi.so.? for bundling])
+          fi
+        elif test "x${OPENJDK_TARGET_CPU}" = "xx86_64"; then
+          if test -e ${SYSROOT}/usr/lib64/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib64/libffi.so.?"
+          elif test -e ${SYSROOT}/usr/lib/x86_64-linux-gnu/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/x86_64-linux-gnu/libffi.so.?"
+          else
+            AC_MSG_ERROR([Could not locate libffi.so.? for bundling])
+          fi
+        else
+          # Fallback on the default /usr/lib dir
+          if test -e ${SYSROOT}/usr/lib/libffi.so.? ; then
+            LIBFFI_LIB_FILE="${SYSROOT}/usr/lib/libffi.so.?"
+          else
+            AC_MSG_ERROR([Could not locate libffi.so.? for bundling])
+          fi
+        fi
+      fi
+      # Make sure the wildcard is evaluated
+      LIBFFI_LIB_FILE="$(ls ${LIBFFI_LIB_FILE})"
+      AC_MSG_RESULT([${LIBFFI_LIB_FILE}])
+    fi
   fi
 
   AC_SUBST(LIBFFI_CFLAGS)
   AC_SUBST(LIBFFI_LIBS)
+  AC_SUBST(ENABLE_LIBFFI_BUNDLING)
+  AC_SUBST(LIBFFI_LIB_FILE)
 ])
--- a/common/autoconf/spec.gmk.in	Thu Dec 08 18:03:34 2016 +0000
+++ b/common/autoconf/spec.gmk.in	Thu Dec 08 21:21:16 2016 +0000
@@ -319,6 +319,8 @@
 ALSA_CFLAGS:=@ALSA_CFLAGS@
 LIBFFI_LIBS:=@LIBFFI_LIBS@
 LIBFFI_CFLAGS:=@LIBFFI_CFLAGS@
+ENABLE_LIBFFI_BUNDLING:=@ENABLE_LIBFFI_BUNDLING@
+LIBFFI_LIB_FILE:=@LIBFFI_LIB_FILE@
 
 PACKAGE_PATH=@PACKAGE_PATH@
 
--- a/common/conf/jib-profiles.js	Thu Dec 08 18:03:34 2016 +0000
+++ b/common/conf/jib-profiles.js	Thu Dec 08 21:21:16 2016 +0000
@@ -346,6 +346,35 @@
     // Generate debug profiles for the open jprt profiles
     profiles = concatObjects(profiles, generateDebugProfiles(common, openOnlyProfiles));
 
+    // Profiles for building the zero jvm variant. These are used for verification
+    // in JPRT.
+    var zeroProfiles = {
+        "linux-x64-zero": {
+            target_os: "linux",
+            target_cpu: "x64",
+            dependencies: concat(common.dependencies, "devkit"),
+            configure_args: concat(common.configure_args,
+                "--with-zlib=system",
+                "--with-jvm-variants=zero",
+                "--enable-libffi-bundling"),
+            default_make_targets: common.default_make_targets
+        },
+
+        "linux-x86-zero": {
+            target_os: "linux",
+            target_cpu: "x86",
+            build_cpu: "x64",
+            dependencies: concat(common.dependencies, "devkit"),
+            configure_args: concat(common.configure_args, common.configure_args_32bit,
+                "--with-zlib=system",
+                "--with-jvm-variants=zero",
+                "--enable-libffi-bundling"),
+            default_make_targets: common.default_make_targets
+        },
+    }
+    profiles = concatObjects(profiles, zeroProfiles);
+    profiles = concatObjects(profiles, generateDebugProfiles(common, zeroProfiles));
+
     // Profiles used to run tests. Used in JPRT.
     var testOnlyProfiles = {
 
@@ -380,7 +409,7 @@
         + (input.build_cpu == "x86" ? "i586" : input.build_cpu);
 
     var devkit_platform_revisions = {
-        linux_x64: "gcc4.9.2-OEL6.4+1.0",
+        linux_x64: "gcc4.9.2-OEL6.4+1.1",
         macosx_x64: "Xcode6.3-MacOSX10.9+1.0",
         solaris_x64: "SS12u4-Solaris11u1+1.0",
         solaris_sparcv9: "SS12u4-Solaris11u1+1.0",
--- a/make/common/MakeBase.gmk	Thu Dec 08 18:03:34 2016 +0000
+++ b/make/common/MakeBase.gmk	Thu Dec 08 21:21:16 2016 +0000
@@ -507,14 +507,18 @@
 	if [ -n "`$(XATTR) -l '$@'`" ]; then $(XATTR) -c '$@'; fi
   endef
 else
-  # Running mkdir and cp in the same shell speeds up copy intensive tasks in Cygwin
-  # significantly.
   define install-file
 	$(call MakeDir, $(@D))
 	$(CP) -fP '$<' '$@'
   endef
 endif
 
+# Variant of install file that does not preserve symlinks
+define install-file-nolink
+	$(call MakeDir, $(@D))
+	$(CP) -f '$<' '$@'
+endef
+
 ################################################################################
 # Take two paths and return the path of the last common directory.
 # Ex: /foo/bar/baz, /foo/bar/banan -> /foo/bar
--- a/make/devkit/Tools.gmk	Thu Dec 08 18:03:34 2016 +0000
+++ b/make/devkit/Tools.gmk	Thu Dec 08 21:21:16 2016 +0000
@@ -85,8 +85,8 @@
     libgcc \
     elfutils elfutils-libs elfutils-devel \
     elfutils-libelf elfutils-libelf-devel \
-    zlib zlib-devel
-
+    zlib zlib-devel \
+    libffi libffi-devel
 
 ifeq ($(ARCH),x86_64)
   RPM_DIR ?= $(RPM_DIR_x86_64)
@@ -209,6 +209,18 @@
 	@touch $@
 
 ##########################################################################################
+# Create links for ffi header files so that they become visible by default when using the
+# devkit.
+
+$(SYSROOT)/usr/include/ffi.h: $(rpms)
+	cd $(@D) && rm $(@F) && ln -s ../lib/libffi-*/include/$(@F) .
+
+$(SYSROOT)/usr/include/ffitarget.h: $(rpms)
+	cd $(@D) && rm $(@F) && ln -s ../lib/libffi-*/include/$(@F) .
+
+SYSROOT_LINKS += $(SYSROOT)/usr/include/ffi.h $(SYSROOT)/usr/include/ffitarget.h
+
+##########################################################################################
 
 # Define marker files for each source package to be compiled
 $(foreach t,binutils mpfr gmp mpc gcc ccache,$(eval $(t) = $(TARGETDIR)/$($(t)_ver).done))
@@ -496,7 +508,7 @@
 libs : $(libs)
 sysroot : rpms libs
 gcc : sysroot $(gcc) $(gccpatch)
-all : binutils gcc bfdlib $(PREFIX)/devkit.info $(missing-links)
+all : binutils gcc bfdlib $(PREFIX)/devkit.info $(missing-links) $(SYSROOT_LINKS)
 
 # this is only built for host. so separate.
 ccache : $(ccache)
--- a/make/jprt.properties	Thu Dec 08 18:03:34 2016 +0000
+++ b/make/jprt.properties	Thu Dec 08 21:21:16 2016 +0000
@@ -118,6 +118,12 @@
 jprt.windows_i586.fastdebugOpen.build.jib.profile=windows-x86-open-debug
 jprt.windows_x64.fastdebugOpen.build.jib.profile=windows-x64-open-debug
 
+jprt.linux_i586.productZero.build.jib.profile=linux-x86-zero
+jprt.linux_x64.productZero.build.jib.profile=linux-x64-zero
+
+jprt.linux_i586.fastdebugZero.build.jib.profile=linux-x86-zero-debug
+jprt.linux_x64.fastdebugZero.build.jib.profile=linux-x64-zero-debug
+
 jprt.test.jib.profile=run-test
 
 # Set make target to use for different build flavors
@@ -128,6 +134,8 @@
 jprt.build.flavor.optimized.target=jprt_bundle
 jprt.build.flavor.optimizedOpen.target=jprt_bundle
 jprt.build.flavor.slowdebug.target=jprt_bundle
+jprt.build.flavor.productZero.target=jprt_bundle
+jprt.build.flavor.fastdebugZero.target=jprt_bundle
 
 # Use these configure args to define debug level or provide specific
 # configuration details not covered by Jib profiles.
@@ -181,7 +189,7 @@
 jprt.build.configure.args=						\
     --with-output-sync=recurse						\
     --with-jobs=$ALT_PARALLEL_COMPILE_JOBS				\
-    --with-version-opt=$JPRT_JOB_ID				 	\
+    --with-version-opt=$JPRT_JOB_ID					\
     ${my.additional.build.configure.args.${jprt.test.set}}		\
     ${my.custom.build.configure.args}
 
@@ -481,15 +489,15 @@
 ################################################################################
 # Testset buildinfra
 my.build.flavors.buildinfra = \
-    product,fastdebug,slowdebug, \
+    product,fastdebug,slowdebug,productZero,fastdebugZero \
     ${my.additional.build.flavors.buildinfra}
 
 # Platforms built for hotspot push jobs
 my.build.targets.buildinfra = \
     solaris_sparcv9_5.11-{product|fastdebug|slowdebug}, \
     solaris_x64_5.11-{product|fastdebug|slowdebug}, \
-    linux_i586_3.8-{product|fastdebug|slowdebug}, \
-    linux_x64_3.8-{product|fastdebug|slowdebug}, \
+    linux_i586_3.8-{product|fastdebug|slowdebug|productZero|fastdebugZero}, \
+    linux_x64_3.8-{product|fastdebug|slowdebug|productZero|fastdebugZero}, \
     macosx_x64_10.9-{product|fastdebug|slowdebug}, \
     windows_i586_6.3-{product|fastdebug|slowdebug}, \
     windows_x64_6.3-{product|fastdebug|slowdebug}, \
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/TestCommon.gmk	Thu Dec 08 21:21:16 2016 +0000
@@ -0,0 +1,422 @@
+#
+# Copyright (c) 1995, 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.
+#
+
+#
+# Common logic to run various tests for a component, to be included by the
+# component specific test makefiles.
+#
+
+# Default values for some properties that can be overridden by components.
+USE_JTREG_VERSION ?= 4.2
+JTREG_VM_TYPE ?= -agentvm
+USE_JTREG_ASSERT ?= true
+LIMIT_JTREG_VM_MEMORY ?= true
+
+.DEFAULT : all
+
+# Empty these to get rid of some default rules
+.SUFFIXES:
+.SUFFIXES: .java
+CO=
+GET=
+
+# Utilities used
+AWK       = awk
+CAT       = cat
+CD        = cd
+CHMOD     = chmod
+CP        = cp
+CUT       = cut
+DIRNAME   = dirname
+ECHO      = echo
+EGREP     = egrep
+EXPAND    = expand
+FIND      = find
+MKDIR     = mkdir
+PWD       = pwd
+RM        = rm -f
+SED       = sed
+SORT      = sort
+TEE       = tee
+UNAME     = uname
+UNIQ      = uniq
+WC        = wc
+ZIPEXE    = zip
+
+# Get OS name from uname (Cygwin inexplicably adds _NT-5.1)
+UNAME_S := $(shell $(UNAME) -s | $(CUT) -f1 -d_)
+
+# Commands to run on paths to make mixed paths for java on windows
+ifeq ($(findstring CYGWIN,$(UNAME_S)), CYGWIN)
+  # Location of developer shared files
+  SLASH_JAVA = J:
+  GETMIXEDPATH = cygpath -m
+  PLATFORM = windows
+else
+  # Location of developer shared files
+  SLASH_JAVA = /java
+  GETMIXEDPATH = $(ECHO)
+  PLATFORM = unix # we only care about windows or bsd.
+  ifeq ($(UNAME_S), Darwin)
+    PLATFORM = bsd
+  endif
+  ifeq ($(findstring BSD,$(UNAME_S)), BSD)
+    PLATFORM = bsd
+  endif
+endif
+
+ifdef ALT_SLASH_JAVA
+  SLASH_JAVA = $(ALT_SLASH_JAVA)
+endif
+
+# Root of this test area (important to use full paths in some places)
+TEST_ROOT := $(shell $(PWD))
+
+# Root of all test results
+ifdef TEST_OUTPUT_DIR
+  $(shell $(MKDIR) -p $(TEST_OUTPUT_DIR)/jtreg)
+  ABS_TEST_OUTPUT_DIR := \
+    $(shell $(CD) $(TEST_OUTPUT_DIR)/jtreg && $(PWD))
+else
+  ifdef ALT_OUTPUTDIR
+    ABS_OUTPUTDIR = $(shell $(CD) $(ALT_OUTPUTDIR) && $(PWD))
+  else
+    ABS_OUTPUTDIR = $(shell $(CD) $(TEST_ROOT)/.. && $(PWD))
+  endif
+
+  ABS_PLATFORM_BUILD_ROOT = $(ABS_OUTPUTDIR)
+  ABS_TEST_OUTPUT_DIR := $(ABS_PLATFORM_BUILD_ROOT)/testoutput/$(UNIQUE_DIR)
+endif
+
+# Expect JPRT to set PRODUCT_HOME (the product or jdk in this case to test)
+ifndef PRODUCT_HOME
+  # Try to use images/jdk if it exists
+  ABS_JDK_IMAGE = $(ABS_PLATFORM_BUILD_ROOT)/images/jdk
+  PRODUCT_HOME :=                               \
+    $(shell                                     \
+      if [ -d $(ABS_JDK_IMAGE) ] ; then         \
+         $(ECHO) "$(ABS_JDK_IMAGE)";            \
+       else                                     \
+         $(ECHO) "$(ABS_PLATFORM_BUILD_ROOT)";  \
+       fi)
+  PRODUCT_HOME := $(PRODUCT_HOME)
+endif
+
+# Expect JPRT to set JAVA_ARGS (e.g. -server etc.)
+ifdef JAVA_ARGS
+  JAVA_OPTIONS := $(JAVA_ARGS)
+else
+  JAVA_OPTIONS :=
+endif
+
+# Expect JPRT to set JPRT_PRODUCT_ARGS (e.g. -server etc.)
+#   Should be passed into 'java' only.
+#   Could include: -d64 -server -client OR any java option
+ifdef JPRT_PRODUCT_ARGS
+  JAVA_ARGS = $(JPRT_PRODUCT_ARGS)
+endif
+
+# Expect JPRT to set JPRT_PRODUCT_VM_ARGS (e.g. -Xcomp etc.)
+#   Should be passed into anything running the vm (java, javac, javadoc, ...).
+ifdef JPRT_PRODUCT_VM_ARGS
+  JAVA_VM_ARGS = $(JPRT_PRODUCT_VM_ARGS)
+endif
+
+ifneq ($(NATIVE_TEST_PATH), )
+  # jtreg -nativepath <dir>
+  #
+  # Local make tests will be TEST_IMAGE_DIR and JPRT with jprt.use.reg.test.bundle=true
+  # should be JPRT_TESTNATIVE_PATH
+  ifdef TEST_IMAGE_DIR
+    TESTNATIVE_DIR = $(TEST_IMAGE_DIR)
+  else ifdef JPRT_TESTNATIVE_PATH
+    TESTNATIVE_DIR = $(JPRT_TESTNATIVE_PATH)
+  endif
+  ifdef TESTNATIVE_DIR
+    JTREG_NATIVE_PATH = -nativepath:$(shell $(GETMIXEDPATH) "$(TESTNATIVE_DIR)/$(NATIVE_TEST_PATH)")
+  endif
+endif
+
+ifeq ($(USE_FAILURE_HANDLER), true)
+  # jtreg failure handler config
+  ifeq ($(FAILURE_HANDLER_DIR), )
+    ifneq ($(TESTNATIVE_DIR), )
+      FAILURE_HANDLER_DIR := $(TESTNATIVE_DIR)/failure_handler
+    endif
+  endif
+  ifneq ($(FAILURE_HANDLER_DIR), )
+    FAILURE_HANDLER_DIR_MIXED := $(shell $(GETMIXEDPATH) "$(FAILURE_HANDLER_DIR)")
+    JTREG_FAILURE_HANDLER_OPTIONS := \
+        -timeoutHandlerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \
+        -observerDir:$(FAILURE_HANDLER_DIR_MIXED)/jtregFailureHandler.jar \
+        -timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
+        -observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
+        -timeoutHandlerTimeout:0
+  ifeq ($(PLATFORM), windows)
+      JTREG_FAILURE_HANDLER_OPTIONS += -J-Djava.library.path="$(FAILURE_HANDLER_DIR_MIXED)"
+    endif
+  endif
+endif
+
+# Expect JPRT to set JPRT_ARCHIVE_BUNDLE (path to zip bundle for results)
+ifdef JPRT_ARCHIVE_BUNDLE
+  ARCHIVE_BUNDLE = $(JPRT_ARCHIVE_BUNDLE)
+else
+  ARCHIVE_BUNDLE = $(ABS_TEST_OUTPUT_DIR)/ARCHIVE_BUNDLE.zip
+endif
+
+# How to create the test bundle (pass or fail, we want to create this)
+#   Follow command with ";$(BUNDLE_UP_AND_EXIT)", so it always gets executed.
+ZIP_UP_RESULTS = ( $(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`     \
+	           && $(CD) $(ABS_TEST_OUTPUT_DIR)             \
+	           && $(CHMOD) -R a+r . \
+	           && $(ZIPEXE) -q -r $(ARCHIVE_BUNDLE) . )
+
+# important results files
+SUMMARY_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport/text/summary.txt")
+STATS_TXT_NAME = Stats.txt
+STATS_TXT = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/$(STATS_TXT_NAME)")
+RUNLIST   = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/runlist.txt")
+PASSLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/passlist.txt")
+FAILLIST  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/faillist.txt")
+EXITCODE  = $(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/exitcode.txt")
+
+TESTEXIT = \
+  if [ ! -s $(EXITCODE) ] ; then \
+    $(ECHO) "ERROR: EXITCODE file not filled in."; \
+    $(ECHO) "1" > $(EXITCODE); \
+  fi ; \
+  testExitCode=`$(CAT) $(EXITCODE)`; \
+  $(ECHO) "EXIT CODE: $${testExitCode}"; \
+  exit $${testExitCode}
+
+ifeq ($(TREAT_EXIT_CODE_1_AS_0), true)
+  ADJUST_EXIT_CODE := \
+  if [ $${jtregExitCode} = 1 ] ; then \
+    jtregExitCode=0; \
+  fi
+else
+  # colon is the shell no-op
+  ADJUST_EXIT_CODE := :
+endif
+
+BUNDLE_UP_AND_EXIT = \
+( \
+  jtregExitCode=$$? && \
+  _summary="$(SUMMARY_TXT)"; \
+  $(ADJUST_EXIT_CODE) ; \
+  $(RM) -f $(STATS_TXT) $(RUNLIST) $(PASSLIST) $(FAILLIST) $(EXITCODE); \
+  $(ECHO) "$${jtregExitCode}" > $(EXITCODE); \
+  if [ -r "$${_summary}" ] ; then \
+    $(ECHO) "Summary: $(UNIQUE_DIR)" > $(STATS_TXT); \
+    $(EXPAND) $${_summary} | $(EGREP) -v ' Not run\.' > $(RUNLIST); \
+    $(EGREP) ' Passed\.' $(RUNLIST) \
+      | $(EGREP) -v ' Error\.' \
+      | $(EGREP) -v ' Failed\.' > $(PASSLIST); \
+    ( $(EGREP) ' Failed\.' $(RUNLIST); \
+      $(EGREP) ' Error\.' $(RUNLIST); \
+      $(EGREP) -v ' Passed\.' $(RUNLIST) ) \
+      | $(SORT) | $(UNIQ) > $(FAILLIST); \
+    if [ $${jtregExitCode} != 0 -o -s $(FAILLIST) ] ; then \
+      $(EXPAND) $(FAILLIST) \
+        | $(CUT) -d' ' -f1 \
+        | $(SED) -e 's@^@FAILED: @' >> $(STATS_TXT); \
+      if [ $${jtregExitCode} = 0 ] ; then \
+        jtregExitCode=1; \
+      fi; \
+    fi; \
+    runc="`$(CAT) $(RUNLIST)      | $(WC) -l | $(AWK) '{print $$1;}'`"; \
+    passc="`$(CAT) $(PASSLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
+    failc="`$(CAT) $(FAILLIST)    | $(WC) -l | $(AWK) '{print $$1;}'`"; \
+    exclc="FIXME CODETOOLS-7900176"; \
+    $(ECHO) "TEST STATS: name=$(UNIQUE_DIR)  run=$${runc}  pass=$${passc}  fail=$${failc}" \
+      >> $(STATS_TXT); \
+  else \
+    $(ECHO) "Missing file: $${_summary}" >> $(STATS_TXT); \
+  fi; \
+  if [ -f $(STATS_TXT) ] ; then \
+    $(CAT) $(STATS_TXT); \
+  fi; \
+  $(ZIP_UP_RESULTS) ; \
+  $(TESTEXIT) \
+)
+
+################################################################
+
+# Prep for output
+# Change execute permissions on shared library files.
+# Files in repositories should never have execute permissions, but
+# there are some tests that have pre-built shared libraries, and these
+# windows dll files must have execute permission. Adding execute
+# permission may happen automatically on windows when using certain
+# versions of mercurial but it cannot be guaranteed. And blindly
+# adding execute permission might be seen as a mercurial 'change', so
+# we avoid adding execute permission to repository files. But testing
+# from a plain source tree needs the chmod a+rx. Applying the chmod to
+# all shared libraries not just dll files. And with CYGWIN and sshd
+# service, you may need CYGWIN=ntsec for this to work.
+prep:
+	@$(MKDIR) -p $(ABS_TEST_OUTPUT_DIR)
+	@$(MKDIR) -p `$(DIRNAME) $(ARCHIVE_BUNDLE)`
+	@if [ ! -d $(TEST_ROOT)/../.hg ] ; then                                   \
+	  $(FIND) $(TEST_ROOT) \( -name \*.dll -o -name \*.DLL -o -name \*.so \)  \
+	        -exec $(CHMOD) a+rx {} \; ;                                       \
+	fi
+
+ifeq ($(CLEAN_BEFORE_PREP), true)
+prep: clean
+
+endif
+
+# Cleanup
+clean:
+	@$(RM) -r $(ABS_TEST_OUTPUT_DIR)
+	@$(RM) $(ARCHIVE_BUNDLE)
+
+################################################################
+
+# jtreg tests
+
+# Expect JT_HOME to be set for jtreg tests. (home for jtreg)
+ifndef JT_HOME
+  JT_HOME = $(SLASH_JAVA)/re/jtreg/$(USE_JTREG_VERSION)/promoted/latest/binaries/jtreg
+  ifdef JPRT_JTREG_HOME
+    JT_HOME = $(JPRT_JTREG_HOME)
+  endif
+endif
+
+# Problematic tests to be excluded
+PROBLEM_LISTS=$(call MixedDirs,$(wildcard ProblemList.txt closed/ProblemList.txt))
+
+# Create exclude list for this platform and arch
+ifdef NO_EXCLUDES
+  JTREG_EXCLUSIONS =
+else
+  JTREG_EXCLUSIONS = $(PROBLEM_LISTS:%=-exclude:%)
+endif
+
+# convert list of directories to dos paths
+define MixedDirs
+$(foreach i,$1,$(shell $(GETMIXEDPATH) "${i}"))
+endef
+
+# ------------------------------------------------------------------
+
+# When called from JPRT the TESTDIRS variable is set to the jtreg tests to run
+ifdef TESTDIRS
+  TEST_SELECTION = $(TESTDIRS)
+endif
+
+ifdef CONCURRENCY
+  JTREG_BASIC_OPTIONS += -concurrency:$(CONCURRENCY)
+endif
+ifdef EXTRA_JTREG_OPTIONS
+  JTREG_BASIC_OPTIONS += $(EXTRA_JTREG_OPTIONS)
+endif
+
+# Default JTREG to run
+JTREG = $(JT_HOME)/bin/jtreg
+# run in agentvm/othervm mode
+JTREG_BASIC_OPTIONS += $(JTREG_VM_TYPE)
+# Only run automatic tests
+JTREG_BASIC_OPTIONS += -a
+# Always turn on assertions
+ifeq ($(USE_JTREG_ASSERT), true)
+  JTREG_ASSERT_OPTION = -ea -esa
+endif
+JTREG_BASIC_OPTIONS += $(JTREG_ASSERT_OPTION)
+# jtreg verbosity setting
+# Default is to report details on all failed or error tests, times too
+JTREG_VERBOSE ?= fail,error,time
+JTREG_BASIC_OPTIONS += $(if $(JTREG_VERBOSE),-v:$(JTREG_VERBOSE))
+# Retain all files for failing tests
+JTREG_BASIC_OPTIONS += -retain:fail,error
+# Ignore tests are not run and completely silent about it
+JTREG_IGNORE_OPTION = -ignore:quiet
+JTREG_BASIC_OPTIONS += $(JTREG_IGNORE_OPTION)
+# Multiply by 4 the timeout factor
+JTREG_TIMEOUT_OPTION =  -timeoutFactor:4
+JTREG_BASIC_OPTIONS += $(JTREG_TIMEOUT_OPTION)
+ifeq ($(LIMIT_JTREG_VM_MEMORY), true)
+  # Set the max memory for jtreg control vm
+  JTREG_MEMORY_OPTION = -J-Xmx512m
+  JTREG_BASIC_OPTIONS += $(JTREG_MEMORY_OPTION)
+  # Set the max memory for jtreg target test vms
+  JTREG_TESTVM_MEMORY_OPTION = -vmoption:-Xmx512m
+  JTREG_TEST_OPTIONS += $(JTREG_TESTVM_MEMORY_OPTION)
+endif
+# Give tests access to JT_JAVA, see JDK-8141609
+JTREG_BASIC_OPTIONS += -e:JDK8_HOME=${JT_JAVA}
+# Set other vm and test options
+JTREG_TEST_OPTIONS = $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_OPTIONS:%=-vmoption:%) $(JAVA_VM_ARGS:%=-vmoption:%)
+
+ifeq ($(IGNORE_MARKED_TESTS), true)
+  # Option to tell jtreg to not run tests marked with "ignore"
+  ifeq ($(PLATFORM), windows)
+    JTREG_KEY_OPTION = -k:!ignore
+  else
+    JTREG_KEY_OPTION = -k:\!ignore
+  endif
+  JTREG_BASIC_OPTIONS += $(JTREG_KEY_OPTION)
+endif
+
+# Make sure jtreg exists
+ifeq ($(USE_WINDOWS_EXISTENCE_CHECK), true)
+  jtreg_exists:
+	test -d $(shell $(GETMIXEDPATH) "$(JT_HOME)")
+	test -f $(shell $(GETMIXEDPATH) "$(JTREG)")
+
+else
+  jtreg_exists: $(JT_HOME)
+endif
+PHONY_LIST += jtreg_exists
+
+# Run jtreg
+jtreg_tests: prep jtreg_exists $(PRODUCT_HOME)
+	(                                                                    \
+	  ( JT_HOME=$(shell $(GETMIXEDPATH) "$(JT_HOME)");                   \
+	    export JT_HOME;                                                  \
+	    $(shell $(GETMIXEDPATH) "$(JTREG)")                              \
+	      $(JTREG_BASIC_OPTIONS)                                         \
+	      -r:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTreport")  \
+	      -w:$(shell $(GETMIXEDPATH) "$(ABS_TEST_OUTPUT_DIR)/JTwork")    \
+	      -jdk:$(shell $(GETMIXEDPATH) "$(PRODUCT_HOME)")                \
+	      $(JTREG_NATIVE_PATH)                                           \
+	      $(JTREG_FAILURE_HANDLER_OPTIONS)                               \
+	      $(JTREG_EXCLUSIONS)                                            \
+	      $(JTREG_TEST_OPTIONS)                                          \
+	      $(TEST_SELECTION)                                              \
+	  ) ;                                                                \
+	  $(BUNDLE_UP_AND_EXIT)                                              \
+	) 2>&1 | $(TEE) $(ABS_TEST_OUTPUT_DIR)/output.txt ; $(TESTEXIT)
+
+PHONY_LIST += jtreg_tests
+
+################################################################
+
+# Phony targets (e.g. these are not filenames)
+.PHONY: all clean prep $(PHONY_LIST)
+
+################################################################