--- a/.hgtags Thu Jun 04 18:28:52 2015 +0200
+++ b/.hgtags Mon Jun 22 13:28:57 2015 -0700
@@ -311,3 +311,4 @@
ff3fc75f3214ad7e03595be1b0d0f38d887b6f0e jdk9-b66
56166ce66037952fa21e9f680b31bf8eb47312c0 jdk9-b67
5b500c93ce4822d47061cd518ff3f72d9d8cb5b5 jdk9-b68
+d69c968463f0ae5d0b45de3fc14fe65171b23948 jdk9-b69
--- a/.hgtags-top-repo Thu Jun 04 18:28:52 2015 +0200
+++ b/.hgtags-top-repo Mon Jun 22 13:28:57 2015 -0700
@@ -311,3 +311,4 @@
dc6e8336f51bb6b67b7245766179eab5ca7720b4 jdk9-b66
f546760134eb861fcfecd4ce611b0040b0d25a6a jdk9-b67
70e4272790b6199e9ca89df2758ff9cb58ec4125 jdk9-b68
+1bcfd6b8726582cff5a42dbfc75903e36f9dd4fe jdk9-b69
--- a/common/autoconf/basics.m4 Thu Jun 04 18:28:52 2015 +0200
+++ b/common/autoconf/basics.m4 Mon Jun 22 13:28:57 2015 -0700
@@ -436,7 +436,6 @@
BASIC_PATH_PROGS(CYGPATH, cygpath)
BASIC_PATH_PROGS(READLINK, [greadlink readlink])
BASIC_PATH_PROGS(DF, df)
- BASIC_PATH_PROGS(SETFILE, SetFile)
BASIC_PATH_PROGS(CPIO, [cpio bsdcpio])
])
@@ -574,10 +573,11 @@
)
if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then
- # detect if Xcode is installed by running xcodebuild -version
+ # If a devkit has been supplied, find xcodebuild in the toolchain_path.
+ # If not, detect if Xcode is installed by running xcodebuild -version
# if no Xcode installed, xcodebuild exits with 1
# if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0
- if /usr/bin/xcodebuild -version >/dev/null 2>&1; then
+ if test "x$DEVKIT_ROOT" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then
# We need to use xcodebuild in the toolchain dir provided by the user, this will
# fall back on the stub binary in /usr/bin/xcodebuild
AC_PATH_PROG([XCODEBUILD], [xcodebuild], [/usr/bin/xcodebuild], [$TOOLCHAIN_PATH])
@@ -961,6 +961,7 @@
AC_MSG_RESULT([yes])
fi
fi
+ BASIC_REQUIRE_PROGS(SETFILE, SetFile)
fi
])
--- a/common/autoconf/build-aux/config.guess Thu Jun 04 18:28:52 2015 +0200
+++ b/common/autoconf/build-aux/config.guess Mon Jun 22 13:28:57 2015 -0700
@@ -86,4 +86,11 @@
fi
fi
+# Test and fix cpu on Macosx when C preprocessor is not on the path
+echo $OUT | grep i386-apple-darwin > /dev/null 2> /dev/null
+if test $? = 0; then
+ REAL_CPU=`uname -m`
+ OUT=$REAL_CPU`echo $OUT | sed -e 's/[^-]*//'`
+fi
+
echo $OUT
--- a/common/autoconf/generated-configure.sh Thu Jun 04 18:28:52 2015 +0200
+++ b/common/autoconf/generated-configure.sh Mon Jun 22 13:28:57 2015 -0700
@@ -855,6 +855,7 @@
OS_VERSION_MAJOR
PKG_CONFIG
BASH_ARGS
+SETFILE
CODESIGN
XATTR
DSYMUTIL
@@ -946,7 +947,6 @@
build_cpu
build
CPIO
-SETFILE
DF
READLINK
CYGPATH
@@ -1167,7 +1167,6 @@
CYGPATH
READLINK
DF
-SETFILE
CPIO
UNZIP
ZIP
@@ -1180,6 +1179,7 @@
DSYMUTIL
XATTR
CODESIGN
+SETFILE
PKG_CONFIG
JAVA
JAVAC
@@ -2049,7 +2049,6 @@
CYGPATH Override default value for CYGPATH
READLINK Override default value for READLINK
DF Override default value for DF
- SETFILE Override default value for SETFILE
CPIO Override default value for CPIO
UNZIP Override default value for UNZIP
ZIP Override default value for ZIP
@@ -2062,6 +2061,7 @@
DSYMUTIL Override default value for DSYMUTIL
XATTR Override default value for XATTR
CODESIGN Override default value for CODESIGN
+ SETFILE Override default value for SETFILE
PKG_CONFIG path to pkg-config utility
JAVA Override default value for JAVA
JAVAC Override default value for JAVAC
@@ -4364,7 +4364,7 @@
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1433337614
+DATE_WHEN_GENERATED=1434614912
###############################################################################
#
@@ -13058,192 +13058,6 @@
# Publish this variable in the help.
- if test "x$SETFILE" = x; then
- # The variable is not set by user, try to locate tool using the code snippet
- for ac_prog in SetFile
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_SETFILE+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- case $SETFILE in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_SETFILE="$SETFILE" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_SETFILE="$as_dir/$ac_word$ac_exec_ext"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-fi
-SETFILE=$ac_cv_path_SETFILE
-if test -n "$SETFILE"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SETFILE" >&5
-$as_echo "$SETFILE" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$SETFILE" && break
-done
-
- else
- # The variable is set, but is it from the command line or the environment?
-
- # Try to remove the string !SETFILE! from our list.
- try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!SETFILE!/}
- if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
- # If it failed, the variable was not from the command line. Ignore it,
- # but warn the user (except for BASH, which is always set by the calling BASH).
- if test "xSETFILE" != xBASH; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of SETFILE from the environment. Use command line variables instead." >&5
-$as_echo "$as_me: WARNING: Ignoring value of SETFILE from the environment. Use command line variables instead." >&2;}
- fi
- # Try to locate tool using the code snippet
- for ac_prog in SetFile
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_SETFILE+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- case $SETFILE in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_SETFILE="$SETFILE" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_SETFILE="$as_dir/$ac_word$ac_exec_ext"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-fi
-SETFILE=$ac_cv_path_SETFILE
-if test -n "$SETFILE"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SETFILE" >&5
-$as_echo "$SETFILE" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$SETFILE" && break
-done
-
- else
- # If it succeeded, then it was overridden by the user. We will use it
- # for the tool.
-
- # First remove it from the list of overridden variables, so we can test
- # for unknown variables in the end.
- CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
-
- # Check if the provided tool contains a complete path.
- tool_specified="$SETFILE"
- tool_basename="${tool_specified##*/}"
- if test "x$tool_basename" = "x$tool_specified"; then
- # A command without a complete path is provided, search $PATH.
- { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool SETFILE=$tool_basename" >&5
-$as_echo "$as_me: Will search for user supplied tool SETFILE=$tool_basename" >&6;}
- # Extract the first word of "$tool_basename", so it can be a program name with args.
-set dummy $tool_basename; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_SETFILE+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- case $SETFILE in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_SETFILE="$SETFILE" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_SETFILE="$as_dir/$ac_word$ac_exec_ext"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-fi
-SETFILE=$ac_cv_path_SETFILE
-if test -n "$SETFILE"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SETFILE" >&5
-$as_echo "$SETFILE" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- if test "x$SETFILE" = x; then
- as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
- fi
- else
- # Otherwise we believe it is a complete path. Use it as it is.
- { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool SETFILE=$tool_specified" >&5
-$as_echo "$as_me: Will use user supplied tool SETFILE=$tool_specified" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SETFILE" >&5
-$as_echo_n "checking for SETFILE... " >&6; }
- if test ! -x "$tool_specified"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
- as_fn_error $? "User supplied tool SETFILE=$tool_specified does not exist or is not executable" "$LINENO" 5
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
-$as_echo "$tool_specified" >&6; }
- fi
- fi
- fi
-
-
-
-
- # Publish this variable in the help.
-
-
if test "x$CPIO" = x; then
# The variable is not set by user, try to locate tool using the code snippet
for ac_prog in cpio bsdcpio
@@ -15140,10 +14954,11 @@
if test "x$OPENJDK_BUILD_OS" = "xmacosx"; then
- # detect if Xcode is installed by running xcodebuild -version
+ # If a devkit has been supplied, find xcodebuild in the toolchain_path.
+ # If not, detect if Xcode is installed by running xcodebuild -version
# if no Xcode installed, xcodebuild exits with 1
# if Xcode is installed, even if xcode-select is misconfigured, then it exits with 0
- if /usr/bin/xcodebuild -version >/dev/null 2>&1; then
+ if test "x$DEVKIT_ROOT" != x || /usr/bin/xcodebuild -version >/dev/null 2>&1; then
# We need to use xcodebuild in the toolchain dir provided by the user, this will
# fall back on the stub binary in /usr/bin/xcodebuild
# Extract the first word of "xcodebuild", so it can be a program name with args.
@@ -19653,6 +19468,199 @@
$as_echo "yes" >&6; }
fi
fi
+
+
+
+ # Publish this variable in the help.
+
+
+ if test "x$SETFILE" = x; then
+ # The variable is not set by user, try to locate tool using the code snippet
+ for ac_prog in SetFile
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_SETFILE+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $SETFILE in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_SETFILE="$SETFILE" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_SETFILE="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+SETFILE=$ac_cv_path_SETFILE
+if test -n "$SETFILE"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SETFILE" >&5
+$as_echo "$SETFILE" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$SETFILE" && break
+done
+
+ else
+ # The variable is set, but is it from the command line or the environment?
+
+ # Try to remove the string !SETFILE! from our list.
+ try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!SETFILE!/}
+ if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
+ # If it failed, the variable was not from the command line. Ignore it,
+ # but warn the user (except for BASH, which is always set by the calling BASH).
+ if test "xSETFILE" != xBASH; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of SETFILE from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of SETFILE from the environment. Use command line variables instead." >&2;}
+ fi
+ # Try to locate tool using the code snippet
+ for ac_prog in SetFile
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_SETFILE+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $SETFILE in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_SETFILE="$SETFILE" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_SETFILE="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+SETFILE=$ac_cv_path_SETFILE
+if test -n "$SETFILE"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SETFILE" >&5
+$as_echo "$SETFILE" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$SETFILE" && break
+done
+
+ else
+ # If it succeeded, then it was overridden by the user. We will use it
+ # for the tool.
+
+ # First remove it from the list of overridden variables, so we can test
+ # for unknown variables in the end.
+ CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
+
+ # Check if the provided tool contains a complete path.
+ tool_specified="$SETFILE"
+ tool_basename="${tool_specified##*/}"
+ if test "x$tool_basename" = "x$tool_specified"; then
+ # A command without a complete path is provided, search $PATH.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool SETFILE=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool SETFILE=$tool_basename" >&6;}
+ # Extract the first word of "$tool_basename", so it can be a program name with args.
+set dummy $tool_basename; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_SETFILE+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $SETFILE in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_SETFILE="$SETFILE" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_SETFILE="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+SETFILE=$ac_cv_path_SETFILE
+if test -n "$SETFILE"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SETFILE" >&5
+$as_echo "$SETFILE" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ if test "x$SETFILE" = x; then
+ as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
+ fi
+ else
+ # Otherwise we believe it is a complete path. Use it as it is.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool SETFILE=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool SETFILE=$tool_specified" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for SETFILE" >&5
+$as_echo_n "checking for SETFILE... " >&6; }
+ if test ! -x "$tool_specified"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+ as_fn_error $? "User supplied tool SETFILE=$tool_specified does not exist or is not executable" "$LINENO" 5
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
+$as_echo "$tool_specified" >&6; }
+ fi
+ fi
+ fi
+
+
+
+ if test "x$SETFILE" = x; then
+ as_fn_error $? "Could not find required tool for SETFILE" "$LINENO" 5
+ fi
+
+
fi
--- a/corba/.hgtags Thu Jun 04 18:28:52 2015 +0200
+++ b/corba/.hgtags Mon Jun 22 13:28:57 2015 -0700
@@ -311,3 +311,4 @@
44ee68f7dbacab24a45115fd6a8ccdc7eb6e8f0b jdk9-b66
4418697e56f1f43597f55c7cb6573549c6117868 jdk9-b67
8efad64f40eb8cd4df376c0a5275892eeb396bbd jdk9-b68
+de8acedcb5b5870f1dc54cba575aaa5d33897ea2 jdk9-b69
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/DynAny.java Thu Jun 04 18:28:52 2015 +0200
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/DynAny.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -52,8 +52,8 @@
*
* @param dyn_any the <code>DynAny</code> object whose contents
* are assigned to this <code>DynAny</code>.
- * @throws Invalid if the source <code>DynAny</code> is
- * invalid
+ * @throws org.omg.CORBA.DynAnyPackage.Invalid if the source
+ * <code>DynAny</code> is invalid
*/
public void assign(org.omg.CORBA.DynAny dyn_any)
throws org.omg.CORBA.DynAnyPackage.Invalid;
@@ -63,8 +63,8 @@
* object.
*
* @param value the <code>Any</code> object.
- * @throws Invalid if the source <code>Any</code> object is
- * empty or bad
+ * @throws org.omg.CORBA.DynAnyPackage.Invalid if the source
+ * <code>Any</code> object is empty or bad
*/
public void from_any(org.omg.CORBA.Any value)
throws org.omg.CORBA.DynAnyPackage.Invalid;
@@ -74,8 +74,8 @@
* object.
*
* @return the <code>Any</code> object.
- * @throws Invalid if this <code>DynAny</code> is empty or
- * bad.
+ * @throws org.omg.CORBA.DynAnyPackage.Invalid if this
+ * <code>DynAny</code> is empty or bad.
* created or does not contain a meaningful value
*/
public org.omg.CORBA.Any to_any()
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/DynArray.java Thu Jun 04 18:28:52 2015 +0200
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/DynArray.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -48,7 +48,8 @@
* <code>DynArray</code> object to the given array.
*
* @param value the array of <code>Any</code> objects
- * @exception InvalidSeq if the sequence is bad
+ * @exception org.omg.CORBA.DynAnyPackage.InvalidSeq if the
+ * sequence is bad
* @see #get_elements
*/
public void set_elements(org.omg.CORBA.Any[] value)
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/DynSequence.java Thu Jun 04 18:28:52 2015 +0200
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/DynSequence.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 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
@@ -65,7 +65,8 @@
* array.
*
* @param value the array of <code>Any</code> objects to be set
- * @exception InvalidSeq if the array of values is bad
+ * @exception org.omg.CORBA.DynAnyPackage.InvalidSeq if the array
+ * of values is bad
* @see #get_elements
*/
public void set_elements(org.omg.CORBA.Any[] value)
--- a/corba/src/java.corba/share/classes/org/omg/CORBA/ServerRequest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/corba/src/java.corba/share/classes/org/omg/CORBA/ServerRequest.java Mon Jun 22 13:28:57 2015 -0700
@@ -248,7 +248,7 @@
* contain an exception will result in a BAD_PARAM system exception. Passing
* in an unlisted user exception will result in either the DIR receiving a
* BAD_PARAM system exception or in the client receiving an
- * UNKNOWN_EXCEPTION system exception.
+ * UNKNOWN system exception.
*
* @param any the <code>Any</code> object containing the exception
* @deprecated use set_exception()
@@ -272,13 +272,13 @@
* will cause a BAD_PARAM system exception to be thrown. Passing
* in an unlisted user exception will result in either the DIR receiving a
* BAD_PARAM system exception or in the client receiving an
- * UNKNOWN_EXCEPTION system exception.
+ * UNKNOWN system exception.
*
* @param any the <code>Any</code> object containing the exception
* @exception BAD_PARAM if the given <code>Any</code> object does not
* contain an exception or the exception is an
* unlisted user exception
- * @exception UNKNOWN_EXCEPTION if the given exception is an unlisted
+ * @exception UNKNOWN if the given exception is an unlisted
* user exception and the DIR did not
* receive a BAD_PARAM exception
* @see <a href="package-summary.html#unimpl"><code>CORBA</code>
--- a/hotspot/.hgtags Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/.hgtags Mon Jun 22 13:28:57 2015 -0700
@@ -471,3 +471,4 @@
197e94e0dacddd16816f101d24fc0442ab518326 jdk9-b66
d47dfabd16d48eb96a451edd1b61194a39ee0eb5 jdk9-b67
11af3990d56c97b40318bc1f20608e86f051a3f7 jdk9-b68
+ff0929a59ced0e144201aa05819ae2e47d6f2c61 jdk9-b69
--- a/hotspot/src/cpu/x86/vm/assembler_x86.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -2813,6 +2813,13 @@
emit_arith(0x0B, 0xC0, dst, src);
}
+void Assembler::orl(Address dst, Register src) {
+ InstructionMark im(this);
+ prefix(dst, src);
+ emit_int8(0x09);
+ emit_operand(src, dst);
+}
+
void Assembler::packuswb(XMMRegister dst, Address src) {
NOT_LP64(assert(VM_Version::supports_sse2(), ""));
assert((UseAVX > 0), "SSE mode requires address alignment 16 bytes");
@@ -6907,6 +6914,19 @@
}
}
+void Assembler::rcrq(Register dst, int imm8) {
+ assert(isShiftCount(imm8 >> 1), "illegal shift count");
+ int encode = prefixq_and_encode(dst->encoding());
+ if (imm8 == 1) {
+ emit_int8((unsigned char)0xD1);
+ emit_int8((unsigned char)(0xD8 | encode));
+ } else {
+ emit_int8((unsigned char)0xC1);
+ emit_int8((unsigned char)(0xD8 | encode));
+ emit_int8(imm8);
+ }
+}
+
void Assembler::rorq(Register dst, int imm8) {
assert(isShiftCount(imm8 >> 1), "illegal shift count");
int encode = prefixq_and_encode(dst->encoding());
--- a/hotspot/src/cpu/x86/vm/assembler_x86.hpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/cpu/x86/vm/assembler_x86.hpp Mon Jun 22 13:28:57 2015 -0700
@@ -1594,6 +1594,7 @@
void orl(Register dst, int32_t imm32);
void orl(Register dst, Address src);
void orl(Register dst, Register src);
+ void orl(Address dst, Register src);
void orq(Address dst, int32_t imm32);
void orq(Register dst, int32_t imm32);
@@ -1694,6 +1695,8 @@
void rclq(Register dst, int imm8);
+ void rcrq(Register dst, int imm8);
+
void rdtsc();
void ret(int imm16);
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -7750,6 +7750,503 @@
pop(tmp2);
pop(tmp1);
}
+
+//Helper functions for square_to_len()
+
+/**
+ * Store the squares of x[], right shifted one bit (divided by 2) into z[]
+ * Preserves x and z and modifies rest of the registers.
+ */
+
+void MacroAssembler::square_rshift(Register x, Register xlen, Register z, Register tmp1, Register tmp3, Register tmp4, Register tmp5, Register rdxReg, Register raxReg) {
+ // Perform square and right shift by 1
+ // Handle odd xlen case first, then for even xlen do the following
+ // jlong carry = 0;
+ // for (int j=0, i=0; j < xlen; j+=2, i+=4) {
+ // huge_128 product = x[j:j+1] * x[j:j+1];
+ // z[i:i+1] = (carry << 63) | (jlong)(product >>> 65);
+ // z[i+2:i+3] = (jlong)(product >>> 1);
+ // carry = (jlong)product;
+ // }
+
+ xorq(tmp5, tmp5); // carry
+ xorq(rdxReg, rdxReg);
+ xorl(tmp1, tmp1); // index for x
+ xorl(tmp4, tmp4); // index for z
+
+ Label L_first_loop, L_first_loop_exit;
+
+ testl(xlen, 1);
+ jccb(Assembler::zero, L_first_loop); //jump if xlen is even
+
+ // Square and right shift by 1 the odd element using 32 bit multiply
+ movl(raxReg, Address(x, tmp1, Address::times_4, 0));
+ imulq(raxReg, raxReg);
+ shrq(raxReg, 1);
+ adcq(tmp5, 0);
+ movq(Address(z, tmp4, Address::times_4, 0), raxReg);
+ incrementl(tmp1);
+ addl(tmp4, 2);
+
+ // Square and right shift by 1 the rest using 64 bit multiply
+ bind(L_first_loop);
+ cmpptr(tmp1, xlen);
+ jccb(Assembler::equal, L_first_loop_exit);
+
+ // Square
+ movq(raxReg, Address(x, tmp1, Address::times_4, 0));
+ rorq(raxReg, 32); // convert big-endian to little-endian
+ mulq(raxReg); // 64-bit multiply rax * rax -> rdx:rax
+
+ // Right shift by 1 and save carry
+ shrq(tmp5, 1); // rdx:rax:tmp5 = (tmp5:rdx:rax) >>> 1
+ rcrq(rdxReg, 1);
+ rcrq(raxReg, 1);
+ adcq(tmp5, 0);
+
+ // Store result in z
+ movq(Address(z, tmp4, Address::times_4, 0), rdxReg);
+ movq(Address(z, tmp4, Address::times_4, 8), raxReg);
+
+ // Update indices for x and z
+ addl(tmp1, 2);
+ addl(tmp4, 4);
+ jmp(L_first_loop);
+
+ bind(L_first_loop_exit);
+}
+
+
+/**
+ * Perform the following multiply add operation using BMI2 instructions
+ * carry:sum = sum + op1*op2 + carry
+ * op2 should be in rdx
+ * op2 is preserved, all other registers are modified
+ */
+void MacroAssembler::multiply_add_64_bmi2(Register sum, Register op1, Register op2, Register carry, Register tmp2) {
+ // assert op2 is rdx
+ mulxq(tmp2, op1, op1); // op1 * op2 -> tmp2:op1
+ addq(sum, carry);
+ adcq(tmp2, 0);
+ addq(sum, op1);
+ adcq(tmp2, 0);
+ movq(carry, tmp2);
+}
+
+/**
+ * Perform the following multiply add operation:
+ * carry:sum = sum + op1*op2 + carry
+ * Preserves op1, op2 and modifies rest of registers
+ */
+void MacroAssembler::multiply_add_64(Register sum, Register op1, Register op2, Register carry, Register rdxReg, Register raxReg) {
+ // rdx:rax = op1 * op2
+ movq(raxReg, op2);
+ mulq(op1);
+
+ // rdx:rax = sum + carry + rdx:rax
+ addq(sum, carry);
+ adcq(rdxReg, 0);
+ addq(sum, raxReg);
+ adcq(rdxReg, 0);
+
+ // carry:sum = rdx:sum
+ movq(carry, rdxReg);
+}
+
+/**
+ * Add 64 bit long carry into z[] with carry propogation.
+ * Preserves z and carry register values and modifies rest of registers.
+ *
+ */
+void MacroAssembler::add_one_64(Register z, Register zlen, Register carry, Register tmp1) {
+ Label L_fourth_loop, L_fourth_loop_exit;
+
+ movl(tmp1, 1);
+ subl(zlen, 2);
+ addq(Address(z, zlen, Address::times_4, 0), carry);
+
+ bind(L_fourth_loop);
+ jccb(Assembler::carryClear, L_fourth_loop_exit);
+ subl(zlen, 2);
+ jccb(Assembler::negative, L_fourth_loop_exit);
+ addq(Address(z, zlen, Address::times_4, 0), tmp1);
+ jmp(L_fourth_loop);
+ bind(L_fourth_loop_exit);
+}
+
+/**
+ * Shift z[] left by 1 bit.
+ * Preserves x, len, z and zlen registers and modifies rest of the registers.
+ *
+ */
+void MacroAssembler::lshift_by_1(Register x, Register len, Register z, Register zlen, Register tmp1, Register tmp2, Register tmp3, Register tmp4) {
+
+ Label L_fifth_loop, L_fifth_loop_exit;
+
+ // Fifth loop
+ // Perform primitiveLeftShift(z, zlen, 1)
+
+ const Register prev_carry = tmp1;
+ const Register new_carry = tmp4;
+ const Register value = tmp2;
+ const Register zidx = tmp3;
+
+ // int zidx, carry;
+ // long value;
+ // carry = 0;
+ // for (zidx = zlen-2; zidx >=0; zidx -= 2) {
+ // (carry:value) = (z[i] << 1) | carry ;
+ // z[i] = value;
+ // }
+
+ movl(zidx, zlen);
+ xorl(prev_carry, prev_carry); // clear carry flag and prev_carry register
+
+ bind(L_fifth_loop);
+ decl(zidx); // Use decl to preserve carry flag
+ decl(zidx);
+ jccb(Assembler::negative, L_fifth_loop_exit);
+
+ if (UseBMI2Instructions) {
+ movq(value, Address(z, zidx, Address::times_4, 0));
+ rclq(value, 1);
+ rorxq(value, value, 32);
+ movq(Address(z, zidx, Address::times_4, 0), value); // Store back in big endian form
+ }
+ else {
+ // clear new_carry
+ xorl(new_carry, new_carry);
+
+ // Shift z[i] by 1, or in previous carry and save new carry
+ movq(value, Address(z, zidx, Address::times_4, 0));
+ shlq(value, 1);
+ adcl(new_carry, 0);
+
+ orq(value, prev_carry);
+ rorq(value, 0x20);
+ movq(Address(z, zidx, Address::times_4, 0), value); // Store back in big endian form
+
+ // Set previous carry = new carry
+ movl(prev_carry, new_carry);
+ }
+ jmp(L_fifth_loop);
+
+ bind(L_fifth_loop_exit);
+}
+
+
+/**
+ * Code for BigInteger::squareToLen() intrinsic
+ *
+ * rdi: x
+ * rsi: len
+ * r8: z
+ * rcx: zlen
+ * r12: tmp1
+ * r13: tmp2
+ * r14: tmp3
+ * r15: tmp4
+ * rbx: tmp5
+ *
+ */
+void MacroAssembler::square_to_len(Register x, Register len, Register z, Register zlen, Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5, Register rdxReg, Register raxReg) {
+
+ Label L_second_loop, L_second_loop_exit, L_third_loop, L_third_loop_exit, fifth_loop, fifth_loop_exit, L_last_x, L_multiply;
+ push(tmp1);
+ push(tmp2);
+ push(tmp3);
+ push(tmp4);
+ push(tmp5);
+
+ // First loop
+ // Store the squares, right shifted one bit (i.e., divided by 2).
+ square_rshift(x, len, z, tmp1, tmp3, tmp4, tmp5, rdxReg, raxReg);
+
+ // Add in off-diagonal sums.
+ //
+ // Second, third (nested) and fourth loops.
+ // zlen +=2;
+ // for (int xidx=len-2,zidx=zlen-4; xidx > 0; xidx-=2,zidx-=4) {
+ // carry = 0;
+ // long op2 = x[xidx:xidx+1];
+ // for (int j=xidx-2,k=zidx; j >= 0; j-=2) {
+ // k -= 2;
+ // long op1 = x[j:j+1];
+ // long sum = z[k:k+1];
+ // carry:sum = multiply_add_64(sum, op1, op2, carry, tmp_regs);
+ // z[k:k+1] = sum;
+ // }
+ // add_one_64(z, k, carry, tmp_regs);
+ // }
+
+ const Register carry = tmp5;
+ const Register sum = tmp3;
+ const Register op1 = tmp4;
+ Register op2 = tmp2;
+
+ push(zlen);
+ push(len);
+ addl(zlen,2);
+ bind(L_second_loop);
+ xorq(carry, carry);
+ subl(zlen, 4);
+ subl(len, 2);
+ push(zlen);
+ push(len);
+ cmpl(len, 0);
+ jccb(Assembler::lessEqual, L_second_loop_exit);
+
+ // Multiply an array by one 64 bit long.
+ if (UseBMI2Instructions) {
+ op2 = rdxReg;
+ movq(op2, Address(x, len, Address::times_4, 0));
+ rorxq(op2, op2, 32);
+ }
+ else {
+ movq(op2, Address(x, len, Address::times_4, 0));
+ rorq(op2, 32);
+ }
+
+ bind(L_third_loop);
+ decrementl(len);
+ jccb(Assembler::negative, L_third_loop_exit);
+ decrementl(len);
+ jccb(Assembler::negative, L_last_x);
+
+ movq(op1, Address(x, len, Address::times_4, 0));
+ rorq(op1, 32);
+
+ bind(L_multiply);
+ subl(zlen, 2);
+ movq(sum, Address(z, zlen, Address::times_4, 0));
+
+ // Multiply 64 bit by 64 bit and add 64 bits lower half and upper 64 bits as carry.
+ if (UseBMI2Instructions) {
+ multiply_add_64_bmi2(sum, op1, op2, carry, tmp2);
+ }
+ else {
+ multiply_add_64(sum, op1, op2, carry, rdxReg, raxReg);
+ }
+
+ movq(Address(z, zlen, Address::times_4, 0), sum);
+
+ jmp(L_third_loop);
+ bind(L_third_loop_exit);
+
+ // Fourth loop
+ // Add 64 bit long carry into z with carry propogation.
+ // Uses offsetted zlen.
+ add_one_64(z, zlen, carry, tmp1);
+
+ pop(len);
+ pop(zlen);
+ jmp(L_second_loop);
+
+ // Next infrequent code is moved outside loops.
+ bind(L_last_x);
+ movl(op1, Address(x, 0));
+ jmp(L_multiply);
+
+ bind(L_second_loop_exit);
+ pop(len);
+ pop(zlen);
+ pop(len);
+ pop(zlen);
+
+ // Fifth loop
+ // Shift z left 1 bit.
+ lshift_by_1(x, len, z, zlen, tmp1, tmp2, tmp3, tmp4);
+
+ // z[zlen-1] |= x[len-1] & 1;
+ movl(tmp3, Address(x, len, Address::times_4, -4));
+ andl(tmp3, 1);
+ orl(Address(z, zlen, Address::times_4, -4), tmp3);
+
+ pop(tmp5);
+ pop(tmp4);
+ pop(tmp3);
+ pop(tmp2);
+ pop(tmp1);
+}
+
+/**
+ * Helper function for mul_add()
+ * Multiply the in[] by int k and add to out[] starting at offset offs using
+ * 128 bit by 32 bit multiply and return the carry in tmp5.
+ * Only quad int aligned length of in[] is operated on in this function.
+ * k is in rdxReg for BMI2Instructions, for others it is in tmp2.
+ * This function preserves out, in and k registers.
+ * len and offset point to the appropriate index in "in" & "out" correspondingly
+ * tmp5 has the carry.
+ * other registers are temporary and are modified.
+ *
+ */
+void MacroAssembler::mul_add_128_x_32_loop(Register out, Register in,
+ Register offset, Register len, Register tmp1, Register tmp2, Register tmp3,
+ Register tmp4, Register tmp5, Register rdxReg, Register raxReg) {
+
+ Label L_first_loop, L_first_loop_exit;
+
+ movl(tmp1, len);
+ shrl(tmp1, 2);
+
+ bind(L_first_loop);
+ subl(tmp1, 1);
+ jccb(Assembler::negative, L_first_loop_exit);
+
+ subl(len, 4);
+ subl(offset, 4);
+
+ Register op2 = tmp2;
+ const Register sum = tmp3;
+ const Register op1 = tmp4;
+ const Register carry = tmp5;
+
+ if (UseBMI2Instructions) {
+ op2 = rdxReg;
+ }
+
+ movq(op1, Address(in, len, Address::times_4, 8));
+ rorq(op1, 32);
+ movq(sum, Address(out, offset, Address::times_4, 8));
+ rorq(sum, 32);
+ if (UseBMI2Instructions) {
+ multiply_add_64_bmi2(sum, op1, op2, carry, raxReg);
+ }
+ else {
+ multiply_add_64(sum, op1, op2, carry, rdxReg, raxReg);
+ }
+ // Store back in big endian from little endian
+ rorq(sum, 0x20);
+ movq(Address(out, offset, Address::times_4, 8), sum);
+
+ movq(op1, Address(in, len, Address::times_4, 0));
+ rorq(op1, 32);
+ movq(sum, Address(out, offset, Address::times_4, 0));
+ rorq(sum, 32);
+ if (UseBMI2Instructions) {
+ multiply_add_64_bmi2(sum, op1, op2, carry, raxReg);
+ }
+ else {
+ multiply_add_64(sum, op1, op2, carry, rdxReg, raxReg);
+ }
+ // Store back in big endian from little endian
+ rorq(sum, 0x20);
+ movq(Address(out, offset, Address::times_4, 0), sum);
+
+ jmp(L_first_loop);
+ bind(L_first_loop_exit);
+}
+
+/**
+ * Code for BigInteger::mulAdd() intrinsic
+ *
+ * rdi: out
+ * rsi: in
+ * r11: offs (out.length - offset)
+ * rcx: len
+ * r8: k
+ * r12: tmp1
+ * r13: tmp2
+ * r14: tmp3
+ * r15: tmp4
+ * rbx: tmp5
+ * Multiply the in[] by word k and add to out[], return the carry in rax
+ */
+void MacroAssembler::mul_add(Register out, Register in, Register offs,
+ Register len, Register k, Register tmp1, Register tmp2, Register tmp3,
+ Register tmp4, Register tmp5, Register rdxReg, Register raxReg) {
+
+ Label L_carry, L_last_in, L_done;
+
+// carry = 0;
+// for (int j=len-1; j >= 0; j--) {
+// long product = (in[j] & LONG_MASK) * kLong +
+// (out[offs] & LONG_MASK) + carry;
+// out[offs--] = (int)product;
+// carry = product >>> 32;
+// }
+//
+ push(tmp1);
+ push(tmp2);
+ push(tmp3);
+ push(tmp4);
+ push(tmp5);
+
+ Register op2 = tmp2;
+ const Register sum = tmp3;
+ const Register op1 = tmp4;
+ const Register carry = tmp5;
+
+ if (UseBMI2Instructions) {
+ op2 = rdxReg;
+ movl(op2, k);
+ }
+ else {
+ movl(op2, k);
+ }
+
+ xorq(carry, carry);
+
+ //First loop
+
+ //Multiply in[] by k in a 4 way unrolled loop using 128 bit by 32 bit multiply
+ //The carry is in tmp5
+ mul_add_128_x_32_loop(out, in, offs, len, tmp1, tmp2, tmp3, tmp4, tmp5, rdxReg, raxReg);
+
+ //Multiply the trailing in[] entry using 64 bit by 32 bit, if any
+ decrementl(len);
+ jccb(Assembler::negative, L_carry);
+ decrementl(len);
+ jccb(Assembler::negative, L_last_in);
+
+ movq(op1, Address(in, len, Address::times_4, 0));
+ rorq(op1, 32);
+
+ subl(offs, 2);
+ movq(sum, Address(out, offs, Address::times_4, 0));
+ rorq(sum, 32);
+
+ if (UseBMI2Instructions) {
+ multiply_add_64_bmi2(sum, op1, op2, carry, raxReg);
+ }
+ else {
+ multiply_add_64(sum, op1, op2, carry, rdxReg, raxReg);
+ }
+
+ // Store back in big endian from little endian
+ rorq(sum, 0x20);
+ movq(Address(out, offs, Address::times_4, 0), sum);
+
+ testl(len, len);
+ jccb(Assembler::zero, L_carry);
+
+ //Multiply the last in[] entry, if any
+ bind(L_last_in);
+ movl(op1, Address(in, 0));
+ movl(sum, Address(out, offs, Address::times_4, -4));
+
+ movl(raxReg, k);
+ mull(op1); //tmp4 * eax -> edx:eax
+ addl(sum, carry);
+ adcl(rdxReg, 0);
+ addl(sum, raxReg);
+ adcl(rdxReg, 0);
+ movl(carry, rdxReg);
+
+ movl(Address(out, offs, Address::times_4, -4), sum);
+
+ bind(L_carry);
+ //return tmp5/carry as carry in rax
+ movl(rax, carry);
+
+ bind(L_done);
+ pop(tmp5);
+ pop(tmp4);
+ pop(tmp3);
+ pop(tmp2);
+ pop(tmp1);
+}
#endif
/**
--- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp Mon Jun 22 13:28:57 2015 -0700
@@ -1241,6 +1241,25 @@
Register carry2);
void multiply_to_len(Register x, Register xlen, Register y, Register ylen, Register z, Register zlen,
Register tmp1, Register tmp2, Register tmp3, Register tmp4, Register tmp5);
+
+ void square_rshift(Register x, Register len, Register z, Register tmp1, Register tmp3,
+ Register tmp4, Register tmp5, Register rdxReg, Register raxReg);
+ void multiply_add_64_bmi2(Register sum, Register op1, Register op2, Register carry,
+ Register tmp2);
+ void multiply_add_64(Register sum, Register op1, Register op2, Register carry,
+ Register rdxReg, Register raxReg);
+ void add_one_64(Register z, Register zlen, Register carry, Register tmp1);
+ void lshift_by_1(Register x, Register len, Register z, Register zlen, Register tmp1, Register tmp2,
+ Register tmp3, Register tmp4);
+ void square_to_len(Register x, Register len, Register z, Register zlen, Register tmp1, Register tmp2,
+ Register tmp3, Register tmp4, Register tmp5, Register rdxReg, Register raxReg);
+
+ void mul_add_128_x_32_loop(Register out, Register in, Register offset, Register len, Register tmp1,
+ Register tmp2, Register tmp3, Register tmp4, Register tmp5, Register rdxReg,
+ Register raxReg);
+ void mul_add(Register out, Register in, Register offset, Register len, Register k, Register tmp1,
+ Register tmp2, Register tmp3, Register tmp4, Register tmp5, Register rdxReg,
+ Register raxReg);
#endif
// CRC32 code for java.util.zip.CRC32::updateBytes() instrinsic.
--- a/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/cpu/x86/vm/stubGenerator_x86_64.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -3785,6 +3785,107 @@
return start;
}
+/**
+ * Arguments:
+ *
+ // Input:
+ // c_rarg0 - x address
+ // c_rarg1 - x length
+ // c_rarg2 - z address
+ // c_rarg3 - z lenth
+ *
+ */
+ address generate_squareToLen() {
+
+ __ align(CodeEntryAlignment);
+ StubCodeMark mark(this, "StubRoutines", "squareToLen");
+
+ address start = __ pc();
+ // Win64: rcx, rdx, r8, r9 (c_rarg0, c_rarg1, ...)
+ // Unix: rdi, rsi, rdx, rcx (c_rarg0, c_rarg1, ...)
+ const Register x = rdi;
+ const Register len = rsi;
+ const Register z = r8;
+ const Register zlen = rcx;
+
+ const Register tmp1 = r12;
+ const Register tmp2 = r13;
+ const Register tmp3 = r14;
+ const Register tmp4 = r15;
+ const Register tmp5 = rbx;
+
+ BLOCK_COMMENT("Entry:");
+ __ enter(); // required for proper stackwalking of RuntimeStub frame
+
+ setup_arg_regs(4); // x => rdi, len => rsi, z => rdx
+ // zlen => rcx
+ // r9 and r10 may be used to save non-volatile registers
+ __ movptr(r8, rdx);
+ __ square_to_len(x, len, z, zlen, tmp1, tmp2, tmp3, tmp4, tmp5, rdx, rax);
+
+ restore_arg_regs();
+
+ __ leave(); // required for proper stackwalking of RuntimeStub frame
+ __ ret(0);
+
+ return start;
+ }
+
+ /**
+ * Arguments:
+ *
+ * Input:
+ * c_rarg0 - out address
+ * c_rarg1 - in address
+ * c_rarg2 - offset
+ * c_rarg3 - len
+ * not Win64
+ * c_rarg4 - k
+ * Win64
+ * rsp+40 - k
+ */
+ address generate_mulAdd() {
+ __ align(CodeEntryAlignment);
+ StubCodeMark mark(this, "StubRoutines", "mulAdd");
+
+ address start = __ pc();
+ // Win64: rcx, rdx, r8, r9 (c_rarg0, c_rarg1, ...)
+ // Unix: rdi, rsi, rdx, rcx, r8, r9 (c_rarg0, c_rarg1, ...)
+ const Register out = rdi;
+ const Register in = rsi;
+ const Register offset = r11;
+ const Register len = rcx;
+ const Register k = r8;
+
+ // Next registers will be saved on stack in mul_add().
+ const Register tmp1 = r12;
+ const Register tmp2 = r13;
+ const Register tmp3 = r14;
+ const Register tmp4 = r15;
+ const Register tmp5 = rbx;
+
+ BLOCK_COMMENT("Entry:");
+ __ enter(); // required for proper stackwalking of RuntimeStub frame
+
+ setup_arg_regs(4); // out => rdi, in => rsi, offset => rdx
+ // len => rcx, k => r8
+ // r9 and r10 may be used to save non-volatile registers
+#ifdef _WIN64
+ // last argument is on stack on Win64
+ __ movl(k, Address(rsp, 6 * wordSize));
+#endif
+ __ movptr(r11, rdx); // move offset in rdx to offset(r11)
+ __ mul_add(out, in, offset, len, k, tmp1, tmp2, tmp3, tmp4, tmp5, rdx, rax);
+
+ restore_arg_regs();
+
+ __ leave(); // required for proper stackwalking of RuntimeStub frame
+ __ ret(0);
+
+ return start;
+ }
+
+
#undef __
#define __ masm->
@@ -4030,6 +4131,12 @@
if (UseMultiplyToLenIntrinsic) {
StubRoutines::_multiplyToLen = generate_multiplyToLen();
}
+ if (UseSquareToLenIntrinsic) {
+ StubRoutines::_squareToLen = generate_squareToLen();
+ }
+ if (UseMulAddIntrinsic) {
+ StubRoutines::_mulAdd = generate_mulAdd();
+ }
#endif
}
--- a/hotspot/src/cpu/x86/vm/stubRoutines_x86_64.hpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/cpu/x86/vm/stubRoutines_x86_64.hpp Mon Jun 22 13:28:57 2015 -0700
@@ -33,7 +33,7 @@
enum platform_dependent_constants {
code_size1 = 19000, // simply increase if too small (assembler will crash if too small)
- code_size2 = 22000 // simply increase if too small (assembler will crash if too small)
+ code_size2 = 23000 // simply increase if too small (assembler will crash if too small)
};
class x86 {
--- a/hotspot/src/cpu/x86/vm/vm_version_x86.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/cpu/x86/vm/vm_version_x86.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -790,6 +790,12 @@
if (FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) {
UseMultiplyToLenIntrinsic = true;
}
+ if (FLAG_IS_DEFAULT(UseSquareToLenIntrinsic)) {
+ UseSquareToLenIntrinsic = true;
+ }
+ if (FLAG_IS_DEFAULT(UseMulAddIntrinsic)) {
+ UseMulAddIntrinsic = true;
+ }
#else
if (UseMultiplyToLenIntrinsic) {
if (!FLAG_IS_DEFAULT(UseMultiplyToLenIntrinsic)) {
@@ -797,6 +803,18 @@
}
FLAG_SET_DEFAULT(UseMultiplyToLenIntrinsic, false);
}
+ if (UseSquareToLenIntrinsic) {
+ if (!FLAG_IS_DEFAULT(UseSquareToLenIntrinsic)) {
+ warning("squareToLen intrinsic is not available in 32-bit VM");
+ }
+ FLAG_SET_DEFAULT(UseSquareToLenIntrinsic, false);
+ }
+ if (UseMulAddIntrinsic) {
+ if (!FLAG_IS_DEFAULT(UseMulAddIntrinsic)) {
+ warning("mulAdd intrinsic is not available in 32-bit VM");
+ }
+ FLAG_SET_DEFAULT(UseMulAddIntrinsic, false);
+ }
#endif
#endif // COMPILER2
--- a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -59,8 +59,8 @@
extern sigjmp_buf* get_jmp_buf_for_continuation();
address os::current_stack_pointer() {
- address dummy = (address) &dummy;
- return dummy;
+ // return the address of the current function
+ return (address)__builtin_frame_address(0);
}
frame os::get_sender_for_C_frame(frame* fr) {
--- a/hotspot/src/share/vm/classfile/vmSymbols.hpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/classfile/vmSymbols.hpp Mon Jun 22 13:28:57 2015 -0700
@@ -799,6 +799,14 @@
do_name( multiplyToLen_name, "multiplyToLen") \
do_signature(multiplyToLen_signature, "([II[II[I)[I") \
\
+ do_intrinsic(_squareToLen, java_math_BigInteger, squareToLen_name, squareToLen_signature, F_S) \
+ do_name( squareToLen_name, "implSquareToLen") \
+ do_signature(squareToLen_signature, "([II[II)[I") \
+ \
+ do_intrinsic(_mulAdd, java_math_BigInteger, mulAdd_name, mulAdd_signature, F_S) \
+ do_name( mulAdd_name, "implMulAdd") \
+ do_signature(mulAdd_signature, "([I[IIII)I") \
+ \
/* java/lang/ref/Reference */ \
do_intrinsic(_Reference_get, java_lang_ref_Reference, get_name, void_object_signature, F_R) \
\
--- a/hotspot/src/share/vm/opto/c2_globals.hpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/opto/c2_globals.hpp Mon Jun 22 13:28:57 2015 -0700
@@ -665,6 +665,12 @@
product(bool, UseMultiplyToLenIntrinsic, false, \
"Enables intrinsification of BigInteger.multiplyToLen()") \
\
+ product(bool, UseSquareToLenIntrinsic, false, \
+ "Enables intrinsification of BigInteger.squareToLen()") \
+ \
+ product(bool, UseMulAddIntrinsic, false, \
+ "Enables intrinsification of BigInteger.mulAdd()") \
+ \
product(bool, UseTypeSpeculation, true, \
"Speculatively propagate types from profiles") \
\
--- a/hotspot/src/share/vm/opto/escape.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/opto/escape.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -972,7 +972,9 @@
strcmp(call->as_CallLeaf()->_name, "sha256_implCompressMB") == 0 ||
strcmp(call->as_CallLeaf()->_name, "sha512_implCompress") == 0 ||
strcmp(call->as_CallLeaf()->_name, "sha512_implCompressMB") == 0 ||
- strcmp(call->as_CallLeaf()->_name, "multiplyToLen") == 0)
+ strcmp(call->as_CallLeaf()->_name, "multiplyToLen") == 0 ||
+ strcmp(call->as_CallLeaf()->_name, "squareToLen") == 0 ||
+ strcmp(call->as_CallLeaf()->_name, "mulAdd") == 0)
))) {
call->dump();
fatal(err_msg_res("EA unexpected CallLeaf %s", call->as_CallLeaf()->_name));
--- a/hotspot/src/share/vm/opto/ifnode.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/opto/ifnode.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -817,19 +817,78 @@
BoolTest::mask hi_test = this_bool->_test._test;
BoolTest::mask cond = hi_test;
+ // convert:
+ //
+ // dom_bool = x {<,<=,>,>=} a
+ // / \
+ // proj = {True,False} / \ otherproj = {False,True}
+ // /
+ // this_bool = x {<,<=} b
+ // / \
+ // fail = {True,False} / \ success = {False,True}
+ // /
+ //
+ // (Second test guaranteed canonicalized, first one may not have
+ // been canonicalized yet)
+ //
+ // into:
+ //
+ // cond = (x - lo) {<u,<=u,>u,>=u} adjusted_lim
+ // / \
+ // fail / \ success
+ // /
+ //
+
// Figure out which of the two tests sets the upper bound and which
// sets the lower bound if any.
+ Node* adjusted_lim = NULL;
if (hi_type->_lo > lo_type->_hi && hi_type->_hi == max_jint && lo_type->_lo == min_jint) {
-
assert((dom_bool->_test.is_less() && !proj->_con) ||
(dom_bool->_test.is_greater() && proj->_con), "incorrect test");
// this test was canonicalized
assert(this_bool->_test.is_less() && fail->_con, "incorrect test");
+ // this_bool = <
+ // dom_bool = >= (proj = True) or dom_bool = < (proj = False)
+ // x in [a, b[ on the fail (= True) projection, b > a-1 (because of hi_type->_lo > lo_type->_hi test above):
+ // lo = a, hi = b, adjusted_lim = b-a, cond = <u
+ // dom_bool = > (proj = True) or dom_bool = <= (proj = False)
+ // x in ]a, b[ on the fail (= True) projection, b > a:
+ // lo = a+1, hi = b, adjusted_lim = b-a-1, cond = <u
+ // this_bool = <=
+ // dom_bool = >= (proj = True) or dom_bool = < (proj = False)
+ // x in [a, b] on the fail (= True) projection, b+1 > a-1:
+ // lo = a, hi = b, adjusted_lim = b-a, cond = <=u
+ // dom_bool = > (proj = True) or dom_bool = <= (proj = False)
+ // x in ]a, b] on the fail (= True) projection b+1 > a:
+ // lo = a+1, hi = b, adjusted_lim = b-a, cond = <u
+ // lo = a+1, hi = b, adjusted_lim = b-a-1, cond = <=u doesn't work because a = b is possible, then hi-lo = -1
+
if (lo_test == BoolTest::gt || lo_test == BoolTest::le) {
+ if (hi_test == BoolTest::le) {
+ adjusted_lim = igvn->transform(new SubINode(hi, lo));
+ cond = BoolTest::lt;
+ }
lo = igvn->transform(new AddINode(lo, igvn->intcon(1)));
}
} else if (lo_type->_lo > hi_type->_hi && lo_type->_hi == max_jint && hi_type->_lo == min_jint) {
+
+ // this_bool = <
+ // dom_bool = < (proj = True) or dom_bool = >= (proj = False)
+ // x in [b, a[ on the fail (= False) projection, a > b-1 (because of lo_type->_lo > hi_type->_hi above):
+ // lo = b, hi = a, adjusted_lim = a-b, cond = >=u
+ // dom_bool = <= (proj = True) or dom_bool = > (proj = False)
+ // x in [b, a] on the fail (= False) projection, a+1 > b-1:
+ // lo = b, hi = a, adjusted_lim = a-b, cond = >u
+ // this_bool = <=
+ // dom_bool = < (proj = True) or dom_bool = >= (proj = False)
+ // x in ]b, a[ on the fail (= False) projection, a > b:
+ // lo = b+1, hi = a, adjusted_lim = a-b-1, cond = >=u
+ // dom_bool = <= (proj = True) or dom_bool = > (proj = False)
+ // x in ]b, a] on the fail (= False) projection, a+1 > b:
+ // lo = b+1, hi = a, adjusted_lim = a-b, cond = >=u
+ // lo = b+1, hi = a, adjusted_lim = a-b-1, cond = >u doesn't work because a = b is possible, then hi-lo = -1
+
swap(lo, hi);
swap(lo_type, hi_type);
swap(lo_test, hi_test);
@@ -842,6 +901,10 @@
cond = (hi_test == BoolTest::le || hi_test == BoolTest::gt) ? BoolTest::gt : BoolTest::ge;
if (lo_test == BoolTest::le) {
+ if (cond == BoolTest::gt) {
+ adjusted_lim = igvn->transform(new SubINode(hi, lo));
+ cond = BoolTest::ge;
+ }
lo = igvn->transform(new AddINode(lo, igvn->intcon(1)));
}
@@ -860,7 +923,6 @@
}
}
}
-
lo = NULL;
hi = NULL;
}
@@ -868,12 +930,13 @@
if (lo && hi) {
// Merge the two compares into a single unsigned compare by building (CmpU (n - lo) (hi - lo))
Node* adjusted_val = igvn->transform(new SubINode(n, lo));
- Node* adjusted_lim = igvn->transform(new SubINode(hi, lo));
+ if (adjusted_lim == NULL) {
+ adjusted_lim = igvn->transform(new SubINode(hi, lo));
+ }
Node* newcmp = igvn->transform(new CmpUNode(adjusted_val, adjusted_lim));
Node* newbool = igvn->transform(new BoolNode(newcmp, cond));
- igvn->is_IterGVN()->replace_input_of(dom_iff, 1, igvn->intcon(proj->_con));
- igvn->hash_delete(this);
+ igvn->replace_input_of(dom_iff, 1, igvn->intcon(proj->_con));
set_req(1, newbool);
return true;
--- a/hotspot/src/share/vm/opto/library_call.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/opto/library_call.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -291,6 +291,8 @@
bool inline_updateBytesCRC32();
bool inline_updateByteBufferCRC32();
bool inline_multiplyToLen();
+ bool inline_squareToLen();
+ bool inline_mulAdd();
bool inline_profileBoolean();
bool inline_isCompileConstant();
@@ -494,6 +496,14 @@
if (!UseMultiplyToLenIntrinsic) return NULL;
break;
+ case vmIntrinsics::_squareToLen:
+ if (!UseSquareToLenIntrinsic) return NULL;
+ break;
+
+ case vmIntrinsics::_mulAdd:
+ if (!UseMulAddIntrinsic) return NULL;
+ break;
+
case vmIntrinsics::_cipherBlockChaining_encryptAESCrypt:
case vmIntrinsics::_cipherBlockChaining_decryptAESCrypt:
if (!UseAESIntrinsics) return NULL;
@@ -913,6 +923,12 @@
case vmIntrinsics::_multiplyToLen:
return inline_multiplyToLen();
+ case vmIntrinsics::_squareToLen:
+ return inline_squareToLen();
+
+ case vmIntrinsics::_mulAdd:
+ return inline_mulAdd();
+
case vmIntrinsics::_encodeISOArray:
return inline_encodeISOArray();
@@ -5306,6 +5322,100 @@
return true;
}
+//-------------inline_squareToLen------------------------------------
+bool LibraryCallKit::inline_squareToLen() {
+ assert(UseSquareToLenIntrinsic, "not implementated on this platform");
+
+ address stubAddr = StubRoutines::squareToLen();
+ if (stubAddr == NULL) {
+ return false; // Intrinsic's stub is not implemented on this platform
+ }
+ const char* stubName = "squareToLen";
+
+ assert(callee()->signature()->size() == 4, "implSquareToLen has 4 parameters");
+
+ Node* x = argument(0);
+ Node* len = argument(1);
+ Node* z = argument(2);
+ Node* zlen = argument(3);
+
+ const Type* x_type = x->Value(&_gvn);
+ const Type* z_type = z->Value(&_gvn);
+ const TypeAryPtr* top_x = x_type->isa_aryptr();
+ const TypeAryPtr* top_z = z_type->isa_aryptr();
+ if (top_x == NULL || top_x->klass() == NULL ||
+ top_z == NULL || top_z->klass() == NULL) {
+ // failed array check
+ return false;
+ }
+
+ BasicType x_elem = x_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ BasicType z_elem = z_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ if (x_elem != T_INT || z_elem != T_INT) {
+ return false;
+ }
+
+
+ Node* x_start = array_element_address(x, intcon(0), x_elem);
+ Node* z_start = array_element_address(z, intcon(0), z_elem);
+
+ Node* call = make_runtime_call(RC_LEAF|RC_NO_FP,
+ OptoRuntime::squareToLen_Type(),
+ stubAddr, stubName, TypePtr::BOTTOM,
+ x_start, len, z_start, zlen);
+
+ set_result(z);
+ return true;
+}
+
+//-------------inline_mulAdd------------------------------------------
+bool LibraryCallKit::inline_mulAdd() {
+ assert(UseMulAddIntrinsic, "not implementated on this platform");
+
+ address stubAddr = StubRoutines::mulAdd();
+ if (stubAddr == NULL) {
+ return false; // Intrinsic's stub is not implemented on this platform
+ }
+ const char* stubName = "mulAdd";
+
+ assert(callee()->signature()->size() == 5, "mulAdd has 5 parameters");
+
+ Node* out = argument(0);
+ Node* in = argument(1);
+ Node* offset = argument(2);
+ Node* len = argument(3);
+ Node* k = argument(4);
+
+ const Type* out_type = out->Value(&_gvn);
+ const Type* in_type = in->Value(&_gvn);
+ const TypeAryPtr* top_out = out_type->isa_aryptr();
+ const TypeAryPtr* top_in = in_type->isa_aryptr();
+ if (top_out == NULL || top_out->klass() == NULL ||
+ top_in == NULL || top_in->klass() == NULL) {
+ // failed array check
+ return false;
+ }
+
+ BasicType out_elem = out_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ BasicType in_elem = in_type->isa_aryptr()->klass()->as_array_klass()->element_type()->basic_type();
+ if (out_elem != T_INT || in_elem != T_INT) {
+ return false;
+ }
+
+ Node* outlen = load_array_length(out);
+ Node* new_offset = _gvn.transform(new SubINode(outlen, offset));
+ Node* out_start = array_element_address(out, intcon(0), out_elem);
+ Node* in_start = array_element_address(in, intcon(0), in_elem);
+
+ Node* call = make_runtime_call(RC_LEAF|RC_NO_FP,
+ OptoRuntime::mulAdd_Type(),
+ stubAddr, stubName, TypePtr::BOTTOM,
+ out_start,in_start, new_offset, len, k);
+ Node* result = _gvn.transform(new ProjNode(call, TypeFunc::Parms));
+ set_result(result);
+ return true;
+}
+
/**
* Calculate CRC32 for byte.
--- a/hotspot/src/share/vm/opto/loopTransform.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/opto/loopTransform.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -475,7 +475,7 @@
C->set_major_progress();
// Peeling a 'main' loop in a pre/main/post situation obfuscates the
- // 'pre' loop from the main and the 'pre' can no longer have it's
+ // 'pre' loop from the main and the 'pre' can no longer have its
// iterations adjusted. Therefore, we need to declare this loop as
// no longer a 'main' loop; it will need new pre and post loops before
// we can do further RCE.
@@ -1911,10 +1911,13 @@
return;
assert(opqzm->in(1) == main_limit, "do not understand situation");
- // Find the pre-loop limit; we will expand it's iterations to
+ // Find the pre-loop limit; we will expand its iterations to
// not ever trip low tests.
Node *p_f = iffm->in(0);
- assert(p_f->Opcode() == Op_IfFalse, "");
+ // pre loop may have been optimized out
+ if (p_f->Opcode() != Op_IfFalse) {
+ return;
+ }
CountedLoopEndNode *pre_end = p_f->in(0)->as_CountedLoopEnd();
assert(pre_end->loopnode()->is_pre_loop(), "");
Node *pre_opaq1 = pre_end->limit();
@@ -2215,6 +2218,56 @@
}
}
+#ifdef ASSERT
+static CountedLoopNode* locate_pre_from_main(CountedLoopNode *cl) {
+ Node *ctrl = cl->in(LoopNode::EntryControl);
+ assert(ctrl->Opcode() == Op_IfTrue || ctrl->Opcode() == Op_IfFalse, "");
+ Node *iffm = ctrl->in(0);
+ assert(iffm->Opcode() == Op_If, "");
+ Node *p_f = iffm->in(0);
+ assert(p_f->Opcode() == Op_IfFalse, "");
+ CountedLoopEndNode *pre_end = p_f->in(0)->as_CountedLoopEnd();
+ assert(pre_end->loopnode()->is_pre_loop(), "");
+ return pre_end->loopnode();
+}
+#endif
+
+// Remove the main and post loops and make the pre loop execute all
+// iterations. Useful when the pre loop is found empty.
+void IdealLoopTree::remove_main_post_loops(CountedLoopNode *cl, PhaseIdealLoop *phase) {
+ CountedLoopEndNode* pre_end = cl->loopexit();
+ Node* pre_cmp = pre_end->cmp_node();
+ if (pre_cmp->in(2)->Opcode() != Op_Opaque1) {
+ // Only safe to remove the main loop if the compiler optimized it
+ // out based on an unknown number of iterations
+ return;
+ }
+
+ // Can we find the main loop?
+ if (_next == NULL) {
+ return;
+ }
+
+ Node* next_head = _next->_head;
+ if (!next_head->is_CountedLoop()) {
+ return;
+ }
+
+ CountedLoopNode* main_head = next_head->as_CountedLoop();
+ if (!main_head->is_main_loop()) {
+ return;
+ }
+
+ assert(locate_pre_from_main(main_head) == cl, "bad main loop");
+ Node* main_iff = main_head->in(LoopNode::EntryControl)->in(0);
+
+ // Remove the Opaque1Node of the pre loop and make it execute all iterations
+ phase->_igvn.replace_input_of(pre_cmp, 2, pre_cmp->in(2)->in(2));
+ // Remove the Opaque1Node of the main loop so it can be optimized out
+ Node* main_cmp = main_iff->in(1)->in(1);
+ assert(main_cmp->in(2)->Opcode() == Op_Opaque1, "main loop has no opaque node?");
+ phase->_igvn.replace_input_of(main_cmp, 2, main_cmp->in(2)->in(1));
+}
//------------------------------policy_do_remove_empty_loop--------------------
// Micro-benchmark spamming. Policy is to always remove empty loops.
@@ -2233,6 +2286,12 @@
if (!phase->is_member(this, phase->get_ctrl(cl->loopexit()->in(CountedLoopEndNode::TestValue))))
return false; // Infinite loop
+ if (cl->is_pre_loop()) {
+ // If the loop we are removing is a pre-loop then the main and
+ // post loop can be removed as well
+ remove_main_post_loops(cl, phase);
+ }
+
#ifdef ASSERT
// Ensure only one phi which is the iv.
Node* iv = NULL;
--- a/hotspot/src/share/vm/opto/loopnode.hpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/opto/loopnode.hpp Mon Jun 22 13:28:57 2015 -0700
@@ -485,6 +485,8 @@
bool is_inner() { return is_loop() && _child == NULL; }
bool is_counted() { return is_loop() && _head != NULL && _head->is_CountedLoop(); }
+ void remove_main_post_loops(CountedLoopNode *cl, PhaseIdealLoop *phase);
+
#ifndef PRODUCT
void dump_head( ) const; // Dump loop head only
void dump() const; // Dump this loop recursively
--- a/hotspot/src/share/vm/opto/runtime.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/opto/runtime.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -945,6 +945,48 @@
return TypeFunc::make(domain, range);
}
+const TypeFunc* OptoRuntime::squareToLen_Type() {
+ // create input type (domain)
+ int num_args = 4;
+ int argcnt = num_args;
+ const Type** fields = TypeTuple::fields(argcnt);
+ int argp = TypeFunc::Parms;
+ fields[argp++] = TypePtr::NOTNULL; // x
+ fields[argp++] = TypeInt::INT; // len
+ fields[argp++] = TypePtr::NOTNULL; // z
+ fields[argp++] = TypeInt::INT; // zlen
+ assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
+ const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
+
+ // no result type needed
+ fields = TypeTuple::fields(1);
+ fields[TypeFunc::Parms+0] = NULL;
+ const TypeTuple* range = TypeTuple::make(TypeFunc::Parms, fields);
+ return TypeFunc::make(domain, range);
+}
+
+// for mulAdd calls, 2 pointers and 3 ints, returning int
+const TypeFunc* OptoRuntime::mulAdd_Type() {
+ // create input type (domain)
+ int num_args = 5;
+ int argcnt = num_args;
+ const Type** fields = TypeTuple::fields(argcnt);
+ int argp = TypeFunc::Parms;
+ fields[argp++] = TypePtr::NOTNULL; // out
+ fields[argp++] = TypePtr::NOTNULL; // in
+ fields[argp++] = TypeInt::INT; // offset
+ fields[argp++] = TypeInt::INT; // len
+ fields[argp++] = TypeInt::INT; // k
+ assert(argp == TypeFunc::Parms+argcnt, "correct decoding");
+ const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms+argcnt, fields);
+
+ // returning carry (int)
+ fields = TypeTuple::fields(1);
+ fields[TypeFunc::Parms+0] = TypeInt::INT;
+ const TypeTuple* range = TypeTuple::make(TypeFunc::Parms+1, fields);
+ return TypeFunc::make(domain, range);
+}
+
//------------- Interpreter state access for on stack replacement
--- a/hotspot/src/share/vm/opto/runtime.hpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/opto/runtime.hpp Mon Jun 22 13:28:57 2015 -0700
@@ -312,6 +312,10 @@
static const TypeFunc* multiplyToLen_Type();
+ static const TypeFunc* squareToLen_Type();
+
+ static const TypeFunc* mulAdd_Type();
+
static const TypeFunc* updateBytesCRC32_Type();
// leaf on stack replacement interpreter accessor types
--- a/hotspot/src/share/vm/runtime/stubRoutines.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/runtime/stubRoutines.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -137,6 +137,8 @@
address StubRoutines::_crc_table_adr = NULL;
address StubRoutines::_multiplyToLen = NULL;
+address StubRoutines::_squareToLen = NULL;
+address StubRoutines::_mulAdd = NULL;
double (* StubRoutines::_intrinsic_log )(double) = NULL;
double (* StubRoutines::_intrinsic_log10 )(double) = NULL;
--- a/hotspot/src/share/vm/runtime/stubRoutines.hpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/runtime/stubRoutines.hpp Mon Jun 22 13:28:57 2015 -0700
@@ -197,6 +197,8 @@
static address _crc_table_adr;
static address _multiplyToLen;
+ static address _squareToLen;
+ static address _mulAdd;
// These are versions of the java.lang.Math methods which perform
// the same operations as the intrinsic version. They are used for
@@ -356,6 +358,8 @@
static address crc_table_addr() { return _crc_table_adr; }
static address multiplyToLen() {return _multiplyToLen; }
+ static address squareToLen() {return _squareToLen; }
+ static address mulAdd() {return _mulAdd; }
static address select_fill_function(BasicType t, bool aligned, const char* &name);
--- a/hotspot/src/share/vm/runtime/vmStructs.cpp Thu Jun 04 18:28:52 2015 +0200
+++ b/hotspot/src/share/vm/runtime/vmStructs.cpp Mon Jun 22 13:28:57 2015 -0700
@@ -831,6 +831,8 @@
static_field(StubRoutines, _updateBytesCRC32, address) \
static_field(StubRoutines, _crc_table_adr, address) \
static_field(StubRoutines, _multiplyToLen, address) \
+ static_field(StubRoutines, _squareToLen, address) \
+ static_field(StubRoutines, _mulAdd, address) \
\
/*****************/ \
/* SharedRuntime */ \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/muladd/TestMulAdd.java Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,117 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8081778
+ * @summary Add C2 x86 intrinsic for BigInteger::mulAdd() method
+ *
+ * @run main/othervm/timeout=600 -XX:-TieredCompilation -Xbatch
+ * -XX:+IgnoreUnrecognizedVMOptions -XX:-UseSquareToLenIntrinsic -XX:-UseMultiplyToLenIntrinsic
+ * -XX:CompileCommand=dontinline,TestMulAdd::main
+ * -XX:CompileCommand=option,TestMulAdd::base_multiply,ccstr,DisableIntrinsic,_mulAdd
+ * -XX:CompileCommand=option,java.math.BigInteger::multiply,ccstr,DisableIntrinsic,_mulAdd
+ * -XX:CompileCommand=option,java.math.BigInteger::square,ccstr,DisableIntrinsic,_mulAdd
+ * -XX:CompileCommand=option,java.math.BigInteger::squareToLen,ccstr,DisableIntrinsic,_mulAdd
+ * -XX:CompileCommand=option,java.math.BigInteger::mulAdd,ccstr,DisableIntrinsic,_mulAdd
+ * -XX:CompileCommand=inline,java.math.BigInteger::multiply
+ * -XX:CompileCommand=inline,java.math.BigInteger::square
+ * -XX:CompileCommand=inline,java.math.BigInteger::squareToLen
+ * -XX:CompileCommand=inline,java.math.BigInteger::mulAdd TestMulAdd
+ */
+
+import java.util.Random;
+import java.math.*;
+
+public class TestMulAdd {
+
+ // Avoid intrinsic by preventing inlining multiply() and mulAdd().
+ public static BigInteger base_multiply(BigInteger op1) {
+ return op1.multiply(op1);
+ }
+
+ // Generate mulAdd() intrinsic by inlining multiply().
+ public static BigInteger new_multiply(BigInteger op1) {
+ return op1.multiply(op1);
+ }
+
+ public static boolean bytecompare(BigInteger b1, BigInteger b2) {
+ byte[] data1 = b1.toByteArray();
+ byte[] data2 = b2.toByteArray();
+ if (data1.length != data2.length)
+ return false;
+ for (int i = 0; i < data1.length; i++) {
+ if (data1[i] != data2[i])
+ return false;
+ }
+ return true;
+ }
+
+ public static String stringify(BigInteger b) {
+ String strout= "";
+ byte [] data = b.toByteArray();
+ for (int i = 0; i < data.length; i++) {
+ strout += (String.format("%02x",data[i]) + " ");
+ }
+ return strout;
+ }
+
+ public static void main(String args[]) throws Exception {
+
+ BigInteger oldsum = new BigInteger("0");
+ BigInteger newsum = new BigInteger("0");
+
+ BigInteger b1, b2, oldres, newres;
+
+ Random rand = new Random();
+ long seed = System.nanoTime();
+ Random rand1 = new Random();
+ long seed1 = System.nanoTime();
+ rand.setSeed(seed);
+ rand1.setSeed(seed1);
+
+ for (int j = 0; j < 100000; j++) {
+ int rand_int = rand1.nextInt(3136)+32;
+ b1 = new BigInteger(rand_int, rand);
+
+ oldres = base_multiply(b1);
+ newres = new_multiply(b1);
+
+ oldsum = oldsum.add(oldres);
+ newsum = newsum.add(newres);
+
+ if (!bytecompare(oldres,newres)) {
+ System.out.print("mismatch for:b1:" + stringify(b1) + " :oldres:" + stringify(oldres) + " :newres:" + stringify(newres));
+ System.out.println(b1);
+ throw new Exception("Failed");
+ }
+ }
+ if (!bytecompare(oldsum,newsum)) {
+ System.out.println("Failure: oldsum:" + stringify(oldsum) + " newsum:" + stringify(newsum));
+ throw new Exception("Failed");
+ } else {
+ System.out.println("Success");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/intrinsics/squaretolen/TestSquareToLen.java Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ *
+ */
+
+/**
+ * @test
+ * @bug 8081778
+ * @summary Add C2 x86 intrinsic for BigInteger::squareToLen() method
+ *
+ * @run main/othervm/timeout=600 -XX:-TieredCompilation -Xbatch
+ * -XX:CompileCommand=exclude,TestSquareToLen::main
+ * -XX:CompileCommand=option,TestSquareToLen::base_multiply,ccstr,DisableIntrinsic,_squareToLen
+ * -XX:CompileCommand=option,java.math.BigInteger::multiply,ccstr,DisableIntrinsic,_squareToLen
+ * -XX:CompileCommand=option,java.math.BigInteger::square,ccstr,DisableIntrinsic,_squareToLen
+ * -XX:CompileCommand=option,java.math.BigInteger::squareToLen,ccstr,DisableIntrinsic,_squareToLen
+ * -XX:CompileCommand=inline,java.math.BigInteger::multiply
+ * -XX:CompileCommand=inline,java.math.BigInteger::square
+ * -XX:CompileCommand=inline,java.math.BigInteger::squareToLen TestSquareToLen
+ */
+
+import java.util.Random;
+import java.math.*;
+
+public class TestSquareToLen {
+
+ // Avoid intrinsic by preventing inlining multiply() and squareToLen().
+ public static BigInteger base_multiply(BigInteger op1) {
+ return op1.multiply(op1);
+ }
+
+ // Generate squareToLen() intrinsic by inlining multiply().
+ public static BigInteger new_multiply(BigInteger op1) {
+ return op1.multiply(op1);
+ }
+
+ public static boolean bytecompare(BigInteger b1, BigInteger b2) {
+ byte[] data1 = b1.toByteArray();
+ byte[] data2 = b2.toByteArray();
+ if (data1.length != data2.length)
+ return false;
+ for (int i = 0; i < data1.length; i++) {
+ if (data1[i] != data2[i])
+ return false;
+ }
+ return true;
+ }
+
+ public static String stringify(BigInteger b) {
+ String strout= "";
+ byte [] data = b.toByteArray();
+ for (int i = 0; i < data.length; i++) {
+ strout += (String.format("%02x",data[i]) + " ");
+ }
+ return strout;
+ }
+
+ public static void main(String args[]) throws Exception {
+
+ BigInteger oldsum = new BigInteger("0");
+ BigInteger newsum = new BigInteger("0");
+
+ BigInteger b1, b2, oldres, newres;
+
+ Random rand = new Random();
+ long seed = System.nanoTime();
+ Random rand1 = new Random();
+ long seed1 = System.nanoTime();
+ rand.setSeed(seed);
+ rand1.setSeed(seed1);
+
+ for (int j = 0; j < 100000; j++) {
+ int rand_int = rand1.nextInt(3136)+32;
+ b1 = new BigInteger(rand_int, rand);
+
+ oldres = base_multiply(b1);
+ newres = new_multiply(b1);
+
+ oldsum = oldsum.add(oldres);
+ newsum = newsum.add(newres);
+
+ if (!bytecompare(oldres,newres)) {
+ System.out.print("mismatch for:b1:" + stringify(b1) + " :oldres:" + stringify(oldres) + " :newres:" + stringify(newres));
+ System.out.println(b1);
+ throw new Exception("Failed");
+ }
+ }
+ if (!bytecompare(oldsum,newsum)) {
+ System.out.println("Failure: oldsum:" + stringify(oldsum) + " newsum:" + stringify(newsum));
+ throw new Exception("Failed");
+ } else {
+ System.out.println("Success");
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/hotspot/test/compiler/rangechecks/TestBadFoldCompare.java Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8085832
+ * @summary x <= 0 || x > 0 wrongly folded as (x-1) >u -1
+ * @run main/othervm -XX:-BackgroundCompilation -XX:-UseOnStackReplacement TestBadFoldCompare
+ */
+
+public class TestBadFoldCompare {
+
+ static boolean test1_taken;
+
+ static void helper1(int i, int a, int b, boolean flag) {
+ if (flag) {
+ if (i <= a || i > b) {
+ test1_taken = true;
+ }
+ }
+ }
+
+ static void test1(int i, boolean flag) {
+ helper1(i, 0, 0, flag);
+ }
+
+ static boolean test2_taken;
+
+ static void helper2(int i, int a, int b, boolean flag) {
+ if (flag) {
+ if (i > b || i <= a) {
+ test2_taken = true;
+ }
+ }
+ }
+
+ static void test2(int i, boolean flag) {
+ helper2(i, 0, 0, flag);
+ }
+
+ static public void main(String[] args) {
+ boolean success = true;
+
+ for (int i = 0; i < 20000; i++) {
+ helper1(5, 0, 10, (i%2)==0);
+ helper1(-1, 0, 10, (i%2)==0);
+ helper1(15, 0, 10, (i%2)==0);
+ test1(0, false);
+ }
+ test1_taken = false;
+ test1(0, true);
+ if (!test1_taken) {
+ System.out.println("Test1 failed");
+ success = false;
+ }
+
+ for (int i = 0; i < 20000; i++) {
+ helper2(5, 0, 10, (i%2)==0);
+ helper2(-1, 0, 10, (i%2)==0);
+ helper2(15, 0, 10, (i%2)==0);
+ test2(0, false);
+ }
+ test2_taken = false;
+ test2(0, true);
+
+ if (!test2_taken) {
+ System.out.println("Test2 failed");
+ success = false;
+ }
+ if (!success) {
+ throw new RuntimeException("Some tests failed");
+ }
+ }
+}
--- a/jaxp/.hgtags Thu Jun 04 18:28:52 2015 +0200
+++ b/jaxp/.hgtags Mon Jun 22 13:28:57 2015 -0700
@@ -311,3 +311,4 @@
d5963ccce28d7a3e96ee3e2dc8a8676e61699b70 jdk9-b66
78c2685daabafae827c686ca2d1bb2e451faed2b jdk9-b67
82aae947938ec9b0119fdd78a616d0b7263072ee jdk9-b68
+f844a908d3308f47d73cf64e87c98d37d5d76ce8 jdk9-b69
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/FunctionTable.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/FunctionTable.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,21 +1,23 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
-/*
- * Copyright 1999-2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
/*
* $Id: FunctionTable.java,v 1.3 2005/09/28 13:49:34 pvedula Exp $
@@ -135,6 +137,9 @@
/** The 'unparsed-entity-uri()' id (XSLT). */
public static final int FUNC_UNPARSED_ENTITY_URI = 36;
+ /** The 'here()' id (XML Signature). */
+ public static final int FUNC_HERE = 37;
+
// Proprietary
/** The 'document-location()' id (Proprietary). */
@@ -162,7 +167,7 @@
* Number of built in functions. Be sure to update this as
* built-in functions are added.
*/
- private static final int NUM_BUILT_IN_FUNCS = 37;
+ private static final int NUM_BUILT_IN_FUNCS = 38;
/**
* Number of built-in functions that may be added.
@@ -229,6 +234,8 @@
com.sun.org.apache.xpath.internal.functions.FuncDoclocation.class;
m_functions[FUNC_UNPARSED_ENTITY_URI] =
com.sun.org.apache.xpath.internal.functions.FuncUnparsedEntityURI.class;
+ m_functions[FUNC_HERE] =
+ com.sun.org.apache.xpath.internal.functions.FuncHere.class;
}
static{
@@ -302,6 +309,8 @@
new Integer(FunctionTable.FUNC_UNPARSED_ENTITY_URI));
m_functionID.put(Keywords.FUNC_DOCLOCATION_STRING,
new Integer(FunctionTable.FUNC_DOCLOCATION));
+ m_functionID.put(Keywords.FUNC_HERE_STRING,
+ new Integer(FunctionTable.FUNC_HERE));
}
public FunctionTable(){
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/Keywords.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/compiler/Keywords.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,21 +1,23 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
*/
-/*
- * Copyright 1999-2005 The Apache Software Foundation.
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
*/
/*
* $Id: Keywords.java,v 1.2.4.1 2005/09/14 19:46:01 jeffsuttor Exp $
@@ -210,6 +212,9 @@
public static final String FUNC_UNPARSED_ENTITY_URI_STRING =
"unparsed-entity-uri";
+ /** here function string (XML Signature). */
+ public static final String FUNC_HERE_STRING = "here";
+
// Proprietary, built in functions
/** current function string (Proprietary). */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xpath/internal/functions/FuncHere.java Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ */
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.sun.org.apache.xpath.internal.functions;
+
+import javax.xml.transform.TransformerException;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import com.sun.org.apache.xml.internal.dtm.DTM;
+import com.sun.org.apache.xpath.internal.NodeSetDTM;
+import com.sun.org.apache.xpath.internal.XPathContext;
+import com.sun.org.apache.xpath.internal.objects.XNodeSet;
+import com.sun.org.apache.xpath.internal.objects.XObject;
+import com.sun.org.apache.xpath.internal.res.XPATHErrorResources;
+
+/**
+ * Execute the XML Signature here() function.
+ */
+public final class FuncHere extends Function {
+
+ private static final long serialVersionUID = 4328660760070034592L;
+
+ @Override
+ public XObject execute(XPathContext xctxt) throws TransformerException {
+ Node xpathOwnerNode = (Node)xctxt.getOwnerObject();
+ if (xpathOwnerNode == null) {
+ return null;
+ }
+
+ int xpathOwnerNodeDTM = xctxt.getDTMHandleFromNode(xpathOwnerNode);
+ int currentNode = xctxt.getCurrentNode();
+ DTM dtm = xctxt.getDTM(currentNode);
+ int docContext = dtm.getDocument();
+
+ if (docContext == DTM.NULL) {
+ error(xctxt, XPATHErrorResources.ER_CONTEXT_HAS_NO_OWNERDOC, null);
+ }
+
+ // check whether currentNode and the node containing the XPath
+ // expression are in the same document
+ Document currentDoc = getOwnerDocument(dtm.getNode(currentNode));
+ Document xpathOwnerDoc = getOwnerDocument(xpathOwnerNode);
+
+ if (currentDoc != xpathOwnerDoc) {
+ throw new TransformerException("Owner documents differ");
+ }
+
+ XNodeSet nodes = new XNodeSet(xctxt.getDTMManager());
+ NodeSetDTM nodeSet = nodes.mutableNodeset();
+
+ int hereNode = DTM.NULL;
+
+ switch (dtm.getNodeType(xpathOwnerNodeDTM)) {
+
+ case Node.ATTRIBUTE_NODE:
+ case Node.PROCESSING_INSTRUCTION_NODE: {
+ // returns a node-set containing the attribute / processing
+ // instruction node
+ hereNode = xpathOwnerNodeDTM;
+ nodeSet.addNode(hereNode);
+ break;
+ }
+ case Node.TEXT_NODE : {
+ // returns a node-set containing the parent element of the
+ // text node that directly bears the XPath expression
+ hereNode = dtm.getParent(xpathOwnerNodeDTM);
+ nodeSet.addNode(hereNode);
+ break;
+ }
+ default :
+ break;
+ }
+
+ /** $todo$ Do I have to do this detach() call? */
+ nodeSet.detach();
+
+ return nodes;
+ }
+
+ private static Document getOwnerDocument(Node node) {
+ if (node.getNodeType() == Node.DOCUMENT_NODE) {
+ return (Document)node;
+ }
+ return node.getOwnerDocument();
+ }
+
+ @Override
+ public void fixupVariables(java.util.Vector vars, int globalsSize) { }
+}
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -23,28 +23,32 @@
package javax.xml.parsers.ptests;
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+import static javax.xml.parsers.ptests.ParserTestConst.GOLDEN_DIR;
+import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
+import static jaxp.library.JAXPTestUtilities.USER_DIR;
+import static jaxp.library.JAXPTestUtilities.compareWithGold;
+import static jaxp.library.JAXPTestUtilities.filenameToURL;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
+import static org.testng.Assert.assertTrue;
import java.io.BufferedReader;
+import java.io.Closeable;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FilePermission;
import java.io.FileReader;
-import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
-
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.FactoryConfigurationError;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
-
-import static javax.xml.parsers.ptests.ParserTestConst.GOLDEN_DIR;
-import static javax.xml.parsers.ptests.ParserTestConst.XML_DIR;
-
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
@@ -52,10 +56,6 @@
import jaxp.library.JAXPDataProvider;
import jaxp.library.JAXPFileBaseTest;
-import static jaxp.library.JAXPTestUtilities.USER_DIR;
-import static jaxp.library.JAXPTestUtilities.compareWithGold;
-import static org.testng.Assert.assertFalse;
-import static org.testng.Assert.assertTrue;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -67,6 +67,7 @@
import org.xml.sax.helpers.DefaultHandler;
/**
+ * @bug 8080907
* This checks the methods of DocumentBuilderFactoryImpl.
*/
public class DocumentBuilderFactoryTest extends JAXPFileBaseTest {
@@ -134,28 +135,11 @@
assertFalse(eh.isErrorOccured());
}
- /**
- * Test the default functionality of schema support method. In
- * this case the schema source property is set.
- * @throws Exception If any errors occur.
- */
- @Test
- public void testCheckSchemaSupport2() throws Exception {
- try (FileInputStream fis = new FileInputStream(new File(
- XML_DIR, "test.xsd"))) {
- DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
- dbf.setValidating(true);
- dbf.setNamespaceAware(true);
- dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
- W3C_XML_SCHEMA_NS_URI);
- dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource",
- new InputSource(fis));
- MyErrorHandler eh = MyErrorHandler.newInstance();
- DocumentBuilder db = dbf.newDocumentBuilder();
- db.setErrorHandler(eh);
- db.parse(new File(XML_DIR, "test1.xml"));
- assertFalse(eh.isErrorOccured());
- }
+ @DataProvider(name = "schema-source")
+ public Object[][] getSchemaSource() throws FileNotFoundException {
+ return new Object[][] {
+ { new FileInputStream(new File(XML_DIR, "test.xsd")) },
+ { new InputSource(filenameToURL(XML_DIR + "test.xsd")) } };
}
/**
@@ -163,22 +147,50 @@
* this case the schema source property is set.
* @throws Exception If any errors occur.
*/
- @Test
- public void testCheckSchemaSupport3() throws Exception {
- try (FileInputStream fis = new FileInputStream(new File(
- XML_DIR, "test.xsd"))) {
+ @Test(dataProvider = "schema-source")
+ public void testCheckSchemaSupport2(Object schemaSource) throws Exception {
+ try {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setValidating(true);
+ dbf.setNamespaceAware(true);
+ dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
+ W3C_XML_SCHEMA_NS_URI);
+ dbf.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", schemaSource);
+ MyErrorHandler eh = MyErrorHandler.newInstance();
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ db.setErrorHandler(eh);
+ db.parse(new File(XML_DIR, "test1.xml"));
+ assertFalse(eh.isErrorOccured());
+ } finally {
+ if (schemaSource instanceof Closeable) {
+ ((Closeable) schemaSource).close();
+ }
+ }
+
+ }
+
+ /**
+ * Test the default functionality of schema support method. In
+ * this case the schema source property is set.
+ * @throws Exception If any errors occur.
+ */
+ @Test(dataProvider = "schema-source")
+ public void testCheckSchemaSupport3(Object schemaSource) throws Exception {
+ try {
SAXParserFactory spf = SAXParserFactory.newInstance();
- spf.setNamespaceAware(true);
spf.setValidating(true);
spf.setNamespaceAware(true);
SAXParser sp = spf.newSAXParser();
sp.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
W3C_XML_SCHEMA_NS_URI);
- sp.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource",
- new InputSource(fis));
+ sp.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", schemaSource);
DefaultHandler dh = new DefaultHandler();
// Not expect any unrecoverable error here.
sp.parse(new File(XML_DIR, "test1.xml"), dh);
+ } finally {
+ if (schemaSource instanceof Closeable) {
+ ((Closeable) schemaSource).close();
+ }
}
}
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -27,6 +27,7 @@
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertSame;
+import static org.testng.Assert.assertTrue;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -39,9 +40,12 @@
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLStreamException;
import javax.xml.transform.Source;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXSource;
import javax.xml.transform.stream.StreamSource;
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
@@ -60,6 +64,7 @@
import org.xml.sax.SAXParseException;
/*
+ * @bug 8080907
* @summary Class containing the test cases for SchemaFactory
*/
@Test(singleThreaded = true)
@@ -68,8 +73,9 @@
@BeforeClass
public void setup() throws SAXException, IOException, ParserConfigurationException {
sf = newSchemaFactory();
+ assertNotNull(sf);
- assertNotNull(sf);
+ ifac = XMLInputFactory.newInstance();
xsd1 = Files.readAllBytes(Paths.get(XML_DIR + "test.xsd"));
xsd2 = Files.readAllBytes(Paths.get(XML_DIR + "test1.xsd"));
@@ -152,11 +158,13 @@
}
@DataProvider(name = "valid-source")
- public Object[][] getValidSource() {
+ public Object[][] getValidSource() throws XMLStreamException {
return new Object[][] {
{ streamSource(xsd1) },
{ saxSource(xsd1) },
- { domSource(xsdDoc1) } };
+ { domSource(xsdDoc1) },
+ { staxStreamSource(xsd1) },
+ { staxEventSource(xsd1) } };
}
@@ -299,6 +307,34 @@
sf.setFeature(null, true);
}
+ @DataProvider(name = "source-feature")
+ public Object[][] getSourceFeature() {
+ return new Object[][] {
+ { StreamSource.FEATURE },
+ { SAXSource.FEATURE },
+ { DOMSource.FEATURE },
+ { DOMSource.FEATURE } };
+
+ }
+
+ /*
+ * Return true for each of the JAXP Source features to indicate that this
+ * SchemaFactory supports all of the built-in JAXP Source types.
+ */
+ @Test(dataProvider = "source-feature")
+ public void testSourceFeatureGet(String sourceFeature) throws Exception {
+ assertTrue(newSchemaFactory().getFeature(sourceFeature));
+ }
+
+ /*
+ * JAXP Source features are read-only because this SchemaFactory always
+ * supports all JAXP Source types.
+ */
+ @Test(dataProvider = "source-feature", expectedExceptions = SAXNotSupportedException.class)
+ public void testSourceFeatureSet(String sourceFeature) throws Exception {
+ newSchemaFactory().setFeature(sourceFeature, false);
+ }
+
@Test(expectedExceptions = IllegalArgumentException.class)
public void testInvalidSchemaLanguage() {
final String INVALID_SCHEMA_LANGUAGE = "http://relaxng.org/ns/structure/1.0";
@@ -337,6 +373,15 @@
return new DOMSource(xsdDoc);
}
+ private Source staxStreamSource(byte[] xsd) throws XMLStreamException {
+ return new StAXSource(ifac.createXMLStreamReader(newInputStream(xsd)));
+ }
+
+ private Source staxEventSource(byte[] xsd) throws XMLStreamException {
+ return new StAXSource(ifac.createXMLEventReader(newInputStream(xsd)));
+ }
+
+
private SchemaFactory newSchemaFactory() {
return SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI);
}
@@ -346,6 +391,7 @@
private static final String SCHEMA_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory";
private SchemaFactory sf;
+ private XMLInputFactory ifac;
private byte[] xsd1;
private byte[] xsd2;
private Document xsdDoc1;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/validation/AnyElementTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.xml.validation;
+
+/*
+ * @bug 8080907
+ * @summary Test processContents attribute of any element
+ */
+import static javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI;
+
+import java.net.URISyntaxException;
+
+import javax.xml.transform.stream.StreamSource;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+public class AnyElementTest {
+ @BeforeClass
+ public void setup() throws URISyntaxException, SAXException {
+ validator = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI).newSchema(new StreamSource(getUri("ProcessContents.xsd"))).newValidator();
+ }
+
+ /*
+ * processContents attribute - Specifies how the XML processor should handle
+ * validation against the elements specified by this any element. Can be set
+ * to one of the following:
+ * strict - the XML processor must obtain the schema for the required
+ * namespaces and validate the elements (this is default)
+ * lax - same as strict, but if the schema cannot be obtained, no errors
+ * will occur
+ * skip - The XML processor does not attempt to validate any elements from
+ * the specified namespaces
+ */
+ @Test
+ public void testProcessContents() throws Exception {
+ validator.validate(new StreamSource(getUri("ProcessContents-ok.xml")));
+ }
+
+ /*
+ * When processContents="lax", validation will be performed when the element
+ * is declared in the schema.
+ */
+ @Test(expectedExceptions = SAXParseException.class)
+ public void testProcessContentsLax() throws Exception {
+ validator.validate(new StreamSource(getUri("ProcessContents-lax-error.xml")));
+ }
+
+ /*
+ * Get the URI of the file, which is in the same path as this class
+ */
+ private String getUri(String fileName) throws URISyntaxException {
+ return this.getClass().getResource(fileName).toURI().toASCIIString();
+ }
+
+ private Validator validator;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/validation/ProcessContents-lax-error.xml Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,4 @@
+<?xml version="1.0"?>
+<my_lax>
+ <my_int>25.5</my_int>
+</my_lax>
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/validation/ProcessContents-ok.xml Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,21 @@
+<?xml version="1.0"?>
+<my_strict>
+ <my_int>255</my_int>
+ <my_skip>
+ <my_int>2.55</my_int>
+ <un_define/>
+ <my_lax>
+ <my_int>25.5</my_int>
+ </my_lax>
+ <my_strict>
+ <un_define>TTT</un_define>
+ </my_strict>
+ </my_skip>
+ <my_lax>
+ <my_int>2555</my_int>
+ <un_define>TTT</un_define>
+ <my_strict>
+ <my_int>20</my_int>
+ </my_strict>
+ </my_lax>
+</my_strict>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/unittest/javax/xml/validation/ProcessContents.xsd Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+
+<xs:element name="my_lax">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any processContents="lax" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="my_skip">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any processContents="skip" maxOccurs="unbounded"/>
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="my_strict">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:any maxOccurs="unbounded"/> <!-- by default, processContents="strict" -->
+ </xs:sequence>
+ </xs:complexType>
+</xs:element>
+
+<xs:element name="my_int">
+ <xs:simpleType>
+ <xs:restriction base="xs:int"/>
+ </xs:simpleType>
+</xs:element>
+
+</xs:schema>
\ No newline at end of file
--- a/jaxws/.hgtags Thu Jun 04 18:28:52 2015 +0200
+++ b/jaxws/.hgtags Mon Jun 22 13:28:57 2015 -0700
@@ -314,3 +314,4 @@
1232f4013417e4a9cd291096798d10f2e601d69d jdk9-b66
c9785bc8ade98a16a050d7520b70c68363857e00 jdk9-b67
b5878b03d1b2e105917d959fbfa3c57c22495803 jdk9-b68
+f5911c6155c29ac24b6f9068273207e5ebd3a3df jdk9-b69
--- a/jdk/.hgtags Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/.hgtags Mon Jun 22 13:28:57 2015 -0700
@@ -311,3 +311,4 @@
4fbcca8ab812198c7fb747ea7b213b6e404f36e9 jdk9-b66
1abd45df5480a04bff98fba1851d66a5230e67d4 jdk9-b67
046fd17bb9a0cdf6681124866df9626d17b0516a jdk9-b68
+551323004d0ce2f1d4b0e99552f7e0cdcebc6fca jdk9-b69
--- a/jdk/make/lib/CoreLibraries.gmk Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/make/lib/CoreLibraries.gmk Mon Jun 22 13:28:57 2015 -0700
@@ -161,7 +161,7 @@
-export:getLastErrorString \
jvm.lib $(BUILD_LIBFDLIBM) $(WIN_VERIFY_LIB) \
shell32.lib delayimp.lib -DELAYLOAD:shell32.dll \
- advapi32.lib, \
+ advapi32.lib version.lib, \
VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
RC_FLAGS := $(RC_FLAGS) \
-D "JDK_FNAME=java.dll" \
--- a/jdk/src/java.base/share/classes/java/lang/SecurityManager.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/SecurityManager.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 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
@@ -1447,7 +1447,7 @@
throw new NullPointerException("package name can't be null");
}
- String[] pkgs;
+ String[] restrictedPkgs;
synchronized (packageAccessLock) {
/*
* Do we need to update our property array?
@@ -1457,8 +1457,7 @@
AccessController.doPrivileged(
new PrivilegedAction<>() {
public String run() {
- return java.security.Security.getProperty(
- "package.access");
+ return Security.getProperty("package.access");
}
}
);
@@ -1468,14 +1467,33 @@
// Using a snapshot of packageAccess -- don't care if static field
// changes afterwards; array contents won't change.
- pkgs = packageAccess;
+ restrictedPkgs = packageAccess;
}
/*
* Traverse the list of packages, check for any matches.
*/
- for (String restrictedPkg : pkgs) {
- if (pkg.startsWith(restrictedPkg) || restrictedPkg.equals(pkg + ".")) {
+ final int plen = pkg.length();
+ for (String restrictedPkg : restrictedPkgs) {
+ final int rlast = restrictedPkg.length() - 1;
+
+ // Optimizations:
+ //
+ // If rlast >= plen then restrictedPkg is longer than pkg by at
+ // least one char. This means pkg cannot start with restrictedPkg,
+ // since restrictedPkg will be longer than pkg.
+ //
+ // Similarly if rlast != plen, then pkg + "." cannot be the same
+ // as restrictedPkg, since pkg + "." will have a different length
+ // than restrictedPkg.
+ //
+ if (rlast < plen && pkg.startsWith(restrictedPkg) ||
+ // The following test is equivalent to
+ // restrictedPkg.equals(pkg + ".") but is noticeably more
+ // efficient:
+ rlast == plen && restrictedPkg.startsWith(pkg) &&
+ restrictedPkg.charAt(rlast) == '.')
+ {
checkPermission(
new RuntimePermission("accessClassInPackage." + pkg));
break; // No need to continue; only need to check this once
--- a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedArrayType.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedArrayType.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -39,6 +39,7 @@
* Returns the potentially annotated generic component type of this array type.
*
* @return the potentially annotated generic component type of this array type
+ * @see GenericArrayType#getGenericComponentType()
*/
AnnotatedType getAnnotatedGenericComponentType();
}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedParameterizedType.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedParameterizedType.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -38,6 +38,7 @@
* Returns the potentially annotated actual type arguments of this parameterized type.
*
* @return the potentially annotated actual type arguments of this parameterized type
+ * @see ParameterizedType#getActualTypeArguments()
*/
AnnotatedType[] getAnnotatedActualTypeArguments();
}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedTypeVariable.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedTypeVariable.java Mon Jun 22 13:28:57 2015 -0700
@@ -36,10 +36,11 @@
/**
* Returns the potentially annotated bounds of this type variable.
- * Note that if no bound is explicitly declared, the bound is unannotated
+ * If no bound is explicitly declared, the bound is unannotated
* {@code Object}.
*
* @return the potentially annotated bounds of this type variable
+ * @see TypeVariable#getBounds()
*/
AnnotatedType[] getAnnotatedBounds();
}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedWildcardType.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/AnnotatedWildcardType.java Mon Jun 22 13:28:57 2015 -0700
@@ -36,20 +36,22 @@
/**
* Returns the potentially annotated lower bounds of this wildcard type.
- * Note that if no lower bound is explicitly declared, the lower bound is the
+ * If no lower bound is explicitly declared, the lower bound is the
* type of null. In this case, a zero length array is returned.
*
* @return the potentially annotated lower bounds of this wildcard type or
* an empty array if no lower bound is explicitly declared.
+ * @see WildcardType#getLowerBounds()
*/
AnnotatedType[] getAnnotatedLowerBounds();
/**
* Returns the potentially annotated upper bounds of this wildcard type.
- * Note that if no upper bound is explicitly declared, the upper bound is
+ * If no upper bound is explicitly declared, the upper bound is
* unannotated {@code Object}
*
* @return the potentially annotated upper bounds of this wildcard type
+ * @see WildcardType#getUpperBounds()
*/
AnnotatedType[] getAnnotatedUpperBounds();
}
--- a/jdk/src/java.base/share/classes/java/lang/reflect/TypeVariable.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/TypeVariable.java Mon Jun 22 13:28:57 2015 -0700
@@ -51,7 +51,7 @@
public interface TypeVariable<D extends GenericDeclaration> extends Type, AnnotatedElement {
/**
* Returns an array of {@code Type} objects representing the
- * upper bound(s) of this type variable. Note that if no upper bound is
+ * upper bound(s) of this type variable. If no upper bound is
* explicitly declared, the upper bound is {@code Object}.
*
* <p>For each upper bound B: <ul> <li>if B is a parameterized
@@ -67,7 +67,7 @@
* for any reason
* @return an array of {@code Type}s representing the upper
* bound(s) of this type variable
- */
+ */
Type[] getBounds();
/**
--- a/jdk/src/java.base/share/classes/java/lang/reflect/WildcardType.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/WildcardType.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -34,7 +34,7 @@
public interface WildcardType extends Type {
/**
* Returns an array of {@code Type} objects representing the upper
- * bound(s) of this type variable. Note that if no upper bound is
+ * bound(s) of this type variable. If no upper bound is
* explicitly declared, the upper bound is {@code Object}.
*
* <p>For each upper bound B :
@@ -57,7 +57,7 @@
/**
* Returns an array of {@code Type} objects representing the
- * lower bound(s) of this type variable. Note that if no lower bound is
+ * lower bound(s) of this type variable. If no lower bound is
* explicitly declared, the lower bound is the type of {@code null}.
* In this case, a zero length array is returned.
*
--- a/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/share/classes/java/security/SecureClassLoader.java Mon Jun 22 13:28:57 2015 -0700
@@ -25,9 +25,11 @@
package java.security;
-import java.util.HashMap;
+import java.util.Map;
import java.util.ArrayList;
import java.net.URL;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
import sun.security.util.Debug;
@@ -48,7 +50,7 @@
private final boolean initialized;
/*
- * HashMap that maps the CodeSource URL (as a String) to ProtectionDomain.
+ * Map that maps the CodeSource URL (as a String) to ProtectionDomain.
* We use a String instead of a CodeSource/URL as the key to avoid
* potential expensive name service lookups. This does mean that URLs that
* are equivalent after nameservice lookup will be placed in separate
@@ -56,7 +58,8 @@
* canonicalized and resolved resulting in a consistent set of granted
* permissions.
*/
- private final HashMap<String, ProtectionDomain> pdcache = new HashMap<>(11);
+ private final Map<String, ProtectionDomain> pdcache
+ = new ConcurrentHashMap<>(11);
private static final Debug debug = Debug.getInstance("scl");
@@ -206,25 +209,28 @@
return null;
}
- ProtectionDomain pd = null;
- synchronized (pdcache) {
- // Use a String form of the URL as the key. It should behave in the
- // same manner as the URL when compared for equality except that no
- // nameservice lookup is done on the hostname (String comparison
- // only), and the fragment is not considered.
- String key = cs.getLocationNoFragString();
- pd = pdcache.get(key);
- if (pd == null) {
- PermissionCollection perms = getPermissions(cs);
- pd = new ProtectionDomain(cs, perms, this, null);
- pdcache.put(key, pd);
+ // Use a String form of the URL as the key. It should behave in the
+ // same manner as the URL when compared for equality except that no
+ // nameservice lookup is done on the hostname (String comparison
+ // only), and the fragment is not considered.
+ String key = cs.getLocationNoFragString();
+ if (key == null) {
+ key = "<null>";
+ }
+ return pdcache.computeIfAbsent(key, new Function<>() {
+ @Override
+ public ProtectionDomain apply(String key /* not used */) {
+ PermissionCollection perms
+ = SecureClassLoader.this.getPermissions(cs);
+ ProtectionDomain pd = new ProtectionDomain(
+ cs, perms, SecureClassLoader.this, null);
if (debug != null) {
- debug.println(" getPermissions "+ pd);
+ debug.println(" getPermissions " + pd);
debug.println("");
}
+ return pd;
}
- }
- return pd;
+ });
}
/*
--- a/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/unix/classes/java/lang/ProcessImpl.java Mon Jun 22 13:28:57 2015 -0700
@@ -542,7 +542,22 @@
@Override
public CompletableFuture<Process> onExit() {
return ProcessHandleImpl.completion(pid, false)
- .handleAsync((exitStatus, unusedThrowable) -> this);
+ .handleAsync((exitStatus, unusedThrowable) -> {
+ boolean interrupted = false;
+ while (true) {
+ // Ensure that the concurrent task setting the exit status has completed
+ try {
+ waitFor();
+ break;
+ } catch (InterruptedException ie) {
+ interrupted = true;
+ }
+ }
+ if (interrupted) {
+ Thread.currentThread().interrupt();
+ }
+ return this;
+ });
}
@Override
--- a/jdk/src/java.base/windows/native/launcher/java.manifest Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/windows/native/launcher/java.manifest Mon Jun 22 13:28:57 2015 -0700
@@ -52,6 +52,8 @@
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
+ <!-- Windows 10 -->
+ <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
--- a/jdk/src/java.base/windows/native/libjava/java_props_md.c Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/src/java.base/windows/native/libjava/java_props_md.c Mon Jun 22 13:28:57 2015 -0700
@@ -351,8 +351,8 @@
GetJavaProperties(JNIEnv* env)
{
static java_props_t sprops = {0};
-
- OSVERSIONINFOEX ver;
+ int majorVersion;
+ int minorVersion;
if (sprops.line_separator) {
return &sprops;
@@ -383,21 +383,65 @@
/* OS properties */
{
char buf[100];
- SYSTEM_INFO si;
- PGNSI pGNSI;
+ boolean is_workstation;
+ boolean is_64bit;
+ DWORD platformId;
+ {
+ OSVERSIONINFOEX ver;
+ ver.dwOSVersionInfoSize = sizeof(ver);
+ GetVersionEx((OSVERSIONINFO *) &ver);
+ majorVersion = ver.dwMajorVersion;
+ minorVersion = ver.dwMinorVersion;
+ is_workstation = (ver.wProductType == VER_NT_WORKSTATION);
+ platformId = ver.dwPlatformId;
+ sprops.patch_level = _strdup(ver.szCSDVersion);
+ }
- ver.dwOSVersionInfoSize = sizeof(ver);
- GetVersionEx((OSVERSIONINFO *) &ver);
+ {
+ SYSTEM_INFO si;
+ ZeroMemory(&si, sizeof(SYSTEM_INFO));
+ GetNativeSystemInfo(&si);
+
+ is_64bit = (si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64);
+ }
+ do {
+ // Read the major and minor version number from kernel32.dll
+ VS_FIXEDFILEINFO *file_info;
+ WCHAR kernel32_path[MAX_PATH];
+ UINT len, ret;
- ZeroMemory(&si, sizeof(SYSTEM_INFO));
- // Call GetNativeSystemInfo if supported or GetSystemInfo otherwise.
- pGNSI = (PGNSI) GetProcAddress(
- GetModuleHandle(TEXT("kernel32.dll")),
- "GetNativeSystemInfo");
- if(NULL != pGNSI)
- pGNSI(&si);
- else
- GetSystemInfo(&si);
+ // Get the full path to \Windows\System32\kernel32.dll and use that for
+ // determining what version of Windows we're running on.
+ len = MAX_PATH - (UINT)strlen("\\kernel32.dll") - 1;
+ ret = GetSystemDirectoryW(kernel32_path, len);
+ if (ret == 0 || ret > len) {
+ break;
+ }
+ wcsncat(kernel32_path, L"\\kernel32.dll", MAX_PATH - ret);
+
+ DWORD version_size = GetFileVersionInfoSizeW(kernel32_path, NULL);
+ if (version_size == 0) {
+ break;
+ }
+
+ LPTSTR version_info = (LPTSTR)malloc(version_size);
+ if (version_info == NULL) {
+ break;
+ }
+
+ if (!GetFileVersionInfoW(kernel32_path, 0, version_size, version_info)) {
+ free(version_info);
+ break;
+ }
+
+ if (!VerQueryValueW(version_info, L"\\", (LPVOID*)&file_info, &len)) {
+ free(version_info);
+ break;
+ }
+ majorVersion = HIWORD(file_info->dwProductVersionMS);
+ minorVersion = LOWORD(file_info->dwProductVersionMS);
+ free(version_info);
+ } while (0);
/*
* From msdn page on OSVERSIONINFOEX, current as of this
@@ -423,17 +467,15 @@
* Windows Server 2008 R2 6 1 (!VER_NT_WORKSTATION)
* Windows 8 6 2 (VER_NT_WORKSTATION)
* Windows Server 2012 6 2 (!VER_NT_WORKSTATION)
+ * Windows 10 10 0 (VER_NT_WORKSTATION)
*
* This mapping will presumably be augmented as new Windows
* versions are released.
*/
- switch (ver.dwPlatformId) {
- case VER_PLATFORM_WIN32s:
- sprops.os_name = "Windows 3.1";
- break;
+ switch (platformId) {
case VER_PLATFORM_WIN32_WINDOWS:
- if (ver.dwMajorVersion == 4) {
- switch (ver.dwMinorVersion) {
+ if (majorVersion == 4) {
+ switch (minorVersion) {
case 0: sprops.os_name = "Windows 95"; break;
case 10: sprops.os_name = "Windows 98"; break;
case 90: sprops.os_name = "Windows Me"; break;
@@ -444,10 +486,10 @@
}
break;
case VER_PLATFORM_WIN32_NT:
- if (ver.dwMajorVersion <= 4) {
+ if (majorVersion <= 4) {
sprops.os_name = "Windows NT";
- } else if (ver.dwMajorVersion == 5) {
- switch (ver.dwMinorVersion) {
+ } else if (majorVersion == 5) {
+ switch (minorVersion) {
case 0: sprops.os_name = "Windows 2000"; break;
case 1: sprops.os_name = "Windows XP"; break;
case 2:
@@ -462,8 +504,7 @@
* If it is, the operating system is Windows XP 64 bit;
* otherwise, it is Windows Server 2003."
*/
- if(ver.wProductType == VER_NT_WORKSTATION &&
- si.wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64) {
+ if (is_workstation && is_64bit) {
sprops.os_name = "Windows XP"; /* 64 bit */
} else {
sprops.os_name = "Windows 2003";
@@ -471,12 +512,12 @@
break;
default: sprops.os_name = "Windows NT (unknown)"; break;
}
- } else if (ver.dwMajorVersion == 6) {
+ } else if (majorVersion == 6) {
/*
* See table in MSDN OSVERSIONINFOEX documentation.
*/
- if (ver.wProductType == VER_NT_WORKSTATION) {
- switch (ver.dwMinorVersion) {
+ if (is_workstation) {
+ switch (minorVersion) {
case 0: sprops.os_name = "Windows Vista"; break;
case 1: sprops.os_name = "Windows 7"; break;
case 2: sprops.os_name = "Windows 8"; break;
@@ -484,7 +525,7 @@
default: sprops.os_name = "Windows NT (unknown)";
}
} else {
- switch (ver.dwMinorVersion) {
+ switch (minorVersion) {
case 0: sprops.os_name = "Windows Server 2008"; break;
case 1: sprops.os_name = "Windows Server 2008 R2"; break;
case 2: sprops.os_name = "Windows Server 2012"; break;
@@ -492,6 +533,17 @@
default: sprops.os_name = "Windows NT (unknown)";
}
}
+ } else if (majorVersion == 10) {
+ if (is_workstation) {
+ switch (minorVersion) {
+ case 0: sprops.os_name = "Windows 10"; break;
+ default: sprops.os_name = "Windows NT (unknown)";
+ }
+ } else {
+ switch (minorVersion) {
+ default: sprops.os_name = "Windows NT (unknown)";
+ }
+ }
} else {
sprops.os_name = "Windows NT (unknown)";
}
@@ -500,7 +552,7 @@
sprops.os_name = "Windows (unknown)";
break;
}
- sprintf(buf, "%d.%d", ver.dwMajorVersion, ver.dwMinorVersion);
+ sprintf(buf, "%d.%d", majorVersion, minorVersion);
sprops.os_version = _strdup(buf);
#if _M_IA64
sprops.os_arch = "ia64";
@@ -511,9 +563,6 @@
#else
sprops.os_arch = "unknown";
#endif
-
- sprops.patch_level = _strdup(ver.szCSDVersion);
-
sprops.desktop = "windows";
}
@@ -624,7 +673,7 @@
&display_encoding);
sprops.sun_jnu_encoding = getEncodingInternal(systemDefaultLCID);
- if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && ver.dwMajorVersion == 6) {
+ if (LANGIDFROMLCID(userDefaultLCID) == 0x0c04 && majorVersion == 6) {
// MS claims "Vista has built-in support for HKSCS-2004.
// All of the HKSCS-2004 characters have Unicode 4.1.
// PUA code point assignments". But what it really means
--- a/jdk/test/java/lang/ProcessHandle/OnExitTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/ProcessHandle/OnExitTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -26,21 +26,17 @@
import java.time.Duration;
import java.time.Instant;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
-import java.util.stream.Collectors;
-import jdk.testlibrary.Platform;
import org.testng.annotations.Test;
import org.testng.Assert;
import org.testng.TestNG;
/*
* @test
- * @library /lib/testlibrary
* @summary Functions of Process.onExit and ProcessHandle.onExit
* @author Roger Riggs
*/
--- a/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageAccess.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 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
@@ -29,12 +29,9 @@
* @run main/othervm CheckPackageAccess
*/
-import java.security.Security;
import java.util.Collections;
-import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
-import java.util.StringTokenizer;
/*
* The main benefit of this test is to catch merge errors or other types
@@ -44,60 +41,12 @@
*/
public class CheckPackageAccess {
- /*
- * This array should be updated whenever new packages are added to the
- * package.access property in the java.security file
- * NOTE: it should be in the same order as the java.security file
- */
- private static final String[] packages = {
- "sun.",
- "com.sun.xml.internal.",
- "com.sun.imageio.",
- "com.sun.istack.internal.",
- "com.sun.jmx.",
- "com.sun.media.sound.",
- "com.sun.naming.internal.",
- "com.sun.proxy.",
- "com.sun.corba.se.",
- "com.sun.org.apache.bcel.internal.",
- "com.sun.org.apache.regexp.internal.",
- "com.sun.org.apache.xerces.internal.",
- "com.sun.org.apache.xpath.internal.",
- "com.sun.org.apache.xalan.internal.extensions.",
- "com.sun.org.apache.xalan.internal.lib.",
- "com.sun.org.apache.xalan.internal.res.",
- "com.sun.org.apache.xalan.internal.templates.",
- "com.sun.org.apache.xalan.internal.utils.",
- "com.sun.org.apache.xalan.internal.xslt.",
- "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
- "com.sun.org.apache.xalan.internal.xsltc.compiler.",
- "com.sun.org.apache.xalan.internal.xsltc.trax.",
- "com.sun.org.apache.xalan.internal.xsltc.util.",
- "com.sun.org.apache.xml.internal.res.",
- "com.sun.org.apache.xml.internal.security.",
- "com.sun.org.apache.xml.internal.serializer.utils.",
- "com.sun.org.apache.xml.internal.utils.",
- "com.sun.org.glassfish.",
- "com.sun.tools.script.",
- "com.oracle.xmlns.internal.",
- "com.oracle.webservices.internal.",
- "org.jcp.xml.dsig.internal.",
- "jdk.internal.",
- "jdk.nashorn.internal.",
- "jdk.nashorn.tools.",
- "jdk.tools.jimage.",
- "com.sun.activation.registries."
- };
+ public static void main(String[] args) throws Exception {
+ // get expected list of restricted packages
+ List<String> pkgs = RestrictedPackages.expected();
- public static void main(String[] args) throws Exception {
- List<String> pkgs = new ArrayList<>(Arrays.asList(packages));
- String osName = System.getProperty("os.name");
- if (osName.contains("OS X")) {
- pkgs.add("apple."); // add apple package for OS X
- }
-
- List<String> jspkgs =
- getPackages(Security.getProperty("package.access"));
+ // get actual list of restricted packages
+ List<String> jspkgs = RestrictedPackages.actual();
if (!isOpenJDKOnly()) {
String lastPkg = pkgs.get(pkgs.size() - 1);
@@ -127,7 +76,7 @@
}
System.setSecurityManager(new SecurityManager());
SecurityManager sm = System.getSecurityManager();
- for (String pkg : packages) {
+ for (String pkg : pkgs) {
String subpkg = pkg + "foo";
try {
sm.checkPackageAccess(pkg);
@@ -153,18 +102,6 @@
System.out.println("Test passed");
}
- private static List<String> getPackages(String p) {
- List<String> packages = new ArrayList<>();
- if (p != null && !p.equals("")) {
- StringTokenizer tok = new StringTokenizer(p, ",");
- while (tok.hasMoreElements()) {
- String s = tok.nextToken().trim();
- packages.add(s);
- }
- }
- return packages;
- }
-
private static boolean isOpenJDKOnly() {
String prop = System.getProperty("java.runtime.name");
return prop != null && prop.startsWith("OpenJDK");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/SecurityManager/CheckPackageMatching.java Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,545 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8072692
+ * @summary Check the matching implemented by SecurityManager.checkPackageAccess
+ * @run main/othervm CheckPackageMatching
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+/*
+ * The purpose of this test is not to verify the content of the package
+ * access list - but to ensure that the matching implemented by the
+ * SecurityManager is correct. This is why we have our own pattern matching
+ * algorithm here.
+ */
+public class CheckPackageMatching {
+
+ /**
+ * The restricted packages listed in the package.access property of the
+ * java.security file.
+ */
+ private static final String[] packages =
+ RestrictedPackages.actual().toArray(new String[0]);
+
+ private static final boolean OPEN_JDK = isOpenJDKOnly();
+
+ /**
+ * PackageMatcher implements a state machine that matches package
+ * names against packages parsed from the package access list.
+ */
+ private static abstract class PackageMatcher {
+ // For each state, chars[state] contains the chars that matches.
+ private final char[][] chars;
+ // For each state, states[state][i] contains the next state to go
+ // to when chars[state][i] matches the current character.
+ private final int[][] states;
+
+ // Some markers. We're making the assumption that 0
+ // cannot be a valid character for a package name.
+ //
+ // We use 0 for marking that we expect an end of string in
+ // char[state][i].
+ private static final char END_OF_STRING = 0;
+ // This special state value indicates that we expect the string to end
+ // there.
+ private static final int END_STATE = -1;
+ // This special state value indicates that we can accept any character
+ // from now on.
+ private static final int WILDCARD_STATE = Integer.MIN_VALUE;
+
+ // Create the data for a new state machine to match package names from
+ // the array of package names passed as argument.
+ // Each package name in the array is expected to end with '.'
+ // For each package in packages we're going to compile state data
+ // that will match the regexp:
+ // ^packages[i].substring(0, packages[i].length()-1).replace(".","\\.")$|^packages[i].replace(".","\\.").*
+ //
+ // Let's say the package array is:
+ //
+ // String[] packages = { "sun.", "com.sun.jmx.", "com.sun.proxy.",
+ // "apple." };
+ //
+ // then the state machine will need data that looks like:
+ //
+ // char[][] chars = {
+ // { 'a', 'c', 's' }, { 'p' }, { 'p' }, { 'l' }, { 'e' }, { 0, '.' },
+ // { 'o' }, { 'm' }, { '.' }, { 's' }, { 'u' }, { 'n' }, { '.' },
+ // { 'j', 'p'},
+ // { 'm' }, { 'x' }, { 0, '.' },
+ // { 'r' }, { 'o' }, { 'x' }, { 'y' }, { 0, '.' },
+ // { 'u' }, { 'n' }, { 0, '.' }
+ // }
+ // int[][] states = {
+ // { 1, 6, 22 }, { 2 }, { 3 }, { 4 }, { 5 },
+ // { END_STATE, WILDCARD_STATE },
+ // { 7 }, { 8 }, { 9 }, { 10 }, { 11 }, { 12 }, { 13 }, { 14, 17 },
+ // { 15 }, { 16 }, { END_STATE, WILDCARD_STATE },
+ // { 18 }, { 19 }, { 20 }, { 21 }, { END_STATE, WILDCARD_STATE },
+ // { 23 }, { 24 }, { END_STATE, WILDCARD_STATE }
+ // }
+ //
+ // The machine will start by loading the chars and states for state 0
+ // chars[0] => { 'a', 'c', 's' } states[0] => { 1, 6, 22 }
+ // then it examines the char at index 0 in the candidate name.
+ // if the char matches one of the characters in chars[0], then it goes
+ // to the corresponding state in states[0]. For instance - if the first
+ // char in the candidate name is 's', which corresponds to chars[0][2] -
+ // then it will proceed with the next char in the candidate name and go
+ // to state 22 (as indicated by states[0][2]) - where it will load the
+ // chars and states for states 22: chars[22] = { 'u' },
+ // states[22] = { 23 } etc... until the candidate char at the current
+ // index matches no char in chars[states] => the candidate name doesn't
+ // match - or until it finds a success termination condition: the
+ // candidate chars are exhausted and states[state][0] is END_STATE, or
+ // the candidate chars are not exhausted - and
+ // states[state][chars[state]] is WILDCARD_STATE indicating a '.*' like
+ // regexp.
+ //
+ // [Note that the chars in chars[i] are sorted]
+ //
+ // The compile(...) method is reponsible for building the state machine
+ // data and is called only once in the constructor.
+ //
+ // The matches(String candidate) method will tell whether the candidate
+ // matches by implementing the algorithm described above.
+ //
+ PackageMatcher(String[] packages) {
+ final boolean[] selected = new boolean[packages.length];
+ Arrays.fill(selected, true);
+ final ArrayList<char[]> charList = new ArrayList<>();
+ final ArrayList<int[]> stateList = new ArrayList<>();
+ compile(0, 0, packages, selected, charList, stateList);
+ chars = charList.toArray(new char[0][0]);
+ states = stateList.toArray(new int[0][0]);
+ }
+
+ /**
+ * Compiles the state machine data (recursive).
+ *
+ * @param step The index of the character which we're looking at in
+ * this step.
+ * @param state The current state (starts at 0).
+ * @param pkgs The list of packages from which the automaton is built.
+ * @param selected Indicates which packages we're looking at in this
+ step.
+ * @param charList The list from which we will build
+ {@code char[][] chars;}
+ * @param stateList The list from which we will build
+ {@code int[][] states;}
+ * @return the next available state.
+ */
+ private int compile(int step, int state, String[] pkgs,
+ boolean[] selected, ArrayList<char[]> charList,
+ ArrayList<int[]> stateList) {
+ final char[] next = new char[pkgs.length];
+ final int[] nexti = new int[pkgs.length];
+ int j = 0;
+ char min = Character.MAX_VALUE; char max = 0;
+ for (int i = 0; i < pkgs.length; i++) {
+ if (!selected[i]) continue;
+ final String p = pkgs[i];
+ final int len = p.length();
+ if (step > len) {
+ selected[i] = false;
+ continue;
+ }
+ if (len - 1 == step) {
+ boolean unknown = true;
+ for (int k = 0; k < j ; k++) {
+ if (next[k] == END_OF_STRING) {
+ unknown = false;
+ break;
+ }
+ }
+ if (unknown) {
+ next[j] = END_OF_STRING;
+ j++;
+ }
+ nexti[i] = END_STATE;
+ }
+ final char c = p.charAt(step);
+ nexti[i] = len - 1 == step ? END_STATE : c;
+ boolean unknown = j == 0 || c < min || c > max;
+ if (!unknown) {
+ if (c != min || c != max) {
+ unknown = true;
+ for (int k = 0; k < j ; k++) {
+ if (next[k] == c) {
+ unknown = false;
+ break;
+ }
+ }
+ }
+ }
+ if (unknown) {
+ min = min > c ? c : min;
+ max = max < c ? c : max;
+ next[j] = c;
+ j++;
+ }
+ }
+ final char[] nc = new char[j];
+ final int[] nst = new int[j];
+ System.arraycopy(next, 0, nc, 0, nc.length);
+ Arrays.sort(nc);
+ final boolean ns[] = new boolean[pkgs.length];
+
+ charList.ensureCapacity(state + 1);
+ stateList.ensureCapacity(state + 1);
+ charList.add(state, nc);
+ stateList.add(state, nst);
+ state = state + 1;
+ for (int k = 0; k < nc.length; k++) {
+ int selectedCount = 0;
+ boolean endStateFound = false;
+ boolean wildcardFound = false;
+ for (int l = 0; l < nexti.length; l++) {
+ if (!(ns[l] = selected[l])) {
+ continue;
+ }
+ ns[l] = nexti[l] == nc[k] || nexti[l] == END_STATE
+ && nc[k] == '.';
+ endStateFound = endStateFound || nc[k] == END_OF_STRING
+ && nexti[l] == END_STATE;
+ wildcardFound = wildcardFound || nc[k] == '.'
+ && nexti[l] == END_STATE;
+ if (ns[l]) {
+ selectedCount++;
+ }
+ }
+ nst[k] = (endStateFound ? END_STATE
+ : wildcardFound ? WILDCARD_STATE : state);
+ if (selectedCount == 0 || wildcardFound) {
+ continue;
+ }
+ state = compile(step + 1, state, pkgs, ns, charList, stateList);
+ }
+ return state;
+ }
+
+ /**
+ * Matches 'pkg' against the list of package names compiled in the
+ * state machine data.
+ *
+ * @param pkg The package name to match. Must not end with '.'.
+ * @return true if the package name matches, false otherwise.
+ */
+ public boolean matches(String pkg) {
+ int state = 0;
+ int i;
+ final int len = pkg.length();
+ next: for (i = 0; i <= len; i++) {
+ if (state == WILDCARD_STATE) {
+ return true; // all characters will match.
+ }
+ if (state == END_STATE) {
+ return i == len;
+ }
+ final char[] ch = chars[state];
+ final int[] st = states[state];
+ if (i == len) {
+ // matches only if we have exhausted the string.
+ return st[0] == END_STATE;
+ }
+ if (st[0] == END_STATE && st.length == 1) {
+ // matches only if we have exhausted the string.
+ return i == len;
+ }
+ final char c = pkg.charAt(i); // look at next char...
+ for (int j = st[0] == END_STATE ? 1 : 0; j < ch.length; j++) {
+ final char n = ch[j];
+ if (c == n) { // found a match
+ state = st[j]; // get the next state.
+ continue next; // go to next state
+ } else if (c < n) {
+ break; // chars are sorted. we won't find it. no match.
+ }
+ }
+ break; // no match
+ }
+ return false;
+ }
+ }
+
+ private static final class TestPackageMatcher extends PackageMatcher {
+ private final List<String> list;
+
+ TestPackageMatcher(String[] packages) {
+ super(packages);
+ this.list = Collections.unmodifiableList(Arrays.asList(packages));
+ }
+
+ @Override
+ public boolean matches(String pkg) {
+ final boolean match1 = super.matches(pkg);
+ boolean match2 = false;
+ String p2 = pkg + ".";
+ for (String p : list) {
+ if (pkg.startsWith(p) || p2.equals(p)) {
+ match2 = true;
+ break;
+ }
+ }
+ if (match1 != match2) {
+ System.err.println("Test Bug: PackageMatcher.matches(\"" +
+ pkg + "\") returned " + match1);
+ System.err.println("Package Access List is: " + list);
+ throw new Error("Test Bug: PackageMatcher.matches(\"" +
+ pkg + "\") returned " + match1);
+ }
+ return match1;
+ }
+ }
+
+ private static void smokeTest() {
+ // these checks should pass.
+ System.getSecurityManager().checkPackageAccess("com.sun.blah");
+ System.getSecurityManager().checkPackageAccess("com.sun.jm");
+ System.getSecurityManager().checkPackageAccess("com.sun.jmxa");
+ System.getSecurityManager().checkPackageAccess("jmx");
+ List<String> actual = Arrays.asList(packages);
+ for (String p : actual) {
+ if (!actual.contains(p)) {
+ System.err.println("Warning: '" + p + " not in package.access");
+ }
+ }
+ if (!actual.contains("sun.")) {
+ throw new Error("package.access does not contain 'sun.'");
+ }
+ }
+
+ // This is a sanity test for our own test code.
+ private static void testTheTest(String[] pkgs, char[][] chars,
+ int[][] states) {
+
+ PackageMatcher m = new TestPackageMatcher(pkgs);
+ String unexpected = "";
+ if (!Arrays.deepEquals(chars, m.chars)) {
+ System.err.println("Char arrays differ");
+ if (chars.length != m.chars.length) {
+ System.err.println("Char array lengths differ: expected="
+ + chars.length + " actual=" + m.chars.length);
+ }
+ System.err.println(Arrays.deepToString(m.chars).replace((char)0,
+ '0'));
+ unexpected = "chars[]";
+ }
+ if (!Arrays.deepEquals(states, m.states)) {
+ System.err.println("State arrays differ");
+ if (states.length != m.states.length) {
+ System.err.println("Char array lengths differ: expected="
+ + states.length + " actual=" + m.states.length);
+ }
+ System.err.println(Arrays.deepToString(m.states));
+ if (unexpected.length() > 0) {
+ unexpected = unexpected + " and ";
+ }
+ unexpected = unexpected + "states[]";
+ }
+
+ if (unexpected.length() > 0) {
+ throw new Error("Unexpected "+unexpected+" in PackageMatcher");
+ }
+
+ testMatches(m, pkgs);
+ }
+
+ // This is a sanity test for our own test code.
+ private static void testTheTest() {
+ final String[] packages2 = { "sun.", "com.sun.jmx.",
+ "com.sun.proxy.", "apple." };
+
+ final int END_STATE = PackageMatcher.END_STATE;
+ final int WILDCARD_STATE = PackageMatcher.WILDCARD_STATE;
+
+ final char[][] chars2 = {
+ { 'a', 'c', 's' }, { 'p' }, { 'p' }, { 'l' }, { 'e' }, { 0, '.' },
+ { 'o' }, { 'm' }, { '.' }, { 's' }, { 'u' }, { 'n' }, { '.' },
+ { 'j', 'p'},
+ { 'm' }, { 'x' }, { 0, '.' },
+ { 'r' }, { 'o' }, { 'x' }, { 'y' }, { 0, '.' },
+ { 'u' }, { 'n' }, { 0, '.' }
+ };
+
+ final int[][] states2 = {
+ { 1, 6, 22 }, { 2 }, { 3 }, { 4 }, { 5 },
+ { END_STATE, WILDCARD_STATE },
+ { 7 }, { 8 }, { 9 }, { 10 }, { 11 }, { 12 }, { 13 }, { 14, 17 },
+ { 15 }, { 16 }, { END_STATE, WILDCARD_STATE },
+ { 18 }, { 19 }, { 20 }, { 21 }, { END_STATE, WILDCARD_STATE },
+ { 23 }, { 24 }, { END_STATE, WILDCARD_STATE }
+ };
+
+ testTheTest(packages2, chars2, states2);
+
+ final String[] packages3 = { "sun.", "com.sun.pro.",
+ "com.sun.proxy.", "apple." };
+
+ final char[][] chars3 = {
+ { 'a', 'c', 's' }, { 'p' }, { 'p' }, { 'l' }, { 'e' }, { 0, '.' },
+ { 'o' }, { 'm' }, { '.' }, { 's' }, { 'u' }, { 'n' }, { '.' },
+ { 'p' }, { 'r' }, { 'o' }, { 0, '.', 'x' },
+ { 'y' }, { 0, '.' },
+ { 'u' }, { 'n' }, { 0, '.' }
+ };
+
+ final int[][] states3 = {
+ { 1, 6, 19 }, { 2 }, { 3 }, { 4 }, { 5 },
+ { END_STATE, WILDCARD_STATE },
+ { 7 }, { 8 }, { 9 }, { 10 }, { 11 }, { 12 }, { 13 }, { 14 },
+ { 15 }, { 16 }, { END_STATE, WILDCARD_STATE, 17 },
+ { 18 }, { END_STATE, WILDCARD_STATE },
+ { 20 }, { 21 }, { END_STATE, WILDCARD_STATE }
+ };
+
+ testTheTest(packages3, chars3, states3);
+ }
+
+ private static volatile boolean sanityTesting = false;
+
+ public static void main(String[] args) {
+ System.setSecurityManager(new SecurityManager());
+
+ // Some smoke tests.
+ smokeTest();
+ System.out.println("Smoke tests passed.");
+
+ // Test our own pattern matching algorithm. Here we actually test
+ // the PackageMatcher class from our own test code.
+ sanityTesting = true;
+ try {
+ testTheTest();
+ System.out.println("Sanity tests passed.");
+ } finally {
+ sanityTesting = false;
+ }
+
+ // Now test the package matching in the security manager.
+ PackageMatcher matcher = new TestPackageMatcher(packages);
+
+ // These should not match.
+ for (String pkg : new String[] {"gloups.machin", "su",
+ "org.jcp.xml.dsig.interna",
+ "com.sun.jm", "com.sun.jmxa"}) {
+ testMatch(matcher, pkg, false, true);
+ }
+
+ // These should match.
+ for (String pkg : Arrays.asList(
+ new String[] {"sun.gloups.machin", "sun", "sun.com",
+ "com.sun.jmx", "com.sun.jmx.a",
+ "org.jcp.xml.dsig.internal",
+ "org.jcp.xml.dsig.internal.foo"})) {
+ testMatch(matcher, pkg, true, true);
+ }
+
+ // Derive a list of packages that should match or not match from
+ // the list in 'packages' - and check that the security manager
+ // throws the appropriate exception.
+ testMatches(matcher, packages);
+ }
+
+ private static void testMatches(PackageMatcher matcher, String[] pkgs) {
+ Collection<String> pkglist = Arrays.asList(pkgs);
+ PackageMatcher ref = new TestPackageMatcher(packages);
+
+ for (String pkg : pkgs) {
+ String candidate = pkg + "toto";
+ boolean expected = true;
+ testMatch(matcher, candidate, expected,
+ ref.matches(candidate) == expected);
+ }
+
+ for (String pkg : pkgs) {
+ String candidate = pkg.substring(0, pkg.length() - 1);
+ boolean expected = pkglist.contains(candidate + ".");
+ testMatch(matcher, candidate, expected,
+ ref.matches(candidate) == expected);
+ }
+
+ for (String pkg : pkgs) {
+ if (!OPEN_JDK && pkg.equals("com.sun.media.sound.")) {
+ // don't test com.sun.media.sound since there is an entry
+ // for com.sun.media in non OpenJDK builds. Otherwise,
+ // the test for this package will fail unexpectedly.
+ continue;
+ }
+ String candidate = pkg.substring(0, pkg.length() - 2);
+ boolean expected = pkglist.contains(candidate + ".");
+ testMatch(matcher, candidate, expected,
+ ref.matches(candidate) == expected);
+ }
+ }
+
+ private static void testMatch(PackageMatcher matcher, String candidate,
+ boolean expected, boolean testSecurityManager)
+ {
+ final boolean m = matcher.matches(candidate);
+ if (m != expected) {
+ final String msg = "\"" + candidate + "\": " +
+ (m ? "matches" : "does not match");
+ throw new Error("PackageMatcher does not give expected results: "
+ + msg);
+ }
+
+ if (sanityTesting) {
+ testSecurityManager = false;
+ }
+
+ if (testSecurityManager) {
+ System.out.println("Access to " + candidate + " should be " +
+ (expected ? "rejected" : "granted"));
+ final String errormsg = "\"" + candidate + "\" : " +
+ (expected ? "granted" : "not granted");
+ try {
+ System.getSecurityManager().checkPackageAccess(candidate);
+ if (expected) {
+ System.err.println(errormsg);
+ throw new Error("Expected exception not thrown: " +
+ errormsg);
+ }
+ } catch (SecurityException x) {
+ if (!expected) {
+ System.err.println(errormsg);
+ throw new Error(errormsg + " - unexpected exception: " +
+ x, x);
+ } else {
+ System.out.println("Got expected exception: " + x);
+ }
+ }
+ }
+ }
+
+ private static boolean isOpenJDKOnly() {
+ String prop = System.getProperty("java.runtime.name");
+ return prop != null && prop.startsWith("OpenJDK");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/SecurityManager/RestrictedPackages.java Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,150 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+import java.security.Security;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * A collection of utility methods and constants for testing the package
+ * access and package definition security checks.
+ */
+final class RestrictedPackages {
+
+ /*
+ * The expected list of restricted packages.
+ *
+ * This array should be updated whenever new packages are added to the
+ * package.access property in the java.security file
+ * NOTE: it should be in the same order as the java.security file
+ */
+ static final String[] EXPECTED = {
+ "sun.",
+ "com.sun.xml.internal.",
+ "com.sun.imageio.",
+ "com.sun.istack.internal.",
+ "com.sun.jmx.",
+ "com.sun.media.sound.",
+ "com.sun.naming.internal.",
+ "com.sun.proxy.",
+ "com.sun.corba.se.",
+ "com.sun.org.apache.bcel.internal.",
+ "com.sun.org.apache.regexp.internal.",
+ "com.sun.org.apache.xerces.internal.",
+ "com.sun.org.apache.xpath.internal.",
+ "com.sun.org.apache.xalan.internal.extensions.",
+ "com.sun.org.apache.xalan.internal.lib.",
+ "com.sun.org.apache.xalan.internal.res.",
+ "com.sun.org.apache.xalan.internal.templates.",
+ "com.sun.org.apache.xalan.internal.utils.",
+ "com.sun.org.apache.xalan.internal.xslt.",
+ "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
+ "com.sun.org.apache.xalan.internal.xsltc.compiler.",
+ "com.sun.org.apache.xalan.internal.xsltc.trax.",
+ "com.sun.org.apache.xalan.internal.xsltc.util.",
+ "com.sun.org.apache.xml.internal.res.",
+ "com.sun.org.apache.xml.internal.security.",
+ "com.sun.org.apache.xml.internal.serializer.utils.",
+ "com.sun.org.apache.xml.internal.utils.",
+ "com.sun.org.glassfish.",
+ "com.sun.tools.script.",
+ "com.oracle.xmlns.internal.",
+ "com.oracle.webservices.internal.",
+ "org.jcp.xml.dsig.internal.",
+ "jdk.internal.",
+ "jdk.nashorn.internal.",
+ "jdk.nashorn.tools.",
+ "jdk.tools.jimage.",
+ "com.sun.activation.registries."
+ };
+
+ /*
+ * A non-exhaustive list of restricted packages.
+ *
+ * Contrary to what is in the EXPECTED list, this list does not need
+ * to be exhaustive.
+ */
+ static final String[] EXPECTED_NONEXHAUSTIVE = {
+ "sun.",
+ "com.sun.xml.internal.",
+ "com.sun.imageio.",
+ "com.sun.istack.internal.",
+ "com.sun.jmx.",
+ "com.sun.proxy.",
+ "com.sun.org.apache.bcel.internal.",
+ "com.sun.org.apache.regexp.internal.",
+ "com.sun.org.apache.xerces.internal.",
+ "com.sun.org.apache.xpath.internal.",
+ "com.sun.org.apache.xalan.internal.extensions.",
+ "com.sun.org.apache.xalan.internal.lib.",
+ "com.sun.org.apache.xalan.internal.res.",
+ "com.sun.org.apache.xalan.internal.templates.",
+ "com.sun.org.apache.xalan.internal.utils.",
+ "com.sun.org.apache.xalan.internal.xslt.",
+ "com.sun.org.apache.xalan.internal.xsltc.cmdline.",
+ "com.sun.org.apache.xalan.internal.xsltc.compiler.",
+ "com.sun.org.apache.xalan.internal.xsltc.trax.",
+ "com.sun.org.apache.xalan.internal.xsltc.util.",
+ "com.sun.org.apache.xml.internal.res.",
+ "com.sun.org.apache.xml.internal.serializer.utils.",
+ "com.sun.org.apache.xml.internal.utils.",
+ "com.sun.org.apache.xml.internal.security.",
+ "com.sun.org.glassfish.",
+ "org.jcp.xml.dsig.internal."
+ };
+
+ private static final String OS_NAME = System.getProperty("os.name");
+
+ /**
+ * Returns a list of expected restricted packages, including any
+ * OS specific packages. The returned list is mutable.
+ */
+ static List<String> expected() {
+ List<String> pkgs = new ArrayList<>(Arrays.asList(EXPECTED));
+ if (OS_NAME.contains("OS X")) {
+ pkgs.add("apple."); // add apple package for OS X
+ }
+ return pkgs;
+ }
+
+ /**
+ * Returns a list of actual restricted packages. The returned list
+ * is mutable.
+ */
+ static List<String> actual() {
+ String prop = Security.getProperty("package.access");
+ List<String> packages = new ArrayList<>();
+ if (prop != null && !prop.equals("")) {
+ StringTokenizer tok = new StringTokenizer(prop, ",");
+ while (tok.hasMoreElements()) {
+ String s = tok.nextToken().trim();
+ packages.add(s);
+ }
+ }
+ return packages;
+ }
+
+ private RestrictedPackages() { }
+}
--- a/jdk/test/java/lang/invoke/LFCaching/LFCachingTestCase.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/invoke/LFCaching/LFCachingTestCase.java Mon Jun 22 13:28:57 2015 -0700
@@ -77,7 +77,7 @@
}
} catch (IllegalAccessException | IllegalArgumentException |
SecurityException | InvocationTargetException ex) {
- throw new Error("Unexpected exception: ", ex);
+ throw new Error("Unexpected exception", ex);
}
}
}
--- a/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/invoke/LFCaching/LFGarbageCollectedTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -24,6 +24,7 @@
/*
* @test LFGarbageCollectedTest
* @bug 8046703
+ * @key randomness
* @ignore 8078602
* @summary Test verifies that lambda forms are garbage collected
* @author kshefov
@@ -73,7 +74,7 @@
try {
adapter = testCase.getTestCaseMH(data, TestMethods.Kind.ONE);
} catch (NoSuchMethodException ex) {
- throw new Error("Unexpected exception: ", ex);
+ throw new Error("Unexpected exception", ex);
}
mtype = adapter.type();
Object lambdaForm = INTERNAL_FORM.invoke(adapter);
@@ -94,7 +95,7 @@
collectLambdaForm();
} catch (IllegalAccessException | IllegalArgumentException |
InvocationTargetException ex) {
- throw new Error("Unexpected exception: ", ex);
+ throw new Error("Unexpected exception", ex);
}
}
--- a/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/invoke/LFCaching/LFMultiThreadCachingTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -24,6 +24,7 @@
/*
* @test LFMultiThreadCachingTest
* @bug 8046703
+ * @key randomness
* @summary Test verifies that lambda forms are cached when run with multiple threads
* @author kshefov
* @library /lib/testlibrary/jsr292 /lib/testlibrary
@@ -35,18 +36,23 @@
*/
import java.lang.invoke.MethodHandle;
+import java.util.Collections;
import java.util.EnumSet;
+import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.CyclicBarrier;
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
/**
* Multiple threaded lambda forms caching test class.
*/
public final class LFMultiThreadCachingTest extends LFCachingTestCase {
+
private static final TestMethods.Kind[] KINDS;
+
static {
EnumSet<TestMethods.Kind> set = EnumSet.complementOf(EnumSet.of(TestMethods.Kind.EXCEPT));
KINDS = set.toArray(new TestMethods.Kind[set.size()]);
@@ -72,21 +78,55 @@
ConcurrentLinkedQueue<MethodHandle> adapters = new ConcurrentLinkedQueue<>();
CyclicBarrier begin = new CyclicBarrier(CORES);
CountDownLatch end = new CountDownLatch(CORES);
+ final Map<Thread, Throwable> threadUncaughtExceptions
+ = Collections.synchronizedMap(new HashMap<Thread, Throwable>(CORES));
+ Thread.UncaughtExceptionHandler exHandler = (t, e) -> {
+ threadUncaughtExceptions.put(t, e);
+ };
for (int i = 0; i < CORES; ++i) {
TestMethods.Kind kind = KINDS[i % KINDS.length];
- new Thread(() -> {
+ Thread t = new Thread(() -> {
try {
begin.await();
adapters.add(getTestMethod().getTestCaseMH(data, kind));
- } catch (InterruptedException | BrokenBarrierException | IllegalAccessException | NoSuchMethodException ex) {
- throw new Error("Unexpected exception: ", ex);
+ } catch (InterruptedException | BrokenBarrierException
+ | IllegalAccessException | NoSuchMethodException ex) {
+ throw new Error("Unexpected exception", ex);
} finally {
end.countDown();
}
- }).start();
+ });
+ t.setUncaughtExceptionHandler(exHandler);
+ t.start();
}
try {
end.await();
+ boolean vmeThrown = false;
+ boolean nonVmeThrown = false;
+ Throwable vme = null;
+ for (Map.Entry<Thread,
+ Throwable> entry : threadUncaughtExceptions.entrySet()) {
+ Thread t = entry.getKey();
+ Throwable e = entry.getValue();
+ System.err.printf("%nA thread with name \"%s\" of %d threads"
+ + " has thrown exception:%n", t.getName(), CORES);
+ e.printStackTrace();
+ if (CodeCacheOverflowProcessor.isThrowableCausedByVME(e)) {
+ vmeThrown = true;
+ vme = e;
+ } else {
+ nonVmeThrown = true;
+ }
+ if (nonVmeThrown) {
+ throw new Error("One ore more threads have"
+ + " thrown unexpected exceptions. See log.");
+ }
+ if (vmeThrown) {
+ throw new Error("One ore more threads have"
+ + " thrown VirtualMachineError caused by"
+ + " code cache overflow. See log.", vme);
+ }
+ }
} catch (InterruptedException ex) {
throw new Error("Unexpected exception: ", ex);
}
--- a/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/invoke/LFCaching/LFSingleThreadCachingTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -24,6 +24,7 @@
/*
* @test LFSingleThreadCachingTest
* @bug 8046703
+ * @key randomness
* @summary Test verifies that lambda forms are cached when run with single thread
* @author kshefov
* @library /lib/testlibrary/jsr292 /lib/testlibrary
@@ -62,7 +63,7 @@
adapter1 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.ONE);
adapter2 = getTestMethod().getTestCaseMH(data, TestMethods.Kind.TWO);
} catch (NoSuchMethodException | IllegalAccessException ex) {
- throw new Error("Unexpected exception: ", ex);
+ throw new Error("Unexpected exception", ex);
}
checkLFCaching(adapter1, adapter2);
}
--- a/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/invoke/LFCaching/LambdaFormTestCase.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -22,7 +22,7 @@
*/
import com.oracle.testlibrary.jsr292.Helper;
-import com.sun.management.HotSpotDiagnosticMXBean;
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
import java.lang.invoke.MethodHandle;
import java.lang.management.GarbageCollectorMXBean;
import java.lang.management.ManagementFactory;
@@ -44,8 +44,6 @@
*/
public abstract class LambdaFormTestCase {
- private static final double ITERATIONS_TO_CODE_CACHE_SIZE_RATIO
- = 45 / (128.0 * 1024 * 1024);
private static final long TIMEOUT = Helper.IS_THOROUGH ? 0L : (long) (Utils.adjustTimeout(Utils.DEFAULT_TEST_TIMEOUT) * 0.9);
/**
@@ -72,7 +70,7 @@
REF_FIELD = Reference.class.getDeclaredField("referent");
REF_FIELD.setAccessible(true);
} catch (Exception ex) {
- throw new Error("Unexpected exception: ", ex);
+ throw new Error("Unexpected exception", ex);
}
gcInfo = ManagementFactory.getGarbageCollectorMXBeans();
@@ -101,28 +99,6 @@
long iterations = Math.max(1, Helper.TEST_LIMIT / testCaseNum);
System.out.printf("Number of iterations according to -DtestLimit is %d (%d cases)%n",
iterations, iterations * testCaseNum);
- HotSpotDiagnosticMXBean hsDiagBean = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
- long codeCacheSize = Long.parseLong(
- hsDiagBean.getVMOption("ReservedCodeCacheSize").getValue());
- System.out.printf("Code cache size is %d bytes%n", codeCacheSize);
- long iterationsByCodeCacheSize = (long) (codeCacheSize
- * ITERATIONS_TO_CODE_CACHE_SIZE_RATIO);
- long nonProfiledCodeCacheSize = Long.parseLong(
- hsDiagBean.getVMOption("NonProfiledCodeHeapSize").getValue());
- System.out.printf("Non-profiled code cache size is %d bytes%n", nonProfiledCodeCacheSize);
- long iterationsByNonProfiledCodeCacheSize = (long) (nonProfiledCodeCacheSize
- * ITERATIONS_TO_CODE_CACHE_SIZE_RATIO);
- System.out.printf("Number of iterations limited by code cache size is %d (%d cases)%n",
- iterationsByCodeCacheSize, iterationsByCodeCacheSize * testCaseNum);
- System.out.printf("Number of iterations limited by non-profiled code cache size is %d (%d cases)%n",
- iterationsByNonProfiledCodeCacheSize, iterationsByNonProfiledCodeCacheSize * testCaseNum);
- iterations = Math.min(iterationsByCodeCacheSize,
- Math.min(iterations, iterationsByNonProfiledCodeCacheSize));
- if (iterations == 0) {
- System.out.println("Warning: code cache size is too small to provide at"
- + " least one iteration! Test will try to do one iteration.");
- iterations = 1;
- }
System.out.printf("Number of iterations is set to %d (%d cases)%n",
iterations, iterations * testCaseNum);
System.out.flush();
@@ -141,22 +117,27 @@
for (TestMethods testMethod : testMethods) {
LambdaFormTestCase testCase = ctor.apply(testMethod);
try {
- System.err.printf("Tested LF caching feature with MethodHandles.%s method.%n",
+ System.err.printf("Tested LF caching feature"
+ + " with MethodHandles.%s method.%n",
testCase.getTestMethod().name);
- testCase.doTest();
+ Throwable t = CodeCacheOverflowProcessor
+ .runMHTest(testCase::doTest);
+ if (t != null) {
+ return false;
+ }
System.err.println("PASSED");
- } catch (OutOfMemoryError e) {
+ } catch (OutOfMemoryError oome) {
// Don't swallow OOME so a heap dump can be created.
System.err.println("FAILED");
- throw e;
+ throw oome;
} catch (Throwable t) {
t.printStackTrace();
System.err.printf("FAILED. Caused by %s%n", t.getMessage());
passed = false;
failCounter++;
}
- testCounter++;
- }
+ testCounter++;
+ }
doneIterations++;
return true;
}
@@ -205,8 +186,8 @@
* @param testMethods list of test methods
*/
public static void runTests(Function<TestMethods, LambdaFormTestCase> ctor, Collection<TestMethods> testMethods) {
- LambdaFormTestCase.TestRun run =
- new LambdaFormTestCase.TestRun(ctor, testMethods);
+ LambdaFormTestCase.TestRun run
+ = new LambdaFormTestCase.TestRun(ctor, testMethods);
TimeLimitedRunner runner = new TimeLimitedRunner(TIMEOUT, 4.0d, run::doIteration);
try {
runner.call();
--- a/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/invoke/MethodHandles/CatchExceptionTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -23,6 +23,7 @@
package test.java.lang.invoke.MethodHandles;
import com.oracle.testlibrary.jsr292.Helper;
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
import jdk.testlibrary.Asserts;
import jdk.testlibrary.TimeLimitedRunner;
import jdk.testlibrary.Utils;
@@ -35,7 +36,6 @@
import java.util.function.BiFunction;
import java.util.function.Function;
import java.util.function.Supplier;
-import java.util.concurrent.TimeUnit;
/* @test
* @library /lib/testlibrary/jsr292 /lib/testlibrary/
@@ -91,6 +91,10 @@
}
public static void main(String[] args) throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(CatchExceptionTest::test);
+ }
+
+ public static void test() throws Throwable {
System.out.println("classes = " + ARGS_CLASSES);
TestFactory factory = new TestFactory();
@@ -116,7 +120,6 @@
return Helper.getParams(ARGS_CLASSES, isVararg, argsCount);
}
-
private List<Class<?>> getCatcherParams() {
int catchArgc = 1 + this.argsCount - dropped;
List<Class<?>> result = new ArrayList<>(
--- a/jdk/test/java/lang/invoke/MethodHandlesTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/invoke/MethodHandlesTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 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
@@ -23,6 +23,7 @@
/* @test
* @summary unit tests for java.lang.invoke.MethodHandles
+ * @library /lib/testlibrary /lib/testlibrary/jsr292
* @compile MethodHandlesTest.java remote/RemoteExample.java
* @run junit/othervm/timeout=2500 -XX:+IgnoreUnrecognizedVMOptions -XX:-VerifyDependencies -esa test.java.lang.invoke.MethodHandlesTest
*/
@@ -36,6 +37,7 @@
import java.util.*;
import org.junit.*;
import static org.junit.Assert.*;
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
/**
@@ -499,6 +501,10 @@
@Test
public void testFindStatic() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindStatic0);
+ }
+
+ public void testFindStatic0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findStatic");
testFindStatic(PubExample.class, void.class, "s0");
@@ -586,6 +592,10 @@
@Test
public void testFindVirtual() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindVirtual0);
+ }
+
+ public void testFindVirtual0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findVirtual");
testFindVirtual(Example.class, void.class, "v0");
@@ -616,6 +626,10 @@
@Test
public void testFindVirtualClone() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindVirtualClone0);
+ }
+
+ public void testFindVirtualClone0() throws Throwable {
// test some ad hoc system methods
testFindVirtual(false, PUBLIC, Object.class, Object.class, "clone");
testFindVirtual(true, PUBLIC, Object[].class, Object.class, "clone");
@@ -699,6 +713,10 @@
@Test
public void testFindSpecial() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindSpecial0);
+ }
+
+ public void testFindSpecial0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findSpecial");
testFindSpecial(SubExample.class, Example.class, void.class, "v0");
@@ -775,6 +793,10 @@
@Test
public void testFindConstructor() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindConstructor0);
+ }
+
+ public void testFindConstructor0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findConstructor");
testFindConstructor(true, EXAMPLE, Example.class);
@@ -818,6 +840,10 @@
@Test
public void testBind() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testBind0);
+ }
+
+ public void testBind0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("bind");
testBind(Example.class, void.class, "v0");
@@ -879,6 +905,10 @@
@Test
public void testUnreflect() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testUnreflect0);
+ }
+
+ public void testUnreflect0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("unreflect");
testUnreflect(Example.class, true, void.class, "s0");
@@ -985,6 +1015,10 @@
@Test
public void testUnreflectSpecial() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testUnreflectSpecial0);
+ }
+
+ public void testUnreflectSpecial0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("unreflectSpecial");
testUnreflectSpecial(Example.class, Example.class, void.class, "v0");
@@ -1077,23 +1111,38 @@
@Test
public void testUnreflectGetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testUnreflectGetter0);
+ }
+
+ public void testUnreflectGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("unreflectGetter");
testGetter(TEST_UNREFLECT);
}
+
@Test
public void testFindGetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindGetter0);
+ }
+
+ public void testFindGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findGetter");
testGetter(TEST_FIND_FIELD);
testGetter(TEST_FIND_FIELD | TEST_BOUND);
}
+
@Test
public void testFindStaticGetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindStaticGetter0);
+ }
+
+ public void testFindStaticGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findStaticGetter");
testGetter(TEST_FIND_STATIC);
}
+
public void testGetter(int testMode) throws Throwable {
Lookup lookup = PRIVATE; // FIXME: test more lookups than this one
for (Object[] c : HasFields.CASES) {
@@ -1287,26 +1336,40 @@
}
}
-
@Test
public void testUnreflectSetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testUnreflectSetter0);
+ }
+
+ public void testUnreflectSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("unreflectSetter");
testSetter(TEST_UNREFLECT);
}
+
@Test
public void testFindSetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindSetter0);
+ }
+
+ public void testFindSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findSetter");
testSetter(TEST_FIND_FIELD);
testSetter(TEST_FIND_FIELD | TEST_BOUND);
}
+
@Test
public void testFindStaticSetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFindStaticSetter0);
+ }
+
+ public void testFindStaticSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("findStaticSetter");
testSetter(TEST_FIND_STATIC);
}
+
public void testSetter(int testMode) throws Throwable {
Lookup lookup = PRIVATE; // FIXME: test more lookups than this one
startTest("unreflectSetter");
@@ -1329,6 +1392,10 @@
@Test
public void testArrayElementGetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testArrayElementGetter0);
+ }
+
+ public void testArrayElementGetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("arrayElementGetter");
testArrayElementGetterSetter(false);
@@ -1336,6 +1403,10 @@
@Test
public void testArrayElementSetter() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testArrayElementSetter0);
+ }
+
+ public void testArrayElementSetter0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("arrayElementSetter");
testArrayElementGetterSetter(true);
@@ -1349,6 +1420,10 @@
@Test
public void testArrayElementErrors() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testArrayElementErrors0);
+ }
+
+ public void testArrayElementErrors0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("arrayElementErrors");
testArrayElementGetterSetter(false, TEST_ARRAY_NPE);
@@ -1528,6 +1603,10 @@
@Test
public void testConvertArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testConvertArguments0);
+ }
+
+ public void testConvertArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("convertArguments");
testConvert(Callee.ofType(1), null, "id", int.class);
@@ -1591,6 +1670,10 @@
@Test
public void testVarargsCollector() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testVarargsCollector0);
+ }
+
+ public void testVarargsCollector0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("varargsCollector");
MethodHandle vac0 = PRIVATE.findStatic(MethodHandlesTest.class, "called",
@@ -1605,8 +1688,12 @@
}
}
- @Test // SLOW
+ @Test // SLOW
public void testPermuteArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testPermuteArguments0);
+ }
+
+ public void testPermuteArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("permuteArguments");
testPermuteArguments(4, Integer.class, 2, long.class, 6);
@@ -1744,8 +1831,12 @@
}
- @Test // SLOW
+ @Test // SLOW
public void testSpreadArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testSpreadArguments0);
+ }
+
+ public void testSpreadArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("spreadArguments");
for (Class<?> argType : new Class<?>[]{Object.class, Integer.class, int.class}) {
@@ -1838,8 +1929,12 @@
}
}
- @Test // SLOW
+ @Test // SLOW
public void testAsCollector() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testAsCollector0);
+ }
+
+ public void testAsCollector0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("asCollector");
for (Class<?> argType : new Class<?>[]{Object.class, Integer.class, int.class}) {
@@ -1880,8 +1975,12 @@
assertArrayEquals(collectedArgs, returnValue);
}
- @Test // SLOW
+ @Test // SLOW
public void testInsertArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testInsertArguments0);
+ }
+
+ public void testInsertArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("insertArguments");
for (int nargs = 0; nargs < 50; nargs++) {
@@ -1923,6 +2022,10 @@
@Test
public void testFilterReturnValue() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFilterReturnValue0);
+ }
+
+ public void testFilterReturnValue0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("filterReturnValue");
Class<?> classOfVCList = varargsList(1).invokeWithArguments(0).getClass();
@@ -1972,6 +2075,10 @@
@Test
public void testFilterArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFilterArguments0);
+ }
+
+ public void testFilterArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("filterArguments");
for (int nargs = 1; nargs <= 6; nargs++) {
@@ -2004,6 +2111,10 @@
@Test
public void testCollectArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testCollectArguments0);
+ }
+
+ public void testCollectArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("collectArguments");
testFoldOrCollectArguments(true);
@@ -2011,6 +2122,10 @@
@Test
public void testFoldArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testFoldArguments0);
+ }
+
+ public void testFoldArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("foldArguments");
testFoldOrCollectArguments(false);
@@ -2112,6 +2227,10 @@
@Test
public void testDropArguments() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testDropArguments0);
+ }
+
+ public void testDropArguments0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("dropArguments");
for (int nargs = 0; nargs <= 4; nargs++) {
@@ -2143,6 +2262,10 @@
@Test // SLOW
public void testInvokers() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testInvokers0);
+ }
+
+ public void testInvokers0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("exactInvoker, genericInvoker, varargsInvoker, dynamicInvoker");
// exactInvoker, genericInvoker, varargsInvoker[0..N], dynamicInvoker
@@ -2344,6 +2467,10 @@
@Test
public void testGuardWithTest() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testGuardWithTest0);
+ }
+
+ public void testGuardWithTest0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("guardWithTest");
for (int nargs = 0; nargs <= 50; nargs++) {
@@ -2415,6 +2542,10 @@
@Test
public void testThrowException() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testThrowException0);
+ }
+
+ public void testThrowException0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("throwException");
testThrowException(int.class, new ClassCastException("testing"));
@@ -2446,6 +2577,10 @@
@Test
public void testInterfaceCast() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testInterfaceCast0);
+ }
+
+ public void testInterfaceCast0() throws Throwable {
//if (CAN_SKIP_WORKING) return;
startTest("interfaceCast");
assert( (((Object)"foo") instanceof CharSequence));
@@ -2543,6 +2678,10 @@
@Test // SLOW
public void testCastFailure() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testCastFailure0);
+ }
+
+ public void testCastFailure0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("testCastFailure");
testCastFailure("cast/argument", 11000);
@@ -2655,6 +2794,10 @@
@Test
public void testUserClassInSignature() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testUserClassInSignature0);
+ }
+
+ public void testUserClassInSignature0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("testUserClassInSignature");
Lookup lookup = MethodHandles.lookup();
@@ -2706,6 +2849,10 @@
@Test
public void testAsInterfaceInstance() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testAsInterfaceInstance0);
+ }
+
+ public void testAsInterfaceInstance0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("asInterfaceInstance");
Lookup lookup = MethodHandles.lookup();
@@ -2869,6 +3016,10 @@
@Test
public void testRunnableProxy() throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(this::testRunnableProxy0);
+ }
+
+ public void testRunnableProxy0() throws Throwable {
if (CAN_SKIP_WORKING) return;
startTest("testRunnableProxy");
MethodHandles.Lookup lookup = MethodHandles.lookup();
--- a/jdk/test/java/lang/invoke/TestCatchExceptionWithVarargs.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/invoke/TestCatchExceptionWithVarargs.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -24,9 +24,12 @@
/*
* @test
* @bug 8019184
+ * @library /lib/testlibrary /lib/testlibrary/jsr292
* @summary MethodHandles.catchException() fails when methods have 8 args + varargs
+ * @run main TestCatchExceptionWithVarargs
*/
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
import java.util.*;
import java.lang.invoke.*;
@@ -68,6 +71,11 @@
}
public static void main(String[] args) throws Throwable {
+ CodeCacheOverflowProcessor
+ .runMHTest(TestCatchExceptionWithVarargs::test);
+ }
+
+ public static void test() throws Throwable {
List<Class<?>> ptypes = new LinkedList<>();
ptypes.add(Object[].class);
--- a/jdk/test/java/lang/invoke/VarargsArrayTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/lang/invoke/VarargsArrayTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * 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
@@ -24,14 +24,14 @@
package java.lang.invoke;
import sun.invoke.util.Wrapper;
-
import java.util.Arrays;
import java.util.Collections;
+import com.oracle.testlibrary.jsr292.CodeCacheOverflowProcessor;
/* @test
* @summary unit tests for varargs array methods: MethodHandleInfo.varargsArray(int),
* MethodHandleInfo.varargsArray(Class,int) & MethodHandleInfo.varargsList(int)
- *
+ * @library /lib/testlibrary /lib/testlibrary/jsr292
* @run main/bootclasspath java.lang.invoke.VarargsArrayTest
* @run main/bootclasspath -DVarargsArrayTest.MAX_ARITY=255 -DVarargsArrayTest.START_ARITY=250
* java.lang.invoke.VarargsArrayTest
@@ -47,6 +47,10 @@
private static final boolean EXHAUSTIVE = Boolean.getBoolean(CLASS.getSimpleName()+".EXHAUSTIVE");
public static void main(String[] args) throws Throwable {
+ CodeCacheOverflowProcessor.runMHTest(VarargsArrayTest::test);
+ }
+
+ public static void test() throws Throwable {
testVarargsArray();
testVarargsReferenceArray();
testVarargsPrimitiveArray();
--- a/jdk/test/java/nio/channels/DatagramChannel/EmptyBuffer.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/nio/channels/DatagramChannel/EmptyBuffer.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 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
@@ -27,39 +27,50 @@
* @author Mike McCloskey
*/
-import java.io.*;
-import java.net.*;
-import java.nio.*;
-import java.nio.channels.*;
-import java.nio.charset.*;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.net.InetAddress;
+import java.net.InetSocketAddress;
+import java.net.SocketAddress;
+import java.nio.ByteBuffer;
+import java.nio.ByteOrder;
+import java.nio.channels.ClosedByInterruptException;
+import java.nio.channels.DatagramChannel;
public class EmptyBuffer {
- static PrintStream log = System.err;
+ private static final PrintStream log = System.err;
public static void main(String[] args) throws Exception {
test();
}
- static void test() throws Exception {
- Server server = new Server();
+ private static void test() throws Exception {
+ DatagramChannel dc = DatagramChannel.open();
+ InetAddress localHost = InetAddress.getLocalHost();
+ dc.bind(new InetSocketAddress(localHost, 0));
+
+ Server server = new Server(dc.getLocalAddress());
Thread serverThread = new Thread(server);
serverThread.start();
- DatagramChannel dc = DatagramChannel.open();
+
try {
+ InetSocketAddress isa = new InetSocketAddress(localHost, server.port());
+ dc.connect(isa);
+
ByteBuffer bb = ByteBuffer.allocateDirect(12);
bb.order(ByteOrder.BIG_ENDIAN);
bb.putInt(1).putLong(1);
bb.flip();
- InetAddress address = InetAddress.getLocalHost();
- InetSocketAddress isa = new InetSocketAddress(address, server.port());
- dc.connect(isa);
+
dc.write(bb);
bb.rewind();
dc.write(bb);
bb.rewind();
dc.write(bb);
+
Thread.sleep(2000);
+
serverThread.interrupt();
server.throwException();
} finally {
@@ -67,12 +78,14 @@
}
}
- public static class Server implements Runnable {
- final DatagramChannel dc;
- Exception e = null;
+ private static class Server implements Runnable {
+ private final DatagramChannel dc;
+ private final SocketAddress clientAddress;
+ private Exception e = null;
- Server() throws IOException {
+ Server(SocketAddress clientAddress) throws IOException {
this.dc = DatagramChannel.open().bind(new InetSocketAddress(0));
+ this.clientAddress = clientAddress;
}
int port() {
@@ -94,30 +107,37 @@
log.println();
}
+ @Override
public void run() {
- SocketAddress sa = null;
- int numberReceived = 0;
try {
ByteBuffer bb = ByteBuffer.allocateDirect(12);
bb.clear();
// Only one clear. The buffer will be full after
// the first receive, but it should still block
// and receive and discard the next two
+ int numberReceived = 0;
while (!Thread.interrupted()) {
+ SocketAddress sa;
try {
sa = dc.receive(bb);
} catch (ClosedByInterruptException cbie) {
// Expected
log.println("Took expected exit");
+ // Verify that enough packets were received
+ if (numberReceived != 3)
+ throw new RuntimeException("Failed: Too few datagrams");
break;
}
if (sa != null) {
log.println("Client: " + sa);
- showBuffer("RECV", bb);
+ // Check client address so as not to count stray packets
+ if (sa.equals(clientAddress)) {
+ showBuffer("RECV", bb);
+ numberReceived++;
+ }
+ if (numberReceived > 3)
+ throw new RuntimeException("Failed: Too many datagrams");
sa = null;
- numberReceived++;
- if (numberReceived > 3)
- throw new RuntimeException("Test failed");
}
}
} catch (Exception ex) {
@@ -127,5 +147,4 @@
}
}
}
-
}
--- a/jdk/test/java/nio/file/Files/CopyAndMove.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/nio/file/Files/CopyAndMove.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 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
@@ -23,9 +23,9 @@
/* @test
* @bug 4313887 6838333 6917021 7006126 6950237 8006645
- * @summary Unit test for java.nio.file.Files copy and move methods
- * @library ..
- * @build CopyAndMove PassThroughFileSystem
+ * @summary Unit test for java.nio.file.Files copy and move methods (use -Dseed=X to set PRNG seed)
+ * @library .. /lib/testlibrary/
+ * @build jdk.testlibrary.* CopyAndMove PassThroughFileSystem
* @run main/othervm CopyAndMove
* @key randomness
*/
@@ -39,9 +39,10 @@
import java.io.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
+import jdk.testlibrary.RandomFactory;
public class CopyAndMove {
- static final Random rand = new Random();
+ static final Random rand = RandomFactory.getRandom();
static boolean heads() { return rand.nextBoolean(); }
private static boolean testPosixAttributes = false;
--- a/jdk/test/java/util/prefs/CodePointZeroPrefsTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/java/util/prefs/CodePointZeroPrefsTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -28,6 +28,7 @@
* @test
* @bug 8068373 8075110 8075156
* @summary Ensure a code point U+0000 null control character is detected.
+ * @run main/othervm -Djava.util.prefs.userRoot=. CodePointZeroPrefsTest
*/
public class CodePointZeroPrefsTest
{
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.java Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+import com.sun.security.auth.NTUserPrincipal;
+import com.sun.security.auth.UnixPrincipal;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import javax.security.auth.Subject;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/*
+ * @test
+ * @bug 8050409
+ * @summary Tests with Subject.getPrivateCredentials to check permission checks with one or more principals.
+ * @run testng/othervm/policy=MoreThenOnePrincipals.policy MoreThenOnePrincipals
+ */
+public class MoreThenOnePrincipals {
+ private static final String[] CRED_VALUES =
+ new String[]{"testPrivateCredential-1", "testPrivateCredentials-2"};
+ private static final HashSet CREDS = new HashSet<>(Arrays.asList(CRED_VALUES));
+
+ /**
+ * Policy file grants access to the private Credential,belonging to a
+ * Subject with at least two associated Principals:"com.sun.security.auth
+ * .NTUserPrincipal", with the name,"NTUserPrincipal-1", and
+ * "com.sun.security.auth.UnixPrincipal", with the name, "UnixPrincipals-1".
+ *
+ * For test1 and test2, subjects are associated with none or only one of
+ * principals mentioned above, SecurityException is expected.
+ * For test 3 and test 4, subjects are associated with two or more
+ * Principals (above principals are included), no exception is expected.
+ *
+ */
+
+ @Test(dataProvider = "Provider1", expectedExceptions = SecurityException.class)
+ public void test1(Subject s) {
+ s.getPrivateCredentials(String.class);
+ }
+
+ @Test(dataProvider = "Provider1", expectedExceptions = SecurityException.class)
+ public void test2(Subject s) {
+ s.getPrivateCredentials().iterator().next();
+ }
+
+ @Test(dataProvider = "Provider2")
+ public void test3(Subject s) {
+ s.getPrivateCredentials(String.class);
+ }
+
+ @Test(dataProvider = "Provider2")
+ public void test4(Subject s) {
+ s.getPrivateCredentials().iterator().next();
+ }
+
+ @DataProvider
+ public Object[][] Provider1() {
+ Subject s1 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
+ s1.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-2"));
+ Subject s2 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
+ s2.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-1"));
+ return new Object[][]{{s1}, {s2}};
+ }
+
+ @DataProvider
+ public Object[][] Provider2() {
+ Subject s3 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
+ s3.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-1"));
+ s3.getPrincipals().add(new UnixPrincipal("UnixPrincipals-1"));
+ Subject s4 = new Subject(false, Collections.EMPTY_SET, Collections.EMPTY_SET, CREDS);
+ s4.getPrincipals().add(new NTUserPrincipal("NTUserPrincipal-1"));
+ s4.getPrincipals().add(new UnixPrincipal("UnixPrincipals-1"));
+ s4.getPrincipals().add(new UnixPrincipal("UnixPrincipals-2"));
+ return new Object[][]{{s3}, {s4}};
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/javax/security/auth/PrivateCredentialPermission/MoreThenOnePrincipals.policy Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,10 @@
+grant{
+// permissions for TestNG execution
+permission java.io.FilePermission "*","read,write";
+permission java.lang.RuntimePermission "accessDeclaredMembers";
+permission java.util.PropertyPermission "*","read";
+permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
+// permissions for test itself
+permission javax.security.auth.AuthPermission "modifyPrincipals";
+permission javax.security.auth.PrivateCredentialPermission "* com.sun.security.auth.NTUserPrincipal \"NTUserPrincipal-1\" com.sun.security.auth.UnixPrincipal \"UnixPrincipals-1\"", "read";
+};
--- a/jdk/test/lib/security/CheckBlacklistedCerts.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/lib/security/CheckBlacklistedCerts.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -69,7 +69,9 @@
};
// Is this an OPENJDK build?
- if (!new File(home, "lib/security/local_policy.jar").exists()) {
+ String prop = System.getProperty("java.runtime.name");
+ if (prop != null && prop.startsWith("OpenJDK")) {
+ System.out.println("This is a OpenJDK build.");
blacklists = Arrays.copyOf(blacklists, 1);
}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java Thu Jun 04 18:28:52 2015 +0200
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/Utils.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2013, 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
@@ -25,9 +25,6 @@
import static jdk.testlibrary.Asserts.assertTrue;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
@@ -40,6 +37,7 @@
import java.util.regex.Matcher;
import java.util.concurrent.TimeUnit;
import java.util.function.BooleanSupplier;
+import java.util.function.Function;
/**
* Common library for various test helper functions.
@@ -326,4 +324,38 @@
}
return condition.getAsBoolean();
}
+
+ /**
+ * Interface same as java.lang.Runnable but with
+ * method {@code run()} able to throw any Throwable.
+ */
+ public static interface ThrowingRunnable {
+ void run() throws Throwable;
+ }
+
+ /**
+ * Filters out an exception that may be thrown by the given
+ * test according to the given filter.
+ *
+ * @param test - method that is invoked and checked for exception.
+ * @param filter - function that checks if the thrown exception matches
+ * criteria given in the filter's implementation.
+ * @return - exception that matches the filter if it has been thrown or
+ * {@code null} otherwise.
+ * @throws Throwable - if test has thrown an exception that does not
+ * match the filter.
+ */
+ public static Throwable filterException(ThrowingRunnable test,
+ Function<Throwable, Boolean> filter) throws Throwable {
+ try {
+ test.run();
+ } catch (Throwable t) {
+ if (filter.apply(t)) {
+ return t;
+ } else {
+ throw t;
+ }
+ }
+ return null;
+ }
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/lib/testlibrary/jsr292/com/oracle/testlibrary/jsr292/CodeCacheOverflowProcessor.java Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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 com.oracle.testlibrary.jsr292;
+
+import jdk.testlibrary.Utils;
+
+/**
+ * Helper class used to catch and process VirtualMachineError with message "Out
+ * of space in CodeCache". Some JSR292 tests run out of code cache size, so code
+ * cache overflows and VME is thrown. This VME is considered as non-critical in
+ * some JSR292 tests, so it should be processed to prevent test failure.
+ */
+public class CodeCacheOverflowProcessor {
+
+ /**
+ * Checks if an instance of Throwable is caused by VirtualMachineError with
+ * message "Out of space in CodeCache". May be used as filter in method
+ * {@code jdk.testlibrary.Utils.filterException}.
+ *
+ * @param t - Throwable to check.
+ * @return true if Throwable is caused by VME, false otherwise.
+ */
+ public static Boolean isThrowableCausedByVME(Throwable t) {
+ Throwable causeOfT = t;
+ do {
+ if (causeOfT instanceof VirtualMachineError
+ && causeOfT.getMessage().matches(".*[Oo]ut of space"
+ + " in CodeCache.*")) {
+ return true;
+ }
+ causeOfT = causeOfT != null ? causeOfT.getCause() : null;
+ } while (causeOfT != null && causeOfT != t);
+ return false;
+ }
+
+ /**
+ * Checks if the given test throws an exception caused by
+ * VirtualMachineError with message "Out of space in CodeCache", and, if VME
+ * takes place, processes it so that no exception is thrown, and prints its
+ * stack trace. If test throws exception not caused by VME, this method just
+ * re-throws this exception.
+ *
+ * @param test - test to check for and process VirtualMachineError.
+ * @return - an exception caused by VME or null
+ * if test has thrown no exception.
+ * @throws Throwable - if test has thrown an exception
+ * that is not caused by VME.
+ */
+ public static Throwable runMHTest(Utils.ThrowingRunnable test) throws Throwable {
+ Throwable t = Utils.filterException(test::run,
+ CodeCacheOverflowProcessor::isThrowableCausedByVME);
+ if (t != null) {
+ System.err.printf("%nNon-critical exception caught becuse of"
+ + " code cache size is not enough to run all test cases.%n%n");
+ t.printStackTrace();
+ }
+ return t;
+ }
+}
--- a/langtools/.hgtags Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/.hgtags Mon Jun 22 13:28:57 2015 -0700
@@ -311,3 +311,4 @@
fd6bda430d96fc5ab421161de016412f2ddd9082 jdk9-b66
fd782cd69b0497299269952d30a6b88cad960fcf jdk9-b67
c71857c93f57c63be44258d3d67e656c2bacdb45 jdk9-b68
+931ec7dd6cd9e4a92bde7b2cd26e9a9fb0ecdb56 jdk9-b69
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java Mon Jun 22 13:28:57 2015 -0700
@@ -4140,7 +4140,12 @@
public void visitAnnotatedType(JCAnnotatedType tree) {
attribAnnotationTypes(tree.annotations, env);
- Type underlyingType = attribType(tree.underlyingType, env);
+ JCExpression underlyingTypeTree = tree.getUnderlyingType();
+ Type underlyingType = attribTree(underlyingTypeTree, env,
+ new ResultInfo(KindSelector.TYP_PCK, Type.noType));
+ if (!chk.checkAnnotableType(underlyingType, tree.annotations, underlyingTypeTree.pos())) {
+ underlyingType = underlyingTypeTree.type = syms.errType;
+ }
Type annotatedType = underlyingType.annotatedType(Annotations.TO_BE_SET);
if (!env.info.isNewClass)
@@ -4631,16 +4636,7 @@
}
} else if (enclTr.hasTag(ANNOTATED_TYPE)) {
JCAnnotatedType at = (JCTree.JCAnnotatedType) enclTr;
- if (enclTy == null || enclTy.hasTag(NONE)) {
- if (at.getAnnotations().size() == 1) {
- log.error(at.underlyingType.pos(), "cant.type.annotate.scoping.1", at.getAnnotations().head.attribute);
- } else {
- ListBuffer<Attribute.Compound> comps = new ListBuffer<>();
- for (JCAnnotation an : at.getAnnotations()) {
- comps.add(an.attribute);
- }
- log.error(at.underlyingType.pos(), "cant.type.annotate.scoping", comps.toList());
- }
+ if (!chk.checkAnnotableType(enclTy, at.getAnnotations(), at.underlyingType.pos())) {
repeat = false;
}
enclTr = at.underlyingType;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Check.java Mon Jun 22 13:28:57 2015 -0700
@@ -62,6 +62,8 @@
import static com.sun.tools.javac.code.TypeTag.*;
import static com.sun.tools.javac.code.TypeTag.WILDCARD;
+import static com.sun.tools.javac.resources.CompilerProperties.Errors.CantTypeAnnotateScoping;
+import static com.sun.tools.javac.resources.CompilerProperties.Errors.CantTypeAnnotateScoping1;
import static com.sun.tools.javac.tree.JCTree.Tag.*;
/** Type checking helper class for the attribution phase.
@@ -2691,6 +2693,29 @@
* Check annotations
**************************************************************************/
+ /** Verify that a component of a qualified type name being type annotated
+ * can indeed be legally be annotated. For example, package names and type
+ * names used to access static members cannot be annotated.
+ *
+ * @param typeComponent the component of the qualified name being annotated
+ * @param annotations the annotations
+ * @param pos diagnostic position
+ * @return true if all is swell, false otherwise.
+ */
+ boolean checkAnnotableType(Type typeComponent, List<JCAnnotation> annotations, DiagnosticPosition pos) {
+ if (typeComponent == null || typeComponent.hasTag(PACKAGE) || typeComponent.hasTag(NONE)) {
+ ListBuffer<Symbol> lb = new ListBuffer<>();
+ for (JCAnnotation annotation : annotations) {
+ lb.append(annotation.annotationType.type.tsym);
+ }
+ List<Symbol> symbols = lb.toList();
+ log.error(pos,
+ symbols.size() > 1 ? CantTypeAnnotateScoping(symbols)
+ : CantTypeAnnotateScoping1(symbols.get(0)));
+ return false;
+ }
+ return true;
+ }
/**
* Recursively validate annotations values
*/
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,12 +1,12 @@
/*
* @test /nodynamiccopyright/
- * @bug 8026564
+ * @bug 8026564 8074346
* @summary The parts of a fully-qualified type can't be annotated.
* @author Werner Dietl
- * @ignore 8057679 clarify error messages trying to annotate scoping
* @compile/fail/ref=CantAnnotatePackages.out -XDrawDiagnostics CantAnnotatePackages.java
*/
+
import java.lang.annotation.*;
import java.util.List;
@@ -21,6 +21,8 @@
java. @TA lang.Object of3;
List<java. @TA lang.Object> of4;
+ List<@CantAnnotatePackages_TB java.lang.Object> of5; // test that we do reasonable things for missing types.
+
// TODO: also note the order of error messages.
}
--- a/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.out Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/CantAnnotatePackages.out Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,7 @@
-CantAnnotatePackages.java:14:13: compiler.err.cant.type.annotate.scoping.1: @TA
-CantAnnotatePackages.java:19:18: compiler.err.cant.type.annotate.scoping.1: @TA
-CantAnnotatePackages.java:20:19: compiler.err.cant.type.annotate.scoping.1: @TA
-CantAnnotatePackages.java:21:24: compiler.err.cant.type.annotate.scoping.1: @TA
-4 errors
+CantAnnotatePackages.java:20:14: compiler.err.cant.type.annotate.scoping.1: TA
+CantAnnotatePackages.java:21:9: compiler.err.cant.type.annotate.scoping.1: TA
+CantAnnotatePackages.java:22:14: compiler.err.cant.type.annotate.scoping.1: TA
+CantAnnotatePackages.java:24:11: compiler.err.cant.resolve.location: kindname.class, CantAnnotatePackages_TB, , , (compiler.misc.location: kindname.class, CantAnnotatePackages, null)
+CantAnnotatePackages.java:24:35: compiler.err.cant.type.annotate.scoping.1: CantAnnotatePackages_TB
+CantAnnotatePackages.java:15:18: compiler.err.cant.type.annotate.scoping.1: @TA
+6 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8074346.java Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,18 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8074346
+ * @author sadayapalam
+ * @summary Test that type annotation on a qualified type doesn't cause spurious 'cannot find symbol' errors
+ * @compile/fail/ref=T8074346.out -XDrawDiagnostics T8074346.java
+*/
+
+abstract class T8074346 implements
+ @T8074346_TA @T8074346_TB java.util.Map<@T8074346_TA java.lang.String, java.lang.@T8074346_TA String>,
+ java.util.@T8074346_TA List {
+}
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE)
+@interface T8074346_TA { }
+
+@java.lang.annotation.Target(java.lang.annotation.ElementType.TYPE_USE)
+@interface T8074346_TB { }
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/annotations/typeAnnotations/failures/T8074346.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,3 @@
+T8074346.java:10:35: compiler.err.cant.type.annotate.scoping: T8074346_TA,T8074346_TB
+T8074346.java:10:62: compiler.err.cant.type.annotate.scoping.1: T8074346_TA
+2 errors
\ No newline at end of file
--- a/langtools/test/tools/javac/generics/typeargs/Metharg1.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typeargs/Metharg1.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Metharg1.java
+ * @compile/fail/ref=Metharg1.out -XDrawDiagnostics Metharg1.java
*/
// Test type mismatch on type argument for method call
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typeargs/Metharg1.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,2 @@
+Metharg1.java:33:13: compiler.err.cant.apply.symbol: kindname.method, f, K, java.lang.String, kindname.class, T<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
--- a/langtools/test/tools/javac/generics/typeargs/Metharg2.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typeargs/Metharg2.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Metharg2.java
+ * @compile/fail/ref=Metharg2.out -XDrawDiagnostics Metharg2.java
*/
// Test type mismatch on type argument for qualified method call
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typeargs/Metharg2.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,2 @@
+Metharg2.java:39:10: compiler.err.cant.apply.symbol: kindname.method, f, K, java.lang.String, kindname.class, T<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
--- a/langtools/test/tools/javac/generics/typeargs/Newarg1.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typeargs/Newarg1.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Newarg1.java
+ * @compile/fail/ref=Newarg1.out -XDrawDiagnostics Newarg1.java
*/
// Test type mismatch on type argument for constructor
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typeargs/Newarg1.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,2 @@
+Newarg1.java:18:9: compiler.err.cant.apply.symbol: kindname.constructor, T, K, java.lang.String, kindname.class, T<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
--- a/langtools/test/tools/javac/generics/typeargs/Newarg2.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typeargs/Newarg2.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Newarg2.java
+ * @compile/fail/ref=Newarg2.out -XDrawDiagnostics Newarg2.java
*/
// Test type mismatch on type argument for inner constructor
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typeargs/Newarg2.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,2 @@
+Newarg2.java:19:17: compiler.err.cant.apply.symbol: kindname.constructor, U, B, java.lang.String, kindname.class, T.U<Y>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
--- a/langtools/test/tools/javac/generics/typeargs/Superarg1.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typeargs/Superarg1.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Superarg1.java
+ * @compile/fail/ref=Superarg1.out -XDrawDiagnostics Superarg1.java
*/
// Test type mismatch on type argument for super constructor
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typeargs/Superarg1.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,2 @@
+Superarg1.java:16:13: compiler.err.cant.apply.symbol: kindname.constructor, T, A, java.lang.String, kindname.class, T<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))
+1 error
--- a/langtools/test/tools/javac/generics/typeargs/Superarg2.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typeargs/Superarg2.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail Superarg2.java
+ * @compile/fail/ref=Superarg2.out -XDrawDiagnostics Superarg2.java
*/
// Test type mismatch on type argument for inner super constructor
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typeargs/Superarg2.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,2 @@
+Superarg2.java:25:14: compiler.err.cant.apply.symbols: kindname.constructor, U, java.lang.String,{(compiler.misc.inapplicable.method: kindname.constructor, T.U, <B>T.U(B), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))),(compiler.misc.inapplicable.method: kindname.constructor, T.U, T.U(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, int)))}
+1 error
--- a/langtools/test/tools/javac/generics/typeargs/ThisArg.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typeargs/ThisArg.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
+ * @test /nodynamiccopyright/
* @bug 4851039
* @summary explicit type arguments
* @author gafter
*
- * @compile/fail ThisArg.java
+ * @compile/fail/ref=ThisArg.out -XDrawDiagnostics ThisArg.java
*/
// Test type mismatch on type argument for this constructor
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typeargs/ThisArg.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,2 @@
+ThisArg.java:19:13: compiler.err.cant.apply.symbols: kindname.constructor, U, java.lang.String,{(compiler.misc.inapplicable.method: kindname.constructor, T.U, <B>T.U(B), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, java.lang.Integer))),(compiler.misc.inapplicable.method: kindname.constructor, T.U, T.U(int), (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inconvertible.types: java.lang.String, int)))}
+1 error
--- a/langtools/test/tools/javac/generics/typevars/4856983/T4856983.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typevars/4856983/T4856983.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
--- a/langtools/test/tools/javac/generics/typevars/4856983/T4856983a.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typevars/4856983/T4856983a.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,32 +1,9 @@
/*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
+ * @test /nodynamiccopyright/
* @bug 4856983
* @summary (crash) mutually f-bounded type vars with multiple bounds may crash javac
* @author Peter von der Ah\u00e9
- * @compile/fail T4856983a.java
+ * @compile/fail/ref=T4856983a.out -XDrawDiagnostics T4856983a.java
*/
interface I1 { Number m(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typevars/4856983/T4856983a.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,2 @@
+T4856983a.java:13:6: compiler.err.types.incompatible.diff.ret: I2, I1, m()
+1 error
--- a/langtools/test/tools/javac/generics/typevars/4856983/T4856983b.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typevars/4856983/T4856983b.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,32 +1,9 @@
/*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
+ * @test /nodynamiccopyright/
* @bug 4856983
* @summary (crash) mutually f-bounded type vars with multiple bounds may crash javac
* @author Peter von der Ah\u00e9
- * @compile/fail T4856983b.java
+ * @compile/fail/ref=T4856983b.out -XDrawDiagnostics T4856983b.java
*/
interface I1 { Number m(); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typevars/4856983/T4856983b.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,2 @@
+T4856983b.java:12:24: compiler.err.types.incompatible.diff.ret: I2, I1, m()
+1 error
--- a/langtools/test/tools/javac/generics/typevars/6182630/T6182630.java Thu Jun 04 18:28:52 2015 +0200
+++ b/langtools/test/tools/javac/generics/typevars/6182630/T6182630.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,39 +1,9 @@
/*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-/*
- * @test
+ * @test /nodynamiccopyright/
* @bug 6182630
* @summary Method with parameter bound to raw type avoids unchecked warning
* @author Peter von der Ah\u00e9
- * @compile -Xlint:unchecked T6182630.java
- * @compile/fail -Werror -Xlint:unchecked T6182630.java
- * @compile/fail -Werror -Xlint:unchecked T6182630a.java
- * @compile/fail -Werror -Xlint:unchecked T6182630b.java
- * @compile/fail -Werror -Xlint:unchecked T6182630c.java
- * @compile/fail -Werror -Xlint:unchecked T6182630d.java
- * @compile/fail -Werror -Xlint:unchecked T6182630e.java
- * @compile/fail -Werror -Xlint:unchecked T6182630f.java
+ * @compile/ref=T6182630.out -XDrawDiagnostics -Xlint:unchecked T6182630.java
*/
public class T6182630 {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/typevars/6182630/T6182630.out Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,7 @@
+T6182630.java:16:10: compiler.warn.unchecked.assign.to.var: x, T6182630.Foo
+T6182630.java:17:12: compiler.warn.unchecked.call.mbr.of.raw.type: m(X), T6182630.Foo
+T6182630.java:18:12: compiler.warn.unchecked.call.mbr.of.raw.type: m(X), T6182630.Foo
+T6182630.java:19:10: compiler.warn.unchecked.assign.to.var: x, T6182630.Foo
+T6182630.java:20:12: compiler.warn.unchecked.call.mbr.of.raw.type: m(X), T6182630.Foo
+T6182630.java:21:12: compiler.warn.unchecked.call.mbr.of.raw.type: m(X), T6182630.Foo
+6 warnings
--- a/langtools/test/tools/javac/generics/typevars/6182630/T6182630a.java Thu Jun 04 18:28:52 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-public class T6182630a {
- static class Foo<X> {
- public X x;
- public void m(X x) { }
- }
- interface Bar {}
- <T extends Foo, S extends Foo & Bar> void test1(T t, S s) {
- t.x = "BAD";
- }
-}
--- a/langtools/test/tools/javac/generics/typevars/6182630/T6182630b.java Thu Jun 04 18:28:52 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-public class T6182630b {
- static class Foo<X> {
- public X x;
- public void m(X x) { }
- }
- interface Bar {}
- <T extends Foo, S extends Foo & Bar> void test1(T t, S s) {
- t.m("BAD");
- }
-}
--- a/langtools/test/tools/javac/generics/typevars/6182630/T6182630c.java Thu Jun 04 18:28:52 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-public class T6182630c {
- static class Foo<X> {
- public X x;
- public void m(X x) { }
- }
- interface Bar {}
- <T extends Foo, S extends Foo & Bar> void test1(T t, S s) {
- t.m(t.x);
- }
-}
--- a/langtools/test/tools/javac/generics/typevars/6182630/T6182630d.java Thu Jun 04 18:28:52 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-public class T6182630d {
- static class Foo<X> {
- public X x;
- public void m(X x) { }
- }
- interface Bar {}
- <T extends Foo, S extends Foo & Bar> void test1(T t, S s) {
- s.x = "BAD";
- }
-}
--- a/langtools/test/tools/javac/generics/typevars/6182630/T6182630e.java Thu Jun 04 18:28:52 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-public class T6182630e {
- static class Foo<X> {
- public X x;
- public void m(X x) { }
- }
- interface Bar {}
- <T extends Foo, S extends Foo & Bar> void test1(T t, S s) {
- s.m("BAD");
- }
-}
--- a/langtools/test/tools/javac/generics/typevars/6182630/T6182630f.java Thu Jun 04 18:28:52 2015 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-public class T6182630f {
- static class Foo<X> {
- public X x;
- public void m(X x) { }
- }
- interface Bar {}
- <T extends Foo, S extends Foo & Bar> void test1(T t, S s) {
- s.m(s.x);
- }
-}
--- a/make/MacBundles.gmk Thu Jun 04 18:28:52 2015 +0200
+++ b/make/MacBundles.gmk Mon Jun 22 13:28:57 2015 -0700
@@ -25,6 +25,7 @@
include $(SPEC)
include MakeBase.gmk
+include TextFileProcessing.gmk
default: bundles
--- a/make/common/CORE_PKGS.gmk Thu Jun 04 18:28:52 2015 +0200
+++ b/make/common/CORE_PKGS.gmk Mon Jun 22 13:28:57 2015 -0700
@@ -222,7 +222,6 @@
javax.swing.plaf.nimbus \
javax.swing.plaf.synth \
javax.tools \
- javax.tools.annotation \
javax.transaction \
javax.transaction.xa \
javax.xml.parsers \
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make/devkit/createMacosxDevkit.sh Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,147 @@
+#!/bin/bash
+#
+# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# This script copies part of an Xcode installer into a devkit suitable
+# for building OpenJDK and OracleJDK. The installation .dmg files for Xcode
+# and the aux tools need to be available.
+# erik.joelsson@oracle.com
+
+USAGE="$0 <Xcode.dmg> <XQuartz.dmg> [<auxtools.dmg>]"
+
+if [ "$1" = "" ] || [ "$2" = "" ]; then
+ echo $USAGE
+ exit 1
+fi
+
+XCODE_DMG="$1"
+XQUARTZ_DMG="$2"
+AUXTOOLS_DMG="$3"
+
+SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
+BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
+
+# Mount XCODE_DMG
+if [ -e "/Volumes/Xcode" ]; then
+ hdiutil detach /Volumes/Xcode
+fi
+hdiutil attach $XCODE_DMG
+
+# Find the version of Xcode
+XCODE_VERSION="$(/Volumes/Xcode/Xcode.app/Contents/Developer/usr/bin/xcodebuild -version \
+ | awk '/Xcode/ { print $2 }' )"
+
+DEVKIT_ROOT="${BUILD_DIR}/Xcode${XCODE_VERSION}-devkit"
+DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
+
+echo "Xcode version: $XCODE_VERSION"
+echo "Creating devkit in $DEVKIT_ROOT"
+
+################################################################################
+# Copy files to root
+mkdir -p $DEVKIT_ROOT
+if [ ! -d $DEVKIT_ROOT/Xcode.app ]; then
+ echo "Copying Xcode.app..."
+ cp -RH "/Volumes/Xcode/Xcode.app" $DEVKIT_ROOT/
+fi
+# Trim out some seemingly unneeded parts to save space.
+rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Applications
+rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/iPhone*
+rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Documentation
+rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/share/man
+if [ -e $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk ]; then
+ rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk
+ rm -rf $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/share/man
+fi
+
+hdiutil detach /Volumes/Xcode
+
+################################################################################
+# Copy Freetype into sysroot
+if [ -e "/Volumes/XQuartz-*" ]; then
+ hdiutil detach /Volumes/XQuartz-*
+fi
+hdiutil attach $XQUARTZ_DMG
+
+echo "Copying freetype..."
+rm -rf /tmp/XQuartz
+pkgutil --expand /Volumes/XQuartz-*/XQuartz.pkg /tmp/XQuartz/
+rm -rf /tmp/x11
+mkdir /tmp/x11
+cd /tmp/x11
+cat /tmp/XQuartz-*/x11.pkg/Payload | gunzip -dc |cpio -i
+
+cp -RH opt/X11/include/freetype2 \
+ $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/
+cp -RH opt/X11/include/ft2build.h \
+ $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/
+cp -RH opt/X11/lib/libfreetype.* \
+ $DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/lib/
+
+cd -
+
+hdiutil detach /Volumes/XQuartz-*
+
+################################################################################
+# Optionally copy PackageMaker
+
+if [ -e "$AUXTOOLS_DMG" ]; then
+ if [ -e "/Volumes/Auxiliary Tools" ]; then
+ hdiutil detach "/Volumes/Auxiliary Tools"
+ fi
+ hdiutil attach $AUXTOOLS_DMG
+
+ echo "Copying PackageMaker.app..."
+ cp -RH "/Volumes/Auxiliary Tools/PackageMaker.app" $DEVKIT_ROOT/
+
+ hdiutil detach "/Volumes/Auxiliary Tools"
+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=\"Xcode $XCODE_VERSION (devkit)\""
+echo-info "DEVKIT_TOOLCHAIN_PATH=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin:\$DEVKIT_ROOT/Xcode.app/Contents/Developer/usr/bin\""
+echo-info "DEVKIT_SYSROOT=\"\$DEVKIT_ROOT/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk\""
+echo-info "DEVKIT_EXTRA_PATH=\"\$DEVKIT_ROOT/PackageMaker.app/Contents/MacOS:\$DEVKIT_TOOLCHAIN_PATH\""
+
+################################################################################
+# Copy this script
+
+echo "Copying this script..."
+cp $0 $DEVKIT_ROOT/
+
+################################################################################
+# Create bundle
+
+echo "Creating bundle..."
+(cd $DEVKIT_ROOT && tar c - . | gzip - > "$DEVKIT_BUNDLE")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/make/devkit/createWindowsDevkit.sh Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,131 @@
+#!/bin/bash
+#
+# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# This code is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License version 2 only, as
+# published by the Free Software Foundation. Oracle designates this
+# particular file as subject to the "Classpath" exception as provided
+# by Oracle in the LICENSE file that accompanied this code.
+#
+# This code is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+# version 2 for more details (a copy is included in the LICENSE file that
+# accompanied this code).
+#
+# You should have received a copy of the GNU General Public License version
+# 2 along with this work; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+# or visit www.oracle.com if you need additional information or have any
+# questions.
+#
+
+# This script copies parts of a Visual Studio 2013 installation into a devkit
+# suitable for building OpenJDK and OracleJDK. Needs to run in Cygwin.
+# erik.joelsson@oracle.com
+
+VS_VERSION="2013"
+VS_VERSION_NUM="12.0"
+VS_VERSION_NUM_NODOT="120"
+SDK_VERSION="8.1"
+
+SCRIPT_DIR="$(cd "$(dirname $0)" > /dev/null && pwd)"
+BUILD_DIR="${SCRIPT_DIR}/../../build/devkit"
+DEVKIT_ROOT="${BUILD_DIR}/VS${VS_VERSION}-devkit"
+DEVKIT_BUNDLE="${DEVKIT_ROOT}.tar.gz"
+
+echo "Creating devkit in $DEVKIT_ROOT"
+
+MSVCR_DLL=Microsoft.VC${VS_VERSION_NUM_NODOT}.CRT/msvcr${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/
+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/
+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 (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\""
+echo-info "DEVKIT_VS_LIB_x86=\"\$DEVKIT_ROOT/VC/lib;\$DEVKIT_ROOT/VC/atlmfc/lib;\$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/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\""
+echo-info "DEVKIT_VS_LIB_x86_64=\"\$DEVKIT_ROOT/VC/lib/amd64;\$DEVKIT_ROOT/VC/atlmfc/lib/amd64;\$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" .)
--- a/nashorn/.hgtags Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/.hgtags Mon Jun 22 13:28:57 2015 -0700
@@ -302,3 +302,4 @@
9dd95cff9dae897e8dee712f1f0303c460262288 jdk9-b66
f822b749821e364cae0b7bd7c8f667d9437e6d83 jdk9-b67
dd6dd848b854dbd3f3cc422668276b1ae0834179 jdk9-b68
+194b74467afcab3ca0096f04570def424977215d jdk9-b69
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java Mon Jun 22 13:28:57 2015 -0700
@@ -152,6 +152,7 @@
}
if (constructor != null) {
+ initPrototype(mi);
final int arity = constructor.getArity();
if (arity != MemberInfo.DEFAULT_ARITY) {
mi.loadThis();
@@ -193,6 +194,7 @@
}
private void initFunctionFields(final MethodGenerator mi) {
+ assert memberCount > 0;
for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
if (!memInfo.isConstructorFunction()) {
continue;
@@ -204,37 +206,39 @@
}
private void initDataFields(final MethodGenerator mi) {
- for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
- if (!memInfo.isConstructorProperty() || memInfo.isFinal()) {
- continue;
- }
- final Object value = memInfo.getValue();
- if (value != null) {
- mi.loadThis();
- mi.loadLiteral(value);
- mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
- } else if (!memInfo.getInitClass().isEmpty()) {
- final String clazz = memInfo.getInitClass();
- mi.loadThis();
- mi.newObject(clazz);
- mi.dup();
- mi.invokeSpecial(clazz, INIT, DEFAULT_INIT_DESC);
- mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
- }
+ assert memberCount > 0;
+ for (final MemberInfo memInfo : scriptClassInfo.getMembers()) {
+ if (!memInfo.isConstructorProperty() || memInfo.isFinal()) {
+ continue;
+ }
+ final Object value = memInfo.getValue();
+ if (value != null) {
+ mi.loadThis();
+ mi.loadLiteral(value);
+ mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
+ } else if (!memInfo.getInitClass().isEmpty()) {
+ final String clazz = memInfo.getInitClass();
+ mi.loadThis();
+ mi.newObject(clazz);
+ mi.dup();
+ mi.invokeSpecial(clazz, INIT, DEFAULT_INIT_DESC);
+ mi.putField(className, memInfo.getJavaName(), memInfo.getJavaDesc());
+ }
}
+ }
- if (constructor != null) {
- mi.loadThis();
- final String protoName = scriptClassInfo.getPrototypeClassName();
- mi.newObject(protoName);
- mi.dup();
- mi.invokeSpecial(protoName, INIT, DEFAULT_INIT_DESC);
- mi.dup();
- mi.loadThis();
- mi.invokeStatic(PROTOTYPEOBJECT_TYPE, PROTOTYPEOBJECT_SETCONSTRUCTOR,
- PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC);
- mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETPROTOTYPE, SCRIPTFUNCTION_SETPROTOTYPE_DESC);
- }
+ private void initPrototype(final MethodGenerator mi) {
+ assert constructor != null;
+ mi.loadThis();
+ final String protoName = scriptClassInfo.getPrototypeClassName();
+ mi.newObject(protoName);
+ mi.dup();
+ mi.invokeSpecial(protoName, INIT, DEFAULT_INIT_DESC);
+ mi.dup();
+ mi.loadThis();
+ mi.invokeStatic(PROTOTYPEOBJECT_TYPE, PROTOTYPEOBJECT_SETCONSTRUCTOR,
+ PROTOTYPEOBJECT_SETCONSTRUCTOR_DESC);
+ mi.invokeVirtual(SCRIPTFUNCTION_TYPE, SCRIPTFUNCTION_SETPROTOTYPE, SCRIPTFUNCTION_SETPROTOTYPE_DESC);
}
/**
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/Main.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/Main.java Mon Jun 22 13:28:57 2015 -0700
@@ -140,7 +140,7 @@
String simpleName = inFile.getName();
simpleName = simpleName.substring(0, simpleName.indexOf(".class"));
- if (sci.getPrototypeMemberCount() > 0) {
+ if (sci.isPrototypeNeeded()) {
// generate prototype class
final PrototypeGenerator protGen = new PrototypeGenerator(sci);
buf = protGen.getClassBytes();
@@ -152,7 +152,7 @@
}
}
- if (sci.getConstructorMemberCount() > 0 || sci.getConstructor() != null) {
+ if (sci.isConstructorNeeded()) {
// generate constructor class
final ConstructorGenerator consGen = new ConstructorGenerator(sci);
buf = consGen.getClassBytes();
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfo.java Mon Jun 22 13:28:57 2015 -0700
@@ -126,10 +126,42 @@
return Collections.unmodifiableList(res);
}
+ boolean isConstructorNeeded() {
+ // Constructor class generation is needed if we one or
+ // more constructor properties are defined or @Constructor
+ // is defined in the class.
+ for (final MemberInfo memInfo : members) {
+ if (memInfo.getKind() == Kind.CONSTRUCTOR ||
+ memInfo.getWhere() == Where.CONSTRUCTOR) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ boolean isPrototypeNeeded() {
+ // Prototype class generation is needed if we have atleast one
+ // prototype property or @Constructor defined in the class.
+ for (final MemberInfo memInfo : members) {
+ if (memInfo.getWhere() == Where.PROTOTYPE || memInfo.isConstructor()) {
+ return true;
+ }
+ }
+ return false;
+ }
+
int getPrototypeMemberCount() {
int count = 0;
for (final MemberInfo memInfo : members) {
- if (memInfo.getWhere() == Where.PROTOTYPE || memInfo.isConstructor()) {
+ switch (memInfo.getKind()) {
+ case SETTER:
+ case SPECIALIZED_FUNCTION:
+ // SETTER was counted when GETTER was encountered.
+ // SPECIALIZED_FUNCTION was counted as FUNCTION already.
+ continue;
+ }
+
+ if (memInfo.getWhere() == Where.PROTOTYPE) {
count++;
}
}
@@ -139,6 +171,16 @@
int getConstructorMemberCount() {
int count = 0;
for (final MemberInfo memInfo : members) {
+ switch (memInfo.getKind()) {
+ case CONSTRUCTOR:
+ case SETTER:
+ case SPECIALIZED_FUNCTION:
+ // SETTER was counted when GETTER was encountered.
+ // Constructor and constructor SpecializedFunctions
+ // are not added as members and so not counted.
+ continue;
+ }
+
if (memInfo.getWhere() == Where.CONSTRUCTOR) {
count++;
}
@@ -149,6 +191,14 @@
int getInstancePropertyCount() {
int count = 0;
for (final MemberInfo memInfo : members) {
+ switch (memInfo.getKind()) {
+ case SETTER:
+ case SPECIALIZED_FUNCTION:
+ // SETTER was counted when GETTER was encountered.
+ // SPECIALIZED_FUNCTION was counted as FUNCTION already.
+ continue;
+ }
+
if (memInfo.getWhere() == Where.INSTANCE) {
count++;
}
--- a/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInfoCollector.java Mon Jun 22 13:28:57 2015 -0700
@@ -288,9 +288,7 @@
where = Where.PROTOTYPE;
break;
case SPECIALIZED_FUNCTION:
- if (isSpecializedConstructor) {
- where = Where.CONSTRUCTOR;
- }
+ where = isSpecializedConstructor? Where.CONSTRUCTOR : Where.PROTOTYPE;
//fallthru
default:
break;
--- a/nashorn/samples/javahelp.js Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/samples/javahelp.js Mon Jun 22 13:28:57 2015 -0700
@@ -63,5 +63,3 @@
}
}
}
-
-undefined;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java Mon Jun 22 13:28:57 2015 -0700
@@ -172,7 +172,7 @@
return Context.getContext();
}
}, GET_CONTEXT_ACC_CTXT);
- return wrapLikeMe(context.eval(global, s, sobj, null, false));
+ return wrapLikeMe(context.eval(global, s, sobj, null));
}
});
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Compiler.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Compiler.java Mon Jun 22 13:28:57 2015 -0700
@@ -103,7 +103,7 @@
private final CodeInstaller<ScriptEnvironment> installer;
- /** logger for compiler, trampolines, splits and related code generation events
+ /** logger for compiler, trampolines and related code generation events
* that affect classes */
private final DebugLogger log;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ConstantData.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/ConstantData.java Mon Jun 22 13:28:57 2015 -0700
@@ -30,6 +30,8 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
+
import jdk.nashorn.internal.runtime.PropertyMap;
/**
@@ -120,7 +122,7 @@
private final int hashCode;
public PropertyMapWrapper(final PropertyMap map) {
- this.hashCode = Arrays.hashCode(map.getProperties());
+ this.hashCode = Arrays.hashCode(map.getProperties()) + 31 * Objects.hashCode(map.getClassName());
this.propertyMap = map;
}
@@ -131,8 +133,13 @@
@Override
public boolean equals(final Object other) {
- return other instanceof PropertyMapWrapper &&
- Arrays.equals(propertyMap.getProperties(), ((PropertyMapWrapper) other).propertyMap.getProperties());
+ if (!(other instanceof PropertyMapWrapper)) {
+ return false;
+ }
+ final PropertyMap otherMap = ((PropertyMapWrapper) other).propertyMap;
+ return propertyMap == otherMap
+ || (Arrays.equals(propertyMap.getProperties(), otherMap.getProperties())
+ && Objects.equals(propertyMap.getClassName(), otherMap.getClassName()));
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java Mon Jun 22 13:28:57 2015 -0700
@@ -584,7 +584,9 @@
@Override
public Node leaveVarNode(final VarNode varNode) {
addStatement(varNode);
- if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION) && lc.getCurrentFunction().isProgram()) {
+ if (varNode.getFlag(VarNode.IS_LAST_FUNCTION_DECLARATION)
+ && lc.getCurrentFunction().isProgram()
+ && ((FunctionNode) varNode.getInit()).isAnonymous()) {
new ExpressionStatement(varNode.getLineNumber(), varNode.getToken(), varNode.getFinish(), new IdentNode(varNode.getName())).accept(this);
}
return varNode;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Splitter.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Splitter.java Mon Jun 22 13:28:57 2015 -0700
@@ -42,13 +42,17 @@
import jdk.nashorn.internal.ir.SplitNode;
import jdk.nashorn.internal.ir.Statement;
import jdk.nashorn.internal.ir.visitor.NodeVisitor;
+import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.logging.DebugLogger;
+import jdk.nashorn.internal.runtime.logging.Loggable;
+import jdk.nashorn.internal.runtime.logging.Logger;
import jdk.nashorn.internal.runtime.options.Options;
/**
* Split the IR into smaller compile units.
*/
-final class Splitter extends NodeVisitor<LexicalContext> {
+@Logger(name="splitter")
+final class Splitter extends NodeVisitor<LexicalContext> implements Loggable {
/** Current compiler. */
private final Compiler compiler;
@@ -78,7 +82,17 @@
this.compiler = compiler;
this.outermost = functionNode;
this.outermostCompileUnit = outermostCompileUnit;
- this.log = compiler.getLogger();
+ this.log = initLogger(compiler.getContext());
+ }
+
+ @Override
+ public DebugLogger initLogger(final Context context) {
+ return context.getLogger(this.getClass());
+ }
+
+ @Override
+ public DebugLogger getLogger() {
+ return log;
}
/**
@@ -89,7 +103,7 @@
FunctionNode split(final FunctionNode fn, final boolean top) {
FunctionNode functionNode = fn;
- log.finest("Initiating split of '", functionNode.getName(), "'");
+ log.fine("Initiating split of '", functionNode.getName(), "'");
long weight = WeighNodes.weigh(functionNode);
@@ -98,7 +112,7 @@
assert lc.isEmpty() : "LexicalContext not empty";
if (weight >= SPLIT_THRESHOLD) {
- log.finest("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD);
+ log.info("Splitting '", functionNode.getName(), "' as its weight ", weight, " exceeds split threshold ", SPLIT_THRESHOLD);
functionNode = (FunctionNode)functionNode.accept(this);
if (functionNode.isSplit()) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/BooleanType.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/types/BooleanType.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,28 +1,3 @@
-/*
- * Copyright (c) 2010, 2013, 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.
- */
-
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Mon Jun 22 13:28:57 2015 -0700
@@ -87,7 +87,7 @@
* Representation of global scope.
*/
@ScriptClass("Global")
-public final class Global extends ScriptObject implements Scope {
+public final class Global extends Scope {
// Placeholder value used in place of a location property (__FILE__, __DIR__, __LINE__)
private static final Object LOCATION_PROPERTY_PLACEHOLDER = new Object();
private final InvokeByName TO_STRING = new InvokeByName("toString", ScriptObject.class);
@@ -906,9 +906,6 @@
*/
private ScriptFunction typeErrorThrower;
- // Flag to indicate that a split method issued a return statement
- private int splitState = -1;
-
// Used to store the last RegExp result to support deprecated RegExp constructor properties
private RegExpResult lastRegExpResult;
@@ -995,7 +992,6 @@
public Global(final Context context) {
super(checkAndGetMap(context));
this.context = context;
- this.setIsScope();
this.lexicalScope = context.getEnv()._es6 ? new LexicalScope(this) : null;
}
@@ -1451,7 +1447,7 @@
* @return the result of eval
*/
public static Object eval(final Object self, final Object str) {
- return directEval(self, str, UNDEFINED, UNDEFINED, false);
+ return directEval(self, str, Global.instanceFrom(self), UNDEFINED, false);
}
/**
@@ -1461,7 +1457,7 @@
* @param str Evaluated code
* @param callThis "this" to be passed to the evaluated code
* @param location location of the eval call
- * @param strict is eval called a strict mode code?
+ * @param strict is eval called from a strict mode code?
*
* @return the return value of the eval
*
@@ -1502,26 +1498,53 @@
}
/**
- * Global load implementation - Nashorn extension
+ * Global load implementation - Nashorn extension.
*
- * @param self scope
- * @param source source to load
+ * <p>
+ * load builtin loads the given script. Script source can be a URL or a File
+ * or a script object with name and script properties. Evaluated code gets
+ * global object "this" and uses global object as scope for evaluation.
+ * </p>
+ * <p>
+ * If self is undefined or null or global, then global object is used
+ * as scope as well as "this" for the evaluated code. If self is any other
+ * object, then it is indirect load call. With indirect load call, the
+ * properties of scope are available to evaluated script as variables. Also,
+ * global scope properties are accessible. Any var, function definition in
+ * evaluated script goes into an object that is not accessible to user scripts.
+ * </p>
+ * Thus the indirect load call is equivalent to the following:
+ * <pre>
+ * <code>
+ * (function (scope, source) {
+ * with(scope) {
+ * eval(<script_from_source>);
+ * }
+ * })(self, source);
+ * </code>
+ * </pre>
*
- * @return result of load (undefined)
+ * @param self scope to use for the script evaluation
+ * @param source script source
+ *
+ * @return result of load (may be undefined)
*
* @throws IOException if source could not be read
*/
public static Object load(final Object self, final Object source) throws IOException {
final Global global = Global.instanceFrom(self);
- final ScriptObject scope = self instanceof ScriptObject ? (ScriptObject)self : global;
- return global.getContext().load(scope, source);
+ return global.getContext().load(self, source);
}
/**
- * Global loadWithNewGlobal implementation - Nashorn extension
+ * Global loadWithNewGlobal implementation - Nashorn extension.
*
- * @param self scope
- * @param args from plus (optional) arguments to be passed to the loaded script
+ * loadWithNewGlobal builtin loads the given script from a URL or a File
+ * or a script object with name and script properties. Evaluated code gets
+ * new global object "this" and uses that new global object as scope for evaluation.
+ *
+ * @param self self This value is ignored by this function
+ * @param args optional arguments to be passed to the loaded script
*
* @return result of load (may be undefined)
*
@@ -2328,26 +2351,6 @@
}
/**
- * Get the current split state.
- *
- * @return current split state
- */
- @Override
- public int getSplitState() {
- return splitState;
- }
-
- /**
- * Set the current split state.
- *
- * @param state current split state
- */
- @Override
- public void setSplitState(final int state) {
- splitState = state;
- }
-
- /**
* Return the ES6 global scope for lexically declared bindings.
* @return the ES6 lexical global scope.
*/
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeDebug.java Mon Jun 22 13:28:57 2015 -0700
@@ -37,6 +37,7 @@
import jdk.nashorn.internal.runtime.JSType;
import jdk.nashorn.internal.runtime.PropertyListeners;
import jdk.nashorn.internal.runtime.PropertyMap;
+import jdk.nashorn.internal.runtime.Scope;
import jdk.nashorn.internal.runtime.ScriptFunction;
import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.ScriptRuntime;
@@ -245,7 +246,7 @@
final PrintWriter out = Context.getCurrentErr();
out.println("ScriptObject count " + ScriptObject.getCount());
- out.println("Scope count " + ScriptObject.getScopeCount());
+ out.println("Scope count " + Scope.getCount());
out.println("ScriptObject listeners added " + PropertyListeners.getListenersAdded());
out.println("ScriptObject listeners removed " + PropertyListeners.getListenersRemoved());
out.println("ScriptFunction constructor calls " + ScriptFunction.getConstructorCount());
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeFunction.java Mon Jun 22 13:28:57 2015 -0700
@@ -279,8 +279,8 @@
sb.append("})");
final Global global = Global.instance();
-
- return (ScriptFunction)Global.directEval(global, sb.toString(), global, "<function>", global.isStrictContext());
+ final Context context = global.getContext();
+ return (ScriptFunction)context.eval(global, sb.toString(), global, "<function>");
}
private static void checkFunctionParameters(final String params) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/AbstractParser.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/AbstractParser.java Mon Jun 22 13:28:57 2015 -0700
@@ -459,6 +459,19 @@
if (kind == TokenKind.KEYWORD || kind == TokenKind.FUTURE || kind == TokenKind.FUTURESTRICT) {
return true;
}
+
+ // only literals allowed are null, false and true
+ if (kind == TokenKind.LITERAL) {
+ switch (type) {
+ case FALSE:
+ case NULL:
+ case TRUE:
+ return true;
+ default:
+ return false;
+ }
+ }
+
// Fake out identifier.
final long identToken = Token.recast(token, IDENT);
// Get IDENT.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java Mon Jun 22 13:28:57 2015 -0700
@@ -668,12 +668,11 @@
* @param string Evaluated code as a String
* @param callThis "this" to be passed to the evaluated code
* @param location location of the eval call
- * @param strict is this {@code eval} call from a strict mode code?
* @return the return value of the {@code eval}
*/
public Object eval(final ScriptObject initialScope, final String string,
- final Object callThis, final Object location, final boolean strict) {
- return eval(initialScope, string, callThis, location, strict, false);
+ final Object callThis, final Object location) {
+ return eval(initialScope, string, callThis, location, false, false);
}
/**
@@ -692,14 +691,16 @@
final Object callThis, final Object location, final boolean strict, final boolean evalCall) {
final String file = location == UNDEFINED || location == null ? "<eval>" : location.toString();
final Source source = sourceFor(file, string, evalCall);
- final boolean directEval = location != UNDEFINED; // is this direct 'eval' call or indirectly invoked eval?
+ // is this direct 'eval' builtin call?
+ final boolean directEval = evalCall && (location != UNDEFINED);
final Global global = Context.getGlobal();
ScriptObject scope = initialScope;
// ECMA section 10.1.1 point 2 says eval code is strict if it begins
// with "use strict" directive or eval direct call itself is made
// from from strict mode code. We are passed with caller's strict mode.
- boolean strictFlag = directEval && strict;
+ // Nashorn extension: any 'eval' is unconditionally strict when -strict is specified.
+ boolean strictFlag = strict || this._strict;
Class<?> clazz = null;
try {
@@ -723,16 +724,8 @@
// In strict mode, eval does not instantiate variables and functions
// in the caller's environment. A new environment is created!
if (strictFlag) {
- // Create a new scope object
- final ScriptObject strictEvalScope = global.newObject();
-
- // bless it as a "scope"
- strictEvalScope.setIsScope();
-
- // set given scope to be it's proto so that eval can still
- // access caller environment vars in the new environment.
- strictEvalScope.setProto(scope);
- scope = strictEvalScope;
+ // Create a new scope object with given scope as its prototype
+ scope = newScope(scope);
}
final ScriptFunction func = getProgramFunction(clazz, scope);
@@ -740,12 +733,17 @@
if (directEval) {
evalThis = (callThis != UNDEFINED && callThis != null) || strictFlag ? callThis : global;
} else {
- evalThis = global;
+ // either indirect evalCall or non-eval (Function, engine.eval, ScriptObjectMirror.eval..)
+ evalThis = callThis;
}
return ScriptRuntime.apply(func, evalThis);
}
+ private static ScriptObject newScope(final ScriptObject callerScope) {
+ return new Scope(callerScope, PropertyMap.newMap(Scope.class));
+ }
+
private static Source loadInternal(final String srcStr, final String prefix, final String resourcePath) {
if (srcStr.startsWith(prefix)) {
final String resource = resourcePath + srcStr.substring(prefix.length());
@@ -779,7 +777,7 @@
*
* @throws IOException if source cannot be found or loaded
*/
- public Object load(final ScriptObject scope, final Object from) throws IOException {
+ public Object load(final Object scope, final Object from) throws IOException {
final Object src = from instanceof ConsString ? from.toString() : from;
Source source = null;
@@ -831,7 +829,42 @@
}
if (source != null) {
- return evaluateSource(source, scope, scope);
+ if (scope instanceof ScriptObject && ((ScriptObject)scope).isScope()) {
+ final ScriptObject sobj = (ScriptObject)scope;
+ // passed object is a script object
+ // Global is the only user accessible scope ScriptObject
+ assert sobj.isGlobal() : "non-Global scope object!!";
+ return evaluateSource(source, sobj, sobj);
+ } else if (scope == null || scope == UNDEFINED) {
+ // undefined or null scope. Use current global instance.
+ final Global global = getGlobal();
+ return evaluateSource(source, global, global);
+ } else {
+ /*
+ * Arbitrary object passed for scope.
+ * Indirect load that is equivalent to:
+ *
+ * (function(scope, source) {
+ * with (scope) {
+ * eval(<script_from_source>);
+ * }
+ * })(scope, source);
+ */
+ final Global global = getGlobal();
+ // Create a new object. This is where all declarations
+ // (var, function) from the evaluated code go.
+ // make global to be its __proto__ so that global
+ // definitions are accessible to the evaluated code.
+ final ScriptObject evalScope = newScope(global);
+
+ // finally, make a WithObject around user supplied scope object
+ // so that it's properties are accessible as variables.
+ final ScriptObject withObj = ScriptRuntime.openWith(evalScope, scope);
+
+ // evaluate given source with 'withObj' as scope
+ // but use global object as "this".
+ return evaluateSource(source, withObj, global);
+ }
}
throw typeError("cant.load.script", ScriptRuntime.safeToString(from));
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/DebuggerSupport.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/DebuggerSupport.java Mon Jun 22 13:28:57 2015 -0700
@@ -156,7 +156,7 @@
final Context context = global.getContext();
try {
- return context.eval(initialScope, string, callThis, ScriptRuntime.UNDEFINED, false);
+ return context.eval(initialScope, string, callThis, ScriptRuntime.UNDEFINED);
} catch (final Throwable ex) {
return returnException ? ex : null;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FunctionScope.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/FunctionScope.java Mon Jun 22 13:28:57 2015 -0700
@@ -35,17 +35,12 @@
*
* The constructor of this class is responsible for any function prologue
* involving the scope.
- *
- * TODO see NASHORN-715.
*/
-public class FunctionScope extends ScriptObject implements Scope {
+public class FunctionScope extends Scope {
/** Area to store scope arguments. (public for access from scripts.) */
public final ScriptObject arguments;
- /** Flag to indicate that a split method issued a return statement */
- private int splitState = -1;
-
/**
* Constructor
*
@@ -56,7 +51,6 @@
public FunctionScope(final PropertyMap map, final ScriptObject callerScope, final ScriptObject arguments) {
super(callerScope, map);
this.arguments = arguments;
- setIsScope();
}
/**
@@ -68,7 +62,6 @@
public FunctionScope(final PropertyMap map, final ScriptObject callerScope) {
super(callerScope, map);
this.arguments = null;
- setIsScope();
}
/**
@@ -82,23 +75,4 @@
super(map, primitiveSpill, objectSpill);
this.arguments = null;
}
-
-
- /**
- * Get the current split state.
- * @return current split state
- */
- @Override
- public int getSplitState() {
- return splitState;
- }
-
- /**
- * Set the current split state.
- * @param state current split state
- */
- @Override
- public void setSplitState(final int state) {
- splitState = state;
- }
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java Mon Jun 22 13:28:57 2015 -0700
@@ -597,6 +597,15 @@
}
/**
+ * Return the name of the class of objects using this property map.
+ *
+ * @return class name of owner objects.
+ */
+ public String getClassName() {
+ return className;
+ }
+
+ /**
* Prevents the map from having additional properties.
*
* @return New map with {@link #NOT_EXTENSIBLE} flag set.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Scope.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Scope.java Mon Jun 22 13:28:57 2015 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 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
@@ -25,30 +25,105 @@
package jdk.nashorn.internal.runtime;
-import static jdk.nashorn.internal.codegen.CompilerConstants.interfaceCallNoLookup;
+import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup;
import jdk.nashorn.internal.codegen.CompilerConstants;
/**
- * Interface implemented by {@link ScriptObject}s that act as scope.
+ * A {@link ScriptObject} subclass for objects that act as scope.
*/
-public interface Scope {
+public class Scope extends ScriptObject {
+
+ /* This is used to store return state of split functions. */
+ private int splitState = -1;
+
+ /** This is updated only in debug mode - counts number of {@code ScriptObject} instances created that are scope */
+ private static int count;
/** Method handle that points to {@link Scope#getSplitState}. */
- public static final CompilerConstants.Call GET_SPLIT_STATE = interfaceCallNoLookup(Scope.class, "getSplitState", int.class);
+ public static final CompilerConstants.Call GET_SPLIT_STATE = virtualCallNoLookup(Scope.class, "getSplitState", int.class);
+ /** Method handle that points to {@link Scope#setSplitState(int)}. */
+ public static final CompilerConstants.Call SET_SPLIT_STATE = virtualCallNoLookup(Scope.class, "setSplitState", void.class, int.class);
+
+ /**
+ * Constructor
+ *
+ * @param map initial property map
+ */
+ public Scope(final PropertyMap map) {
+ super(map);
+ if (Context.DEBUG) {
+ count++;
+ }
+ }
+
+ /**
+ * Constructor
+ *
+ * @param proto parent scope
+ * @param map initial property map
+ */
+ public Scope(final ScriptObject proto, final PropertyMap map) {
+ super(proto, map);
+ if (Context.DEBUG) {
+ count++;
+ }
+ }
- /** Method handle that points to {@link Scope#setSplitState(int)}. */
- public static final CompilerConstants.Call SET_SPLIT_STATE = interfaceCallNoLookup(Scope.class, "setSplitState", void.class, int.class);
+ /**
+ * Constructor
+ *
+ * @param map property map
+ * @param primitiveSpill primitive spill array
+ * @param objectSpill reference spill array
+ */
+ public Scope(final PropertyMap map, final long[] primitiveSpill, final Object[] objectSpill) {
+ super(map, primitiveSpill, objectSpill);
+ if (Context.DEBUG) {
+ count++;
+ }
+ }
+
+ @Override
+ public boolean isScope() {
+ return true;
+ }
+
+ @Override
+ boolean hasWithScope() {
+ for (ScriptObject obj = this; obj != null; obj = obj.getProto()) {
+ if (obj instanceof WithObject) {
+ return true;
+ }
+ }
+ return false;
+ }
/**
* Get the scope's split method state.
- * @return the current state
+ *
+ * @return current split state
*/
- public int getSplitState();
+ public int getSplitState() {
+ return splitState;
+ }
/**
* Set the scope's split method state.
- * @param state the new state.
+ *
+ * @param state current split state
*/
- public void setSplitState(int state);
+ public void setSplitState(final int state) {
+ splitState = state;
+ }
+
+ /**
+ * Get number of {@code Scope} instances created. If not running in debug
+ * mode this is always 0.
+ *
+ * @return number of scope ScriptObjects created
+ */
+ public static int getScopeCount() {
+ return count;
+ }
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Mon Jun 22 13:28:57 2015 -0700
@@ -109,20 +109,17 @@
/** Search fall back routine name for "no such property" */
public static final String NO_SUCH_PROPERTY_NAME = "__noSuchProperty__";
- /** Per ScriptObject flag - is this a scope object? */
- public static final int IS_SCOPE = 1 << 0;
-
/** Per ScriptObject flag - is this an array object? */
- public static final int IS_ARRAY = 1 << 1;
+ public static final int IS_ARRAY = 1 << 0;
/** Per ScriptObject flag - is this an arguments object? */
- public static final int IS_ARGUMENTS = 1 << 2;
+ public static final int IS_ARGUMENTS = 1 << 1;
/** Is length property not-writable? */
- public static final int IS_LENGTH_NOT_WRITABLE = 1 << 3;
+ public static final int IS_LENGTH_NOT_WRITABLE = 1 << 2;
/** Is this a builtin object? */
- public static final int IS_BUILTIN = 1 << 4;
+ public static final int IS_BUILTIN = 1 << 3;
/**
* Spill growth rate - by how many elements does {@link ScriptObject#primitiveSpill} and
@@ -396,14 +393,6 @@
}
/**
- * ECMA 8.10.3 IsGenericDescriptor ( Desc )
- * @return true if this has a descriptor describing an {@link AccessorPropertyDescriptor} or {@link DataPropertyDescriptor}
- */
- public final boolean isGenericDescriptor() {
- return isAccessorDescriptor() || isDataDescriptor();
- }
-
- /**
* ECMA 8.10.5 ToPropertyDescriptor ( Obj )
*
* @return property descriptor
@@ -1630,23 +1619,12 @@
return getMap().isFrozen();
}
-
- /**
- * Flag this ScriptObject as scope
- */
- public final void setIsScope() {
- if (Context.DEBUG) {
- scopeCount++;
- }
- flags |= IS_SCOPE;
- }
-
/**
* Check whether this ScriptObject is scope
* @return true if scope
*/
- public final boolean isScope() {
- return (flags & IS_SCOPE) != 0;
+ public boolean isScope() {
+ return false;
}
/**
@@ -1921,14 +1899,7 @@
* Test whether this object contains in its prototype chain or is itself a with-object.
* @return true if a with-object was found
*/
- final boolean hasWithScope() {
- if (isScope()) {
- for (ScriptObject obj = this; obj != null; obj = obj.getProto()) {
- if (obj instanceof WithObject) {
- return true;
- }
- }
- }
+ boolean hasWithScope() {
return false;
}
@@ -3817,9 +3788,6 @@
/** This is updated only in debug mode - counts number of {@code ScriptObject} instances created */
private static int count;
- /** This is updated only in debug mode - counts number of {@code ScriptObject} instances created that are scope */
- private static int scopeCount;
-
/**
* Get number of {@code ScriptObject} instances created. If not running in debug
* mode this is always 0
@@ -3829,15 +3797,4 @@
public static int getCount() {
return count;
}
-
- /**
- * Get number of scope {@code ScriptObject} instances created. If not running in debug
- * mode this is always 0
- *
- * @return number of scope ScriptObjects created
- */
- public static int getScopeCount() {
- return scopeCount;
- }
-
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptRuntime.java Mon Jun 22 13:28:57 2015 -0700
@@ -373,9 +373,9 @@
* @return prototype object after merge
*/
public static ScriptObject mergeScope(final ScriptObject scope) {
- final ScriptObject global = scope.getProto();
- global.addBoundProperties(scope);
- return global;
+ final ScriptObject parentScope = scope.getProto();
+ parentScope.addBoundProperties(scope);
+ return parentScope;
}
/**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/WithObject.java Mon Jun 22 13:28:57 2015 -0700
@@ -44,7 +44,7 @@
* This class supports the handling of scope in a with body.
*
*/
-public final class WithObject extends ScriptObject implements Scope {
+public final class WithObject extends Scope {
private static final MethodHandle WITHEXPRESSIONGUARD = findOwnMH("withExpressionGuard", boolean.class, Object.class, PropertyMap.class, SwitchPoint.class);
private static final MethodHandle WITHEXPRESSIONFILTER = findOwnMH("withFilterExpression", Object.class, Object.class);
private static final MethodHandle WITHSCOPEFILTER = findOwnMH("withFilterScope", Object.class, Object.class);
@@ -62,7 +62,6 @@
*/
WithObject(final ScriptObject scope, final ScriptObject expression) {
super(scope, null);
- setIsScope();
this.expression = expression;
}
@@ -224,29 +223,33 @@
@Override
public void setSplitState(final int state) {
- getNonWithParent().setSplitState(state);
+ ((Scope) getNonWithParent()).setSplitState(state);
}
@Override
public int getSplitState() {
- return getNonWithParent().getSplitState();
+ return ((Scope) getNonWithParent()).getSplitState();
+ }
+
+ @Override
+ public void addBoundProperties(final ScriptObject source, final Property[] properties) {
+ // Declared variables in nested eval go to first normal (non-with) parent scope.
+ getNonWithParent().addBoundProperties(source, properties);
}
/**
* Get first parent scope that is not an instance of WithObject.
*/
- private Scope getNonWithParent() {
- ScriptObject proto = getParentScope();
+ private ScriptObject getNonWithParent() {
+ ScriptObject proto = getProto();
while (proto != null && proto instanceof WithObject) {
- proto = ((WithObject)proto).getParentScope();
+ proto = proto.getProto();
}
- assert proto instanceof Scope : "with scope without parent scope";
- return (Scope) proto;
+ return proto;
}
-
private static GuardedInvocation fixReceiverType(final GuardedInvocation link, final MethodHandle filter) {
// The receiver may be an Object or a ScriptObject.
final MethodType invType = link.getInvocation().type();
@@ -380,14 +383,6 @@
return expression;
}
- /**
- * Get the parent scope for this {@code WithObject}
- * @return the parent scope
- */
- public ScriptObject getParentScope() {
- return getProto();
- }
-
private static MethodHandle findOwnMH(final String name, final Class<?> rtype, final Class<?>... types) {
return MH.findStatic(MethodHandles.lookup(), WithObject.class, name, MH.type(rtype, types));
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/Shell.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/tools/Shell.java Mon Jun 22 13:28:57 2015 -0700
@@ -439,7 +439,7 @@
}
try {
- final Object res = context.eval(global, source, global, "<shell>", env._strict);
+ final Object res = context.eval(global, source, global, "<shell>");
if (res != ScriptRuntime.UNDEFINED) {
err.println(JSType.toString(res));
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8087211.js Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,63 @@
+/*
+ * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * JDK-8087211: Indirect evals should be strict with -strict option
+ *
+ * @test
+ * @run
+ * @option -strict
+ */
+
+var global = this;
+
+try {
+ // indirect eval call.
+ global.eval("x = 34;");
+ throw new Error("should have thrown ReferenceError");
+} catch (e if e instanceof ReferenceError) {
+}
+
+
+function teststrict() {
+ "use strict";
+ // strict caller, indirect eval.
+ global.eval('public = 1;');
+}
+
+try {
+ teststrict();
+ throw new Error("should have thrown SyntaxError");
+} catch (e if e instanceof SyntaxError) {
+}
+
+function testnonstrict() {
+ // non strict caller, indirect eval.
+ global.eval('public = 1;');
+}
+
+try {
+ testnonstrict();
+ throw new Error("should have thrown SyntaxError");
+} catch (e if e instanceof SyntaxError) {
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8087211_2.js Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * JDK-8087211: Indirect evals should be strict with -strict option
+ * Make sure without -strict option, indirect evals are not strict.
+ *
+ * @test
+ * @run
+ */
+
+var global = this;
+
+// indirect eval call.
+global.eval("x = 34;");
+
+function teststrict() {
+ "use strict";
+ // strict caller, indirect eval.
+ global.eval('public = 1;');
+}
+
+teststrict();
+
+function testnonstrict() {
+ // non strict caller, indirect eval.
+ global.eval('public = 1;');
+}
+
+testnonstrict();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8087312.js Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * JDK-8087312: PropertyMapWrapper.equals should compare className
+ *
+ * @test
+ * @run
+ * @fork
+ * @option -Dnashorn.debug=true
+ */
+
+function createObject(type) {
+ // we want to make sure two different object literals with the same keys and types share the same property map.
+ if (type) {
+ return {
+ a: "a",
+ b: 1,
+ c: 0.1
+ }
+ } else {
+ return {
+ a: "x",
+ b: 10,
+ c: 3.4
+ }
+ }
+}
+
+var o1 = createObject(false);
+var o2 = createObject(true);
+Assert.assertTrue(Debug.map(o1) === Debug.map(o2));
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8098546.js Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * JDK-8098546: eval within a 'with' leaks definitions into global scope
+ *
+ * @test
+ * @run
+ */
+
+function func() {
+ var obj = { foo: 344 };
+ with (obj) {
+ eval("var x = foo + 3");
+ }
+ Assert.assertTrue(obj.x === undefined);
+ Assert.assertTrue(x === 347);
+}
+
+func();
+
+// x should be undefined here
+Assert.assertTrue(typeof x === "undefined");
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8098578.js Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * JDK-8098578: Global scope is not accessible with indirect load call
+ *
+ * @test
+ * @run
+ */
+
+var obj = { foo: 343 };
+var global = this;
+var x = 434;
+
+// indirect load call
+var res = load.call(obj, {
+ name: "t.js",
+ // global is accessible. All declarations go into
+ // intermediate inaccessible scope. "this" is global
+ // User's passed object's properties are accessible
+ // as variables.
+ script: "foo -= 300; var bar = x; Assert.assertTrue(bar == 434); function func() {}; this"
+})
+
+// 'this' for the evaluated code is global
+Assert.assertTrue(res === global);
+
+// properties of passed object are accessible in evaluated code
+Assert.assertTrue(obj.foo == 43);
+
+// vars, functions definined in evaluated code don't go into passed object
+Assert.assertTrue(typeof obj.bar == "undefined");
+Assert.assertTrue(typeof obj.func == "undefined");
+
+// vars, functions definined in evaluated code don't go leak into global
+Assert.assertTrue(typeof bar == "undefined");
+Assert.assertTrue(typeof func == "undefined");
+Assert.assertTrue(typeof foo == "undefined");
+
+var res = load.call(undefined, {
+ name: "t1.js",
+ // still global is accessible and 'this' is global
+ script: "Assert.assertTrue(x == 434); this"
+});
+
+// indirect load with 'undefined' this is same as as direct load
+// or load on global itself.
+Assert.assertTrue(res === global);
+
+// indirect load with 'undefined' this is same as as direct load
+// or load on global itself.
+var res = load.call(null, {
+ name: "t2.js",
+ // still global is accessible and 'this' is global
+ script: "Assert.assertTrue(x == 434); this"
+});
+Assert.assertTrue(res === global);
+
+// indirect load with mirror object
+var mirror = loadWithNewGlobal({
+ name: "t3.js",
+ script: "({ foo: 'hello', x: Math.PI })"
+});
+
+var res = load.call(mirror, {
+ name: "t4.js",
+ script: "Assert.assertTrue(foo == 'hello'); Assert.assertTrue(x == Math.PI); this"
+});
+Assert.assertTrue(res === global);
+
+// indirect load on non-script object, non-mirror results in TypeError
+function tryLoad(obj) {
+ try {
+ load.call(obj, {
+ name: "t5.js", script: "this"
+ });
+ throw new Error("should thrown TypeError for: " + obj);
+ } catch (e if TypeError) {}
+}
+
+tryLoad("hello");
+tryLoad(Math.E);
+tryLoad(true);
+tryLoad(false);
+
+// indirect load of a large script
+load.call({}, __DIR__ + "JDK-8098807-payload.js");
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8098807-payload.js Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,157 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * JDK-8098807: Strict eval throws ClassCastException with large scripts
+ *
+ * @subtest
+ */
+
+function f() {}
+
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
+f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f(); f();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8098807.js Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * JDK-8098807: Strict eval throws ClassCastException with large scripts
+ *
+ * @test
+ * @run
+ * @option -scripting
+ */
+
+"use strict";
+
+var path = __DIR__ + "JDK-8098807-payload.js"
+var source = readFully(path);
+eval(source);
--- a/nashorn/test/script/basic/evalreturn.js Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/test/script/basic/evalreturn.js Mon Jun 22 13:28:57 2015 -0700
@@ -59,10 +59,14 @@
print("Scoping OK");
-var f = eval("function cookie() { print('sweet and crunchy!'); } function cake() { print('moist and delicious!'); }");
+// According to the spec, evaluation of function declarations should not return a value,
+// but we return values of anonymous function declarations (Nashorn extension).
+var e = eval("function cookie() { print('sweet and crunchy!'); } function cake() { print('moist and delicious!'); }");
+print(e);
+var f = eval("function cookie() { print('sweet and crunchy!'); } function() { print('moist and delicious!'); }");
print(f);
f();
-var g = eval("function cake() { print('moist and delicious!'); } function cookie() { print('sweet and crunchy!'); }");
+var g = eval("function cake() { print('moist and delicious!'); } function() { print('sweet and crunchy!'); }");
print(g);
g();
--- a/nashorn/test/script/basic/evalreturn.js.EXPECTED Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/test/script/basic/evalreturn.js.EXPECTED Mon Jun 22 13:28:57 2015 -0700
@@ -5,7 +5,8 @@
undefined
hello
Scoping OK
-function cake() { print('moist and delicious!'); }
+undefined
+function() { print('moist and delicious!'); }
moist and delicious!
-function cookie() { print('sweet and crunchy!'); }
+function() { print('sweet and crunchy!'); }
sweet and crunchy!
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/error/JDK-8098847.js Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+/**
+ * JDK-8098847: obj."prop" and obj.'prop' should result in SyntaxError
+ *
+ * @test/compile-error
+ */
+
+var obj = { "prop": 45 };
+
+obj."prop" = "hello";
+obj.'prop' = "hello";
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/error/JDK-8098847.js.EXPECTED Mon Jun 22 13:28:57 2015 -0700
@@ -0,0 +1,6 @@
+test/script/error/JDK-8098847.js:32:5 Expected ident but found prop
+obj."prop" = "hello";
+ ^
+test/script/error/JDK-8098847.js:33:5 Expected ident but found prop
+obj.'prop' = "hello";
+ ^
--- a/nashorn/test/src/jdk/nashorn/api/scripting/JSONCompatibleTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/JSONCompatibleTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -97,12 +97,14 @@
assertEquals(x2.get("1"), 5);
}
+ @SuppressWarnings("unchecked")
private static List<Object> asList(final Object obj) {
assertJSObject(obj);
Assert.assertTrue(obj instanceof List);
return (List)obj;
}
+ @SuppressWarnings("unchecked")
private static Map<String, Object> asMap(final Object obj) {
assertJSObject(obj);
Assert.assertTrue(obj instanceof Map);
--- a/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java Thu Jun 04 18:28:52 2015 +0200
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/test/ScriptObjectMirrorTest.java Mon Jun 22 13:28:57 2015 -0700
@@ -204,7 +204,7 @@
}
try {
- final Object obj = e.eval("function func() { print('hello'); }");
+ final Object obj = e.eval("(function func() { print('hello'); })");
assertEquals(obj.toString(), "function func() { print('hello'); }", "toString returns wrong value");
} catch (final Throwable t) {
t.printStackTrace();