diff --git a/.hgtags b/.hgtags index 14e634a3afd..c8a158f5305 100644 --- a/.hgtags +++ b/.hgtags @@ -460,7 +460,8 @@ a2008587c13fa05fa2dbfcb09fe987576fbedfd1 jdk-10+32 bbd692ad4fa300ecca7939ffbe3b1d5e52a28cc6 jdk-10+33 89deac44e51517841491ba86ff44aa82a5ca96b3 jdk-10+34 d8c634b016c628622c9abbdc6bf50509e5dedbec jdk-10+35 -cb54a299aa91419cb7caef3992592e7b22488163 jdk-10+36 +0ee20aad71c4f33c426372b4c8bcc1235ce2ec08 jdk-11+0 +959f2f7cbaa6d2ee45d50029744efb219721576c jdk-10+36 4f830b447edf04fb4a52151a5ad44d9bb60723cd jdk-10+37 e569e83139fdfbecfeb3cd9014d560917787f158 jdk-10+38 5b834ec962366e00d4445352a999a3ac14e26f64 jdk-10+39 diff --git a/bin/idea.sh b/bin/idea.sh index 13c47490292..03b9eee13da 100644 --- a/bin/idea.sh +++ b/bin/idea.sh @@ -30,9 +30,10 @@ usage() { } SCRIPT_DIR=`dirname $0` -PWD=`pwd` +#assume TOP is the dir from which the script has been called +TOP=`pwd` cd $SCRIPT_DIR; SCRIPT_DIR=`pwd` -cd ../; TOP=`pwd`; cd $PWD +cd $TOP; IDEA_OUTPUT=$TOP/.idea VERBOSE="false" @@ -66,30 +67,42 @@ done mkdir $IDEA_OUTPUT || exit 1 cd $IDEA_OUTPUT; IDEA_OUTPUT=`pwd` -IDEA_MAKE="$TOP/make/idea" +MAKE_DIR="$SCRIPT_DIR/../make" +IDEA_MAKE="$MAKE_DIR/idea" IDEA_TEMPLATE="$IDEA_MAKE/template" -IML_TEMPLATE="$IDEA_TEMPLATE/jdk.iml" -ANT_TEMPLATE="$IDEA_TEMPLATE/ant.xml" -MISC_TEMPLATE="$IDEA_TEMPLATE/misc.xml" -IDEA_IML="$IDEA_OUTPUT/jdk.iml" -IDEA_ANT="$IDEA_OUTPUT/ant.xml" -IDEA_MISC="$IDEA_OUTPUT/misc.xml" + +cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT" + +#init template variables +for file in `ls -p $IDEA_TEMPLATE | grep -v /`; do + VAR_SUFFIX=`echo $file | cut -d'.' -f1 | tr [:lower:] [:upper:]` + eval "$VAR_SUFFIX"_TEMPLATE="$IDEA_TEMPLATE"/$file + eval IDEA_"$VAR_SUFFIX"="$IDEA_OUTPUT"/$file +done + +#override template variables +if [ -d "$TEMPLATES_OVERRIDE" ] ; then + for file in `ls -p "$TEMPLATES_OVERRIDE" | grep -v /`; do + cp "$TEMPLATES_OVERRIDE"/$file "$IDEA_OUTPUT"/ + VAR_SUFFIX=`echo $file | cut -d'.' -f1 | tr [:lower:] [:upper:]` + eval "$VAR_SUFFIX"_TEMPLATE="$TEMPLATES_OVERRIDE"/$file + done +fi if [ "$VERBOSE" = "true" ] ; then echo "output dir: $IDEA_OUTPUT" echo "idea template dir: $IDEA_TEMPLATE" fi -if [ ! -f "$IML_TEMPLATE" ] ; then - echo "FATAL: cannot find $IML_TEMPLATE" >&2; exit 1 +if [ ! -f "$JDK_TEMPLATE" ] ; then + echo "FATAL: cannot find $JDK_TEMPLATE" >&2; exit 1 fi if [ ! -f "$ANT_TEMPLATE" ] ; then echo "FATAL: cannot find $ANT_TEMPLATE" >&2; exit 1 fi -cp -r "$IDEA_TEMPLATE"/* "$IDEA_OUTPUT" -cd $TOP ; make -f "$IDEA_MAKE/idea.gmk" -I make/common idea MAKEOVERRIDES= OUT=$IDEA_OUTPUT/env.cfg MODULES="$*" || exit 1 +cd $TOP ; make -f "$IDEA_MAKE/idea.gmk" -I $MAKE_DIR/.. idea MAKEOVERRIDES= OUT=$IDEA_OUTPUT/env.cfg MODULES="$*" || exit 1 cd $SCRIPT_DIR . $IDEA_OUTPUT/env.cfg @@ -118,11 +131,12 @@ addSourceFolder() { root=$@ relativePath="`echo "$root" | sed -e s@"$TOP/\(.*$\)"@"\1"@`" folder="`echo "$SOURCE_FOLDER" | sed -e s@"\(.*/\)####\(.*\)"@"\1$relativePath\2"@`" - printf "%s\n" "$folder" >> $IDEA_IML + printf "%s\n" "$folder" >> $IDEA_JDK } ### Generate project iml -rm -f $IDEA_IML + +rm -f $IDEA_JDK while IFS= read -r line do if echo "$line" | egrep "^ .* /dev/null ; then @@ -133,9 +147,9 @@ do done fi else - printf "%s\n" "$line" >> $IDEA_IML + printf "%s\n" "$line" >> $IDEA_JDK fi -done < "$IML_TEMPLATE" +done < "$JDK_TEMPLATE" MODULE_NAME=" " diff --git a/make/Main.gmk b/make/Main.gmk index 9e4917b4553..0dc06bd98ef 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -637,7 +637,7 @@ else # Declare dependencies between hotspot-* targets $(foreach v, $(JVM_VARIANTS), \ $(eval hotspot-$v: hotspot-$v-gensrc hotspot-$v-libs) \ - $(eval hotspot-$v-libs: hotspot-$v-gensrc) \ + $(eval hotspot-$v-libs: hotspot-$v-gensrc java.base-copy) \ ) hotspot-ide-project: hotspot exploded-image @@ -691,8 +691,9 @@ else jdk.jdwp.agent-libs: jdk.jdwp.agent-gensrc # The swing beans need to have java base properly generated to avoid errors - # in javadoc. - java.desktop-gensrc-src: java.base-gensrc + # in javadoc. The X11 wrappers need the java.base include files to have been + # copied and processed. + java.desktop-gensrc-src: java.base-gensrc java.base-copy # The annotation processing for jdk.internal.vm.ci and jdk.internal.vm.compiler # needs classes from the current JDK. diff --git a/make/autoconf/basics.m4 b/make/autoconf/basics.m4 index e30e596cbb5..394961dc433 100644 --- a/make/autoconf/basics.m4 +++ b/make/autoconf/basics.m4 @@ -586,69 +586,71 @@ AC_DEFUN([BASIC_EVAL_DEVKIT_VARIABLE], AC_DEFUN_ONCE([BASIC_SETUP_DEVKIT], [ AC_ARG_WITH([devkit], [AS_HELP_STRING([--with-devkit], - [use this devkit for compilers, tools and resources])], - [ - BASIC_FIXUP_PATH([with_devkit]) - DEVKIT_ROOT="$with_devkit" - # Check for a meta data info file in the root of the devkit - if test -f "$DEVKIT_ROOT/devkit.info"; then - . $DEVKIT_ROOT/devkit.info - # This potentially sets the following: - # A descriptive name of the devkit - BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_NAME]) - # Corresponds to --with-extra-path - BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_EXTRA_PATH]) - # Corresponds to --with-toolchain-path - BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_TOOLCHAIN_PATH]) - # Corresponds to --with-sysroot - BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_SYSROOT]) + [use this devkit for compilers, tools and resources])]) - # Identifies the Visual Studio version in the devkit - BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_VERSION]) - # The Visual Studio include environment variable - BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_INCLUDE]) - # The Visual Studio lib environment variable - BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_LIB]) - # Corresponds to --with-msvcr-dll - BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCR_DLL]) - # Corresponds to --with-msvcp-dll - BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCP_DLL]) - fi + if test "x$with_devkit" = xyes; then + AC_MSG_ERROR([--with-devkit must have a value]) + elif test "x$with_devkit" != x && test "x$with_devkit" != xno; then + BASIC_FIXUP_PATH([with_devkit]) + DEVKIT_ROOT="$with_devkit" + # Check for a meta data info file in the root of the devkit + if test -f "$DEVKIT_ROOT/devkit.info"; then + . $DEVKIT_ROOT/devkit.info + # This potentially sets the following: + # A descriptive name of the devkit + BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_NAME]) + # Corresponds to --with-extra-path + BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_EXTRA_PATH]) + # Corresponds to --with-toolchain-path + BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_TOOLCHAIN_PATH]) + # Corresponds to --with-sysroot + BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_SYSROOT]) - AC_MSG_CHECKING([for devkit]) - if test "x$DEVKIT_NAME" != x; then - AC_MSG_RESULT([$DEVKIT_NAME in $DEVKIT_ROOT]) - else - AC_MSG_RESULT([$DEVKIT_ROOT]) - fi + # Identifies the Visual Studio version in the devkit + BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_VERSION]) + # The Visual Studio include environment variable + BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_INCLUDE]) + # The Visual Studio lib environment variable + BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_VS_LIB]) + # Corresponds to --with-msvcr-dll + BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCR_DLL]) + # Corresponds to --with-msvcp-dll + BASIC_EVAL_DEVKIT_VARIABLE([DEVKIT_MSVCP_DLL]) + fi - BASIC_PREPEND_TO_PATH([EXTRA_PATH],$DEVKIT_EXTRA_PATH) + AC_MSG_CHECKING([for devkit]) + if test "x$DEVKIT_NAME" != x; then + AC_MSG_RESULT([$DEVKIT_NAME in $DEVKIT_ROOT]) + else + AC_MSG_RESULT([$DEVKIT_ROOT]) + fi - # Fallback default of just /bin if DEVKIT_PATH is not defined - if test "x$DEVKIT_TOOLCHAIN_PATH" = x; then - DEVKIT_TOOLCHAIN_PATH="$DEVKIT_ROOT/bin" - fi - BASIC_PREPEND_TO_PATH([TOOLCHAIN_PATH],$DEVKIT_TOOLCHAIN_PATH) + BASIC_PREPEND_TO_PATH([EXTRA_PATH],$DEVKIT_EXTRA_PATH) - # If DEVKIT_SYSROOT is set, use that, otherwise try a couple of known - # places for backwards compatiblity. - if test "x$DEVKIT_SYSROOT" != x; then - SYSROOT="$DEVKIT_SYSROOT" - elif test -d "$DEVKIT_ROOT/$host_alias/libc"; then - SYSROOT="$DEVKIT_ROOT/$host_alias/libc" - elif test -d "$DEVKIT_ROOT/$host/sys-root"; then - SYSROOT="$DEVKIT_ROOT/$host/sys-root" - fi + # Fallback default of just /bin if DEVKIT_PATH is not defined + if test "x$DEVKIT_TOOLCHAIN_PATH" = x; then + DEVKIT_TOOLCHAIN_PATH="$DEVKIT_ROOT/bin" + fi + BASIC_PREPEND_TO_PATH([TOOLCHAIN_PATH],$DEVKIT_TOOLCHAIN_PATH) - if test "x$DEVKIT_ROOT" != x; then - DEVKIT_LIB_DIR="$DEVKIT_ROOT/lib" - if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - DEVKIT_LIB_DIR="$DEVKIT_ROOT/lib64" - fi - AC_SUBST(DEVKIT_LIB_DIR) - fi - ] - ) + # If DEVKIT_SYSROOT is set, use that, otherwise try a couple of known + # places for backwards compatiblity. + if test "x$DEVKIT_SYSROOT" != x; then + SYSROOT="$DEVKIT_SYSROOT" + elif test -d "$DEVKIT_ROOT/$host_alias/libc"; then + SYSROOT="$DEVKIT_ROOT/$host_alias/libc" + elif test -d "$DEVKIT_ROOT/$host/sys-root"; then + SYSROOT="$DEVKIT_ROOT/$host/sys-root" + fi + + if test "x$DEVKIT_ROOT" != x; then + DEVKIT_LIB_DIR="$DEVKIT_ROOT/lib" + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then + DEVKIT_LIB_DIR="$DEVKIT_ROOT/lib64" + fi + AC_SUBST(DEVKIT_LIB_DIR) + fi + fi # You can force the sysroot if the sysroot encoded into the compiler tools # is not correct. @@ -1185,9 +1187,6 @@ AC_DEFUN_ONCE([BASIC_CHECK_SRC_PERMS], AC_DEFUN_ONCE([BASIC_TEST_USABILITY_ISSUES], [ - # Did user specify any unknown variables? - BASIC_CHECK_LEFTOVER_OVERRIDDEN - AC_MSG_CHECKING([if build directory is on local disk]) BASIC_CHECK_DIR_ON_LOCAL_DISK($OUTPUTDIR, [OUTPUT_DIR_IS_LOCAL="yes"], diff --git a/make/autoconf/buildjdk-spec.gmk.in b/make/autoconf/buildjdk-spec.gmk.in index aceaef7c452..b01d00b7c35 100644 --- a/make/autoconf/buildjdk-spec.gmk.in +++ b/make/autoconf/buildjdk-spec.gmk.in @@ -55,6 +55,7 @@ OPENJDK_TARGET_CPU_ARCH := @OPENJDK_BUILD_CPU_ARCH@ OPENJDK_TARGET_CPU_BITS := @OPENJDK_BUILD_CPU_BITS@ OPENJDK_TARGET_CPU_ENDIAN := @OPENJDK_BUILD_CPU_ENDIAN@ OPENJDK_TARGET_CPU_LEGACY := @OPENJDK_BUILD_CPU_LEGACY@ +OPENJDK_TARGET_OS_INCLUDE_SUBDIR := @OPENJDK_BUILD_OS_INCLUDE_SUBDIR@ HOTSPOT_TARGET_OS := @HOTSPOT_BUILD_OS@ HOTSPOT_TARGET_OS_TYPE := @HOTSPOT_BUILD_OS_TYPE@ diff --git a/make/autoconf/configure.ac b/make/autoconf/configure.ac index 26946f38152..cee41fba70d 100644 --- a/make/autoconf/configure.ac +++ b/make/autoconf/configure.ac @@ -280,6 +280,9 @@ CUSTOM_LATE_HOOK # This needs to be done after CUSTOM_LATE_HOOK since we can setup custom features. HOTSPOT_VALIDATE_JVM_FEATURES +# Did user specify any unknown variables? +BASIC_CHECK_LEFTOVER_OVERRIDDEN + # We're messing a bit with internal autoconf variables to put the config.status # in the output directory instead of the current directory. CONFIG_STATUS="$CONFIGURESUPPORT_OUTPUTDIR/config.status" diff --git a/make/autoconf/flags.m4 b/make/autoconf/flags.m4 index b1c2982aa65..85a014bdbd5 100644 --- a/make/autoconf/flags.m4 +++ b/make/autoconf/flags.m4 @@ -1162,9 +1162,7 @@ AC_DEFUN([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK_HELPER], # Setup some hard coded includes $2COMMON_CCXXFLAGS_JDK="[$]$2COMMON_CCXXFLAGS_JDK \ -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ - -I${TOPDIR}/src/java.base/share/native/include \ - -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS/native/include \ - -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/include \ + -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \ -I${TOPDIR}/src/java.base/share/native/libjava \ -I${TOPDIR}/src/java.base/$OPENJDK_$1_OS_TYPE/native/libjava \ -I${TOPDIR}/src/hotspot/share/include \ diff --git a/make/autoconf/generated-configure.sh b/make/autoconf/generated-configure.sh index d1fefffe605..ffc5bdafa7f 100644 --- a/make/autoconf/generated-configure.sh +++ b/make/autoconf/generated-configure.sh @@ -886,6 +886,8 @@ JAVA BOOT_JDK JAVA_CHECK JAVAC_CHECK +VERSION_CLASSFILE_MINOR +VERSION_CLASSFILE_MAJOR VENDOR_VERSION_STRING VERSION_DATE VERSION_IS_GA @@ -970,6 +972,7 @@ JDK_VARIANT USERNAME TOPDIR PATH_SEP +OPENJDK_BUILD_OS_INCLUDE_SUBDIR HOTSPOT_BUILD_CPU_DEFINE HOTSPOT_BUILD_CPU_ARCH HOTSPOT_BUILD_CPU @@ -980,6 +983,7 @@ OPENJDK_BUILD_CPU_OSARCH OPENJDK_BUILD_CPU_ISADIR OPENJDK_BUILD_CPU_LEGACY_LIB OPENJDK_BUILD_CPU_LEGACY +OPENJDK_TARGET_OS_INCLUDE_SUBDIR HOTSPOT_TARGET_CPU_DEFINE HOTSPOT_TARGET_CPU_ARCH HOTSPOT_TARGET_CPU @@ -5113,7 +5117,7 @@ TOOLCHAIN_MINIMUM_VERSION_xlc="" ################################################################################ # The order of these defines the priority by which we try to find them. -VALID_VS_VERSIONS="2013 2012 2010" +VALID_VS_VERSIONS="2013 2012 2010 2015 2017" VS_DESCRIPTION_2010="Microsoft Visual Studio 2010" VS_VERSION_INTERNAL_2010=100 @@ -5146,6 +5150,30 @@ VS_SDK_INSTALLDIR_2013= VS_VS_PLATFORM_NAME_2013="v120" VS_SDK_PLATFORM_NAME_2013= +VS_DESCRIPTION_2015="Microsoft Visual Studio 2015 - CURRENTLY NOT WORKING" +VS_VERSION_INTERNAL_2015=140 +VS_MSVCR_2015=vcruntime140.dll +VS_MSVCP_2015=msvcp140.dll +VS_ENVVAR_2015="VS140COMNTOOLS" +VS_VS_INSTALLDIR_2015="Microsoft Visual Studio 14.0" +VS_SDK_INSTALLDIR_2015= +VS_VS_PLATFORM_NAME_2015="v140" +VS_SDK_PLATFORM_NAME_2015= +# The vcvars of 2015 breaks if 2017 is also installed. Work around this by +# explicitly specifying Windows Kit 8.1 to be used. +VS_ENV_ARGS_2015="8.1" + +VS_DESCRIPTION_2017="Microsoft Visual Studio 2017 - CURRENTLY NOT WORKING" +VS_VERSION_INTERNAL_2017=141 +VS_MSVCR_2017=vcruntime140.dll +VS_MSVCP_2017=msvcp140.dll +VS_ENVVAR_2017="VS150COMNTOOLS" +VS_VS_INSTALLDIR_2017="Microsoft Visual Studio/2017" +VS_EDITIONS_2017="Community Professional Enterprise" +VS_SDK_INSTALLDIR_2017= +VS_VS_PLATFORM_NAME_2017="v141" +VS_SDK_PLATFORM_NAME_2017= + ################################################################################ @@ -5187,7 +5215,7 @@ VS_SDK_PLATFORM_NAME_2013= #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1516225089 +DATE_WHEN_GENERATED=1517274450 ############################################################################### # @@ -16318,6 +16346,14 @@ $as_echo "$COMPILE_TYPE" >&6; } fi + # For historical reasons, the OS include directories have odd names. + OPENJDK_TARGET_OS_INCLUDE_SUBDIR="$OPENJDK_TARGET_OS" + if test "x$OPENJDK_TARGET_OS" = "xwindows"; then + OPENJDK_TARGET_OS_INCLUDE_SUBDIR="win32" + elif test "x$OPENJDK_TARGET_OS" = "xmacosx"; then + OPENJDK_TARGET_OS_INCLUDE_SUBDIR="darwin" + fi + # Also store the legacy naming of the cpu. @@ -16469,6 +16505,14 @@ $as_echo "$COMPILE_TYPE" >&6; } fi + # For historical reasons, the OS include directories have odd names. + OPENJDK_BUILD_OS_INCLUDE_SUBDIR="$OPENJDK_TARGET_OS" + if test "x$OPENJDK_TARGET_OS" = "xwindows"; then + OPENJDK_BUILD_OS_INCLUDE_SUBDIR="win32" + elif test "x$OPENJDK_TARGET_OS" = "xmacosx"; then + OPENJDK_BUILD_OS_INCLUDE_SUBDIR="darwin" + fi + @@ -17093,6 +17137,12 @@ $as_echo "$as_me: Unknown variant(s) specified: $INVALID_VARIANTS" >&6;} # Check whether --with-devkit was given. if test "${with_devkit+set}" = set; then : withval=$with_devkit; +fi + + + if test "x$with_devkit" = xyes; then + as_fn_error $? "--with-devkit must have a value" "$LINENO" 5 + elif test "x$with_devkit" != x && test "x$with_devkit" != xno; then # Only process if variable expands to non-empty @@ -17225,77 +17275,77 @@ $as_echo "$as_me: The path of with_devkit, which resolves as \"$path\", is inval fi fi - DEVKIT_ROOT="$with_devkit" - # Check for a meta data info file in the root of the devkit - if test -f "$DEVKIT_ROOT/devkit.info"; then - . $DEVKIT_ROOT/devkit.info - # This potentially sets the following: - # A descriptive name of the devkit + DEVKIT_ROOT="$with_devkit" + # Check for a meta data info file in the root of the devkit + if test -f "$DEVKIT_ROOT/devkit.info"; then + . $DEVKIT_ROOT/devkit.info + # This potentially sets the following: + # A descriptive name of the devkit if test "x$DEVKIT_NAME" = x; then eval DEVKIT_NAME="\${DEVKIT_NAME_${OPENJDK_TARGET_CPU}}" fi - # Corresponds to --with-extra-path + # Corresponds to --with-extra-path if test "x$DEVKIT_EXTRA_PATH" = x; then eval DEVKIT_EXTRA_PATH="\${DEVKIT_EXTRA_PATH_${OPENJDK_TARGET_CPU}}" fi - # Corresponds to --with-toolchain-path + # Corresponds to --with-toolchain-path if test "x$DEVKIT_TOOLCHAIN_PATH" = x; then eval DEVKIT_TOOLCHAIN_PATH="\${DEVKIT_TOOLCHAIN_PATH_${OPENJDK_TARGET_CPU}}" fi - # Corresponds to --with-sysroot + # Corresponds to --with-sysroot if test "x$DEVKIT_SYSROOT" = x; then eval DEVKIT_SYSROOT="\${DEVKIT_SYSROOT_${OPENJDK_TARGET_CPU}}" fi - # Identifies the Visual Studio version in the devkit + # Identifies the Visual Studio version in the devkit if test "x$DEVKIT_VS_VERSION" = x; then eval DEVKIT_VS_VERSION="\${DEVKIT_VS_VERSION_${OPENJDK_TARGET_CPU}}" fi - # The Visual Studio include environment variable + # The Visual Studio include environment variable if test "x$DEVKIT_VS_INCLUDE" = x; then eval DEVKIT_VS_INCLUDE="\${DEVKIT_VS_INCLUDE_${OPENJDK_TARGET_CPU}}" fi - # The Visual Studio lib environment variable + # The Visual Studio lib environment variable if test "x$DEVKIT_VS_LIB" = x; then eval DEVKIT_VS_LIB="\${DEVKIT_VS_LIB_${OPENJDK_TARGET_CPU}}" fi - # Corresponds to --with-msvcr-dll + # Corresponds to --with-msvcr-dll if test "x$DEVKIT_MSVCR_DLL" = x; then eval DEVKIT_MSVCR_DLL="\${DEVKIT_MSVCR_DLL_${OPENJDK_TARGET_CPU}}" fi - # Corresponds to --with-msvcp-dll + # Corresponds to --with-msvcp-dll if test "x$DEVKIT_MSVCP_DLL" = x; then eval DEVKIT_MSVCP_DLL="\${DEVKIT_MSVCP_DLL_${OPENJDK_TARGET_CPU}}" fi - fi + fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for devkit" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for devkit" >&5 $as_echo_n "checking for devkit... " >&6; } - if test "x$DEVKIT_NAME" != x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEVKIT_NAME in $DEVKIT_ROOT" >&5 + if test "x$DEVKIT_NAME" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEVKIT_NAME in $DEVKIT_ROOT" >&5 $as_echo "$DEVKIT_NAME in $DEVKIT_ROOT" >&6; } - else - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEVKIT_ROOT" >&5 + else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DEVKIT_ROOT" >&5 $as_echo "$DEVKIT_ROOT" >&6; } - fi + fi if test "x$DEVKIT_EXTRA_PATH" != x; then @@ -17307,10 +17357,10 @@ $as_echo "$DEVKIT_ROOT" >&6; } fi - # Fallback default of just /bin if DEVKIT_PATH is not defined - if test "x$DEVKIT_TOOLCHAIN_PATH" = x; then - DEVKIT_TOOLCHAIN_PATH="$DEVKIT_ROOT/bin" - fi + # Fallback default of just /bin if DEVKIT_PATH is not defined + if test "x$DEVKIT_TOOLCHAIN_PATH" = x; then + DEVKIT_TOOLCHAIN_PATH="$DEVKIT_ROOT/bin" + fi if test "x$DEVKIT_TOOLCHAIN_PATH" != x; then if test "x$TOOLCHAIN_PATH" = x; then @@ -17321,27 +17371,24 @@ $as_echo "$DEVKIT_ROOT" >&6; } fi - # If DEVKIT_SYSROOT is set, use that, otherwise try a couple of known - # places for backwards compatiblity. - if test "x$DEVKIT_SYSROOT" != x; then - SYSROOT="$DEVKIT_SYSROOT" - elif test -d "$DEVKIT_ROOT/$host_alias/libc"; then - SYSROOT="$DEVKIT_ROOT/$host_alias/libc" - elif test -d "$DEVKIT_ROOT/$host/sys-root"; then - SYSROOT="$DEVKIT_ROOT/$host/sys-root" - fi + # If DEVKIT_SYSROOT is set, use that, otherwise try a couple of known + # places for backwards compatiblity. + if test "x$DEVKIT_SYSROOT" != x; then + SYSROOT="$DEVKIT_SYSROOT" + elif test -d "$DEVKIT_ROOT/$host_alias/libc"; then + SYSROOT="$DEVKIT_ROOT/$host_alias/libc" + elif test -d "$DEVKIT_ROOT/$host/sys-root"; then + SYSROOT="$DEVKIT_ROOT/$host/sys-root" + fi - if test "x$DEVKIT_ROOT" != x; then - DEVKIT_LIB_DIR="$DEVKIT_ROOT/lib" - if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - DEVKIT_LIB_DIR="$DEVKIT_ROOT/lib64" - fi - - fi - - -fi + if test "x$DEVKIT_ROOT" != x; then + DEVKIT_LIB_DIR="$DEVKIT_ROOT/lib" + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then + DEVKIT_LIB_DIR="$DEVKIT_ROOT/lib64" + fi + fi + fi # You can force the sysroot if the sysroot encoded into the compiler tools # is not correct. @@ -25524,6 +25571,10 @@ fi VENDOR_VERSION_STRING="$with_vendor_version_string" fi + # We could define --with flags for these, if really needed + VERSION_CLASSFILE_MAJOR="$DEFAULT_VERSION_CLASSFILE_MAJOR" + VERSION_CLASSFILE_MINOR="$DEFAULT_VERSION_CLASSFILE_MINOR" + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for version string" >&5 $as_echo_n "checking for version string... " >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: result: $VERSION_STRING" >&5 @@ -25545,6 +25596,9 @@ $as_echo "$VERSION_STRING" >&6; } + + + ############################################################################### # # Setup BootJDK, used to bootstrap the build. @@ -32272,7 +32326,11 @@ $as_echo "$as_me: The following toolchain versions are valid on this platform:" elif test "x$DEVKIT_VS_VERSION" != x; then VS_VERSION=$DEVKIT_VS_VERSION TOOLCHAIN_VERSION=$VS_VERSION - eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}" + # If the devkit has a name, use that as description + VS_DESCRIPTION="$DEVKIT_NAME" + if test "x$VS_DESCRIPTION" = x; then + eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}" + fi eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}" eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}" eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}" @@ -32340,7 +32398,9 @@ $as_echo "$as_me: Valid Visual Studio versions: $VALID_VS_VERSIONS." >&6;} eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}" eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}" eval VS_INSTALL_DIR="\${VS_VS_INSTALLDIR_${VS_VERSION}}" + eval VS_EDITIONS="\${VS_EDITIONS_${VS_VERSION}}" eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}" + eval VS_ENV_ARGS="\${VS_ENV_ARGS_${VS_VERSION}}" # When using --with-tools-dir, assume it points to the correct and default # version of Visual Studio or that --with-toolchain-version was also set. @@ -32351,12 +32411,6 @@ $as_echo "$as_me: Valid Visual Studio versions: $VALID_VS_VERSIONS." >&6;} VS_BASE="$with_tools_dir/../.." METHOD="--with-tools-dir" - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - VCVARSFILE="vc/bin/vcvars32.bat" - else - VCVARSFILE="vc/bin/amd64/vcvars64.bat" - fi - windows_path="$VS_BASE" if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -32367,19 +32421,42 @@ $as_echo "$as_me: Valid Visual Studio versions: $VALID_VS_VERSIONS." >&6;} VS_BASE="$unix_path" fi + # In VS 2017, the default installation is in a subdir named after the edition. + # Find the first one present and use that. + if test "x$VS_EDITIONS" != x; then + for edition in $VS_EDITIONS; do + if test -d "$VS_BASE/$edition"; then + VS_BASE="$VS_BASE/$edition" + break + fi + done + fi + if test -d "$VS_BASE"; then - if test -f "$VS_BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS_BASE/$VCVARSFILE" - # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see - # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013 - eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat" else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \ + vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat" + fi + + for VCVARSFILE in $VCVARSFILES; do + if test -f "$VS_BASE/$VCVARSFILE"; then + VS_ENV_CMD="$VS_BASE/$VCVARSFILE" + break + fi + done + + if test "x$VS_ENV_CMD" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&5 +$as_echo "$as_me: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&6;} + else + # PLATFORM_TOOLSET is used during the compilation of the freetype sources + # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', + # 'v110' or 'v120' for VS 2010, 2012 or VS2013 + eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" fi fi fi @@ -32390,12 +32467,6 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi VS_BASE="$with_tools_dir/../../.." METHOD="--with-tools-dir" - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - VCVARSFILE="vc/bin/vcvars32.bat" - else - VCVARSFILE="vc/bin/amd64/vcvars64.bat" - fi - windows_path="$VS_BASE" if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -32406,19 +32477,42 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi VS_BASE="$unix_path" fi + # In VS 2017, the default installation is in a subdir named after the edition. + # Find the first one present and use that. + if test "x$VS_EDITIONS" != x; then + for edition in $VS_EDITIONS; do + if test -d "$VS_BASE/$edition"; then + VS_BASE="$VS_BASE/$edition" + break + fi + done + fi + if test -d "$VS_BASE"; then - if test -f "$VS_BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS_BASE/$VCVARSFILE" - # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see - # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013 - eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat" else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \ + vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat" + fi + + for VCVARSFILE in $VCVARSFILES; do + if test -f "$VS_BASE/$VCVARSFILE"; then + VS_ENV_CMD="$VS_BASE/$VCVARSFILE" + break + fi + done + + if test "x$VS_ENV_CMD" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&5 +$as_echo "$as_me: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&6;} + else + # PLATFORM_TOOLSET is used during the compilation of the freetype sources + # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', + # 'v110' or 'v120' for VS 2010, 2012 or VS2013 + eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" fi fi fi @@ -32437,7 +32531,6 @@ $as_echo "$as_me: directory within the Visual Studio installation" >&6;} fi VS_ENV_CMD="" - VS_ENV_ARGS="" if test "x$VS_COMNTOOLS" != x; then @@ -32446,12 +32539,6 @@ $as_echo "$as_me: directory within the Visual Studio installation" >&6;} VS_BASE="$VS_COMNTOOLS/../.." METHOD="$VS_COMNTOOLS_VAR variable" - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - VCVARSFILE="vc/bin/vcvars32.bat" - else - VCVARSFILE="vc/bin/amd64/vcvars64.bat" - fi - windows_path="$VS_BASE" if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -32462,19 +32549,42 @@ $as_echo "$as_me: directory within the Visual Studio installation" >&6;} VS_BASE="$unix_path" fi + # In VS 2017, the default installation is in a subdir named after the edition. + # Find the first one present and use that. + if test "x$VS_EDITIONS" != x; then + for edition in $VS_EDITIONS; do + if test -d "$VS_BASE/$edition"; then + VS_BASE="$VS_BASE/$edition" + break + fi + done + fi + if test -d "$VS_BASE"; then - if test -f "$VS_BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS_BASE/$VCVARSFILE" - # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see - # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013 - eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat" else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \ + vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat" + fi + + for VCVARSFILE in $VCVARSFILES; do + if test -f "$VS_BASE/$VCVARSFILE"; then + VS_ENV_CMD="$VS_BASE/$VCVARSFILE" + break + fi + done + + if test "x$VS_ENV_CMD" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&5 +$as_echo "$as_me: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&6;} + else + # PLATFORM_TOOLSET is used during the compilation of the freetype sources + # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', + # 'v110' or 'v120' for VS 2010, 2012 or VS2013 + eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" fi fi fi @@ -32487,12 +32597,6 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi VS_BASE="$PROGRAMFILES/$VS_INSTALL_DIR" METHOD="well-known name" - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - VCVARSFILE="vc/bin/vcvars32.bat" - else - VCVARSFILE="vc/bin/amd64/vcvars64.bat" - fi - windows_path="$VS_BASE" if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -32503,19 +32607,42 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi VS_BASE="$unix_path" fi + # In VS 2017, the default installation is in a subdir named after the edition. + # Find the first one present and use that. + if test "x$VS_EDITIONS" != x; then + for edition in $VS_EDITIONS; do + if test -d "$VS_BASE/$edition"; then + VS_BASE="$VS_BASE/$edition" + break + fi + done + fi + if test -d "$VS_BASE"; then - if test -f "$VS_BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS_BASE/$VCVARSFILE" - # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see - # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013 - eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat" else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \ + vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat" + fi + + for VCVARSFILE in $VCVARSFILES; do + if test -f "$VS_BASE/$VCVARSFILE"; then + VS_ENV_CMD="$VS_BASE/$VCVARSFILE" + break + fi + done + + if test "x$VS_ENV_CMD" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&5 +$as_echo "$as_me: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&6;} + else + # PLATFORM_TOOLSET is used during the compilation of the freetype sources + # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', + # 'v110' or 'v120' for VS 2010, 2012 or VS2013 + eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" fi fi fi @@ -32530,12 +32657,6 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi VS_BASE="$PROGRAMFILES_X86/$VS_INSTALL_DIR" METHOD="well-known name" - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - VCVARSFILE="vc/bin/vcvars32.bat" - else - VCVARSFILE="vc/bin/amd64/vcvars64.bat" - fi - windows_path="$VS_BASE" if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -32546,19 +32667,42 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi VS_BASE="$unix_path" fi + # In VS 2017, the default installation is in a subdir named after the edition. + # Find the first one present and use that. + if test "x$VS_EDITIONS" != x; then + for edition in $VS_EDITIONS; do + if test -d "$VS_BASE/$edition"; then + VS_BASE="$VS_BASE/$edition" + break + fi + done + fi + if test -d "$VS_BASE"; then - if test -f "$VS_BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS_BASE/$VCVARSFILE" - # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see - # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013 - eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat" else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \ + vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat" + fi + + for VCVARSFILE in $VCVARSFILES; do + if test -f "$VS_BASE/$VCVARSFILE"; then + VS_ENV_CMD="$VS_BASE/$VCVARSFILE" + break + fi + done + + if test "x$VS_ENV_CMD" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&5 +$as_echo "$as_me: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&6;} + else + # PLATFORM_TOOLSET is used during the compilation of the freetype sources + # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', + # 'v110' or 'v120' for VS 2010, 2012 or VS2013 + eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" fi fi fi @@ -32570,12 +32714,6 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi VS_BASE="C:/Program Files/$VS_INSTALL_DIR" METHOD="well-known name" - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - VCVARSFILE="vc/bin/vcvars32.bat" - else - VCVARSFILE="vc/bin/amd64/vcvars64.bat" - fi - windows_path="$VS_BASE" if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -32586,19 +32724,42 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi VS_BASE="$unix_path" fi + # In VS 2017, the default installation is in a subdir named after the edition. + # Find the first one present and use that. + if test "x$VS_EDITIONS" != x; then + for edition in $VS_EDITIONS; do + if test -d "$VS_BASE/$edition"; then + VS_BASE="$VS_BASE/$edition" + break + fi + done + fi + if test -d "$VS_BASE"; then - if test -f "$VS_BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS_BASE/$VCVARSFILE" - # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see - # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013 - eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat" else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \ + vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat" + fi + + for VCVARSFILE in $VCVARSFILES; do + if test -f "$VS_BASE/$VCVARSFILE"; then + VS_ENV_CMD="$VS_BASE/$VCVARSFILE" + break + fi + done + + if test "x$VS_ENV_CMD" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&5 +$as_echo "$as_me: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&6;} + else + # PLATFORM_TOOLSET is used during the compilation of the freetype sources + # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', + # 'v110' or 'v120' for VS 2010, 2012 or VS2013 + eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" fi fi fi @@ -32609,12 +32770,6 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi VS_BASE="C:/Program Files (x86)/$VS_INSTALL_DIR" METHOD="well-known name" - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - VCVARSFILE="vc/bin/vcvars32.bat" - else - VCVARSFILE="vc/bin/amd64/vcvars64.bat" - fi - windows_path="$VS_BASE" if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then @@ -32625,19 +32780,42 @@ $as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studi VS_BASE="$unix_path" fi + # In VS 2017, the default installation is in a subdir named after the edition. + # Find the first one present and use that. + if test "x$VS_EDITIONS" != x; then + for edition in $VS_EDITIONS; do + if test -d "$VS_BASE/$edition"; then + VS_BASE="$VS_BASE/$edition" + break + fi + done + fi + if test -d "$VS_BASE"; then - if test -f "$VS_BASE/$VCVARSFILE"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 $as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - VS_ENV_CMD="$VS_BASE/$VCVARSFILE" - # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see - # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013 - eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat" else - { $as_echo "$as_me:${as_lineno-$LINENO}: Found Visual Studio installation at $VS_BASE using $METHOD" >&5 -$as_echo "$as_me: Found Visual Studio installation at $VS_BASE using $METHOD" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&5 -$as_echo "$as_me: Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring" >&6;} + VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \ + vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat" + fi + + for VCVARSFILE in $VCVARSFILES; do + if test -f "$VS_BASE/$VCVARSFILE"; then + VS_ENV_CMD="$VS_BASE/$VCVARSFILE" + break + fi + done + + if test "x$VS_ENV_CMD" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&5 +$as_echo "$as_me: Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring" >&6;} + else + # PLATFORM_TOOLSET is used during the compilation of the freetype sources + # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', + # 'v110' or 'v120' for VS 2010, 2012 or VS2013 + eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" fi fi fi @@ -32890,6 +33068,11 @@ $as_echo "$as_me: Found $VS_DESCRIPTION" >&6;} fi done + TOOLCHAIN_DESCRIPTION="$VS_DESCRIPTION" + if test "$TOOLCHAIN_VERSION" -gt 2013; then + UNSUPPORTED_TOOLCHAIN_VERSION=yes + fi + # If we have a devkit, skip all of the below. if test "x$DEVKIT_VS_VERSION" = x; then @@ -33222,6 +33405,9 @@ $as_echo "$as_me: Trying to extract Visual Studio environment variables" >&6;} # This will end up something like: # call C:/progra~2/micros~2.0/vc/bin/amd64/vcvars64.bat $ECHO "call $WINPATH_VS_ENV_CMD $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE + # In some cases, the VS_ENV_CMD will change directory, change back so + # the set-vs-env.sh ends up in the right place. + $ECHO 'cd %~dp0' >> $EXTRACT_VC_ENV_BAT_FILE # These will end up something like: # C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh # The trailing space for everyone except PATH is no typo, but is needed due @@ -33643,7 +33829,7 @@ $as_echo "$as_me: or run \"bash.exe -l\" from a VS command prompt and then run c if test "x$XCODE_VERSION_OUTPUT" != x; then # For Xcode, we set the Xcode version as TOOLCHAIN_VERSION TOOLCHAIN_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | $CUT -f 2 -d ' '` - TOOLCHAIN_DESCRIPTION="$TOOLCHAIN_DESCRIPTION from Xcode" + TOOLCHAIN_DESCRIPTION="$TOOLCHAIN_DESCRIPTION from Xcode $TOOLCHAIN_VERSION" else # Currently we do not define this for other toolchains. This might change as the need arise. TOOLCHAIN_VERSION= @@ -52817,9 +53003,7 @@ fi # Setup some hard coded includes COMMON_CCXXFLAGS_JDK="$COMMON_CCXXFLAGS_JDK \ -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ - -I${TOPDIR}/src/java.base/share/native/include \ - -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS/native/include \ - -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/include \ + -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \ -I${TOPDIR}/src/java.base/share/native/libjava \ -I${TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava \ -I${TOPDIR}/src/hotspot/share/include \ @@ -53700,9 +53884,7 @@ fi # Setup some hard coded includes OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK="$OPENJDK_BUILD_COMMON_CCXXFLAGS_JDK \ -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ - -I${TOPDIR}/src/java.base/share/native/include \ - -I${TOPDIR}/src/java.base/$OPENJDK_BUILD_OS/native/include \ - -I${TOPDIR}/src/java.base/$OPENJDK_BUILD_OS_TYPE/native/include \ + -I\$(SUPPORT_OUTPUTDIR)/modules_include/java.base/\$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \ -I${TOPDIR}/src/java.base/share/native/libjava \ -I${TOPDIR}/src/java.base/$OPENJDK_BUILD_OS_TYPE/native/libjava \ -I${TOPDIR}/src/hotspot/share/include \ @@ -55865,7 +56047,6 @@ $as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" MSVC_DLL= if test "x$MSVC_DLL" = x; then - # Probe: Using well-known location from Visual Studio 10.0 if test "x$VCINSTALLDIR" != x; then CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR" @@ -55878,15 +56059,27 @@ $as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" CYGWIN_VC_INSTALL_DIR="$unix_path" fi - if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + if test "$VS_VERSION" -lt 2017; then + # Probe: Using well-known location from Visual Studio 12.0 and older + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then + POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + else + POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + fi else - POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + # Probe: Using well-known location from VS 2017 + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then + POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`" + else + POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`" + fi fi - $ECHO "POSSIBLE_MSVC_DLL $POSSIBLEMSVC_DLL" + # In case any of the above finds more than one file, loop over them. + for possible_msvc_dll in $POSSIBLE_MSVC_DLL; do + $ECHO "POSSIBLE_MSVC_DLL $possible_msvc_dll" DLL_NAME="$DLL_NAME" - POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL" + POSSIBLE_MSVC_DLL="$possible_msvc_dll" METHOD="well-known location in VCINSTALLDIR" if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5 @@ -56059,6 +56252,7 @@ $as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" fi fi + done fi fi @@ -57214,7 +57408,6 @@ $as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" MSVC_DLL= if test "x$MSVC_DLL" = x; then - # Probe: Using well-known location from Visual Studio 10.0 if test "x$VCINSTALLDIR" != x; then CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR" @@ -57227,15 +57420,27 @@ $as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" CYGWIN_VC_INSTALL_DIR="$unix_path" fi - if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + if test "$VS_VERSION" -lt 2017; then + # Probe: Using well-known location from Visual Studio 12.0 and older + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then + POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + else + POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + fi else - POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + # Probe: Using well-known location from VS 2017 + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then + POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`" + else + POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`" + fi fi - $ECHO "POSSIBLE_MSVC_DLL $POSSIBLEMSVC_DLL" + # In case any of the above finds more than one file, loop over them. + for possible_msvc_dll in $POSSIBLE_MSVC_DLL; do + $ECHO "POSSIBLE_MSVC_DLL $possible_msvc_dll" DLL_NAME="$DLL_NAME" - POSSIBLE_MSVC_DLL="$POSSIBLE_MSVC_DLL" + POSSIBLE_MSVC_DLL="$possible_msvc_dll" METHOD="well-known location in VCINSTALLDIR" if test -n "$POSSIBLE_MSVC_DLL" -a -e "$POSSIBLE_MSVC_DLL"; then { $as_echo "$as_me:${as_lineno-$LINENO}: Found $DLL_NAME at $POSSIBLE_MSVC_DLL using $METHOD" >&5 @@ -57408,6 +57613,7 @@ $as_echo "$as_me: The file type of the located $DLL_NAME is $MSVC_DLL_FILETYPE" fi fi + done fi fi @@ -68877,16 +69083,6 @@ $as_echo "no" >&6; } fi - # Did user specify any unknown variables? - - if test "x$CONFIGURE_OVERRIDDEN_VARIABLES" != x; then - # Replace the separating ! with spaces before presenting for end user. - unknown_variables=${CONFIGURE_OVERRIDDEN_VARIABLES//!/ } - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The following variables might be unknown to configure: $unknown_variables" >&5 -$as_echo "$as_me: WARNING: The following variables might be unknown to configure: $unknown_variables" >&2;} - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking if build directory is on local disk" >&5 $as_echo_n "checking if build directory is on local disk... " >&6; } @@ -68968,6 +69164,16 @@ $as_echo "$JVM_FEATURES_TO_TEST" >&6; } done +# Did user specify any unknown variables? + + if test "x$CONFIGURE_OVERRIDDEN_VARIABLES" != x; then + # Replace the separating ! with spaces before presenting for end user. + unknown_variables=${CONFIGURE_OVERRIDDEN_VARIABLES//!/ } + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The following variables might be unknown to configure: $unknown_variables" >&5 +$as_echo "$as_me: WARNING: The following variables might be unknown to configure: $unknown_variables" >&2;} + fi + + # We're messing a bit with internal autoconf variables to put the config.status # in the output directory instead of the current directory. CONFIG_STATUS="$CONFIGURESUPPORT_OUTPUTDIR/config.status" @@ -70200,10 +70406,7 @@ fi printf "* Environment: $WINDOWS_ENV_VENDOR version $WINDOWS_ENV_VERSION (root at $WINDOWS_ENV_ROOT_PATH)\n" fi printf "* Boot JDK: $BOOT_JDK_VERSION (at $BOOT_JDK)\n" - if test "x$TOOLCHAIN_VERSION" != "x"; then - print_version=" $TOOLCHAIN_VERSION" - fi - printf "* Toolchain: $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION$print_version)\n" + printf "* Toolchain: $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)\n" printf "* C Compiler: Version $CC_VERSION_NUMBER (at $CC)\n" printf "* C++ Compiler: Version $CXX_VERSION_NUMBER (at $CXX)\n" @@ -70251,6 +70454,12 @@ fi printf "\n" fi + if test "x$UNSUPPORTED_TOOLCHAIN_VERSION" = "xyes"; then + printf "WARNING: The toolchain version used is known to have issues. Please\n" + printf "consider using a supported version unless you know what you are doing.\n" + printf "\n" + fi + # Locate config.log. diff --git a/make/autoconf/help.m4 b/make/autoconf/help.m4 index 3937b93c15b..785597300be 100644 --- a/make/autoconf/help.m4 +++ b/make/autoconf/help.m4 @@ -242,10 +242,7 @@ AC_DEFUN_ONCE([HELP_PRINT_SUMMARY_AND_WARNINGS], printf "* Environment: $WINDOWS_ENV_VENDOR version $WINDOWS_ENV_VERSION (root at $WINDOWS_ENV_ROOT_PATH)\n" fi printf "* Boot JDK: $BOOT_JDK_VERSION (at $BOOT_JDK)\n" - if test "x$TOOLCHAIN_VERSION" != "x"; then - print_version=" $TOOLCHAIN_VERSION" - fi - printf "* Toolchain: $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION$print_version)\n" + printf "* Toolchain: $TOOLCHAIN_TYPE ($TOOLCHAIN_DESCRIPTION)\n" printf "* C Compiler: Version $CC_VERSION_NUMBER (at $CC)\n" printf "* C++ Compiler: Version $CXX_VERSION_NUMBER (at $CXX)\n" @@ -292,6 +289,12 @@ AC_DEFUN_ONCE([HELP_PRINT_SUMMARY_AND_WARNINGS], printf "You should run without '--no-create | -n' to create the configuration.\n" printf "\n" fi + + if test "x$UNSUPPORTED_TOOLCHAIN_VERSION" = "xyes"; then + printf "WARNING: The toolchain version used is known to have issues. Please\n" + printf "consider using a supported version unless you know what you are doing.\n" + printf "\n" + fi ]) AC_DEFUN_ONCE([HELP_REPEAT_WARNINGS], diff --git a/make/autoconf/jdk-version.m4 b/make/autoconf/jdk-version.m4 index 37985385a26..b6580cd372e 100644 --- a/make/autoconf/jdk-version.m4 +++ b/make/autoconf/jdk-version.m4 @@ -381,6 +381,10 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS], VENDOR_VERSION_STRING="$with_vendor_version_string" fi + # We could define --with flags for these, if really needed + VERSION_CLASSFILE_MAJOR="$DEFAULT_VERSION_CLASSFILE_MAJOR" + VERSION_CLASSFILE_MINOR="$DEFAULT_VERSION_CLASSFILE_MINOR" + AC_MSG_CHECKING([for version string]) AC_MSG_RESULT([$VERSION_STRING]) @@ -398,4 +402,7 @@ AC_DEFUN_ONCE([JDKVER_SETUP_JDK_VERSION_NUMBERS], AC_SUBST(VERSION_IS_GA) AC_SUBST(VERSION_DATE) AC_SUBST(VENDOR_VERSION_STRING) + AC_SUBST(VERSION_CLASSFILE_MAJOR) + AC_SUBST(VERSION_CLASSFILE_MINOR) + ]) diff --git a/make/autoconf/platform.m4 b/make/autoconf/platform.m4 index f62f94daace..654ce9b2b4e 100644 --- a/make/autoconf/platform.m4 +++ b/make/autoconf/platform.m4 @@ -478,6 +478,14 @@ AC_DEFUN([PLATFORM_SETUP_LEGACY_VARS_HELPER], fi AC_SUBST(HOTSPOT_$1_CPU_DEFINE) + # For historical reasons, the OS include directories have odd names. + OPENJDK_$1_OS_INCLUDE_SUBDIR="$OPENJDK_TARGET_OS" + if test "x$OPENJDK_TARGET_OS" = "xwindows"; then + OPENJDK_$1_OS_INCLUDE_SUBDIR="win32" + elif test "x$OPENJDK_TARGET_OS" = "xmacosx"; then + OPENJDK_$1_OS_INCLUDE_SUBDIR="darwin" + fi + AC_SUBST(OPENJDK_$1_OS_INCLUDE_SUBDIR) ]) AC_DEFUN([PLATFORM_SET_RELEASE_FILE_OS_VALUES], diff --git a/make/autoconf/spec.gmk.in b/make/autoconf/spec.gmk.in index 38a30a44cf6..307a28a3f53 100644 --- a/make/autoconf/spec.gmk.in +++ b/make/autoconf/spec.gmk.in @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -78,6 +78,7 @@ OPENJDK_TARGET_CPU_ISADIR:=@OPENJDK_TARGET_CPU_ISADIR@ OPENJDK_TARGET_CPU_LEGACY:=@OPENJDK_TARGET_CPU_LEGACY@ OPENJDK_TARGET_CPU_LEGACY_LIB:=@OPENJDK_TARGET_CPU_LEGACY_LIB@ OPENJDK_TARGET_CPU_OSARCH:=@OPENJDK_TARGET_CPU_OSARCH@ +OPENJDK_TARGET_OS_INCLUDE_SUBIDR:=@OPENJDK_TARGET_OS_INCLUDE_SUBDIR@ HOTSPOT_TARGET_OS := @HOTSPOT_TARGET_OS@ HOTSPOT_TARGET_OS_TYPE := @HOTSPOT_TARGET_OS_TYPE@ @@ -100,6 +101,8 @@ OPENJDK_BUILD_CPU_ARCH:=@OPENJDK_BUILD_CPU_ARCH@ OPENJDK_BUILD_CPU_BITS:=@OPENJDK_BUILD_CPU_BITS@ OPENJDK_BUILD_CPU_ENDIAN:=@OPENJDK_BUILD_CPU_ENDIAN@ +OPENJDK_BUILD_OS_INCLUDE_SUBIDR:=@OPENJDK_TARGET_OS_INCLUDE_SUBDIR@ + # Target platform value in ModuleTarget class file attribute. OPENJDK_MODULE_TARGET_PLATFORM:=@OPENJDK_MODULE_TARGET_PLATFORM@ @@ -189,6 +192,10 @@ VERSION_DATE := @VERSION_DATE@ # Vendor version string VENDOR_VERSION_STRING := @VENDOR_VERSION_STRING@ +# Class-file version +VERSION_CLASSFILE_MAJOR := @VERSION_CLASSFILE_MAJOR@ +VERSION_CLASSFILE_MINOR := @VERSION_CLASSFILE_MINOR@ + # Convenience CFLAGS settings for passing version information into native programs. VERSION_CFLAGS := \ -DVERSION_FEATURE=$(VERSION_FEATURE) \ @@ -204,6 +211,8 @@ VERSION_CFLAGS := \ -DVERSION_SPECIFICATION='"$(VERSION_SPECIFICATION)"' \ -DVERSION_DATE='"$(VERSION_DATE)"' \ -DVENDOR_VERSION_STRING='"$(VENDOR_VERSION_STRING)"' \ + -DVERSION_CLASSFILE_MAJOR=$(VERSION_CLASSFILE_MAJOR) \ + -DVERSION_CLASSFILE_MINOR=$(VERSION_CLASSFILE_MINOR) \ # ifneq ($(COMPANY_NAME),) @@ -604,6 +613,8 @@ INTERIM_LANGTOOLS_BASE_MODULES := java.compiler jdk.compiler jdk.javadoc INTERIM_LANGTOOLS_MODULES := $(addsuffix .interim, $(INTERIM_LANGTOOLS_BASE_MODULES)) INTERIM_LANGTOOLS_ADD_EXPORTS := \ --add-exports java.base/sun.reflect.annotation=jdk.compiler.interim \ + --add-exports java.base/jdk.internal.jmod=jdk.compiler.interim \ + --add-exports java.base/jdk.internal.misc=jdk.compiler.interim \ # INTERIM_LANGTOOLS_MODULES_COMMA := $(strip $(subst $(SPACE),$(COMMA),$(strip \ $(INTERIM_LANGTOOLS_MODULES)))) diff --git a/make/autoconf/toolchain.m4 b/make/autoconf/toolchain.m4 index b5416aed9af..599a2212647 100644 --- a/make/autoconf/toolchain.m4 +++ b/make/autoconf/toolchain.m4 @@ -286,7 +286,7 @@ AC_DEFUN_ONCE([TOOLCHAIN_PRE_DETECTION], if test "x$XCODE_VERSION_OUTPUT" != x; then # For Xcode, we set the Xcode version as TOOLCHAIN_VERSION TOOLCHAIN_VERSION=`$ECHO $XCODE_VERSION_OUTPUT | $CUT -f 2 -d ' '` - TOOLCHAIN_DESCRIPTION="$TOOLCHAIN_DESCRIPTION from Xcode" + TOOLCHAIN_DESCRIPTION="$TOOLCHAIN_DESCRIPTION from Xcode $TOOLCHAIN_VERSION" else # Currently we do not define this for other toolchains. This might change as the need arise. TOOLCHAIN_VERSION= diff --git a/make/autoconf/toolchain_windows.m4 b/make/autoconf/toolchain_windows.m4 index f2304df0fe9..6ce41805c5f 100644 --- a/make/autoconf/toolchain_windows.m4 +++ b/make/autoconf/toolchain_windows.m4 @@ -25,7 +25,7 @@ ################################################################################ # The order of these defines the priority by which we try to find them. -VALID_VS_VERSIONS="2013 2012 2010" +VALID_VS_VERSIONS="2013 2012 2010 2015 2017" VS_DESCRIPTION_2010="Microsoft Visual Studio 2010" VS_VERSION_INTERNAL_2010=100 @@ -58,6 +58,30 @@ VS_SDK_INSTALLDIR_2013= VS_VS_PLATFORM_NAME_2013="v120" VS_SDK_PLATFORM_NAME_2013= +VS_DESCRIPTION_2015="Microsoft Visual Studio 2015 - CURRENTLY NOT WORKING" +VS_VERSION_INTERNAL_2015=140 +VS_MSVCR_2015=vcruntime140.dll +VS_MSVCP_2015=msvcp140.dll +VS_ENVVAR_2015="VS140COMNTOOLS" +VS_VS_INSTALLDIR_2015="Microsoft Visual Studio 14.0" +VS_SDK_INSTALLDIR_2015= +VS_VS_PLATFORM_NAME_2015="v140" +VS_SDK_PLATFORM_NAME_2015= +# The vcvars of 2015 breaks if 2017 is also installed. Work around this by +# explicitly specifying Windows Kit 8.1 to be used. +VS_ENV_ARGS_2015="8.1" + +VS_DESCRIPTION_2017="Microsoft Visual Studio 2017 - CURRENTLY NOT WORKING" +VS_VERSION_INTERNAL_2017=141 +VS_MSVCR_2017=vcruntime140.dll +VS_MSVCP_2017=msvcp140.dll +VS_ENVVAR_2017="VS150COMNTOOLS" +VS_VS_INSTALLDIR_2017="Microsoft Visual Studio/2017" +VS_EDITIONS_2017="Community Professional Enterprise" +VS_SDK_INSTALLDIR_2017= +VS_VS_PLATFORM_NAME_2017="v141" +VS_SDK_PLATFORM_NAME_2017= + ################################################################################ AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT], @@ -67,23 +91,41 @@ AC_DEFUN([TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT], VS_BASE="$2" METHOD="$3" - if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then - VCVARSFILE="vc/bin/vcvars32.bat" - else - VCVARSFILE="vc/bin/amd64/vcvars64.bat" + BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS_BASE) + # In VS 2017, the default installation is in a subdir named after the edition. + # Find the first one present and use that. + if test "x$VS_EDITIONS" != x; then + for edition in $VS_EDITIONS; do + if test -d "$VS_BASE/$edition"; then + VS_BASE="$VS_BASE/$edition" + break + fi + done fi - BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(VS_BASE) if test -d "$VS_BASE"; then - if test -f "$VS_BASE/$VCVARSFILE"; then - AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD]) - VS_ENV_CMD="$VS_BASE/$VCVARSFILE" - # PLATFORM_TOOLSET is used during the compilation of the freetype sources (see - # 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', 'v110' or 'v120' for VS 2010, 2012 or VS2013 - eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" + AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD]) + if test "x$OPENJDK_TARGET_CPU_BITS" = x32; then + VCVARSFILES="vc/bin/vcvars32.bat vc/auxiliary/build/vcvars32.bat" else - AC_MSG_NOTICE([Found Visual Studio installation at $VS_BASE using $METHOD]) - AC_MSG_NOTICE([Warning: $VCVARSFILE is missing, this is probably Visual Studio Express. Ignoring]) + VCVARSFILES="vc/bin/amd64/vcvars64.bat vc/bin/x86_amd64/vcvarsx86_amd64.bat \ + vc/auxiliary/build/vcvarsx86_amd64.bat vc/auxiliary/build/vcvars64.bat" + fi + + for VCVARSFILE in $VCVARSFILES; do + if test -f "$VS_BASE/$VCVARSFILE"; then + VS_ENV_CMD="$VS_BASE/$VCVARSFILE" + break + fi + done + + if test "x$VS_ENV_CMD" = x; then + AC_MSG_NOTICE([Warning: None of $VCVARSFILES were found, Visual Studio installation not recognized. Ignoring]) + else + # PLATFORM_TOOLSET is used during the compilation of the freetype sources + # (see 'LIB_BUILD_FREETYPE' in libraries.m4) and must be one of 'v100', + # 'v110' or 'v120' for VS 2010, 2012 or VS2013 + eval PLATFORM_TOOLSET="\${VS_VS_PLATFORM_NAME_${VS_VERSION}}" fi fi fi @@ -133,7 +175,9 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE], eval VS_COMNTOOLS_VAR="\${VS_ENVVAR_${VS_VERSION}}" eval VS_COMNTOOLS="\$${VS_COMNTOOLS_VAR}" eval VS_INSTALL_DIR="\${VS_VS_INSTALLDIR_${VS_VERSION}}" + eval VS_EDITIONS="\${VS_EDITIONS_${VS_VERSION}}" eval SDK_INSTALL_DIR="\${VS_SDK_INSTALLDIR_${VS_VERSION}}" + eval VS_ENV_ARGS="\${VS_ENV_ARGS_${VS_VERSION}}" # When using --with-tools-dir, assume it points to the correct and default # version of Visual Studio or that --with-toolchain-version was also set. @@ -153,7 +197,6 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO_BAT_FILE], fi VS_ENV_CMD="" - VS_ENV_ARGS="" if test "x$VS_COMNTOOLS" != x; then TOOLCHAIN_CHECK_POSSIBLE_VISUAL_STUDIO_ROOT([${VS_VERSION}], @@ -213,7 +256,11 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO], elif test "x$DEVKIT_VS_VERSION" != x; then VS_VERSION=$DEVKIT_VS_VERSION TOOLCHAIN_VERSION=$VS_VERSION - eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}" + # If the devkit has a name, use that as description + VS_DESCRIPTION="$DEVKIT_NAME" + if test "x$VS_DESCRIPTION" = x; then + eval VS_DESCRIPTION="\${VS_DESCRIPTION_${VS_VERSION}}" + fi eval VS_VERSION_INTERNAL="\${VS_VERSION_INTERNAL_${VS_VERSION}}" eval MSVCR_NAME="\${VS_MSVCR_${VS_VERSION}}" eval MSVCP_NAME="\${VS_MSVCP_${VS_VERSION}}" @@ -267,6 +314,11 @@ AC_DEFUN([TOOLCHAIN_FIND_VISUAL_STUDIO], break fi done + + TOOLCHAIN_DESCRIPTION="$VS_DESCRIPTION" + if test "$TOOLCHAIN_VERSION" -gt 2013; then + UNSUPPORTED_TOOLCHAIN_VERSION=yes + fi ]) ################################################################################ @@ -320,6 +372,9 @@ AC_DEFUN([TOOLCHAIN_SETUP_VISUAL_STUDIO_ENV], # This will end up something like: # call C:/progra~2/micros~2.0/vc/bin/amd64/vcvars64.bat $ECHO "call $WINPATH_VS_ENV_CMD $VS_ENV_ARGS" >> $EXTRACT_VC_ENV_BAT_FILE + # In some cases, the VS_ENV_CMD will change directory, change back so + # the set-vs-env.sh ends up in the right place. + $ECHO 'cd %~dp0' >> $EXTRACT_VC_ENV_BAT_FILE # These will end up something like: # C:/CygWin/bin/bash -c 'echo VS_PATH=\"$PATH\" > localdevenv.sh # The trailing space for everyone except PATH is no typo, but is needed due @@ -483,18 +538,30 @@ AC_DEFUN([TOOLCHAIN_SETUP_MSVC_DLL], MSVC_DLL= if test "x$MSVC_DLL" = x; then - # Probe: Using well-known location from Visual Studio 10.0 if test "x$VCINSTALLDIR" != x; then CYGWIN_VC_INSTALL_DIR="$VCINSTALLDIR" BASIC_WINDOWS_REWRITE_AS_UNIX_PATH(CYGWIN_VC_INSTALL_DIR) - if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then - POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + if test "$VS_VERSION" -lt 2017; then + # Probe: Using well-known location from Visual Studio 12.0 and older + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then + POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + else + POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + fi else - POSSIBLE_MSVC_DLL="$CYGWIN_VC_INSTALL_DIR/redist/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME" + # Probe: Using well-known location from VS 2017 + if test "x$OPENJDK_TARGET_CPU_BITS" = x64; then + POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x64/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`" + else + POSSIBLE_MSVC_DLL="`ls $CYGWIN_VC_INSTALL_DIR/Redist/MSVC/*/x86/Microsoft.VC${VS_VERSION_INTERNAL}.CRT/$DLL_NAME`" + fi fi - $ECHO "POSSIBLE_MSVC_DLL $POSSIBLEMSVC_DLL" - TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$POSSIBLE_MSVC_DLL], - [well-known location in VCINSTALLDIR]) + # In case any of the above finds more than one file, loop over them. + for possible_msvc_dll in $POSSIBLE_MSVC_DLL; do + $ECHO "POSSIBLE_MSVC_DLL $possible_msvc_dll" + TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL([$DLL_NAME], [$possible_msvc_dll], + [well-known location in VCINSTALLDIR]) + done fi fi @@ -576,7 +643,7 @@ AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS], TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCR_NAME, [$DEVKIT_MSVCR_DLL], [devkit]) if test "x$MSVC_DLL" = x; then AC_MSG_ERROR([Could not find a proper $MSVCR_NAME as specified by devkit]) - fi + fi MSVCR_DLL="$MSVC_DLL" else TOOLCHAIN_SETUP_MSVC_DLL([${MSVCR_NAME}]) @@ -599,7 +666,7 @@ AC_DEFUN([TOOLCHAIN_SETUP_VS_RUNTIME_DLLS], TOOLCHAIN_CHECK_POSSIBLE_MSVC_DLL($MSVCP_NAME, [$DEVKIT_MSVCP_DLL], [devkit]) if test "x$MSVC_DLL" = x; then AC_MSG_ERROR([Could not find a proper $MSVCP_NAME as specified by devkit]) - fi + fi MSVCP_DLL="$MSVC_DLL" else TOOLCHAIN_SETUP_MSVC_DLL([${MSVCP_NAME}]) diff --git a/make/autoconf/version-numbers b/make/autoconf/version-numbers index 60d565c1805..fb748470c00 100644 --- a/make/autoconf/version-numbers +++ b/make/autoconf/version-numbers @@ -30,6 +30,8 @@ DEFAULT_VERSION_INTERIM=0 DEFAULT_VERSION_UPDATE=0 DEFAULT_VERSION_PATCH=0 DEFAULT_VERSION_DATE=2018-03-20 +DEFAULT_VERSION_CLASSFILE_MAJOR=55 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" +DEFAULT_VERSION_CLASSFILE_MINOR=0 LAUNCHER_NAME=openjdk PRODUCT_NAME=OpenJDK diff --git a/make/common/SetupJavaCompilers.gmk b/make/common/SetupJavaCompilers.gmk index 72bc7e442b7..861406901a7 100644 --- a/make/common/SetupJavaCompilers.gmk +++ b/make/common/SetupJavaCompilers.gmk @@ -26,13 +26,16 @@ ifndef _SETUP_GMK _SETUP_GMK := 1 +# Include custom extension hook +$(eval $(call IncludeCustomExtension, common/SetupJavaCompilers.gmk)) + include JavaCompilation.gmk -DISABLE_WARNINGS := -Xlint:all,-deprecation,-removal,-unchecked,-rawtypes,-cast,-serial,-dep-ann,-static,-fallthrough,-try,-varargs,-empty,-finally +DISABLE_WARNINGS ?= -Xlint:all,-deprecation,-removal,-unchecked,-rawtypes,-cast,-serial,-dep-ann,-static,-fallthrough,-try,-varargs,-empty,-finally # If warnings needs to be non-fatal for testing purposes use a command like: # make JAVAC_WARNINGS="-Xlint:all -Xmaxwarns 10000" -JAVAC_WARNINGS := -Xlint:all -Werror +JAVAC_WARNINGS ?= -Xlint:all -Werror # The BOOT_JAVAC setup uses the boot jdk compiler to compile the tools # and the interim javac, to be run by the boot jdk. @@ -69,7 +72,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE, \ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \ JVM := $(JAVA_JAVAC), \ JAVAC := $(NEW_JAVAC), \ - FLAGS := -source 10 -target 10 --doclint-format html5 \ + FLAGS := -source 11 -target 11 --doclint-format html5 \ -encoding ascii -XDignore.symbol.file=true $(JAVAC_WARNINGS), \ SERVER_DIR := $(SJAVAC_SERVER_DIR), \ SERVER_JVM := $(SJAVAC_SERVER_JAVA))) @@ -79,7 +82,7 @@ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE, \ $(eval $(call SetupJavaCompiler,GENERATE_JDKBYTECODE_NOWARNINGS, \ JVM := $(JAVA_JAVAC), \ JAVAC := $(NEW_JAVAC), \ - FLAGS := -source 10 -target 10 \ + FLAGS := -source 11 -target 11 \ -encoding ascii -XDignore.symbol.file=true $(DISABLE_WARNINGS), \ SERVER_DIR := $(SJAVAC_SERVER_DIR), \ SERVER_JVM := $(SJAVAC_SERVER_JAVA))) diff --git a/make/conf/jib-profiles.js b/make/conf/jib-profiles.js index 5066599a924..d01fdaeaa16 100644 --- a/make/conf/jib-profiles.js +++ b/make/conf/jib-profiles.js @@ -829,7 +829,7 @@ var getJibProfilesDependencies = function (input, common) { jtreg: { server: "javare", revision: "4.2", - build_number: "b10", + build_number: "b11", checksum_file: "MD5_VALUES", file: "jtreg_bin-4.2.zip", environment_name: "JT_HOME", diff --git a/make/copy/Copy-java.base.gmk b/make/copy/Copy-java.base.gmk index 74759879179..096f6c0e903 100644 --- a/make/copy/Copy-java.base.gmk +++ b/make/copy/Copy-java.base.gmk @@ -24,6 +24,7 @@ # include CopyCommon.gmk +include TextFileProcessing.gmk $(eval $(call IncludeCustomExtension, copy/Copy-java.base.gmk)) @@ -244,3 +245,16 @@ ifeq ($(ENABLE_LIBFFI_BUNDLING), true) endif ################################################################################ +# Generate classfile_constants.h + +$(eval $(call SetupTextFileProcessing, CREATE_CLASSFILE_CONSTANTS_H, \ + SOURCE_FILES := $(TOPDIR)/src/java.base/share/native/include/classfile_constants.h.template, \ + OUTPUT_FILE := $(SUPPORT_OUTPUTDIR)/modules_include/java.base/classfile_constants.h, \ + REPLACEMENTS := \ + @@VERSION_CLASSFILE_MAJOR@@ => $(VERSION_CLASSFILE_MAJOR) ; \ + @@VERSION_CLASSFILE_MINOR@@ => $(VERSION_CLASSFILE_MINOR) ; , \ +)) + +TARGETS += $(CREATE_CLASSFILE_CONSTANTS_H) + +################################################################################ diff --git a/make/copy/CopyCommon.gmk b/make/copy/CopyCommon.gmk index 2956e9ddf92..6d4cdbaf747 100644 --- a/make/copy/CopyCommon.gmk +++ b/make/copy/CopyCommon.gmk @@ -39,20 +39,12 @@ ifneq ($(wildcard $(INCLUDE_SOURCE_DIR)/*), ) $(eval $(call SetupCopyFiles, COPY_EXPORTED_INCLUDE, \ SRC := $(INCLUDE_SOURCE_DIR), \ DEST := $(INCLUDE_TARGET_DIR), \ - FILES := $(shell $(FIND) $(INCLUDE_SOURCE_DIR) -type f), \ + FILES := $(filter %.h, $(call CacheFind, $(INCLUDE_SOURCE_DIR))), \ )) TARGETS += $(COPY_EXPORTED_INCLUDE) endif -# For historical reasons, the OS include directories have odd names. -INCLUDE_TARGET_OS_SUBDIR := $(OPENJDK_TARGET_OS) -ifeq ($(OPENJDK_TARGET_OS), windows) - INCLUDE_TARGET_OS_SUBDIR := win32 -else ifeq ($(OPENJDK_TARGET_OS), macosx) - INCLUDE_TARGET_OS_SUBDIR := darwin -endif - # Use the most specific of OS and OS_TYPE. INCLUDE_SOURCE_OS_DIR := $(TOPDIR)/src/$(MODULE)/$(OPENJDK_TARGET_OS)/native/include ifeq ($(wildcard $(INCLUDE_SOURCE_OS_DIR)/*), ) @@ -62,8 +54,8 @@ endif ifneq ($(wildcard $(INCLUDE_SOURCE_OS_DIR)/*), ) $(eval $(call SetupCopyFiles, COPY_EXPORTED_INCLUDE_OS, \ SRC := $(INCLUDE_SOURCE_OS_DIR), \ - DEST := $(INCLUDE_TARGET_DIR)/$(INCLUDE_TARGET_OS_SUBDIR), \ - FILES := $(shell $(FIND) $(INCLUDE_SOURCE_OS_DIR) -type f), \ + DEST := $(INCLUDE_TARGET_DIR)/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR), \ + FILES := $(filter %.h, $(call CacheFind, $(INCLUDE_SOURCE_OS_DIR))), \ )) TARGETS += $(COPY_EXPORTED_INCLUDE_OS) diff --git a/make/data/characterdata/CharacterDataLatin1.java.template b/make/data/characterdata/CharacterDataLatin1.java.template index 23e672bc7f5..23bf2b04671 100644 --- a/make/data/characterdata/CharacterDataLatin1.java.template +++ b/make/data/characterdata/CharacterDataLatin1.java.template @@ -25,6 +25,8 @@ package java.lang; +import java.util.Arrays; + /** The CharacterData class encapsulates the large tables found in Java.lang.Character. */ @@ -159,20 +161,39 @@ class CharacterDataLatin1 extends CharacterData { return toUpperCase(ch); } + // Digit values for codePoints in the 0-255 range. Contents generated using: + // for (char i = 0; i < 256; i++) { + // int v = -1; + // if (i >= '0' && i <= '9') { v = i - '0'; } + // else if (i >= 'A' && i <= 'Z') { v = i - 'A' + 10; } + // else if (i >= 'a' && i <= 'z') { v = i - 'a' + 10; } + // if (i % 20 == 0) System.out.println(); + // System.out.printf("%2d, ", v); + // } + // + // Analysis has shown that generating the whole array allows the JIT to generate + // better code compared to a slimmed down array, such as one cutting off after 'z' + private static final byte[] DIGITS = new byte[] { + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, + -1, -1, -1, -1, -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 }; + int digit(int ch, int radix) { - int value = -1; - if (radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX) { - int val = getProperties(ch); - int kind = val & $$maskType; - if (kind == Character.DECIMAL_DIGIT_NUMBER) { - value = ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit; - } - else if ((val & $$maskNumericType) == $$valueJavaSupradecimal) { - // Java supradecimal digit - value = (ch + ((val & $$maskDigitOffset) >> $$shiftDigitOffset) & $$maskDigit) + 10; - } + int value = DIGITS[ch]; + if (value >= 0 && radix >= Character.MIN_RADIX && radix <= Character.MAX_RADIX) { + value = (value < radix) ? value : -1; } - return (value < radix) ? value : -1; + return value; } int getNumericValue(int ch) { diff --git a/make/data/jdwp/jdwp.spec b/make/data/jdwp/jdwp.spec index 0b7afa76a9c..a33f31ed41c 100644 --- a/make/data/jdwp/jdwp.spec +++ b/make/data/jdwp/jdwp.spec @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -869,7 +869,6 @@ JDWP "Java(tm) Debug Wire Protocol" "section in " "The Java™ Virtual Machine Specification. " "Since JDWP version 1.5." - "

(Out (referenceType refType "The reference type ID.") ) @@ -2723,7 +2722,6 @@ JDWP "Java(tm) Debug Wire Protocol" "

" "The events that are grouped in a composite event are restricted in the " "following ways: " - "

" "

    " "
  • Only with other thread start events for the same thread:" "
      " diff --git a/make/devkit/createWindowsDevkit.sh b/make/devkit/createWindowsDevkit2013.sh similarity index 100% rename from make/devkit/createWindowsDevkit.sh rename to make/devkit/createWindowsDevkit2013.sh diff --git a/make/devkit/createWindowsDevkit2015.sh b/make/devkit/createWindowsDevkit2015.sh new file mode 100644 index 00000000000..12a2f31d024 --- /dev/null +++ b/make/devkit/createWindowsDevkit2015.sh @@ -0,0 +1,142 @@ +#!/bin/bash +# +# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# 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. +# + +# This script copies parts of a Visual Studio installation into a devkit +# suitable for building OpenJDK and OracleJDK. Needs to run in Cygwin. +# erik.joelsson@oracle.com + +VS_VERSION="2015" +VS_VERSION_NUM="14.0" +VS_VERSION_NUM_NODOT="140" +SDK_VERSION="8.1" +VS_VERSION_SP="update3" + +SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)" +BUILD_DIR="${SCRIPT_DIR}/../../build/devkit" +DEVKIT_ROOT="${BUILD_DIR}/VS${VS_VERSION}${VS_VERSION_SP}-devkit" +DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz" + +echo "Creating devkit in $DEVKIT_ROOT" + +MSVCR_DLL=Microsoft.VC${VS_VERSION_NUM_NODOT}.CRT/vcruntime${VS_VERSION_NUM_NODOT}.dll +MSVCP_DLL=Microsoft.VC${VS_VERSION_NUM_NODOT}.CRT/msvcp${VS_VERSION_NUM_NODOT}.dll + +################################################################################ +# Copy Visual Studio files + +eval VSNNNCOMNTOOLS="\"\${VS${VS_VERSION_NUM_NODOT}COMNTOOLS}\"" +VS_INSTALL_DIR="$(cygpath "$VSNNNCOMNTOOLS/../..")" +echo "VS_INSTALL_DIR: $VS_INSTALL_DIR" + +if [ ! -d $DEVKIT_ROOT/VC ]; then + echo "Copying VC..." + mkdir -p $DEVKIT_ROOT/VC/bin + cp -r "$VS_INSTALL_DIR/VC/bin/amd64" $DEVKIT_ROOT/VC/bin/ + cp "$VS_INSTALL_DIR/VC/bin/"*.* $DEVKIT_ROOT/VC/bin/ + cp -r "$VS_INSTALL_DIR/VC/bin/1033/" $DEVKIT_ROOT/VC/bin/ + mkdir -p $DEVKIT_ROOT/VC/lib + cp -r "$VS_INSTALL_DIR/VC/lib/amd64" $DEVKIT_ROOT/VC/lib/ + cp "$VS_INSTALL_DIR/VC/lib/"*.* $DEVKIT_ROOT/VC/lib/ + cp -r "$VS_INSTALL_DIR/VC/include" $DEVKIT_ROOT/VC/ + mkdir -p $DEVKIT_ROOT/VC/atlmfc/lib + cp -r "$VS_INSTALL_DIR/VC/atlmfc/include" $DEVKIT_ROOT/VC/atlmfc/ + cp -r "$VS_INSTALL_DIR/VC/atlmfc/lib/amd64" $DEVKIT_ROOT/VC/atlmfc/lib/ + cp "$VS_INSTALL_DIR/VC/atlmfc/lib/"*.* $DEVKIT_ROOT/VC/atlmfc/lib/ + mkdir -p $DEVKIT_ROOT/VC/redist + cp -r "$VS_INSTALL_DIR/VC/redist/x64" $DEVKIT_ROOT/VC/redist/ + cp -r "$VS_INSTALL_DIR/VC/redist/x86" $DEVKIT_ROOT/VC/redist/ + # The redist runtime libs are needed to run the compiler but may not be + # installed on the machine where the devkit will be used. + cp $DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/ + cp $DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/ + cp $DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/amd64/ + cp $DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/amd64/ + # The msvcdis dll is needed to run some of the tools in VC/bin but is not + # shipped in that directory. Copy it from the common dir. + cp "$VS_INSTALL_DIR/Common7/IDE/msvcdis${VS_VERSION_NUM_NODOT}.dll" \ + $DEVKIT_ROOT/VC/bin/ +fi + +################################################################################ +# Copy SDK files + +PROGRAMFILES_X86="`env | sed -n 's/^ProgramFiles(x86)=//p'`" +SDK_INSTALL_DIR="$(cygpath "$PROGRAMFILES_X86/Windows Kits/$SDK_VERSION")" +echo "SDK_INSTALL_DIR: $SDK_INSTALL_DIR" + +if [ ! -d $DEVKIT_ROOT/$SDK_VERSION ]; then + echo "Copying SDK..." + mkdir -p $DEVKIT_ROOT/$SDK_VERSION/bin + cp -r "$SDK_INSTALL_DIR/bin/x64" $DEVKIT_ROOT/$SDK_VERSION/bin/ + cp -r "$SDK_INSTALL_DIR/bin/x86" $DEVKIT_ROOT/$SDK_VERSION/bin/ + mkdir -p $DEVKIT_ROOT/$SDK_VERSION/lib + cp -r "$SDK_INSTALL_DIR/lib/"winv*/um/x64 $DEVKIT_ROOT/$SDK_VERSION/lib/ + cp -r "$SDK_INSTALL_DIR/lib/"winv*/um/x86 $DEVKIT_ROOT/$SDK_VERSION/lib/ + cp -r "$SDK_INSTALL_DIR/include" $DEVKIT_ROOT/$SDK_VERSION/ + # In 2015, the new Universal CRT is delivered in the sdk 10 directory + # so need to include that as well. + mkdir -p $DEVKIT_ROOT/10/lib + cp -r "$SDK_INSTALL_DIR/../10/lib/10.0.10240.0/ucrt" $DEVKIT_ROOT/10/lib/ + mkdir -p $DEVKIT_ROOT/10/include + cp -r "$SDK_INSTALL_DIR/../10/include/10.0.10240.0/ucrt" $DEVKIT_ROOT/10/include/ +fi + +################################################################################ +# Generate devkit.info + +echo-info() { + echo "$1" >> $DEVKIT_ROOT/devkit.info +} + +echo "Generating devkit.info..." +rm -f $DEVKIT_ROOT/devkit.info +echo-info "# This file describes to configure how to interpret the contents of this devkit" +echo-info "DEVKIT_NAME=\"Microsoft Visual Studio $VS_VERSION $VS_VERSION_SP (devkit)\"" +echo-info "DEVKIT_VS_VERSION=\"$VS_VERSION\"" +echo-info "" +echo-info "DEVKIT_TOOLCHAIN_PATH_x86=\"\$DEVKIT_ROOT/VC/bin:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\"" +echo-info "DEVKIT_VS_INCLUDE_x86=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt;\$DEVKIT_ROOT/10/include/ucrt\"" +echo-info "DEVKIT_VS_LIB_x86=\"\$DEVKIT_ROOT/VC/lib;\$DEVKIT_ROOT/VC/atlmfc/lib;\$DEVKIT_ROOT/$SDK_VERSION/lib/x86;\$DEVKIT_ROOT/10/lib/ucrt/x86\"" +echo-info "DEVKIT_MSVCR_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL\"" +echo-info "DEVKIT_MSVCP_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL\"" +echo-info "" +echo-info "DEVKIT_TOOLCHAIN_PATH_x86_64=\"\$DEVKIT_ROOT/VC/bin/amd64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\"" +echo-info "DEVKIT_VS_INCLUDE_x86_64=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt;\$DEVKIT_ROOT/10/include/ucrt\"" +echo-info "DEVKIT_VS_LIB_x86_64=\"\$DEVKIT_ROOT/VC/lib/amd64;\$DEVKIT_ROOT/VC/atlmfc/lib/amd64;\$DEVKIT_ROOT/$SDK_VERSION/lib/x64;\$DEVKIT_ROOT/10/lib/ucrt/x64\"" +echo-info "DEVKIT_MSVCR_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL\"" +echo-info "DEVKIT_MSVCP_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL\"" + +################################################################################ +# Copy this script + +echo "Copying this script..." +cp $0 $DEVKIT_ROOT/ + +################################################################################ +# Create bundle + +echo "Creating bundle: $DEVKIT_BUNDLE" +(cd "$DEVKIT_ROOT" && tar zcf "$DEVKIT_BUNDLE" .) diff --git a/make/devkit/createWindowsDevkit2017.sh b/make/devkit/createWindowsDevkit2017.sh new file mode 100644 index 00000000000..b4cd65d438b --- /dev/null +++ b/make/devkit/createWindowsDevkit2017.sh @@ -0,0 +1,172 @@ +#!/bin/bash +# +# Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# 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. +# + +# This script copies parts of a Visual Studio installation into a devkit +# suitable for building OpenJDK and OracleJDK. Needs to run in Cygwin. +# erik.joelsson@oracle.com + +VS_VERSION="2017" +VS_VERSION_NUM_NODOT="150" +VS_DLL_VERSION="140" +SDK_VERSION="10" +SDK_FULL_VERSION="10.0.16299.0" +MSVC_DIR="Microsoft.VC141.CRT" + +SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)" +BUILD_DIR="${SCRIPT_DIR}/../../build/devkit" + +################################################################################ +# Prepare settings + +# Work around the insanely named ProgramFiles(x86) env variable +PROGRAMFILES_X86="$(cygpath "$(env | sed -n 's/^ProgramFiles(x86)=//p')")" + +# Find Visual Studio installation dir +eval VSNNNCOMNTOOLS="\"\${VS${VS_VERSION_NUM_NODOT}COMNTOOLS}\"" +if [ -d "$VSNNNCOMNTOOLS" ]; then + VS_INSTALL_DIR="$(cygpath "$VSNNNCOMNTOOLS/../..")" +else + VS_INSTALL_DIR="${PROGRAMFILES_X86}/Microsoft Visual Studio/2017" + VS_INSTALL_DIR="$(ls -d "${VS_INSTALL_DIR}/"{Community,Professional} 2>/dev/null | head -n1)" + VS_INSTALL_DIR="$(cygpath "$VS_INSTALL_DIR")" +fi +echo "VS_INSTALL_DIR: $VS_INSTALL_DIR" + +# Extract semantic version +POTENTIAL_INI_FILES="Common7\IDE\wdexpress.isolation.ini Common7\IDE\devenv.isolation.ini" +for f in $POTENTIAL_INI_FILES; do + if [ -f "$VS_INSTALL_DIR/$f" ]; then + VS_VERSION_SP="$(grep ^SemanticVersion= "$VS_INSTALL_DIR/$f")" + # Remove SemnaticVersion= + VS_VERSION_SP="${VS_VERSION_SP#*=}" + # Remove suffix of too detailed numbering starting with + + VS_VERSION_SP="${VS_VERSION_SP%+*}" + break + fi +done +if [ -z "$VS_VERSION_SP" ]; then + echo "Failed to find SP version" + exit 1 +fi +echo "Found Version SP: $VS_VERSION_SP" + +# Setup output dirs +DEVKIT_ROOT="${BUILD_DIR}/VS${VS_VERSION}-${VS_VERSION_SP}-devkit" +DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz" + +echo "Creating devkit in $DEVKIT_ROOT" + +MSVCR_DLL=${MSVC_DIR}/vcruntime${VS_DLL_VERSION}.dll +MSVCP_DLL=${MSVC_DIR}/msvcp${VS_DLL_VERSION}.dll + +################################################################################ +# Copy Visual Studio files + +if [ ! -d $DEVKIT_ROOT/VC ]; then + VC_SUBDIR="VC/Tools/MSVC/14.12.25827" + REDIST_SUBDIR="VC/Redist/MSVC/14.12.25810" + echo "Copying VC..." + mkdir -p $DEVKIT_ROOT/VC/bin + cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/bin/Hostx64/x64" $DEVKIT_ROOT/VC/bin/ + cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/bin/Hostx86/x86" $DEVKIT_ROOT/VC/bin/ + mkdir -p $DEVKIT_ROOT/VC/lib + cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/lib/x64" $DEVKIT_ROOT/VC/lib/ + cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/lib/x86" $DEVKIT_ROOT/VC/lib/ + cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/include" $DEVKIT_ROOT/VC/ + mkdir -p $DEVKIT_ROOT/VC/atlmfc/lib + cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/lib/x64" $DEVKIT_ROOT/VC/atlmfc/lib/ + cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/lib/x86" $DEVKIT_ROOT/VC/atlmfc/lib/ + cp -r "$VS_INSTALL_DIR/${VC_SUBDIR}/atlmfc/include" $DEVKIT_ROOT/VC/atlmfc/ + mkdir -p $DEVKIT_ROOT/VC/Auxiliary + cp -r "$VS_INSTALL_DIR/VC/Auxiliary/Build" $DEVKIT_ROOT/VC/Auxiliary/ + mkdir -p $DEVKIT_ROOT/VC/redist + cp -r "$VS_INSTALL_DIR/$REDIST_SUBDIR/x64" $DEVKIT_ROOT/VC/redist/ + cp -r "$VS_INSTALL_DIR/$REDIST_SUBDIR/x86" $DEVKIT_ROOT/VC/redist/ + + # The redist runtime libs are needed to run the compiler but may not be + # installed on the machine where the devkit will be used. + cp $DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/x86 + cp $DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/x86 + cp $DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL $DEVKIT_ROOT/VC/bin/x64 + cp $DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL $DEVKIT_ROOT/VC/bin/x64 +fi + +################################################################################ +# Copy SDK files + +SDK_INSTALL_DIR="$(cygpath "$PROGRAMFILES_X86/Windows Kits/$SDK_VERSION")" +echo "SDK_INSTALL_DIR: $SDK_INSTALL_DIR" + +if [ ! -d $DEVKIT_ROOT/$SDK_VERSION ]; then + echo "Copying SDK..." + mkdir -p $DEVKIT_ROOT/$SDK_VERSION/bin + cp -r "$SDK_INSTALL_DIR/bin/$SDK_FULL_VERSION/x64" $DEVKIT_ROOT/$SDK_VERSION/bin/ + cp -r "$SDK_INSTALL_DIR/bin/$SDK_FULL_VERSION/x86" $DEVKIT_ROOT/$SDK_VERSION/bin/ + mkdir -p $DEVKIT_ROOT/$SDK_VERSION/lib + cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/um/x64" $DEVKIT_ROOT/$SDK_VERSION/lib/ + cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/um/x86" $DEVKIT_ROOT/$SDK_VERSION/lib/ + cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/ucrt/x64" $DEVKIT_ROOT/$SDK_VERSION/lib/ + cp -r "$SDK_INSTALL_DIR/lib/$SDK_FULL_VERSION/ucrt/x86" $DEVKIT_ROOT/$SDK_VERSION/lib/ + mkdir -p $DEVKIT_ROOT/$SDK_VERSION/include + cp -r "$SDK_INSTALL_DIR/include/$SDK_FULL_VERSION/"* $DEVKIT_ROOT/$SDK_VERSION/include/ +fi + +################################################################################ +# Generate devkit.info + +echo-info() { + echo "$1" >> $DEVKIT_ROOT/devkit.info +} + +echo "Generating devkit.info..." +rm -f $DEVKIT_ROOT/devkit.info +echo-info "# This file describes to configure how to interpret the contents of this devkit" +echo-info "DEVKIT_NAME=\"Microsoft Visual Studio $VS_VERSION $VS_VERSION_SP (devkit)\"" +echo-info "DEVKIT_VS_VERSION=\"$VS_VERSION\"" +echo-info "" +echo-info "DEVKIT_TOOLCHAIN_PATH_x86=\"\$DEVKIT_ROOT/VC/bin/x86:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\"" +echo-info "DEVKIT_VS_INCLUDE_x86=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/ucrt;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt\"" +echo-info "DEVKIT_VS_LIB_x86=\"\$DEVKIT_ROOT/VC/lib/x86;\$DEVKIT_ROOT/VC/atlmfc/lib/x86;\$DEVKIT_ROOT/$SDK_VERSION/lib/x86\"" +echo-info "DEVKIT_MSVCR_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCR_DLL\"" +echo-info "DEVKIT_MSVCP_DLL_x86=\"\$DEVKIT_ROOT/VC/redist/x86/$MSVCP_DLL\"" +echo-info "" +echo-info "DEVKIT_TOOLCHAIN_PATH_x86_64=\"\$DEVKIT_ROOT/VC/bin/x64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x64:\$DEVKIT_ROOT/$SDK_VERSION/bin/x86\"" +echo-info "DEVKIT_VS_INCLUDE_x86_64=\"\$DEVKIT_ROOT/VC/include;\$DEVKIT_ROOT/VC/atlmfc/include;\$DEVKIT_ROOT/$SDK_VERSION/include/shared;\$DEVKIT_ROOT/$SDK_VERSION/include/ucrt;\$DEVKIT_ROOT/$SDK_VERSION/include/um;\$DEVKIT_ROOT/$SDK_VERSION/include/winrt\"" +echo-info "DEVKIT_VS_LIB_x86_64=\"\$DEVKIT_ROOT/VC/lib/x64;\$DEVKIT_ROOT/VC/atlmfc/lib/x64;\$DEVKIT_ROOT/$SDK_VERSION/lib/x64\"" +echo-info "DEVKIT_MSVCR_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCR_DLL\"" +echo-info "DEVKIT_MSVCP_DLL_x86_64=\"\$DEVKIT_ROOT/VC/redist/x64/$MSVCP_DLL\"" + +################################################################################ +# Copy this script + +echo "Copying this script..." +cp $0 $DEVKIT_ROOT/ + +################################################################################ +# Create bundle + +echo "Creating bundle: $DEVKIT_BUNDLE" +(cd "$DEVKIT_ROOT" && tar zcf "$DEVKIT_BUNDLE" .) diff --git a/make/gensrc/GensrcVarHandles.gmk b/make/gensrc/GensrcVarHandles.gmk index acdce6c03a7..2f9e4bd928d 100644 --- a/make/gensrc/GensrcVarHandles.gmk +++ b/make/gensrc/GensrcVarHandles.gmk @@ -168,3 +168,7 @@ $(foreach t, $(VARHANDLES_BYTE_ARRAY_TYPES), \ $(eval $(call GenerateVarHandleByteArray,VAR_HANDLE_BYTE_ARRAY_$t,$t))) GENSRC_JAVA_BASE += $(GENSRC_VARHANDLES) + +# Include custom extension post hook +$(eval $(call IncludeCustomExtension, gensrc/GensrcVarHandles-post.gmk)) + diff --git a/make/gensrc/GensrcX11Wrappers.gmk b/make/gensrc/GensrcX11Wrappers.gmk index e506c5c01ff..ca95d0edae9 100644 --- a/make/gensrc/GensrcX11Wrappers.gmk +++ b/make/gensrc/GensrcX11Wrappers.gmk @@ -92,10 +92,10 @@ ifneq ($(COMPILE_TYPE), cross) endif SIZER_CFLAGS := \ - -I${TOPDIR}/src/hotspot/share/include \ - -I${TOPDIR}/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \ - -I$(TOPDIR)/src/java.base/share/native/include \ - -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/include \ + -I$(TOPDIR)/src/hotspot/share/include \ + -I$(TOPDIR)/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \ + -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ + -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \ -I$(TOPDIR)/src/java.base/share/native/libjava \ -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/libjava \ -I$(TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/common/awt \ diff --git a/make/hotspot/lib/CompileJvm.gmk b/make/hotspot/lib/CompileJvm.gmk index 91b5f9c74aa..de8213232b6 100644 --- a/make/hotspot/lib/CompileJvm.gmk +++ b/make/hotspot/lib/CompileJvm.gmk @@ -59,8 +59,8 @@ JVM_CFLAGS_INCLUDES += \ -I$(TOPDIR)/src/hotspot/share/precompiled \ -I$(TOPDIR)/src/hotspot/share/include \ -I$(TOPDIR)/src/hotspot/os/$(HOTSPOT_TARGET_OS_TYPE)/include \ - -I$(TOPDIR)/src/java.base/share/native/include \ - -I$(TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/native/include \ + -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base \ + -I$(SUPPORT_OUTPUTDIR)/modules_include/java.base/$(OPENJDK_TARGET_OS_INCLUDE_SUBDIR) \ -I$(TOPDIR)/src/java.base/share/native/libjimage \ # diff --git a/make/idea/idea.gmk b/make/idea/idea.gmk index 299ffe805bc..8b9d862794b 100644 --- a/make/idea/idea.gmk +++ b/make/idea/idea.gmk @@ -20,16 +20,9 @@ else #with SPEC SEL_MODULES := $(MODULES) endif - # Find all source dirs for a particular module - # $1 - Module to find source dirs for - FindIdeaModuleSrcDirs = \ - $(strip $(addsuffix /$(strip $1), $(GENERATED_SRC_DIRS) $(IMPORT_MODULES_SRC)) \ - $(wildcard $(foreach sub, $(SRC_SUBDIRS), $(addsuffix /$(strip $1)/$(sub), $(TOP_SRC_DIRS))))) - - idea: $(ECHO) "SUPPORT=$(SUPPORT_OUTPUTDIR)" >> $(OUT) - $(ECHO) "MODULE_ROOTS=\"$(foreach mod, $(SEL_MODULES), $(call FindIdeaModuleSrcDirs,$(mod)))\"" >> $(OUT) + $(ECHO) "MODULE_ROOTS=\"$(foreach mod, $(SEL_MODULES), $(call FindModuleSrcDirs,$(mod)))\"" >> $(OUT) $(ECHO) "MODULE_NAMES=\"$(strip $(foreach mod, $(SEL_MODULES), $(mod)))\"" >> $(OUT) $(ECHO) "SEL_MODULES=\"$(SEL_MODULES)\"" >> $(OUT) $(ECHO) "BOOT_JDK=\"$(BOOT_JDK)\"" >> $(OUT) diff --git a/make/idea/template/ant.xml b/make/idea/template/ant.xml index 9e7c19b8c89..74d7c1e34c2 100644 --- a/make/idea/template/ant.xml +++ b/make/idea/template/ant.xml @@ -3,7 +3,6 @@ - diff --git a/make/idea/template/build.xml b/make/idea/template/build.xml index 7f0eff40e3b..a553a940d2b 100644 --- a/make/idea/template/build.xml +++ b/make/idea/template/build.xml @@ -6,32 +6,16 @@ new JdkLogger(project) - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + @@ -43,71 +27,17 @@ **** Global JDK Build Targets --> - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/make/idea/template/jdk.iml b/make/idea/template/jdk.iml index 384f7806d3b..c3fb9c6963a 100644 --- a/make/idea/template/jdk.iml +++ b/make/idea/template/jdk.iml @@ -4,11 +4,9 @@ - - - + diff --git a/make/jdk/src/classes/build/tools/jdwpgen/AbstractCommandNode.java b/make/jdk/src/classes/build/tools/jdwpgen/AbstractCommandNode.java index b4b17196088..d007c584b69 100644 --- a/make/jdk/src/classes/build/tools/jdwpgen/AbstractCommandNode.java +++ b/make/jdk/src/classes/build/tools/jdwpgen/AbstractCommandNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,8 +30,8 @@ import java.io.*; class AbstractCommandNode extends AbstractNamedNode { void document(PrintWriter writer) { - writer.println("
      " + name + - " Command (" + nameNode.value() + ")
      "); + writer.println("
      " + name + + " Command (" + nameNode.value() + ")
      "); writer.println(comment()); writer.println("
      "); for (Node node : components) { diff --git a/make/jdk/src/classes/build/tools/jdwpgen/AbstractNamedNode.java b/make/jdk/src/classes/build/tools/jdwpgen/AbstractNamedNode.java index a71b8949e3d..764558be1a7 100644 --- a/make/jdk/src/classes/build/tools/jdwpgen/AbstractNamedNode.java +++ b/make/jdk/src/classes/build/tools/jdwpgen/AbstractNamedNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,8 +62,8 @@ abstract class AbstractNamedNode extends Node { } void document(PrintWriter writer) { - writer.println("

      " + name + - " Command Set

      "); + writer.println("

      " + name + + " Command Set

      "); for (Node node : components) { node.document(writer); } diff --git a/make/jdk/src/classes/build/tools/jdwpgen/AbstractTypeListNode.java b/make/jdk/src/classes/build/tools/jdwpgen/AbstractTypeListNode.java index eea9b9314a9..5ceae49b811 100644 --- a/make/jdk/src/classes/build/tools/jdwpgen/AbstractTypeListNode.java +++ b/make/jdk/src/classes/build/tools/jdwpgen/AbstractTypeListNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,11 +43,11 @@ abstract class AbstractTypeListNode extends AbstractNamedNode { if (components.isEmpty()) { writer.println("
      (None)"); } else { - writer.println("
      "); + writer.println("
      "); for (int i = maxStructIndent; i > 0; --i) { - writer.print("
      "); + writer.print(""); } - writer.println(""); + writer.println(""); writer.println(""); for (Node node : components) { node.document(writer); diff --git a/make/jdk/src/classes/build/tools/jdwpgen/CommandSetNode.java b/make/jdk/src/classes/build/tools/jdwpgen/CommandSetNode.java index 738cf61be5b..440e138ccb9 100644 --- a/make/jdk/src/classes/build/tools/jdwpgen/CommandSetNode.java +++ b/make/jdk/src/classes/build/tools/jdwpgen/CommandSetNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,8 @@ class CommandSetNode extends AbstractNamedNode { } void document(PrintWriter writer) { - writer.println("

      " + name + - " Command Set (" + + writer.println("

      " + name + + " Command Set (" + nameNode.value() + ")

      "); writer.println(comment()); for (Node node : components) { @@ -51,11 +51,13 @@ class CommandSetNode extends AbstractNamedNode { writer.print("
    • "); writer.println(name() + " Command Set (" + nameNode.value() + ")"); - writer.println("
        "); - for (Node node : components) { - node.documentIndex(writer); + if (components.size() > 0) { + writer.println("
          "); + for (Node node : components) { + node.documentIndex(writer); + } + writer.println("
        "); } - writer.println("
      "); } void genJavaClassSpecifics(PrintWriter writer, int depth) { diff --git a/make/jdk/src/classes/build/tools/jdwpgen/ConstantSetNode.java b/make/jdk/src/classes/build/tools/jdwpgen/ConstantSetNode.java index 280136766d4..4990cb2740e 100644 --- a/make/jdk/src/classes/build/tools/jdwpgen/ConstantSetNode.java +++ b/make/jdk/src/classes/build/tools/jdwpgen/ConstantSetNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,15 +54,15 @@ class ConstantSetNode extends AbstractNamedNode { } void document(PrintWriter writer) { - writer.println("

      " + name + - " Constants

      "); + writer.println("

      " + name + + " Constants

      "); writer.println(comment()); - writer.println("
      "); - writer.println("
      "); + writer.println(""); + writer.println("
      "); ConstantNode n; for (Node node : components) { n = (ConstantNode)node; - writer.println(""); + writer.println(""); n.document(writer); } writer.println("
      "); diff --git a/make/jdk/src/classes/build/tools/jdwpgen/ErrorSetNode.java b/make/jdk/src/classes/build/tools/jdwpgen/ErrorSetNode.java index 2cfe505a858..50dd0af39d4 100644 --- a/make/jdk/src/classes/build/tools/jdwpgen/ErrorSetNode.java +++ b/make/jdk/src/classes/build/tools/jdwpgen/ErrorSetNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ class ErrorSetNode extends AbstractSimpleNode { if (components.isEmpty()) { writer.println("
      (None)"); } else { - writer.println("
      "); + writer.println("
      "); for (Node node : components) { node.document(writer); } diff --git a/make/jdk/src/classes/build/tools/jdwpgen/RootNode.java b/make/jdk/src/classes/build/tools/jdwpgen/RootNode.java index 2361f335949..da485d66a61 100644 --- a/make/jdk/src/classes/build/tools/jdwpgen/RootNode.java +++ b/make/jdk/src/classes/build/tools/jdwpgen/RootNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,11 +41,22 @@ class RootNode extends AbstractNamedNode { void document(PrintWriter writer) { writer.println(""); - writer.println("" + comment() + ""); - writer.println(""); + writer.println(""); + writer.println(""); + writer.println(""); + writer.println("" + comment() + ""); + writer.println(""); + writer.println(""); + writer.println(""); + writer.println("
        "); for (Node node : components) { node.documentIndex(writer); } + writer.println("
      "); for (Node node : components) { node.document(writer); } diff --git a/make/lib/Lib-java.management.gmk b/make/lib/Lib-java.management.gmk index f59a6ac05e1..84e37386ba3 100644 --- a/make/lib/Lib-java.management.gmk +++ b/make/lib/Lib-java.management.gmk @@ -70,3 +70,7 @@ $(BUILD_LIBMANAGEMENT): $(call FindLib, java.base, java) TARGETS += $(BUILD_LIBMANAGEMENT) ################################################################################ + +# Include custom extension post hook +$(eval $(call IncludeCustomExtension, lib/Lib-java.management-post.gmk)) + diff --git a/make/lib/Lib-jdk.management.gmk b/make/lib/Lib-jdk.management.gmk index b04f5b2ed3a..6bb92b1c796 100644 --- a/make/lib/Lib-jdk.management.gmk +++ b/make/lib/Lib-jdk.management.gmk @@ -80,3 +80,7 @@ $(BUILD_LIBMANAGEMENT_EXT): $(call FindLib, java.base, java) TARGETS += $(BUILD_LIBMANAGEMENT_EXT) ################################################################################ + +# Include custom extension post hook +$(eval $(call IncludeCustomExtension, lib/Lib-jdk.management-post.gmk)) + diff --git a/make/mapfiles/libjava/mapfile-vers b/make/mapfiles/libjava/mapfile-vers index 8b68c02469e..4ee3bc1d72f 100644 --- a/make/mapfiles/libjava/mapfile-vers +++ b/make/mapfiles/libjava/mapfile-vers @@ -258,7 +258,6 @@ SUNWprivate_1.1 { Java_jdk_internal_reflect_NativeConstructorAccessorImpl_newInstance0; Java_jdk_internal_reflect_NativeMethodAccessorImpl_invoke0; Java_jdk_internal_reflect_Reflection_getCallerClass__; - Java_jdk_internal_reflect_Reflection_getCallerClass__I; Java_jdk_internal_reflect_Reflection_getClassAccessFlags; Java_jdk_internal_misc_VM_latestUserDefinedLoader0; Java_jdk_internal_misc_VM_getuid; diff --git a/make/mapfiles/libjava/reorder-sparc b/make/mapfiles/libjava/reorder-sparc index 990ca32b6fb..43f1afda6b1 100644 --- a/make/mapfiles/libjava/reorder-sparc +++ b/make/mapfiles/libjava/reorder-sparc @@ -27,7 +27,6 @@ text: .text%Java_java_io_FileDescriptor_initIDs; text: .text%Java_java_io_FileOutputStream_initIDs; text: .text%Java_java_lang_System_setIn0; text: .text%Java_sun_reflect_Reflection_getCallerClass__; -text: .text%Java_sun_reflect_Reflection_getCallerClass__I; text: .text%Java_java_lang_Class_forName0; text: .text%Java_java_lang_Object_getClass; text: .text%Java_sun_reflect_Reflection_getClassAccessFlags; diff --git a/make/mapfiles/libjava/reorder-sparcv9 b/make/mapfiles/libjava/reorder-sparcv9 index 4e3ce84b862..3e480bb7682 100644 --- a/make/mapfiles/libjava/reorder-sparcv9 +++ b/make/mapfiles/libjava/reorder-sparcv9 @@ -26,7 +26,6 @@ text: .text%Java_java_io_FileDescriptor_initIDs; text: .text%Java_java_io_FileOutputStream_initIDs; text: .text%Java_java_lang_System_setIn0; text: .text%Java_sun_reflect_Reflection_getCallerClass__; -text: .text%Java_sun_reflect_Reflection_getCallerClass__I; text: .text%Java_java_lang_Class_forName0; text: .text%Java_java_lang_String_intern; text: .text%Java_java_lang_StringUTF16_isBigEndian; diff --git a/make/mapfiles/libjava/reorder-x86 b/make/mapfiles/libjava/reorder-x86 index de28893a4d2..f294a93c4ba 100644 --- a/make/mapfiles/libjava/reorder-x86 +++ b/make/mapfiles/libjava/reorder-x86 @@ -27,7 +27,6 @@ text: .text%Java_java_io_FileDescriptor_initIDs; text: .text%Java_java_io_FileOutputStream_initIDs; text: .text%Java_java_lang_System_setIn0; text: .text%Java_sun_reflect_Reflection_getCallerClass__; -text: .text%Java_sun_reflect_Reflection_getCallerClass__I; text: .text%Java_java_lang_Class_forName0; text: .text%Java_java_lang_String_intern; text: .text%Java_java_lang_StringUTF16_isBigEndian; diff --git a/make/test/JtregNativeHotspot.gmk b/make/test/JtregNativeHotspot.gmk index 40df7d1ee42..511f9022304 100644 --- a/make/test/JtregNativeHotspot.gmk +++ b/make/test/JtregNativeHotspot.gmk @@ -44,6 +44,7 @@ $(eval $(call IncludeCustomExtension, test/JtregNativeHotspot.gmk)) # Add more directories here when needed. BUILD_HOTSPOT_JTREG_NATIVE_SRC += \ $(TOPDIR)/test/hotspot/jtreg/gc/g1/TestJNIWeakG1 \ + $(TOPDIR)/test/hotspot/jtreg/gc/stress/TestJNIBlockFullGC \ $(TOPDIR)/test/hotspot/jtreg/gc/stress/gclocker \ $(TOPDIR)/test/hotspot/jtreg/gc/cslocker \ $(TOPDIR)/test/hotspot/jtreg/native_sanity \ diff --git a/src/hotspot/cpu/aarch64/aarch64.ad b/src/hotspot/cpu/aarch64/aarch64.ad index 0b1e086f3a9..0a295cfbb46 100644 --- a/src/hotspot/cpu/aarch64/aarch64.ad +++ b/src/hotspot/cpu/aarch64/aarch64.ad @@ -5844,8 +5844,8 @@ operand immPollPage() operand immByteMapBase() %{ // Get base of card map - predicate((jbyte*)n->get_ptr() == - ((CardTableModRefBS*)(Universe::heap()->barrier_set()))->byte_map_base); + predicate(Universe::heap()->barrier_set()->is_a(BarrierSet::CardTableModRef) && + (jbyte*)n->get_ptr() == ((CardTableModRefBS*)(Universe::heap()->barrier_set()))->byte_map_base); match(ConP); op_cost(0); diff --git a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp index 2a9766f5143..23d0c691ce1 100644 --- a/src/hotspot/cpu/aarch64/assembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/assembler_aarch64.hpp @@ -848,7 +848,7 @@ public: // architecture. In debug mode we shrink it in order to test // trampolines, but not so small that branches in the interpreter // are out of range. - static const unsigned long branch_range = INCLUDE_JVMCI ? 128 * M : NOT_DEBUG(128 * M) DEBUG_ONLY(2 * M); + static const unsigned long branch_range = NOT_DEBUG(128 * M) DEBUG_ONLY(2 * M); static bool reachable_from_branch_at(address branch, address target) { return uabs(target - branch) < branch_range; @@ -2295,23 +2295,32 @@ public: rf(Vn, 5), rf(Rd, 0); } -#define INSN(NAME, opc, opc2) \ +#define INSN(NAME, opc, opc2, isSHR) \ void NAME(FloatRegister Vd, SIMD_Arrangement T, FloatRegister Vn, int shift){ \ starti; \ - /* The encodings for the immh:immb fields (bits 22:16) are \ - * 0001 xxx 8B/16B, shift = xxx \ - * 001x xxx 4H/8H, shift = xxxx \ - * 01xx xxx 2S/4S, shift = xxxxx \ - * 1xxx xxx 1D/2D, shift = xxxxxx (1D is RESERVED) \ + /* The encodings for the immh:immb fields (bits 22:16) in *SHR are \ + * 0001 xxx 8B/16B, shift = 16 - UInt(immh:immb) \ + * 001x xxx 4H/8H, shift = 32 - UInt(immh:immb) \ + * 01xx xxx 2S/4S, shift = 64 - UInt(immh:immb) \ + * 1xxx xxx 1D/2D, shift = 128 - UInt(immh:immb) \ + * (1D is RESERVED) \ + * for SHL shift is calculated as: \ + * 0001 xxx 8B/16B, shift = UInt(immh:immb) - 8 \ + * 001x xxx 4H/8H, shift = UInt(immh:immb) - 16 \ + * 01xx xxx 2S/4S, shift = UInt(immh:immb) - 32 \ + * 1xxx xxx 1D/2D, shift = UInt(immh:immb) - 64 \ + * (1D is RESERVED) \ */ \ assert((1 << ((T>>1)+3)) > shift, "Invalid Shift value"); \ + int cVal = (1 << (((T >> 1) + 3) + (isSHR ? 1 : 0))); \ + int encodedShift = isSHR ? cVal - shift : cVal + shift; \ f(0, 31), f(T & 1, 30), f(opc, 29), f(0b011110, 28, 23), \ - f((1 << ((T>>1)+3))|shift, 22, 16); f(opc2, 15, 10), rf(Vn, 5), rf(Vd, 0); \ + f(encodedShift, 22, 16); f(opc2, 15, 10), rf(Vn, 5), rf(Vd, 0); \ } - INSN(shl, 0, 0b010101); - INSN(sshr, 0, 0b000001); - INSN(ushr, 1, 0b000001); + INSN(shl, 0, 0b010101, /* isSHR = */ false); + INSN(sshr, 0, 0b000001, /* isSHR = */ true); + INSN(ushr, 1, 0b000001, /* isSHR = */ true); #undef INSN diff --git a/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp b/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp index 3059ad37bc6..09860aa0708 100644 --- a/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/compiledIC_aarch64.cpp @@ -71,6 +71,13 @@ int CompiledStaticCall::to_interp_stub_size() { return 7 * NativeInstruction::instruction_size; } +int CompiledStaticCall::to_trampoline_stub_size() { + // Somewhat pessimistically, we count 3 instructions here (although + // there are only two) because we sometimes emit an alignment nop. + // Trampoline stubs are always word aligned. + return 3 * NativeInstruction::instruction_size + wordSize; +} + // Relocation entries for call stub, compiled java to interpreter. int CompiledStaticCall::reloc_to_interp_stub() { return 4; // 3 in emit_to_interp_stub + 1 in emit_call diff --git a/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp b/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp index bebd5ae8ca9..9e36f607234 100644 --- a/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/jvmciCodeInstaller_aarch64.cpp @@ -109,7 +109,7 @@ void CodeInstaller::pd_relocate_ForeignCall(NativeInstruction* inst, jlong forei TRACE_jvmci_3("relocating (foreign call) at " PTR_FORMAT, p2i(inst)); } -void CodeInstaller::pd_relocate_JavaMethod(Handle hotspot_method, jint pc_offset, TRAPS) { +void CodeInstaller::pd_relocate_JavaMethod(CodeBuffer &cbuf, Handle hotspot_method, jint pc_offset, TRAPS) { #ifdef ASSERT Method* method = NULL; // we need to check, this might also be an unresolved method @@ -124,22 +124,22 @@ void CodeInstaller::pd_relocate_JavaMethod(Handle hotspot_method, jint pc_offset case INVOKEINTERFACE: { assert(method == NULL || !method->is_static(), "cannot call static method with invokeinterface"); NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_virtual_call_stub()); _instructions->relocate(call->instruction_address(), virtual_call_Relocation::spec(_invoke_mark_pc)); + call->trampoline_jump(cbuf, SharedRuntime::get_resolve_virtual_call_stub()); break; } case INVOKESTATIC: { assert(method == NULL || method->is_static(), "cannot call non-static method with invokestatic"); NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_static_call_stub()); _instructions->relocate(call->instruction_address(), relocInfo::static_call_type); + call->trampoline_jump(cbuf, SharedRuntime::get_resolve_static_call_stub()); break; } case INVOKESPECIAL: { assert(method == NULL || !method->is_static(), "cannot call static method with invokespecial"); NativeCall* call = nativeCall_at(_instructions->start() + pc_offset); - call->set_destination(SharedRuntime::get_resolve_opt_virtual_call_stub()); _instructions->relocate(call->instruction_address(), relocInfo::opt_virtual_call_type); + call->trampoline_jump(cbuf, SharedRuntime::get_resolve_opt_virtual_call_stub()); break; } default: diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 5bc06e36533..87c2ba75194 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -801,7 +801,7 @@ address MacroAssembler::emit_trampoline_stub(int insts_call_instruction_offset, assert(is_NativeCallTrampolineStub_at(stub_start_addr), "doesn't look like a trampoline"); end_a_stub(); - return stub; + return stub_start_addr; } address MacroAssembler::ic_call(address entry, jint method_index) { diff --git a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp index 6a313273ea6..98672792a32 100644 --- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.cpp @@ -367,3 +367,24 @@ void NativeCallTrampolineStub::set_destination(address new_destination) { set_ptr_at(data_offset, new_destination); OrderAccess::release(); } + +// Generate a trampoline for a branch to dest. If there's no need for a +// trampoline, simply patch the call directly to dest. +address NativeCall::trampoline_jump(CodeBuffer &cbuf, address dest) { + MacroAssembler a(&cbuf); + address stub = NULL; + + if (a.far_branches() + && ! is_NativeCallTrampolineStub_at(instruction_address() + displacement())) { + stub = a.emit_trampoline_stub(instruction_address() - cbuf.insts()->start(), dest); + } + + if (stub == NULL) { + // If we generated no stub, patch this call directly to dest. + // This will happen if we don't need far branches or if there + // already was a trampoline. + set_destination(dest); + } + + return stub; +} diff --git a/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp b/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp index a3a6d6a1302..da61fcf75d1 100644 --- a/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/nativeInst_aarch64.hpp @@ -61,7 +61,7 @@ class NativeInstruction VALUE_OBJ_CLASS_SPEC { return uint_at(0); } - bool is_blr() const { return (encoding() & 0xfffffc1f) == 0xd63f0000; } + bool is_blr() const { return (encoding() & 0xff9ffc1f) == 0xd61f0000; } // blr(register) or br(register) bool is_adr_aligned() const { return (encoding() & 0xff000000) == 0x10000000; } // adr Xn, * * - * + * * * * diff --git a/src/java.base/share/classes/java/lang/VersionProps.java.template b/src/java.base/share/classes/java/lang/VersionProps.java.template index 031d1393d38..e8585e4b0a3 100644 --- a/src/java.base/share/classes/java/lang/VersionProps.java.template +++ b/src/java.base/share/classes/java/lang/VersionProps.java.template @@ -166,15 +166,8 @@ class VersionProps { * Print version info. */ private static void print(boolean err, boolean newln) { - boolean isHeadless = false; PrintStream ps = err ? System.err : System.out; - /* Report that we're running headless if the property is true */ - String headless = System.getProperty("java.awt.headless"); - if ( (headless != null) && (headless.equalsIgnoreCase("true")) ) { - isHeadless = true; - } - /* First line: platform version. */ if (err) { ps.println(launcher_name + " version \"" + java_version + "\"" diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandle.java b/src/java.base/share/classes/java/lang/invoke/MethodHandle.java index 27c70b68964..ede758307d7 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandle.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandle.java @@ -1667,6 +1667,7 @@ assertEquals("[three, thee, tee]", asListFix.invoke((Object)argv).toString()); /** Craft a LambdaForm customized for this particular MethodHandle */ /*non-public*/ void customize() { + final LambdaForm form = this.form; if (form.customized == null) { LambdaForm newForm = form.customize(this); updateForm(newForm); diff --git a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java index bad45f6e336..f100ab2913c 100644 --- a/src/java.base/share/classes/java/lang/invoke/MethodHandles.java +++ b/src/java.base/share/classes/java/lang/invoke/MethodHandles.java @@ -3766,6 +3766,7 @@ assertEquals("xy", h3.invoke("x", "y", 1, "a", "b", "c")); * specified in the elements of the {@code filters} array. * The first element of the filter array corresponds to the {@code pos} * argument of the target, and so on in sequence. + * The filter functions are invoked in left to right order. *

      * Null arguments in the array are treated as identity functions, * and the corresponding arguments left unchanged. @@ -3836,11 +3837,12 @@ assertEquals("XY", (String) f2.invokeExact("x", "y")); // XY MethodHandle filterArguments(MethodHandle target, int pos, MethodHandle... filters) { filterArgumentsCheckArity(target, pos, filters); MethodHandle adapter = target; - int curPos = pos-1; // pre-incremented - for (MethodHandle filter : filters) { - curPos += 1; + // process filters in reverse order so that the invocation of + // the resulting adapter will invoke the filters in left-to-right order + for (int i = filters.length - 1; i >= 0; --i) { + MethodHandle filter = filters[i]; if (filter == null) continue; // ignore null elements of filters - adapter = filterArgument(adapter, curPos, filter); + adapter = filterArgument(adapter, pos + i, filter); } return adapter; } diff --git a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java index 7a4ace8dd6b..626c5200606 100644 --- a/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java +++ b/src/java.base/share/classes/java/lang/module/ModuleDescriptor.java @@ -2521,7 +2521,7 @@ public class ModuleDescriptor * the {@code packageFinder} throws an {@link UncheckedIOException} then * {@link IOException} cause will be re-thrown.

      * - *

      The module descriptor is read from the buffer stating at index + *

      The module descriptor is read from the buffer starting at index * {@code p}, where {@code p} is the buffer's {@link ByteBuffer#position() * position} when this method is invoked. Upon return the buffer's position * will be equal to {@code p + n} where {@code n} is the number of bytes diff --git a/src/java.base/share/classes/java/lang/ref/Reference.java b/src/java.base/share/classes/java/lang/ref/Reference.java index 5125e7cb553..2ead79fb636 100644 --- a/src/java.base/share/classes/java/lang/ref/Reference.java +++ b/src/java.base/share/classes/java/lang/ref/Reference.java @@ -140,14 +140,6 @@ public abstract class Reference { } } - /* - * system property to disable clearing before enqueuing. - */ - private static final class ClearBeforeEnqueue { - static final boolean DISABLE = - Boolean.getBoolean("jdk.lang.ref.disableClearBeforeEnqueue"); - } - /* * Atomically get and clear (set to null) the VM's pending list. */ @@ -299,8 +291,7 @@ public abstract class Reference { * it was not registered with a queue when it was created */ public boolean enqueue() { - if (!ClearBeforeEnqueue.DISABLE) - this.referent = null; + this.referent = null; return this.queue.enqueue(this); } diff --git a/src/java.base/share/classes/java/net/Inet6Address.java b/src/java.base/share/classes/java/net/Inet6Address.java index 0b612798f7c..8e1b0858bd4 100644 --- a/src/java.base/share/classes/java/net/Inet6Address.java +++ b/src/java.base/share/classes/java/net/Inet6Address.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -595,7 +595,7 @@ class Inet6Address extends InetAddress { } ObjectInputStream.GetField gf = s.readFields(); - byte[] ipaddress = (byte[])gf.get("ipaddress", null); + byte[] ipaddress = (byte[])gf.get("ipaddress", new byte[0]); int scope_id = gf.get("scope_id", -1); boolean scope_id_set = gf.get("scope_id_set", false); boolean scope_ifname_set = gf.get("scope_ifname_set", false); diff --git a/src/java.base/share/classes/java/net/InetSocketAddress.java b/src/java.base/share/classes/java/net/InetSocketAddress.java index 52517bd5ff9..bc37087a833 100644 --- a/src/java.base/share/classes/java/net/InetSocketAddress.java +++ b/src/java.base/share/classes/java/net/InetSocketAddress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -317,10 +317,9 @@ public class InetSocketAddress } /** - * * Gets the {@code InetAddress}. * - * @return the InetAdress or {@code null} if it is unresolved. + * @return the InetAddress or {@code null} if it is unresolved. */ public final InetAddress getAddress() { return holder.getAddress(); diff --git a/src/java.base/share/classes/java/nio/Bits.java b/src/java.base/share/classes/java/nio/Bits.java index dfe6a8f13a7..fff84e9e58d 100644 --- a/src/java.base/share/classes/java/nio/Bits.java +++ b/src/java.base/share/classes/java/nio/Bits.java @@ -63,38 +63,38 @@ class Bits { // package-private // -- Unsafe access -- - private static final Unsafe unsafe = Unsafe.getUnsafe(); + private static final Unsafe UNSAFE = Unsafe.getUnsafe(); static Unsafe unsafe() { - return unsafe; + return UNSAFE; } // -- Processor and memory-system properties -- - private static final ByteOrder byteOrder - = unsafe.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; + private static final ByteOrder BYTE_ORDER + = UNSAFE.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; static ByteOrder byteOrder() { - return byteOrder; + return BYTE_ORDER; } - private static int pageSize = -1; + private static int PAGE_SIZE = -1; static int pageSize() { - if (pageSize == -1) - pageSize = unsafe().pageSize(); - return pageSize; + if (PAGE_SIZE == -1) + PAGE_SIZE = unsafe().pageSize(); + return PAGE_SIZE; } static int pageCount(long size) { return (int)(size + (long)pageSize() - 1L) / pageSize(); } - private static boolean unaligned = unsafe.unalignedAccess(); + private static boolean UNALIGNED = UNSAFE.unalignedAccess(); static boolean unaligned() { - return unaligned; + return UNALIGNED; } @@ -103,11 +103,11 @@ class Bits { // package-private // A user-settable upper limit on the maximum amount of allocatable // direct buffer memory. This value may be changed during VM // initialization if it is launched with "-XX:MaxDirectMemorySize=". - private static volatile long maxMemory = VM.maxDirectMemory(); - private static final AtomicLong reservedMemory = new AtomicLong(); - private static final AtomicLong totalCapacity = new AtomicLong(); - private static final AtomicLong count = new AtomicLong(); - private static volatile boolean memoryLimitSet; + private static volatile long MAX_MEMORY = VM.maxDirectMemory(); + private static final AtomicLong RESERVED_MEMORY = new AtomicLong(); + private static final AtomicLong TOTAL_CAPACITY = new AtomicLong(); + private static final AtomicLong COUNT = new AtomicLong(); + private static volatile boolean MEMORY_LIMIT_SET; // max. number of sleeps during try-reserving with exponentially // increasing delay before throwing OutOfMemoryError: @@ -120,9 +120,9 @@ class Bits { // package-private // which a process may access. All sizes are specified in bytes. static void reserveMemory(long size, int cap) { - if (!memoryLimitSet && VM.initLevel() >= 1) { - maxMemory = VM.maxDirectMemory(); - memoryLimitSet = true; + if (!MEMORY_LIMIT_SET && VM.initLevel() >= 1) { + MAX_MEMORY = VM.maxDirectMemory(); + MEMORY_LIMIT_SET = true; } // optimist! @@ -200,10 +200,10 @@ class Bits { // package-private // actual memory usage, which will differ when buffers are page // aligned. long totalCap; - while (cap <= maxMemory - (totalCap = totalCapacity.get())) { - if (totalCapacity.compareAndSet(totalCap, totalCap + cap)) { - reservedMemory.addAndGet(size); - count.incrementAndGet(); + while (cap <= MAX_MEMORY - (totalCap = TOTAL_CAPACITY.get())) { + if (TOTAL_CAPACITY.compareAndSet(totalCap, totalCap + cap)) { + RESERVED_MEMORY.addAndGet(size); + COUNT.incrementAndGet(); return true; } } @@ -213,9 +213,9 @@ class Bits { // package-private static void unreserveMemory(long size, int cap) { - long cnt = count.decrementAndGet(); - long reservedMem = reservedMemory.addAndGet(-size); - long totalCap = totalCapacity.addAndGet(-cap); + long cnt = COUNT.decrementAndGet(); + long reservedMem = RESERVED_MEMORY.addAndGet(-size); + long totalCap = TOTAL_CAPACITY.addAndGet(-cap); assert cnt >= 0 && reservedMem >= 0 && totalCap >= 0; } @@ -234,15 +234,15 @@ class Bits { // package-private } @Override public long getCount() { - return Bits.count.get(); + return Bits.COUNT.get(); } @Override public long getTotalCapacity() { - return Bits.totalCapacity.get(); + return Bits.TOTAL_CAPACITY.get(); } @Override public long getMemoryUsed() { - return Bits.reservedMemory.get(); + return Bits.RESERVED_MEMORY.get(); } }; } diff --git a/src/java.base/share/classes/java/nio/Buffer.java b/src/java.base/share/classes/java/nio/Buffer.java index 1f6bef17960..1217ca78a74 100644 --- a/src/java.base/share/classes/java/nio/Buffer.java +++ b/src/java.base/share/classes/java/nio/Buffer.java @@ -26,6 +26,7 @@ package java.nio; import jdk.internal.HotSpotIntrinsicCandidate; +import jdk.internal.misc.Unsafe; import java.util.Spliterator; @@ -181,6 +182,8 @@ import java.util.Spliterator; */ public abstract class Buffer { + // Cached unsafe-access object + static final Unsafe UNSAFE = Bits.unsafe(); /** * The characteristics of Spliterators that traverse and split elements @@ -616,6 +619,14 @@ public abstract class Buffer { // -- Package-private methods for bounds checking, etc. -- + /** + * + * @return the base reference, paired with the address + * field, which in combination can be used for unsafe access into a heap + * buffer or direct byte buffer (and views of). + */ + abstract Object base(); + /** * Checks the current position against the limit, throwing a {@link * BufferUnderflowException} if it is not smaller than the limit, and then diff --git a/src/java.base/share/classes/java/nio/BufferMismatch.java b/src/java.base/share/classes/java/nio/BufferMismatch.java new file mode 100644 index 00000000000..c1260f62a19 --- /dev/null +++ b/src/java.base/share/classes/java/nio/BufferMismatch.java @@ -0,0 +1,198 @@ +/* + * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package java.nio; + +import jdk.internal.util.ArraysSupport; + +/** + * Mismatch methods for buffers + */ +final class BufferMismatch { + + static int mismatch(ByteBuffer a, int aOff, ByteBuffer b, int bOff, int length) { + int i = 0; + if (length > 7) { + i = ArraysSupport.vectorizedMismatch( + a.base(), a.address + aOff, + b.base(), b.address + bOff, + length, + ArraysSupport.LOG2_ARRAY_BYTE_INDEX_SCALE); + if (i >= 0) return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a.get(aOff + i) != b.get(bOff + i)) + return i; + } + return -1; + } + + static int mismatch(CharBuffer a, int aOff, CharBuffer b, int bOff, int length) { + int i = 0; + // Ensure only heap or off-heap buffer instances use the + // vectorized mismatch. If either buffer is a StringCharBuffer + // (order is null) then the slow path is taken + if (length > 3 && a.charRegionOrder() == b.charRegionOrder() + && a.charRegionOrder() != null && b.charRegionOrder() != null) { + i = ArraysSupport.vectorizedMismatch( + a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_CHAR_INDEX_SCALE), + b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_CHAR_INDEX_SCALE), + length, + ArraysSupport.LOG2_ARRAY_CHAR_INDEX_SCALE); + if (i >= 0) return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a.get(aOff + i) != b.get(bOff + i)) + return i; + } + return -1; + } + + static int mismatch(ShortBuffer a, int aOff, ShortBuffer b, int bOff, int length) { + int i = 0; + if (length > 3 && a.order() == b.order()) { + i = ArraysSupport.vectorizedMismatch( + a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_SHORT_INDEX_SCALE), + b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_SHORT_INDEX_SCALE), + length, + ArraysSupport.LOG2_ARRAY_SHORT_INDEX_SCALE); + if (i >= 0) return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a.get(aOff + i) != b.get(bOff + i)) + return i; + } + return -1; + } + + static int mismatch(IntBuffer a, int aOff, IntBuffer b, int bOff, int length) { + int i = 0; + if (length > 1 && a.order() == b.order()) { + i = ArraysSupport.vectorizedMismatch( + a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_INT_INDEX_SCALE), + b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_INT_INDEX_SCALE), + length, + ArraysSupport.LOG2_ARRAY_INT_INDEX_SCALE); + if (i >= 0) return i; + i = length - ~i; + } + for (; i < length; i++) { + if (a.get(aOff + i) != b.get(bOff + i)) + return i; + } + return -1; + } + + static int mismatch(FloatBuffer a, int aOff, FloatBuffer b, int bOff, int length) { + int i = 0; + if (length > 1 && a.order() == b.order()) { + i = ArraysSupport.vectorizedMismatch( + a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_FLOAT_INDEX_SCALE), + b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_FLOAT_INDEX_SCALE), + length, + ArraysSupport.LOG2_ARRAY_FLOAT_INDEX_SCALE); + // Mismatched + if (i >= 0) { + // Check if mismatch is not associated with two NaN values; and + // is not associated with +0 and -0 + float av = a.get(aOff + i); + float bv = b.get(bOff + i); + if (av != bv && (!Float.isNaN(av) || !Float.isNaN(bv))) + return i; + + // Fall back to slow mechanism + // ISSUE: Consider looping over vectorizedMismatch adjusting ranges + // However, requires that returned value be relative to input ranges + i++; + } + // Matched + else { + i = length - ~i; + } + } + for (; i < length; i++) { + float av = a.get(aOff + i); + float bv = b.get(bOff + i); + if (av != bv && (!Float.isNaN(av) || !Float.isNaN(bv))) + return i; + } + return -1; + } + + static int mismatch(LongBuffer a, int aOff, LongBuffer b, int bOff, int length) { + int i = 0; + if (length > 0 && a.order() == b.order()) { + i = ArraysSupport.vectorizedMismatch( + a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_LONG_INDEX_SCALE), + b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_LONG_INDEX_SCALE), + length, + ArraysSupport.LOG2_ARRAY_LONG_INDEX_SCALE); + return i >= 0 ? i : -1; + } + for (; i < length; i++) { + if (a.get(aOff + i) != b.get(bOff + i)) + return i; + } + return -1; + } + + static int mismatch(DoubleBuffer a, int aOff, DoubleBuffer b, int bOff, int length) { + int i = 0; + if (length > 0 && a.order() == b.order()) { + i = ArraysSupport.vectorizedMismatch( + a.base(), a.address + (aOff << ArraysSupport.LOG2_ARRAY_DOUBLE_INDEX_SCALE), + b.base(), b.address + (bOff << ArraysSupport.LOG2_ARRAY_DOUBLE_INDEX_SCALE), + length, + ArraysSupport.LOG2_ARRAY_DOUBLE_INDEX_SCALE); + // Mismatched + if (i >= 0) { + // Check if mismatch is not associated with two NaN values; and + // is not associated with +0 and -0 + double av = a.get(aOff + i); + double bv = b.get(bOff + i); + if (av != bv && (!Double.isNaN(av) || !Double.isNaN(bv))) + return i; + + // Fall back to slow mechanism + // ISSUE: Consider looping over vectorizedMismatch adjusting ranges + // However, requires that returned value be relative to input ranges + i++; + } + // Matched + else { + return -1; + } + } + for (; i < length; i++) { + double av = a.get(aOff + i); + double bv = b.get(bOff + i); + if (av != bv && (!Double.isNaN(av) || !Double.isNaN(bv))) + return i; + } + return -1; + } +} diff --git a/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template b/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template index 3ceb4122b62..b390448b110 100644 --- a/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template +++ b/src/java.base/share/classes/java/nio/ByteBufferAs-X-Buffer.java.template @@ -36,9 +36,6 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private #if[rw] - // Cached unsafe-access object - private static final Unsafe unsafe = Bits.unsafe(); - protected final ByteBuffer bb; #end[rw] @@ -74,6 +71,11 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private #end[rw] } + @Override + Object base() { + return bb.hb; + } + public $Type$Buffer slice() { int pos = this.position(); int lim = this.limit(); @@ -117,20 +119,20 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private } public $type$ get() { - $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(nextGetIndex()), + $memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(nextGetIndex()), {#if[boB]?true:false}); return $fromBits$(x); } public $type$ get(int i) { - $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), + $memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), {#if[boB]?true:false}); return $fromBits$(x); } #if[streamableType] $type$ getUnchecked(int i) { - $memtype$ x = unsafe.get$Memtype$Unaligned(bb.hb, byteOffset(i), + $memtype$ x = UNSAFE.get$Memtype$Unaligned(bb.hb, byteOffset(i), {#if[boB]?true:false}); return $fromBits$(x); } @@ -141,7 +143,7 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private public $Type$Buffer put($type$ x) { #if[rw] $memtype$ y = $toBits$(x); - unsafe.put$Memtype$Unaligned(bb.hb, byteOffset(nextPutIndex()), y, + UNSAFE.put$Memtype$Unaligned(bb.hb, byteOffset(nextPutIndex()), y, {#if[boB]?true:false}); return this; #else[rw] @@ -152,7 +154,7 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private public $Type$Buffer put(int i, $type$ x) { #if[rw] $memtype$ y = $toBits$(x); - unsafe.put$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), y, + UNSAFE.put$Memtype$Unaligned(bb.hb, byteOffset(checkIndex(i)), y, {#if[boB]?true:false}); return this; #else[rw] @@ -241,4 +243,9 @@ class ByteBufferAs$Type$Buffer$RW$$BO$ // package-private #end[boL] } +#if[char] + ByteOrder charRegionOrder() { + return order(); + } +#end[char] } diff --git a/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template b/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template index 6179776100d..cacadb101df 100644 --- a/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template +++ b/src/java.base/share/classes/java/nio/Direct-X-Buffer-bin.java.template @@ -32,7 +32,7 @@ class XXX { #if[rw] private $type$ get$Type$(long a) { - $memtype$ x = unsafe.get$Memtype$Unaligned(null, a, bigEndian); + $memtype$ x = UNSAFE.get$Memtype$Unaligned(null, a, bigEndian); return $fromBits$(x); } @@ -49,7 +49,7 @@ class XXX { private ByteBuffer put$Type$(long a, $type$ x) { #if[rw] $memtype$ y = $toBits$(x); - unsafe.put$Memtype$Unaligned(null, a, y, bigEndian); + UNSAFE.put$Memtype$Unaligned(null, a, y, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -81,7 +81,7 @@ class XXX { int rem = (off <= lim ? lim - off : 0); int size = rem >> $LG_BYTES_PER_VALUE$; - if (!unaligned && ((address + off) % $BYTES_PER_VALUE$ != 0)) { + if (!UNALIGNED && ((address + off) % $BYTES_PER_VALUE$ != 0)) { return (bigEndian ? ($Type$Buffer)(new ByteBufferAs$Type$Buffer$RW$B(this, -1, diff --git a/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template b/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template index 68ec8340e0d..5fa9be47b20 100644 --- a/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template +++ b/src/java.base/share/classes/java/nio/Direct-X-Buffer.java.template @@ -28,7 +28,6 @@ package java.nio; import java.io.FileDescriptor; -import jdk.internal.misc.Unsafe; import jdk.internal.misc.VM; import jdk.internal.ref.Cleaner; import sun.nio.ch.DirectBuffer; @@ -45,14 +44,11 @@ class Direct$Type$Buffer$RW$$BO$ #if[rw] - // Cached unsafe-access object - protected static final Unsafe unsafe = Bits.unsafe(); - // Cached array base offset - private static final long arrayBaseOffset = (long)unsafe.arrayBaseOffset($type$[].class); + private static final long ARRAY_BASE_OFFSET = UNSAFE.arrayBaseOffset($type$[].class); // Cached unaligned-access capability - protected static final boolean unaligned = Bits.unaligned(); + protected static final boolean UNALIGNED = Bits.unaligned(); // Base address, used in all indexing calculations // NOTE: moved up to Buffer.java for speed in JNI GetDirectBufferAddress @@ -73,8 +69,6 @@ class Direct$Type$Buffer$RW$$BO$ implements Runnable { - private static Unsafe unsafe = Unsafe.getUnsafe(); - private long address; private long size; private int capacity; @@ -91,7 +85,7 @@ class Direct$Type$Buffer$RW$$BO$ // Paranoia return; } - unsafe.freeMemory(address); + UNSAFE.freeMemory(address); address = 0; Bits.unreserveMemory(size, capacity); } @@ -124,12 +118,12 @@ class Direct$Type$Buffer$RW$$BO$ long base = 0; try { - base = unsafe.allocateMemory(size); + base = UNSAFE.allocateMemory(size); } catch (OutOfMemoryError x) { Bits.unreserveMemory(size, cap); throw x; } - unsafe.setMemory(base, size, (byte) 0); + UNSAFE.setMemory(base, size, (byte) 0); if (pa && (base % ps != 0)) { // Round up to page boundary address = base + ps - (base & (ps - 1)); @@ -206,6 +200,11 @@ class Direct$Type$Buffer$RW$$BO$ #end[rw] } + @Override + Object base() { + return null; + } + public $Type$Buffer slice() { int pos = this.position(); int lim = this.limit(); @@ -258,16 +257,16 @@ class Direct$Type$Buffer$RW$$BO$ } public $type$ get() { - return $fromBits$($swap$(unsafe.get$Swaptype$(ix(nextGetIndex())))); + return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(nextGetIndex())))); } public $type$ get(int i) { - return $fromBits$($swap$(unsafe.get$Swaptype$(ix(checkIndex(i))))); + return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(checkIndex(i))))); } #if[streamableType] $type$ getUnchecked(int i) { - return $fromBits$($swap$(unsafe.get$Swaptype$(ix(i)))); + return $fromBits$($swap$(UNSAFE.get$Swaptype$(ix(i)))); } #end[streamableType] @@ -282,10 +281,10 @@ class Direct$Type$Buffer$RW$$BO$ if (length > rem) throw new BufferUnderflowException(); - long dstOffset = arrayBaseOffset + ((long)offset << $LG_BYTES_PER_VALUE$); + long dstOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$); #if[!byte] if (order() != ByteOrder.nativeOrder()) - unsafe.copySwapMemory(null, + UNSAFE.copySwapMemory(null, ix(pos), dst, dstOffset, @@ -293,7 +292,7 @@ class Direct$Type$Buffer$RW$$BO$ (long)1 << $LG_BYTES_PER_VALUE$); else #end[!byte] - unsafe.copyMemory(null, + UNSAFE.copyMemory(null, ix(pos), dst, dstOffset, @@ -312,7 +311,7 @@ class Direct$Type$Buffer$RW$$BO$ public $Type$Buffer put($type$ x) { #if[rw] - unsafe.put$Swaptype$(ix(nextPutIndex()), $swap$($toBits$(x))); + UNSAFE.put$Swaptype$(ix(nextPutIndex()), $swap$($toBits$(x))); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -321,7 +320,7 @@ class Direct$Type$Buffer$RW$$BO$ public $Type$Buffer put(int i, $type$ x) { #if[rw] - unsafe.put$Swaptype$(ix(checkIndex(i)), $swap$($toBits$(x))); + UNSAFE.put$Swaptype$(ix(checkIndex(i)), $swap$($toBits$(x))); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -347,7 +346,7 @@ class Direct$Type$Buffer$RW$$BO$ if (srem > rem) throw new BufferOverflowException(); - unsafe.copyMemory(sb.ix(spos), ix(pos), (long)srem << $LG_BYTES_PER_VALUE$); + UNSAFE.copyMemory(sb.ix(spos), ix(pos), (long)srem << $LG_BYTES_PER_VALUE$); sb.position(spos + srem); position(pos + srem); } else if (src.hb != null) { @@ -380,10 +379,10 @@ class Direct$Type$Buffer$RW$$BO$ if (length > rem) throw new BufferOverflowException(); - long srcOffset = arrayBaseOffset + ((long)offset << $LG_BYTES_PER_VALUE$); + long srcOffset = ARRAY_BASE_OFFSET + ((long)offset << $LG_BYTES_PER_VALUE$); #if[!byte] if (order() != ByteOrder.nativeOrder()) - unsafe.copySwapMemory(src, + UNSAFE.copySwapMemory(src, srcOffset, null, ix(pos), @@ -391,7 +390,7 @@ class Direct$Type$Buffer$RW$$BO$ (long)1 << $LG_BYTES_PER_VALUE$); else #end[!byte] - unsafe.copyMemory(src, + UNSAFE.copyMemory(src, srcOffset, null, ix(pos), @@ -413,7 +412,7 @@ class Direct$Type$Buffer$RW$$BO$ assert (pos <= lim); int rem = (pos <= lim ? lim - pos : 0); - unsafe.copyMemory(ix(pos), ix(0), (long)rem << $LG_BYTES_PER_VALUE$); + UNSAFE.copyMemory(ix(pos), ix(0), (long)rem << $LG_BYTES_PER_VALUE$); position(rem); limit(capacity()); discardMark(); @@ -490,17 +489,22 @@ class Direct$Type$Buffer$RW$$BO$ #end[!byte] +#if[char] + ByteOrder charRegionOrder() { + return order(); + } +#end[char] #if[byte] byte _get(int i) { // package-private - return unsafe.getByte(address + i); + return UNSAFE.getByte(address + i); } void _put(int i, byte b) { // package-private #if[rw] - unsafe.putByte(address + i, b); + UNSAFE.putByte(address + i, b); #else[rw] throw new ReadOnlyBufferException(); #end[rw] diff --git a/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template b/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template index 69e65a099c7..7f2a2597ba3 100644 --- a/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template +++ b/src/java.base/share/classes/java/nio/Heap-X-Buffer.java.template @@ -27,8 +27,6 @@ package java.nio; -import jdk.internal.misc.Unsafe; - /** #if[rw] * A read/write Heap$Type$Buffer. @@ -43,6 +41,11 @@ import jdk.internal.misc.Unsafe; class Heap$Type$Buffer$RW$ extends {#if[ro]?Heap}$Type$Buffer { + // Cached array base offset + private static final long ARRAY_BASE_OFFSET = UNSAFE.arrayBaseOffset($type$[].class); + + // Cached array base offset + private static final long ARRAY_INDEX_SCALE = UNSAFE.arrayIndexScale($type$[].class); // For speed these fields are actually declared in X-Buffer; // these declarations are here as documentation @@ -53,16 +56,6 @@ class Heap$Type$Buffer$RW$ #end[rw] */ -#if[byte] - - // Cached unsafe-access object - private static final Unsafe unsafe = Bits.unsafe(); - - // Cached array base offset - private static final long arrayBaseOffset = unsafe.arrayBaseOffset($type$[].class); - -#end[byte] - Heap$Type$Buffer$RW$(int cap, int lim) { // package-private #if[rw] super(-1, 0, lim, cap, new $type$[cap], 0); @@ -70,13 +63,11 @@ class Heap$Type$Buffer$RW$ hb = new $type$[cap]; offset = 0; */ + this.address = ARRAY_BASE_OFFSET; #else[rw] super(cap, lim); this.isReadOnly = true; #end[rw] -#if[byte] - this.address = arrayBaseOffset; -#end[byte] } Heap$Type$Buffer$RW$($type$[] buf, int off, int len) { // package-private @@ -86,13 +77,11 @@ class Heap$Type$Buffer$RW$ hb = buf; offset = 0; */ + this.address = ARRAY_BASE_OFFSET; #else[rw] super(buf, off, len); this.isReadOnly = true; #end[rw] -#if[byte] - this.address = arrayBaseOffset; -#end[byte] } protected Heap$Type$Buffer$RW$($type$[] buf, @@ -105,13 +94,11 @@ class Heap$Type$Buffer$RW$ hb = buf; offset = off; */ + this.address = ARRAY_BASE_OFFSET + off * ARRAY_INDEX_SCALE; #else[rw] super(buf, mark, pos, lim, cap, off); this.isReadOnly = true; #end[rw] -#if[byte] - this.address = arrayBaseOffset + off; -#end[byte] } public $Type$Buffer slice() { @@ -296,18 +283,18 @@ class Heap$Type$Buffer$RW$ #if[rw] public char getChar() { - return unsafe.getCharUnaligned(hb, byteOffset(nextGetIndex(2)), bigEndian); + return UNSAFE.getCharUnaligned(hb, byteOffset(nextGetIndex(2)), bigEndian); } public char getChar(int i) { - return unsafe.getCharUnaligned(hb, byteOffset(checkIndex(i, 2)), bigEndian); + return UNSAFE.getCharUnaligned(hb, byteOffset(checkIndex(i, 2)), bigEndian); } #end[rw] public $Type$Buffer putChar(char x) { #if[rw] - unsafe.putCharUnaligned(hb, byteOffset(nextPutIndex(2)), x, bigEndian); + UNSAFE.putCharUnaligned(hb, byteOffset(nextPutIndex(2)), x, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -316,7 +303,7 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer putChar(int i, char x) { #if[rw] - unsafe.putCharUnaligned(hb, byteOffset(checkIndex(i, 2)), x, bigEndian); + UNSAFE.putCharUnaligned(hb, byteOffset(checkIndex(i, 2)), x, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -347,18 +334,18 @@ class Heap$Type$Buffer$RW$ #if[rw] public short getShort() { - return unsafe.getShortUnaligned(hb, byteOffset(nextGetIndex(2)), bigEndian); + return UNSAFE.getShortUnaligned(hb, byteOffset(nextGetIndex(2)), bigEndian); } public short getShort(int i) { - return unsafe.getShortUnaligned(hb, byteOffset(checkIndex(i, 2)), bigEndian); + return UNSAFE.getShortUnaligned(hb, byteOffset(checkIndex(i, 2)), bigEndian); } #end[rw] public $Type$Buffer putShort(short x) { #if[rw] - unsafe.putShortUnaligned(hb, byteOffset(nextPutIndex(2)), x, bigEndian); + UNSAFE.putShortUnaligned(hb, byteOffset(nextPutIndex(2)), x, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -367,7 +354,7 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer putShort(int i, short x) { #if[rw] - unsafe.putShortUnaligned(hb, byteOffset(checkIndex(i, 2)), x, bigEndian); + UNSAFE.putShortUnaligned(hb, byteOffset(checkIndex(i, 2)), x, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -398,18 +385,18 @@ class Heap$Type$Buffer$RW$ #if[rw] public int getInt() { - return unsafe.getIntUnaligned(hb, byteOffset(nextGetIndex(4)), bigEndian); + return UNSAFE.getIntUnaligned(hb, byteOffset(nextGetIndex(4)), bigEndian); } public int getInt(int i) { - return unsafe.getIntUnaligned(hb, byteOffset(checkIndex(i, 4)), bigEndian); + return UNSAFE.getIntUnaligned(hb, byteOffset(checkIndex(i, 4)), bigEndian); } #end[rw] public $Type$Buffer putInt(int x) { #if[rw] - unsafe.putIntUnaligned(hb, byteOffset(nextPutIndex(4)), x, bigEndian); + UNSAFE.putIntUnaligned(hb, byteOffset(nextPutIndex(4)), x, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -418,7 +405,7 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer putInt(int i, int x) { #if[rw] - unsafe.putIntUnaligned(hb, byteOffset(checkIndex(i, 4)), x, bigEndian); + UNSAFE.putIntUnaligned(hb, byteOffset(checkIndex(i, 4)), x, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -449,18 +436,18 @@ class Heap$Type$Buffer$RW$ #if[rw] public long getLong() { - return unsafe.getLongUnaligned(hb, byteOffset(nextGetIndex(8)), bigEndian); + return UNSAFE.getLongUnaligned(hb, byteOffset(nextGetIndex(8)), bigEndian); } public long getLong(int i) { - return unsafe.getLongUnaligned(hb, byteOffset(checkIndex(i, 8)), bigEndian); + return UNSAFE.getLongUnaligned(hb, byteOffset(checkIndex(i, 8)), bigEndian); } #end[rw] public $Type$Buffer putLong(long x) { #if[rw] - unsafe.putLongUnaligned(hb, byteOffset(nextPutIndex(8)), x, bigEndian); + UNSAFE.putLongUnaligned(hb, byteOffset(nextPutIndex(8)), x, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -469,7 +456,7 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer putLong(int i, long x) { #if[rw] - unsafe.putLongUnaligned(hb, byteOffset(checkIndex(i, 8)), x, bigEndian); + UNSAFE.putLongUnaligned(hb, byteOffset(checkIndex(i, 8)), x, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -500,12 +487,12 @@ class Heap$Type$Buffer$RW$ #if[rw] public float getFloat() { - int x = unsafe.getIntUnaligned(hb, byteOffset(nextGetIndex(4)), bigEndian); + int x = UNSAFE.getIntUnaligned(hb, byteOffset(nextGetIndex(4)), bigEndian); return Float.intBitsToFloat(x); } public float getFloat(int i) { - int x = unsafe.getIntUnaligned(hb, byteOffset(checkIndex(i, 4)), bigEndian); + int x = UNSAFE.getIntUnaligned(hb, byteOffset(checkIndex(i, 4)), bigEndian); return Float.intBitsToFloat(x); } @@ -514,7 +501,7 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer putFloat(float x) { #if[rw] int y = Float.floatToRawIntBits(x); - unsafe.putIntUnaligned(hb, byteOffset(nextPutIndex(4)), y, bigEndian); + UNSAFE.putIntUnaligned(hb, byteOffset(nextPutIndex(4)), y, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -524,7 +511,7 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer putFloat(int i, float x) { #if[rw] int y = Float.floatToRawIntBits(x); - unsafe.putIntUnaligned(hb, byteOffset(checkIndex(i, 4)), y, bigEndian); + UNSAFE.putIntUnaligned(hb, byteOffset(checkIndex(i, 4)), y, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -555,12 +542,12 @@ class Heap$Type$Buffer$RW$ #if[rw] public double getDouble() { - long x = unsafe.getLongUnaligned(hb, byteOffset(nextGetIndex(8)), bigEndian); + long x = UNSAFE.getLongUnaligned(hb, byteOffset(nextGetIndex(8)), bigEndian); return Double.longBitsToDouble(x); } public double getDouble(int i) { - long x = unsafe.getLongUnaligned(hb, byteOffset(checkIndex(i, 8)), bigEndian); + long x = UNSAFE.getLongUnaligned(hb, byteOffset(checkIndex(i, 8)), bigEndian); return Double.longBitsToDouble(x); } @@ -569,7 +556,7 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer putDouble(double x) { #if[rw] long y = Double.doubleToRawLongBits(x); - unsafe.putLongUnaligned(hb, byteOffset(nextPutIndex(8)), y, bigEndian); + UNSAFE.putLongUnaligned(hb, byteOffset(nextPutIndex(8)), y, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -579,7 +566,7 @@ class Heap$Type$Buffer$RW$ public $Type$Buffer putDouble(int i, double x) { #if[rw] long y = Double.doubleToRawLongBits(x); - unsafe.putLongUnaligned(hb, byteOffset(checkIndex(i, 8)), y, bigEndian); + UNSAFE.putLongUnaligned(hb, byteOffset(checkIndex(i, 8)), y, bigEndian); return this; #else[rw] throw new ReadOnlyBufferException(); @@ -643,7 +630,11 @@ class Heap$Type$Buffer$RW$ public ByteOrder order() { return ByteOrder.nativeOrder(); } - #end[!byte] +#if[char] + ByteOrder charRegionOrder() { + return order(); + } +#end[char] } diff --git a/src/java.base/share/classes/java/nio/StringCharBuffer.java b/src/java.base/share/classes/java/nio/StringCharBuffer.java index 71f4b368d29..26b355bc819 100644 --- a/src/java.base/share/classes/java/nio/StringCharBuffer.java +++ b/src/java.base/share/classes/java/nio/StringCharBuffer.java @@ -127,4 +127,30 @@ class StringCharBuffer // package-private return ByteOrder.nativeOrder(); } + ByteOrder charRegionOrder() { + return null; + } + + public boolean equals(Object ob) { + if (this == ob) + return true; + if (!(ob instanceof CharBuffer)) + return false; + CharBuffer that = (CharBuffer)ob; + if (this.remaining() != that.remaining()) + return false; + return BufferMismatch.mismatch(this, this.position(), + that, that.position(), + this.remaining()) < 0; + } + + public int compareTo(CharBuffer that) { + int i = BufferMismatch.mismatch(this, this.position(), + that, that.position(), + Math.min(this.remaining(), that.remaining())); + if (i >= 0) { + return Character.compare(this.get(this.position() + i), that.get(this.position() + i)); + } + return this.remaining() - that.remaining(); + } } diff --git a/src/java.base/share/classes/java/nio/X-Buffer.java.template b/src/java.base/share/classes/java/nio/X-Buffer.java.template index 0a39543a88e..96e05d6a663 100644 --- a/src/java.base/share/classes/java/nio/X-Buffer.java.template +++ b/src/java.base/share/classes/java/nio/X-Buffer.java.template @@ -36,6 +36,8 @@ import java.util.stream.StreamSupport; import java.util.stream.$Streamtype$Stream; #end[streamableType] +import jdk.internal.util.ArraysSupport; + /** * $A$ $type$ buffer. * @@ -287,6 +289,11 @@ public abstract class $Type$Buffer this(mark, pos, lim, cap, null, 0); } + @Override + Object base() { + return hb; + } + #if[byte] /** @@ -1297,19 +1304,9 @@ public abstract class $Type$Buffer $Type$Buffer that = ($Type$Buffer)ob; if (this.remaining() != that.remaining()) return false; - int p = this.position(); - for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) - if (!equals(this.get(i), that.get(j))) - return false; - return true; - } - - private static boolean equals($type$ x, $type$ y) { -#if[floatingPointType] - return (x == y) || ($Fulltype$.isNaN(x) && $Fulltype$.isNaN(y)); -#else[floatingPointType] - return x == y; -#end[floatingPointType] + return BufferMismatch.mismatch(this, this.position(), + that, that.position(), + this.remaining()) < 0; } /** @@ -1336,11 +1333,11 @@ public abstract class $Type$Buffer * is less than, equal to, or greater than the given buffer */ public int compareTo($Type$Buffer that) { - int n = this.position() + Math.min(this.remaining(), that.remaining()); - for (int i = this.position(), j = that.position(); i < n; i++, j++) { - int cmp = compare(this.get(i), that.get(j)); - if (cmp != 0) - return cmp; + int i = BufferMismatch.mismatch(this, this.position(), + that, that.position(), + Math.min(this.remaining(), that.remaining())); + if (i >= 0) { + return compare(this.get(this.position() + i), that.get(this.position() + i)); } return this.remaining() - that.remaining(); } @@ -1571,6 +1568,12 @@ public abstract class $Type$Buffer #end[!byte] +#if[char] + // The order or null if the buffer does not cover a memory region, + // such as StringCharBuffer + abstract ByteOrder charRegionOrder(); +#end[char] + #if[byte] boolean bigEndian // package-private diff --git a/src/java.base/share/classes/java/nio/file/Files.java b/src/java.base/share/classes/java/nio/file/Files.java index c7e0dcf9938..41ac57fa3cf 100644 --- a/src/java.base/share/classes/java/nio/file/Files.java +++ b/src/java.base/share/classes/java/nio/file/Files.java @@ -2954,22 +2954,6 @@ public final class Files { return newBufferedWriter(path, StandardCharsets.UTF_8, options); } - /** - * Reads all bytes from an input stream and writes them to an output stream. - */ - private static long copy(InputStream source, OutputStream sink) - throws IOException - { - long nread = 0L; - byte[] buf = new byte[BUFFER_SIZE]; - int n; - while ((n = source.read(buf)) > 0) { - sink.write(buf, 0, n); - nread += n; - } - return nread; - } - /** * Copies all bytes from an input stream to a file. On return, the input * stream will be at end of stream. @@ -3082,7 +3066,7 @@ public final class Files { // do the copy try (OutputStream out = ostream) { - return copy(in, out); + return in.transferTo(out); } } @@ -3124,7 +3108,7 @@ public final class Files { Objects.requireNonNull(out); try (InputStream in = newInputStream(source)) { - return copy(in, out); + return in.transferTo(out); } } diff --git a/src/java.base/share/classes/java/text/DateFormatSymbols.java b/src/java.base/share/classes/java/text/DateFormatSymbols.java index 774b64ca1b5..7fecda24ca8 100644 --- a/src/java.base/share/classes/java/text/DateFormatSymbols.java +++ b/src/java.base/share/classes/java/text/DateFormatSymbols.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -394,6 +394,12 @@ public class DateFormatSymbols implements Serializable, Cloneable { /** * Gets month strings. For example: "January", "February", etc. + * An array with either 12 or 13 elements will be returned depending + * on whether or not {@link java.util.Calendar#UNDECIMBER Calendar.UNDECIMBER} + * is supported. Use + * {@link java.util.Calendar#JANUARY Calendar.JANUARY}, + * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY}, + * etc. to index the result array. * *

      If the language requires different forms for formatting and * stand-alone usages, this method returns month names in the @@ -405,10 +411,9 @@ public class DateFormatSymbols implements Serializable, Cloneable { * Calendar Elements in the Unicode Locale Data Markup Language * (LDML) specification for more details. * - * @return the month strings. Use - * {@link java.util.Calendar#JANUARY Calendar.JANUARY}, - * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY}, - * etc. to index the result array. + * @implSpec This method returns 13 elements since + * {@link java.util.Calendar#UNDECIMBER Calendar.UNDECIMBER} is supported. + * @return the month strings. */ public String[] getMonths() { return Arrays.copyOf(months, months.length); @@ -427,6 +432,12 @@ public class DateFormatSymbols implements Serializable, Cloneable { /** * Gets short month strings. For example: "Jan", "Feb", etc. + * An array with either 12 or 13 elements will be returned depending + * on whether or not {@link java.util.Calendar#UNDECIMBER Calendar.UNDECIMBER} + * is supported. Use + * {@link java.util.Calendar#JANUARY Calendar.JANUARY}, + * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY}, + * etc. to index the result array. * *

      If the language requires different forms for formatting and * stand-alone usages, this method returns short month names in @@ -438,10 +449,9 @@ public class DateFormatSymbols implements Serializable, Cloneable { * Calendar Elements in the Unicode Locale Data Markup Language * (LDML) specification for more details. * - * @return the short month strings. Use - * {@link java.util.Calendar#JANUARY Calendar.JANUARY}, - * {@link java.util.Calendar#FEBRUARY Calendar.FEBRUARY}, - * etc. to index the result array. + * @implSpec This method returns 13 elements since + * {@link java.util.Calendar#UNDECIMBER Calendar.UNDECIMBER} is supported. + * @return the short month strings. */ public String[] getShortMonths() { return Arrays.copyOf(shortMonths, shortMonths.length); diff --git a/src/java.base/share/classes/java/time/temporal/IsoFields.java b/src/java.base/share/classes/java/time/temporal/IsoFields.java index 1294bb1e8be..5a0d52555a3 100644 --- a/src/java.base/share/classes/java/time/temporal/IsoFields.java +++ b/src/java.base/share/classes/java/time/temporal/IsoFields.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -708,9 +708,8 @@ public final class IsoFields { return (R) temporal.with(WEEK_BASED_YEAR, Math.addExact(temporal.get(WEEK_BASED_YEAR), amount)); case QUARTER_YEARS: - // no overflow (256 is multiple of 4) - return (R) temporal.plus(amount / 256, YEARS) - .plus((amount % 256) * 3, MONTHS); + return (R) temporal.plus(amount / 4, YEARS) + .plus((amount % 4) * 3, MONTHS); default: throw new IllegalStateException("Unreachable"); } diff --git a/src/java.base/share/classes/java/util/ArrayList.java b/src/java.base/share/classes/java/util/ArrayList.java index 53d2a05f61b..c57ccf73778 100644 --- a/src/java.base/share/classes/java/util/ArrayList.java +++ b/src/java.base/share/classes/java/util/ArrayList.java @@ -1143,6 +1143,23 @@ public class ArrayList extends AbstractList return modified; } + public Object[] toArray() { + checkForComodification(); + return Arrays.copyOfRange(root.elementData, offset, offset + size); + } + + @SuppressWarnings("unchecked") + public T[] toArray(T[] a) { + checkForComodification(); + if (a.length < size) + return (T[]) Arrays.copyOfRange( + root.elementData, offset, offset + size, a.getClass()); + System.arraycopy(root.elementData, offset, a, 0, size); + if (a.length > size) + a[size] = null; + return a; + } + public Iterator iterator() { return listIterator(); } @@ -1550,7 +1567,6 @@ public class ArrayList extends AbstractList setBit(deathRow, i - beg); if (modCount != expectedModCount) throw new ConcurrentModificationException(); - expectedModCount++; modCount++; int w = beg; for (i = beg; i < end; i++) diff --git a/src/java.base/share/classes/java/util/Arrays.java b/src/java.base/share/classes/java/util/Arrays.java index e1571cc613f..74011566f26 100644 --- a/src/java.base/share/classes/java/util/Arrays.java +++ b/src/java.base/share/classes/java/util/Arrays.java @@ -26,6 +26,7 @@ package java.util; import jdk.internal.HotSpotIntrinsicCandidate; +import jdk.internal.util.ArraysSupport; import java.lang.reflect.Array; import java.util.concurrent.ForkJoinPool; diff --git a/src/java.base/share/classes/java/util/Base64.java b/src/java.base/share/classes/java/util/Base64.java index 0973a63844c..398dee43dba 100644 --- a/src/java.base/share/classes/java/util/Base64.java +++ b/src/java.base/share/classes/java/util/Base64.java @@ -116,8 +116,8 @@ public class Base64 { * * @param lineLength * the length of each output line (rounded down to nearest multiple - * of 4). If {@code lineLength <= 0} the output will not be separated - * in lines + * of 4). If the rounded down line length is not a positive value, + * the output will not be separated in lines * @param lineSeparator * the line separator for each output line * @@ -135,10 +135,12 @@ public class Base64 { throw new IllegalArgumentException( "Illegal base64 line separator character 0x" + Integer.toString(b, 16)); } + // round down to nearest multiple of 4 + lineLength &= ~0b11; if (lineLength <= 0) { return Encoder.RFC4648; } - return new Encoder(false, lineSeparator, lineLength >> 2 << 2, true); + return new Encoder(false, lineSeparator, lineLength, true); } /** diff --git a/src/java.base/share/classes/java/util/Vector.java b/src/java.base/share/classes/java/util/Vector.java index fac073b1116..bb80cba55b6 100644 --- a/src/java.base/share/classes/java/util/Vector.java +++ b/src/java.base/share/classes/java/util/Vector.java @@ -1023,7 +1023,6 @@ public class Vector setBit(deathRow, i - beg); if (modCount != expectedModCount) throw new ConcurrentModificationException(); - expectedModCount++; modCount++; int w = beg; for (i = beg; i < end; i++) diff --git a/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java b/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java index e4d22357190..a2068671fab 100644 --- a/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java +++ b/src/java.base/share/classes/java/util/concurrent/AbstractExecutorService.java @@ -245,8 +245,7 @@ public abstract class AbstractExecutorService implements ExecutorService { Future f = futures.get(i); if (!f.isDone()) { try { f.get(); } - catch (CancellationException ignore) {} - catch (ExecutionException ignore) {} + catch (CancellationException | ExecutionException ignore) {} } } return futures; @@ -283,8 +282,7 @@ public abstract class AbstractExecutorService implements ExecutorService { Future f = futures.get(j); if (!f.isDone()) { try { f.get(deadline - System.nanoTime(), NANOSECONDS); } - catch (CancellationException ignore) {} - catch (ExecutionException ignore) {} + catch (CancellationException | ExecutionException ignore) {} catch (TimeoutException timedOut) { break timedOut; } diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java index 03ed2fa2974..383253eddc4 100644 --- a/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java +++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentHashMap.java @@ -717,12 +717,12 @@ public class ConcurrentHashMap extends AbstractMap */ static Class comparableClassFor(Object x) { if (x instanceof Comparable) { - Class c; Type[] ts, as; Type t; ParameterizedType p; + Class c; Type[] ts, as; ParameterizedType p; if ((c = x.getClass()) == String.class) // bypass checks return c; if ((ts = c.getGenericInterfaces()) != null) { - for (int i = 0; i < ts.length; ++i) { - if (((t = ts[i]) instanceof ParameterizedType) && + for (Type t : ts) { + if ((t instanceof ParameterizedType) && ((p = (ParameterizedType)t).getRawType() == Comparable.class) && (as = p.getActualTypeArguments()) != null && @@ -2328,15 +2328,15 @@ public class ConcurrentHashMap extends AbstractMap * @param check if <0, don't check resize, if <= 1 only check if uncontended */ private final void addCount(long x, int check) { - CounterCell[] as; long b, s; - if ((as = counterCells) != null || + CounterCell[] cs; long b, s; + if ((cs = counterCells) != null || !U.compareAndSetLong(this, BASECOUNT, b = baseCount, s = b + x)) { - CounterCell a; long v; int m; + CounterCell c; long v; int m; boolean uncontended = true; - if (as == null || (m = as.length - 1) < 0 || - (a = as[ThreadLocalRandom.getProbe() & m]) == null || + if (cs == null || (m = cs.length - 1) < 0 || + (c = cs[ThreadLocalRandom.getProbe() & m]) == null || !(uncontended = - U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x))) { + U.compareAndSetLong(c, CELLVALUE, v = c.value, v + x))) { fullAddCount(x, uncontended); return; } @@ -2574,13 +2574,12 @@ public class ConcurrentHashMap extends AbstractMap } final long sumCount() { - CounterCell[] as = counterCells; CounterCell a; + CounterCell[] cs = counterCells; long sum = baseCount; - if (as != null) { - for (int i = 0; i < as.length; ++i) { - if ((a = as[i]) != null) - sum += a.value; - } + if (cs != null) { + for (CounterCell c : cs) + if (c != null) + sum += c.value; } return sum; } @@ -2595,9 +2594,9 @@ public class ConcurrentHashMap extends AbstractMap } boolean collide = false; // True if last slot nonempty for (;;) { - CounterCell[] as; CounterCell a; int n; long v; - if ((as = counterCells) != null && (n = as.length) > 0) { - if ((a = as[(n - 1) & h]) == null) { + CounterCell[] cs; CounterCell c; int n; long v; + if ((cs = counterCells) != null && (n = cs.length) > 0) { + if ((c = cs[(n - 1) & h]) == null) { if (cellsBusy == 0) { // Try to attach new Cell CounterCell r = new CounterCell(x); // Optimistic create if (cellsBusy == 0 && @@ -2623,21 +2622,17 @@ public class ConcurrentHashMap extends AbstractMap } else if (!wasUncontended) // CAS already known to fail wasUncontended = true; // Continue after rehash - else if (U.compareAndSetLong(a, CELLVALUE, v = a.value, v + x)) + else if (U.compareAndSetLong(c, CELLVALUE, v = c.value, v + x)) break; - else if (counterCells != as || n >= NCPU) + else if (counterCells != cs || n >= NCPU) collide = false; // At max size or stale else if (!collide) collide = true; else if (cellsBusy == 0 && U.compareAndSetInt(this, CELLSBUSY, 0, 1)) { try { - if (counterCells == as) {// Expand table unless stale - CounterCell[] rs = new CounterCell[n << 1]; - for (int i = 0; i < n; ++i) - rs[i] = as[i]; - counterCells = rs; - } + if (counterCells == cs) // Expand table unless stale + counterCells = Arrays.copyOf(cs, n << 1); } finally { cellsBusy = 0; } @@ -2646,11 +2641,11 @@ public class ConcurrentHashMap extends AbstractMap } h = ThreadLocalRandom.advanceProbe(h); } - else if (cellsBusy == 0 && counterCells == as && + else if (cellsBusy == 0 && counterCells == cs && U.compareAndSetInt(this, CELLSBUSY, 0, 1)) { boolean init = false; try { // Initialize table - if (counterCells == as) { + if (counterCells == cs) { CounterCell[] rs = new CounterCell[2]; rs[h & 1] = new CounterCell(x); counterCells = rs; diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java index 96afa4c32c8..b0db2794026 100644 --- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java +++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListMap.java @@ -2204,9 +2204,7 @@ public class ConcurrentSkipListMap extends AbstractMap Collection c = (Collection) o; try { return containsAll(c) && c.containsAll(this); - } catch (ClassCastException unused) { - return false; - } catch (NullPointerException unused) { + } catch (ClassCastException | NullPointerException unused) { return false; } } @@ -2331,9 +2329,7 @@ public class ConcurrentSkipListMap extends AbstractMap Collection c = (Collection) o; try { return containsAll(c) && c.containsAll(this); - } catch (ClassCastException unused) { - return false; - } catch (NullPointerException unused) { + } catch (ClassCastException | NullPointerException unused) { return false; } } @@ -2453,9 +2449,7 @@ public class ConcurrentSkipListMap extends AbstractMap if (k == null) // pass by markers and headers return true; int c = cpr(cmp, k, hi); - if (c > 0 || (c == 0 && !hiInclusive)) - return false; - return true; + return c < 0 || (c == 0 && hiInclusive); } /** diff --git a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java index 82e4b987781..9b6330238d7 100644 --- a/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java +++ b/src/java.base/share/classes/java/util/concurrent/ConcurrentSkipListSet.java @@ -309,9 +309,7 @@ public class ConcurrentSkipListSet Collection c = (Collection) o; try { return containsAll(c) && c.containsAll(this); - } catch (ClassCastException unused) { - return false; - } catch (NullPointerException unused) { + } catch (ClassCastException | NullPointerException unused) { return false; } } diff --git a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java index ad66f47e277..fb6a4e9b832 100644 --- a/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java +++ b/src/java.base/share/classes/java/util/concurrent/CopyOnWriteArrayList.java @@ -508,7 +508,7 @@ public class CopyOnWriteArrayList public boolean remove(Object o) { Object[] snapshot = getArray(); int index = indexOf(o, snapshot, 0, snapshot.length); - return (index < 0) ? false : remove(o, snapshot, index); + return index >= 0 && remove(o, snapshot, index); } /** @@ -587,8 +587,8 @@ public class CopyOnWriteArrayList */ public boolean addIfAbsent(E e) { Object[] snapshot = getArray(); - return indexOf(e, snapshot, 0, snapshot.length) >= 0 ? false : - addIfAbsent(e, snapshot); + return indexOf(e, snapshot, 0, snapshot.length) < 0 + && addIfAbsent(e, snapshot); } /** @@ -980,13 +980,10 @@ public class CopyOnWriteArrayList List list = (List)o; Iterator it = list.iterator(); - Object[] elements = getArray(); - for (int i = 0, len = elements.length; i < len; i++) - if (!it.hasNext() || !Objects.equals(elements[i], it.next())) + for (Object element : getArray()) + if (!it.hasNext() || !Objects.equals(element, it.next())) return false; - if (it.hasNext()) - return false; - return true; + return !it.hasNext(); } /** diff --git a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java index 82c522690ec..9bac335693c 100644 --- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java +++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingDeque.java @@ -1353,17 +1353,16 @@ public class LinkedBlockingDeque @SuppressWarnings("unchecked") private boolean bulkRemove(Predicate filter) { boolean removed = false; - Node p = null; final ReentrantLock lock = this.lock; + Node p = null; Node[] nodes = null; int n, len = 0; do { // 1. Extract batch of up to 64 elements while holding the lock. - long deathRow = 0; // "bitset" of size 64 lock.lock(); try { - if (nodes == null) { - if (p == null) p = first; + if (nodes == null) { // first batch; initialize + p = first; for (Node q = p; q != null; q = succ(q)) if (q.item != null && ++len == 64) break; @@ -1376,6 +1375,7 @@ public class LinkedBlockingDeque } // 2. Run the filter on the elements while lock is free. + long deathRow = 0L; // "bitset" of size 64 for (int i = 0; i < n; i++) { final E e; if ((e = nodes[i].item) != null && filter.test(e)) @@ -1393,6 +1393,7 @@ public class LinkedBlockingDeque unlink(q); removed = true; } + nodes[i] = null; // help GC } } finally { lock.unlock(); diff --git a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java index 368f6014dfa..0786eefdb41 100644 --- a/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/LinkedBlockingQueue.java @@ -1060,11 +1060,10 @@ public class LinkedBlockingQueue extends AbstractQueue int n, len = 0; do { // 1. Extract batch of up to 64 elements while holding the lock. - long deathRow = 0; // "bitset" of size 64 fullyLock(); try { - if (nodes == null) { - if (p == null) p = head.next; + if (nodes == null) { // first batch; initialize + p = head.next; for (Node q = p; q != null; q = succ(q)) if (q.item != null && ++len == 64) break; @@ -1077,6 +1076,7 @@ public class LinkedBlockingQueue extends AbstractQueue } // 2. Run the filter on the elements while lock is free. + long deathRow = 0L; // "bitset" of size 64 for (int i = 0; i < n; i++) { final E e; if ((e = nodes[i].item) != null && filter.test(e)) @@ -1095,6 +1095,7 @@ public class LinkedBlockingQueue extends AbstractQueue unlink(q, ancestor); removed = true; } + nodes[i] = null; // help GC } } finally { fullyUnlock(); diff --git a/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java b/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java index e9f0120eecf..137bd872a87 100644 --- a/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/LinkedTransferQueue.java @@ -772,9 +772,8 @@ public class LinkedTransferQueue extends AbstractQueue Node first = null; restartFromHead: for (;;) { Node h = head, p = h; - for (; p != null;) { - final Object item; - if ((item = p.item) != null) { + while (p != null) { + if (p.item != null) { if (p.isData) { first = p; break; @@ -1602,8 +1601,7 @@ public class LinkedTransferQueue extends AbstractQueue // Read in elements until trailing null sentinel found Node h = null, t = null; for (Object item; (item = s.readObject()) != null; ) { - @SuppressWarnings("unchecked") - Node newNode = new Node((E) item); + Node newNode = new Node(item); if (h == null) h = t = newNode; else diff --git a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java index 8b0b3fec285..ae2927c96f9 100644 --- a/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java +++ b/src/java.base/share/classes/java/util/concurrent/PriorityBlockingQueue.java @@ -269,8 +269,8 @@ public class PriorityBlockingQueue extends AbstractQueue if (a.getClass() != Object[].class) a = Arrays.copyOf(a, n, Object[].class); if (screen && (n == 1 || this.comparator != null)) { - for (int i = 0; i < n; ++i) - if (a[i] == null) + for (Object elt : a) + if (elt == null) throw new NullPointerException(); } this.queue = a; diff --git a/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java b/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java index 713c3fbd395..8fd33c69d32 100644 --- a/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java +++ b/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java @@ -753,8 +753,10 @@ public class SubmissionPublisher implements Publisher, else pred.next = next; } - else + else { subs.add(b.subscriber); + pred = b; + } } } return subs; diff --git a/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java b/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java index 371ac7d9d33..c20d2b3488f 100644 --- a/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java +++ b/src/java.base/share/classes/java/util/concurrent/ThreadLocalRandom.java @@ -67,7 +67,7 @@ import jdk.internal.misc.VM; * {@code ThreadLocalRandom.current().nextX(...)} (where * {@code X} is {@code Int}, {@code Long}, etc). * When all usages are of this form, it is never possible to - * accidently share a {@code ThreadLocalRandom} across multiple threads. + * accidentally share a {@code ThreadLocalRandom} across multiple threads. * *

      This class also provides additional commonly used bounded random * generation methods. diff --git a/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java b/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java index e4f05649b24..c502e783537 100644 --- a/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java +++ b/src/java.base/share/classes/java/util/concurrent/ThreadPoolExecutor.java @@ -264,13 +264,12 @@ import java.util.concurrent.locks.ReentrantLock; * assist in storage reclamation when large numbers of queued tasks * become cancelled. * - *

      Finalization
      + *
      Reclamation
      * *
      A pool that is no longer referenced in a program AND - * has no remaining threads will be {@code shutdown} automatically. If - * you would like to ensure that unreferenced pools are reclaimed even - * if users forget to call {@link #shutdown}, then you must arrange - * that unused threads eventually die, by setting appropriate + * has no remaining threads may be reclaimed (garbage collected) + * without being explicity shutdown. You can configure a pool to allow + * all unused threads to eventually die by setting appropriate * keep-alive times, using a lower bound of zero core threads and/or * setting {@link #allowCoreThreadTimeOut(boolean)}.
      * @@ -361,7 +360,7 @@ public class ThreadPoolExecutor extends AbstractExecutorService { * time, but need not hit each state. The transitions are: * * RUNNING -> SHUTDOWN - * On invocation of shutdown(), perhaps implicitly in finalize() + * On invocation of shutdown() * (RUNNING or SHUTDOWN) -> STOP * On invocation of shutdownNow() * SHUTDOWN -> TIDYING @@ -581,9 +580,6 @@ public class ThreadPoolExecutor extends AbstractExecutorService { private static final RuntimePermission shutdownPerm = new RuntimePermission("modifyThread"); - /** The context to be used when executing the finalizer, or null. */ - private final AccessControlContext acc; - /** * Class Worker mainly maintains interrupt control state for * threads running tasks, along with other minor bookkeeping. @@ -1300,9 +1296,6 @@ public class ThreadPoolExecutor extends AbstractExecutorService { throw new IllegalArgumentException(); if (workQueue == null || threadFactory == null || handler == null) throw new NullPointerException(); - this.acc = (System.getSecurityManager() == null) - ? null - : AccessController.getContext(); this.corePoolSize = corePoolSize; this.maximumPoolSize = maximumPoolSize; this.workQueue = workQueue; @@ -1469,33 +1462,6 @@ public class ThreadPoolExecutor extends AbstractExecutorService { } } - /** - * Invokes {@code shutdown} when this executor is no longer - * referenced and it has no threads. - * - *

      This method is invoked with privileges that are restricted by - * the security context of the caller that invokes the constructor. - * - * @deprecated The {@code finalize} method has been deprecated. - * Subclasses that override {@code finalize} in order to perform cleanup - * should be modified to use alternative cleanup mechanisms and - * to remove the overriding {@code finalize} method. - * When overriding the {@code finalize} method, its implementation must explicitly - * ensure that {@code super.finalize()} is invoked as described in {@link Object#finalize}. - * See the specification for {@link Object#finalize()} for further - * information about migration options. - */ - @Deprecated(since="9") - protected void finalize() { - SecurityManager sm = System.getSecurityManager(); - if (sm == null || acc == null) { - shutdown(); - } else { - PrivilegedAction pa = () -> { shutdown(); return null; }; - AccessController.doPrivileged(pa, acc); - } - } - /** * Sets the thread factory used to create new threads. * diff --git a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java index ea89380a1cf..e7aae9ce86f 100644 --- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java +++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java @@ -320,7 +320,9 @@ public abstract class AbstractQueuedLongSynchronizer // predNext is the apparent node to unsplice. CASes below will // fail if not, in which case, we lost race vs another cancel - // or signal, so no further action is necessary. + // or signal, so no further action is necessary, although with + // a possibility that a cancelled node may transiently remain + // reachable. Node predNext = pred.next; // Can use unconditional write instead of CAS here. @@ -912,13 +914,13 @@ public abstract class AbstractQueuedLongSynchronizer * at any time, a {@code true} return does not guarantee that any * other thread will ever acquire. * - *

      In this implementation, this operation returns in - * constant time. - * * @return {@code true} if there may be other threads waiting to acquire */ public final boolean hasQueuedThreads() { - return head != tail; + for (Node p = tail, h = head; p != h && p != null; p = p.prev) + if (p.waitStatus <= 0) + return true; + return false; } /** @@ -1067,17 +1069,21 @@ public abstract class AbstractQueuedLongSynchronizer * @since 1.7 */ public final boolean hasQueuedPredecessors() { - // The correctness of this depends on head being initialized - // before tail and on head.next being accurate if the current - // thread is first in queue. - Node t = tail; // Read fields in reverse initialization order - Node h = head; - Node s; - return h != t && - ((s = h.next) == null || s.thread != Thread.currentThread()); + Node h, s; + if ((h = head) != null) { + if ((s = h.next) == null || s.waitStatus > 0) { + s = null; // traverse in case of concurrent cancellation + for (Node p = tail; p != h && p != null; p = p.prev) { + if (p.waitStatus <= 0) + s = p; + } + } + if (s != null && s.thread != Thread.currentThread()) + return true; + } + return false; } - // Instrumentation and monitoring methods /** diff --git a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java index 347796c4f7a..ce701cf0bb4 100644 --- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java +++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java @@ -800,7 +800,9 @@ public abstract class AbstractQueuedSynchronizer // predNext is the apparent node to unsplice. CASes below will // fail if not, in which case, we lost race vs another cancel - // or signal, so no further action is necessary. + // or signal, so no further action is necessary, although with + // a possibility that a cancelled node may transiently remain + // reachable. Node predNext = pred.next; // Can use unconditional write instead of CAS here. @@ -1392,13 +1394,13 @@ public abstract class AbstractQueuedSynchronizer * at any time, a {@code true} return does not guarantee that any * other thread will ever acquire. * - *

      In this implementation, this operation returns in - * constant time. - * * @return {@code true} if there may be other threads waiting to acquire */ public final boolean hasQueuedThreads() { - return head != tail; + for (Node p = tail, h = head; p != h && p != null; p = p.prev) + if (p.waitStatus <= 0) + return true; + return false; } /** @@ -1547,17 +1549,21 @@ public abstract class AbstractQueuedSynchronizer * @since 1.7 */ public final boolean hasQueuedPredecessors() { - // The correctness of this depends on head being initialized - // before tail and on head.next being accurate if the current - // thread is first in queue. - Node t = tail; // Read fields in reverse initialization order - Node h = head; - Node s; - return h != t && - ((s = h.next) == null || s.thread != Thread.currentThread()); + Node h, s; + if ((h = head) != null) { + if ((s = h.next) == null || s.waitStatus > 0) { + s = null; // traverse in case of concurrent cancellation + for (Node p = tail; p != h && p != null; p = p.prev) { + if (p.waitStatus <= 0) + s = p; + } + } + if (s != null && s.thread != Thread.currentThread()) + return true; + } + return false; } - // Instrumentation and monitoring methods /** diff --git a/src/java.base/share/classes/java/util/regex/Pattern.java b/src/java.base/share/classes/java/util/regex/Pattern.java index 5ddf3f609ac..972697fcb0f 100644 --- a/src/java.base/share/classes/java/util/regex/Pattern.java +++ b/src/java.base/share/classes/java/util/regex/Pattern.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -953,6 +953,12 @@ public final class Pattern */ private int flags; + /** + * The temporary pattern flags used during compiling. The flags might be turn + * on and off by embedded flag. + */ + private transient int flags0; + /** * Boolean indicating this Pattern is compiled; this is necessary in order * to lazily compile deserialized Patterns. @@ -1137,7 +1143,7 @@ public final class Pattern * @return The match flags specified when this pattern was compiled */ public int flags() { - return flags; + return flags0; } /** @@ -1369,6 +1375,9 @@ public final class Pattern // Read in all fields s.defaultReadObject(); + // reset the flags + flags0 = flags; + // Initialize counts capturingGroupCount = 1; localCount = 0; @@ -1400,6 +1409,9 @@ public final class Pattern if ((flags & UNICODE_CHARACTER_CLASS) != 0) flags |= UNICODE_CASE; + // 'flags' for compiling + flags0 = flags; + // Reset group index count capturingGroupCount = 1; localCount = 0; @@ -1841,7 +1853,7 @@ loop: for(int x=0, offset=0; x Opcodes.V10) { + if (readShort(off + 6) > Opcodes.V11) { throw new IllegalArgumentException(); } // parses the constant pool diff --git a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java index 7ce9d9210c8..8b3ab18626c 100644 --- a/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java +++ b/src/java.base/share/classes/jdk/internal/org/objectweb/asm/Opcodes.java @@ -90,6 +90,7 @@ public interface Opcodes { int V1_8 = 0 << 16 | 52; int V9 = 0 << 16 | 53; int V10 = 0 << 16 | 54; + int V11 = 0 << 16 | 55; // access flags diff --git a/src/java.base/share/classes/jdk/internal/reflect/Reflection.java b/src/java.base/share/classes/jdk/internal/reflect/Reflection.java index 384b67734a3..c05273c3a07 100644 --- a/src/java.base/share/classes/jdk/internal/reflect/Reflection.java +++ b/src/java.base/share/classes/jdk/internal/reflect/Reflection.java @@ -64,14 +64,6 @@ public class Reflection { @HotSpotIntrinsicCandidate public static native Class getCallerClass(); - /** - * @deprecated This method will be removed. - * This method is a private JDK API and retained temporarily to - * simplify the implementation of sun.misc.Reflection.getCallerClass. - */ - @Deprecated(forRemoval=true) - public static native Class getCallerClass(int depth); - /** Retrieves the access flags written to the class file. For inner classes these flags may differ from those returned by Class.getModifiers(), which searches the InnerClasses diff --git a/src/java.base/share/classes/java/util/ArraysSupport.java b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java similarity index 83% rename from src/java.base/share/classes/java/util/ArraysSupport.java rename to src/java.base/share/classes/jdk/internal/util/ArraysSupport.java index 31612a7d4f8..cc051df7d31 100644 --- a/src/java.base/share/classes/java/util/ArraysSupport.java +++ b/src/java.base/share/classes/jdk/internal/util/ArraysSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2017 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package java.util; +package jdk.internal.util; import jdk.internal.HotSpotIntrinsicCandidate; import jdk.internal.misc.Unsafe; @@ -50,19 +50,19 @@ import jdk.internal.misc.Unsafe; * responsibility of the caller (direct or otherwise) to perform such checks * before calling this method. */ -class ArraysSupport { +public class ArraysSupport { static final Unsafe U = Unsafe.getUnsafe(); private static final boolean BIG_ENDIAN = U.isBigEndian(); - private static final int LOG2_ARRAY_BOOLEAN_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE); - private static final int LOG2_ARRAY_BYTE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BYTE_INDEX_SCALE); - private static final int LOG2_ARRAY_CHAR_INDEX_SCALE = exactLog2(Unsafe.ARRAY_CHAR_INDEX_SCALE); - private static final int LOG2_ARRAY_SHORT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_SHORT_INDEX_SCALE); - private static final int LOG2_ARRAY_INT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_INT_INDEX_SCALE); - private static final int LOG2_ARRAY_LONG_INDEX_SCALE = exactLog2(Unsafe.ARRAY_LONG_INDEX_SCALE); - private static final int LOG2_ARRAY_FLOAT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_FLOAT_INDEX_SCALE); - private static final int LOG2_ARRAY_DOUBLE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_DOUBLE_INDEX_SCALE); + public static final int LOG2_ARRAY_BOOLEAN_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BOOLEAN_INDEX_SCALE); + public static final int LOG2_ARRAY_BYTE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_BYTE_INDEX_SCALE); + public static final int LOG2_ARRAY_CHAR_INDEX_SCALE = exactLog2(Unsafe.ARRAY_CHAR_INDEX_SCALE); + public static final int LOG2_ARRAY_SHORT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_SHORT_INDEX_SCALE); + public static final int LOG2_ARRAY_INT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_INT_INDEX_SCALE); + public static final int LOG2_ARRAY_LONG_INDEX_SCALE = exactLog2(Unsafe.ARRAY_LONG_INDEX_SCALE); + public static final int LOG2_ARRAY_FLOAT_INDEX_SCALE = exactLog2(Unsafe.ARRAY_FLOAT_INDEX_SCALE); + public static final int LOG2_ARRAY_DOUBLE_INDEX_SCALE = exactLog2(Unsafe.ARRAY_DOUBLE_INDEX_SCALE); private static final int LOG2_BYTE_BIT_SIZE = exactLog2(Byte.SIZE); @@ -107,10 +107,10 @@ class ArraysSupport { * the tail of the two arrays. */ @HotSpotIntrinsicCandidate - static int vectorizedMismatch(Object a, long aOffset, - Object b, long bOffset, - int length, - int log2ArrayIndexScale) { + public static int vectorizedMismatch(Object a, long aOffset, + Object b, long bOffset, + int length, + int log2ArrayIndexScale) { // assert a.getClass().isArray(); // assert b.getClass().isArray(); // assert 0 <= length <= sizeOf(a) @@ -161,9 +161,9 @@ class ArraysSupport { // Booleans // Each boolean element takes up one byte - static int mismatch(boolean[] a, - boolean[] b, - int length) { + public static int mismatch(boolean[] a, + boolean[] b, + int length) { int i = 0; if (length > 7) { i = vectorizedMismatch( @@ -181,9 +181,9 @@ class ArraysSupport { return -1; } - static int mismatch(boolean[] a, int aFromIndex, - boolean[] b, int bFromIndex, - int length) { + public static int mismatch(boolean[] a, int aFromIndex, + boolean[] b, int bFromIndex, + int length) { int i = 0; if (length > 7) { int aOffset = Unsafe.ARRAY_BOOLEAN_BASE_OFFSET + aFromIndex; @@ -219,9 +219,9 @@ class ArraysSupport { * no mismatch. The index will be within the range of (inclusive) 0 to * (exclusive) the smaller of the two array lengths. */ - static int mismatch(byte[] a, - byte[] b, - int length) { + public static int mismatch(byte[] a, + byte[] b, + int length) { // ISSUE: defer to index receiving methods if performance is good // assert length <= a.length // assert length <= b.length @@ -264,9 +264,9 @@ class ArraysSupport { * otherwise -1 if no mismatch. The index will be within the range of * (inclusive) 0 to (exclusive) the smaller of the two array bounds. */ - static int mismatch(byte[] a, int aFromIndex, - byte[] b, int bFromIndex, - int length) { + public static int mismatch(byte[] a, int aFromIndex, + byte[] b, int bFromIndex, + int length) { // assert 0 <= aFromIndex < a.length // assert 0 <= aFromIndex + length <= a.length // assert 0 <= bFromIndex < b.length @@ -295,9 +295,9 @@ class ArraysSupport { // Chars - static int mismatch(char[] a, - char[] b, - int length) { + public static int mismatch(char[] a, + char[] b, + int length) { int i = 0; if (length > 3) { i = vectorizedMismatch( @@ -315,9 +315,9 @@ class ArraysSupport { return -1; } - static int mismatch(char[] a, int aFromIndex, - char[] b, int bFromIndex, - int length) { + public static int mismatch(char[] a, int aFromIndex, + char[] b, int bFromIndex, + int length) { int i = 0; if (length > 3) { int aOffset = Unsafe.ARRAY_CHAR_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_CHAR_INDEX_SCALE); @@ -340,9 +340,9 @@ class ArraysSupport { // Shorts - static int mismatch(short[] a, - short[] b, - int length) { + public static int mismatch(short[] a, + short[] b, + int length) { int i = 0; if (length > 3) { i = vectorizedMismatch( @@ -360,9 +360,9 @@ class ArraysSupport { return -1; } - static int mismatch(short[] a, int aFromIndex, - short[] b, int bFromIndex, - int length) { + public static int mismatch(short[] a, int aFromIndex, + short[] b, int bFromIndex, + int length) { int i = 0; if (length > 3) { int aOffset = Unsafe.ARRAY_SHORT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_SHORT_INDEX_SCALE); @@ -385,9 +385,9 @@ class ArraysSupport { // Ints - static int mismatch(int[] a, - int[] b, - int length) { + public static int mismatch(int[] a, + int[] b, + int length) { int i = 0; if (length > 1) { i = vectorizedMismatch( @@ -405,9 +405,9 @@ class ArraysSupport { return -1; } - static int mismatch(int[] a, int aFromIndex, - int[] b, int bFromIndex, - int length) { + public static int mismatch(int[] a, int aFromIndex, + int[] b, int bFromIndex, + int length) { int i = 0; if (length > 1) { int aOffset = Unsafe.ARRAY_INT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_INT_INDEX_SCALE); @@ -430,15 +430,15 @@ class ArraysSupport { // Floats - static int mismatch(float[] a, - float[] b, - int length) { + public static int mismatch(float[] a, + float[] b, + int length) { return mismatch(a, 0, b, 0, length); } - static int mismatch(float[] a, int aFromIndex, - float[] b, int bFromIndex, - int length) { + public static int mismatch(float[] a, int aFromIndex, + float[] b, int bFromIndex, + int length) { int i = 0; if (length > 1) { int aOffset = Unsafe.ARRAY_FLOAT_BASE_OFFSET + (aFromIndex << LOG2_ARRAY_FLOAT_INDEX_SCALE); @@ -475,9 +475,9 @@ class ArraysSupport { // Long - static int mismatch(long[] a, - long[] b, - int length) { + public static int mismatch(long[] a, + long[] b, + int length) { if (length == 0) { return -1; } @@ -488,9 +488,9 @@ class ArraysSupport { return i >= 0 ? i : -1; } - static int mismatch(long[] a, int aFromIndex, - long[] b, int bFromIndex, - int length) { + public static int mismatch(long[] a, int aFromIndex, + long[] b, int bFromIndex, + int length) { if (length == 0) { return -1; } @@ -506,15 +506,15 @@ class ArraysSupport { // Double - static int mismatch(double[] a, - double[] b, - int length) { + public static int mismatch(double[] a, + double[] b, + int length) { return mismatch(a, 0, b, 0, length); } - static int mismatch(double[] a, int aFromIndex, - double[] b, int bFromIndex, - int length) { + public static int mismatch(double[] a, int aFromIndex, + double[] b, int bFromIndex, + int length) { if (length == 0) { return -1; } diff --git a/src/java.base/share/classes/module-info.java b/src/java.base/share/classes/module-info.java index 7e06bf0b8ac..3b1f998b4b1 100644 --- a/src/java.base/share/classes/module-info.java +++ b/src/java.base/share/classes/module-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -142,7 +142,7 @@ module java.base { java.instrument, java.logging; exports jdk.internal.jmod to - jdk.compiler, // reflective dependency + jdk.compiler, jdk.jlink; exports jdk.internal.logger to java.logging; @@ -172,7 +172,7 @@ module java.base { java.xml, jdk.attach, jdk.charsets, - jdk.compiler, // reflective dependency + jdk.compiler, jdk.incubator.httpclient, jdk.jdeps, jdk.jlink, diff --git a/src/java.base/share/classes/sun/nio/cs/DoubleByte.java b/src/java.base/share/classes/sun/nio/cs/DoubleByte.java index 9f8d97fdb39..e31c0264d28 100644 --- a/src/java.base/share/classes/sun/nio/cs/DoubleByte.java +++ b/src/java.base/share/classes/sun/nio/cs/DoubleByte.java @@ -236,10 +236,8 @@ public class DoubleByte { int b2 = src[sp++] & 0xff; if (b2 < b2Min || b2 > b2Max || (c = b2c[b1][b2 - b2Min]) == UNMAPPABLE_DECODING) { - if (b2c[b1] == B2C_UNMAPPABLE || // isNotLeadingByte - b2c[b2] != B2C_UNMAPPABLE || // isLeadingByte - decodeSingle(b2) != UNMAPPABLE_DECODING) { - sp--; + if (crMalformedOrUnmappable(b1, b2).length() == 1) { + sp--; } } } @@ -472,6 +470,13 @@ public class DoubleByte { b2cSB_UNMAPPABLE = new char[0x100]; Arrays.fill(b2cSB_UNMAPPABLE, UNMAPPABLE_DECODING); } + + // always returns unmappableForLenth(2) for doublebyte_only + @Override + protected CoderResult crMalformedOrUnmappable(int b1, int b2) { + return CoderResult.unmappableForLength(2); + } + public Decoder_DBCSONLY(Charset cs, char[][] b2c, char[] b2cSB, int b2Min, int b2Max, boolean isASCIICompatible) { super(cs, 0.5f, 1.0f, b2c, b2cSB_UNMAPPABLE, b2Min, b2Max, isASCIICompatible); diff --git a/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/src/java.base/share/classes/sun/security/tools/keytool/Main.java index b927bf29689..4413458d408 100644 --- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java +++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -523,9 +523,11 @@ public final class Main { if (c != null) { command = c; - } else if (collator.compare(flags, "-help") == 0 || - collator.compare(flags, "-h") == 0 || - collator.compare(flags, "-?") == 0) { + } else if (collator.compare(flags, "--help") == 0 || + collator.compare(flags, "-h") == 0 || + collator.compare(flags, "-?") == 0 || + // -help: legacy. + collator.compare(flags, "-help") == 0) { help = true; } else if (collator.compare(flags, "-conf") == 0) { i++; @@ -4608,6 +4610,8 @@ public final class Main { System.err.printf(" %-20s%s\n", c, rb.getString(c.description)); } System.err.println(); + System.err.println(rb.getString( + "Use.keytool.help.for.all.available.commands")); System.err.println(rb.getString( "Use.keytool.command.name.help.for.usage.of.command.name")); } diff --git a/src/java.base/share/classes/sun/security/tools/keytool/Resources.java b/src/java.base/share/classes/sun/security/tools/keytool/Resources.java index 485129086c7..699a086c7ea 100644 --- a/src/java.base/share/classes/sun/security/tools/keytool/Resources.java +++ b/src/java.base/share/classes/sun/security/tools/keytool/Resources.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,12 +45,12 @@ public class Resources extends java.util.ListResourceBundle { {"option.1.set.twice", "The %s option is specified multiple times. All except the last one will be ignored."}, {"multiple.commands.1.2", "Only one command is allowed: both %1$s and %2$s were specified."}, {"Use.keytool.help.for.all.available.commands", - "Use \"keytool -help\" for all available commands"}, + "Use \"keytool -?, -h, or --help\" for this help message"}, {"Key.and.Certificate.Management.Tool", "Key and Certificate Management Tool"}, {"Commands.", "Commands:"}, {"Use.keytool.command.name.help.for.usage.of.command.name", - "Use \"keytool -command_name -help\" for usage of command_name.\n" + + "Use \"keytool -command_name --help\" for usage of command_name.\n" + "Use the -conf option to specify a pre-configured options file."}, // keytool: help: commands {"Generates.a.certificate.request", @@ -462,7 +462,7 @@ public class Resources extends java.util.ListResourceBundle { {"with.weak", "%s (weak)"}, {"key.bit", "%1$d-bit %2$s key"}, {"key.bit.weak", "%1$d-bit %2$s key (weak)"}, - {"unknown.size.1", "unknown size %s key"}, + {"unknown.size.1", "%s key of unknown size"}, {".PATTERN.printX509Cert.with.weak", "Owner: {0}\nIssuer: {1}\nSerial number: {2}\nValid from: {3} until: {4}\nCertificate fingerprints:\n\t SHA1: {5}\n\t SHA256: {6}\nSignature algorithm name: {7}\nSubject Public Key Algorithm: {8}\nVersion: {9}"}, {"PKCS.10.with.weak", diff --git a/src/java.base/share/conf/security/java.security b/src/java.base/share/conf/security/java.security index 851651465e0..b7766158830 100644 --- a/src/java.base/share/conf/security/java.security +++ b/src/java.base/share/conf/security/java.security @@ -812,14 +812,14 @@ jdk.tls.legacyAlgorithms= \ # limited: These policy files contain more restricted cryptographic # strengths # -# The default setting is determined by the value of the “crypto.policy†+# The default setting is determined by the value of the "crypto.policy" # Security property below. If your country or usage requires the -# traditional restrictive policy, the “limited†Java cryptographic +# traditional restrictive policy, the "limited" Java cryptographic # policy is still available and may be appropriate for your environment. # # If you have restrictions that do not fit either use case mentioned # above, Java provides the capability to customize these policy files. -# The “crypto.policy†security property points to a subdirectory +# The "crypto.policy" security property points to a subdirectory # within /conf/security/policy/ which can be customized. # Please see the /conf/security/policy/README.txt file or consult # the Java Security Guide/JCA documentation for more information. diff --git a/src/java.base/share/conf/security/policy/README.txt b/src/java.base/share/conf/security/policy/README.txt index e9138e79a4b..fdf77d3e3a4 100644 --- a/src/java.base/share/conf/security/policy/README.txt +++ b/src/java.base/share/conf/security/policy/README.txt @@ -8,7 +8,7 @@ Import and export control rules on cryptographic software vary from country to country. The Java Cryptography Extension (JCE) architecture allows flexible cryptographic key strength to be configured via the -jurisdiction policy files which are referenced by the “crypto.policy†+jurisdiction policy files which are referenced by the "crypto.policy" security property in the /conf/security/java.security file. By default, Java provides two different sets of cryptographic policy @@ -20,8 +20,8 @@ files: limited: These policy files contain more restricted cryptographic strengths -These files reside in /conf/security/policy in the “unlimited†-or “limited†subdirectories respectively. +These files reside in /conf/security/policy in the "unlimited" +or "limited" subdirectories respectively. Each subdirectory contains a complete policy configuration, and subdirectories can be added/edited/removed to reflect your diff --git a/src/java.base/share/native/include/classfile_constants.h b/src/java.base/share/native/include/classfile_constants.h.template similarity index 99% rename from src/java.base/share/native/include/classfile_constants.h rename to src/java.base/share/native/include/classfile_constants.h.template index 3b63f31c6e8..1046b54b37a 100644 --- a/src/java.base/share/native/include/classfile_constants.h +++ b/src/java.base/share/native/include/classfile_constants.h.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 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,8 +31,8 @@ extern "C" { #endif /* Classfile version number for this information */ -#define JVM_CLASSFILE_MAJOR_VERSION 54 -#define JVM_CLASSFILE_MINOR_VERSION 0 +#define JVM_CLASSFILE_MAJOR_VERSION @@VERSION_CLASSFILE_MAJOR@@ +#define JVM_CLASSFILE_MINOR_VERSION @@VERSION_CLASSFILE_MINOR@@ /* Flags */ diff --git a/src/java.base/share/native/libjava/Reflection.c b/src/java.base/share/native/libjava/Reflection.c index 0a5327eb1fa..b634726c500 100644 --- a/src/java.base/share/native/libjava/Reflection.c +++ b/src/java.base/share/native/libjava/Reflection.c @@ -30,13 +30,7 @@ JNIEXPORT jclass JNICALL Java_jdk_internal_reflect_Reflection_getCallerClass__(JNIEnv *env, jclass unused) { - return JVM_GetCallerClass(env, JVM_CALLER_DEPTH); -} - -JNIEXPORT jclass JNICALL -Java_jdk_internal_reflect_Reflection_getCallerClass__I(JNIEnv *env, jclass unused, jint depth) -{ - return JVM_GetCallerClass(env, depth); + return JVM_GetCallerClass(env); } JNIEXPORT jint JNICALL diff --git a/src/java.base/share/native/libjava/System.c b/src/java.base/share/native/libjava/System.c index 8dfe41fcb45..06fe6319344 100644 --- a/src/java.base/share/native/libjava/System.c +++ b/src/java.base/share/native/libjava/System.c @@ -119,9 +119,6 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x) #define VENDOR_URL_BUG "http://bugreport.java.com/bugreport/" #endif -#define JAVA_MAX_SUPPORTED_VERSION 54 -#define JAVA_MAX_SUPPORTED_MINOR_VERSION 0 - #ifdef JAVA_SPECIFICATION_VENDOR /* Third party may NOT overwrite this. */ #error "ERROR: No override of JAVA_SPECIFICATION_VENDOR is allowed" #else @@ -227,8 +224,8 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props) PUTPROP(props, "java.vendor.url", VENDOR_URL); PUTPROP(props, "java.vendor.url.bug", VENDOR_URL_BUG); - jio_snprintf(buf, sizeof(buf), "%d.%d", JAVA_MAX_SUPPORTED_VERSION, - JAVA_MAX_SUPPORTED_MINOR_VERSION); + jio_snprintf(buf, sizeof(buf), "%d.%d", JVM_CLASSFILE_MAJOR_VERSION, + JVM_CLASSFILE_MINOR_VERSION); PUTPROP(props, "java.class.version", buf); if (sprops->awt_toolkit) { diff --git a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java index 6ab21d602da..b5f2a6f9a5a 100644 --- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java +++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java @@ -57,6 +57,7 @@ public enum SourceVersion { * 1.8: lambda expressions and default methods * 9: modules, small cleanups to 1.7 and 1.8 changes * 10: local-variable type inference (var) + * 11: to be determined changes */ /** @@ -162,7 +163,15 @@ public enum SourceVersion { * * @since 10 */ - RELEASE_10; + RELEASE_10, + + /** + * The version recognized by the Java Platform, Standard Edition + * 11. + * + * @since 11 + */ + RELEASE_11; // Note that when adding constants for newer releases, the // behavior of latest() and latestSupported() must be updated too. @@ -173,7 +182,7 @@ public enum SourceVersion { * @return the latest source version that can be modeled */ public static SourceVersion latest() { - return RELEASE_10; + return RELEASE_11; } private static final SourceVersion latestSupported = getLatestSupported(); @@ -183,6 +192,8 @@ public enum SourceVersion { String specVersion = System.getProperty("java.specification.version"); switch (specVersion) { + case "11": + return RELEASE_11; case "10": return RELEASE_10; case "9": diff --git a/src/java.compiler/share/classes/javax/tools/FileManagerUtils.java b/src/java.compiler/share/classes/javax/tools/FileManagerUtils.java deleted file mode 100644 index 1fe7783f638..00000000000 --- a/src/java.compiler/share/classes/javax/tools/FileManagerUtils.java +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package javax.tools; - -import java.io.File; -import java.nio.file.Path; -import java.util.Iterator; - -/** - * Package-private utility methods to convert between files and paths. - * - * @since 9 - */ -class FileManagerUtils { - private FileManagerUtils() { } - - static Iterable asPaths(final Iterable files) { - return () -> new Iterator() { - Iterator iter = files.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public Path next() { - return iter.next().toPath(); - } - }; - } - - static Iterable asFiles(final Iterable paths) { - return () -> new Iterator() { - Iterator iter = paths.iterator(); - - @Override - public boolean hasNext() { - return iter.hasNext(); - } - - @Override - public File next() { - Path p = iter.next(); - try { - return p.toFile(); - } catch (UnsupportedOperationException e) { - throw new IllegalArgumentException(p.toString(), e); - } - } - }; - } -} diff --git a/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java b/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java index aeb17169c56..1e9612f62f1 100644 --- a/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java +++ b/src/java.compiler/share/classes/javax/tools/StandardJavaFileManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,8 +30,7 @@ import java.io.IOException; import java.nio.file.Path; import java.util.Arrays; import java.util.Collection; - -import static javax.tools.FileManagerUtils.*; +import java.util.Iterator; /** * File manager based on {@linkplain File java.io.File} and {@linkplain Path java.nio.file.Path}. @@ -447,4 +446,42 @@ public interface StandardJavaFileManager extends JavaFileManager { * @since 9 */ default void setPathFactory(PathFactory f) { } + + + private static Iterable asPaths(final Iterable files) { + return () -> new Iterator() { + Iterator iter = files.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public Path next() { + return iter.next().toPath(); + } + }; + } + + private static Iterable asFiles(final Iterable paths) { + return () -> new Iterator() { + Iterator iter = paths.iterator(); + + @Override + public boolean hasNext() { + return iter.hasNext(); + } + + @Override + public File next() { + Path p = iter.next(); + try { + return p.toFile(); + } catch (UnsupportedOperationException e) { + throw new IllegalArgumentException(p.toString(), e); + } + } + }; + } } diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m index 03829b3dc1a..ba0c44c8167 100644 --- a/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m +++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/AWTWindow.m @@ -954,11 +954,6 @@ AWT_ASSERT_APPKIT_THREAD; return lastKeyWindow; } -- (BOOL)windowShouldZoom:(NSWindow *)window toFrame:(NSRect)newFrame { - return !NSEqualSizes(self.nsWindow.frame.size, newFrame.size); -} - - @end // AWTWindow diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java index e744095d2f7..a04926083cf 100644 --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/jpeg/JPEGImageReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -374,7 +374,10 @@ public class JPEGImageReader extends ImageReader { // And set current image since we've read it now currentImage = 0; } - if (seekForwardOnly) { + // If the image positions list is empty as in the case of a tables-only + // stream, then attempting to access the element at index + // imagePositions.size() - 1 will cause an IndexOutOfBoundsException. + if (seekForwardOnly && !imagePositions.isEmpty()) { Long pos = imagePositions.get(imagePositions.size()-1); iis.flushBefore(pos.longValue()); } @@ -492,6 +495,11 @@ public class JPEGImageReader extends ImageReader { if (!tablesOnlyChecked) { checkTablesOnly(); } + // If the image positions list is empty as in the case of a tables-only + // stream, then no image data can be read. + if (imagePositions.isEmpty()) { + throw new IIOException("No image data present to read"); + } if (imageIndex < imagePositions.size()) { iis.seek(imagePositions.get(imageIndex).longValue()); } else { diff --git a/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java b/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java index 7a43480a23c..c1622664bc0 100644 --- a/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java +++ b/src/java.desktop/share/classes/com/sun/imageio/plugins/png/PNGImageReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -738,6 +738,17 @@ public class PNGImageReader extends ImageReader { case IDAT_TYPE: // If chunk type is 'IDAT', we've reached the image data. if (imageStartPosition == -1L) { + /* + * The PNG specification mandates that if colorType is + * PNG_COLOR_PALETTE then the PLTE chunk should appear + * before the first IDAT chunk. + */ + if (colorType == PNG_COLOR_PALETTE && + !(metadata.PLTE_present)) + { + throw new IIOException("Required PLTE chunk" + + " missing"); + } /* * PNGs may contain multiple IDAT chunks containing * a portion of image data. We store the position of @@ -986,7 +997,9 @@ public class PNGImageReader extends ImageReader { } int inputBands = inputBandsForColorType[metadata.IHDR_colorType]; - int bytesPerRow = (inputBands*passWidth*metadata.IHDR_bitDepth + 7)/8; + int bitsPerRow = Math. + multiplyExact((inputBands * metadata.IHDR_bitDepth), passWidth); + int bytesPerRow = (bitsPerRow + 7) / 8; // Read the image row-by-row for (int srcY = 0; srcY < passHeight; srcY++) { @@ -1037,7 +1050,8 @@ public class PNGImageReader extends ImageReader { int bytesPerPixel = (bitDepth == 16) ? 2 : 1; bytesPerPixel *= inputBands; - int bytesPerRow = (inputBands*passWidth*bitDepth + 7)/8; + int bitsPerRow = Math.multiplyExact((inputBands * bitDepth), passWidth); + int bytesPerRow = (bitsPerRow + 7) / 8; int eltsPerRow = (bitDepth == 16) ? bytesPerRow/2 : bytesPerRow; // If no pixels need updating, just skip the input data diff --git a/src/java.desktop/share/classes/java/awt/Toolkit.java b/src/java.desktop/share/classes/java/awt/Toolkit.java index 8a36c2977b1..7a4372ace66 100644 --- a/src/java.desktop/share/classes/java/awt/Toolkit.java +++ b/src/java.desktop/share/classes/java/awt/Toolkit.java @@ -678,6 +678,11 @@ public abstract class Toolkit { * If the connection to the specified URL requires * either {@code URLPermission} or {@code SocketPermission}, * then {@code URLPermission} is used for security checks. + * For compatibility with pre-1.2 security managers, if the access + * is denied with {@code FilePermission} or {@code SocketPermission}, + * the method throws the {@code SecurityException} + * if the corresponding 1.1-style SecurityManager.checkXXX method + * also denies permission. * @param url the URL to use in fetching the pixel data. * @return an image which gets its pixel data from * the specified URL. @@ -719,6 +724,11 @@ public abstract class Toolkit { * If the connection to the specified URL requires * either {@code URLPermission} or {@code SocketPermission}, * then {@code URLPermission} is used for security checks. + * For compatibility with pre-1.2 security managers, if the access + * is denied with {@code FilePermission} or {@code SocketPermission}, + * the method throws {@code SecurityException} + * if the corresponding 1.1-style SecurityManager.checkXXX method + * also denies permission. * @param url the URL to use in fetching the pixel data. * @return an image which gets its pixel data from * the specified URL. diff --git a/src/java.desktop/share/classes/java/awt/image/BandedSampleModel.java b/src/java.desktop/share/classes/java/awt/image/BandedSampleModel.java index b09b0c0a3ee..26654bdbe92 100644 --- a/src/java.desktop/share/classes/java/awt/image/BandedSampleModel.java +++ b/src/java.desktop/share/classes/java/awt/image/BandedSampleModel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -185,7 +185,33 @@ public final class BandedSampleModel extends ComponentSampleModel public DataBuffer createDataBuffer() { DataBuffer dataBuffer = null; + // The minimum size required to store samples of one band int size = scanlineStride * height; + + if (numBanks == 1) { + /* + * The sample model contains a single bank of data buffer. Hence + * we need to compute the size required to store samples of all + * bands including the respective offsets. + */ + int sizePerBand = size; + size += bandOffsets[0]; + for (int index = 1; index < bandOffsets.length; index++) { + size += (bandOffsets[index] - size) + sizePerBand; + } + } else { + /* + * The sample model contains multiple banks of data buffer where + * each bank would correspond to a particular band. Hence we need + * to compute only the additional space required for band offsets. + */ + int maxBandOffset = bandOffsets[0]; + for (int index = 1; index < bandOffsets.length; index++) { + maxBandOffset = Math.max(maxBandOffset, bandOffsets[index]); + } + size += maxBandOffset; + } + switch (dataType) { case DataBuffer.TYPE_BYTE: dataBuffer = new DataBufferByte(size, numBanks); diff --git a/src/java.desktop/share/classes/javax/swing/tree/VariableHeightLayoutCache.java b/src/java.desktop/share/classes/javax/swing/tree/VariableHeightLayoutCache.java index fea3a16131d..b2adcc6f0d4 100644 --- a/src/java.desktop/share/classes/javax/swing/tree/VariableHeightLayoutCache.java +++ b/src/java.desktop/share/classes/javax/swing/tree/VariableHeightLayoutCache.java @@ -409,11 +409,10 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { */ public void treeNodesChanged(TreeModelEvent e) { if(e != null) { - int changedIndexs[]; - TreeStateNode changedNode; + int changedIndexs[] = e.getChildIndices(); + TreeStateNode changedNode = getNodeForPath( + SwingUtilities2.getTreePath(e, getModel()), false, false); - changedIndexs = e.getChildIndices(); - changedNode = getNodeForPath(SwingUtilities2.getTreePath(e, getModel()), false, false); if(changedNode != null) { Object changedValue = changedNode.getValue(); @@ -421,17 +420,12 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { child indexs that are passed in. */ changedNode.updatePreferredSize(); if(changedNode.hasBeenExpanded() && changedIndexs != null) { - int counter; - TreeStateNode changedChildNode; - - for(counter = 0; counter < changedIndexs.length; - counter++) { - changedChildNode = (TreeStateNode)changedNode - .getChildAt(changedIndexs[counter]); + for(int index : changedIndexs) { + TreeStateNode changedChildNode = (TreeStateNode)changedNode + .getChildAt(index); /* Reset the user object. */ changedChildNode.setUserObject - (treeModel.getChild(changedValue, - changedIndexs[counter])); + (treeModel.getChild(changedValue, index)); changedChildNode.updatePreferredSize(); } } @@ -462,34 +456,26 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { */ public void treeNodesInserted(TreeModelEvent e) { if(e != null) { - int changedIndexs[]; - TreeStateNode changedParentNode; - - changedIndexs = e.getChildIndices(); - changedParentNode = getNodeForPath(SwingUtilities2.getTreePath(e, getModel()), false, false); + int changedIndexs[] = e.getChildIndices(); + TreeStateNode changedParentNode = getNodeForPath( + SwingUtilities2.getTreePath(e, getModel()), false, false); /* Only need to update the children if the node has been expanded once. */ // PENDING(scott): make sure childIndexs is sorted! if(changedParentNode != null && changedIndexs != null && changedIndexs.length > 0) { if(changedParentNode.hasBeenExpanded()) { - boolean makeVisible; - int counter; - Object changedParent; - TreeStateNode newNode; - int oldChildCount = changedParentNode. - getChildCount(); + boolean makeVisible =((changedParentNode == root && + !rootVisible) || + (changedParentNode.getRow() != -1 && + changedParentNode.isExpanded())); + int oldChildCount = changedParentNode.getChildCount(); - changedParent = changedParentNode.getValue(); - makeVisible = ((changedParentNode == root && - !rootVisible) || - (changedParentNode.getRow() != -1 && - changedParentNode.isExpanded())); - for(counter = 0;counter < changedIndexs.length;counter++) + for(int index : changedIndexs) { - newNode = this.createNodeAt(changedParentNode, - changedIndexs[counter]); + this.createNodeAt(changedParentNode, index); } + if(oldChildCount == 0) { // Update the size of the parent. changedParentNode.updatePreferredSize(); @@ -643,7 +629,7 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { rebuild(true); } else if(changedNode != null) { - int nodeIndex, oldRow; + int nodeIndex; TreeStateNode newNode, parent; boolean wasExpanded, wasVisible; int newIndex; @@ -925,24 +911,22 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { * row index, the last row index is returned. */ private int getRowContainingYLocation(int location) { + final int rows = getRowCount(); + + if(rows <= 0) + return -1; if(isFixedRowHeight()) { - if(getRowCount() == 0) - return -1; - return Math.max(0, Math.min(getRowCount() - 1, + return Math.max(0, Math.min(rows - 1, location / getRowHeight())); } - int max, maxY, mid, min, minY; - TreeStateNode node; + int max = rows, min = 0, mid = 0; - if((max = getRowCount()) <= 0) - return -1; - mid = min = 0; while(min < max) { mid = (max - min) / 2 + min; - node = (TreeStateNode)visibleNodes.elementAt(mid); - minY = node.getYOrigin(); - maxY = minY + node.getPreferredHeight(); + TreeStateNode node = (TreeStateNode)visibleNodes.elementAt(mid); + int minY = node.getYOrigin(); + int maxY = minY + node.getPreferredHeight(); if(location < minY) { max = mid - 1; } @@ -954,8 +938,8 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { } if(min == max) { mid = min; - if(mid >= getRowCount()) - mid = getRowCount() - 1; + if(mid >= rows) + mid = rows - 1; } return mid; } @@ -1008,9 +992,9 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { if(nodeWidth > maxWidth) maxWidth = nodeWidth; } + return maxWidth; } - /** * Responsible for creating a TreeStateNode that will be used * to track display information about value. @@ -1362,17 +1346,11 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { isExpanded(), boundsBuffer); - if(bounds == null) { + if(bounds == null || bounds.height == 0) { xOrigin = 0; preferredWidth = preferredHeight = 0; updateNodeSizes = true; - } - else if(bounds.height == 0) { - xOrigin = 0; - preferredWidth = preferredHeight = 0; - updateNodeSizes = true; - } - else { + } else { xOrigin = bounds.x; preferredWidth = bounds.width; if(isFixedRowHeight()) @@ -1477,24 +1455,14 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { Object realNode = getValue(); TreeModel treeModel = getModel(); int count = treeModel.getChildCount(realNode); - + int offset = originalRow == -1 ? -1 : originalRow + 1; hasBeenExpanded = true; - if(originalRow == -1) { - for (int i = 0; i < count; i++) { - newNode = createNodeForValue(treeModel.getChild - (realNode, i)); - this.add(newNode); - newNode.updatePreferredSize(-1); - } - } - else { - int offset = originalRow + 1; - for (int i = 0; i < count; i++) { - newNode = createNodeForValue(treeModel.getChild - (realNode, i)); - this.add(newNode); - newNode.updatePreferredSize(offset); - } + + for (int i = 0; i < count; i++) { + newNode = createNodeForValue(treeModel.getChild + (realNode, i)); + this.add(newNode); + newNode.updatePreferredSize(offset); } } @@ -1502,14 +1470,9 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { Enumeration cursor = preorderEnumeration(); cursor.nextElement(); // don't add me, I'm already in - int newYOrigin; + int newYOrigin = isFixed || (this == root && !isRootVisible()) ? + 0 : getYOrigin() + this.getPreferredHeight(); - if(isFixed) - newYOrigin = 0; - else if(this == root && !isRootVisible()) - newYOrigin = 0; - else - newYOrigin = getYOrigin() + this.getPreferredHeight(); TreeStateNode aNode; if(!isFixed) { while (cursor.hasMoreElements()) { @@ -1744,14 +1707,10 @@ public class VariableHeightLayoutCache extends AbstractLayoutCache { protected boolean updateNextIndex() { // nextIndex == -1 identifies receiver, make sure is expanded // before descend. - if(nextIndex == -1 && !parent.isExpanded()) - return false; - - // Check that it can have kids - if(childCount == 0) - return false; - // Make sure next index not beyond child count. - else if(++nextIndex >= childCount) + if((nextIndex == -1 && !parent.isExpanded()) || + childCount == 0 || // Check that it can have kids + ++nextIndex >= childCount) // Make sure next index not beyond + // child count. return false; TreeStateNode child = (TreeStateNode)parent. diff --git a/src/java.desktop/unix/classes/sun/java2d/xr/XRSolidSrcPict.java b/src/java.desktop/unix/classes/sun/java2d/xr/XRSolidSrcPict.java index 03e3bdb18ec..9a7372639ba 100644 --- a/src/java.desktop/unix/classes/sun/java2d/xr/XRSolidSrcPict.java +++ b/src/java.desktop/unix/classes/sun/java2d/xr/XRSolidSrcPict.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,7 @@ public class XRSolidSrcPict { public XRSurfaceData prepareSrcPict(int pixelVal) { if(pixelVal != curPixVal) { - xrCol.setColorValues(pixelVal, false); + xrCol.setColorValues(pixelVal, true); con.renderRectangle(srcPict.picture, XRUtils.PictOpSrc, xrCol, 0, 0, 1, 1); this.curPixVal = pixelVal; } diff --git a/src/java.logging/share/classes/java/util/logging/LogManager.java b/src/java.logging/share/classes/java/util/logging/LogManager.java index e864f5ebabf..736f07694f0 100644 --- a/src/java.logging/share/classes/java/util/logging/LogManager.java +++ b/src/java.logging/share/classes/java/util/logging/LogManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -396,12 +396,6 @@ public class LogManager { // Create and retain Logger for the root of the namespace. owner.addLogger(root); - // For backward compatibility: add any handlers configured using - // ".handlers" - owner.createLoggerHandlers("", ".handlers") - .stream() - .forEach(root::addHandler); - // Initialize level if not yet initialized if (!root.isLevelInitialized()) { root.setLevel(defaultLevel); @@ -995,7 +989,8 @@ public class LogManager { } } - private List createLoggerHandlers(final String name, final String handlersPropertyName) + private List createLoggerHandlers(final String name, + final String handlersPropertyName) { String names[] = parseClassNames(handlersPropertyName); List handlers = new ArrayList<>(names.length); @@ -1198,7 +1193,7 @@ public class LogManager { } drainLoggerRefQueueBounded(); LoggerContext cx = getUserContext(); - if (cx.addLocalLogger(logger)) { + if (cx.addLocalLogger(logger) || forceLoadHandlers(logger)) { // Do we have a per logger handler too? // Note: this will add a 200ms penalty loadLoggerHandlers(logger, name, name + ".handlers"); @@ -1208,6 +1203,26 @@ public class LogManager { } } + + // Checks whether the given logger is a special logger + // that still requires handler initialization. + // This method will only return true for the root and + // global loggers and only if called by the thread that + // performs initialization of the LogManager, during that + // initialization. Must only be called by addLogger. + @SuppressWarnings("deprecation") + private boolean forceLoadHandlers(Logger logger) { + // Called just after reading the primordial configuration, in + // the same thread that reads it. + // The root and global logger would already be present in the context + // by this point, but we would not have called loadLoggerHandlers + // yet. + return (logger == rootLogger || logger == Logger.global) + && !initializationDone + && initializedCalled + && configurationLock.isHeldByCurrentThread(); + } + // Private method to set a level on a logger. // If necessary, we raise privilege before doing the call. private static void doSetLevel(final Logger logger, final Level level) { diff --git a/src/java.rmi/share/classes/sun/rmi/server/resources/rmid.properties b/src/java.rmi/share/classes/sun/rmi/server/resources/rmid.properties index e4543689d29..8d76a2a3726 100644 --- a/src/java.rmi/share/classes/sun/rmi/server/resources/rmid.properties +++ b/src/java.rmi/share/classes/sun/rmi/server/resources/rmid.properties @@ -1,6 +1,6 @@ # # -# Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ rmid.syntax.log.required=\ # {0} = the (string) illegal argument in question rmid.syntax.illegal.option=\ - illegal option: {0} + invalid option: {0} # {0} = the (string) reason text that came with a thrown exception # "Activation.main" should not be translated, because it's a codepoint diff --git a/src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java b/src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java index cc8127d2cb4..646aab4cffd 100644 --- a/src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java +++ b/src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,7 +122,11 @@ public class Main { } } continue; - } else if (arg.equals("-?") || arg.equals("-help")) { + } else if (arg.equals("-?") || + arg.equals("-h") || + arg.equals("--help") || + // -help: legacy. + arg.equals("-help")) { usage(EXIT_SUCCESS); } else if (arg.equals("-e")) { seenScript = true; diff --git a/src/java.scripting/share/classes/com/sun/tools/script/shell/messages.properties b/src/java.scripting/share/classes/com/sun/tools/script/shell/messages.properties index 4838fb098b4..2e17668b260 100644 --- a/src/java.scripting/share/classes/com/sun/tools/script/shell/messages.properties +++ b/src/java.scripting/share/classes/com/sun/tools/script/shell/messages.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -55,8 +55,7 @@ where [options] include:\n\ \ \-f

      java.class.versionJava class format version number
      java.class.pathJava class path
      Java class path (refer to + * {@link ClassLoader#getSystemClassLoader()} for details)
      java.library.pathList of paths to search when loading libraries
      java.io.tmpdir