# HG changeset patch # User jwilhelm # Date 1496942282 -7200 # Node ID 0444b69aad040a90b0514ac846330f4b30109264 # Parent 036dbf8b381798e5d31065109714d04d97bf98a4# Parent 59ae25e5d4b9866e91b642f72cb651f8171b28c3 Merge diff -r 036dbf8b3817 -r 0444b69aad04 common/autoconf/configure.ac --- a/common/autoconf/configure.ac Wed Jul 05 23:37:13 2017 +0200 +++ b/common/autoconf/configure.ac Thu Jun 08 19:18:02 2017 +0200 @@ -187,6 +187,9 @@ # Setup the JTReg Regression Test Harness. TOOLCHAIN_SETUP_JTREG +# Setup Jib dependency tool +TOOLCHAIN_SETUP_JIB + FLAGS_SETUP_INIT_FLAGS # Now we can test some aspects on the target using configure macros. diff -r 036dbf8b3817 -r 0444b69aad04 common/autoconf/flags.m4 --- a/common/autoconf/flags.m4 Wed Jul 05 23:37:13 2017 +0200 +++ b/common/autoconf/flags.m4 Thu Jun 08 19:18:02 2017 +0200 @@ -760,6 +760,19 @@ [ FLAGS_SETUP_ABI_PROFILE + + # Optional POSIX functionality needed by the JVM + # + # Check if clock_gettime is available and in which library. This indicates + # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so + # don't let it update LIBS. + save_LIBS="$LIBS" + AC_SEARCH_LIBS(clock_gettime, rt, [HAS_CLOCK_GETTIME=true], []) + if test "x$LIBS" = "x-lrt "; then + CLOCK_GETTIME_IN_LIBRT=true + fi + LIBS="$save_LIBS" + FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER([TARGET]) FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER([BUILD], [OPENJDK_BUILD_]) @@ -981,6 +994,16 @@ $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK -DDEBUG" fi + # Optional POSIX functionality needed by the VM + + if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then + $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DSUPPORTS_CLOCK_MONOTONIC" + if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then + $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DNEEDS_LIBRT" + fi + fi + + # Set some additional per-OS defines. if test "x$OPENJDK_$1_OS" = xlinux; then $2JVM_CFLAGS="[$]$2JVM_CFLAGS -DLINUX" diff -r 036dbf8b3817 -r 0444b69aad04 common/autoconf/generated-configure.sh --- a/common/autoconf/generated-configure.sh Wed Jul 05 23:37:13 2017 +0200 +++ b/common/autoconf/generated-configure.sh Thu Jun 08 19:18:02 2017 +0200 @@ -663,8 +663,6 @@ JVM_FEATURES_client JVM_FEATURES_server INCLUDE_GRAAL -ELF_LIBS -ELF_CFLAGS STLPORT_LIB LIBZIP_CAN_USE_MMAP LIBDL @@ -788,6 +786,7 @@ COMPILER_BINDCMD_FILE_FLAG COMPILER_COMMAND_FILE_FLAG COMPILER_TARGET_BITS_FLAG +JIB_JAR JT_HOME JTREGEXE HOTSPOT_TOOLCHAIN_TYPE @@ -1180,6 +1179,7 @@ with_toolchain_version with_build_devkit with_jtreg +with_jib with_abi_profile enable_warnings_as_errors with_native_debug_symbols @@ -1215,9 +1215,6 @@ with_dxsdk with_dxsdk_lib with_dxsdk_include -with_libelf -with_libelf_include -with_libelf_lib with_jvm_features with_jvm_interpreter enable_jtreg_failure_handler @@ -1347,8 +1344,6 @@ PNG_LIBS LCMS_CFLAGS LCMS_LIBS -ELF_CFLAGS -ELF_LIBS ICECC_CMD ICECC_CREATE_ENV ICECC_WRAPPER @@ -2126,6 +2121,7 @@ dependent] --with-build-devkit Devkit to use for the build platform toolchain --with-jtreg Regression Test Harness [probed] + --with-jib Jib dependency management tool [not used] --with-abi-profile specify ABI profile for ARM builds (arm-vfp-sflt,arm-vfp-hflt,arm-sflt, armv5-vfp-sflt,armv6-vfp-hflt,arm64,aarch64) @@ -2179,11 +2175,6 @@ compatibility and is ignored --with-dxsdk-include Deprecated. Option is kept for backwards compatibility and is ignored - --with-libelf specify prefix directory for the libelf package - (expecting the libraries under PATH/lib and the - headers under PATH/include) - --with-libelf-include specify directory for the libelf include files - --with-libelf-lib specify directory for the libelf library --with-jvm-features additional JVM features to enable (separated by comma), use '--help' to show possible values [none] --with-jvm-interpreter Deprecated. Option is kept for backwards @@ -2320,8 +2311,6 @@ PNG_LIBS linker flags for PNG, overriding pkg-config LCMS_CFLAGS C compiler flags for LCMS, overriding pkg-config LCMS_LIBS linker flags for LCMS, overriding pkg-config - ELF_CFLAGS C compiler flags for ELF, overriding pkg-config - ELF_LIBS linker flags for ELF, overriding pkg-config ICECC_CMD Override default value for ICECC_CMD ICECC_CREATE_ENV Override default value for ICECC_CREATE_ENV @@ -4509,7 +4498,7 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -4786,36 +4775,6 @@ ################################################################################ -# -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -################################################################################ -# Setup libelf (ELF library) -################################################################################ - - ################################################################################ # Determine which libraries are needed for this configuration @@ -4954,7 +4913,7 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -5085,6 +5044,9 @@ # Setup the JTReg Regression Test Harness. +# Setup the JIB dependency resolver + + # # Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -5186,7 +5148,7 @@ #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1494858828 +DATE_WHEN_GENERATED=1496941901 ############################################################################### # @@ -49517,6 +49479,41 @@ +# Setup Jib dependency tool + + +# Check whether --with-jib was given. +if test "${with_jib+set}" = set; then : + withval=$with_jib; +fi + + + if test "x$with_jib" = xno || test "x$with_jib" = x; then + # jib disabled + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jib" >&5 +$as_echo_n "checking for jib... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + elif test "x$with_jib" = xyes; then + as_fn_error $? "Must supply a value to --with-jib" "$LINENO" 5 + else + JIB_HOME="${with_jib}" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jib" >&5 +$as_echo_n "checking for jib... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${JIB_HOME}" >&5 +$as_echo "${JIB_HOME}" >&6; } + if test ! -d "${JIB_HOME}"; then + as_fn_error $? "--with-jib must be a directory" "$LINENO" 5 + fi + JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar) + if test ! -f "${JIB_JAR}"; then + as_fn_error $? "Could not find jib jar file in ${JIB_HOME}" "$LINENO" 5 + fi + fi + + + + # COMPILER_TARGET_BITS_FLAG : option for selecting 32- or 64-bit output # COMPILER_COMMAND_FILE_FLAG : option for passing a command file to the compiler @@ -51059,6 +51056,74 @@ fi + # Optional POSIX functionality needed by the JVM + # + # Check if clock_gettime is available and in which library. This indicates + # availability of CLOCK_MONOTONIC for hotspot. But we don't need to link, so + # don't let it update LIBS. + save_LIBS="$LIBS" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5 +$as_echo_n "checking for library containing clock_gettime... " >&6; } +if ${ac_cv_search_clock_gettime+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char clock_gettime (); +int +main () +{ +return clock_gettime (); + ; + return 0; +} +_ACEOF +for ac_lib in '' rt; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_cxx_try_link "$LINENO"; then : + ac_cv_search_clock_gettime=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_clock_gettime+:} false; then : + break +fi +done +if ${ac_cv_search_clock_gettime+:} false; then : + +else + ac_cv_search_clock_gettime=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5 +$as_echo "$ac_cv_search_clock_gettime" >&6; } +ac_res=$ac_cv_search_clock_gettime +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + HAS_CLOCK_GETTIME=true +fi + + if test "x$LIBS" = "x-lrt "; then + CLOCK_GETTIME_IN_LIBRT=true + fi + LIBS="$save_LIBS" + + # Special extras... if test "x$TOOLCHAIN_TYPE" = xsolstudio; then if test "x$OPENJDK_TARGET_CPU_ARCH" = "xsparc"; then @@ -51443,6 +51508,16 @@ COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK -DDEBUG" fi + # Optional POSIX functionality needed by the VM + + if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then + JVM_CFLAGS="$JVM_CFLAGS -DSUPPORTS_CLOCK_MONOTONIC" + if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then + JVM_CFLAGS="$JVM_CFLAGS -DNEEDS_LIBRT" + fi + fi + + # Set some additional per-OS defines. if test "x$OPENJDK_TARGET_OS" = xlinux; then JVM_CFLAGS="$JVM_CFLAGS -DLINUX" @@ -52261,6 +52336,16 @@ OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK -DDEBUG" fi + # Optional POSIX functionality needed by the VM + + if test "x$HAS_CLOCK_GETTIME" = "xtrue"; then + OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -DSUPPORTS_CLOCK_MONOTONIC" + if test "x$CLOCK_GETTIME_IN_LIBRT" = "xtrue"; then + OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -DNEEDS_LIBRT" + fi + fi + + # Set some additional per-OS defines. if test "x$OPENJDK_BUILD_OS" = xlinux; then OPENJDK_BUILD_JVM_CFLAGS="$OPENJDK_BUILD_JVM_CFLAGS -DLINUX" @@ -53890,8 +53975,8 @@ fi if test "x$ENABLE_AOT" = "xtrue"; then - # Only enable AOT on linux-X64. - if test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-x86_64"; then + # Only enable AOT on X64 platforms. + if test "x$OPENJDK_TARGET_OS" != "xwindows" && test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then if test -e "$HOTSPOT_TOPDIR/src/jdk.aot"; then if test -e "$HOTSPOT_TOPDIR/src/jdk.internal.vm.compiler"; then ENABLE_AOT="true" @@ -53910,7 +53995,7 @@ else ENABLE_AOT="false" if test "x$enable_aot" = "xyes"; then - as_fn_error $? "AOT is currently only supported on Linux-x86_64. Remove --enable-aot." "$LINENO" 5 + as_fn_error $? "AOT is currently only supported on x86_64. Remove --enable-aot." "$LINENO" 5 fi fi fi @@ -65247,286 +65332,6 @@ -# Check whether --with-libelf was given. -if test "${with_libelf+set}" = set; then : - withval=$with_libelf; -fi - - -# Check whether --with-libelf-include was given. -if test "${with_libelf_include+set}" = set; then : - withval=$with_libelf_include; -fi - - -# Check whether --with-libelf-lib was given. -if test "${with_libelf_lib+set}" = set; then : - withval=$with_libelf_lib; -fi - - - if test "x$ENABLE_AOT" = xfalse; then - if (test "x${with_libelf}" != x && test "x${with_libelf}" != xno) || \ - (test "x${with_libelf_include}" != x && test "x${with_libelf_include}" != xno) || \ - (test "x${with_libelf_lib}" != x && test "x${with_libelf_lib}" != xno); then - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libelf is not used, so --with-libelf[-*] is ignored" >&5 -$as_echo "$as_me: WARNING: libelf is not used, so --with-libelf[-*] is ignored" >&2;} - fi - LIBELF_CFLAGS= - LIBELF_LIBS= - else - LIBELF_FOUND=no - - if test "x${with_libelf}" = xno || test "x${with_libelf_include}" = xno || test "x${with_libelf_lib}" = xno; then - ENABLE_AOT="false" - if test "x${enable_aot}" = xyes; then - as_fn_error $? "libelf is explicitly disabled, cannot build AOT. Enable libelf or remove --enable-aot to disable AOT." "$LINENO" 5 - fi - else - if test "x${with_libelf}" != x; then - ELF_LIBS="-L${with_libelf}/lib -lelf" - ELF_CFLAGS="-I${with_libelf}/include" - LIBELF_FOUND=yes - fi - if test "x${with_libelf_include}" != x; then - ELF_CFLAGS="-I${with_libelf_include}" - LIBELF_FOUND=yes - fi - if test "x${with_libelf_lib}" != x; then - ELF_LIBS="-L${with_libelf_lib} -lelf" - LIBELF_FOUND=yes - fi - # Do not try pkg-config if we have a sysroot set. - if test "x$SYSROOT" = x; then - if test "x$LIBELF_FOUND" = xno; then - # Figure out ELF_CFLAGS and ELF_LIBS - -pkg_failed=no -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ELF" >&5 -$as_echo_n "checking for ELF... " >&6; } - -if test -n "$ELF_CFLAGS"; then - pkg_cv_ELF_CFLAGS="$ELF_CFLAGS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libelf\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libelf") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_ELF_CFLAGS=`$PKG_CONFIG --cflags "libelf" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi -if test -n "$ELF_LIBS"; then - pkg_cv_ELF_LIBS="$ELF_LIBS" - elif test -n "$PKG_CONFIG"; then - if test -n "$PKG_CONFIG" && \ - { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"libelf\""; } >&5 - ($PKG_CONFIG --exists --print-errors "libelf") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; then - pkg_cv_ELF_LIBS=`$PKG_CONFIG --libs "libelf" 2>/dev/null` -else - pkg_failed=yes -fi - else - pkg_failed=untried -fi - - - -if test $pkg_failed = yes; then - -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi - if test $_pkg_short_errors_supported = yes; then - ELF_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors "libelf" 2>&1` - else - ELF_PKG_ERRORS=`$PKG_CONFIG --print-errors "libelf" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$ELF_PKG_ERRORS" >&5 - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - LIBELF_FOUND=no -elif test $pkg_failed = untried; then - LIBELF_FOUND=no -else - ELF_CFLAGS=$pkg_cv_ELF_CFLAGS - ELF_LIBS=$pkg_cv_ELF_LIBS - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - LIBELF_FOUND=yes -fi - fi - fi - if test "x$LIBELF_FOUND" = xno; then - for ac_header in libelf.h -do : - ac_fn_cxx_check_header_mongrel "$LINENO" "libelf.h" "ac_cv_header_libelf_h" "$ac_includes_default" -if test "x$ac_cv_header_libelf_h" = xyes; then : - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBELF_H 1 -_ACEOF - - LIBELF_FOUND=yes - ELF_CFLAGS= - ELF_LIBS=-lelf - -else - LIBELF_FOUND=no - -fi - -done - - fi - if test "x$LIBELF_FOUND" = xno; then - ENABLE_AOT="false" - - # Print a helpful message on how to acquire the necessary build dependency. - # elf is the help tag: freetype, cups, alsa etc - MISSING_DEPENDENCY=elf - - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - cygwin_help $MISSING_DEPENDENCY - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - msys_help $MISSING_DEPENDENCY - else - PKGHANDLER_COMMAND= - - case $PKGHANDLER in - apt-get) - apt_help $MISSING_DEPENDENCY ;; - yum) - yum_help $MISSING_DEPENDENCY ;; - brew) - brew_help $MISSING_DEPENDENCY ;; - port) - port_help $MISSING_DEPENDENCY ;; - pkgutil) - pkgutil_help $MISSING_DEPENDENCY ;; - pkgadd) - pkgadd_help $MISSING_DEPENDENCY ;; - esac - - if test "x$PKGHANDLER_COMMAND" != x; then - HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." - fi - fi - - if test "x${enable_aot}" = xyes; then - as_fn_error $? "libelf not found, cannot build AOT. Remove --enable-aot to disable AOT or: $HELP_MSG" "$LINENO" 5 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: libelf not found, cannot build AOT. $HELP_MSG" >&5 -$as_echo "$as_me: WARNING: libelf not found, cannot build AOT. $HELP_MSG" >&2;} - fi - else - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libelf works" >&5 -$as_echo_n "checking if libelf works... " >&6; } - ac_ext=c -ac_cpp='$CPP $CPPFLAGS' -ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_c_compiler_gnu - - OLD_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $ELF_CFLAGS" - OLD_LIBS="$LIBS" - LIBS="$LIBS $ELF_LIBS" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ -#include -int -main () -{ - - elf_version(0); - return 0; - - ; - return 0; -} -_ACEOF -if ac_fn_c_try_link "$LINENO"; then : - LIBELF_WORKS=yes -else - LIBELF_WORKS=no - -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext conftest.$ac_ext - CFLAGS="$OLD_CFLAGS" - LIBS="$OLD_LIBS" - ac_ext=cpp -ac_cpp='$CXXCPP $CPPFLAGS' -ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5' -ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' -ac_compiler_gnu=$ac_cv_cxx_compiler_gnu - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIBELF_WORKS" >&5 -$as_echo "$LIBELF_WORKS" >&6; } - - if test "x$LIBELF_WORKS" = xno; then - ENABLE_AOT="false" - - # Print a helpful message on how to acquire the necessary build dependency. - # elf is the help tag: freetype, cups, alsa etc - MISSING_DEPENDENCY=elf - - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - cygwin_help $MISSING_DEPENDENCY - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - msys_help $MISSING_DEPENDENCY - else - PKGHANDLER_COMMAND= - - case $PKGHANDLER in - apt-get) - apt_help $MISSING_DEPENDENCY ;; - yum) - yum_help $MISSING_DEPENDENCY ;; - brew) - brew_help $MISSING_DEPENDENCY ;; - port) - port_help $MISSING_DEPENDENCY ;; - pkgutil) - pkgutil_help $MISSING_DEPENDENCY ;; - pkgadd) - pkgadd_help $MISSING_DEPENDENCY ;; - esac - - if test "x$PKGHANDLER_COMMAND" != x; then - HELP_MSG="You might be able to fix this by running '$PKGHANDLER_COMMAND'." - fi - fi - - if test "x$enable_aot" = "xyes"; then - as_fn_error $? "Found libelf but could not link and compile with it. Remove --enable-aot to disable AOT or: $HELP_MSG" "$LINENO" 5 - else - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Found libelf but could not link and compile with it. $HELP_MSG" >&5 -$as_echo "$as_me: WARNING: Found libelf but could not link and compile with it. $HELP_MSG" >&2;} - fi - fi - fi - fi - fi - - - - - - - diff -r 036dbf8b3817 -r 0444b69aad04 common/autoconf/hotspot.m4 --- a/common/autoconf/hotspot.m4 Wed Jul 05 23:37:13 2017 +0200 +++ b/common/autoconf/hotspot.m4 Thu Jun 08 19:18:02 2017 +0200 @@ -212,8 +212,8 @@ fi if test "x$ENABLE_AOT" = "xtrue"; then - # Only enable AOT on linux-X64. - if test "x$OPENJDK_TARGET_OS-$OPENJDK_TARGET_CPU" = "xlinux-x86_64"; then + # Only enable AOT on X64 platforms. + if test "x$OPENJDK_TARGET_OS" != "xwindows" && test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then if test -e "$HOTSPOT_TOPDIR/src/jdk.aot"; then if test -e "$HOTSPOT_TOPDIR/src/jdk.internal.vm.compiler"; then ENABLE_AOT="true" @@ -232,7 +232,7 @@ else ENABLE_AOT="false" if test "x$enable_aot" = "xyes"; then - AC_MSG_ERROR([AOT is currently only supported on Linux-x86_64. Remove --enable-aot.]) + AC_MSG_ERROR([AOT is currently only supported on x86_64. Remove --enable-aot.]) fi fi fi diff -r 036dbf8b3817 -r 0444b69aad04 common/autoconf/lib-elf.m4 --- a/common/autoconf/lib-elf.m4 Wed Jul 05 23:37:13 2017 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,129 +0,0 @@ -# -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -################################################################################ -# Setup libelf (ELF library) -################################################################################ -AC_DEFUN_ONCE([LIB_SETUP_LIBELF], -[ - AC_ARG_WITH(libelf, [AS_HELP_STRING([--with-libelf], - [specify prefix directory for the libelf package - (expecting the libraries under PATH/lib and the headers under PATH/include)])]) - AC_ARG_WITH(libelf-include, [AS_HELP_STRING([--with-libelf-include], - [specify directory for the libelf include files])]) - AC_ARG_WITH(libelf-lib, [AS_HELP_STRING([--with-libelf-lib], - [specify directory for the libelf library])]) - - if test "x$ENABLE_AOT" = xfalse; then - if (test "x${with_libelf}" != x && test "x${with_libelf}" != xno) || \ - (test "x${with_libelf_include}" != x && test "x${with_libelf_include}" != xno) || \ - (test "x${with_libelf_lib}" != x && test "x${with_libelf_lib}" != xno); then - AC_MSG_WARN([[libelf is not used, so --with-libelf[-*] is ignored]]) - fi - LIBELF_CFLAGS= - LIBELF_LIBS= - else - LIBELF_FOUND=no - - if test "x${with_libelf}" = xno || test "x${with_libelf_include}" = xno || test "x${with_libelf_lib}" = xno; then - ENABLE_AOT="false" - if test "x${enable_aot}" = xyes; then - AC_MSG_ERROR([libelf is explicitly disabled, cannot build AOT. Enable libelf or remove --enable-aot to disable AOT.]) - fi - else - if test "x${with_libelf}" != x; then - ELF_LIBS="-L${with_libelf}/lib -lelf" - ELF_CFLAGS="-I${with_libelf}/include" - LIBELF_FOUND=yes - fi - if test "x${with_libelf_include}" != x; then - ELF_CFLAGS="-I${with_libelf_include}" - LIBELF_FOUND=yes - fi - if test "x${with_libelf_lib}" != x; then - ELF_LIBS="-L${with_libelf_lib} -lelf" - LIBELF_FOUND=yes - fi - # Do not try pkg-config if we have a sysroot set. - if test "x$SYSROOT" = x; then - if test "x$LIBELF_FOUND" = xno; then - # Figure out ELF_CFLAGS and ELF_LIBS - PKG_CHECK_MODULES([ELF], [libelf], [LIBELF_FOUND=yes], [LIBELF_FOUND=no]) - fi - fi - if test "x$LIBELF_FOUND" = xno; then - AC_CHECK_HEADERS([libelf.h], - [ - LIBELF_FOUND=yes - ELF_CFLAGS= - ELF_LIBS=-lelf - ], - [LIBELF_FOUND=no] - ) - fi - if test "x$LIBELF_FOUND" = xno; then - ENABLE_AOT="false" - HELP_MSG_MISSING_DEPENDENCY([elf]) - if test "x${enable_aot}" = xyes; then - AC_MSG_ERROR([libelf not found, cannot build AOT. Remove --enable-aot to disable AOT or: $HELP_MSG]) - else - AC_MSG_WARN([libelf not found, cannot build AOT. $HELP_MSG]) - fi - else - AC_MSG_CHECKING([if libelf works]) - AC_LANG_PUSH(C) - OLD_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS $ELF_CFLAGS" - OLD_LIBS="$LIBS" - LIBS="$LIBS $ELF_LIBS" - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include ], - [ - elf_version(0); - return 0; - ])], - [LIBELF_WORKS=yes], - [LIBELF_WORKS=no] - ) - CFLAGS="$OLD_CFLAGS" - LIBS="$OLD_LIBS" - AC_LANG_POP(C) - AC_MSG_RESULT([$LIBELF_WORKS]) - - if test "x$LIBELF_WORKS" = xno; then - ENABLE_AOT="false" - HELP_MSG_MISSING_DEPENDENCY([elf]) - if test "x$enable_aot" = "xyes"; then - AC_MSG_ERROR([Found libelf but could not link and compile with it. Remove --enable-aot to disable AOT or: $HELP_MSG]) - else - AC_MSG_WARN([Found libelf but could not link and compile with it. $HELP_MSG]) - fi - fi - fi - fi - fi - - AC_SUBST(ELF_CFLAGS) - AC_SUBST(ELF_LIBS) -]) diff -r 036dbf8b3817 -r 0444b69aad04 common/autoconf/libraries.m4 --- a/common/autoconf/libraries.m4 Wed Jul 05 23:37:13 2017 +0200 +++ b/common/autoconf/libraries.m4 Thu Jun 08 19:18:02 2017 +0200 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -31,7 +31,6 @@ m4_include([lib-freetype.m4]) m4_include([lib-std.m4]) m4_include([lib-x11.m4]) -m4_include([lib-elf.m4]) ################################################################################ # Determine which libraries are needed for this configuration @@ -91,7 +90,6 @@ LIB_SETUP_BUNDLED_LIBS LIB_SETUP_MISC_LIBS LIB_SETUP_SOLARIS_STLPORT - LIB_SETUP_LIBELF ]) ################################################################################ diff -r 036dbf8b3817 -r 0444b69aad04 common/autoconf/spec.gmk.in --- a/common/autoconf/spec.gmk.in Wed Jul 05 23:37:13 2017 +0200 +++ b/common/autoconf/spec.gmk.in Thu Jun 08 19:18:02 2017 +0200 @@ -687,6 +687,7 @@ XATTR:=@XATTR@ JT_HOME:=@JT_HOME@ JTREGEXE:=@JTREGEXE@ +JIB_JAR:=@JIB_JAR@ XCODEBUILD=@XCODEBUILD@ DTRACE := @DTRACE@ FIXPATH:=@FIXPATH@ @@ -771,9 +772,6 @@ PNG_LIBS:=@PNG_LIBS@ PNG_CFLAGS:=@PNG_CFLAGS@ -ELF_CFLAGS:=@ELF_CFLAGS@ -ELF_LIBS:=@ELF_LIBS@ - #################################################### # # Misc diff -r 036dbf8b3817 -r 0444b69aad04 common/autoconf/toolchain.m4 --- a/common/autoconf/toolchain.m4 Wed Jul 05 23:37:13 2017 +0200 +++ b/common/autoconf/toolchain.m4 Thu Jun 08 19:18:02 2017 +0200 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -1005,3 +1005,31 @@ AC_SUBST(JT_HOME) AC_SUBST(JTREGEXE) ]) + +# Setup the JIB dependency resolver +AC_DEFUN_ONCE([TOOLCHAIN_SETUP_JIB], +[ + AC_ARG_WITH(jib, [AS_HELP_STRING([--with-jib], + [Jib dependency management tool @<:@not used@:>@])]) + + if test "x$with_jib" = xno || test "x$with_jib" = x; then + # jib disabled + AC_MSG_CHECKING([for jib]) + AC_MSG_RESULT(no) + elif test "x$with_jib" = xyes; then + AC_MSG_ERROR([Must supply a value to --with-jib]) + else + JIB_HOME="${with_jib}" + AC_MSG_CHECKING([for jib]) + AC_MSG_RESULT(${JIB_HOME}) + if test ! -d "${JIB_HOME}"; then + AC_MSG_ERROR([--with-jib must be a directory]) + fi + JIB_JAR=$(ls ${JIB_HOME}/lib/jib-*.jar) + if test ! -f "${JIB_JAR}"; then + AC_MSG_ERROR([Could not find jib jar file in ${JIB_HOME}]) + fi + fi + + AC_SUBST(JIB_JAR) +]) diff -r 036dbf8b3817 -r 0444b69aad04 common/conf/jib-profiles.js --- a/common/conf/jib-profiles.js Wed Jul 05 23:37:13 2017 +0200 +++ b/common/conf/jib-profiles.js Thu Jun 08 19:18:02 2017 +0200 @@ -237,7 +237,7 @@ // These are the base setttings for all the main build profiles. common.main_profile_base = { - dependencies: ["boot_jdk", "gnumake", "jtreg"], + dependencies: ["boot_jdk", "gnumake", "jtreg", "jib"], default_make_targets: ["product-bundles", "test-bundles"], configure_args: concat(["--enable-jtreg-failure-handler"], versionArgs(input, common)) @@ -589,7 +589,7 @@ "run-test-jprt": { target_os: input.build_os, target_cpu: input.build_cpu, - dependencies: [ "jtreg", "gnumake", "boot_jdk" ], + dependencies: [ "jtreg", "gnumake", "boot_jdk", "devkit", "jib" ], labels: "test", environment: { "JT_JAVA": common.boot_jdk_home @@ -599,7 +599,7 @@ "run-test": { target_os: input.build_os, target_cpu: input.build_cpu, - dependencies: [ "jtreg", "gnumake", "boot_jdk" ], + dependencies: [ "jtreg", "gnumake", "boot_jdk", "devkit", "jib" ], labels: "test", environment: { "JT_JAVA": common.boot_jdk_home @@ -616,7 +616,7 @@ var testOnlyProfilesPrebuilt = { "run-test-prebuilt": { src: "src.conf", - dependencies: [ "jtreg", "gnumake", "boot_jdk", testedProfile + ".jdk", + dependencies: [ "jtreg", "gnumake", "boot_jdk", "jib", testedProfile + ".jdk", testedProfile + ".test", "src.full" ], work_dir: input.get("src.full", "install_path") + "/test", @@ -1009,8 +1009,26 @@ configure_args: "PANDOC=" + input.get("pandoc", "install_path") + "/pandoc/pandoc", environment_path: input.get("pandoc", "install_path") + "/pandoc" }, + // This adds java jib as a dependency for the test artifacts resolver + jib: { + organization: "com.oracle.java.jib", + ext: "zip", + classifier: "distribution", + revision: "3.0-SNAPSHOT", + environment_name: "JIB_JAR", + environment_value: input.get("jib", "install_path") + + "/jib-3.0-SNAPSHOT-distribution/lib/jib-3.0-SNAPSHOT.jar" + } }; + // Need to add a value for the Visual Studio tools variable to make + // jaot be able to pick up the Visual Studio linker in testing. + if (input.target_os == "windows") { + dependencies.devkit.environment = { + VS120COMNTOOLS: input.get("devkit", "install_path") + "/Common7/Tools" + }; + } + return dependencies; }; diff -r 036dbf8b3817 -r 0444b69aad04 make/CompileJavaModules.gmk --- a/make/CompileJavaModules.gmk Wed Jul 05 23:37:13 2017 +0200 +++ b/make/CompileJavaModules.gmk Thu Jun 08 19:18:02 2017 +0200 @@ -509,6 +509,7 @@ org.graalvm.compiler.jtt \ org.graalvm.compiler.lir.jtt \ org.graalvm.compiler.lir.test \ + org.graalvm.compiler.loop.test \ org.graalvm.compiler.microbenchmarks \ org.graalvm.compiler.nodes.test \ org.graalvm.compiler.options.test \ @@ -516,6 +517,7 @@ org.graalvm.compiler.replacements.test \ org.graalvm.compiler.test \ org.graalvm.compiler.virtual.bench \ + org.graalvm.util.test \ # ################################################################################ diff -r 036dbf8b3817 -r 0444b69aad04 make/Docs.gmk diff -r 036dbf8b3817 -r 0444b69aad04 make/MainSupport.gmk --- a/make/MainSupport.gmk Wed Jul 05 23:37:13 2017 +0200 +++ b/make/MainSupport.gmk Thu Jun 08 19:18:02 2017 +0200 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ JT_HOME=$(JT_HOME) PRODUCT_HOME=$(strip $2) \ TEST_IMAGE_DIR=$(TEST_IMAGE_DIR) \ ALT_OUTPUTDIR=$(OUTPUT_ROOT) TEST_JOBS=$(TEST_JOBS) \ - JT_JAVA=$(BOOT_JDK) \ + JT_JAVA=$(BOOT_JDK) JIB_JAR=$(JIB_JAR) \ JOBS=$(JOBS) $1) || true endef diff -r 036dbf8b3817 -r 0444b69aad04 make/jprt.properties --- a/make/jprt.properties Wed Jul 05 23:37:13 2017 +0200 +++ b/make/jprt.properties Thu Jun 08 19:18:02 2017 +0200 @@ -1,5 +1,5 @@ # -# Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -441,25 +441,25 @@ # Hotspot jtreg tests my.make.rule.test.targets.hotspot.reg= \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_compiler_1}, \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_compiler_2}, \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_compiler_3}, \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_compiler_closed}, \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_gc_1}, \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_gc_2}, \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_gc_closed}, \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_gc_gcold}, \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_gc_gcbasher}, \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_runtime}, \ - ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_fast_serviceability}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_compiler_1}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_compiler_2}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_compiler_3}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_compiler_closed}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_gc_1}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_gc_2}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_gc_closed}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_gc_gcold}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_gc_gcbasher}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_runtime}, \ + ${my.make.rule.test.targets.hotspot.reg.group:GROUP=hotspot_tier1_serviceability}, \ ${my.make.rule.test.targets.hotspot.reg.group:GROUP=jdk_svc_sanity}, \ - solaris_sparcv9_5.11-product-c2-hotspot_fast_gc_gcbasher, \ - solaris_x64_5.11-product-c2-hotspot_fast_gc_gcbasher, \ - linux_i586_3.8-product-c2-hotspot_fast_gc_gcbasher, \ - linux_x64_3.8-product-c2-hotspot_fast_gc_gcbasher, \ - macosx_x64_10.9-product-c2-hotspot_fast_gc_gcbasher, \ - windows_i586_6.3-product-c2-hotspot_fast_gc_gcbasher, \ - windows_x64_6.3-product-c2-hotspot_fast_gc_gcbasher, \ + solaris_sparcv9_5.11-product-c2-hotspot_tier1_gc_gcbasher, \ + solaris_x64_5.11-product-c2-hotspot_tier1_gc_gcbasher, \ + linux_i586_3.8-product-c2-hotspot_tier1_gc_gcbasher, \ + linux_x64_3.8-product-c2-hotspot_tier1_gc_gcbasher, \ + macosx_x64_10.9-product-c2-hotspot_tier1_gc_gcbasher, \ + windows_i586_6.3-product-c2-hotspot_tier1_gc_gcbasher, \ + windows_x64_6.3-product-c2-hotspot_tier1_gc_gcbasher, \ ${my.additional.make.rule.test.targets.hotspot.reg} # Other Makefile based Hotspot tests diff -r 036dbf8b3817 -r 0444b69aad04 test/TestCommon.gmk --- a/test/TestCommon.gmk Wed Jul 05 23:37:13 2017 +0200 +++ b/test/TestCommon.gmk Thu Jun 08 19:18:02 2017 +0200 @@ -1,5 +1,5 @@ # -# Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -369,9 +369,15 @@ endif # Give tests access to JT_JAVA, see JDK-8141609 JTREG_BASIC_OPTIONS += -e:JDK8_HOME=${JT_JAVA} +# Give aot tests access to Visual Studio installation +ifneq ($(VS120COMNTOOLS), ) + JTREG_BASIC_OPTIONS += -e:VS120COMNTOOLS=$(shell $(GETMIXEDPATH) "$(VS120COMNTOOLS)") +endif # Set other vm and test options JTREG_TEST_OPTIONS += $(JAVA_ARGS:%=-javaoptions:%) $(JAVA_OPTIONS:%=-vmoption:%) $(JAVA_VM_ARGS:%=-vmoption:%) - +ifneq ($(JIB_JAR), ) + JTREG_BASIC_OPTIONS += -cpa:$(shell $(GETMIXEDPATH) "$(JIB_JAR)") +endif ifeq ($(IGNORE_MARKED_TESTS), true) # Option to tell jtreg to not run tests marked with "ignore" ifeq ($(PLATFORM), windows) diff -r 036dbf8b3817 -r 0444b69aad04 test/jtreg-ext/requires/VMProps.java --- a/test/jtreg-ext/requires/VMProps.java Wed Jul 05 23:37:13 2017 +0200 +++ b/test/jtreg-ext/requires/VMProps.java Thu Jun 08 19:18:02 2017 +0200 @@ -37,6 +37,7 @@ import sun.hotspot.cpuinfo.CPUInfo; import sun.hotspot.gc.GC; import sun.hotspot.WhiteBox; +import jdk.test.lib.Platform; /** * The Class to be invoked by jtreg prior Test Suite execution to @@ -66,6 +67,8 @@ map.put("vm.jvmci", vmJvmci()); map.put("vm.emulatedClient", vmEmulatedClient()); map.put("vm.cpu.features", cpuFeatures()); + map.put("vm.rtm.cpu", vmRTMCPU()); + map.put("vm.rtm.os", vmRTMOS()); vmGC(map); // vm.gc.X = true/false VMProps.dump(map); @@ -206,6 +209,36 @@ } /** + * @return true if VM runs RTM supported OS and false otherwise. + */ + protected String vmRTMOS() { + boolean isRTMOS = true; + + if (Platform.isAix()) { + // Actually, this works since AIX 7.1.3.30, but os.version property + // is set to 7.1. + isRTMOS = (Platform.getOsVersionMajor() > 7) || + (Platform.getOsVersionMajor() == 7 && Platform.getOsVersionMinor() > 1); + + } else if (Platform.isLinux()) { + if (Platform.isPPC()) { + isRTMOS = (Platform.getOsVersionMajor() > 4) || + (Platform.getOsVersionMajor() == 4 && Platform.getOsVersionMinor() > 1); + } + } + return "" + isRTMOS; + } + + /** + * @return true if VM runs RTM supported CPU and false otherwise. + */ + protected String vmRTMCPU() { + boolean vmRTMCPU = (Platform.isPPC() ? CPUInfo.hasFeature("tcheck") : CPUInfo.hasFeature("rtm")); + + return "" + vmRTMCPU; + } + + /** * Dumps the map to the file if the file name is given as the property. * This functionality could be helpful to know context in the real * execution. diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/Platform.java --- a/test/lib/jdk/test/lib/Platform.java Wed Jul 05 23:37:13 2017 +0200 +++ b/test/lib/jdk/test/lib/Platform.java Thu Jun 08 19:18:02 2017 +0200 @@ -23,6 +23,10 @@ package jdk.test.lib; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; import java.util.regex.Pattern; public class Platform { @@ -228,7 +232,7 @@ public static boolean canPtraceAttachLinux() throws Exception { // SELinux deny_ptrace: - String deny_ptrace = Utils.fileAsString("/sys/fs/selinux/booleans/deny_ptrace"); + String deny_ptrace = fileAsString("/sys/fs/selinux/booleans/deny_ptrace"); if (deny_ptrace != null && deny_ptrace.contains("1")) { // ptrace will be denied: return false; @@ -239,7 +243,7 @@ // 1 - restricted ptrace: a process must be a children of the inferior or user is root // 2 - only processes with CAP_SYS_PTRACE may use ptrace or user is root // 3 - no attach: no processes may use ptrace with PTRACE_ATTACH - String ptrace_scope = Utils.fileAsString("/proc/sys/kernel/yama/ptrace_scope"); + String ptrace_scope = fileAsString("/proc/sys/kernel/yama/ptrace_scope"); if (ptrace_scope != null) { if (ptrace_scope.startsWith("3")) { return false; @@ -265,4 +269,10 @@ .matcher(osArch) .matches(); } + + private static String fileAsString(String filename) throws IOException { + Path filePath = Paths.get(filename); + if (!Files.exists(filePath)) return null; + return new String(Files.readAllBytes(filePath)); + } } diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/Utils.java --- a/test/lib/jdk/test/lib/Utils.java Wed Jul 05 23:37:13 2017 +0200 +++ b/test/lib/jdk/test/lib/Utils.java Thu Jun 08 19:18:02 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -90,6 +90,11 @@ */ public static final String TEST_JDK = System.getProperty("test.jdk"); + /* + * Returns the value of 'compile.jdk' system property + */ + public static final String COMPILE_JDK= System.getProperty("compile.jdk", TEST_JDK); + /** * Returns the value of 'test.classes' system property */ @@ -680,5 +685,58 @@ String.format("A mandatory property '%s' isn't set", propName)); return prop; } + + // This method is intended to be called from a jtreg test. + // It will identify the name of the test by means of stack walking. + // It can handle both jtreg tests and a testng tests wrapped inside jtreg tests. + // For jtreg tests the name of the test will be searched by stack-walking + // until the method main() is found; the class containing that method is the + // main test class and will be returned as the name of the test. + // Special handling is used for testng tests. + public static String getTestName() { + String result = null; + // If we are using testng, then we should be able to load the "Test" annotation. + Class testClassAnnotation; + + try { + testClassAnnotation = Class.forName("org.testng.annotations.Test"); + } catch (ClassNotFoundException e) { + testClassAnnotation = null; + } + + StackTraceElement[] elms = (new Throwable()).getStackTrace(); + for (StackTraceElement n: elms) { + String className = n.getClassName(); + + // If this is a "main" method, then use its class name, but only + // if we are not using testng. + if (testClassAnnotation == null && "main".equals(n.getMethodName())) { + result = className; + break; + } + + // If this is a testng test, the test will have no "main" method. We can + // detect a testng test class by looking for the org.testng.annotations.Test + // annotation. If present, then use the name of this class. + if (testClassAnnotation != null) { + try { + Class c = Class.forName(className); + if (c.isAnnotationPresent(testClassAnnotation)) { + result = className; + break; + } + } catch (ClassNotFoundException e) { + throw new RuntimeException("Unexpected exception: " + e, e); + } + } + } + + if (result == null) { + throw new RuntimeException("Couldn't find main test class in stack trace"); + } + + return result; + } + } diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/artifacts/Artifact.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/lib/jdk/test/lib/artifacts/Artifact.java Thu Jun 08 19:18:02 2017 +0200 @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.artifacts; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE) +@Repeatable(ArtifactContainer.class) +@Retention(RetentionPolicy.RUNTIME) +public @interface Artifact { + String organization(); + String name(); + String revision(); + String extension(); + String classifier() default ""; + boolean unpack() default true; +} + diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/artifacts/ArtifactContainer.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/lib/jdk/test/lib/artifacts/ArtifactContainer.java Thu Jun 08 19:18:02 2017 +0200 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.artifacts; + +import java.lang.annotation.*; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface ArtifactContainer { + Artifact[] value(); +} + diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/artifacts/ArtifactManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/lib/jdk/test/lib/artifacts/ArtifactManager.java Thu Jun 08 19:18:02 2017 +0200 @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.artifacts; + +import java.io.FileNotFoundException; +import java.nio.file.Path; + +public interface ArtifactManager { + public Path resolve(Artifact artifact) throws FileNotFoundException; +} diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/artifacts/ArtifactResolver.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/lib/jdk/test/lib/artifacts/ArtifactResolver.java Thu Jun 08 19:18:02 2017 +0200 @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.artifacts; + +import java.io.FileNotFoundException; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; + +public class ArtifactResolver { + public static Map resolve(Class klass) throws FileNotFoundException { + ArtifactManager manager = new DefaultArtifactManager(); + try { + String managerName = System.getProperty("jdk.test.lib.artifacts.artifactmanager"); + if (managerName != null) { + manager = (ArtifactManager) Class.forName(managerName).newInstance(); + } else { + manager = JibArtifactManager.newInstance(); + } + } catch (Exception e) { + // If we end up here, we'll use the DefaultArtifactManager + } + + ArtifactContainer artifactContainer = klass.getAnnotation(ArtifactContainer.class); + HashMap locations = new HashMap<>(); + Artifact[] artifacts; + + if (artifactContainer == null) { + artifacts = new Artifact[]{klass.getAnnotation(Artifact.class)}; + } else { + artifacts = artifactContainer.value(); + } + for (Artifact artifact : artifacts) { + locations.put(artifactName(artifact), manager.resolve(artifact)); + } + + return locations; + } + + private static String artifactName(Artifact artifact) { + // Format of the artifact name is .-(-) + String name = String.format("%s.%s-%s", artifact.organization(), artifact.name(), artifact.revision()); + if (artifact.classifier().length() != 0) { + name = name +"-" + artifact.classifier(); + } + return name; + } +} diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/artifacts/DefaultArtifactManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/lib/jdk/test/lib/artifacts/DefaultArtifactManager.java Thu Jun 08 19:18:02 2017 +0200 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.artifacts; + +import java.io.FileNotFoundException; +import java.nio.file.Path; +import java.nio.file.Paths; + +public class DefaultArtifactManager implements ArtifactManager { + @Override + public Path resolve(Artifact artifact) throws FileNotFoundException { + String name = artifact.name(); + String location = System.getProperty(artifactProperty(name)); + if (location == null) { + throw new FileNotFoundException("Couldn't automatically resolve dependency for " + name + " , revision " + artifact.revision() + "\n" + + "Please specify the location using " + artifactProperty(name)); + } + return Paths.get(location); + } + + private static String artifactProperty(String name) { + return "jdk.test.lib.artifacts." + name; + } +} diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/artifacts/JibArtifactManager.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/lib/jdk/test/lib/artifacts/JibArtifactManager.java Thu Jun 08 19:18:02 2017 +0200 @@ -0,0 +1,92 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.artifacts; + +import java.io.FileNotFoundException; +import java.lang.reflect.Method; +import java.nio.file.Path; +import java.util.HashMap; +import java.util.Map; + +public class JibArtifactManager implements ArtifactManager { + private static String jibVersion = "1.0"; + private Object installerObject; + + private JibArtifactManager(Object o) { + installerObject = o; + } + + public static JibArtifactManager newInstance() throws ClassNotFoundException { + try { + Class jibServiceFactory = Class.forName("com.oracle.jib.api.JibServiceFactory"); + Object jibArtifactInstaller = jibServiceFactory.getMethod("createJibArtifactInstaller").invoke(null); + return new JibArtifactManager(jibArtifactInstaller); + } catch (Exception e) { + throw new ClassNotFoundException(); + } + } + + private Path download(String jibVersion, HashMap artifactDescription) throws Exception { + return invokeInstallerMethod("download", jibVersion, artifactDescription); + } + + private Path install(String jibVersion, HashMap artifactDescription) throws Exception { + return invokeInstallerMethod("install", jibVersion, artifactDescription); + } + + private Path invokeInstallerMethod(String methodName, String jibVersion, HashMap artifactDescription) throws Exception { + Method m = Class.forName("com.oracle.jib.api.JibArtifactInstaller").getMethod(methodName, String.class, Map.class); + return (Path)m.invoke(installerObject, jibVersion, artifactDescription); + } + + @Override + public Path resolve(Artifact artifact) throws FileNotFoundException { + Path path; + // Use the DefaultArtifactManager to enable users to override locations + try { + ArtifactManager manager = new DefaultArtifactManager(); + path = manager.resolve(artifact); + } catch (FileNotFoundException e) { + // Location hasn't been overridden, continue to automatically try to resolve the dependency + try { + HashMap artifactDescription = new HashMap<>(); + artifactDescription.put("module", artifact.name()); + artifactDescription.put("organization", artifact.organization()); + artifactDescription.put("ext", artifact.extension()); + artifactDescription.put("revision", artifact.revision()); + if (artifact.classifier().length() > 0) { + artifactDescription.put("classifier", artifact.classifier()); + } + + path = download(jibVersion, artifactDescription); + if (artifact.unpack()) { + path = install(jibVersion, artifactDescription); + } + } catch (Exception exception) { + throw new FileNotFoundException("Failed to resolve the artifact " + artifact); + } + } + return path; + } +} diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/cds/CDSOptions.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/lib/jdk/test/lib/cds/CDSOptions.java Thu Jun 08 19:18:02 2017 +0200 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.test.lib.cds; + +import java.util.ArrayList; + +// This class represents options used +// during creation of CDS archive and/or running JVM with a CDS archive +public class CDSOptions { + public String xShareMode = "on"; + public String archiveName; + public ArrayList prefix = new ArrayList(); + public ArrayList suffix = new ArrayList(); + + // Indicate whether to append "-version" when using CDS Archive. + // Most of tests will use '-version' + public boolean useVersion = true; + + + public CDSOptions() { + } + + + public CDSOptions addPrefix(String... prefix) { + for (String s : prefix) this.prefix.add(s); + return this; + } + + + public CDSOptions addSuffix(String... suffix) { + for (String s : suffix) this.suffix.add(s); + return this; + } + + public CDSOptions setXShareMode(String mode) { + this.xShareMode = mode; + return this; + } + + + public CDSOptions setArchiveName(String name) { + this.archiveName = name; + return this; + } + + + public CDSOptions setUseVersion(boolean use) { + this.useVersion = use; + return this; + } +} diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/cds/CDSTestUtils.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/lib/jdk/test/lib/cds/CDSTestUtils.java Thu Jun 08 19:18:02 2017 +0200 @@ -0,0 +1,380 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.test.lib.cds; + +import java.io.IOException; +import java.io.File; +import java.io.FileOutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import jdk.test.lib.Utils; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.process.ProcessTools; + + +// This class contains common test utilities for testing CDS +public class CDSTestUtils { + // Specify this property to copy sdandard output of the child test process to + // the parent/main stdout of the test. + // By default such output is logged into a file, and is copied into the main stdout. + public static final boolean CopyChildStdoutToMainStdout = + Boolean.valueOf(System.getProperty("test.cds.copy.child.stdout", "true")); + + // This property is passed to child test processes + public static final String TestTimeoutFactor = System.getProperty("test.timeout.factor", "1.0"); + + public static final String UnableToMapMsg = + "Unable to map shared archive: test did not complete; assumed PASS"; + + // Create bootstrap CDS archive, + // use extra JVM command line args as a prefix. + // For CDS tests specifying prefix makes more sense than specifying suffix, since + // normally there are no classes or arguments to classes, just "-version" + // To specify suffix explicitly use CDSOptions.addSuffix() + public static OutputAnalyzer createArchive(String... cliPrefix) + throws Exception { + return createArchive((new CDSOptions()).addPrefix(cliPrefix)); + } + + // Create bootstrap CDS archive + public static OutputAnalyzer createArchive(CDSOptions opts) + throws Exception { + + ArrayList cmd = new ArrayList(); + + for (String p : opts.prefix) cmd.add(p); + + cmd.add("-Xshare:dump"); + cmd.add("-Xlog:cds,cds+hashtables"); + cmd.add("-XX:+UnlockDiagnosticVMOptions"); + if (opts.archiveName == null) + opts.archiveName = getDefaultArchiveName(); + cmd.add("-XX:SharedArchiveFile=./" + opts.archiveName); + + for (String s : opts.suffix) cmd.add(s); + + String[] cmdLine = cmd.toArray(new String[cmd.size()]); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine); + return executeAndLog(pb, "dump"); + } + + + // check result of 'dump-the-archive' operation, that is "-Xshare:dump" + public static OutputAnalyzer checkDump(OutputAnalyzer output, String... extraMatches) + throws Exception { + + output.shouldContain("Loading classes to share"); + output.shouldHaveExitValue(0); + + for (String match : extraMatches) { + output.shouldContain(match); + } + + return output; + } + + + // A commonly used convenience methods to create an archive and check the results + // Creates an archive and checks for errors + public static OutputAnalyzer createArchiveAndCheck(CDSOptions opts) + throws Exception { + return checkDump(createArchive(opts)); + } + + + public static OutputAnalyzer createArchiveAndCheck(String... cliPrefix) + throws Exception { + return checkDump(createArchive(cliPrefix)); + } + + + // This method should be used to check the output of child VM for common exceptions. + // Most of CDS tests deal with child VM processes for creating and using the archive. + // However exceptions that occur in the child process do not automatically propagate + // to the parent process. This mechanism aims to improve the propagation + // of exceptions and common errors. + // Exception e argument - an exception to be re-thrown if none of the common + // exceptions match. Pass null if you wish not to re-throw any exception. + public static void checkCommonExecExceptions(OutputAnalyzer output, Exception e) + throws Exception { + if (output.getStdout().contains("http://bugreport.java.com/bugreport/crash.jsp")) { + throw new RuntimeException("Hotspot crashed"); + } + if (output.getStdout().contains("TEST FAILED")) { + throw new RuntimeException("Test Failed"); + } + if (output.getOutput().contains("shared class paths mismatch")) { + throw new RuntimeException("shared class paths mismatch"); + } + if (output.getOutput().contains("Unable to unmap shared space")) { + throw new RuntimeException("Unable to unmap shared space"); + } + + // Special case -- sometimes Xshare:on fails because it failed to map + // at given address. This behavior is platform-specific, machine config-specific + // and can be random (see ASLR). + if (isUnableToMap(output)) { + System.out.println(UnableToMapMsg); + return; + } + + if (e != null) + throw e; + } + + + // Check the output for indication that mapping of the archive failed. + // Performance note: this check seems to be rather costly - searching the entire + // output stream of a child process for multiple strings. However, it is necessary + // to detect this condition, a failure to map an archive, since this is not a real + // failure of the test or VM operation, and results in a test being "skipped". + // Suggestions to improve: + // 1. VM can designate a special exit code for such condition. + // 2. VM can print a single distinct string indicating failure to map an archive, + // instead of utilizing multiple messages. + // These are suggestions to improve testibility of the VM. However, implementing them + // could also improve usability in the field. + public static boolean isUnableToMap(OutputAnalyzer output) { + String outStr = output.getOutput(); + if ((output.getExitValue() == 1) && ( + outStr.contains("Unable to reserve shared space at required address") || + outStr.contains("Unable to map ReadOnly shared space at required address") || + outStr.contains("Unable to map ReadWrite shared space at required address") || + outStr.contains("Unable to map MiscData shared space at required address") || + outStr.contains("Unable to map MiscCode shared space at required address") || + outStr.contains("Unable to map shared string space at required address") || + outStr.contains("Could not allocate metaspace at a compatible address") || + outStr.contains("Unable to allocate shared string space: range is not within java heap") )) + { + return true; + } + + return false; + } + + + // Execute JVM with CDS archive, specify command line args suffix + public static OutputAnalyzer runWithArchive(String... cliPrefix) + throws Exception { + + return runWithArchive( (new CDSOptions()) + .setArchiveName(getDefaultArchiveName()) + .addPrefix(cliPrefix) ); + } + + + // Execute JVM with CDS archive, specify CDSOptions + public static OutputAnalyzer runWithArchive(CDSOptions opts) + throws Exception { + + ArrayList cmd = new ArrayList(); + + for (String p : opts.prefix) cmd.add(p); + + cmd.add("-Xshare:" + opts.xShareMode); + cmd.add("-XX:+UnlockDiagnosticVMOptions"); + cmd.add("-Dtest.timeout.factor=" + TestTimeoutFactor); + + if (opts.archiveName == null) + opts.archiveName = getDefaultArchiveName(); + cmd.add("-XX:SharedArchiveFile=" + opts.archiveName); + + if (opts.useVersion) + cmd.add("-version"); + + for (String s : opts.suffix) cmd.add(s); + + String[] cmdLine = cmd.toArray(new String[cmd.size()]); + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine); + return executeAndLog(pb, "exec"); + } + + + // A commonly used convenience methods to create an archive and check the results + // Creates an archive and checks for errors + public static OutputAnalyzer runWithArchiveAndCheck(CDSOptions opts) throws Exception { + return checkExec(runWithArchive(opts)); + } + + + public static OutputAnalyzer runWithArchiveAndCheck(String... cliPrefix) throws Exception { + return checkExec(runWithArchive(cliPrefix)); + } + + + public static OutputAnalyzer checkExec(OutputAnalyzer output, + String... extraMatches) throws Exception { + CDSOptions opts = new CDSOptions(); + return checkExec(output, opts, extraMatches); + } + + + // check result of 'exec' operation, that is when JVM is run using the archive + public static OutputAnalyzer checkExec(OutputAnalyzer output, CDSOptions opts, + String... extraMatches) throws Exception { + try { + if ("on".equals(opts.xShareMode)) { + output.shouldContain("sharing"); + } + output.shouldHaveExitValue(0); + } catch (RuntimeException e) { + checkCommonExecExceptions(output, e); + return output; + } + + checkExtraMatches(output, extraMatches); + return output; + } + + + public static OutputAnalyzer checkExecExpectError(OutputAnalyzer output, + int expectedExitValue, + String... extraMatches) throws Exception { + if (isUnableToMap(output)) { + System.out.println(UnableToMapMsg); + return output; + } + + output.shouldHaveExitValue(expectedExitValue); + checkExtraMatches(output, extraMatches); + return output; + } + + public static OutputAnalyzer checkExtraMatches(OutputAnalyzer output, + String... extraMatches) throws Exception { + for (String match : extraMatches) { + output.shouldContain(match); + } + return output; + } + + + // get the file object for the test artifact + public static File getTestArtifact(String name, boolean checkExistence) { + File dir = new File(System.getProperty("test.classes", ".")); + File file = new File(dir, name); + + if (checkExistence && !file.exists()) { + throw new RuntimeException("Cannot find " + file.getPath()); + } + + return file; + } + + + // create file containing the specified class list + public static File makeClassList(String classes[]) + throws Exception { + return makeClassList(getTestName() + "-", classes); + } + + // create file containing the specified class list + public static File makeClassList(String testCaseName, String classes[]) + throws Exception { + + File classList = getTestArtifact(testCaseName + "test.classlist", false); + FileOutputStream fos = new FileOutputStream(classList); + PrintStream ps = new PrintStream(fos); + + addToClassList(ps, classes); + + ps.close(); + fos.close(); + + return classList; + } + + + public static void addToClassList(PrintStream ps, String classes[]) + throws IOException + { + if (classes != null) { + for (String s : classes) { + ps.println(s); + } + } + } + + + // Optimization for getting a test name. + // Test name does not change during execution of the test, + // but getTestName() uses stack walking hence it is expensive. + // Therefore cache it and reuse it. + private static String testName; + public static String getTestName() { + if (testName == null) { + testName = Utils.getTestName(); + } + return testName; + } + + + public static String getDefaultArchiveName() { + return getTestName() + ".jsa"; + } + + + // ===================== FILE ACCESS convenience methods + public static File getOutputFile(String name) { + File dir = new File(System.getProperty("test.classes", ".")); + return new File(dir, getTestName() + "-" + name); + } + + + public static File getOutputSourceFile(String name) { + File dir = new File(System.getProperty("test.classes", ".")); + return new File(dir, name); + } + + + public static File getSourceFile(String name) { + File dir = new File(System.getProperty("test.src", ".")); + return new File(dir, name); + } + + + // ============================= Logging + public static OutputAnalyzer executeAndLog(ProcessBuilder pb, String logName) throws Exception { + long started = System.currentTimeMillis(); + OutputAnalyzer output = new OutputAnalyzer(pb.start()); + + writeFile(getOutputFile(logName + ".stdout"), output.getStdout()); + writeFile(getOutputFile(logName + ".stderr"), output.getStderr()); + System.out.println("[ELAPSED: " + (System.currentTimeMillis() - started) + " ms]"); + System.out.println("[STDERR]\n" + output.getStderr()); + + if (CopyChildStdoutToMainStdout) + System.out.println("[STDOUT]\n" + output.getStdout()); + + return output; + } + + + private static void writeFile(File file, String content) throws Exception { + FileOutputStream fos = new FileOutputStream(file); + PrintStream ps = new PrintStream(fos); + ps.print(content); + ps.close(); + fos.close(); + } +} diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/jdk/test/lib/process/ProcessTools.java --- a/test/lib/jdk/test/lib/process/ProcessTools.java Wed Jul 05 23:37:13 2017 +0200 +++ b/test/lib/jdk/test/lib/process/ProcessTools.java Thu Jun 08 19:18:02 2017 +0200 @@ -64,7 +64,7 @@ /** * Pumps stdout and stderr from running the process into a String. * - * @param processHandler ProcessHandler to run. + * @param processBuilder ProcessBuilder to run. * @return Output from process. * @throws IOException If an I/O error occurs. */ diff -r 036dbf8b3817 -r 0444b69aad04 test/lib/sun/hotspot/WhiteBox.java --- a/test/lib/sun/hotspot/WhiteBox.java Wed Jul 05 23:37:13 2017 +0200 +++ b/test/lib/sun/hotspot/WhiteBox.java Thu Jun 08 19:18:02 2017 +0200 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -390,6 +390,39 @@ // Force Full GC public native void fullGC(); + // Returns true if the current GC supports control of its concurrent + // phase via requestConcurrentGCPhase(). If false, a request will + // always fail. + public native boolean supportsConcurrentGCPhaseControl(); + + // Returns an array of concurrent phase names provided by this + // collector. These are the names recognized by + // requestConcurrentGCPhase(). + public native String[] getConcurrentGCPhases(); + + // Attempt to put the collector into the indicated concurrent phase, + // and attempt to remain in that state until a new request is made. + // + // Returns immediately if already in the requested phase. + // Otherwise, waits until the phase is reached. + // + // Throws IllegalStateException if unsupported by the current collector. + // Throws NullPointerException if phase is null. + // Throws IllegalArgumentException if phase is not valid for the current collector. + public void requestConcurrentGCPhase(String phase) { + if (!supportsConcurrentGCPhaseControl()) { + throw new IllegalStateException("Concurrent GC phase control not supported"); + } else if (phase == null) { + throw new NullPointerException("null phase"); + } else if (!requestConcurrentGCPhase0(phase)) { + throw new IllegalArgumentException("Unknown concurrent GC phase: " + phase); + } + } + + // Helper for requestConcurrentGCPhase(). Returns true if request + // succeeded, false if the phase is invalid. + private native boolean requestConcurrentGCPhase0(String phase); + // Method tries to start concurrent mark cycle. // It returns false if CM Thread is always in concurrent cycle. public native boolean g1StartConcMarkCycle(); @@ -449,14 +482,13 @@ } // Jigsaw - public native void DefineModule(Object module, String version, String location, - Object[] packages); + public native void DefineModule(Object module, boolean is_open, String version, + String location, Object[] packages); public native void AddModuleExports(Object from_module, String pkg, Object to_module); public native void AddReadsModule(Object from_module, Object source_module); public native void AddModulePackage(Object module, String pkg); public native void AddModuleExportsToAllUnnamed(Object module, String pkg); public native void AddModuleExportsToAll(Object module, String pkg); - public native Object GetModuleByPackageName(Object ldr, String pkg); public native int getOffsetForName0(String name); public int getOffsetForName(String name) throws Exception {