--- a/.hgtags Tue Feb 17 13:19:23 2015 -0500
+++ b/.hgtags Wed Feb 18 19:27:49 2015 -0800
@@ -291,3 +291,5 @@
722378bc599e38d9a1dd484de30f10dfd7b21438 jdk9-b46
8327024a99559982b848e9c2191da9c0bf8838fd jdk9-b47
b2f9702efbe95527ea3a991474fda23987ff1c5c jdk9-b48
+5b8db585a33c3cc48e70e688ceee57dd9271dc5d jdk9-b49
+1550b2f6b63d1411fa84dc7bbc6f04809aedb43f jdk9-b50
--- a/.hgtags-top-repo Tue Feb 17 13:19:23 2015 -0500
+++ b/.hgtags-top-repo Wed Feb 18 19:27:49 2015 -0800
@@ -291,3 +291,5 @@
12f1e276447bcc81516e85367d53e4f08897049d jdk9-b46
b6cca3e6175a69f39e5799b7349ddb0176630291 jdk9-b47
0064e246d83f6f9fc245c19b6d05041ecaf4b6d4 jdk9-b48
+d91ed1951b948210590ce1394bea5515357246ba jdk9-b49
+d1f37d39ff2421f956a6ddf316cf763807bc3363 jdk9-b50
--- a/README-builds.html Tue Feb 17 13:19:23 2015 -0500
+++ b/README-builds.html Wed Feb 18 19:27:49 2015 -0800
@@ -1463,14 +1463,13 @@
<h4>Building with ccache</h4>
- <p>A simple way to radically speed up compilation of native code
- (typically hotspot and native libraries in JDK) is to install
- ccache. This will cache and reuse prior compilation results, if the
- source code is unchanged. However, ccache versions prior to 3.1.4
- does not work correctly with the precompiled headers used in
- OpenJDK. So if your platform supports ccache at 3.1.4 or later, we
- highly recommend installing it. This is currently only supported on
- linux.</p>
+ <p>The OpenJDK build supports building with ccache
+ when using gcc or clang. Using ccache can
+ radically speed up compilation of native code if
+ you often rebuild the same sources. Your milage
+ may vary however so we recommend evaluating it for
+ yourself. To enable it, make sure it's on the path
+ and configure with <code>--enable-ccache</code>.</p>
<h4>Building on local disk</h4>
--- a/common/autoconf/basics.m4 Tue Feb 17 13:19:23 2015 -0500
+++ b/common/autoconf/basics.m4 Wed Feb 18 19:27:49 2015 -0800
@@ -242,6 +242,9 @@
[
# Save the original command line. This is passed to us by the wrapper configure script.
AC_SUBST(CONFIGURE_COMMAND_LINE)
+ # Save the path variable before it gets changed
+ ORIGINAL_PATH="$PATH"
+ AC_SUBST(ORIGINAL_PATH)
DATE_WHEN_CONFIGURED=`LANG=C date`
AC_SUBST(DATE_WHEN_CONFIGURED)
AC_MSG_NOTICE([Configuration created at $DATE_WHEN_CONFIGURED.])
--- a/common/autoconf/build-performance.m4 Tue Feb 17 13:19:23 2015 -0500
+++ b/common/autoconf/build-performance.m4 Wed Feb 18 19:27:49 2015 -0800
@@ -164,19 +164,26 @@
[enable using ccache to speed up recompilations @<:@disabled@:>@])])
CCACHE=
+ CCACHE_STATUS=
AC_MSG_CHECKING([is ccache enabled])
- ENABLE_CCACHE=$enable_ccache
if test "x$enable_ccache" = xyes; then
- AC_MSG_RESULT([yes])
- OLD_PATH="$PATH"
- if test "x$TOOLCHAIN_PATH" != x; then
- PATH=$TOOLCHAIN_PATH:$PATH
+ if test "x$TOOLCHAIN_TYPE" = "xgcc" -o "x$TOOLCHAIN_TYPE" = "xclang"; then
+ AC_MSG_RESULT([yes])
+ OLD_PATH="$PATH"
+ if test "x$TOOLCHAIN_PATH" != x; then
+ PATH=$TOOLCHAIN_PATH:$PATH
+ fi
+ BASIC_REQUIRE_PROGS(CCACHE, ccache)
+ PATH="$OLD_PATH"
+ CCACHE_VERSION=[`$CCACHE --version | head -n1 | $SED 's/[A-Za-z ]*//'`]
+ CCACHE_STATUS="Active ($CCACHE_VERSION)"
+ else
+ AC_MSG_RESULT([no])
+ AC_MSG_WARN([ccache is not supported with toolchain type $TOOLCHAIN_TYPE])
fi
- BASIC_REQUIRE_PROGS(CCACHE, ccache)
- CCACHE_STATUS="enabled"
- PATH="$OLD_PATH"
elif test "x$enable_ccache" = xno; then
AC_MSG_RESULT([no, explicitly disabled])
+ CCACHE_STATUS="Disabled"
elif test "x$enable_ccache" = x; then
AC_MSG_RESULT([no])
else
@@ -206,35 +213,31 @@
AC_DEFUN([BPERF_SETUP_CCACHE_USAGE],
[
if test "x$CCACHE" != x; then
- # Only use ccache if it is 3.1.4 or later, which supports
- # precompiled headers.
- AC_MSG_CHECKING([if ccache supports precompiled headers])
- HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.@<:@456789@:>@) 2> /dev/null`
- if test "x$HAS_GOOD_CCACHE" = x; then
- AC_MSG_RESULT([no, disabling ccache])
- CCACHE=
- CCACHE_STATUS="disabled"
- else
- AC_MSG_RESULT([yes])
+ if test "x$USE_PRECOMPILED_HEADER" = "x1"; then
+ HAS_BAD_CCACHE=[`$ECHO $CCACHE_VERSION | \
+ $GREP -e '^1.*' -e '^2.*' -e '^3\.0.*' -e '^3\.1\.[0123]'`]
+ if test "x$HAS_BAD_CCACHE" != "x"; then
+ AC_MSG_ERROR([Precompiled headers requires ccache 3.1.4 or later, found $CCACHE_VERSION])
+ fi
AC_MSG_CHECKING([if C-compiler supports ccache precompiled headers])
+ CCACHE_PRECOMP_FLAG="-fpch-preprocess"
PUSHED_FLAGS="$CXXFLAGS"
- CXXFLAGS="-fpch-preprocess $CXXFLAGS"
+ CXXFLAGS="$CCACHE_PRECOMP_FLAG $CXXFLAGS"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [CC_KNOWS_CCACHE_TRICK=yes], [CC_KNOWS_CCACHE_TRICK=no])
CXXFLAGS="$PUSHED_FLAGS"
if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then
AC_MSG_RESULT([yes])
+ CFLAGS_CCACHE="$CCACHE_PRECOMP_FLAG"
+ AC_SUBST(CFLAGS_CCACHE)
+ CCACHE_SLOPPINESS=pch_defines,time_macros
else
- AC_MSG_RESULT([no, disabling ccaching of precompiled headers])
- CCACHE=
- CCACHE_STATUS="disabled"
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([Cannot use ccache with precompiled headers without compiler support for $CCACHE_PRECOMP_FLAG])
fi
fi
- fi
- if test "x$CCACHE" != x; then
- CCACHE_SLOPPINESS=time_macros
- CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE"
- CCACHE_FLAGS=-fpch-preprocess
+ CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR \
+ CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS CCACHE_BASEDIR=$TOPDIR $CCACHE"
if test "x$SET_CCACHE_DIR" != x; then
mkdir -p $CCACHE_DIR > /dev/null 2>&1
--- a/common/autoconf/configure Tue Feb 17 13:19:23 2015 -0500
+++ b/common/autoconf/configure Wed Feb 18 19:27:49 2015 -0800
@@ -40,8 +40,9 @@
echo "Error: This script must be run using bash." 1>&2
exit 1
fi
-# Force autoconf to use bash
+# Force autoconf to use bash. This also means we must disable autoconf re-exec.
export CONFIG_SHELL=$BASH
+export _as_can_reexec=no
conf_script_dir="$TOPDIR/common/autoconf"
--- a/common/autoconf/generated-configure.sh Tue Feb 17 13:19:23 2015 -0500
+++ b/common/autoconf/generated-configure.sh Wed Feb 18 19:27:49 2015 -0800
@@ -629,6 +629,7 @@
ac_subst_vars='LTLIBOBJS
LIBOBJS
+CFLAGS_CCACHE
CCACHE
USE_PRECOMPILED_HEADER
SJAVAC_SERVER_DIR
@@ -991,6 +992,7 @@
BASH
BASENAME
DATE_WHEN_CONFIGURED
+ORIGINAL_PATH
CONFIGURE_COMMAND_LINE
target_alias
host_alias
@@ -4333,7 +4335,7 @@
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1421247827
+DATE_WHEN_GENERATED=1423567509
###############################################################################
#
@@ -4366,6 +4368,9 @@
# Save the original command line. This is passed to us by the wrapper configure script.
+ # Save the path variable before it gets changed
+ ORIGINAL_PATH="$PATH"
+
DATE_WHEN_CONFIGURED=`LANG=C date`
{ $as_echo "$as_me:${as_lineno-$LINENO}: Configuration created at $DATE_WHEN_CONFIGURED." >&5
@@ -27438,8 +27443,8 @@
# The trailing space for everyone except PATH is no typo, but is needed due
# to trailing \ in the Windows paths. These will be stripped later.
$ECHO "$WINPATH_BASH -c 'echo VS_PATH="'\"$PATH\" > set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
- $ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
- $ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
+ $ECHO "$WINPATH_BASH -c 'echo VS_INCLUDE="'\"$INCLUDE\;$include \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
+ $ECHO "$WINPATH_BASH -c 'echo VS_LIB="'\"$LIB\;$lib \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo VCINSTALLDIR="'\"$VCINSTALLDIR \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo WindowsSdkDir="'\"$WindowsSdkDir \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
$ECHO "$WINPATH_BASH -c 'echo WINDOWSSDKDIR="'\"$WINDOWSSDKDIR \" >> set-vs-env.sh' >> $EXTRACT_VC_ENV_BAT_FILE
@@ -27486,9 +27491,9 @@
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
$as_echo "ok" >&6; }
- # Remove any trailing "\" and " " from the variables.
- VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED 's/\\\\* *$//'`
- VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\* *$//'`
+ # Remove any trailing "\" ";" and " " from the variables.
+ VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED -e 's/\\\\*;* *$//'`
+ VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\*;* *$//'`
VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
WindowsSDKDir=`$ECHO "$WindowsSDKDir" | $SED 's/\\\\* *$//'`
WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
@@ -27499,6 +27504,268 @@
+
+ # Convert VS_INCLUDE into SYSROOT_CFLAGS
+ OLDIFS="$IFS"
+ IFS=";"
+ for i in $VS_INCLUDE; do
+ ipath=$i
+ IFS="$OLDIFS"
+
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+ # Input might be given as Windows format, start by converting to
+ # unix format.
+ path="$ipath"
+ new_path=`$CYGPATH -u "$path"`
+
+ # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+ # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+ # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+ # "foo.exe" is OK but "foo" is an error.
+ #
+ # This test is therefore slightly more accurate than "test -f" to check for file precense.
+ # It is also a way to make sure we got the proper file name for the real test later on.
+ test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+ if test "x$test_shortpath" = x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of ipath, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of ipath, which resolves as \"$path\", is invalid." >&6;}
+ as_fn_error $? "Cannot locate the the path of ipath" "$LINENO" 5
+ fi
+
+ # Call helper function which possibly converts this using DOS-style short mode.
+ # If so, the updated path is stored in $new_path.
+
+ input_path="$new_path"
+ # Check if we need to convert this using DOS-style short mode. If the path
+ # contains just simple characters, use it. Otherwise (spaces, weird characters),
+ # take no chances and rewrite it.
+ # Note: m4 eats our [], so we need to use [ and ] instead.
+ has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+ if test "x$has_forbidden_chars" != x; then
+ # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+ shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+ path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+ if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+ # Going to short mode and back again did indeed matter. Since short mode is
+ # case insensitive, let's make it lowercase to improve readability.
+ shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ # Now convert it back to Unix-stile (cygpath)
+ input_path=`$CYGPATH -u "$shortmode_path"`
+ new_path="$input_path"
+ fi
+ fi
+
+ test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+ if test "x$test_cygdrive_prefix" = x; then
+ # As a simple fix, exclude /usr/bin since it's not a real path.
+ if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+ # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+ # a path prefixed by /cygdrive for fixpath to work.
+ new_path="$CYGWIN_ROOT_PATH$input_path"
+ fi
+ fi
+
+
+ if test "x$path" != "x$new_path"; then
+ ipath="$new_path"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting ipath to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting ipath to \"$new_path\"" >&6;}
+ fi
+
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+ path="$ipath"
+ has_colon=`$ECHO $path | $GREP ^.:`
+ new_path="$path"
+ if test "x$has_colon" = x; then
+ # Not in mixed or Windows style, start by that.
+ new_path=`cmd //c echo $path`
+ fi
+
+
+ input_path="$new_path"
+ # Check if we need to convert this using DOS-style short mode. If the path
+ # contains just simple characters, use it. Otherwise (spaces, weird characters),
+ # take no chances and rewrite it.
+ # Note: m4 eats our [], so we need to use [ and ] instead.
+ has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+ if test "x$has_forbidden_chars" != x; then
+ # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+ new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ fi
+
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+ if test "x$path" != "x$new_path"; then
+ ipath="$new_path"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting ipath to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting ipath to \"$new_path\"" >&6;}
+ fi
+
+ # Save the first 10 bytes of this path to the storage, so fixpath can work.
+ all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+ else
+ # We're on a unix platform. Hooray! :)
+ path="$ipath"
+ has_space=`$ECHO "$path" | $GREP " "`
+ if test "x$has_space" != x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of ipath, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of ipath, which resolves as \"$path\", is invalid." >&6;}
+ as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+ fi
+
+ # Use eval to expand a potential ~
+ eval path="$path"
+ if test ! -f "$path" && test ! -d "$path"; then
+ as_fn_error $? "The path of ipath, which resolves as \"$path\", is not found." "$LINENO" 5
+ fi
+
+ ipath="`cd "$path"; $THEPWDCMD -L`"
+ fi
+
+ IFS=";"
+ SYSROOT_CFLAGS="$SYSROOT_CFLAGS -I$ipath"
+ done
+ # Convert VS_LIB into SYSROOT_LDFLAGS
+ for i in $VS_LIB; do
+ libpath=$i
+ IFS="$OLDIFS"
+
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+ # Input might be given as Windows format, start by converting to
+ # unix format.
+ path="$libpath"
+ new_path=`$CYGPATH -u "$path"`
+
+ # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+ # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+ # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+ # "foo.exe" is OK but "foo" is an error.
+ #
+ # This test is therefore slightly more accurate than "test -f" to check for file precense.
+ # It is also a way to make sure we got the proper file name for the real test later on.
+ test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+ if test "x$test_shortpath" = x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of libpath, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of libpath, which resolves as \"$path\", is invalid." >&6;}
+ as_fn_error $? "Cannot locate the the path of libpath" "$LINENO" 5
+ fi
+
+ # Call helper function which possibly converts this using DOS-style short mode.
+ # If so, the updated path is stored in $new_path.
+
+ input_path="$new_path"
+ # Check if we need to convert this using DOS-style short mode. If the path
+ # contains just simple characters, use it. Otherwise (spaces, weird characters),
+ # take no chances and rewrite it.
+ # Note: m4 eats our [], so we need to use [ and ] instead.
+ has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+ if test "x$has_forbidden_chars" != x; then
+ # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+ shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+ path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+ if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+ # Going to short mode and back again did indeed matter. Since short mode is
+ # case insensitive, let's make it lowercase to improve readability.
+ shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ # Now convert it back to Unix-stile (cygpath)
+ input_path=`$CYGPATH -u "$shortmode_path"`
+ new_path="$input_path"
+ fi
+ fi
+
+ test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+ if test "x$test_cygdrive_prefix" = x; then
+ # As a simple fix, exclude /usr/bin since it's not a real path.
+ if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+ # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+ # a path prefixed by /cygdrive for fixpath to work.
+ new_path="$CYGWIN_ROOT_PATH$input_path"
+ fi
+ fi
+
+
+ if test "x$path" != "x$new_path"; then
+ libpath="$new_path"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting libpath to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting libpath to \"$new_path\"" >&6;}
+ fi
+
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+ path="$libpath"
+ has_colon=`$ECHO $path | $GREP ^.:`
+ new_path="$path"
+ if test "x$has_colon" = x; then
+ # Not in mixed or Windows style, start by that.
+ new_path=`cmd //c echo $path`
+ fi
+
+
+ input_path="$new_path"
+ # Check if we need to convert this using DOS-style short mode. If the path
+ # contains just simple characters, use it. Otherwise (spaces, weird characters),
+ # take no chances and rewrite it.
+ # Note: m4 eats our [], so we need to use [ and ] instead.
+ has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+ if test "x$has_forbidden_chars" != x; then
+ # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+ new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ fi
+
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+ if test "x$path" != "x$new_path"; then
+ libpath="$new_path"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting libpath to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting libpath to \"$new_path\"" >&6;}
+ fi
+
+ # Save the first 10 bytes of this path to the storage, so fixpath can work.
+ all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+ else
+ # We're on a unix platform. Hooray! :)
+ path="$libpath"
+ has_space=`$ECHO "$path" | $GREP " "`
+ if test "x$has_space" != x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of libpath, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of libpath, which resolves as \"$path\", is invalid." >&6;}
+ as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+ fi
+
+ # Use eval to expand a potential ~
+ eval path="$path"
+ if test ! -f "$path" && test ! -d "$path"; then
+ as_fn_error $? "The path of libpath, which resolves as \"$path\", is not found." "$LINENO" 5
+ fi
+
+ libpath="`cd "$path"; $THEPWDCMD -L`"
+ fi
+
+ IFS=";"
+ SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -libpath:$libpath"
+ done
+ IFS="$OLDIFS"
fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
@@ -50616,16 +50883,17 @@
CCACHE=
+ CCACHE_STATUS=
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking is ccache enabled" >&5
$as_echo_n "checking is ccache enabled... " >&6; }
- ENABLE_CCACHE=$enable_ccache
if test "x$enable_ccache" = xyes; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+ if test "x$TOOLCHAIN_TYPE" = "xgcc" -o "x$TOOLCHAIN_TYPE" = "xclang"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- OLD_PATH="$PATH"
- if test "x$TOOLCHAIN_PATH" != x; then
- PATH=$TOOLCHAIN_PATH:$PATH
- fi
+ OLD_PATH="$PATH"
+ if test "x$TOOLCHAIN_PATH" != x; then
+ PATH=$TOOLCHAIN_PATH:$PATH
+ fi
@@ -50819,11 +51087,19 @@
fi
- CCACHE_STATUS="enabled"
- PATH="$OLD_PATH"
+ PATH="$OLD_PATH"
+ CCACHE_VERSION=`$CCACHE --version | head -n1 | $SED 's/[A-Za-z ]*//'`
+ CCACHE_STATUS="Active ($CCACHE_VERSION)"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: ccache is not supported with toolchain type $TOOLCHAIN_TYPE" >&5
+$as_echo "$as_me: WARNING: ccache is not supported with toolchain type $TOOLCHAIN_TYPE" >&2;}
+ fi
elif test "x$enable_ccache" = xno; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no, explicitly disabled" >&5
$as_echo "no, explicitly disabled" >&6; }
+ CCACHE_STATUS="Disabled"
elif test "x$enable_ccache" = x; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
@@ -50854,23 +51130,17 @@
if test "x$CCACHE" != x; then
if test "x$CCACHE" != x; then
- # Only use ccache if it is 3.1.4 or later, which supports
- # precompiled headers.
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking if ccache supports precompiled headers" >&5
-$as_echo_n "checking if ccache supports precompiled headers... " >&6; }
- HAS_GOOD_CCACHE=`($CCACHE --version | head -n 1 | grep -E 3.1.[456789]) 2> /dev/null`
- if test "x$HAS_GOOD_CCACHE" = x; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, disabling ccache" >&5
-$as_echo "no, disabling ccache" >&6; }
- CCACHE=
- CCACHE_STATUS="disabled"
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
+ if test "x$USE_PRECOMPILED_HEADER" = "x1"; then
+ HAS_BAD_CCACHE=`$ECHO $CCACHE_VERSION | \
+ $GREP -e '^1.*' -e '^2.*' -e '^3\.0.*' -e '^3\.1\.[0123]'`
+ if test "x$HAS_BAD_CCACHE" != "x"; then
+ as_fn_error $? "Precompiled headers requires ccache 3.1.4 or later, found $CCACHE_VERSION" "$LINENO" 5
+ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if C-compiler supports ccache precompiled headers" >&5
$as_echo_n "checking if C-compiler supports ccache precompiled headers... " >&6; }
+ CCACHE_PRECOMP_FLAG="-fpch-preprocess"
PUSHED_FLAGS="$CXXFLAGS"
- CXXFLAGS="-fpch-preprocess $CXXFLAGS"
+ CXXFLAGS="$CCACHE_PRECOMP_FLAG $CXXFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
@@ -50892,19 +51162,18 @@
if test "x$CC_KNOWS_CCACHE_TRICK" = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
- else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, disabling ccaching of precompiled headers" >&5
-$as_echo "no, disabling ccaching of precompiled headers" >&6; }
- CCACHE=
- CCACHE_STATUS="disabled"
- fi
- fi
- fi
-
- if test "x$CCACHE" != x; then
- CCACHE_SLOPPINESS=time_macros
- CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS $CCACHE"
- CCACHE_FLAGS=-fpch-preprocess
+ CFLAGS_CCACHE="$CCACHE_PRECOMP_FLAG"
+
+ CCACHE_SLOPPINESS=pch_defines,time_macros
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ as_fn_error $? "Cannot use ccache with precompiled headers without compiler support for $CCACHE_PRECOMP_FLAG" "$LINENO" 5
+ fi
+ fi
+
+ CCACHE="CCACHE_COMPRESS=1 $SET_CCACHE_DIR \
+ CCACHE_SLOPPINESS=$CCACHE_SLOPPINESS CCACHE_BASEDIR=$TOPDIR $CCACHE"
if test "x$SET_CCACHE_DIR" != x; then
mkdir -p $CCACHE_DIR > /dev/null 2>&1
--- a/common/autoconf/hotspot-spec.gmk.in Tue Feb 17 13:19:23 2015 -0500
+++ b/common/autoconf/hotspot-spec.gmk.in Wed Feb 18 19:27:49 2015 -0800
@@ -109,8 +109,8 @@
MT:=@HOTSPOT_MT@
RC:=@HOTSPOT_RC@
-EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@
-EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@
+EXTRA_CFLAGS=@LEGACY_EXTRA_CFLAGS@ $(CFLAGS_CCACHE)
+EXTRA_CXXFLAGS=@LEGACY_EXTRA_CXXFLAGS@ $(CFLAGS_CCACHE)
EXTRA_LDFLAGS=@LEGACY_EXTRA_LDFLAGS@
USE_PRECOMPILED_HEADER=@USE_PRECOMPILED_HEADER@
@@ -132,6 +132,13 @@
ZIP_DEBUGINFO_FILES:=0
endif
+ifeq ($(OPENJDK_TARGET_OS), windows)
+ # On Windows, the Visual Studio toolchain needs the LIB and INCLUDE
+ # environment variables (in Windows path style).
+ export INCLUDE:=@VS_INCLUDE@
+ export LIB:=@VS_LIB@
+endif
+
# Sneak this in via the spec.gmk file, since we don't want to mess around too much with the Hotspot make files.
# This is needed to get the LOG setting to work properly.
include $(SRC_ROOT)/make/common/MakeBase.gmk
--- a/common/autoconf/spec.gmk.in Tue Feb 17 13:19:23 2015 -0500
+++ b/common/autoconf/spec.gmk.in Wed Feb 18 19:27:49 2015 -0800
@@ -129,14 +129,12 @@
# colon or semicolon
PATH_SEP:=@PATH_SEP@
+# Save the original path before replacing it with the Visual Studio tools
+ORIGINAL_PATH:=@ORIGINAL_PATH@
ifeq ($(OPENJDK_TARGET_OS), windows)
- # On Windows, the Visual Studio toolchain needs the LIB and INCLUDE
- # environment variables (in Windows path style), and the PATH needs to
- # be adjusted to include Visual Studio tools (but this needs to be in
- # cygwin/msys style).
+ # On Windows, the Visual Studio toolchain needs the PATH to be adjusted
+ # to include Visual Studio tools (this needs to be in cygwin/msys style).
export PATH:=@VS_PATH@
- export INCLUDE:=@VS_INCLUDE@
- export LIB:=@VS_LIB@
endif
SYSROOT_CFLAGS := @SYSROOT_CFLAGS@
@@ -328,6 +326,8 @@
CFLAGS_WARNINGS_ARE_ERRORS:=@CFLAGS_WARNINGS_ARE_ERRORS@
+CFLAGS_CCACHE:=@CFLAGS_CCACHE@
+
# Tools that potentially need to be cross compilation aware.
CC:=@FIXPATH@ @CCACHE@ @CC@
--- a/common/autoconf/toolchain_windows.m4 Tue Feb 17 13:19:23 2015 -0500
+++ b/common/autoconf/toolchain_windows.m4 Wed Feb 18 19:27:49 2015 -0800
@@ -213,9 +213,9 @@
AC_MSG_ERROR([Your VC command prompt seems broken, INCLUDE and/or LIB is missing.])
else
AC_MSG_RESULT([ok])
- # Remove any trailing "\" and " " from the variables.
- VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED 's/\\\\* *$//'`
- VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\* *$//'`
+ # Remove any trailing "\" ";" and " " from the variables.
+ VS_INCLUDE=`$ECHO "$VS_INCLUDE" | $SED -e 's/\\\\*;* *$//'`
+ VS_LIB=`$ECHO "$VS_LIB" | $SED 's/\\\\*;* *$//'`
VCINSTALLDIR=`$ECHO "$VCINSTALLDIR" | $SED 's/\\\\* *$//'`
WindowsSDKDir=`$ECHO "$WindowsSDKDir" | $SED 's/\\\\* *$//'`
WINDOWSSDKDIR=`$ECHO "$WINDOWSSDKDIR" | $SED 's/\\\\* *$//'`
@@ -226,6 +226,26 @@
AC_SUBST(VS_PATH)
AC_SUBST(VS_INCLUDE)
AC_SUBST(VS_LIB)
+
+ # Convert VS_INCLUDE into SYSROOT_CFLAGS
+ OLDIFS="$IFS"
+ IFS=";"
+ for i in $VS_INCLUDE; do
+ ipath=$i
+ IFS="$OLDIFS"
+ BASIC_FIXUP_PATH([ipath])
+ IFS=";"
+ SYSROOT_CFLAGS="$SYSROOT_CFLAGS -I$ipath"
+ done
+ # Convert VS_LIB into SYSROOT_LDFLAGS
+ for i in $VS_LIB; do
+ libpath=$i
+ IFS="$OLDIFS"
+ BASIC_FIXUP_PATH([libpath])
+ IFS=";"
+ SYSROOT_LDFLAGS="$SYSROOT_LDFLAGS -libpath:$libpath"
+ done
+ IFS="$OLDIFS"
fi
else
AC_MSG_RESULT([not found])
--- a/common/bin/unshuffle_list.txt Tue Feb 17 13:19:23 2015 -0500
+++ b/common/bin/unshuffle_list.txt Wed Feb 18 19:27:49 2015 -0800
@@ -123,6 +123,7 @@
jdk/src/java.base/share/classes/java/math : jdk/src/share/classes/java/math
jdk/src/java.base/share/classes/java/net : jdk/src/share/classes/java/net
jdk/src/java.base/share/classes/java/nio : jdk/src/share/classes/java/nio
+jdk/src/java.base/share/classes/java/security/acl : jdk/src/share/classes/java/security/acl
jdk/src/java.base/share/classes/java/security/cert : jdk/src/share/classes/java/security/cert
jdk/src/java.base/share/classes/java/security/interfaces : jdk/src/share/classes/java/security/interfaces
jdk/src/java.base/share/classes/java/security : jdk/src/share/classes/java/security
@@ -179,6 +180,7 @@
jdk/src/java.base/share/classes/sun/nio/cs : jdk/src/share/classes/sun/nio/cs
jdk/src/java.base/share/classes/sun/nio/fs : jdk/src/share/classes/sun/nio/fs
jdk/src/java.base/share/classes/sun/reflect : jdk/src/share/classes/sun/reflect
+jdk/src/java.base/share/classes/sun/security/acl : jdk/src/share/classes/sun/security/acl
jdk/src/java.base/share/classes/sun/security/action : jdk/src/share/classes/sun/security/action
jdk/src/java.base/share/classes/sun/security/internal : jdk/src/share/classes/sun/security/internal
jdk/src/java.base/share/classes/sun/security/jca : jdk/src/share/classes/sun/security/jca
@@ -1211,8 +1213,6 @@
jdk/src/java.rmi/unix/bin/java-rmi.cgi.sh : jdk/src/solaris/bin/java-rmi.cgi.sh
jdk/src/java.scripting/share/classes/javax/script : jdk/src/share/classes/javax/script
jdk/src/java.scripting/share/classes/com/sun/tools/script/shell : jdk/src/share/classes/com/sun/tools/script/shell
-jdk/src/java.security.acl/share/classes/java/security/acl : jdk/src/share/classes/java/security/acl
-jdk/src/java.security.acl/share/classes/sun/security/acl : jdk/src/share/classes/sun/security/acl
jdk/src/java.security.jgss/macosx/native/libosxkrb5/nativeccache.c : jdk/src/share/native/sun/security/krb5/nativeccache.c
jdk/src/java.security.jgss/macosx/native/libosxkrb5/SCDynamicStoreConfig.m : jdk/src/macosx/native/sun/security/krb5/SCDynamicStoreConfig.m
jdk/src/java.security.jgss/share/classes/javax/security/auth/kerberos : jdk/src/share/classes/javax/security/auth/kerberos
--- a/corba/.hgtags Tue Feb 17 13:19:23 2015 -0500
+++ b/corba/.hgtags Wed Feb 18 19:27:49 2015 -0800
@@ -291,3 +291,5 @@
326f2068b4a4c05e2fa27d6acf93eba7b54b090d jdk9-b46
ee8447ca632e1d39180b4767c749db101bff7314 jdk9-b47
a13c49c5f2899b702652a460ed7aa73123e671e6 jdk9-b48
+9285d14eb7b6b0815679bae98dd936dbc136218d jdk9-b49
+224f593393e5b01b3c8f1e591b7f4b1790a3737a jdk9-b50
--- a/hotspot/.hgtags Tue Feb 17 13:19:23 2015 -0500
+++ b/hotspot/.hgtags Wed Feb 18 19:27:49 2015 -0800
@@ -451,3 +451,5 @@
a184ee1d717297bd35b7c3e35393e137921a3ed2 jdk9-b46
3b241fb72b8925b75941d612db762a6d5da66d02 jdk9-b47
cc775a4a24c7f5d9e624b4205e9fbd48a17331f6 jdk9-b48
+360cd1fc42f10941a9fd17cc32d5b85a22d12a0b jdk9-b49
+e0947f58c9c1426aa0d98b98ebb78357b27a7b99 jdk9-b50
--- a/jaxp/.hgtags Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxp/.hgtags Wed Feb 18 19:27:49 2015 -0800
@@ -291,3 +291,5 @@
74eaf7ad986576c792df4dbff05eed63e5727695 jdk9-b46
e391de88e69b59d7c618387e3cf91032f6991ce9 jdk9-b47
833051855168a973780fafeb6fc59e7370bcf400 jdk9-b48
+786058752e0ac3e48d7aef79e0885d29d6a2a7eb jdk9-b49
+74ead7bddde19263fd463bc1bd87de84f27d1b5e jdk9-b50
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/DurationTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,585 @@
+/*
+ * Copyright (c) 1999, 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.datatype.ptests;
+
+import static javax.xml.datatype.DatatypeConstants.DAYS;
+import static javax.xml.datatype.DatatypeConstants.HOURS;
+import static javax.xml.datatype.DatatypeConstants.MINUTES;
+import static javax.xml.datatype.DatatypeConstants.MONTHS;
+import static javax.xml.datatype.DatatypeConstants.SECONDS;
+import static javax.xml.datatype.DatatypeConstants.YEARS;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.util.Calendar;
+import java.util.function.Function;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+import javax.xml.namespace.QName;
+
+import jaxp.library.JAXPBaseTest;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/*
+ * @summary Class containing the test cases for Duration.
+ */
+public class DurationTest extends JAXPBaseTest {
+
+ private DatatypeFactory datatypeFactory;
+
+ /*
+ * Setup.
+ */
+ @BeforeClass
+ public void setup() throws DatatypeConfigurationException {
+ datatypeFactory = DatatypeFactory.newInstance();
+ }
+
+ @DataProvider(name = "legal-number-duration")
+ public Object[][] getLegalNumberDuration() {
+ return new Object[][] {
+ // is positive, year, month, day, hour, minute, second
+ { true, 1, 1, 1, 1, 1, 1 },
+ { false, 1, 1, 1, 1, 1, 1 },
+ { true, 1, 0, 0, 0, 0, 0 },
+ { false, 1, 0, 0, 0, 0, 0 }
+ };
+ }
+
+ /*
+ * Test for constructor Duration(boolean isPositive,int years,int months,
+ * int days,int hours,int minutes,int seconds).
+ */
+ @Test(dataProvider = "legal-number-duration")
+ public void checkNumberDurationPos(boolean isPositive, int years, int months, int days, int hours, int minutes, int seconds) {
+ datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds);
+ }
+
+ @DataProvider(name = "illegal-number-duration")
+ public Object[][] getIllegalNumberDuration() {
+ return new Object[][] {
+ // is positive, year, month, day, hour, minute, second
+ { true, 1, 1, -1, 1, 1, 1 },
+ { false, 1, 1, -1, 1, 1, 1 },
+ { true, undef, undef, undef, undef, undef, undef },
+ { false, undef, undef, undef, undef, undef, undef }
+ };
+ }
+
+ /*
+ * Test for constructor Duration(boolean isPositive,int years,int months,
+ * int days,int hours,int minutes,int seconds), if any of the fields is
+ * negative should throw IllegalArgumentException.
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegal-number-duration")
+ public void checkDurationNumberNeg(boolean isPositive, int years, int months, int days, int hours, int minutes, int seconds) {
+ datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds);
+ }
+
+ @DataProvider(name = "legal-bigint-duration")
+ public Object[][] getLegalBigIntegerDuration() {
+ return new Object[][] {
+ // is positive, year, month, day, hour, minute, second
+ { true, zero, zero, zero, zero, zero, new BigDecimal(zero) },
+ { false, zero, zero, zero, zero, zero, new BigDecimal(zero) },
+ { true, one, one, one, one, one, new BigDecimal(one) },
+ { false, one, one, one, one, one, new BigDecimal(one) },
+ { true, null, null, null, null, null, new BigDecimal(one) },
+ { false, null, null, null, null, null, new BigDecimal(one) } };
+ }
+
+ /*
+ * Test for constructor Duration(boolean isPositive,BigInteger
+ * years,BigInteger months, BigInteger days,BigInteger hours,BigInteger
+ * minutes,BigDecimal seconds).
+ */
+ @Test(dataProvider = "legal-bigint-duration")
+ public void checkBigIntegerDurationPos(boolean isPositive, BigInteger years, BigInteger months, BigInteger days, BigInteger hours, BigInteger minutes,
+ BigDecimal seconds) {
+ datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds);
+ }
+
+ @DataProvider(name = "illegal-bigint-duration")
+ public Object[][] getIllegalBigIntegerDuration() {
+ return new Object[][] {
+ // is positive, year, month, day, hour, minute, second
+ { true, null, null, null, null, null, null },
+ { false, null, null, null, null, null, null }
+ };
+ }
+
+ /*
+ * Test for constructor Duration(boolean isPositive,BigInteger
+ * years,BigInteger months, BigInteger days,BigInteger hours,BigInteger
+ * minutes,BigDecimal seconds), if all the fields are null should throw
+ * IllegalArgumentException.
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "illegal-bigint-duration")
+ public void checkBigIntegerDurationNeg(boolean isPositive, BigInteger years, BigInteger months, BigInteger days, BigInteger hours, BigInteger minutes,
+ BigDecimal seconds) {
+ datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds);
+ }
+
+ @DataProvider(name = "legal-millisec-duration")
+ public Object[][] getLegalMilliSecondDuration() {
+ return new Object[][] { { 1000000 }, { 0 }, { Long.MAX_VALUE }, { Long.MIN_VALUE }
+
+ };
+ }
+
+ /*
+ * Test for constructor Duration(long durationInMilliSeconds)
+ */
+ @Test(dataProvider = "legal-millisec-duration")
+ public void checkMilliSecondDuration(long millisec) {
+ datatypeFactory.newDuration(millisec);
+ }
+
+ @DataProvider(name = "legal-lexical-duration")
+ public Object[][] getLegalLexicalDuration() {
+ return new Object[][] { { "P1Y1M1DT1H1M1S" }, { "-P1Y1M1DT1H1M1S" } };
+ }
+
+ /*
+ * Test for constructor Duration(java.lang.String lexicalRepresentation)
+ */
+ @Test(dataProvider = "legal-lexical-duration")
+ public void checkLexicalDurationPos(String lexRepresentation) {
+ datatypeFactory.newDuration(lexRepresentation);
+ }
+
+ @DataProvider(name = "illegal-lexical-duration")
+ public Object[][] getIllegalLexicalDuration() {
+ return new Object[][] {
+ { null },
+ { "P1Y1M1DT1H1M1S " },
+ { " P1Y1M1DT1H1M1S" },
+ { "X1Y1M1DT1H1M1S" },
+ { "" },
+ { "P1Y2MT" } // The designator 'T' shall be absent if all of the time items are absent in "PnYnMnDTnHnMnS"
+ };
+ }
+
+ /*
+ * Test for constructor Duration(java.lang.String lexicalRepresentation),
+ * null should throw NullPointerException, invalid lex should throw
+ * IllegalArgumentException
+ */
+ @Test(expectedExceptions = { NullPointerException.class, IllegalArgumentException.class }, dataProvider = "illegal-lexical-duration")
+ public void checkLexicalDurationNeg(String lexRepresentation) {
+ datatypeFactory.newDuration(lexRepresentation);
+ }
+
+ @DataProvider(name = "equal-duration")
+ public Object[][] getEqualDurations() {
+ return new Object[][] { { "P1Y1M1DT1H1M1S", "P1Y1M1DT1H1M1S" } };
+ }
+
+ /*
+ * Test for compare() both durations valid and equal.
+ */
+ @Test(dataProvider = "equal-duration")
+ public void checkDurationEqual(String lexRepresentation1, String lexRepresentation2) {
+ Duration duration1 = datatypeFactory.newDuration(lexRepresentation1);
+ Duration duration2 = datatypeFactory.newDuration(lexRepresentation2);
+ assertTrue(duration1.equals(duration2));
+ }
+
+ @DataProvider(name = "greater-duration")
+ public Object[][] getGreaterDuration() {
+ return new Object[][] {
+ { "P1Y1M1DT1H1M2S", "P1Y1M1DT1H1M1S" },
+ { "P1Y1M1DT1H1M1S", "-P1Y1M1DT1H1M2S" },
+ { "P1Y1M1DT1H1M2S", "-P1Y1M1DT1H1M1S" },
+ { "-P1Y1M1DT1H1M1S", "-P1Y1M1DT1H1M2S" }, };
+ }
+
+ /*
+ * Test for compare() both durations valid and lhs > rhs.
+ */
+ @Test(dataProvider = "greater-duration")
+ public void checkDurationCompare(String lexRepresentation1, String lexRepresentation2) {
+ Duration duration1 = datatypeFactory.newDuration(lexRepresentation1);
+ Duration duration2 = datatypeFactory.newDuration(lexRepresentation2);
+ assertTrue(duration1.compare(duration2) == DatatypeConstants.GREATER);
+ }
+
+ @DataProvider(name = "not-equal-duration")
+ public Object[][] getNotEqualDurations() {
+ return new Object[][] {
+ { "P1Y1M1DT1H1M1S", "-P1Y1M1DT1H1M1S" },
+ { "P2Y1M1DT1H1M1S", "P1Y1M1DT1H1M1S" } };
+ }
+
+ /*
+ * Test for equals() both durations valid and lhs not equals rhs.
+ */
+ @Test(dataProvider = "not-equal-duration")
+ public void checkDurationNotEqual(String lexRepresentation1, String lexRepresentation2) {
+ Duration duration1 = datatypeFactory.newDuration(lexRepresentation1);
+ Duration duration2 = datatypeFactory.newDuration(lexRepresentation2);
+ Assert.assertNotEquals(duration1, duration2);
+ }
+
+ @DataProvider(name = "duration-sign")
+ public Object[][] getDurationAndSign() {
+ return new Object[][] {
+ { "P0Y0M0DT0H0M0S", 0 },
+ { "P1Y0M0DT0H0M0S", 1 },
+ { "-P1Y0M0DT0H0M0S", -1 } };
+ }
+
+ /*
+ * Test for Duration.getSign().
+ */
+ @Test(dataProvider = "duration-sign")
+ public void checkDurationSign(String lexRepresentation, int sign) {
+ Duration duration = datatypeFactory.newDuration(lexRepresentation);
+ assertEquals(duration.getSign(), sign);
+ }
+
+ /*
+ * Test for Duration.negate().
+ */
+ @Test
+ public void checkDurationNegate() {
+ Duration durationPos = datatypeFactory.newDuration("P1Y0M0DT0H0M0S");
+ Duration durationNeg = datatypeFactory.newDuration("-P1Y0M0DT0H0M0S");
+
+ assertEquals(durationPos.negate(), durationNeg);
+ assertEquals(durationNeg.negate(), durationPos);
+ assertEquals(durationPos.negate().negate(), durationPos);
+
+ }
+
+ /*
+ * Test for Duration.isShorterThan(Duration) and
+ * Duration.isLongerThan(Duration).
+ */
+ @Test
+ public void checkDurationShorterLonger() {
+ Duration shorter = datatypeFactory.newDuration("P1Y1M1DT1H1M1S");
+ Duration longer = datatypeFactory.newDuration("P2Y1M1DT1H1M1S");
+
+ assertTrue(shorter.isShorterThan(longer));
+ assertFalse(longer.isShorterThan(shorter));
+ assertFalse(shorter.isShorterThan(shorter));
+
+ assertTrue(longer.isLongerThan(shorter));
+ assertFalse(shorter.isLongerThan(longer));
+ assertFalse(shorter.isLongerThan(shorter));
+ }
+
+ /*
+ * Test for Duration.isSet().
+ */
+ @Test
+ public void checkDurationIsSet() {
+ Duration duration1 = datatypeFactory.newDuration(true, 1, 1, 1, 1, 1, 1);
+ Duration duration2 = datatypeFactory.newDuration(true, 0, 0, 0, 0, 0, 0);
+
+ assertTrue(duration1.isSet(YEARS));
+ assertTrue(duration1.isSet(MONTHS));
+ assertTrue(duration1.isSet(DAYS));
+ assertTrue(duration1.isSet(HOURS));
+ assertTrue(duration1.isSet(MINUTES));
+ assertTrue(duration1.isSet(SECONDS));
+
+ assertTrue(duration2.isSet(YEARS));
+ assertTrue(duration2.isSet(MONTHS));
+ assertTrue(duration2.isSet(DAYS));
+ assertTrue(duration2.isSet(HOURS));
+ assertTrue(duration2.isSet(MINUTES));
+ assertTrue(duration2.isSet(SECONDS));
+
+ Duration duration66 = datatypeFactory.newDuration(true, null, null, zero, null, null, null);
+ assertFalse(duration66.isSet(YEARS));
+ assertFalse(duration66.isSet(MONTHS));
+ assertFalse(duration66.isSet(HOURS));
+ assertFalse(duration66.isSet(MINUTES));
+ assertFalse(duration66.isSet(SECONDS));
+
+ Duration duration3 = datatypeFactory.newDuration("P1D");
+ assertFalse(duration3.isSet(YEARS));
+ assertFalse(duration3.isSet(MONTHS));
+ assertFalse(duration3.isSet(HOURS));
+ assertFalse(duration3.isSet(MINUTES));
+ assertFalse(duration3.isSet(SECONDS));
+ }
+
+ /*
+ * Test Duration.isSet(Field) throws NPE if the field parameter is null.
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void checkDurationIsSetNeg() {
+ Duration duration = datatypeFactory.newDuration(true, 0, 0, 0, 0, 0, 0);
+ duration.isSet(null);
+ }
+
+ /*
+ * Test for -getField(DatatypeConstants.Field) DatatypeConstants.Field is
+ * null - throws NPE.
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void checkDurationGetFieldNeg() {
+ Duration duration67 = datatypeFactory.newDuration("P1Y1M1DT1H1M1S");
+ duration67.getField(null);
+ }
+
+ @DataProvider(name = "duration-fields")
+ public Object[][] getDurationAndFields() {
+ return new Object[][] {
+ { "P1Y1M1DT1H1M1S", one, one, one, one, one, new BigDecimal(one) },
+ { "PT1M", null, null, null, null, one, null },
+ { "P1M", null, one, null, null, null, null } };
+ }
+
+ /*
+ * Test for Duration.getField(DatatypeConstants.Field).
+ */
+ @Test(dataProvider = "duration-fields")
+ public void checkDurationGetField(String lexRepresentation, BigInteger years, BigInteger months, BigInteger days, BigInteger hours, BigInteger minutes,
+ BigDecimal seconds) {
+ Duration duration = datatypeFactory.newDuration(lexRepresentation);
+
+ assertEquals(duration.getField(YEARS), years);
+ assertEquals(duration.getField(MONTHS), months);
+ assertEquals(duration.getField(DAYS), days);
+ assertEquals(duration.getField(HOURS), hours);
+ assertEquals(duration.getField(MINUTES), minutes);
+ assertEquals(duration.getField(SECONDS), seconds);
+ }
+
+ @DataProvider(name = "number-string")
+ public Object[][] getNumberAndString() {
+ return new Object[][] {
+ // is positive, year, month, day, hour, minute, second, lexical
+ { true, 1, 1, 1, 1, 1, 1, "P1Y1M1DT1H1M1S" },
+ { false, 1, 1, 1, 1, 1, 1, "-P1Y1M1DT1H1M1S" },
+ { true, 0, 0, 0, 0, 0, 0, "P0Y0M0DT0H0M0S" },
+ { false, 0, 0, 0, 0, 0, 0, "P0Y0M0DT0H0M0S" }
+ };
+ }
+
+ /*
+ * Test for - toString().
+ */
+ @Test(dataProvider = "number-string")
+ public void checkDurationToString(boolean isPositive, int years, int months, int days, int hours, int minutes, int seconds, String lexical) {
+ Duration duration = datatypeFactory.newDuration(isPositive, years, months, days, hours, minutes, seconds);
+ assertEquals(duration.toString(), lexical);
+
+ assertEquals(datatypeFactory.newDuration(duration.toString()), duration);
+ }
+
+ @DataProvider(name = "duration-field")
+ public Object[][] getDurationAndField() {
+ Function<Duration, Integer> getyears = duration -> duration.getYears();
+ Function<Duration, Integer> getmonths = duration -> duration.getMonths();
+ Function<Duration, Integer> getdays = duration -> duration.getDays();
+ Function<Duration, Integer> gethours = duration -> duration.getHours();
+ Function<Duration, Integer> getminutes = duration -> duration.getMinutes();
+ Function<Duration, Integer> getseconds = duration -> duration.getSeconds();
+ return new Object[][] {
+ { "P1Y1M1DT1H1M1S", getyears, 1 },
+ { "P1M1DT1H1M1S", getyears, 0 },
+ { "P1Y1M1DT1H1M1S", getmonths, 1 },
+ { "P1Y1DT1H1M1S", getmonths, 0 },
+ { "P1Y1M1DT1H1M1S", getdays, 1 },
+ { "P1Y1MT1H1M1S", getdays, 0 },
+ { "P1Y1M1DT1H1M1S", gethours, 1 },
+ { "P1Y1M1DT1M1S", gethours, 0 },
+ { "P1Y1M1DT1H1M1S", getminutes, 1 },
+ { "P1Y1M1DT1H1S", getminutes, 0 },
+ { "P1Y1M1DT1H1M1S", getseconds, 1 },
+ { "P1Y1M1DT1H1M", getseconds, 0 },
+ { "P1Y1M1DT1H1M100000000S", getseconds, 100000000 }, };
+ }
+
+ /*
+ * Test for Duration.getYears(), getMonths(), etc.
+ */
+ @Test(dataProvider = "duration-field")
+ public void checkDurationGetOneField(String lexRepresentation, Function<Duration, Integer> getter, int value) {
+ Duration duration = datatypeFactory.newDuration(lexRepresentation);
+ assertEquals(getter.apply(duration).intValue(), value);
+ }
+
+ /*
+ * Test for - getField(SECONDS)
+ */
+ @Test
+ public void checkDurationGetSecondsField() {
+ Duration duration85 = datatypeFactory.newDuration("P1Y1M1DT1H1M100000000S");
+ assertEquals((duration85.getField(SECONDS)).intValue(), 100000000);
+ }
+
+ /*
+ * getTimeInMillis(java.util.Calendar startInstant) returns milliseconds
+ * between startInstant and startInstant plus this Duration.
+ */
+ @Test
+ public void checkDurationGetTimeInMillis() {
+ Duration duration86 = datatypeFactory.newDuration("PT1M1S");
+ Calendar calendar86 = Calendar.getInstance();
+ assertEquals(duration86.getTimeInMillis(calendar86), 61000);
+ }
+
+ /*
+ * getTimeInMillis(java.util.Calendar startInstant) returns milliseconds
+ * between startInstant and startInstant plus this Duration throws NPE if
+ * startInstant parameter is null.
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void checkDurationGetTimeInMillisNeg() {
+ Duration duration87 = datatypeFactory.newDuration("PT1M1S");
+ Calendar calendar87 = null;
+ duration87.getTimeInMillis(calendar87);
+ }
+
+ @DataProvider(name = "duration-for-hash")
+ public Object[][] getDurationsForHash() {
+ return new Object[][] {
+ { "P1Y1M1DT1H1M1S", "P1Y1M1DT1H1M1S" },
+ { "P1D", "PT24H" },
+ { "PT1H", "PT60M" },
+ { "PT1M", "PT60S" },
+ { "P1Y", "P12M" } };
+ }
+
+ /*
+ * Test for Duration.hashcode(). hashcode() should return same value for
+ * some equal durations.
+ */
+ @Test(dataProvider = "duration-for-hash")
+ public void checkDurationHashCode(String lexRepresentation1, String lexRepresentation2) {
+ Duration duration1 = datatypeFactory.newDuration(lexRepresentation1);
+ Duration duration2 = datatypeFactory.newDuration(lexRepresentation2);
+ int hash1 = duration1.hashCode();
+ int hash2 = duration2.hashCode();
+ assertTrue(hash1 == hash2, " generated hash1 : " + hash1 + " generated hash2 : " + hash2);
+ }
+
+ @DataProvider(name = "duration-for-add")
+ public Object[][] getDurationsForAdd() {
+ return new Object[][] {
+ // initVal, addVal, resultVal
+ { "P1Y1M1DT1H1M1S", "P1Y1M1DT1H1M1S", "P2Y2M2DT2H2M2S" },
+ { "P1Y1M1DT1H1M1S", "-P1Y1M1DT1H1M1S", "P0Y0M0DT0H0M0S" },
+ { "-P1Y1M1DT1H1M1S", "-P1Y1M1DT1H1M1S", "-P2Y2M2DT2H2M2S" }, };
+ }
+
+ /*
+ * Test for add(Duration rhs).
+ */
+ @Test(dataProvider = "duration-for-add")
+ public void checkDurationAdd(String initVal, String addVal, String result) {
+ Duration durationInit = datatypeFactory.newDuration(initVal);
+ Duration durationAdd = datatypeFactory.newDuration(addVal);
+ Duration durationResult = datatypeFactory.newDuration(result);
+
+ assertEquals(durationInit.add(durationAdd), durationResult);
+ }
+
+ @DataProvider(name = "duration-for-addneg")
+ public Object[][] getDurationsForAddNeg() {
+ return new Object[][] {
+ // initVal, addVal
+ { "P1Y1M1DT1H1M1S", null },
+ { "P1Y", "-P1D" },
+ { "-P1Y", "P1D" }, };
+ }
+
+ /*
+ * Test for add(Duration rhs) 'rhs' is null , should throw NPE. "1 year" +
+ * "-1 day" or "-1 year" + "1 day" should throw IllegalStateException
+ */
+ @Test(expectedExceptions = { NullPointerException.class, IllegalStateException.class }, dataProvider = "duration-for-addneg")
+ public void checkDurationAddNeg(String initVal, String addVal) {
+ Duration durationInit = datatypeFactory.newDuration(initVal);
+ Duration durationAdd = addVal == null ? null : datatypeFactory.newDuration(addVal);
+
+ durationInit.add(durationAdd);
+ }
+
+ /*
+ * Test Duration#compare(Duration duration) with large durations.
+ *
+ * Bug # 4972785 UnsupportedOperationException is expected
+ *
+ */
+ @Test(expectedExceptions = UnsupportedOperationException.class)
+ public void checkDurationCompareLarge() {
+ String duration1Lex = "P100000000000000000000D";
+ String duration2Lex = "PT2400000000000000000000H";
+
+ Duration duration1 = datatypeFactory.newDuration(duration1Lex);
+ Duration duration2 = datatypeFactory.newDuration(duration2Lex);
+ duration1.compare(duration2);
+
+ }
+
+ /*
+ * Test Duration#getXMLSchemaType().
+ *
+ * Bug # 5049544 Duration.getXMLSchemaType shall return the correct result
+ *
+ */
+ @Test
+ public void checkDurationGetXMLSchemaType() {
+ // DURATION
+ Duration duration = datatypeFactory.newDuration("P1Y1M1DT1H1M1S");
+ QName duration_xmlSchemaType = duration.getXMLSchemaType();
+ assertEquals(duration_xmlSchemaType, DatatypeConstants.DURATION, "Expected DatatypeConstants.DURATION, returned " + duration_xmlSchemaType.toString());
+
+ // DURATION_DAYTIME
+ Duration duration_dayTime = datatypeFactory.newDuration("P1DT1H1M1S");
+ QName duration_dayTime_xmlSchemaType = duration_dayTime.getXMLSchemaType();
+ assertEquals(duration_dayTime_xmlSchemaType, DatatypeConstants.DURATION_DAYTIME, "Expected DatatypeConstants.DURATION_DAYTIME, returned "
+ + duration_dayTime_xmlSchemaType.toString());
+
+ // DURATION_YEARMONTH
+ Duration duration_yearMonth = datatypeFactory.newDuration("P1Y1M");
+ QName duration_yearMonth_xmlSchemaType = duration_yearMonth.getXMLSchemaType();
+ assertEquals(duration_yearMonth_xmlSchemaType, DatatypeConstants.DURATION_YEARMONTH, "Expected DatatypeConstants.DURATION_YEARMONTH, returned "
+ + duration_yearMonth_xmlSchemaType.toString());
+
+ }
+
+
+ private final int undef = DatatypeConstants.FIELD_UNDEFINED;
+ private final BigInteger zero = BigInteger.ZERO;
+ private final BigInteger one = BigInteger.ONE;
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/FactoryNewInstanceTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1999, 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.datatype.ptests;
+
+import static org.testng.Assert.assertNotNull;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+
+import jaxp.library.JAXPDataProvider;
+import jaxp.library.JAXPBaseTest;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/*
+ * @summary Tests for DatatypeFactory.newInstance(factoryClassName , classLoader)
+ */
+public class FactoryNewInstanceTest extends JAXPBaseTest {
+
+ private static final String DATATYPE_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl";
+
+ @DataProvider(name = "parameters")
+ public Object[][] getValidateParameters() {
+ return new Object[][] { { DATATYPE_FACTORY_CLASSNAME, null }, { DATATYPE_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
+ }
+
+ /*
+ * test for DatatypeFactory.newInstance(java.lang.String factoryClassName,
+ * java.lang.ClassLoader classLoader) factoryClassName points to correct
+ * implementation of javax.xml.datatype.DatatypeFactory , should return
+ * newInstance of DatatypeFactory
+ */
+ @Test(dataProvider = "parameters")
+ public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws DatatypeConfigurationException {
+ DatatypeFactory dtf = DatatypeFactory.newInstance(DATATYPE_FACTORY_CLASSNAME, null);
+ Duration duration = dtf.newDuration(true, 1, 1, 1, 1, 1, 1);
+ assertNotNull(duration);
+ }
+
+
+ /*
+ * test for DatatypeFactory.newInstance(java.lang.String factoryClassName,
+ * java.lang.ClassLoader classLoader) factoryClassName is null , should
+ * throw DatatypeConfigurationException
+ */
+ @Test(expectedExceptions = DatatypeConfigurationException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class)
+ public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) throws DatatypeConfigurationException {
+ DatatypeFactory.newInstance(factoryClassName, classLoader);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/datatype/ptests/XMLGregorianCalendarTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,356 @@
+/*
+ * Copyright (c) 1999, 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.datatype.ptests;
+
+import static java.util.Calendar.HOUR;
+import static java.util.Calendar.MINUTE;
+import static java.util.Calendar.YEAR;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+
+import java.util.GregorianCalendar;
+import java.util.Locale;
+import java.util.TimeZone;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeConstants;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.Duration;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import jaxp.library.JAXPBaseTest;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/*
+ * @bug 5049592 5041845 5048932 5064587 5040542 5049531 5049528
+ * @summary Class containing the test cases for XMLGregorianCalendar
+ */
+public class XMLGregorianCalendarTest extends JAXPBaseTest {
+
+ private DatatypeFactory datatypeFactory;
+
+ @BeforeClass
+ public void setup() throws DatatypeConfigurationException {
+ datatypeFactory = DatatypeFactory.newInstance();
+ }
+
+ @DataProvider(name = "valid-milliseconds")
+ public Object[][] getValidMilliSeconds() {
+ return new Object[][] { { 0 }, { 1 }, { 2 }, { 16 }, { 1000 } };
+ }
+
+ /*
+ * Test DatatypeFactory.newXMLGregorianCalendar(..) with milliseconds > 1.
+ *
+ * Bug # 5049592
+ *
+ */
+ @Test(dataProvider = "valid-milliseconds")
+ public void checkNewCalendar(int ms) {
+ // valid milliseconds
+ XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(2004, // year
+ 6, // month
+ 2, // day
+ 19, // hour
+ 20, // minute
+ 59, // second
+ ms, // milliseconds
+ 840 // timezone
+ );
+ // expected success
+
+ assertEquals(calendar.getMillisecond(), ms);
+ }
+
+ /*
+ * Test DatatypeFactory.newXMLGregorianCalendarTime(..).
+ *
+ * Bug # 5049592
+ */
+ @Test(dataProvider = "valid-milliseconds")
+ public void checkNewTime(int ms) {
+ // valid milliseconds
+ XMLGregorianCalendar calendar2 = datatypeFactory.newXMLGregorianCalendarTime(19, // hour
+ 20, // minute
+ 59, // second
+ ms, // milliseconds
+ 840 // timezone
+ );
+ // expected success
+
+ assertEquals(calendar2.getMillisecond(), ms);
+ }
+
+ @DataProvider(name = "invalid-milliseconds")
+ public Object[][] getInvalidMilliSeconds() {
+ return new Object[][] { { -1 }, { 1001 } };
+ }
+
+ /*
+ * Test DatatypeFactory.newXMLGregorianCalendar(..).
+ *
+ * Bug # 5049592 IllegalArgumentException is thrown if milliseconds < 0 or >
+ * 1001.
+ *
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "invalid-milliseconds")
+ public void checkNewCalendarNeg(int milliseconds) {
+ // invalid milliseconds
+ datatypeFactory.newXMLGregorianCalendar(2004, // year
+ 6, // month
+ 2, // day
+ 19, // hour
+ 20, // minute
+ 59, // second
+ milliseconds, // milliseconds
+ 840 // timezone
+ );
+ }
+
+ /*
+ * Test DatatypeFactory.newXMLGregorianCalendarTime(..).
+ *
+ * Bug # 5049592 IllegalArgumentException is thrown if milliseconds < 0 or >
+ * 1001.
+ *
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "invalid-milliseconds")
+ public void checkNewTimeNeg(int milliseconds) {
+ // invalid milliseconds
+ datatypeFactory.newXMLGregorianCalendarTime(19, // hour
+ 20, // minute
+ 59, // second
+ milliseconds, // milliseconds
+ 840 // timezone
+ );
+ }
+
+ @DataProvider(name = "data-for-add")
+ public Object[][] getDataForAdd() {
+ return new Object[][] {
+ //calendar1, calendar2, duration
+ { "1999-12-31T00:00:00Z", "2000-01-01T00:00:00Z", "P1D" },
+ { "2000-12-31T00:00:00Z", "2001-01-01T00:00:00Z", "P1D" },
+ { "1998-12-31T00:00:00Z", "1999-01-01T00:00:00Z", "P1D" },
+ { "2001-12-31T00:00:00Z", "2002-01-01T00:00:00Z", "P1D" },
+ { "2003-04-11T00:00:00Z", "2003-04-12T00:00:00Z", "P1D" },
+ { "2003-04-11T00:00:00Z", "2003-04-14T00:00:00Z", "P3D" },
+ { "2003-04-30T00:00:00Z", "2003-05-01T00:00:00Z", "P1D" },
+ { "2003-02-28T00:00:00Z", "2003-03-01T00:00:00Z", "P1D" },
+ { "2000-02-29T00:00:00Z", "2000-03-01T00:00:00Z", "P1D" },
+ { "2000-02-28T00:00:00Z", "2000-02-29T00:00:00Z", "P1D" },
+ { "1998-01-11T00:00:00Z", "1998-04-11T00:00:00Z", "P90D" },
+ { "1999-05-11T00:00:00Z", "2002-05-11T00:00:00Z", "P1096D" }};
+ }
+
+ /*
+ * Test XMLGregorianCalendar.add(Duration).
+ *
+ */
+ @Test(dataProvider = "data-for-add")
+ public void checkAddDays(String cal1, String cal2, String dur) {
+
+ XMLGregorianCalendar calendar1 = datatypeFactory.newXMLGregorianCalendar(cal1);
+ XMLGregorianCalendar calendar2 = datatypeFactory.newXMLGregorianCalendar(cal2);
+
+ Duration duration = datatypeFactory.newDuration(dur);
+
+ XMLGregorianCalendar calendar1Clone = (XMLGregorianCalendar)calendar1.clone();
+
+ calendar1Clone.add(duration);
+ assertEquals(calendar1Clone, calendar2);
+
+ calendar2.add(duration.negate());
+ assertEquals(calendar2, calendar1);
+
+ }
+
+ @DataProvider(name = "gMonth")
+ public Object[][] getGMonth() {
+ return new Object[][] {
+ { "2000-02" },
+ { "2000-03" },
+ { "2018-02" }};
+ }
+ /*
+ * Test XMLGregorianCalendar#isValid(). for gMonth
+ *
+ * Bug # 5041845
+ *
+ */
+ @Test(dataProvider = "gMonth")
+ public void checkIsValid(String month) {
+
+ XMLGregorianCalendar gMonth = datatypeFactory.newXMLGregorianCalendar(month);
+ gMonth.setYear(null);
+ Assert.assertTrue(gMonth.isValid(), gMonth.toString() + " should isValid");
+
+ }
+
+ @DataProvider(name = "lexical01")
+ public Object[][] getLexicalRepresentForNormalize01() {
+ return new Object[][] { { "2000-01-16T12:00:00Z" }, { "2000-01-16T12:00:00" } };
+ }
+
+ /*
+ * Test XMLGregorianCalendar#normalize(...).
+ *
+ * Bug # 5048932 XMLGregorianCalendar.normalize works
+ *
+ */
+ @Test(dataProvider = "lexical01")
+ public void checkNormalize01(String lexical) {
+ XMLGregorianCalendar lhs = datatypeFactory.newXMLGregorianCalendar(lexical);
+ lhs.normalize();
+ }
+
+ @DataProvider(name = "lexical02")
+ public Object[][] getLexicalRepresentForNormalize02() {
+ return new Object[][] { { "2000-01-16T00:00:00.01Z" }, { "2000-01-16T00:00:00.01" }, { "13:20:00" } };
+ }
+
+ /*
+ * Test XMLGregorianCalendar#normalize(...).
+ *
+ * Bug # 5064587 XMLGregorianCalendar.normalize shall not change timezone
+ *
+ */
+ @Test(dataProvider = "lexical02")
+ public void checkNormalize02(String lexical) {
+ XMLGregorianCalendar orig = datatypeFactory.newXMLGregorianCalendar(lexical);
+ XMLGregorianCalendar normalized = datatypeFactory.newXMLGregorianCalendar(lexical).normalize();
+
+ assertEquals(normalized.getTimezone(), orig.getTimezone());
+ assertEquals(normalized.getMillisecond(), orig.getMillisecond());
+ }
+
+ /*
+ * Test XMLGregorianCalendar#toGregorianCalendar( TimeZone timezone, Locale
+ * aLocale, XMLGregorianCalendar defaults)
+ *
+ * Bug # 5040542 the defaults XMLGregorianCalendar parameter shall take
+ * effect
+ *
+ */
+ @Test
+ public void checkToGregorianCalendar01() {
+
+ XMLGregorianCalendar time_16_17_18 = datatypeFactory.newXMLGregorianCalendar("16:17:18");
+ XMLGregorianCalendar date_2001_02_03 = datatypeFactory.newXMLGregorianCalendar("2001-02-03");
+ GregorianCalendar calendar = date_2001_02_03.toGregorianCalendar(null, null, time_16_17_18);
+
+ int year = calendar.get(YEAR);
+ int minute = calendar.get(MINUTE);
+
+ assertTrue((year == 2001 && minute == 17), " expecting year == 2001, minute == 17" + ", result is year == " + year + ", minute == " + minute);
+
+
+ calendar = time_16_17_18.toGregorianCalendar(null, null, date_2001_02_03);
+
+ year = calendar.get(YEAR);
+ minute = calendar.get(MINUTE);
+
+ assertTrue((year == 2001 && minute == 17), " expecting year == 2001, minute == 17" + ", result is year == " + year + ", minute == " + minute);
+
+
+ date_2001_02_03.setMinute(3);
+ date_2001_02_03.setYear(null);
+
+ XMLGregorianCalendar date_time = datatypeFactory.newXMLGregorianCalendar("2003-04-11T02:13:01Z");
+
+ calendar = date_2001_02_03.toGregorianCalendar(null, null, date_time);
+
+ year = calendar.get(YEAR);
+ minute = calendar.get(MINUTE);
+ int hour = calendar.get(HOUR);
+
+ assertTrue((year == 2003 && hour == 2 && minute == 3), " expecting year == 2003, hour == 2, minute == 3" + ", result is year == " + year + ", hour == " + hour + ", minute == " + minute);
+
+
+ }
+
+ /*
+ * Test XMLGregorianCalendar#toGregorianCalendar( TimeZone timezone, Locale
+ * aLocale, XMLGregorianCalendar defaults) with the 'defaults' parameter
+ * being null.
+ *
+ * Bug # 5049531 XMLGregorianCalendar.toGregorianCalendar(..) can accept
+ * 'defaults' is null
+ *
+ */
+ @Test
+ public void checkToGregorianCalendar02() {
+
+ XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar("2004-05-19T12:00:00+06:00");
+ calendar.toGregorianCalendar(TimeZone.getDefault(), Locale.getDefault(), null);
+ }
+
+ @DataProvider(name = "calendar")
+ public Object[][] getXMLGregorianCalendarData() {
+ return new Object[][] {
+ // year, month, day, hour, minute, second
+ { 1970, 1, 1, 0, 0, 0 }, // DATETIME
+ { 1970, 1, 1, undef, undef, undef }, // DATE
+ { undef, undef, undef, 1, 0, 0 }, // TIME
+ { 1970, 1, undef, undef, undef, undef }, // GYEARMONTH
+ { undef, 1, 1, undef, undef, undef }, // GMONTHDAY
+ { 1970, undef, undef, undef, undef, undef }, // GYEAR
+ { undef, 1, undef, undef, undef, undef }, // GMONTH
+ { undef, undef, 1, undef, undef, undef } // GDAY
+ };
+ }
+
+ /*
+ * Test XMLGregorianCalendar#toString()
+ *
+ * Bug # 5049528
+ *
+ */
+ @Test(dataProvider = "calendar")
+ public void checkToStringPos(final int year, final int month, final int day, final int hour, final int minute, final int second) {
+ XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(year, month, day, hour, minute, second, undef, undef);
+ calendar.toString();
+ }
+
+ /*
+ * Negative Test XMLGregorianCalendar#toString()
+ *
+ * Bug # 5049528 XMLGregorianCalendar.toString throws IllegalStateException
+ * if all parameters are undef
+ *
+ */
+ @Test(expectedExceptions = IllegalStateException.class)
+ public void checkToStringNeg() {
+ XMLGregorianCalendar calendar = datatypeFactory.newXMLGregorianCalendar(undef, undef, undef, undef, undef, undef, undef, undef);
+ // expected to fail
+ calendar.toString();
+ }
+
+ private final int undef = DatatypeConstants.FIELD_UNDEFINED;
+
+}
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/DocumentBuilderFactoryTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -26,27 +26,38 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
+
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
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;
import javax.xml.transform.sax.SAXResult;
+
+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;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -60,6 +71,52 @@
*/
public class DocumentBuilderFactoryTest extends JAXPFileBaseTest {
/**
+ * DocumentBuilderFactory implementation class name.
+ */
+ private static final String DOCUMENT_BUILDER_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl";
+
+ /**
+ * Provide valid DocumentBuilderFactory instantiation parameters.
+ *
+ * @return a data provider contains DocumentBuilderFactory instantiation parameters.
+ */
+ @DataProvider(name = "parameters")
+ public Object[][] getValidateParameters() {
+ return new Object[][] { { DOCUMENT_BUILDER_FACTORY_CLASSNAME, null }, { DOCUMENT_BUILDER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
+ }
+
+ /**
+ * Test for DocumentBuilderFactory.newInstance(java.lang.String
+ * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName
+ * points to correct implementation of
+ * javax.xml.parsers.DocumentBuilderFactory , should return newInstance of
+ * DocumentBuilderFactory
+ *
+ * @param factoryClassName
+ * @param classLoader
+ * @throws ParserConfigurationException
+ */
+ @Test(dataProvider = "parameters")
+ public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws ParserConfigurationException {
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(factoryClassName, classLoader);
+ DocumentBuilder builder = dbf.newDocumentBuilder();
+ assertNotNull(builder);
+ }
+
+ /**
+ * test for DocumentBuilderFactory.newInstance(java.lang.String
+ * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName is
+ * null , should throw FactoryConfigurationError
+ *
+ * @param factoryClassName
+ * @param classLoader
+ */
+ @Test(expectedExceptions = FactoryConfigurationError.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class)
+ public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) {
+ DocumentBuilderFactory.newInstance(factoryClassName, classLoader);
+ }
+
+ /**
* Test the default functionality of schema support method.
* @throws Exception If any errors occur.
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/parsers/ptests/SAXFactoryNewInstanceTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,75 @@
+/*
+ * Copyright (c) 1999, 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.parsers.ptests;
+
+import static org.testng.Assert.assertNotNull;
+
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import jaxp.library.JAXPDataProvider;
+import jaxp.library.JAXPBaseTest;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import org.xml.sax.SAXException;
+
+/*
+ * @summary Tests for SAXParserFactory.newInstance(factoryClassName , classLoader)
+ */
+public class SAXFactoryNewInstanceTest extends JAXPBaseTest {
+
+ private static final String SAXPARSER_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";
+
+ @DataProvider(name = "parameters")
+ public Object[][] getValidateParameters() {
+ return new Object[][] { { SAXPARSER_FACTORY_CLASSNAME, null }, { SAXPARSER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
+ }
+
+ /*
+ * test for SAXParserFactory.newInstance(java.lang.String factoryClassName,
+ * java.lang.ClassLoader classLoader) factoryClassName points to correct
+ * implementation of javax.xml.parsers.SAXParserFactory , should return
+ * newInstance of SAXParserFactory
+ */
+ @Test(dataProvider = "parameters")
+ public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws ParserConfigurationException, SAXException {
+ SAXParserFactory spf = SAXParserFactory.newInstance(factoryClassName, classLoader);
+ SAXParser sp = spf.newSAXParser();
+ assertNotNull(sp);
+ }
+
+ /*
+ * test for SAXParserFactory.newInstance(java.lang.String factoryClassName,
+ * java.lang.ClassLoader classLoader) factoryClassName is null , should
+ * throw FactoryConfigurationError
+ */
+ @Test(expectedExceptions = FactoryConfigurationError.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class)
+ public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) {
+ SAXParserFactory.newInstance(factoryClassName, classLoader);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLEventFactoryNewInstanceTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 1999, 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.stream.ptests;
+
+import static org.testng.Assert.assertNotNull;
+
+import javax.xml.stream.XMLEventFactory;
+
+import jaxp.library.JAXPDataProvider;
+import jaxp.library.JAXPBaseTest;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/*
+ * @summary Tests for XMLEventFactory.newFactory(factoryId , classLoader)
+ */
+public class XMLEventFactoryNewInstanceTest extends JAXPBaseTest {
+
+ private static final String XMLEVENT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.events.XMLEventFactoryImpl";
+ private static final String XMLEVENT_FACRORY_ID = "javax.xml.stream.XMLEventFactory";
+
+ @DataProvider(name = "parameters")
+ public Object[][] getValidateParameters() {
+ return new Object[][] { { XMLEVENT_FACRORY_ID, null }, { XMLEVENT_FACRORY_ID, this.getClass().getClassLoader() } };
+ }
+
+ /*
+ * test for XMLEventFactory.newFactory(java.lang.String factoryClassName,
+ * java.lang.ClassLoader classLoader) factoryClassName points to correct
+ * implementation of javax.xml.stream.XMLEventFactory , should return
+ * newInstance of XMLEventFactory
+ */
+ @Test(dataProvider = "parameters")
+ public void testNewFactory(String factoryId, ClassLoader classLoader) {
+ setSystemProperty(XMLEVENT_FACRORY_ID, XMLEVENT_FACTORY_CLASSNAME);
+ try {
+ XMLEventFactory xef = XMLEventFactory.newFactory(factoryId, classLoader);
+ assertNotNull(xef);
+ } finally {
+ setSystemProperty(XMLEVENT_FACRORY_ID, null);
+ }
+ }
+
+ /*
+ * test for XMLEventFactory.newFactory(java.lang.String factoryClassName,
+ * java.lang.ClassLoader classLoader) factoryClassName is null , should
+ * throw NullPointerException
+ */
+ @Test(expectedExceptions = NullPointerException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class)
+ public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) {
+ XMLEventFactory.newFactory(null, null);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/stream/ptests/XMLInputFactoryNewInstanceTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,76 @@
+/*
+ * Copyright (c) 1999, 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.stream.ptests;
+
+import static org.testng.Assert.assertNotNull;
+
+import javax.xml.stream.XMLInputFactory;
+
+import jaxp.library.JAXPDataProvider;
+import jaxp.library.JAXPBaseTest;
+
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+/*
+ * @summary Tests for XMLInputFactory.newFactory(factoryId , classLoader)
+ */
+public class XMLInputFactoryNewInstanceTest extends JAXPBaseTest {
+
+ private static final String XMLINPUT_FACTORY_CLASSNAME = "com.sun.xml.internal.stream.XMLInputFactoryImpl";
+ private static final String XMLINPUT_FACRORY_ID = "javax.xml.stream.XMLInputFactory";
+
+ @DataProvider(name = "parameters")
+ public Object[][] getValidateParameters() {
+ return new Object[][] { { XMLINPUT_FACRORY_ID, null }, { XMLINPUT_FACRORY_ID, this.getClass().getClassLoader() } };
+ }
+
+ /*
+ * test for XMLInputFactory.newFactory(java.lang.String factoryId,
+ * java.lang.ClassLoader classLoader) factoryClassName points to correct
+ * implementation of javax.xml.stream.XMLInputFactory , should return
+ * newInstance of XMLInputFactory
+ */
+ @Test(dataProvider = "parameters")
+ public void testNewFactory(String factoryId, ClassLoader classLoader) {
+ setSystemProperty(XMLINPUT_FACRORY_ID, XMLINPUT_FACTORY_CLASSNAME);
+ try {
+ XMLInputFactory xif = XMLInputFactory.newFactory(factoryId, classLoader);
+ assertNotNull(xif);
+ } finally {
+ setSystemProperty(XMLINPUT_FACRORY_ID, null);
+ }
+ }
+
+ /*
+ * test for XMLInputFactory.newFactory(java.lang.String factoryClassName,
+ * java.lang.ClassLoader classLoader) factoryClassName is null , should
+ * throw NullPointerException
+ */
+ @Test(expectedExceptions = NullPointerException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class)
+ public void testNewFactoryNeg(String factoryId, ClassLoader classLoader) {
+ XMLInputFactory.newFactory(factoryId, classLoader);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/Bug6384418Test.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1999, 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.transform.ptests;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import jaxp.library.JAXPFileBaseTest;
+import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
+
+import org.testng.annotations.Test;
+import org.w3c.dom.Document;
+
+/*
+ * @bug 6384418
+ * @summary verify the transforming won't throw any exception
+ */
+public class Bug6384418Test extends JAXPFileBaseTest {
+
+ @Test
+ public void test() throws Exception {
+ TransformerFactory tfactory = TransformerFactory.newInstance();
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ DocumentBuilder db = dbf.newDocumentBuilder();
+ Document document = db.parse(new File(XML_DIR + "dataentry.xsl"));
+ DOMSource domSource = new DOMSource(document);
+
+ Transformer transformer = tfactory.newTransformer(domSource);
+ StreamSource streamSource = new StreamSource(new File(XML_DIR + "test.xml"));
+ StreamResult streamResult = new StreamResult(new ByteArrayOutputStream());
+ transformer.transform(streamSource, streamResult);
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,383 @@
+/*
+ * Copyright (c) 1999, 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.transform.ptests;
+
+import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
+
+import java.io.BufferedWriter;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.function.Supplier;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Result;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerConfigurationException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.sax.SAXResult;
+import javax.xml.transform.sax.SAXSource;
+import javax.xml.transform.stax.StAXResult;
+import javax.xml.transform.stax.StAXSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+
+import jaxp.library.JAXPFileBaseTest;
+
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+import org.w3c.dom.Document;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+
+/*
+ * @summary Tests for variable combination of Transformer.transform(Source, Result)
+ */
+@Test(singleThreaded = true)
+public class TransformTest extends JAXPFileBaseTest {
+
+ /*
+ * Initialize the share objects.
+ */
+ @BeforeClass
+ public void setup() throws Exception {
+ ifac = XMLInputFactory.newInstance();
+ ofac = XMLOutputFactory.newInstance();
+ tfac = TransformerFactory.newInstance();
+
+ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+ dbf.setNamespaceAware(true);
+ db = dbf.newDocumentBuilder();
+
+ xml = Files.readAllBytes(Paths.get(XML_DIR + "cities.xml"));
+ template = Files.readAllBytes(Paths.get(XML_DIR + "cities.xsl"));
+
+ xmlDoc = db.parse(xmlInputStream());
+ }
+
+ @DataProvider(name = "input-provider")
+ public Object[][] prepareTestCombination() throws Exception {
+
+ Supplier<Source> staxStreamSource = () -> new StAXSource(getXMLStreamReader());
+ Supplier<Source> staxEventSource = this::getStAXEventSource;
+ Supplier<Source> domSource = () -> new DOMSource(xmlDoc);
+ Supplier<Source> saxSource = () -> new SAXSource(new InputSource(xmlInputStream()));
+ Supplier<Source> streamSource = () -> new StreamSource(xmlInputStream());
+
+ Supplier<Result> staxStreamResult = () -> new StAXResult(getXMLStreamWriter());
+ Supplier<Result> staxEventResult = () -> new StAXResult(getXMLEventWriter());
+ Supplier<Result> saxResult = this::getHandlerSAXResult;
+ Supplier<Result> streamResult = () -> new StreamResult(transOutputStream());
+
+ Transformer domTemplateTransformer = createTransformer(getDomTemplate());
+ Transformer saxTemplateTransformer = createTransformer(getSAXTemplate());
+ Transformer streamTemplateTransformer = createTransformer(getStreamTemplate());
+ Transformer noTemplateTransformer = createTransformer(null);
+ Transformer staxStreamTemplateTransformer = createTransformer(getStAXStreamTemplate());
+ Transformer staxEventTemplateTransformer = createTransformer(getStAXEventTemplate());
+
+ return new Object[][] {
+ // StAX Stream
+ { staxStreamSource, staxStreamResult, domTemplateTransformer },
+ { staxStreamSource, staxStreamResult, saxTemplateTransformer },
+ { staxStreamSource, staxStreamResult, streamTemplateTransformer },
+ { staxStreamSource, staxStreamResult, noTemplateTransformer },
+ { staxStreamSource, staxStreamResult, staxStreamTemplateTransformer },
+ { staxStreamSource, saxResult, domTemplateTransformer },
+ { staxStreamSource, streamResult, domTemplateTransformer },
+ { domSource, staxStreamResult, domTemplateTransformer },
+ { saxSource, staxStreamResult, domTemplateTransformer },
+ { streamSource, staxStreamResult, domTemplateTransformer },
+ { staxStreamSource, streamResult, saxTemplateTransformer },
+ { domSource, staxStreamResult, saxTemplateTransformer },
+ { saxSource, staxStreamResult, saxTemplateTransformer },
+ { streamSource, staxStreamResult, saxTemplateTransformer },
+ { staxStreamSource, streamResult, streamTemplateTransformer },
+ { domSource, staxStreamResult, streamTemplateTransformer },
+ { saxSource, staxStreamResult, streamTemplateTransformer },
+ { streamSource, staxStreamResult, streamTemplateTransformer },
+ // StAX Event
+ { staxEventSource, staxEventResult, domTemplateTransformer },
+ { staxEventSource, staxEventResult, saxTemplateTransformer },
+ { staxEventSource, staxEventResult, streamTemplateTransformer },
+ { staxEventSource, staxEventResult, noTemplateTransformer },
+ { staxEventSource, staxEventResult, staxEventTemplateTransformer },
+ { staxEventSource, saxResult, domTemplateTransformer },
+ { staxEventSource, streamResult, domTemplateTransformer },
+ { domSource, staxEventResult, domTemplateTransformer },
+ { saxSource, staxEventResult, domTemplateTransformer },
+ { streamSource, staxEventResult, domTemplateTransformer },
+ { staxEventSource, streamResult, saxTemplateTransformer },
+ { domSource, staxEventResult, saxTemplateTransformer },
+ { saxSource, staxEventResult, saxTemplateTransformer },
+ { streamSource, staxEventResult, saxTemplateTransformer },
+ { staxEventSource, streamResult, streamTemplateTransformer },
+ { domSource, staxEventResult, streamTemplateTransformer },
+ { saxSource, staxEventResult, streamTemplateTransformer },
+ { streamSource, staxEventResult, streamTemplateTransformer } };
+ }
+
+ /*
+ * run Transformer.transform(Source, Result)
+ */
+ @Test(dataProvider = "input-provider")
+ public void testTransform(Supplier<Source> src, Supplier<Result> res, Transformer transformer) throws Throwable {
+ try {
+ transformer.transform(src.get(), res.get());
+ } catch (WrapperException e) {
+ throw e.getCause();
+ }
+ }
+
+ private InputStream xmlInputStream() {
+ return new ByteArrayInputStream(xml);
+ }
+
+ private InputStream templateInputStream() {
+ return new ByteArrayInputStream(template);
+ }
+
+ private OutputStream transOutputStream() {
+ return new ByteArrayOutputStream(xml.length);
+ }
+
+ private XMLStreamReader getXMLStreamReader() {
+ try {
+ return ifac.createXMLStreamReader(xmlInputStream());
+ } catch (XMLStreamException e) {
+ throw new WrapperException(e);
+ }
+ }
+
+ private XMLStreamWriter getXMLStreamWriter() {
+ try {
+ return ofac.createXMLStreamWriter(transOutputStream());
+ } catch (XMLStreamException e) {
+ throw new WrapperException(e);
+ }
+ }
+
+ private StAXSource getStAXEventSource() {
+ try {
+ return new StAXSource(ifac.createXMLEventReader(xmlInputStream()));
+ } catch (XMLStreamException e) {
+ throw new WrapperException(e);
+ }
+ }
+
+ private XMLEventWriter getXMLEventWriter() {
+ try {
+ return ofac.createXMLEventWriter(transOutputStream());
+ } catch (XMLStreamException e) {
+ throw new WrapperException(e);
+ }
+ }
+
+ private SAXResult getHandlerSAXResult() {
+ SAXResult res = new SAXResult();
+ MyContentHandler myContentHandler = new MyContentHandler(transOutputStream());
+ res.setHandler(myContentHandler);
+ return res;
+ }
+
+ private Source getDomTemplate() throws SAXException, IOException {
+ return new DOMSource(db.parse(templateInputStream()));
+ }
+
+ private Source getSAXTemplate() {
+ return new SAXSource(new InputSource(templateInputStream()));
+ }
+
+ private Source getStreamTemplate() {
+ return new StreamSource(templateInputStream());
+ }
+
+ private Source getStAXStreamTemplate() throws XMLStreamException {
+ return new StAXSource(ifac.createXMLStreamReader(templateInputStream()));
+ }
+
+ private Source getStAXEventTemplate() throws XMLStreamException {
+ return new StAXSource(ifac.createXMLEventReader(templateInputStream()));
+ }
+
+ private Transformer createTransformer(Source templateSource) throws TransformerConfigurationException {
+ Transformer transformer = (templateSource == null) ? tfac.newTransformer() : tfac.newTransformer(templateSource);
+ transformer.setOutputProperty("indent", "yes");
+ return transformer;
+
+ }
+
+ private static class MyContentHandler implements ContentHandler {
+ private BufferedWriter bWriter;
+
+ public MyContentHandler(OutputStream os) {
+ bWriter = new BufferedWriter(new OutputStreamWriter(os));
+ }
+
+ public void setDocumentLocator(Locator locator) {
+ }
+
+ public void startDocument() throws SAXException {
+ String str = "startDocument";
+ try {
+ bWriter.write(str, 0, str.length());
+ bWriter.newLine();
+ } catch (IOException e) {
+ System.out.println("bWriter error");
+ }
+ }
+
+ public void endDocument() throws SAXException {
+ String str = "endDocument";
+ try {
+ bWriter.write(str, 0, str.length());
+ bWriter.newLine();
+ bWriter.flush();
+ bWriter.close();
+ } catch (IOException e) {
+ System.out.println("bWriter error");
+ }
+ }
+
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ String str = "startPrefixMapping: " + prefix + ", " + uri;
+ try {
+ bWriter.write(str, 0, str.length());
+ bWriter.newLine();
+ } catch (IOException e) {
+ System.out.println("bWriter error");
+ }
+ }
+
+ public void endPrefixMapping(String prefix) throws SAXException {
+ String str = "endPrefixMapping: " + prefix;
+ try {
+ bWriter.write(str, 0, str.length());
+ bWriter.newLine();
+ } catch (IOException e) {
+ System.out.println("bWriter error");
+ }
+ }
+
+ public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
+ StringBuilder str = new StringBuilder("startElement: ").append(namespaceURI).append(", ").append(namespaceURI).append(", ").append(qName).append(" : ");
+ int n = atts.getLength();
+ for (int i = 0; i < n; i++) {
+ str.append(", ").append(atts.getQName(i)).append(" : ").append(atts.getValue(i));
+ }
+
+ try {
+ bWriter.write(str.toString(), 0, str.length());
+ bWriter.newLine();
+ } catch (IOException e) {
+ System.out.println("bWriter error");
+ }
+ }
+
+ public void endElement(String namespaceURI, String localName, String qName) throws SAXException {
+ String str = "endElement: " + namespaceURI + ", " + namespaceURI + ", " + qName;
+ try {
+ bWriter.write(str, 0, str.length());
+ bWriter.newLine();
+ } catch (IOException e) {
+ System.out.println("bWriter error");
+ }
+
+ }
+
+ public void characters(char ch[], int start, int length) throws SAXException {
+ String str = new String(ch, start, length);
+ try {
+ bWriter.write(str, 0, str.length());
+ bWriter.newLine();
+ } catch (IOException e) {
+ System.out.println("bWriter error");
+ }
+ }
+
+ public void ignorableWhitespace(char ch[], int start, int length) throws SAXException {
+ String str = "ignorableWhitespace";
+ try {
+ bWriter.write(str, 0, str.length());
+ bWriter.newLine();
+ } catch (IOException e) {
+ System.out.println("bWriter error");
+ }
+ }
+
+ public void processingInstruction(String target, String data) throws SAXException {
+ String str = "processingInstruction: " + target + ", " + target;
+ try {
+ bWriter.write(str, 0, str.length());
+ bWriter.newLine();
+ } catch (IOException e) {
+ System.out.println("bWriter error");
+ }
+ }
+
+ public void skippedEntity(String name) throws SAXException {
+ String str = "skippedEntity: " + name;
+ try {
+ bWriter.write(str, 0, str.length());
+ bWriter.newLine();
+ } catch (IOException e) {
+ System.out.println("bWriter error");
+ }
+ }
+ }
+
+ private static class WrapperException extends RuntimeException {
+ public WrapperException(Throwable cause) {
+ super(cause);
+ }
+ }
+
+ private XMLInputFactory ifac;
+ private XMLOutputFactory ofac;
+ private TransformerFactory tfac;
+ private DocumentBuilder db;
+ private byte[] xml;
+ private byte[] template;
+ private Document xmlDoc;
+
+}
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/ptests/TransformerFactoryTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -23,26 +23,79 @@
package javax.xml.transform.ptests;
import java.io.*;
-import java.io.FileOutputStream;
+
import javax.xml.parsers.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
+
import static javax.xml.transform.ptests.TransformerTestConst.GOLDEN_DIR;
import static javax.xml.transform.ptests.TransformerTestConst.XML_DIR;
+
import javax.xml.transform.stream.*;
+
+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.assertNotNull;
import static org.testng.Assert.assertTrue;
+
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.w3c.dom.*;
/**
* Class containing the test cases for TransformerFactory API's
- * getAssociatedStyleSheet method.
+ * getAssociatedStyleSheet method and TransformerFactory.newInstance(factoryClassName , classLoader).
*/
public class TransformerFactoryTest extends JAXPFileBaseTest {
/**
+ * TransformerFactory implementation class name.
+ */
+ private static final String TRANSFORMER_FACTORY_CLASSNAME = "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl";
+
+ /**
+ * Provide valid TransformerFactory instantiation parameters.
+ *
+ * @return a data provider contains TransformerFactory instantiation parameters.
+ */
+ @DataProvider(name = "parameters")
+ public Object[][] getValidateParameters() {
+ return new Object[][] { { TRANSFORMER_FACTORY_CLASSNAME, null }, { TRANSFORMER_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
+ }
+
+ /**
+ * Test for TransformerFactory.newInstance(java.lang.String
+ * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName
+ * points to correct implementation of
+ * javax.xml.transform.TransformerFactory , should return newInstance of
+ * TransformerFactory
+ *
+ * @param factoryClassName
+ * @param classLoader
+ * @throws TransformerConfigurationException
+ */
+ @Test(dataProvider = "parameters")
+ public void testNewInstance(String factoryClassName, ClassLoader classLoader) throws TransformerConfigurationException {
+ TransformerFactory tf = TransformerFactory.newInstance(factoryClassName, classLoader);
+ Transformer transformer = tf.newTransformer();
+ assertNotNull(transformer);
+ }
+
+ /**
+ * Test for TransformerFactory.newInstance(java.lang.String
+ * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName is
+ * null , should throw TransformerFactoryConfigurationError
+ *
+ * @param factoryClassName
+ * @param classLoader
+ */
+ @Test(expectedExceptions = TransformerFactoryConfigurationError.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class)
+ public void testNewInstanceNeg(String factoryClassName, ClassLoader classLoader) {
+ TransformerFactory.newInstance(factoryClassName, classLoader);
+ }
+
+ /**
* This test case checks for the getAssociatedStylesheet method
* of TransformerFactory.
* The style sheet returned is then copied to an tfactory01.out
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/xmlfiles/dataentry.xsl Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,20 @@
+<?xml version="1.0"?>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+ <xsl:template match="dataentry">
+ <table cellspacing="0" cellpadding="0" width="85%" align="center"
+class="color1" border="0">
+ <xsl:apply-templates/>
+ </table>
+
+ </xsl:template>
+ <xsl:template match="list">
+ <xsl:value-of select="self::node()[@multi='false']"/>
+
+ <!--
+ <xsl:if test="self::node()[@multi='false']">
+ <xsl:if test="self::node()">
+ FALSE<br/>
+ </xsl:if>
+ -->
+ </xsl:template>
+</xsl:stylesheet>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/transform/xmlfiles/test.xml Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,8 @@
+<appcapp>
+<dataentry>
+<list multi="false">
+ <name>TypeOfLifeApp</name>
+</list>
+</dataentry>
+</appcapp>
+
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/validation/ptests/SchemaFactoryTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -46,6 +46,8 @@
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
+import jaxp.library.JAXPDataProvider;
+
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
@@ -81,6 +83,59 @@
xml = Files.readAllBytes(Paths.get(XML_DIR + "test.xml"));
}
+
+ @DataProvider(name = "parameters")
+ public Object[][] getValidateParameters() {
+ return new Object[][] { { W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, null },
+ { W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
+ }
+
+ /*
+ * test for SchemaFactory.newInstance(java.lang.String schemaLanguage,
+ * java.lang.String factoryClassName, java.lang.ClassLoader classLoader)
+ * factoryClassName points to correct implementation of
+ * javax.xml.validation.SchemaFactory , should return newInstance of
+ * SchemaFactory
+ */
+ @Test(dataProvider = "parameters")
+ public void testNewInstance(String schemaLanguage, String factoryClassName, ClassLoader classLoader) throws SAXException {
+ SchemaFactory sf = SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI, SCHEMA_FACTORY_CLASSNAME, null);
+ Schema schema = sf.newSchema();
+ assertNotNull(schema);
+ }
+
+ /*
+ * test for SchemaFactory.newInstance(java.lang.String schemaLanguage,
+ * java.lang.String factoryClassName, java.lang.ClassLoader classLoader)
+ * factoryClassName is null , should throw IllegalArgumentException
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class)
+ public void testNewInstanceWithNullFactoryClassName(String factoryClassName, ClassLoader classLoader) {
+
+ SchemaFactory.newInstance(W3C_XML_SCHEMA_NS_URI, factoryClassName, classLoader);
+ }
+
+ /*
+ * test for SchemaFactory.newInstance(java.lang.String schemaLanguage,
+ * java.lang.String factoryClassName, java.lang.ClassLoader classLoader)
+ * schemaLanguage is null , should throw NPE
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testNewInstanceWithNullSchemaLanguage() {
+ SchemaFactory.newInstance(null, SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader());
+ }
+
+ /*
+ * test for SchemaFactory.newInstance(java.lang.String schemaLanguage,
+ * java.lang.String factoryClassName, java.lang.ClassLoader classLoader)
+ * schemaLanguage is empty , should throw IllegalArgumentException
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testNewInstanceWithEmptySchemaLanguage() {
+ SchemaFactory.newInstance("", SCHEMA_FACTORY_CLASSNAME, this.getClass().getClassLoader());
+ }
+
+
@Test(expectedExceptions = SAXParseException.class)
public void testNewSchemaDefault() throws SAXException, IOException {
validate(sf.newSchema());
@@ -288,6 +343,8 @@
private static final String UNRECOGNIZED_NAME = "http://xml.org/sax/features/namespace-prefixes";
+ private static final String SCHEMA_FACTORY_CLASSNAME = "com.sun.org.apache.xerces.internal.jaxp.validation.XMLSchemaFactory";
+
private SchemaFactory sf;
private byte[] xsd1;
private byte[] xsd2;
--- a/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxp/test/javax/xml/jaxp/functional/javax/xml/xpath/ptests/XPathFactoryTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -24,10 +24,16 @@
package javax.xml.xpath.ptests;
import static javax.xml.xpath.XPathConstants.DOM_OBJECT_MODEL;
+
+import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathFactory;
import javax.xml.xpath.XPathFactoryConfigurationException;
+
+import jaxp.library.JAXPDataProvider;
import jaxp.library.JAXPBaseTest;
-import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.Assert.assertNotNull;
+
+import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
/**
@@ -45,6 +51,78 @@
private static final String INVALID_URL = "http://java.sun.com/jaxp/xpath/dom1";
/**
+ * XPathFactory implementation class name.
+ */
+ private static final String XPATH_FACTORY_CLASSNAME = "com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl";
+
+
+ /**
+ * Provide valid XPathFactory instantiation parameters.
+ *
+ * @return a data provider contains XPathFactory instantiation parameters.
+ */
+ @DataProvider(name = "parameters")
+ public Object[][] getValidateParameters() {
+ return new Object[][] { { VALID_URL, XPATH_FACTORY_CLASSNAME, null }, { VALID_URL, XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader() } };
+ }
+
+ /**
+ * Test for XPathFactory.newInstance(java.lang.String uri, java.lang.String
+ * factoryClassName, java.lang.ClassLoader classLoader) factoryClassName
+ * points to correct implementation of javax.xml.xpath.XPathFactory , should
+ * return newInstance of XPathFactory
+ *
+ * @param uri
+ * @param factoryClassName
+ * @param classLoader
+ * @throws XPathFactoryConfigurationException
+ */
+ @Test(dataProvider = "parameters")
+ public void testNewInstance(String uri, String factoryClassName, ClassLoader classLoader) throws XPathFactoryConfigurationException {
+ XPathFactory xpf = XPathFactory.newInstance(uri, factoryClassName, classLoader);
+ XPath xpath = xpf.newXPath();
+ assertNotNull(xpath);
+ }
+
+ /**
+ * Test for XPathFactory.newInstance(java.lang.String uri, java.lang.String
+ * factoryClassName, java.lang.ClassLoader classLoader)
+ *
+ * @param factoryClassName
+ * @param classLoader
+ * @throws XPathFactoryConfigurationException
+ * is expected when factoryClassName is null
+ */
+ @Test(expectedExceptions = XPathFactoryConfigurationException.class, dataProvider = "new-instance-neg", dataProviderClass = JAXPDataProvider.class)
+ public void testNewInstanceWithNullFactoryClassName(String factoryClassName, ClassLoader classLoader) throws XPathFactoryConfigurationException {
+ XPathFactory.newInstance(VALID_URL, factoryClassName, classLoader);
+ }
+
+ /**
+ * Test for XPathFactory.newInstance(java.lang.String uri, java.lang.String
+ * factoryClassName, java.lang.ClassLoader classLoader) uri is null , should
+ * throw NPE
+ *
+ * @throws XPathFactoryConfigurationException
+ */
+ @Test(expectedExceptions = NullPointerException.class)
+ public void testNewInstanceWithNullUri() throws XPathFactoryConfigurationException {
+ XPathFactory.newInstance(null, XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader());
+ }
+
+ /**
+ * Test for XPathFactory.newInstance(java.lang.String uri, java.lang.String
+ * factoryClassName, java.lang.ClassLoader classLoader)
+ *
+ * @throws IllegalArgumentException
+ * is expected when uri is empty
+ */
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void testNewInstanceWithEmptyUri() throws XPathFactoryConfigurationException {
+ XPathFactory.newInstance("", XPATH_FACTORY_CLASSNAME, this.getClass().getClassLoader());
+ }
+
+ /**
* Test for constructor - XPathFactory.newInstance().
*/
@Test
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxp/test/javax/xml/jaxp/libs/jaxp/library/JAXPDataProvider.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,38 @@
+/*
+ * 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 jaxp.library;
+
+import org.testng.annotations.DataProvider;
+
+/**
+ * Provide invalid parameters for negative testing Factory.newInstance.
+ */
+public class JAXPDataProvider {
+
+ @DataProvider(name = "new-instance-neg")
+ public static Object[][] getNewInstanceNeg() {
+ return new Object[][] { { null, null }, { null, JAXPDataProvider.class.getClassLoader() } };
+ }
+
+}
--- a/jaxws/.hgtags Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/.hgtags Wed Feb 18 19:27:49 2015 -0800
@@ -294,3 +294,5 @@
64ca52b0bda8028636e4ccafbe1107befcdda47d jdk9-b46
6c17d648d03e4bf4729c3645f8db55d34115e0b7 jdk9-b47
33e7e699804892c0496adf60ad67cc12855aeb61 jdk9-b48
+435a49db1de0589acc86b2cc5fd61d546f94b56c jdk9-b49
+45a30e7ee623031a1532685512dd2c2d8e8fa0ad jdk9-b50
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBContext.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, 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
@@ -45,14 +45,14 @@
* specialized forms of the method available:
*
* <ul>
- * <li>{@link #newInstance(String,ClassLoader) JAXBContext.newInstance( "com.acme.foo:com.acme.bar" )} <br/>
+ * <li>{@link #newInstance(String,ClassLoader) JAXBContext.newInstance( "com.acme.foo:com.acme.bar" )} <br>
* The JAXBContext instance is initialized from a list of colon
* separated Java package names. Each java package contains
* JAXB mapped classes, schema-derived classes and/or user annotated
* classes. Additionally, the java package may contain JAXB package annotations
* that must be processed. (see JLS, Section 7.4.1 "Named Packages").
* </li>
- * <li>{@link #newInstance(Class...) JAXBContext.newInstance( com.acme.foo.Foo.class )} <br/>
+ * <li>{@link #newInstance(Class...) JAXBContext.newInstance( com.acme.foo.Foo.class )} <br>
* The JAXBContext instance is initialized with class(es)
* passed as parameter(s) and classes that are statically reachable from
* these class(es). See {@link #newInstance(Class...)} for details.
@@ -64,8 +64,8 @@
* class containing the following method signatures:</i>
*
* <pre>
- * public static JAXBContext createContext( String contextPath, ClassLoader classLoader, Map<String,Object> properties ) throws JAXBException
- * public static JAXBContext createContext( Class[] classes, Map<String,Object> properties ) throws JAXBException
+ * public static JAXBContext createContext( String contextPath, ClassLoader classLoader, Map<String,Object> properties ) throws JAXBException
+ * public static JAXBContext createContext( Class[] classes, Map<String,Object> properties ) throws JAXBException
* </pre>
*
* <p><i>
@@ -256,7 +256,7 @@
* @author <ul><li>Ryan Shoemaker, Sun Microsystems, Inc.</li><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Joe Fialli, Sun Microsystems, Inc.</li></ul>
* @see Marshaller
* @see Unmarshaller
- * @see S 7.4.1 "Named Packages" in Java Language Specification</a>
+ * @see <a href="http://docs.oracle.com/javase/specs/jls/se7/html/jls-7.html#jls-7.4.1">S 7.4.1 "Named Packages" in Java Language Specification</a>
* @since 1.6, JAXB 1.0
*/
public abstract class JAXBContext {
@@ -352,7 +352,7 @@
* <p>
* To maintain compatibility with JAXB 1.0 schema to java
* interface/implementation binding, enabled by schema customization
- * <tt><jaxb:globalBindings valueClass="false"></tt>,
+ * <tt><jaxb:globalBindings valueClass="false"></tt>,
* the JAXB provider will ensure that each package on the context path
* has a <tt>jaxb.properties</tt> file which contains a value for the
* <tt>javax.xml.bind.context.factory</tt> property and that all values
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBException.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBException.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, 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
@@ -48,7 +48,7 @@
* Exception reference
*
*/
- private Throwable linkedException;
+ private volatile Throwable linkedException;
static final long serialVersionUID = -5621384651494307979L;
@@ -133,7 +133,7 @@
* indicates that the linked exception does not exist or
* is unknown).
*/
- public synchronized void setLinkedException( Throwable exception ) {
+ public void setLinkedException( Throwable exception ) {
this.linkedException = exception;
}
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBIntrospector.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/JAXBIntrospector.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -51,7 +51,7 @@
* <ol>
* <li>It is an instance of <code>javax.xml.bind.JAXBElement</code>.</li>
* <li>The class of <code>object</code> is annotated with
- * <code>@XmlRootElement</code>.
+ * <code>@XmlRootElement</code>.
* </li>
* </ol>
*
@@ -74,7 +74,7 @@
*
* <p>Convenience method to abstract whether working with either
* a javax.xml.bind.JAXBElement instance or an instance of
- * <tt>@XmlRootElement</tt> annotated Java class.</p>
+ * <tt>@XmlRootElement</tt> annotated Java class.</p>
*
* @param jaxbElement object that #isElement(Object) returns true.
*
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Marshaller.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, 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
@@ -175,7 +175,7 @@
* encoding used during these marshal operations. Client applications are
* expected to supply a valid character encoding name as defined in the
* <a href="http://www.w3.org/TR/2000/REC-xml-20001006#charencoding">W3C XML 1.0
- * Recommendation</a> and supported by your Java Platform</a>.
+ * Recommendation</a> and supported by your Java Platform.
* </blockquote>
*
* <p>
@@ -664,7 +664,7 @@
*
* <p>
* Every marshaller internally maintains a
- * {@link java.util.Map}<{@link Class},{@link XmlAdapter}>,
+ * {@link java.util.Map}<{@link Class},{@link XmlAdapter}>,
* which it uses for marshalling classes whose fields/methods are annotated
* with {@link javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter}.
*
@@ -750,17 +750,17 @@
public Schema getSchema();
/**
- * <p/>
+ * <p>
* Register an instance of an implementation of this class with a {@link Marshaller} to externally listen
* for marshal events.
- * <p/>
- * <p/>
+ * </p>
+ * <p>
* This class enables pre and post processing of each marshalled object.
* The event callbacks are called when marshalling from an instance that maps to an xml element or
* complex type definition. The event callbacks are not called when marshalling from an instance of a
* Java datatype that represents a simple type definition.
- * <p/>
- * <p/>
+ * </p>
+ * <p>
* External listener is one of two different mechanisms for defining marshal event callbacks.
* See <a href="Marshaller.html#marshalEventCallback">Marshal Event Callbacks</a> for an overview.
*
@@ -770,10 +770,10 @@
*/
public static abstract class Listener {
/**
- * <p/>
+ * <p>
* Callback method invoked before marshalling from <tt>source</tt> to XML.
- * <p/>
- * <p/>
+ * </p>
+ * <p>
* This method is invoked just before marshalling process starts to marshal <tt>source</tt>.
* Note that if the class of <tt>source</tt> defines its own <tt>beforeMarshal</tt> method,
* the class specific callback method is invoked just before this method is invoked.
@@ -784,10 +784,10 @@
}
/**
- * <p/>
+ * <p>
* Callback method invoked after marshalling <tt>source</tt> to XML.
- * <p/>
- * <p/>
+ * </p>
+ * <p>
* This method is invoked after <tt>source</tt> and all its descendants have been marshalled.
* Note that if the class of <tt>source</tt> defines its own <tt>afterMarshal</tt> method,
* the class specific callback method is invoked just before this method is invoked.
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/SchemaOutputResolver.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/SchemaOutputResolver.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -70,11 +70,11 @@
*
* If the {@link Result} object has a system ID, it must be an
* absolute system ID. Those system IDs are relativized by the caller and used
- * for <xs:import> statements.
+ * for <xs:import> statements.
*
* If the {@link Result} object does not have a system ID, a schema
* for the namespace URI is generated but it won't be explicitly
- * <xs:import>ed from other schemas.
+ * <xs:import>ed from other schemas.
*
* If {@code null} is returned, the schema generation for this
* namespace URI will be skipped.
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/TypeConstraintException.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/TypeConstraintException.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, 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
@@ -57,8 +57,9 @@
* Exception reference
*
*/
- private Throwable linkedException;
+ private volatile Throwable linkedException;
+ static final long serialVersionUID = -3059799699420143848L;
/**
* Construct a TypeConstraintException with the specified detail message. The
@@ -141,7 +142,7 @@
* indicates that the linked exception does not exist or
* is unknown).
*/
- public synchronized void setLinkedException( Throwable exception ) {
+ public void setLinkedException( Throwable exception ) {
this.linkedException = exception;
}
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/Unmarshaller.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, 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
@@ -238,13 +238,12 @@
* to a JAXB mapped class by {@link JAXBContext}, that the root
* element's <tt>xsi:type</tt> attribute takes
* precedence over the unmarshal methods <tt>declaredType</tt> parameter.
- * These methods always return a <tt>JAXBElement<declaredType></tt>
+ * These methods always return a <tt>JAXBElement<declaredType></tt>
* instance. The table below shows how the properties of the returned JAXBElement
* instance are set.
*
* <a name="unmarshalDeclaredTypeReturn"></a>
- * <p>
- * <table border="2" rules="all" cellpadding="4">
+ * <table summary="" border="2" rules="all" cellpadding="4">
* <thead>
* <tr>
* <th align="center" colspan="2">
@@ -284,19 +283,19 @@
* <blockquote>
* <pre>
* Schema fragment for example
- * <xs:schema>
- * <xs:complexType name="FooType">...<\xs:complexType>
- * <!-- global element declaration "PurchaseOrder" -->
- * <xs:element name="PurchaseOrder">
- * <xs:complexType>
- * <xs:sequence>
- * <!-- local element declaration "foo" -->
- * <xs:element name="foo" type="FooType"/>
+ * <xs:schema>
+ * <xs:complexType name="FooType">...<\xs:complexType>
+ * <!-- global element declaration "PurchaseOrder" -->
+ * <xs:element name="PurchaseOrder">
+ * <xs:complexType>
+ * <xs:sequence>
+ * <!-- local element declaration "foo" -->
+ * <xs:element name="foo" type="FooType"/>
* ...
- * </xs:sequence>
- * </xs:complexType>
- * </xs:element>
- * </xs:schema>
+ * </xs:sequence>
+ * </xs:complexType>
+ * </xs:element>
+ * </xs:schema>
*
* JAXBContext jc = JAXBContext.newInstance( "com.acme.foo" );
* Unmarshaller u = jc.createUnmarshaller();
@@ -309,7 +308,7 @@
* // local element declaration in schema.
*
* // FooType is the JAXB mapping of the type of local element declaration foo.
- * JAXBElement<FooType> foo = u.unmarshal( fooSubtree, FooType.class);
+ * JAXBElement<FooType> foo = u.unmarshal( fooSubtree, FooType.class);
* </pre>
* </blockquote>
*
@@ -390,7 +389,7 @@
* The external listener callback mechanism enables the registration of a {@link Listener}
* instance with an {@link Unmarshaller#setListener(Listener)}. The external listener receives all callback events,
* allowing for more centralized processing than per class defined callback methods. The external listener
- * receives events when unmarshalling proces is marshalling to a JAXB element or to JAXB mapped class.
+ * receives events when unmarshalling process is marshalling to a JAXB element or to JAXB mapped class.
* <p>
* The 'class defined' and external listener event callback methods are independent of each other,
* both can be called for one event. The invocation ordering when both listener callback methods exist is
@@ -1010,7 +1009,7 @@
*
* <p>
* Every unmarshaller internally maintains a
- * {@link java.util.Map}<{@link Class},{@link XmlAdapter}>,
+ * {@link java.util.Map}<{@link Class},{@link XmlAdapter}>,
* which it uses for unmarshalling classes whose fields/methods are annotated
* with {@link javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter}.
*
@@ -1050,7 +1049,6 @@
/**
* <p>Associate a context that resolves cid's, content-id URIs, to
* binary data passed as attachments.</p>
- * <p/>
* <p>Unmarshal time validation, enabled via {@link #setSchema(Schema)},
* must be supported even when unmarshaller is performing XOP processing.
* </p>
@@ -1063,21 +1061,21 @@
AttachmentUnmarshaller getAttachmentUnmarshaller();
/**
- * <p/>
+ * <p>
* Register an instance of an implementation of this class with {@link Unmarshaller} to externally listen
* for unmarshal events.
- * <p/>
- * <p/>
+ * </p>
+ * <p>
* This class enables pre and post processing of an instance of a JAXB mapped class
* as XML data is unmarshalled into it. The event callbacks are called when unmarshalling
* XML content into a JAXBElement instance or a JAXB mapped class that represents a complex type definition.
* The event callbacks are not called when unmarshalling to an instance of a
* Java datatype that represents a simple type definition.
- * <p/>
- * <p/>
+ * </p>
+ * <p>
* External listener is one of two different mechanisms for defining unmarshal event callbacks.
* See <a href="Unmarshaller.html#unmarshalEventCallback">Unmarshal Event Callbacks</a> for an overview.
- * <p/>
+ * </p>
* (@link #setListener(Listener)}
* (@link #getListener()}
*
@@ -1085,10 +1083,10 @@
*/
public static abstract class Listener {
/**
- * <p/>
+ * <p>
* Callback method invoked before unmarshalling into <tt>target</tt>.
- * <p/>
- * <p/>
+ * </p>
+ * <p>
* This method is invoked immediately after <tt>target</tt> was created and
* before the unmarshalling of this object begins. Note that
* if the class of <tt>target</tt> defines its own <tt>beforeUnmarshal</tt> method,
@@ -1102,10 +1100,10 @@
}
/**
- * <p/>
+ * <p>
* Callback method invoked after unmarshalling XML data into <tt>target</tt>.
- * <p/>
- * <p/>
+ * </p>
+ * <p>
* This method is invoked after all the properties (except IDREF) are unmarshalled into <tt>target</tt>,
* but before <tt>target</tt> is set into its <tt>parent</tt> object.
* Note that if the class of <tt>target</tt> defines its own <tt>afterUnmarshal</tt> method,
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyAttribute.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyAttribute.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -62,7 +62,7 @@
* each attribute that is not statically associated with another
* JavaBean property, via {@link XmlAttribute}, is entered into the
* wildcard attribute map represented by
- * {@link Map}<{@link QName},{@link Object}>. The attribute QName is the
+ * {@link Map}<{@link QName},{@link Object}>. The attribute QName is the
* map's key. The key's value is the String value of the attribute.
*
* @author Kohsuke Kawaguchi, Sun Microsystems, Inc.
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyElement.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAnyElement.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -50,7 +50,6 @@
* annotation for the other JavaBean properties on the class, is added to this
* "catch-all" property.
*
- * <p>
* <h2>Usages:</h2>
* <pre>
* @XmlAnyElement
@@ -61,7 +60,7 @@
* public {@link Object}[] others;
*
* @XmlAnyElement
- * private List<{@link Element}> nodes;
+ * private List<{@link Element}> nodes;
*
* @XmlAnyElement
* private {@link Element} node;
@@ -88,7 +87,7 @@
* <pre>
* // List of java.lang.String or DOM nodes.
* @XmlAnyElement @XmlMixed
- * List<Object> others;
+ * List<Object> others;
* </pre>
*
*
@@ -96,13 +95,13 @@
*
* The following schema would produce the following Java class:
* <pre>
- * <xs:complexType name="foo">
- * <xs:sequence>
- * <xs:element name="a" type="xs:int" />
- * <xs:element name="b" type="xs:int" />
- * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
- * </xs:sequence>
- * </xs:complexType>
+ * <xs:complexType name="foo">
+ * <xs:sequence>
+ * <xs:element name="a" type="xs:int" />
+ * <xs:element name="b" type="xs:int" />
+ * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
*
* <pre>
@@ -110,35 +109,35 @@
* int a;
* int b;
* @{@link XmlAnyElement}
- * List<Element> any;
+ * List<Element> any;
* }
* </pre>
*
* It can unmarshal instances like
*
* <pre>
- * <foo xmlns:e="extra">
- * <a>1</a>
- * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
- * <b>3</b>
- * <e:other />
- * <c>5</c> // this will be bound to DOM, because the annotation doesn't remember namespaces.
- * </foo>
+ * <foo xmlns:e="extra">
+ * <a>1</a>
+ * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
+ * <b>3</b>
+ * <e:other />
+ * <c>5</c> // this will be bound to DOM, because the annotation doesn't remember namespaces.
+ * </foo>
* </pre>
*
*
*
* The following schema would produce the following Java class:
* <pre>
- * <xs:complexType name="bar">
- * <xs:complexContent>
- * <xs:extension base="foo">
- * <xs:sequence>
- * <xs:element name="c" type="xs:int" />
- * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
- * </xs:sequence>
- * </xs:extension>
- * </xs:complexType>
+ * <xs:complexType name="bar">
+ * <xs:complexContent>
+ * <xs:extension base="foo">
+ * <xs:sequence>
+ * <xs:element name="c" type="xs:int" />
+ * <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded" />
+ * </xs:sequence>
+ * </xs:extension>
+ * </xs:complexType>
* </pre>
*
* <pre>
@@ -152,14 +151,14 @@
* It can unmarshal instances like
*
* <pre>
- * <bar xmlns:e="extra">
- * <a>1</a>
- * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
- * <b>3</b>
- * <e:other />
- * <c>5</c> // this now goes to Bar.c
- * <e:other /> // this will go to Foo.any
- * </bar>
+ * <bar xmlns:e="extra">
+ * <a>1</a>
+ * <e:other /> // this will be bound to DOM, because unmarshalling is orderless
+ * <b>3</b>
+ * <e:other />
+ * <c>5</c> // this now goes to Bar.c
+ * <e:other /> // this will go to Foo.any
+ * </bar>
* </pre>
*
*
@@ -173,13 +172,13 @@
* <p>
* The following schema would produce the following Java class:
* <pre>
- * <xs:complexType name="foo">
- * <xs:choice maxOccurs="unbounded" minOccurs="0">
- * <xs:element name="a" type="xs:int" />
- * <xs:element name="b" type="xs:int" />
- * <xs:any namespace="##other" processContents="lax" />
- * </xs:choice>
- * </xs:complexType>
+ * <xs:complexType name="foo">
+ * <xs:choice maxOccurs="unbounded" minOccurs="0">
+ * <xs:element name="a" type="xs:int" />
+ * <xs:element name="b" type="xs:int" />
+ * <xs:any namespace="##other" processContents="lax" />
+ * </xs:choice>
+ * </xs:complexType>
* </pre>
*
* <pre>
@@ -189,27 +188,27 @@
* @{@link XmlElementRef}(name="a", type="JAXBElement.class")
* @{@link XmlElementRef}(name="b", type="JAXBElement.class")
* })
- * {@link List}<{@link Object}> others;
+ * {@link List}<{@link Object}> others;
* }
*
* @XmlRegistry
* class ObjectFactory {
* ...
* @XmlElementDecl(name = "a", namespace = "", scope = Foo.class)
- * {@link JAXBElement}<Integer> createFooA( Integer i ) { ... }
+ * {@link JAXBElement}<Integer> createFooA( Integer i ) { ... }
*
* @XmlElementDecl(name = "b", namespace = "", scope = Foo.class)
- * {@link JAXBElement}<Integer> createFooB( Integer i ) { ... }
+ * {@link JAXBElement}<Integer> createFooB( Integer i ) { ... }
* </pre>
*
* It can unmarshal instances like
*
* <pre>
- * <foo xmlns:e="extra">
- * <a>1</a> // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
- * <e:other /> // this will unmarshal to a DOM {@link Element}.
- * <b>3</b> // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
- * </foo>
+ * <foo xmlns:e="extra">
+ * <a>1</a> // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
+ * <e:other /> // this will unmarshal to a DOM {@link Element}.
+ * <b>3</b> // this will unmarshal to a {@link JAXBElement} instance whose value is 1.
+ * </foo>
* </pre>
*
*
@@ -227,10 +226,10 @@
* </pre>
* then the following document will unmarshal like this:
* <pre>
- * <foo>
- * <unknown />
- * <foo />
- * </foo>
+ * <foo>
+ * <unknown />
+ * <foo />
+ * </foo>
*
* Foo foo = unmarshal();
* // 1 for 'unknown', another for 'foo'
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttachmentRef.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttachmentRef.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,14 +52,14 @@
* </pre>
* The above code maps to the following XML:
* <pre>
- * <xs:element name="foo" xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd">
- * <xs:complexType>
- * <xs:sequence>
- * <xs:element name="body" type="ref:swaRef" minOccurs="0" />
- * </xs:sequence>
- * <xs:attribute name="data" type="ref:swaRef" use="optional" />
- * </xs:complexType>
- * </xs:element>
+ * <xs:element name="foo" xmlns:ref="http://ws-i.org/profiles/basic/1.1/xsd">
+ * <xs:complexType>
+ * <xs:sequence>
+ * <xs:element name="body" type="ref:swaRef" minOccurs="0" />
+ * </xs:sequence>
+ * <xs:attribute name="data" type="ref:swaRef" use="optional" />
+ * </xs:complexType>
+ * </xs:element>
* </pre>
*
* <p>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttribute.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlAttribute.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -56,8 +56,8 @@
* simple type.
* <pre>
* // Examples
- * @XmlAttribute List<Integer> items; //legal
- * @XmlAttribute List<Bar> foo; // illegal if Bar does not map to a schema simple type
+ * @XmlAttribute List<Integer> items; //legal
+ * @XmlAttribute List<Bar> foo; // illegal if Bar does not map to a schema simple type
* </pre>
* </li>
* <li> If the type of the field or the property is a non
@@ -80,7 +80,6 @@
* {@link XmlInlineBinaryData},
* {@link javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter}.</li>
* </ul>
- * </p>
*
* <p> <b>Example 1: </b>Map a JavaBean property to an XML attribute.</p>
* <pre>
@@ -91,12 +90,12 @@
* public void setPrice(java.math.BigDecimal ) {...};
* }
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="USPrice">
- * <xs:sequence>
- * </xs:sequence>
- * <xs:attribute name="price" type="xs:decimal"/>
- * </xs:complexType>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="USPrice">
+ * <xs:sequence>
+ * </xs:sequence>
+ * <xs:attribute name="price" type="xs:decimal"/>
+ * </xs:complexType>
* </pre>
*
* <p> <b>Example 2: </b>Map a JavaBean property to an XML attribute with anonymous type.</p>
@@ -107,17 +106,17 @@
* // Example: Code fragment
* class Foo {
* ...
- * @XmlAttribute List<Integer> items;
+ * @XmlAttribute List<Integer> items;
* }
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="foo">
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="foo">
* ...
- * <xs:attribute name="items">
- * <xs:simpleType>
- * <xs:list itemType="xs:int"/>
- * </xs:simpleType>
- * </xs:complexType>
+ * <xs:attribute name="items">
+ * <xs:simpleType>
+ * <xs:list itemType="xs:int"/>
+ * </xs:simpleType>
+ * </xs:complexType>
*
* </pre>
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElement.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElement.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -83,12 +83,12 @@
* public java.math.BigDecimal price;
* }
*
- * <!-- Example: Local XML Schema element -->
- * <xs:complexType name="USPrice"/>
- * <xs:sequence>
- * <xs:element name="itemprice" type="xs:decimal" minOccurs="0"/>
- * </sequence>
- * </xs:complexType>
+ * <!-- Example: Local XML Schema element -->
+ * <xs:complexType name="USPrice"/>
+ * <xs:sequence>
+ * <xs:element name="itemprice" type="xs:decimal" minOccurs="0"/>
+ * </sequence>
+ * </xs:complexType>
* </pre>
* <p>
*
@@ -101,12 +101,12 @@
* public java.math.BigDecimal price;
* }
*
- * <!-- Example: Local XML Schema element -->
- * <xs:complexType name="USPrice">
- * <xs:sequence>
- * <xs:element name="price" type="xs:decimal" nillable="true" minOccurs="0"/>
- * </sequence>
- * </xs:complexType>
+ * <!-- Example: Local XML Schema element -->
+ * <xs:complexType name="USPrice">
+ * <xs:sequence>
+ * <xs:element name="price" type="xs:decimal" nillable="true" minOccurs="0"/>
+ * </sequence>
+ * </xs:complexType>
* </pre>
* <p>
* <b> Example 3: </b> Map a field to a nillable, required element.
@@ -118,14 +118,13 @@
* public java.math.BigDecimal price;
* }
*
- * <!-- Example: Local XML Schema element -->
- * <xs:complexType name="USPrice">
- * <xs:sequence>
- * <xs:element name="price" type="xs:decimal" nillable="true" minOccurs="1"/>
- * </sequence>
- * </xs:complexType>
+ * <!-- Example: Local XML Schema element -->
+ * <xs:complexType name="USPrice">
+ * <xs:sequence>
+ * <xs:element name="price" type="xs:decimal" nillable="true" minOccurs="1"/>
+ * </sequence>
+ * </xs:complexType>
* </pre>
- * <p>
*
* <p> <b>Example 4: </b>Map a JavaBean property to an XML element
* with anonymous type.</p>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementDecl.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementDecl.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -62,23 +62,23 @@
* @XmlRegistry
* class ObjectFactory {
* @XmlElementDecl(name="foo")
- * JAXBElement<String> createFoo(String s) { ... }
+ * JAXBElement<String> createFoo(String s) { ... }
* }
* </pre>
* <pre>
- * <!-- XML input -->
- * <foo>string</foo>
+ * <!-- XML input -->
+ * <foo>string</foo>
*
* // Example: code fragment corresponding to XML input
- * JAXBElement<String> o =
- * (JAXBElement<String>)unmarshaller.unmarshal(aboveDocument);
+ * JAXBElement<String> o =
+ * (JAXBElement<String>)unmarshaller.unmarshal(aboveDocument);
* // print JAXBElement instance to show values
* System.out.println(o.getName()); // prints "{}foo"
* System.out.println(o.getValue()); // prints "string"
* System.out.println(o.getValue().getClass()); // prints "java.lang.String"
*
- * <!-- Example: XML schema definition -->
- * <xs:element name="foo" type="xs:string"/>
+ * <!-- Example: XML schema definition -->
+ * <xs:element name="foo" type="xs:string"/>
* </pre>
*
* <p><b>Example 2: </b> Element declaration with non local scope
@@ -91,16 +91,16 @@
* this javadoc.
*
* <pre>
- * <!-- Example: XML schema definition -->
- * <xs:schema>
- * <xs:complexType name="pea">
- * <xs:choice maxOccurs="unbounded">
- * <xs:element name="foo" type="xs:string"/>
- * <xs:element name="bar" type="xs:string"/>
- * </xs:choice>
- * </xs:complexType>
- * <xs:element name="foo" type="xs:int"/>
- * </xs:schema>
+ * <!-- Example: XML schema definition -->
+ * <xs:schema>
+ * <xs:complexType name="pea">
+ * <xs:choice maxOccurs="unbounded">
+ * <xs:element name="foo" type="xs:string"/>
+ * <xs:element name="bar" type="xs:string"/>
+ * </xs:choice>
+ * </xs:complexType>
+ * <xs:element name="foo" type="xs:int"/>
+ * </xs:schema>
* </pre>
* <pre>
* // Example: expected default binding
@@ -109,19 +109,19 @@
* @XmlElementRef(name="foo",type=JAXBElement.class)
* @XmlElementRef(name="bar",type=JAXBElement.class)
* })
- * List<JAXBElement<String>> fooOrBar;
+ * List<JAXBElement<String>> fooOrBar;
* }
*
* @XmlRegistry
* class ObjectFactory {
* @XmlElementDecl(scope=Pea.class,name="foo")
- * JAXBElement<String> createPeaFoo(String s);
+ * JAXBElement<String> createPeaFoo(String s);
*
* @XmlElementDecl(scope=Pea.class,name="bar")
- * JAXBElement<String> createPeaBar(String s);
+ * JAXBElement<String> createPeaBar(String s);
*
* @XmlElementDecl(name="foo")
- * JAXBElement<Integer> createFoo(Integer i);
+ * JAXBElement<Integer> createFoo(Integer i);
* }
*
* </pre>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementRef.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementRef.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -57,8 +57,8 @@
* (section 5.5.5, "Element Property" of JAXB 2.0 specification). An
* element property method signature is of the form:
* <pre>
- * public void setTerm(JAXBElement<? extends Operator>);
- * public JAXBElement<? extends Operator> getTerm();
+ * public void setTerm(JAXBElement<? extends Operator>);
+ * public JAXBElement<? extends Operator> getTerm();
* </pre>
* <p>
* An element factory method annotated with {@link XmlElementDecl} is
@@ -106,7 +106,7 @@
* // element name will be derived from the @XmlRootElement
* // annotation on the type (for e.g. "jar" for JarTask).
* @XmlElementRef
- * List<Task> tasks;
+ * List<Task> tasks;
* }
*
* abstract class Task {
@@ -122,16 +122,16 @@
* ...
* }
*
- * <!-- XML Schema fragment -->
- * <xs:element name="target" type="Target">
- * <xs:complexType name="Target">
- * <xs:sequence>
- * <xs:choice maxOccurs="unbounded">
- * <xs:element ref="jar">
- * <xs:element ref="javac">
- * </xs:choice>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- XML Schema fragment -->
+ * <xs:element name="target" type="Target">
+ * <xs:complexType name="Target">
+ * <xs:sequence>
+ * <xs:choice maxOccurs="unbounded">
+ * <xs:element ref="jar">
+ * <xs:element ref="javac">
+ * </xs:choice>
+ * </xs:sequence>
+ * </xs:complexType>
*
* </pre>
* <p>
@@ -144,14 +144,14 @@
* </pre>
* will produce the following XML output:
* <pre>
- * <target>
- * <jar>
+ * <target>
+ * <jar>
* ....
- * </jar>
- * <javac>
+ * </jar>
+ * <javac>
* ....
- * </javac>
- * </target>
+ * </javac>
+ * </target>
* </pre>
* <p>
* It is not an error to have a class that extends <tt>Task</tt>
@@ -182,17 +182,17 @@
* // substituted in the XML document.
* //
* @XmlElementRef(type=JAXBElement.class,name="operator")
- * JAXBElement<? extends Operator> term;
+ * JAXBElement<? extends Operator> term;
* }
*
* @XmlRegistry
* class ObjectFactory {
* @XmlElementDecl(name="operator")
- * JAXBElement<Operator> createOperator(Operator o) {...}
+ * JAXBElement<Operator> createOperator(Operator o) {...}
* @XmlElementDecl(name="add",substitutionHeadName="operator")
- * JAXBElement<Operator> createAdd(Operator o) {...}
+ * JAXBElement<Operator> createAdd(Operator o) {...}
* @XmlElementDecl(name="sub",substitutionHeadName="operator")
- * JAXBElement<Operator> createSub(Operator o) {...}
+ * JAXBElement<Operator> createSub(Operator o) {...}
* }
*
* class Operator {
@@ -208,9 +208,9 @@
* </pre>
* will produce the following XML output:
* <pre>
- * <math>
- * <add>...</add>
- * </math>
+ * <math>
+ * <add>...</add>
+ * </math>
* </pre>
*
*
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementWrapper.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElementWrapper.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -44,15 +44,15 @@
* int[] names;
*
* // XML Serialization Form 1 (Unwrapped collection)
- * <names> ... </names>
- * <names> ... </names>
+ * <names> ... </names>
+ * <names> ... </names>
*
* // XML Serialization Form 2 ( Wrapped collection )
- * <wrapperElement>
- * <names> value-of-item </names>
- * <names> value-of-item </names>
+ * <wrapperElement>
+ * <names> value-of-item </names>
+ * <names> value-of-item </names>
* ....
- * </wrapperElement>
+ * </wrapperElement>
* </pre>
*
* <p> The two serialized XML forms allow a null collection to be
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElements.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlElements.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -83,21 +83,21 @@
* }
*
* <!-- XML Representation for a List of {1,2.5}
- * XML output is not wrapped using another element -->
+ * XML output is not wrapped using another element -->
* ...
- * <A> 1 </A>
- * <B> 2.5 </B>
+ * <A> 1 </A>
+ * <B> 2.5 </B>
* ...
*
- * <!-- XML Schema fragment -->
- * <xs:complexType name="Foo">
- * <xs:sequence>
- * <xs:choice minOccurs="0" maxOccurs="unbounded">
- * <xs:element name="A" type="xs:int"/>
- * <xs:element name="B" type="xs:float"/>
- * <xs:choice>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- XML Schema fragment -->
+ * <xs:complexType name="Foo">
+ * <xs:sequence>
+ * <xs:choice minOccurs="0" maxOccurs="unbounded">
+ * <xs:element name="A" type="xs:int"/>
+ * <xs:element name="B" type="xs:float"/>
+ * <xs:choice>
+ * </xs:sequence>
+ * </xs:complexType>
*
* </pre>
*
@@ -115,19 +115,19 @@
* public List items;
* }
*
- * <!-- XML Schema fragment -->
- * <xs:complexType name="Foo">
- * <xs:sequence>
- * <xs:element name="bar">
- * <xs:complexType>
- * <xs:choice minOccurs="0" maxOccurs="unbounded">
- * <xs:element name="A" type="xs:int"/>
- * <xs:element name="B" type="xs:float"/>
- * </xs:choice>
- * </xs:complexType>
- * </xs:element>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- XML Schema fragment -->
+ * <xs:complexType name="Foo">
+ * <xs:sequence>
+ * <xs:element name="bar">
+ * <xs:complexType>
+ * <xs:choice minOccurs="0" maxOccurs="unbounded">
+ * <xs:element name="A" type="xs:int"/>
+ * <xs:element name="B" type="xs:float"/>
+ * </xs:choice>
+ * </xs:complexType>
+ * </xs:element>
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
*
* <p><b>Example 3:</b> Change element name based on type using an adapter.
@@ -146,19 +146,19 @@
* @XmlType(name="PX") class PX extends P {...}
* @XmlType(name="PY") class PY extends P {...}
*
- * <!-- XML Schema fragment -->
- * <xs:complexType name="Foo">
- * <xs:sequence>
- * <xs:element name="bar">
- * <xs:complexType>
- * <xs:choice minOccurs="0" maxOccurs="unbounded">
- * <xs:element name="A" type="PX"/>
- * <xs:element name="B" type="PY"/>
- * </xs:choice>
- * </xs:complexType>
- * </xs:element>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- XML Schema fragment -->
+ * <xs:complexType name="Foo">
+ * <xs:sequence>
+ * <xs:element name="bar">
+ * <xs:complexType>
+ * <xs:choice minOccurs="0" maxOccurs="unbounded">
+ * <xs:element name="A" type="PX"/>
+ * <xs:element name="B" type="PY"/>
+ * </xs:choice>
+ * </xs:complexType>
+ * </xs:element>
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
*
* @author <ul><li>Kohsuke Kawaguchi, Sun Microsystems, Inc.</li><li>Sekhar Vajjhala, Sun Microsystems, Inc.</li></ul>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlEnumValue.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlEnumValue.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -56,23 +56,23 @@
* <p> In the absence of this annotation, {@link Enum#name()} is used
* as the XML representation.
*
- * <p> <b>Example 1: </b>Map enum constant name -> enumeration facet</p>
+ * <p> <b>Example 1: </b>Map enum constant name -> enumeration facet</p>
* <pre>
* //Example: Code fragment
* @XmlEnum(String.class)
* public enum Card { CLUBS, DIAMONDS, HEARTS, SPADES }
*
- * <!-- Example: XML Schema fragment -->
- * <xs:simpleType name="Card">
- * <xs:restriction base="xs:string"/>
- * <xs:enumeration value="CLUBS"/>
- * <xs:enumeration value="DIAMONDS"/>
- * <xs:enumeration value="HEARTS"/>
- * <xs:enumeration value="SPADES"/>
- * </xs:simpleType>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:simpleType name="Card">
+ * <xs:restriction base="xs:string"/>
+ * <xs:enumeration value="CLUBS"/>
+ * <xs:enumeration value="DIAMONDS"/>
+ * <xs:enumeration value="HEARTS"/>
+ * <xs:enumeration value="SPADES"/>
+ * </xs:simpleType>
* </pre>
*
- * <p><b>Example 2: </b>Map enum constant name(value) -> enumeration facet </p>
+ * <p><b>Example 2: </b>Map enum constant name(value) -> enumeration facet </p>
* <pre>
* //Example: code fragment
* @XmlType
@@ -83,18 +83,18 @@
* @XmlEnumValue("10") DIME(10),
* @XmlEnumValue("25") QUARTER(25) }
*
- * <!-- Example: XML Schema fragment -->
- * <xs:simpleType name="Coin">
- * <xs:restriction base="xs:int">
- * <xs:enumeration value="1"/>
- * <xs:enumeration value="5"/>
- * <xs:enumeration value="10"/>
- * <xs:enumeration value="25"/>
- * </xs:restriction>
- * </xs:simpleType>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:simpleType name="Coin">
+ * <xs:restriction base="xs:int">
+ * <xs:enumeration value="1"/>
+ * <xs:enumeration value="5"/>
+ * <xs:enumeration value="10"/>
+ * <xs:enumeration value="25"/>
+ * </xs:restriction>
+ * </xs:simpleType>
* </pre>
*
- * <p><b>Example 3: </b>Map enum constant name -> enumeration facet </p>
+ * <p><b>Example 3: </b>Map enum constant name -> enumeration facet </p>
*
* <pre>
* //Code fragment
@@ -105,13 +105,13 @@
* @XmlEnumValue("2") TWO;
* }
*
- * <!-- Example: XML Schema fragment -->
- * <xs:simpleType name="Code">
- * <xs:restriction base="xs:int">
- * <xs:enumeration value="1"/>
- * <xs:enumeration value="2"/>
- * </xs:restriction>
- * </xs:simpleType>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:simpleType name="Code">
+ * <xs:restriction base="xs:int">
+ * <xs:enumeration value="1"/>
+ * <xs:enumeration value="2"/>
+ * </xs:restriction>
+ * </xs:simpleType>
* </pre>
*
* @since 1.6, JAXB 2.0
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlID.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlID.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -74,15 +74,15 @@
* .... other properties not shown
* }
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="Customer">
- * <xs:complexContent>
- * <xs:sequence>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="Customer">
+ * <xs:complexContent>
+ * <xs:sequence>
* ....
- * </xs:sequence>
- * <xs:attribute name="customerID" type="xs:ID"/>
- * </xs:complexContent>
- * </xs:complexType>
+ * </xs:sequence>
+ * <xs:attribute name="customerID" type="xs:ID"/>
+ * </xs:complexContent>
+ * </xs:complexType>
* </pre>
*
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlIDREF.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlIDREF.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -83,15 +83,15 @@
* ....
* }
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="Shipping">
- * <xs:complexContent>
- * <xs:sequence>
- * <xs:element name="customer" type="xs:IDREF"/>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="Shipping">
+ * <xs:complexContent>
+ * <xs:sequence>
+ * <xs:element name="customer" type="xs:IDREF"/>
* ....
- * </xs:sequence>
- * </xs:complexContent>
- * </xs:complexType>
+ * </xs:sequence>
+ * </xs:complexContent>
+ * </xs:complexType>
*
* </pre>
*
@@ -143,61 +143,61 @@
* public Invoice getInvoice();
* }
*
- * <!-- XML Schema mapping for above code frament -->
+ * <!-- XML Schema mapping for above code frament -->
*
- * <xs:complexType name="Invoice">
- * <xs:complexContent>
- * <xs:sequence>
- * <xs:element name="customer" type="xs:IDREF"/>
+ * <xs:complexType name="Invoice">
+ * <xs:complexContent>
+ * <xs:sequence>
+ * <xs:element name="customer" type="xs:IDREF"/>
* ....
- * </xs:sequence>
- * </xs:complexContent>
- * </xs:complexType>
+ * </xs:sequence>
+ * </xs:complexContent>
+ * </xs:complexType>
*
- * <xs:complexType name="Shipping">
- * <xs:complexContent>
- * <xs:sequence>
- * <xs:element name="customer" type="xs:IDREF"/>
+ * <xs:complexType name="Shipping">
+ * <xs:complexContent>
+ * <xs:sequence>
+ * <xs:element name="customer" type="xs:IDREF"/>
* ....
- * </xs:sequence>
- * </xs:complexContent>
- * </xs:complexType>
+ * </xs:sequence>
+ * </xs:complexContent>
+ * </xs:complexType>
*
- * <xs:complexType name="Customer">
- * <xs:complexContent>
- * <xs:sequence>
+ * <xs:complexType name="Customer">
+ * <xs:complexContent>
+ * <xs:sequence>
* ....
- * </xs:sequence>
- * <xs:attribute name="CustomerID" type="xs:ID"/>
- * </xs:complexContent>
- * </xs:complexType>
+ * </xs:sequence>
+ * <xs:attribute name="CustomerID" type="xs:ID"/>
+ * </xs:complexContent>
+ * </xs:complexType>
*
- * <xs:complexType name="CustomerData">
- * <xs:complexContent>
- * <xs:sequence>
- * <xs:element name="customer" type="xs:Customer"/>
- * <xs:element name="shipping" type="xs:Shipping"/>
- * <xs:element name="invoice" type="xs:Invoice"/>
- * </xs:sequence>
- * </xs:complexContent>
- * </xs:complexType>
+ * <xs:complexType name="CustomerData">
+ * <xs:complexContent>
+ * <xs:sequence>
+ * <xs:element name="customer" type="xs:Customer"/>
+ * <xs:element name="shipping" type="xs:Shipping"/>
+ * <xs:element name="invoice" type="xs:Invoice"/>
+ * </xs:sequence>
+ * </xs:complexContent>
+ * </xs:complexType>
*
- * <xs:element name"customerData" type="xs:CustomerData"/>
+ * <xs:element name"customerData" type="xs:CustomerData"/>
*
- * <!-- Instance document conforming to the above XML Schema -->
- * <customerData>
- * <customer customerID="Alice">
+ * <!-- Instance document conforming to the above XML Schema -->
+ * <customerData>
+ * <customer customerID="Alice">
* ....
- * </customer>
+ * </customer>
*
- * <shipping customer="Alice">
+ * <shipping customer="Alice">
* ....
- * </shipping>
+ * </shipping>
*
- * <invoice customer="Alice">
+ * <invoice customer="Alice">
* ....
- * </invoice>
- * </customerData>
+ * </invoice>
+ * </customerData>
*
* </pre>
*
@@ -210,14 +210,14 @@
* public List customers;
* }
*
- * <!-- XML schema fragment -->
- * <xs:complexType name="Shipping">
- * <xs:sequence>
- * <xs:choice minOccurs="0" maxOccurs="unbounded">
- * <xs:element name="Alice" type="xs:IDREF"/>
- * </xs:choice>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- XML schema fragment -->
+ * <xs:complexType name="Shipping">
+ * <xs:sequence>
+ * <xs:choice minOccurs="0" maxOccurs="unbounded">
+ * <xs:element name="Alice" type="xs:IDREF"/>
+ * </xs:choice>
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
*
* <p><b>Example 4: </b> Mapping a List to a list of elements of type IDREF.
@@ -231,15 +231,15 @@
* public List customers;
* }
*
- * <!-- XML Schema fragment -->
- * <xs:complexType name="Shipping">
- * <xs:sequence>
- * <xs:choice minOccurs="0" maxOccurs="unbounded">
- * <xs:element name="Alice" type="xs:IDREF"/>
- * <xs:element name="John" type="xs:IDREF"/>
- * </xs:choice>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- XML Schema fragment -->
+ * <xs:complexType name="Shipping">
+ * <xs:sequence>
+ * <xs:choice minOccurs="0" maxOccurs="unbounded">
+ * <xs:element name="Alice" type="xs:IDREF"/>
+ * <xs:element name="John" type="xs:IDREF"/>
+ * </xs:choice>
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
* @see XmlID
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlList.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlList.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -53,17 +53,17 @@
* @XmlRootElement
* class Foo {
* @XmlElement
- * List<String> data;
+ * List<String> data;
* }
* </pre>
*
* would produce XML like this:
*
* <pre>
- * <foo>
- * <data>abc</data>
- * <data>def</data>
- * </foo>
+ * <foo>
+ * <data>abc</data>
+ * <data>def</data>
+ * </foo>
* </pre>
*
* @XmlList annotation, on the other hand, allows multiple values to be
@@ -74,16 +74,16 @@
* class Foo {
* @XmlElement
* @XmlList
- * List<String> data;
+ * List<String> data;
* }
* </pre>
*
* the above code will produce XML like this:
*
* <pre>
- * <foo>
- * <data>abc def</data>
- * </foo>
+ * <foo>
+ * <data>abc def</data>
+ * </foo>
* </pre>
*
* <p>This annotation can be used with the following annotations:
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlMixed.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlMixed.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -57,16 +57,16 @@
*
* Below is an example of binding and creation of mixed content.
* <pre>
- * <!-- schema fragment having mixed content -->
- * <xs:complexType name="letterBody" mixed="true">
- * <xs:sequence>
- * <xs:element name="name" type="xs:string"/>
- * <xs:element name="quantity" type="xs:positiveInteger"/>
- * <xs:element name="productName" type="xs:string"/>
- * <!-- etc. -->
- * </xs:sequence>
- * </xs:complexType>
- * <xs:element name="letterBody" type="letterBody"/>
+ * <!-- schema fragment having mixed content -->
+ * <xs:complexType name="letterBody" mixed="true">
+ * <xs:sequence>
+ * <xs:element name="name" type="xs:string"/>
+ * <xs:element name="quantity" type="xs:positiveInteger"/>
+ * <xs:element name="productName" type="xs:string"/>
+ * <!-- etc. -->
+ * </xs:sequence>
+ * </xs:complexType>
+ * <xs:element name="letterBody" type="letterBody"/>
*
* // Schema-derived Java code:
* // (Only annotations relevant to mixed content are shown below,
@@ -74,12 +74,12 @@
* import java.math.BigInteger;
* public class ObjectFactory {
* // element instance factories
- * JAXBElement<LetterBody> createLetterBody(LetterBody value);
- * JAXBElement<String> createLetterBodyName(String value);
- * JAXBElement<BigInteger> createLetterBodyQuantity(BigInteger value);
- * JAXBElement<String> createLetterBodyProductName(String value);
+ * JAXBElement<LetterBody> createLetterBody(LetterBody value);
+ * JAXBElement<String> createLetterBodyName(String value);
+ * JAXBElement<BigInteger> createLetterBodyQuantity(BigInteger value);
+ * JAXBElement<String> createLetterBodyProductName(String value);
* // type instance factory
- * LetterBody> createLetterBody();
+ * LetterBody createLetterBody();
* }
* </pre>
* <pre>
@@ -97,16 +97,16 @@
* </pre>
* The following is an XML instance document with mixed content
* <pre>
- * <letterBody>
- * Dear Mr.<name>Robert Smith</name>
- * Your order of <quantity>1</quantity> <productName>Baby
- * Monitor</productName> shipped from our warehouse. ....
- * </letterBody>
+ * <letterBody>
+ * Dear Mr.<name>Robert Smith</name>
+ * Your order of <quantity>1</quantity> <productName>Baby
+ * Monitor</productName> shipped from our warehouse. ....
+ * </letterBody>
* </pre>
* that can be constructed using following JAXB API calls.
* <pre>
* LetterBody lb = ObjectFactory.createLetterBody();
- * JAXBElement<LetterBody> lbe = ObjectFactory.createLetterBody(lb);
+ * JAXBElement<LetterBody> lbe = ObjectFactory.createLetterBody(lb);
* List gcl = lb.getContent(); //add mixed content to general content property.
* gcl.add("Dear Mr."); // add text information item as a String.
*
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlNsForm.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -36,8 +36,7 @@
* The namespace qualification values are used in the annotations
* defined in this packge. The enumeration values are mapped as follows:
*
- * <p>
- * <table border="1" cellpadding="4" cellspacing="3">
+ * <table summary="" border="1" cellpadding="4" cellspacing="3">
* <tbody>
* <tr>
* <td><b>Enum Value</b></td>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlRootElement.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlRootElement.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -54,7 +54,7 @@
* <p> This annotation can be used with the following annotations:
* {@link XmlType}, {@link XmlEnum}, {@link XmlAccessorType},
* {@link XmlAccessorOrder}.
- * <p>
+ * </p>
* <p>
* <b>Example 1: </b> Associate an element with XML Schema type
@@ -74,11 +74,11 @@
* </pre>
*
* <pre>
- * <!-- Example: XML output -->
- * <point>
- * <x> 3 </x>
- * <y> 5 </y>
- * </point>
+ * <!-- Example: XML output -->
+ * <point>
+ * <x> 3 </x>
+ * <y> 5 </y>
+ * </point>
* </pre>
*
* The annotation causes an global element declaration to be produced
@@ -86,14 +86,14 @@
* the XML schema type to which the class is mapped.
*
* <pre>
- * <!-- Example: XML schema definition -->
- * <xs:element name="point" type="point"/>
- * <xs:complexType name="point">
- * <xs:sequence>
- * <xs:element name="x" type="xs:int"/>
- * <xs:element name="y" type="xs:int"/>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- Example: XML schema definition -->
+ * <xs:element name="point" type="point"/>
+ * <xs:complexType name="point">
+ * <xs:sequence>
+ * <xs:element name="x" type="xs:int"/>
+ * <xs:element name="y" type="xs:int"/>
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
*
* <p>
@@ -114,25 +114,25 @@
* //Example: Code fragment corresponding to XML output *
* marshal( new Point3D(3,5,0), System.out );
*
- * <!-- Example: XML output -->
- * <!-- The element name is point3D not point -->
- * <point3D>
- * <x>3</x>
- * <y>5</y>
- * <z>0</z>
- * </point3D>
+ * <!-- Example: XML output -->
+ * <!-- The element name is point3D not point -->
+ * <point3D>
+ * <x>3</x>
+ * <y>5</y>
+ * <z>0</z>
+ * </point3D>
*
- * <!-- Example: XML schema definition -->
- * <xs:element name="point3D" type="point3D"/>
- * <xs:complexType name="point3D">
- * <xs:complexContent>
- * <xs:extension base="point">
- * <xs:sequence>
- * <xs:element name="z" type="xs:int"/>
- * </xs:sequence>
- * </xs:extension>
- * </xs:complexContent>
- * </xs:complexType>
+ * <!-- Example: XML schema definition -->
+ * <xs:element name="point3D" type="point3D"/>
+ * <xs:complexType name="point3D">
+ * <xs:complexContent>
+ * <xs:extension base="point">
+ * <xs:sequence>
+ * <xs:element name="z" type="xs:int"/>
+ * </xs:sequence>
+ * </xs:extension>
+ * </xs:complexContent>
+ * </xs:complexType>
* </pre>
*
* <b>Example 3: </b> Associate a global element with XML Schema type
@@ -145,13 +145,13 @@
* public java.math.BigDecimal price;
* }
*
- * <!-- Example: XML schema definition -->
- * <xs:element name="PriceElement" type="USPrice"/>
- * <xs:complexType name="USPrice">
- * <xs:sequence>
- * <xs:element name="price" type="xs:decimal"/>
- * </sequence>
- * </xs:complexType>
+ * <!-- Example: XML schema definition -->
+ * <xs:element name="PriceElement" type="USPrice"/>
+ * <xs:complexType name="USPrice">
+ * <xs:sequence>
+ * <xs:element name="price" type="xs:decimal"/>
+ * </sequence>
+ * </xs:complexType>
* </pre>
*
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchema.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchema.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -55,7 +55,6 @@
* will allow the package level annotations to be defined in
* package-info.java.
* </ul>
- * <p>
*
* <p><b>Example 1:</b> Customize name of XML namespace to which
* package is mapped.</p>
@@ -65,14 +64,14 @@
* namespace = "http://www.example.com/MYPO1"
* )
*
- * <!-- XML Schema fragment -->
+ * <!-- XML Schema fragment -->
* <schema
* xmlns=...
* xmlns:po=....
* targetNamespace="http://www.example.com/MYPO1"
- * >
+ * >
* <!-- prefixes generated by default are implementation
- * depedenent -->
+ * depedenent -->
* </pre>
*
* <p><b>Example 2:</b> Customize namespace prefix, namespace URI
@@ -90,11 +89,11 @@
* )
* )
*
- * <!-- XML Schema fragment -->
+ * <!-- XML Schema fragment -->
* <schema
* xmlns:xs="http://www.w3.org/2001/XMLSchema"
* xmlns:po="http://www.example.com/PO1"
- * targetNamespace="http://www.example.com/PO1">
+ * targetNamespace="http://www.example.com/PO1">
*
* </pre>
*
@@ -105,11 +104,11 @@
* ...
* )
*
- * <!-- XML Schema fragment -->
+ * <!-- XML Schema fragment -->
* <schema
* xmlns="http://www.w3.org/2001/XMLSchema"
* xmlns:po="http://www.example.com/PO1"
- * elementFormDefault="unqualified">
+ * elementFormDefault="unqualified">
*
* </pre>
@@ -180,11 +179,11 @@
* More precisely, the value must be either <tt>""</tt>, <tt>"##generate"</tt>, or
* <a href="http://www.w3.org/TR/xmlschema-2/#anyURI">
* a valid lexical representation of <tt>xs:anyURI</tt></a> that begins
- * with <tt><scheme>:</tt>.
+ * with <tt><scheme>:</tt>.
*
* <p>
* A schema generator is expected to generate a corresponding
- * <tt><xs:import namespace="..." schemaLocation="..."/></tt> (or
+ * <tt><xs:import namespace="..." schemaLocation="..."/></tt> (or
* no <tt>schemaLocation</tt> attribute at all if the empty string is specified.)
* However, the schema generator is allowed to use a different value in
* the <tt>schemaLocation</tt> attribute (including not generating
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchemaType.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlSchemaType.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -66,12 +66,12 @@
* public XMLGregorianCalendar date;
* }
*
- * <!-- Example: Local XML Schema element -->
- * <xs:complexType name="USPrice"/>
- * <xs:sequence>
- * <xs:element name="date" type="xs:date"/>
- * </sequence>
- * </xs:complexType>
+ * <!-- Example: Local XML Schema element -->
+ * <xs:complexType name="USPrice"/>
+ * <xs:sequence>
+ * <xs:element name="date" type="xs:date"/>
+ * </sequence>
+ * </xs:complexType>
* </pre>
*
* <p> <b> Example 2: </b> Customize mapping of XMLGregorianCalendar at package
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlTransient.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlTransient.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -79,12 +79,12 @@
* }
*
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="USAddress">
- * <xs:sequence>
- * <xs:element name="name" type="xs:string"/>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="USAddress">
+ * <xs:sequence>
+ * <xs:element name="name" type="xs:string"/>
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
*
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlType.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -64,7 +64,7 @@
* mapping of JavaBean properties and fields contained within the
* class. The schema type to which the class is mapped can either be
* named or anonymous. A class can be mapped to an anonymous schema
- * type by annotating the class with <tt>@XmlType(name="")</tt>.
+ * type by annotating the class with <tt>@XmlType(name="")</tt>.
* <p>
* Either a global element, local element or a local attribute can be
* associated with an anonymous type as follows:
@@ -112,14 +112,14 @@
* The following table shows the mapping of the class to a XML Schema
* complex type or simple type. The notational symbols used in the table are:
* <ul>
- * <li> -> : represents a mapping </li>
+ * <li> -> : represents a mapping </li>
* <li> [x]+ : one or more occurances of x </li>
* <li> [ <tt>@XmlValue</tt> property ]: JavaBean property annotated with
* <tt>@XmlValue</tt></li>
* <li> X : don't care
* </ul>
* <blockquote>
- * <table border="1" cellpadding="4" cellspacing="3">
+ * <table summary="" border="1" cellpadding="4" cellspacing="3">
* <tbody>
* <tr>
* <td><b>Target</b></td>
@@ -132,7 +132,7 @@
* <tr valign="top">
* <td>Class</td>
* <td>{}</td>
- * <td>[property]+ -> elements</td>
+ * <td>[property]+ -> elements</td>
* <td>complexcontent<br>xs:all</td>
* <td> </td>
* </tr>
@@ -140,7 +140,7 @@
* <tr valign="top">
* <td>Class</td>
* <td>non empty</td>
- * <td>[property]+ -> elements</td>
+ * <td>[property]+ -> elements</td>
* <td>complexcontent<br>xs:sequence</td>
* <td> </td>
* </tr>
@@ -148,7 +148,7 @@
* <tr valign="top">
* <td>Class</td>
* <td>X</td>
- * <td>no property -> element</td>
+ * <td>no property -> element</td>
* <td>complexcontent<br>empty sequence</td>
* <td> </td>
* </tr>
@@ -156,8 +156,7 @@
* <tr valign="top">
* <td>Class</td>
* <td>X</td>
- * <td>1 [ <tt>@XmlValue</tt> property] && <br> [property]+
- * ->attributes</td>
+ * <td>1 [<tt>@XmlValue</tt> property] {@literal &&} <br> [property]+ -> attributes</td>
* <td>simplecontent</td>
* <td> </td>
* </tr>
@@ -165,11 +164,9 @@
* <tr valign="top">
* <td>Class</td>
* <td>X</td>
- * <td>1 [ <tt>@XmlValue</tt> property ]&& <br> no properties
- * -> attribute</td>
+ * <td>1 [<tt>@XmlValue</tt> property] {@literal &&} <br> no properties -> attribute</td>
* <td> </td>
* <td>simpletype</td>
- * <td> </td>
* </tr>
* </tbody>
* </table>
@@ -212,16 +209,16 @@
* void setZip(java.math.BigDecimal) {..};
* }
*
- * <!-- XML Schema mapping for USAddress -->
- * <xs:complexType name="USAddress">
- * <xs:sequence>
- * <xs:element name="street" type="xs:string"/>
- * <xs:element name="city" type="xs:string"/>
- * <xs:element name="state" type="xs:string"/>
- * <xs:element name="zip" type="xs:decimal"/>
- * <xs:element name="name" type="xs:string"/>
- * </xs:all>
- * </xs:complexType>
+ * <!-- XML Schema mapping for USAddress -->
+ * <xs:complexType name="USAddress">
+ * <xs:sequence>
+ * <xs:element name="street" type="xs:string"/>
+ * <xs:element name="city" type="xs:string"/>
+ * <xs:element name="state" type="xs:string"/>
+ * <xs:element name="zip" type="xs:decimal"/>
+ * <xs:element name="name" type="xs:string"/>
+ * </xs:all>
+ * </xs:complexType>
* </pre>
* <p> <b> Example 2: </b> Map a class to a complex type with
* xs:all </p>
@@ -229,16 +226,16 @@
* @XmlType(propOrder={})
* public class USAddress { ...}
*
- * <!-- XML Schema mapping for USAddress -->
- * <xs:complexType name="USAddress">
- * <xs:all>
- * <xs:element name="name" type="xs:string"/>
- * <xs:element name="street" type="xs:string"/>
- * <xs:element name="city" type="xs:string"/>
- * <xs:element name="state" type="xs:string"/>
- * <xs:element name="zip" type="xs:decimal"/>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- XML Schema mapping for USAddress -->
+ * <xs:complexType name="USAddress">
+ * <xs:all>
+ * <xs:element name="name" type="xs:string"/>
+ * <xs:element name="street" type="xs:string"/>
+ * <xs:element name="city" type="xs:string"/>
+ * <xs:element name="state" type="xs:string"/>
+ * <xs:element name="zip" type="xs:decimal"/>
+ * </xs:sequence>
+ * </xs:complexType>
*</pre>
* <p> <b> Example 3: </b> Map a class to a global element with an
* anonymous type.
@@ -248,22 +245,22 @@
* @XmlType(name="")
* public class USAddress { ...}
*
- * <!-- XML Schema mapping for USAddress -->
- * <xs:element name="USAddress">
- * <xs:complexType>
- * <xs:sequence>
- * <xs:element name="name" type="xs:string"/>
- * <xs:element name="street" type="xs:string"/>
- * <xs:element name="city" type="xs:string"/>
- * <xs:element name="state" type="xs:string"/>
- * <xs:element name="zip" type="xs:decimal"/>
- * </xs:sequence>
- * </xs:complexType>
- * </xs:element>
+ * <!-- XML Schema mapping for USAddress -->
+ * <xs:element name="USAddress">
+ * <xs:complexType>
+ * <xs:sequence>
+ * <xs:element name="name" type="xs:string"/>
+ * <xs:element name="street" type="xs:string"/>
+ * <xs:element name="city" type="xs:string"/>
+ * <xs:element name="state" type="xs:string"/>
+ * <xs:element name="zip" type="xs:decimal"/>
+ * </xs:sequence>
+ * </xs:complexType>
+ * </xs:element>
* </pre>
*
* <p> <b> Example 4: </b> Map a property to a local element with
- * anonmyous type.
+ * anonymous type.
* <pre>
* //Example: Code fragment
* public class Invoice {
@@ -275,20 +272,20 @@
* public class USAddress { ... }
* }
*
- * <!-- XML Schema mapping for USAddress -->
- * <xs:complexType name="Invoice">
- * <xs:sequence>
- * <xs:element name="addr">
- * <xs:complexType>
- * <xs:element name="name", type="xs:string"/>
- * <xs:element name="city", type="xs:string"/>
- * <xs:element name="city" type="xs:string"/>
- * <xs:element name="state" type="xs:string"/>
- * <xs:element name="zip" type="xs:decimal"/>
- * </xs:complexType>
+ * <!-- XML Schema mapping for USAddress -->
+ * <xs:complexType name="Invoice">
+ * <xs:sequence>
+ * <xs:element name="addr">
+ * <xs:complexType>
+ * <xs:element name="name", type="xs:string"/>
+ * <xs:element name="city", type="xs:string"/>
+ * <xs:element name="city" type="xs:string"/>
+ * <xs:element name="state" type="xs:string"/>
+ * <xs:element name="zip" type="xs:decimal"/>
+ * </xs:complexType>
* ...
- * </xs:sequence>
- * </xs:complexType>
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
*
* <p> <b> Example 5: </b> Map a property to an attribute with
@@ -310,17 +307,17 @@
* public java.math.BigDecimal price;
* }
*
- * <!-- Example: XML Schema fragment -->
- * <xs:complexType name="Item">
- * <xs:sequence>
- * <xs:element name="name" type="xs:string"/>
- * <xs:attribute name="price">
- * <xs:simpleType>
- * <xs:restriction base="xs:decimal"/>
- * </xs:simpleType>
- * </xs:attribute>
- * </xs:sequence>
- * </xs:complexType>
+ * <!-- Example: XML Schema fragment -->
+ * <xs:complexType name="Item">
+ * <xs:sequence>
+ * <xs:element name="name" type="xs:string"/>
+ * <xs:attribute name="price">
+ * <xs:simpleType>
+ * <xs:restriction base="xs:decimal"/>
+ * </xs:simpleType>
+ * </xs:attribute>
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
*
* <p> <b> Example 6: </b> Define a factoryClass and factoryMethod
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlValue.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/XmlValue.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -67,7 +67,6 @@
* type, then the type must map to a XML Schema simple type. </li>
*
* </ul>
- * </p>
* <p>
* If the annotated JavaBean property is the sole class member being
* mapped to XML Schema construct, then the class is mapped to a
@@ -89,10 +88,10 @@
* public java.math.BigDecimal price;
* }
*
- * <!-- Example 1: XML Schema fragment -->
- * <xs:simpleType name="USPrice">
- * <xs:restriction base="xs:decimal"/>
- * </xs:simpleType>
+ * <!-- Example 1: XML Schema fragment -->
+ * <xs:simpleType name="USPrice">
+ * <xs:restriction base="xs:decimal"/>
+ * </xs:simpleType>
*
* </pre>
*
@@ -110,17 +109,16 @@
* public String currency;
* }
*
- * <!-- Example 2: XML Schema fragment -->
- * <xs:complexType name="InternationalPrice">
- * <xs:simpleContent>
- * <xs:extension base="xs:decimal">
- * <xs:attribute name="currency" type="xs:string"/>
- * </xs:extension>
- * </xs:simpleContent>
- * </xs:complexType>
+ * <!-- Example 2: XML Schema fragment -->
+ * <xs:complexType name="InternationalPrice">
+ * <xs:simpleContent>
+ * <xs:extension base="xs:decimal">
+ * <xs:attribute name="currency" type="xs:string"/>
+ * </xs:extension>
+ * </xs:simpleContent>
+ * </xs:complexType>
*
* </pre>
- * </p>
*
* @author Sekhar Vajjhala, Sun Microsystems, Inc.
* @see XmlType
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlAdapter.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/annotation/adapters/XmlAdapter.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2013, 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
@@ -76,11 +76,11 @@
* <p> <b> Step 1: </b> Determine the desired XML representation for HashMap.
*
* <pre>
- * <hashmap>
- * <entry key="id123">this is a value</entry>
- * <entry key="id312">this is another value</entry>
+ * <hashmap>
+ * <entry key="id123">this is a value</entry>
+ * <entry key="id312">this is another value</entry>
* ...
- * </hashmap>
+ * </hashmap>
* </pre>
*
* <p> <b> Step 2: </b> Determine the schema definition that the
@@ -88,20 +88,20 @@
*
* <pre>
*
- * <xs:complexType name="myHashMapType">
- * <xs:sequence>
+ * <xs:complexType name="myHashMapType">
+ * <xs:sequence>
* <xs:element name="entry" type="myHashMapEntryType"
- * minOccurs = "0" maxOccurs="unbounded"/>
- * </xs:sequence>
- * </xs:complexType>
+ * minOccurs = "0" maxOccurs="unbounded"/>
+ * </xs:sequence>
+ * </xs:complexType>
*
- * <xs:complexType name="myHashMapEntryType">
- * <xs:simpleContent>
- * <xs:extension base="xs:string">
- * <xs:attribute name="key" type="xs:int"/>
- * </xs:extension>
- * </xs:simpleContent>
- * </xs:complexType>
+ * <xs:complexType name="myHashMapEntryType">
+ * <xs:simpleContent>
+ * <xs:extension base="xs:string">
+ * <xs:attribute name="key" type="xs:int"/>
+ * </xs:extension>
+ * </xs:simpleContent>
+ * </xs:complexType>
*
* </pre>
*
@@ -110,7 +110,7 @@
*
* <pre>
* public class MyHashMapType {
- * List<MyHashMapEntryType> entry;
+ * List<MyHashMapEntryType> entry;
* }
*
* public class MyHashMapEntryType {
@@ -127,7 +127,7 @@
*
* <pre>
* public final class MyHashMapAdapter extends
- * XmlAdapter<MyHashMapType,HashMap> { ... }
+ * XmlAdapter<MyHashMapType,HashMap> { ... }
*
* </pre>
*
@@ -144,11 +144,11 @@
* The above code fragment will map to the following schema:
*
* <pre>
- * <xs:complexType name="Foo">
- * <xs:sequence>
- * <xs:element name="hashmap" type="myHashMapType"
- * </xs:sequence>
- * </xs:complexType>
+ * <xs:complexType name="Foo">
+ * <xs:sequence>
+ * <xs:element name="hashmap" type="myHashMapType">
+ * </xs:sequence>
+ * </xs:complexType>
* </pre>
*
* @param <BoundType>
--- a/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.bind/share/classes/javax/xml/bind/attachment/AttachmentUnmarshaller.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -70,7 +70,7 @@
*
* <p>The returned <code>DataHandler</code> instance must be configured
* to meet the following required mapping constaint.
- * <table border="2" rules="all" cellpadding="4">
+ * <table summary="" border="2" rules="all" cellpadding="4">
* <thead>
* <tr>
* <th align="center" colspan="2">
@@ -100,7 +100,7 @@
* </tr>
* </tbody>
* </table>
- * Note that it is allowable to support additional mappings.</p>
+ * Note that it is allowable to support additional mappings.
*
* @param cid It is expected to be a valid lexical form of the XML Schema
* <code>xs:anyURI</code> datatype. If <code>{@link #isXOPPackage()}
--- a/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/util/version.properties Wed Feb 18 19:27:49 2015 -0800
@@ -23,7 +23,7 @@
# questions.
#
-build-id=2.2.11-b141124.1933
-build-version=JAX-WS RI 2.2.11-b141124.1933
+build-id=2.2.11-b150127.1410
+build-version=JAX-WS RI 2.2.11-b150127.1410
major-version=2.2.11
-svn-revision=312b19a2e0e312b55e1ea6f531bd595955cd581f
+svn-revision=28121d09ed8ac02b76788709ccb4cdb66e03bbfa
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle.properties Wed Feb 18 19:27:49 2015 -0800
@@ -30,10 +30,10 @@
Non-existent directory: {0}
VERSION = \
- schemagen 2.2.12-b141016.1821
+ schemagen 2.2.12-b150126.1924
FULLVERSION = \
- schemagen full version "2.2.12-b141016.1821"
+ schemagen full version "2.2.12-b150126.1924"
USAGE = \
Usage: schemagen [-options ...] <java files> \n\
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_de.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_de.properties Wed Feb 18 19:27:49 2015 -0800
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = Nicht vorhandenes Verzeichnis: {0}
-VERSION = schemagen 2.2.12-b141016.1821
+VERSION = schemagen 2.2.12-b150126.1924
-FULLVERSION = schemagen vollst\u00E4ndige Version "2.2.12-b141016.1821"
+FULLVERSION = schemagen vollst\u00E4ndige Version "2.2.12-b150126.1924"
USAGE = Verwendung: schemagen [-options ...] <java files> \nOptionen: \n\\ \\ \\ \\ -d <path> : Gibt an, wo die von Prozessor und javac generierten Klassendateien gespeichert werden sollen\n\\ \\ \\ \\ -cp <path> : Gibt an, wo die vom Benutzer angegebenen Dateien gespeichert sind\n\\ \\ \\ \\ -classpath <path> : Gibt an, wo die vom Benutzer angegebenen Dateien gespeichert sind\n\\ \\ \\ \\ -encoding <encoding> : Gibt die Codierung f\u00FCr die Annotationsverarbeitung/den javac-Aufruf an \n\\ \\ \\ \\ -episode <file> : Generiert Episodendatei f\u00FCr separate Kompilierung\n\\ \\ \\ \\ -version : Zeigt Versionsinformation an\n\\ \\ \\ \\ -fullversion : Zeigt vollst\u00E4ndige Versionsinformationen an\n\\ \\ \\ \\ -help : Zeigt diese Verwendungsmeldung an
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_es.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_es.properties Wed Feb 18 19:27:49 2015 -0800
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = Directorio no existente: {0}
-VERSION = schemagen 2.2.12-b141016.1821
+VERSION = schemagen 2.2.12-b150126.1924
-FULLVERSION = versi\u00F3n completa de schemagen "2.2.12-b141016.1821"
+FULLVERSION = versi\u00F3n completa de schemagen "2.2.12-b150126.1924"
USAGE = Sintaxis: schemagen [-options ...] <archivos java> \nOpciones: \n\\ \\ \\ \\ -d <ruta de acceso> : especifique d\u00F3nde se colocan los archivos de clase generados por javac y el procesador\n\\ \\ \\ \\ -cp <ruta de acceso> : especifique d\u00F3nde se encuentran los archivos especificados por el usuario\n\\ \\ \\ \\ -encoding <codificaci\u00F3n> : especifique la codificaci\u00F3n que se va a utilizar para el procesamiento de anotaciones/llamada de javac\n\\ \\ \\ \\ -episode <archivo> : genera un archivo de episodio para una compilaci\u00F3n diferente\n\\ \\ \\ \\ -version : muestra la informaci\u00F3n de la versi\u00F3n\n\\ \\ \\ \\ -fullversion : muestra la informaci\u00F3n completa de la versi\u00F3n\n\\ \\ \\ \\ -help : muestra este mensaje de sintaxis
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_fr.properties Wed Feb 18 19:27:49 2015 -0800
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = R\u00E9pertoire {0} inexistant
-VERSION = schemagen 2.2.12-b141016.1821
+VERSION = schemagen 2.2.12-b150126.1924
-FULLVERSION = version compl\u00E8te de schemagen "2.2.12-b141016.1821"
+FULLVERSION = version compl\u00E8te de schemagen "2.2.12-b150126.1924"
USAGE = Syntaxe : schemagen [-options ...] <java files> \nOptions : \n\ \ \ \ -d <path> : indiquez o\u00F9 placer les fichiers de classe g\u00E9n\u00E9r\u00E9s par le processeur et le compilateur javac\n\ \ \ \ -cp <path> : indiquez o\u00F9 trouver les fichiers sp\u00E9cifi\u00E9s par l'utilisateur\n\ \ \ \ -classpath <path> : indiquez o\u00F9 trouver les fichiers sp\u00E9cifi\u00E9s par l'utilisateur\n\ \ \ \ -encoding <encoding> : indiquez l'encodage \u00E0 utiliser pour l'appel de javac/traitement de l'annotation \n\ \ \ \ -episode <file> : g\u00E9n\u00E9rez un fichier d'\u00E9pisode pour la compilation s\u00E9par\u00E9e\n\ \ \ \ -version : affichez les informations de version\n\ \ \ \ -fullversion : affichez les informations compl\u00E8tes de version\n\ \ \ \ -help : affichez ce message de syntaxe
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_it.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_it.properties Wed Feb 18 19:27:49 2015 -0800
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = Directory non esistente: {0}
-VERSION = schemagen 2.2.12-b141016.1821
+VERSION = schemagen 2.2.12-b150126.1924
-FULLVERSION = versione completa schemagen "2.2.12-b141016.1821"
+FULLVERSION = versione completa schemagen "2.2.12-b150126.1924"
USAGE = Uso: schemagen [-options ...] <java files> \nOpzioni: \n\ \ \ \ -d <path> : specifica dove posizionare il processore e i file della classe generata javac\n\ \ \ \ -cp <path> : specifica dove trovare i file specificati dall'utente\n\ \ \ \ -classpath <path> : specifica dove trovare i file specificati dall'utente\n\ \ \ \ -encoding <encoding> : specifica la codifica da usare per l'elaborazione dell'annotazione/richiamo javac \n\ \ \ \ -episode <file> : genera il file di episodio per la compilazione separata\n\ \ \ \ -version : visualizza le informazioni sulla versione\n\ \ \ \ -fullversion : visualizza le informazioni sulla versione completa\n\ \ \ \ -help : visualizza questo messaggio sull'uso
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ja.properties Wed Feb 18 19:27:49 2015 -0800
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = \u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304C\u5B58\u5728\u3057\u307E\u305B\u3093: {0}
-VERSION = schemagen 2.2.12-b141016.1821
+VERSION = schemagen 2.2.12-b150126.1924
-FULLVERSION = schemagen\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b141016.1821"
+FULLVERSION = schemagen\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b150126.1924"
USAGE = \u4F7F\u7528\u65B9\u6CD5: schemagen [-options ...] <java files> \n\u30AA\u30D7\u30B7\u30E7\u30F3: \n\ \ \ \ -d <path> : \u30D7\u30ED\u30BB\u30C3\u30B5\u304A\u3088\u3073javac\u304C\u751F\u6210\u3057\u305F\u30AF\u30E9\u30B9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u7F6E\u304F\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -cp <path> : \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -classpath <path> : \u30E6\u30FC\u30B6\u30FC\u304C\u6307\u5B9A\u3057\u305F\u30D5\u30A1\u30A4\u30EB\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -encoding <encoding> : \u6CE8\u91C8\u51E6\u7406/javac\u547C\u51FA\u3057\u306B\u4F7F\u7528\u3059\u308B\u30A8\u30F3\u30B3\u30FC\u30C7\u30A3\u30F3\u30B0\u3092\u6307\u5B9A\u3057\u307E\u3059\n\ \ \ \ -episode <file> : \u30B3\u30F3\u30D1\u30A4\u30EB\u3054\u3068\u306B\u30A8\u30D4\u30BD\u30FC\u30C9\u30FB\u30D5\u30A1\u30A4\u30EB\u3092\u751F\u6210\u3057\u307E\u3059\n\ \ \ \ -version : \u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3057\u307E\u3059\n\ \ \ \ -fullversion : \u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3\u60C5\u5831\u3092\u8868\u793A\u3057\u307E\u3059\n\ \ \ \ -help : \u3053\u306E\u4F7F\u7528\u4F8B\u30E1\u30C3\u30BB\u30FC\u30B8\u3092\u8868\u793A\u3057\u307E\u3059
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_ko.properties Wed Feb 18 19:27:49 2015 -0800
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = \uC874\uC7AC\uD558\uC9C0 \uC54A\uB294 \uB514\uB809\uD1A0\uB9AC: {0}
-VERSION = schemagen 2.2.12-b141016.1821
+VERSION = schemagen 2.2.12-b150126.1924
-FULLVERSION = schemagen \uC815\uC2DD \uBC84\uC804 "2.2.12-b141016.1821"
+FULLVERSION = schemagen \uC815\uC2DD \uBC84\uC804 "2.2.12-b150126.1924"
USAGE = \uC0AC\uC6A9\uBC95: schemagen [-options ...] <java files> \n\uC635\uC158: \n\ \ \ \ -d <path> : \uD504\uB85C\uC138\uC11C \uBC0F javac\uC5D0\uC11C \uC0DD\uC131\uD55C \uD074\uB798\uC2A4 \uD30C\uC77C\uC744 \uBC30\uCE58\uD560 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -cp <path> : \uC0AC\uC6A9\uC790\uAC00 \uC9C0\uC815\uD55C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -classpath <path> : \uC0AC\uC6A9\uC790\uAC00 \uC9C0\uC815\uD55C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC704\uCE58\uB97C \uC9C0\uC815\uD569\uB2C8\uB2E4.\n\ \ \ \ -encoding <encoding> : \uC8FC\uC11D \uCC98\uB9AC/javac \uD638\uCD9C\uC5D0 \uC0AC\uC6A9\uD560 \uC778\uCF54\uB529\uC744 \uC9C0\uC815\uD569\uB2C8\uB2E4. \n\ \ \ \ -episode <file> : \uBCC4\uB3C4 \uCEF4\uD30C\uC77C\uC744 \uC704\uD574 episode \uD30C\uC77C\uC744 \uC0DD\uC131\uD569\uB2C8\uB2E4.\n\ \ \ \ -version : \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n\ \ \ \ -fullversion : \uC815\uC2DD \uBC84\uC804 \uC815\uBCF4\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.\n\ \ \ \ -help : \uC774 \uC0AC\uC6A9\uBC95 \uBA54\uC2DC\uC9C0\uB97C \uD45C\uC2DC\uD569\uB2C8\uB2E4.
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_pt_BR.properties Wed Feb 18 19:27:49 2015 -0800
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = Diret\u00F3rio n\u00E3o existente: {0}
-VERSION = gera\u00E7\u00E3o do esquema 2.2.12-b141016.1821
+VERSION = gera\u00E7\u00E3o do esquema 2.2.12-b150126.1924
-FULLVERSION = vers\u00E3o completa da gera\u00E7\u00E3o do esquema "2.2.12-b141016.1821"
+FULLVERSION = vers\u00E3o completa da gera\u00E7\u00E3o do esquema "2.2.12-b150126.1924"
USAGE = Uso: gera\u00E7\u00E3o do esquema [-options ...] <java files> \nOp\u00E7\u00F5es: \n\\ \\ \\ \\ -d <path> : especificar onde colocar o processador e os arquivos da classe gerados por javac\n\\ \\ \\ \\ -cp <path> : especificar onde localizar arquivos especificados pelo usu\u00E1rio\n\\ \\ \\ \\ -classpath <path> : especificar onde localizar os arquivos especificados pelo usu\u00E1rio\n\\ \\ \\ \\ -encoding <encoding> : especificar codifica\u00E7\u00E3o a ser usada para processamento de anota\u00E7\u00E3o/chamada javac \n\\ \\ \\ \\ -episode <file> : gerar arquivo do epis\u00F3dio para compila\u00E7\u00E3o separada\n\\ \\ \\ \\ -version : exibir informa\u00E7\u00F5es da vers\u00E3o\n\\ \\ \\ \\ -fullversion : exibir informa\u00E7\u00F5es da vers\u00E3o completa\n\\ \\ \\ \\ -help : exibir esta mensagem de uso
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_CN.properties Wed Feb 18 19:27:49 2015 -0800
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = \u4E0D\u5B58\u5728\u7684\u76EE\u5F55: {0}
-VERSION = schemagen 2.2.12-b141016.1821
+VERSION = schemagen 2.2.12-b150126.1924
-FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b141016.1821"
+FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924"
USAGE = \u7528\u6CD5: schemagen [-options ...] <java files> \n\u9009\u9879: \n\ \ \ \ -d <path> : \u6307\u5B9A\u653E\u7F6E\u5904\u7406\u7A0B\u5E8F\u548C javac \u751F\u6210\u7684\u7C7B\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -cp <path> : \u6307\u5B9A\u67E5\u627E\u7528\u6237\u6307\u5B9A\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -classpath <path> : \u6307\u5B9A\u67E5\u627E\u7528\u6237\u6307\u5B9A\u6587\u4EF6\u7684\u4F4D\u7F6E\n\ \ \ \ -encoding <encoding> : \u6307\u5B9A\u7528\u4E8E\u6CE8\u91CA\u5904\u7406/javac \u8C03\u7528\u7684\u7F16\u7801\n\ \ \ \ -episode <file> : \u751F\u6210\u7247\u6BB5\u6587\u4EF6\u4EE5\u4F9B\u5355\u72EC\u7F16\u8BD1\n\ \ \ \ -version : \u663E\u793A\u7248\u672C\u4FE1\u606F\n\ \ \ \ -fullversion : \u663E\u793A\u5B8C\u6574\u7684\u7248\u672C\u4FE1\u606F\n\ \ \ \ -help : \u663E\u793A\u6B64\u7528\u6CD5\u6D88\u606F
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/jxc/MessageBundle_zh_TW.properties Wed Feb 18 19:27:49 2015 -0800
@@ -27,8 +27,8 @@
BASEDIR_DOESNT_EXIST = \u4E0D\u5B58\u5728\u7684\u76EE\u9304: {0}
-VERSION = schemagen 2.2.12-b141016.1821
+VERSION = schemagen 2.2.12-b150126.1924
-FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b141016.1821"
+FULLVERSION = schemagen \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924"
USAGE = \u7528\u6CD5: schemagen [-options ...] <java files> \n\u9078\u9805: \n\\ \\ \\ \\ -d <path> : \u6307\u5B9A\u8655\u7406\u5668\u4EE5\u53CA javac \u7522\u751F\u7684\u985E\u5225\u6A94\u6848\u653E\u7F6E\u4F4D\u7F6E\n\\ \\ \\ \\ -cp <path> : \u6307\u5B9A\u8981\u5C0B\u627E\u4F7F\u7528\u8005\u6307\u5B9A\u6A94\u6848\u7684\u4F4D\u7F6E\n\\ \\ \\ \\ -classpath <path> : \u6307\u5B9A\u8981\u5C0B\u627E\u4F7F\u7528\u8005\u6307\u5B9A\u6A94\u6848\u7684\u4F4D\u7F6E\n\\ \\ \\ \\ -encoding <encoding> : \u6307\u5B9A\u8981\u7528\u65BC\u8A3B\u89E3\u8655\u7406/javac \u547C\u53EB\u7684\u7DE8\u78BC \n\\ \\ \\ \\ -episode <file> : \u7522\u751F\u7368\u7ACB\u7DE8\u8B6F\u7684\u4E8B\u4EF6 (episode) \u6A94\u6848\n\\ \\ \\ \\ -version : \u986F\u793A\u7248\u672C\u8CC7\u8A0A\n\\ \\ \\ \\ -fullversion : \u986F\u793A\u5B8C\u6574\u7248\u672C\u8CC7\u8A0A\n\\ \\ \\ \\ -help : \u986F\u793A\u6B64\u7528\u6CD5\u8A0A\u606F
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle.properties Wed Feb 18 19:27:49 2015 -0800
@@ -171,20 +171,20 @@
Driver.FailedToGenerateCode = \
Failed to produce code.
-# DO NOT localize the 2.2.12-b141016.1821 string - it is a token for an mvn <properties filter>
+# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
Driver.FilePrologComment = \
- This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b141016.1821 \n\
+ This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150126.1924 \n\
See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\
Any modifications to this file will be lost upon recompilation of the source schema. \n\
Generated on: {0} \n
Driver.Version = \
- xjc 2.2.12-b141016.1821
+ xjc 2.2.12-b150126.1924
Driver.FullVersion = \
- xjc full version "2.2.12-b141016.1821"
+ xjc full version "2.2.12-b150126.1924"
-Driver.BuildID = 2.2.12-b141016.1821
+Driver.BuildID = 2.2.12-b150126.1924
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_de.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_de.properties Wed Feb 18 19:27:49 2015 -0800
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = Code konnte nicht erzeugt werden.
-# DO NOT localize the 2.2.12-b141016.1821 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b141016.1821 generiert \nSiehe <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u00c4nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. \nGeneriert: {0} \n
+# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = Diese Datei wurde mit der JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150126.1924 generiert \nSiehe <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u00c4nderungen an dieser Datei gehen bei einer Neukompilierung des Quellschemas verloren. \nGeneriert: {0} \n
-Driver.Version = xjc 2.2.12-b141016.1821
+Driver.Version = xjc 2.2.12-b150126.1924
-Driver.FullVersion = xjc vollst\u00E4ndige Version "2.2.12-b141016.1821"
+Driver.FullVersion = xjc vollst\u00E4ndige Version "2.2.12-b150126.1924"
-Driver.BuildID = 2.2.12-b141016.1821
+Driver.BuildID = 2.2.12-b150126.1924
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_es.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_es.properties Wed Feb 18 19:27:49 2015 -0800
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = Fallo al producir c\u00f3digo.
-# DO NOT localize the 2.2.12-b141016.1821 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = Este archivo ha sido generado por la arquitectura JavaTM para la implantaci\u00f3n de la referencia de enlace (JAXB) XML v2.2.12-b141016.1821 \nVisite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nTodas las modificaciones realizadas en este archivo se perder\u00e1n si se vuelve a compilar el esquema de origen. \nGenerado el: {0} \n
+# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = Este archivo ha sido generado por la arquitectura JavaTM para la implantaci\u00f3n de la referencia de enlace (JAXB) XML v2.2.12-b150126.1924 \nVisite <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nTodas las modificaciones realizadas en este archivo se perder\u00e1n si se vuelve a compilar el esquema de origen. \nGenerado el: {0} \n
-Driver.Version = xjc 2.2.12-b141016.1821
+Driver.Version = xjc 2.2.12-b150126.1924
-Driver.FullVersion = versi\u00F3n completa de xjc "2.2.12-b141016.1821"
+Driver.FullVersion = versi\u00F3n completa de xjc "2.2.12-b150126.1924"
-Driver.BuildID = 2.2.12-b141016.1821
+Driver.BuildID = 2.2.12-b150126.1924
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_fr.properties Wed Feb 18 19:27:49 2015 -0800
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = Echec de la production du code.
-# DO NOT localize the 2.2.12-b141016.1821 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = Ce fichier a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9 par l''impl\u00e9mentation de r\u00e9f\u00e9rence JavaTM Architecture for XML Binding (JAXB), v2.2.12-b141016.1821 \nVoir <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nToute modification apport\u00e9e \u00e0 ce fichier sera perdue lors de la recompilation du sch\u00e9ma source. \nG\u00e9n\u00e9r\u00e9 le : {0} \n
+# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = Ce fichier a \u00e9t\u00e9 g\u00e9n\u00e9r\u00e9 par l''impl\u00e9mentation de r\u00e9f\u00e9rence JavaTM Architecture for XML Binding (JAXB), v2.2.12-b150126.1924 \nVoir <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nToute modification apport\u00e9e \u00e0 ce fichier sera perdue lors de la recompilation du sch\u00e9ma source. \nG\u00e9n\u00e9r\u00e9 le : {0} \n
-Driver.Version = xjc 2.2.12-b141016.1821
+Driver.Version = xjc 2.2.12-b150126.1924
-Driver.FullVersion = version compl\u00E8te xjc "2.2.12-b141016.1821"
+Driver.FullVersion = version compl\u00E8te xjc "2.2.12-b150126.1924"
-Driver.BuildID = 2.2.12-b141016.1821
+Driver.BuildID = 2.2.12-b150126.1924
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_it.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_it.properties Wed Feb 18 19:27:49 2015 -0800
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = Produzione del codice non riuscita.
-# DO NOT localize the 2.2.12-b141016.1821 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = Questo file \u00e8 stato generato dall''architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.12-b141016.1821 \nVedere <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nQualsiasi modifica a questo file andr\u00e0 persa durante la ricompilazione dello schema di origine. \nGenerato il: {0} \n
+# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = Questo file \u00e8 stato generato dall''architettura JavaTM per XML Binding (JAXB) Reference Implementation, v2.2.12-b150126.1924 \nVedere <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nQualsiasi modifica a questo file andr\u00e0 persa durante la ricompilazione dello schema di origine. \nGenerato il: {0} \n
-Driver.Version = xjc 2.2.12-b141016.1821
+Driver.Version = xjc 2.2.12-b150126.1924
-Driver.FullVersion = versione completa xjc "2.2.12-b141016.1821"
+Driver.FullVersion = versione completa xjc "2.2.12-b150126.1924"
-Driver.BuildID = 2.2.12-b141016.1821
+Driver.BuildID = 2.2.12-b150126.1924
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ja.properties Wed Feb 18 19:27:49 2015 -0800
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = \u30b3\u30fc\u30c9\u306e\u751f\u6210\u306b\u5931\u6557\u3057\u307e\u3057\u305f\u3002
-# DO NOT localize the 2.2.12-b141016.1821 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001JavaTM Architecture for XML Binding(JAXB) Reference Implementation\u3001v2.2.12-b141016.1821\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u307e\u3057\u305f \n<a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 \n\u30bd\u30fc\u30b9\u30fb\u30b9\u30ad\u30fc\u30de\u306e\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306f\u5931\u308f\u308c\u307e\u3059\u3002 \n\u751f\u6210\u65e5: {0} \n
+# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = \u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306f\u3001JavaTM Architecture for XML Binding(JAXB) Reference Implementation\u3001v2.2.12-b150126.1924\u306b\u3088\u3063\u3066\u751f\u6210\u3055\u308c\u307e\u3057\u305f \n<a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>\u3092\u53c2\u7167\u3057\u3066\u304f\u3060\u3055\u3044 \n\u30bd\u30fc\u30b9\u30fb\u30b9\u30ad\u30fc\u30de\u306e\u518d\u30b3\u30f3\u30d1\u30a4\u30eb\u6642\u306b\u3053\u306e\u30d5\u30a1\u30a4\u30eb\u306e\u5909\u66f4\u306f\u5931\u308f\u308c\u307e\u3059\u3002 \n\u751f\u6210\u65e5: {0} \n
-Driver.Version = xjc 2.2.12-b141016.1821
+Driver.Version = xjc 2.2.12-b150126.1924
-Driver.FullVersion = xjc\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b141016.1821"
+Driver.FullVersion = xjc\u30D5\u30EB\u30FB\u30D0\u30FC\u30B8\u30E7\u30F3"2.2.12-b150126.1924"
-Driver.BuildID = 2.2.12-b141016.1821
+Driver.BuildID = 2.2.12-b150126.1924
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_ko.properties Wed Feb 18 19:27:49 2015 -0800
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = \ucf54\ub4dc \uc0dd\uc131\uc744 \uc2e4\ud328\ud588\uc2b5\ub2c8\ub2e4.
-# DO NOT localize the 2.2.12-b141016.1821 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = \uc774 \ud30c\uc77c\uc740 JAXB(JavaTM Architecture for XML Binding) \ucc38\uc870 \uad6c\ud604 2.2.12-b141016.1821 \ubc84\uc804\uc744 \ud1b5\ud574 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \n<a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624. \n\uc774 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uba74 \uc18c\uc2a4 \uc2a4\ud0a4\ub9c8\ub97c \uc7ac\ucef4\ud30c\uc77c\ud560 \ub54c \uc218\uc815 \uc0ac\ud56d\uc774 \uc190\uc2e4\ub429\ub2c8\ub2e4. \n\uc0dd\uc131 \ub0a0\uc9dc: {0} \n
+# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = \uc774 \ud30c\uc77c\uc740 JAXB(JavaTM Architecture for XML Binding) \ucc38\uc870 \uad6c\ud604 2.2.12-b150126.1924 \ubc84\uc804\uc744 \ud1b5\ud574 \uc0dd\uc131\ub418\uc5c8\uc2b5\ub2c8\ub2e4. \n<a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>\ub97c \ucc38\uc870\ud558\uc2ed\uc2dc\uc624. \n\uc774 \ud30c\uc77c\uc744 \uc218\uc815\ud558\uba74 \uc18c\uc2a4 \uc2a4\ud0a4\ub9c8\ub97c \uc7ac\ucef4\ud30c\uc77c\ud560 \ub54c \uc218\uc815 \uc0ac\ud56d\uc774 \uc190\uc2e4\ub429\ub2c8\ub2e4. \n\uc0dd\uc131 \ub0a0\uc9dc: {0} \n
-Driver.Version = XJC 2.2.12-b141016.1821
+Driver.Version = XJC 2.2.12-b150126.1924
-Driver.FullVersion = XJC \uC815\uC2DD \uBC84\uC804 "2.2.12-b141016.1821"
+Driver.FullVersion = XJC \uC815\uC2DD \uBC84\uC804 "2.2.12-b150126.1924"
-Driver.BuildID = 2.2.12-b141016.1821
+Driver.BuildID = 2.2.12-b150126.1924
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_pt_BR.properties Wed Feb 18 19:27:49 2015 -0800
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = Falha ao produzir o c\u00f3digo.
-# DO NOT localize the 2.2.12-b141016.1821 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = Este arquivo foi gerado pela Arquitetura JavaTM para Implementa\u00e7\u00e3o de Refer\u00eancia (JAXB) de Bind XML, v2.2.12-b141016.1821 \nConsulte <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nTodas as modifica\u00e7\u00f5es neste arquivo ser\u00e3o perdidas ap\u00f3s a recompila\u00e7\u00e3o do esquema de origem. \nGerado em: {0} \n
+# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = Este arquivo foi gerado pela Arquitetura JavaTM para Implementa\u00e7\u00e3o de Refer\u00eancia (JAXB) de Bind XML, v2.2.12-b150126.1924 \nConsulte <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \nTodas as modifica\u00e7\u00f5es neste arquivo ser\u00e3o perdidas ap\u00f3s a recompila\u00e7\u00e3o do esquema de origem. \nGerado em: {0} \n
-Driver.Version = xjc 2.2.12-b141016.1821
+Driver.Version = xjc 2.2.12-b150126.1924
-Driver.FullVersion = vers\u00E3o completa de xjc "2.2.12-b141016.1821"
+Driver.FullVersion = vers\u00E3o completa de xjc "2.2.12-b150126.1924"
-Driver.BuildID = 2.2.12-b141016.1821
+Driver.BuildID = 2.2.12-b150126.1924
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_CN.properties Wed Feb 18 19:27:49 2015 -0800
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = \u65e0\u6cd5\u751f\u6210\u4ee3\u7801\u3002
-# DO NOT localize the 2.2.12-b141016.1821 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = \u6b64\u6587\u4ef6\u662f\u7531 JavaTM Architecture for XML Binding (JAXB) \u5f15\u7528\u5b9e\u73b0 v2.2.12-b141016.1821 \u751f\u6210\u7684\n\u8bf7\u8bbf\u95ee <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u5728\u91cd\u65b0\u7f16\u8bd1\u6e90\u6a21\u5f0f\u65f6, \u5bf9\u6b64\u6587\u4ef6\u7684\u6240\u6709\u4fee\u6539\u90fd\u5c06\u4e22\u5931\u3002\n\u751f\u6210\u65f6\u95f4: {0} \n
+# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = \u6b64\u6587\u4ef6\u662f\u7531 JavaTM Architecture for XML Binding (JAXB) \u5f15\u7528\u5b9e\u73b0 v2.2.12-b150126.1924 \u751f\u6210\u7684\n\u8bf7\u8bbf\u95ee <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u5728\u91cd\u65b0\u7f16\u8bd1\u6e90\u6a21\u5f0f\u65f6, \u5bf9\u6b64\u6587\u4ef6\u7684\u6240\u6709\u4fee\u6539\u90fd\u5c06\u4e22\u5931\u3002\n\u751f\u6210\u65f6\u95f4: {0} \n
-Driver.Version = xjc 2.2.12-b141016.1821
+Driver.Version = xjc 2.2.12-b150126.1924
-Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b141016.1821"
+Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924"
-Driver.BuildID = 2.2.12-b141016.1821
+Driver.BuildID = 2.2.12-b150126.1924
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/MessageBundle_zh_TW.properties Wed Feb 18 19:27:49 2015 -0800
@@ -96,14 +96,14 @@
Driver.FailedToGenerateCode = \u7121\u6cd5\u7522\u751f\u7a0b\u5f0f\u78bc.
-# DO NOT localize the 2.2.12-b141016.1821 string - it is a token for an mvn <properties filter>
-Driver.FilePrologComment = \u6b64\u6a94\u6848\u662f\u7531 JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b141016.1821 \u6240\u7522\u751f \n\u8acb\u53c3\u95b1 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u4e00\u65e6\u91cd\u65b0\u7de8\u8b6f\u4f86\u6e90\u7db1\u8981, \u5c0d\u6b64\u6a94\u6848\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u5c07\u6703\u907a\u5931. \n\u7522\u751f\u6642\u9593: {0} \n
+# DO NOT localize the 2.2.12-b150126.1924 string - it is a token for an mvn <properties filter>
+Driver.FilePrologComment = \u6b64\u6a94\u6848\u662f\u7531 JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.12-b150126.1924 \u6240\u7522\u751f \n\u8acb\u53c3\u95b1 <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a> \n\u4e00\u65e6\u91cd\u65b0\u7de8\u8b6f\u4f86\u6e90\u7db1\u8981, \u5c0d\u6b64\u6a94\u6848\u6240\u505a\u7684\u4efb\u4f55\u4fee\u6539\u90fd\u5c07\u6703\u907a\u5931. \n\u7522\u751f\u6642\u9593: {0} \n
-Driver.Version = xjc 2.2.12-b141016.1821
+Driver.Version = xjc 2.2.12-b150126.1924
-Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b141016.1821"
+Driver.FullVersion = xjc \u5B8C\u6574\u7248\u672C "2.2.12-b150126.1924"
-Driver.BuildID = 2.2.12-b141016.1821
+Driver.BuildID = 2.2.12-b150126.1924
# for JDK integration - include version in source zip
jaxb.jdk.version=@@JAXB_JDK_VERSION@@
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/Options.java Wed Feb 18 19:27:49 2015 -0800
@@ -32,18 +32,18 @@
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StringWriter;
-import java.lang.reflect.Array;
-import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.List;
+import java.util.ServiceLoader;
import java.util.Set;
import com.sun.codemodel.internal.CodeWriter;
@@ -354,9 +354,7 @@
*/
public List<Plugin> getAllPlugins() {
if(allPlugins==null) {
- allPlugins = new ArrayList<Plugin>();
- ClassLoader ucl = getUserClassLoader(SecureLoader.getClassClassLoader(getClass()));
- allPlugins.addAll(Arrays.asList(findServices(Plugin.class,ucl)));
+ allPlugins = findServices(Plugin.class);
}
return allPlugins;
@@ -924,118 +922,44 @@
/**
* If a plugin failed to load, report.
*/
- private static String pluginLoadFailure;
+ private String pluginLoadFailure;
/**
* Looks for all "META-INF/services/[className]" files and
* create one instance for each class name found inside this file.
*/
- private static <T> T[] findServices( Class<T> clazz, ClassLoader classLoader ) {
- // if true, print debug output
- final boolean debug = com.sun.tools.internal.xjc.util.Util.getSystemProperty(Options.class,"findServices")!=null;
-
- // if we are running on Mustang or Dolphin, use ServiceLoader
- // so that we can take advantage of JSR-277 module system.
- try {
- Class<?> serviceLoader = Class.forName("java.util.ServiceLoader");
- if(debug)
- System.out.println("Using java.util.ServiceLoader");
- Iterable<T> itr = (Iterable<T>)serviceLoader.getMethod("load",Class.class,ClassLoader.class).invoke(null,clazz,classLoader);
- List<T> r = new ArrayList<T>();
- for (T t : itr)
- r.add(t);
- return r.toArray((T[])Array.newInstance(clazz,r.size()));
- } catch (ClassNotFoundException e) {
- // fall through
- } catch (IllegalAccessException e) {
- Error x = new IllegalAccessError();
- x.initCause(e);
- throw x;
- } catch (InvocationTargetException e) {
- Throwable x = e.getTargetException();
- if (x instanceof RuntimeException)
- throw (RuntimeException) x;
- if (x instanceof Error)
- throw (Error) x;
- throw new Error(x);
- } catch (NoSuchMethodException e) {
- Error x = new NoSuchMethodError();
- x.initCause(e);
- throw x;
- }
-
- String serviceId = "META-INF/services/" + clazz.getName();
-
- // used to avoid creating the same instance twice
- Set<String> classNames = new HashSet<String>();
-
- if(debug) {
- System.out.println("Looking for "+serviceId+" for add-ons");
- }
-
- // try to find services in CLASSPATH
+ private <T> List<T> findServices( Class<T> clazz) {
+ final List<T> result = new ArrayList<T>();
+ final boolean debug = getDebugPropertyValue();
try {
- Enumeration<URL> e = classLoader.getResources(serviceId);
- if(e==null) return (T[])Array.newInstance(clazz,0);
-
- ArrayList<T> a = new ArrayList<T>();
- while(e.hasMoreElements()) {
- URL url = e.nextElement();
- BufferedReader reader=null;
-
- if(debug) {
- System.out.println("Checking "+url+" for an add-on");
- }
-
- try {
- reader = new BufferedReader(new InputStreamReader(url.openStream()));
- String impl;
- while((impl = reader.readLine())!=null ) {
- // try to instanciate the object
- impl = impl.trim();
- if(classNames.add(impl)) {
- Class implClass = classLoader.loadClass(impl);
- if(!clazz.isAssignableFrom(implClass)) {
- pluginLoadFailure = impl+" is not a subclass of "+clazz+". Skipping";
- if(debug)
- System.out.println(pluginLoadFailure);
- continue;
- }
- if(debug) {
- System.out.println("Attempting to instanciate "+impl);
- }
- a.add(clazz.cast(implClass.newInstance()));
- }
- }
- reader.close();
- } catch( Exception ex ) {
- // let it go.
- StringWriter w = new StringWriter();
- ex.printStackTrace(new PrintWriter(w));
- pluginLoadFailure = w.toString();
- if(debug) {
- System.out.println(pluginLoadFailure);
- }
- if( reader!=null ) {
- try {
- reader.close();
- } catch( IOException ex2 ) {
- // ignore
- }
- }
- }
- }
-
- return a.toArray((T[])Array.newInstance(clazz,a.size()));
+ // TCCL allows user plugins to be loaded even if xjc is in jdk
+ // We have to use our SecureLoader to obtain it because we are trying to avoid SecurityException
+ final ClassLoader tccl = SecureLoader.getContextClassLoader();
+ final ServiceLoader<T> sl = ServiceLoader.load(clazz, tccl);
+ for (T t : sl)
+ result.add(t);
} catch( Throwable e ) {
// ignore any error
StringWriter w = new StringWriter();
e.printStackTrace(new PrintWriter(w));
pluginLoadFailure = w.toString();
- if(debug) {
+ if(debug)
System.out.println(pluginLoadFailure);
- }
- return (T[])Array.newInstance(clazz,0);
+ }
+ return result;
+ }
+
+ private static boolean getDebugPropertyValue() {
+ final String debugPropertyName = Options.class.getName() + ".findServices";
+ if (System.getSecurityManager() != null) {
+ return AccessController.doPrivileged(new PrivilegedAction<Boolean>() {
+ @Override
+ public Boolean run() {
+ return Boolean.getBoolean(debugPropertyName);
+ }
+ });
+ } else {
+ return Boolean.getBoolean(debugPropertyName);
}
}
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/api/impl/s2j/ElementCollectionAdapter.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/api/impl/s2j/ElementCollectionAdapter.java Wed Feb 18 19:27:49 2015 -0800
@@ -40,7 +40,7 @@
import com.sun.codemodel.internal.JType;
import com.sun.codemodel.internal.JVar;
import com.sun.tools.internal.xjc.model.CElementInfo;
-import static com.sun.tools.internal.xjc.model.Aspect.EXPOSED;
+import static com.sun.tools.internal.xjc.outline.Aspect.EXPOSED;
import com.sun.tools.internal.xjc.outline.FieldAccessor;
import com.sun.tools.internal.xjc.outline.FieldOutline;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/api/impl/s2j/ElementSingleAdapter.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/api/impl/s2j/ElementSingleAdapter.java Wed Feb 18 19:27:49 2015 -0800
@@ -33,7 +33,7 @@
import com.sun.codemodel.internal.JConditional;
import com.sun.codemodel.internal.JExpr;
import com.sun.codemodel.internal.JExpression;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.FieldOutline;
import com.sun.tools.internal.xjc.outline.FieldAccessor;
import com.sun.tools.internal.xjc.model.CElementInfo;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/api/impl/s2j/TypeAndAnnotationImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/api/impl/s2j/TypeAndAnnotationImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -36,7 +36,7 @@
import com.sun.tools.internal.xjc.model.CAdapter;
import com.sun.tools.internal.xjc.model.TypeUse;
import com.sun.tools.internal.xjc.model.nav.NType;
-import static com.sun.tools.internal.xjc.model.Aspect.EXPOSED;
+import static com.sun.tools.internal.xjc.outline.Aspect.EXPOSED;
import com.sun.tools.internal.xjc.outline.Outline;
import com.sun.xml.internal.bind.v2.runtime.SwaRefAdapterMarker;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/BeanGenerator.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/BeanGenerator.java Wed Feb 18 19:27:49 2015 -0800
@@ -25,7 +25,7 @@
package com.sun.tools.internal.xjc.generator.bean;
-import static com.sun.tools.internal.xjc.model.Aspect.EXPOSED;
+import static com.sun.tools.internal.xjc.outline.Aspect.EXPOSED;
import java.io.Serializable;
import java.net.URL;
@@ -90,7 +90,7 @@
import com.sun.tools.internal.xjc.model.CTypeRef;
import com.sun.tools.internal.xjc.model.Model;
import com.sun.tools.internal.xjc.model.CClassRef;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.ClassOutline;
import com.sun.tools.internal.xjc.outline.EnumConstantOutline;
import com.sun.tools.internal.xjc.outline.EnumOutline;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/ElementOutlineImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/ElementOutlineImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -39,7 +39,7 @@
import com.sun.codemodel.internal.JMod;
import com.sun.codemodel.internal.JType;
import com.sun.tools.internal.xjc.model.CElementInfo;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.ElementOutline;
/**
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/ImplStructureStrategy.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/ImplStructureStrategy.java Wed Feb 18 19:27:49 2015 -0800
@@ -42,7 +42,7 @@
import com.sun.codemodel.internal.JVar;
import com.sun.tools.internal.xjc.generator.annotation.spec.XmlAccessorTypeWriter;
import com.sun.tools.internal.xjc.model.CClassInfo;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
/**
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/ObjectFactoryGeneratorImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/ObjectFactoryGeneratorImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -51,7 +51,7 @@
import com.sun.tools.internal.xjc.model.CPropertyInfo;
import com.sun.tools.internal.xjc.model.Constructor;
import com.sun.tools.internal.xjc.model.Model;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.FieldAccessor;
import com.sun.tools.internal.xjc.outline.FieldOutline;
import com.sun.xml.internal.bind.v2.TODO;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/PackageOutlineImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/PackageOutlineImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -49,7 +49,7 @@
import com.sun.tools.internal.xjc.model.CValuePropertyInfo;
import com.sun.tools.internal.xjc.model.Model;
import com.sun.tools.internal.xjc.outline.PackageOutline;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
/**
* {@link PackageOutline} enhanced with schema2java specific
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/PrivateObjectFactoryGenerator.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/PrivateObjectFactoryGenerator.java Wed Feb 18 19:27:49 2015 -0800
@@ -32,7 +32,7 @@
import com.sun.codemodel.internal.fmt.JPropertyFile;
import com.sun.tools.internal.xjc.model.CElementInfo;
import com.sun.tools.internal.xjc.model.Model;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.runtime.JAXBContextFactory;
/**
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/PublicObjectFactoryGenerator.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/PublicObjectFactoryGenerator.java Wed Feb 18 19:27:49 2015 -0800
@@ -28,7 +28,7 @@
import com.sun.codemodel.internal.JPackage;
import com.sun.tools.internal.xjc.model.CElementInfo;
import com.sun.tools.internal.xjc.model.Model;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
/**
* Generates public ObjectFactory.
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/field/AbstractField.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/field/AbstractField.java Wed Feb 18 19:27:49 2015 -0800
@@ -63,8 +63,8 @@
import com.sun.tools.internal.xjc.model.CTypeRef;
import com.sun.tools.internal.xjc.model.CValuePropertyInfo;
import com.sun.tools.internal.xjc.model.nav.NClass;
-import com.sun.tools.internal.xjc.model.Aspect;
-import static com.sun.tools.internal.xjc.model.Aspect.IMPLEMENTATION;
+import com.sun.tools.internal.xjc.outline.Aspect;
+import static com.sun.tools.internal.xjc.outline.Aspect.IMPLEMENTATION;
import com.sun.tools.internal.xjc.outline.ClassOutline;
import com.sun.tools.internal.xjc.outline.FieldAccessor;
import com.sun.tools.internal.xjc.outline.FieldOutline;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/field/ContentListField.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/field/ContentListField.java Wed Feb 18 19:27:49 2015 -0800
@@ -38,7 +38,7 @@
import com.sun.tools.internal.xjc.generator.bean.ClassOutlineImpl;
import com.sun.tools.internal.xjc.generator.bean.MethodWriter;
import com.sun.tools.internal.xjc.model.CPropertyInfo;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.xml.internal.bind.api.impl.NameConverter;
import java.io.Serializable;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/field/NoExtendedContentField.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/field/NoExtendedContentField.java Wed Feb 18 19:27:49 2015 -0800
@@ -40,7 +40,7 @@
import com.sun.tools.internal.xjc.model.CElement;
import com.sun.tools.internal.xjc.model.CPropertyInfo;
import com.sun.tools.internal.xjc.model.CReferencePropertyInfo;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.xml.internal.bind.api.impl.NameConverter;
import java.io.Serializable;
import java.util.Set;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/field/UnboxedField.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/generator/bean/field/UnboxedField.java Wed Feb 18 19:27:49 2015 -0800
@@ -35,7 +35,7 @@
import com.sun.tools.internal.xjc.generator.bean.ClassOutlineImpl;
import com.sun.tools.internal.xjc.generator.bean.MethodWriter;
import com.sun.tools.internal.xjc.model.CPropertyInfo;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.FieldAccessor;
import com.sun.xml.internal.bind.api.impl.NameConverter;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/Aspect.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.tools.internal.xjc.model;
-
-import com.sun.tools.internal.xjc.generator.bean.ImplStructureStrategy;
-
-/**
- * Sometimes a single JAXB-generated bean spans across multiple Java classes/interfaces.
- * We call them "aspects of a bean".
- *
- * <p>
- * This is an enumeration of all possible aspects.
- *
- * @author Kohsuke Kawaguchi
- */
-public enum Aspect {
- /**
- * The exposed part of the bean.
- * <p>
- * This corresponds to the content interface when we are geneting one.
- * This would be the same as the {@link #IMPLEMENTATION} when we are
- * just generating beans.
- *
- * <p>
- * This could be an interface, or it could be a class.
- *
- * We don't have any other {@link ImplStructureStrategy} at this point,
- * but generally you can't assume anything about where this could be
- * or whether that's equal to {@link #IMPLEMENTATION}.
- */
- EXPOSED,
- /**
- * The part of the bean that holds all the implementations.
- *
- * <p>
- * This is always a class, never an interface.
- */
- IMPLEMENTATION
-}
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CAdapter.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CAdapter.java Wed Feb 18 19:27:49 2015 -0800
@@ -34,6 +34,7 @@
import com.sun.tools.internal.xjc.model.nav.NClass;
import com.sun.tools.internal.xjc.model.nav.NType;
import com.sun.tools.internal.xjc.model.nav.NavigatorImpl;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
import com.sun.xml.internal.bind.v2.model.core.Adapter;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CArrayInfo.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CArrayInfo.java Wed Feb 18 19:27:49 2015 -0800
@@ -28,6 +28,7 @@
import javax.xml.namespace.QName;
import com.sun.codemodel.internal.JType;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.xml.internal.bind.v2.model.util.ArrayInfoUtil;
import com.sun.tools.internal.xjc.model.nav.NClass;
import com.sun.tools.internal.xjc.model.nav.NType;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CBuiltinLeafInfo.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CBuiltinLeafInfo.java Wed Feb 18 19:27:49 2015 -0800
@@ -49,6 +49,7 @@
import com.sun.codemodel.internal.JExpression;
import com.sun.codemodel.internal.JType;
import com.sun.tools.internal.xjc.model.nav.NClass;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.xml.internal.bind.v2.model.annotation.Locatable;
import com.sun.xml.internal.bind.v2.model.core.BuiltinLeafInfo;
import com.sun.xml.internal.bind.v2.model.core.Element;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CClassInfo.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CClassInfo.java Wed Feb 18 19:27:49 2015 -0800
@@ -45,6 +45,7 @@
import com.sun.tools.internal.xjc.Language;
import com.sun.tools.internal.xjc.model.nav.NClass;
import com.sun.tools.internal.xjc.model.nav.NType;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
import com.sun.tools.internal.xjc.reader.Ring;
import com.sun.tools.internal.xjc.reader.xmlschema.BGMBuilder;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CClassRef.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CClassRef.java Wed Feb 18 19:27:49 2015 -0800
@@ -30,6 +30,7 @@
import com.sun.codemodel.internal.JClass;
import com.sun.tools.internal.xjc.model.nav.NClass;
import com.sun.tools.internal.xjc.model.nav.NType;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIClass;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIEnum;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CElementInfo.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CElementInfo.java Wed Feb 18 19:27:49 2015 -0800
@@ -43,6 +43,7 @@
import com.sun.tools.internal.xjc.model.nav.NClass;
import com.sun.tools.internal.xjc.model.nav.NType;
import com.sun.tools.internal.xjc.model.nav.NavigatorImpl;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIInlineBinaryData;
import com.sun.tools.internal.xjc.reader.xmlschema.bindinfo.BIFactoryMethod;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CEnumLeafInfo.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CEnumLeafInfo.java Wed Feb 18 19:27:49 2015 -0800
@@ -34,6 +34,7 @@
import com.sun.codemodel.internal.JExpression;
import com.sun.tools.internal.xjc.model.nav.NClass;
import com.sun.tools.internal.xjc.model.nav.NType;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
import com.sun.xml.internal.bind.v2.model.annotation.Locatable;
import com.sun.xml.internal.bind.v2.model.core.EnumLeafInfo;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CReferencePropertyInfo.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CReferencePropertyInfo.java Wed Feb 18 19:27:49 2015 -0800
@@ -26,7 +26,7 @@
package com.sun.tools.internal.xjc.model;
import java.util.Collection;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Set;
import java.util.Map;
@@ -60,7 +60,7 @@
/**
* List of referenced elements.
*/
- private final Set<CElement> elements = new HashSet<CElement>();
+ private final Set<CElement> elements = new LinkedHashSet<CElement>();
private final boolean isMixed;
private WildcardMode wildcard;
@@ -87,7 +87,7 @@
// so the Java types of the substitution members need to be taken into account
// when computing the signature
- final class RefList extends HashSet<CTypeInfo> {
+ final class RefList extends LinkedHashSet<CTypeInfo> {
RefList() {
super(elements.size());
addAll(elements);
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CTypeInfo.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CTypeInfo.java Wed Feb 18 19:27:49 2015 -0800
@@ -29,6 +29,7 @@
import com.sun.codemodel.internal.JType;
import com.sun.tools.internal.xjc.model.nav.NClass;
import com.sun.tools.internal.xjc.model.nav.NType;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
import com.sun.xml.internal.bind.v2.model.core.TypeInfo;
@@ -44,7 +45,7 @@
* Returns the {@link JClass} that represents the class being bound,
* under the given {@link Outline}.
*
- * @see NType#toType(Outline, Aspect)
+ * @see NType#toType(Outline, com.sun.tools.internal.xjc.outline.Aspect)
*/
JType toType(Outline o, Aspect aspect);
}
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CWildcardTypeInfo.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/CWildcardTypeInfo.java Wed Feb 18 19:27:49 2015 -0800
@@ -29,6 +29,7 @@
import com.sun.tools.internal.xjc.model.nav.NClass;
import com.sun.tools.internal.xjc.model.nav.NType;
import com.sun.tools.internal.xjc.model.nav.NavigatorImpl;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
import com.sun.xml.internal.bind.v2.model.core.WildcardTypeInfo;
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/EagerNClass.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/EagerNClass.java Wed Feb 18 19:27:49 2015 -0800
@@ -30,7 +30,7 @@
import java.util.Set;
import com.sun.codemodel.internal.JClass;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
/**
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/EagerNType.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/EagerNType.java Wed Feb 18 19:27:49 2015 -0800
@@ -28,7 +28,7 @@
import java.lang.reflect.Type;
import com.sun.codemodel.internal.JType;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
/**
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/NClass.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/NClass.java Wed Feb 18 19:27:49 2015 -0800
@@ -26,7 +26,7 @@
package com.sun.tools.internal.xjc.model.nav;
import com.sun.codemodel.internal.JClass;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
/**
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/NClassByJClass.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/NClassByJClass.java Wed Feb 18 19:27:49 2015 -0800
@@ -26,7 +26,7 @@
package com.sun.tools.internal.xjc.model.nav;
import com.sun.codemodel.internal.JClass;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
/**
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/NParameterizedType.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/NParameterizedType.java Wed Feb 18 19:27:49 2015 -0800
@@ -26,7 +26,7 @@
package com.sun.tools.internal.xjc.model.nav;
import com.sun.codemodel.internal.JClass;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
/**
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/NType.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/model/nav/NType.java Wed Feb 18 19:27:49 2015 -0800
@@ -26,7 +26,7 @@
package com.sun.tools.internal.xjc.model.nav;
import com.sun.codemodel.internal.JType;
-import com.sun.tools.internal.xjc.model.Aspect;
+import com.sun.tools.internal.xjc.outline.Aspect;
import com.sun.tools.internal.xjc.outline.Outline;
/**
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/Aspect.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.tools.internal.xjc.outline;
+
+import com.sun.tools.internal.xjc.generator.bean.ImplStructureStrategy;
+
+/**
+ * Sometimes a single JAXB-generated bean spans across multiple Java classes/interfaces.
+ * We call them "aspects of a bean".
+ *
+ * <p>
+ * This is an enumeration of all possible aspects.
+ *
+ * @author Kohsuke Kawaguchi
+ *
+ * TODO: move this to the model package. We cannot do this before JAXB3 because of old plugins
+ */
+public enum Aspect {
+ /**
+ * The exposed part of the bean.
+ * <p>
+ * This corresponds to the content interface when we are geneting one.
+ * This would be the same as the {@link #IMPLEMENTATION} when we are
+ * just generating beans.
+ *
+ * <p>
+ * This could be an interface, or it could be a class.
+ *
+ * We don't have any other {@link ImplStructureStrategy} at this point,
+ * but generally you can't assume anything about where this could be
+ * or whether that's equal to {@link #IMPLEMENTATION}.
+ */
+ EXPOSED,
+ /**
+ * The part of the bean that holds all the implementations.
+ *
+ * <p>
+ * This is always a class, never an interface.
+ */
+ IMPLEMENTATION
+}
--- a/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/Outline.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.bind/share/classes/com/sun/tools/internal/xjc/outline/Outline.java Wed Feb 18 19:27:49 2015 -0800
@@ -33,7 +33,6 @@
import com.sun.codemodel.internal.JPackage;
import com.sun.codemodel.internal.JType;
import com.sun.tools.internal.xjc.ErrorReceiver;
-import com.sun.tools.internal.xjc.model.Aspect;
import com.sun.tools.internal.xjc.model.CClassInfo;
import com.sun.tools.internal.xjc.model.CClassInfoParent;
import com.sun.tools.internal.xjc.model.CElementInfo;
--- a/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/jaxws/src/jdk.xml.ws/share/classes/com/sun/tools/internal/ws/version.properties Wed Feb 18 19:27:49 2015 -0800
@@ -23,7 +23,7 @@
# questions.
#
-build-id=2.2.11-b141124.1933
-build-version=JAX-WS RI 2.2.11-b141124.1933
+build-id=2.2.11-b150127.1410
+build-version=JAX-WS RI 2.2.11-b150127.1410
major-version=2.2.11
-svn-revision=312b19a2e0e312b55e1ea6f531bd595955cd581f
+svn-revision=28121d09ed8ac02b76788709ccb4cdb66e03bbfa
--- a/jdk/.hgtags Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/.hgtags Wed Feb 18 19:27:49 2015 -0800
@@ -291,3 +291,5 @@
efedac7f44ed41cea2b1038138047271f55aacba jdk9-b46
b641c14730ac05d9ec8b4f66e6fca3dc21adb403 jdk9-b47
ebb2eb7f1aec78eb6d8cc4c96f018afa11093cde jdk9-b48
+541a8cef4e0d54c3e4b52a98c6af3c31e2096669 jdk9-b49
+f6b8edd397ee463be208fee27517c99101293267 jdk9-b50
--- a/jdk/make/Tools.gmk Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/Tools.gmk Wed Feb 18 19:27:49 2015 -0800
@@ -147,6 +147,15 @@
EXCLUDES := jdk/internal/jimage/concurrent, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes))
+# Because of the explicit INCLUDES in the compilation setup above, the service provider
+# file will not be copied unless META-INF/services would also be added to the INCLUDES.
+# Adding META-INF/services would include all files in that directory when only the one
+# is needed, which is why this explicit copy is defined instead.
+$(eval $(call SetupCopyFiles,COPY_JIMAGE_SERVICE_PROVIDER, \
+ SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \
+ DEST := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes, \
+ FILES := META-INF/services/java.nio.file.spi.FileSystemProvider))
+
##########################################################################################
# Tools needed on solaris because OBJCOPY is broken.
@@ -173,7 +182,7 @@
PROGRAM := fix_empty_sec_hdr_flags))
endif
-$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE)
+$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE) $(COPY_JIMAGE_SERVICE_PROVIDER)
java-tools: $(BUILD_TOOLS_JDK)
--- a/jdk/make/data/tzdata/VERSION Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/data/tzdata/VERSION Wed Feb 18 19:27:49 2015 -0800
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2014j
+tzdata2015a
--- a/jdk/make/data/tzdata/antarctica Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/data/tzdata/antarctica Wed Feb 18 19:27:49 2015 -0800
@@ -70,8 +70,8 @@
Rule ChileAQ 2010 only - Apr Sun>=1 3:00u 0 -
Rule ChileAQ 2011 only - May Sun>=2 3:00u 0 -
Rule ChileAQ 2011 only - Aug Sun>=16 4:00u 1:00 S
-Rule ChileAQ 2012 max - Apr Sun>=23 3:00u 0 -
-Rule ChileAQ 2012 max - Sep Sun>=2 4:00u 1:00 S
+Rule ChileAQ 2012 2015 - Apr Sun>=23 3:00u 0 -
+Rule ChileAQ 2012 2014 - Sep Sun>=2 4:00u 1:00 S
# Argentina - year-round bases
# Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05
@@ -377,9 +377,10 @@
#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Antarctica/Palmer 0 - zzz 1965
- -4:00 ArgAQ AR%sT 1969 Oct 5
+ -4:00 ArgAQ AR%sT 1969 Oct 5
-3:00 ArgAQ AR%sT 1982 May
- -4:00 ChileAQ CL%sT
+ -4:00 ChileAQ CL%sT 2015 Apr 26 3:00u
+ -3:00 - CLT
#
#
# McMurdo Station, Ross Island, since 1955-12
--- a/jdk/make/data/tzdata/asia Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/data/tzdata/asia Wed Feb 18 19:27:49 2015 -0800
@@ -168,10 +168,7 @@
4:00 Azer AZ%sT
# Bahrain
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Bahrain 3:22:20 - LMT 1920 # Manamah
- 4:00 - GST 1972 Jun
- 3:00 - AST
+# See Asia/Qatar.
# Bangladesh
# From Alexander Krivenyshev (2009-05-13):
@@ -1754,9 +1751,7 @@
###############################################################################
# Kuwait
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Kuwait 3:11:56 - LMT 1950
- 3:00 - AST
+# See Asia/Riyadh.
# Laos
# See Asia/Bangkok.
@@ -1977,12 +1972,7 @@
5:45 - NPT # Nepal Time
# Oman
-
-# Milne says 3:54:24 was the meridian of the Muscat Tidal Observatory.
-
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Muscat 3:54:24 - LMT 1920
- 4:00 - GST
+# See Asia/Dubai.
# Pakistan
@@ -2476,6 +2466,7 @@
Zone Asia/Qatar 3:26:08 - LMT 1920 # Al Dawhah / Doha
4:00 - GST 1972 Jun
3:00 - AST
+Link Asia/Qatar Asia/Bahrain
# Saudi Arabia
#
@@ -2502,6 +2493,8 @@
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Riyadh 3:06:52 - LMT 1947 Mar 14
3:00 - AST
+Link Asia/Riyadh Asia/Aden # Yemen
+Link Asia/Riyadh Asia/Kuwait
# Singapore
# taken from Mok Ly Yng (2003-10-30)
@@ -2790,6 +2783,7 @@
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Dubai 3:41:12 - LMT 1920
4:00 - GST
+Link Asia/Dubai Asia/Muscat # Oman
# Uzbekistan
# Byalokoz 1919 says Uzbekistan was 4:27:53.
@@ -2874,10 +2868,4 @@
7:00 - ICT
# Yemen
-
-# Milne says 2:59:54 was the meridian of the saluting battery at Aden,
-# and that Yemen was at 1:55:56, the meridian of the Hagia Sophia.
-
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Aden 2:59:54 - LMT 1950
- 3:00 - AST
+# See Asia/Riyadh.
--- a/jdk/make/data/tzdata/backward Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/data/tzdata/backward Wed Feb 18 19:27:49 2015 -0800
@@ -28,7 +28,7 @@
# and their old names. Many names changed in late 1993.
# Link TARGET LINK-NAME
-Link Africa/Asmara Africa/Asmera
+Link Africa/Nairobi Africa/Asmera
Link Africa/Abidjan Africa/Timbuktu
Link America/Argentina/Catamarca America/Argentina/ComodRivadavia
Link America/Adak America/Atka
--- a/jdk/make/data/tzdata/europe Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/data/tzdata/europe Wed Feb 18 19:27:49 2015 -0800
@@ -1430,35 +1430,32 @@
# might be a reference to the Julian calendar as opposed to Gregorian, or it
# might mean something else (???).
#
-# From Paul Eggert (2006-03-22):
-# The Iceland Almanak, Shanks & Pottenger, and Whitman disagree on many points.
-# We go with the Almanak, except for one claim from Shanks & Pottenger, namely
-# that Reykavik was 21W57 from 1837 to 1908, local mean time before that.
+# From Paul Eggert (2014-11-22):
+# The information below is taken from the 1988 Almanak; see
+# http://www.almanak.hi.is/klukkan.html
#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
-Rule Iceland 1917 1918 - Feb 19 23:00 1:00 S
+Rule Iceland 1917 1919 - Feb 19 23:00 1:00 S
Rule Iceland 1917 only - Oct 21 1:00 0 -
-Rule Iceland 1918 only - Nov 16 1:00 0 -
+Rule Iceland 1918 1919 - Nov 16 1:00 0 -
+Rule Iceland 1921 only - Mar 19 23:00 1:00 S
+Rule Iceland 1921 only - Jun 23 1:00 0 -
Rule Iceland 1939 only - Apr 29 23:00 1:00 S
-Rule Iceland 1939 only - Nov 29 2:00 0 -
+Rule Iceland 1939 only - Oct 29 2:00 0 -
Rule Iceland 1940 only - Feb 25 2:00 1:00 S
-Rule Iceland 1940 only - Nov 3 2:00 0 -
-Rule Iceland 1941 only - Mar 2 1:00s 1:00 S
-Rule Iceland 1941 only - Nov 2 1:00s 0 -
-Rule Iceland 1942 only - Mar 8 1:00s 1:00 S
-Rule Iceland 1942 only - Oct 25 1:00s 0 -
+Rule Iceland 1940 1941 - Nov Sun>=2 1:00s 0 -
+Rule Iceland 1941 1942 - Mar Sun>=2 1:00s 1:00 S
# 1943-1946 - first Sunday in March until first Sunday in winter
Rule Iceland 1943 1946 - Mar Sun>=1 1:00s 1:00 S
-Rule Iceland 1943 1948 - Oct Sun>=22 1:00s 0 -
+Rule Iceland 1942 1948 - Oct Sun>=22 1:00s 0 -
# 1947-1967 - first Sunday in April until first Sunday in winter
Rule Iceland 1947 1967 - Apr Sun>=1 1:00s 1:00 S
-# 1949 Oct transition delayed by 1 week
+# 1949 and 1967 Oct transitions delayed by 1 week
Rule Iceland 1949 only - Oct 30 1:00s 0 -
Rule Iceland 1950 1966 - Oct Sun>=22 1:00s 0 -
Rule Iceland 1967 only - Oct 29 1:00s 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Atlantic/Reykjavik -1:27:24 - LMT 1837
- -1:27:48 - RMT 1908 # Reykjavik Mean Time?
+Zone Atlantic/Reykjavik -1:28 - LMT 1908
-1:00 Iceland IS%sT 1968 Apr 7 1:00s
0:00 - GMT
--- a/jdk/make/data/tzdata/leapseconds Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/data/tzdata/leapseconds Wed Feb 18 19:27:49 2015 -0800
@@ -77,3 +77,7 @@
Leap 2005 Dec 31 23:59:60 + S
Leap 2008 Dec 31 23:59:60 + S
Leap 2012 Jun 30 23:59:60 + S
+Leap 2015 Jun 30 23:59:60 + S
+
+# Updated through IERS Bulletin C49
+# File expires on: 28 December 2015
--- a/jdk/make/data/tzdata/northamerica Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/data/tzdata/northamerica Wed Feb 18 19:27:49 2015 -0800
@@ -147,7 +147,7 @@
Rule US 1918 1919 - Oct lastSun 2:00 0 S
Rule US 1942 only - Feb 9 2:00 1:00 W # War
Rule US 1945 only - Aug 14 23:00u 1:00 P # Peace
-Rule US 1945 only - Sep 30 2:00 0 S
+Rule US 1945 only - Sep lastSun 2:00 0 S
Rule US 1967 2006 - Oct lastSun 2:00 0 S
Rule US 1967 1973 - Apr lastSun 2:00 1:00 D
Rule US 1974 only - Jan 6 2:00 1:00 D
@@ -2147,11 +2147,11 @@
# Mexico
-# From Paul Eggert (2001-03-05):
+# From Paul Eggert (2014-12-07):
# The Investigation and Analysis Service of the
# Mexican Library of Congress (MLoC) has published a
# history of Mexican local time (in Spanish)
-# http://www.cddhcu.gob.mx/bibliot/publica/inveyana/polisoc/horver/
+# http://www.diputados.gob.mx/bibliot/publica/inveyana/polisoc/horver/index.htm
#
# Here are the discrepancies between Shanks & Pottenger (S&P) and the MLoC.
# (In all cases we go with the MLoC.)
@@ -2320,6 +2320,24 @@
# efecto desde las dos horas del segundo domingo de marzo y concluirá a
# las dos horas del primer domingo de noviembre.
+# From Steffen Thorsen (2014-12-08), translated by Gwillim Law:
+# The Mexican state of Quintana Roo will likely change to EST in 2015.
+#
+# http://www.unioncancun.mx/articulo/2014/12/04/medio-ambiente/congreso-aprueba-una-hora-mas-de-sol-en-qroo
+# "With this change, the time conflict that has existed between the municipios
+# of Quintana Roo and the municipio of Felipe Carrillo Puerto may come to an
+# end. The latter declared itself in rebellion 15 years ago when a time change
+# was initiated in Mexico, and since then it has refused to change its time
+# zone along with the rest of the country."
+#
+# From Steffen Thorsen (2015-01-14), translated by Gwillim Law:
+# http://sipse.com/novedades/confirman-aplicacion-de-nueva-zona-horaria-para-quintana-roo-132331.html
+# "...the new time zone will come into effect at two o'clock on the first Sunday
+# of February, when we will have to advance the clock one hour from its current
+# time..."
+#
+# Also, the new zone will not use DST.
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Mexico 1939 only - Feb 5 0:00 1:00 D
Rule Mexico 1939 only - Jun 25 0:00 0 S
@@ -2340,7 +2358,8 @@
Zone America/Cancun -5:47:04 - LMT 1922 Jan 1 0:12:56
-6:00 - CST 1981 Dec 23
-5:00 Mexico E%sT 1998 Aug 2 2:00
- -6:00 Mexico C%sT
+ -6:00 Mexico C%sT 2015 Feb 1 2:00
+ -5:00 - EST
# Campeche, Yucatán; represented by Mérida
Zone America/Merida -5:58:28 - LMT 1922 Jan 1 0:01:32
-6:00 - CST 1981 Dec 23
--- a/jdk/make/data/tzdata/southamerica Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/data/tzdata/southamerica Wed Feb 18 19:27:49 2015 -0800
@@ -1229,6 +1229,11 @@
# DST Start: first Saturday of September 2014 (Sun 07 Sep 2014 04:00 UTC)
# http://www.diariooficial.interior.gob.cl//media/2014/02/19/do-20140219.pdf
+# From Juan Correa (2015-01-28):
+# ... today the Ministry of Energy announced that Chile will drop DST, will keep
+# "summer time" (UTC -3 / UTC -5) all year round....
+# http://www.minenergia.cl/ministerio/noticias/generales/ministerio-de-energia-anuncia.html
+
# NOTE: ChileAQ rules for Antarctic bases are stored separately in the
# 'antarctica' file.
@@ -1270,8 +1275,8 @@
Rule Chile 2010 only - Apr Sun>=1 3:00u 0 -
Rule Chile 2011 only - May Sun>=2 3:00u 0 -
Rule Chile 2011 only - Aug Sun>=16 4:00u 1:00 S
-Rule Chile 2012 max - Apr Sun>=23 3:00u 0 -
-Rule Chile 2012 max - Sep Sun>=2 4:00u 1:00 S
+Rule Chile 2012 2015 - Apr Sun>=23 3:00u 0 -
+Rule Chile 2012 2014 - Sep Sun>=2 4:00u 1:00 S
# IATA SSIM anomalies: (1992-02) says 1992-03-14;
# (1996-09) says 1998-03-08. Ignore these.
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -1282,11 +1287,13 @@
-4:00 - CLT 1919 Jul 1 # Chile Time
-4:42:46 - SMT 1927 Sep 1 # Santiago Mean Time
-5:00 Chile CL%sT 1947 May 22 # Chile Time
- -4:00 Chile CL%sT
+ -4:00 Chile CL%sT 2015 Apr 26 3:00u
+ -3:00 - CLT
Zone Pacific/Easter -7:17:44 - LMT 1890
-7:17:28 - EMT 1932 Sep # Easter Mean Time
- -7:00 Chile EAS%sT 1982 Mar 13 21:00 # Easter Time
- -6:00 Chile EAS%sT
+ -7:00 Chile EAS%sT 1982 Mar 13 3:00u # Easter Time
+ -6:00 Chile EAS%sT 2015 Apr 26 3:00u
+ -5:00 - EAST
#
# Salas y Gómez Island is uninhabited.
# Other Chilean locations, including Juan Fernández Is, Desventuradas Is,
--- a/jdk/make/data/tzdata/zone.tab Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/data/tzdata/zone.tab Wed Feb 18 19:27:49 2015 -0800
@@ -297,7 +297,7 @@
MV +0410+07330 Indian/Maldives
MW -1547+03500 Africa/Blantyre
MX +1924-09909 America/Mexico_City Central Time - most locations
-MX +2105-08646 America/Cancun Central Time - Quintana Roo
+MX +2105-08646 America/Cancun Eastern Standard Time - Quintana Roo
MX +2058-08937 America/Merida Central Time - Campeche, Yucatan
MX +2540-10019 America/Monterrey Mexican Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas away from US border
MX +2550-09730 America/Matamoros US Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas near US border
--- a/jdk/make/launcher/Launcher-jdk.runtime.gmk Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/launcher/Launcher-jdk.runtime.gmk Wed Feb 18 19:27:49 2015 -0800
@@ -66,19 +66,6 @@
ifeq ($(OPENJDK_TARGET_OS), solaris)
UNPACKEXE_LANG := C++
endif
-UNPACKEXE_DEBUG_SYMBOLS := true
-# On windows, unpack200 is linked completely differently to all other
-# executables, using the compiler with the compiler arguments.
-# It's also linked incrementally, producing a .ilk file that needs to
-# be kept away.
-ifeq ($(OPENJDK_TARGET_OS), windows)
- BUILD_UNPACKEXE_LDEXE := $(CC)
- EXE_OUT_OPTION_save := $(EXE_OUT_OPTION)
- EXE_OUT_OPTION := -Fe
- # With the current way unpack200 is built, debug symbols aren't supported
- # anyway.
- UNPACKEXE_DEBUG_SYMBOLS := false
-endif
# The linker on older SuSE distros (e.g. on SLES 10) complains with:
# "Invalid version tag `SUNWprivate_1.1'. Only anonymous version tag is allowed in executable."
@@ -93,49 +80,36 @@
SRC := $(UNPACKEXE_SRC), \
LANG := $(UNPACKEXE_LANG), \
OPTIMIZATION := LOW, \
- CFLAGS := $(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE) \
- -DFULL, \
+ CFLAGS := $(UNPACKEXE_CFLAGS) $(CXXFLAGS_JDKEXE) -DFULL, \
CFLAGS_release := -DPRODUCT, \
CFLAGS_linux := -fPIC, \
CFLAGS_solaris := -KPIC, \
CFLAGS_macosx := -fPIC, \
MAPFILE := $(UNPACK_MAPFILE),\
- LDFLAGS := $(UNPACKEXE_ZIPOBJS), \
- LDFLAGS_windows := $(CXXFLAGS_JDKEXE), \
- LDFLAGS_unix := $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
+ LDFLAGS := $(UNPACKEXE_ZIPOBJS) \
+ $(LDFLAGS_JDKEXE) $(LDFLAGS_CXX_JDK) \
$(call SET_SHARED_LIBRARY_NAME,$(LIBRARY_PREFIX)unpack$(SHARED_LIBRARY_SUFFIX)) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
LDFLAGS_linux := -lc, \
LDFLAGS_solaris := $(UNPACKEXE_LDFLAGS_solaris) -lc, \
LDFLAGS_SUFFIX := $(LIBCXX), \
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpackexe$(OUTPUT_SUBDIR), \
- OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/unpackexe$(OUTPUT_SUBDIR), \
+ OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE), \
PROGRAM := unpack200, \
VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
RC_FLAGS := $(RC_FLAGS) \
-D "JDK_FNAME=unpack200.exe" \
-D "JDK_INTERNAL_NAME=unpack200" \
-D "JDK_FTYPE=0x1L", \
- DEBUG_SYMBOLS := $(UNPACKEXE_DEBUG_SYMBOLS), \
+ DEBUG_SYMBOLS := true, \
MANIFEST := $(JDK_TOPDIR)/src/jdk.runtime/windows/native/unpack200/unpack200_proto.exe.manifest))
-ifeq ($(OPENJDK_TARGET_OS), windows)
- EXE_OUT_OPTION := $(EXE_OUT_OPTION_save)
-endif
-
ifneq ($(USE_EXTERNAL_LIBZ), true)
$(BUILD_UNPACKEXE): $(UNPACKEXE_ZIPOBJS)
endif
-# Build into object dir and copy executable afterwards to avoid .ilk file in
-# image. The real fix would be clean up linking of unpack200 using
-# -link -incremental:no
-# like all other launchers.
-$(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)/unpack200$(EXE_SUFFIX): $(BUILD_UNPACKEXE)
- $(call install-file)
-
-TARGETS += $(SUPPORT_OUTPUTDIR)/modules_cmds/$(MODULE)/unpack200$(EXE_SUFFIX)
+TARGETS += $(BUILD_UNPACKEXE)
################################################################################
--- a/jdk/make/src/classes/build/tools/module/boot.modules Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/src/classes/build/tools/module/boot.modules Wed Feb 18 19:27:49 2015 -0800
@@ -1,7 +1,5 @@
java.base
java.desktop
-java.activation
-java.annotations.common
java.compiler
java.corba
java.instrument
@@ -11,7 +9,6 @@
java.prefs
java.rmi
java.scripting
-java.security.acl
java.security.jgss
java.security.sasl
java.smartcardio
@@ -19,9 +16,7 @@
java.sql.rowset
java.transaction
java.xml
-java.xml.bind
java.xml.crypto
-java.xml.ws
jdk.charsets
jdk.deploy
jdk.deploy.osx
--- a/jdk/make/src/classes/build/tools/module/ext.modules Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/make/src/classes/build/tools/module/ext.modules Wed Feb 18 19:27:49 2015 -0800
@@ -1,3 +1,7 @@
+java.activation
+java.annotations.common
+java.xml.bind
+java.xml.ws
jdk.crypto.ec
jdk.crypto.mscapi
jdk.crypto.pkcs11
--- a/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/macosx/native/libjli/java_md_macosx.c Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -1059,6 +1059,7 @@
void PostJVMInit(JNIEnv *env, jstring mainClass, JavaVM *vm) {
jvmInstance = vm;
SetMainClassForAWT(env, mainClass);
+ CHECK_EXCEPTION_RETURN();
ShowSplashScreen();
}
--- a/jdk/src/java.base/share/classes/com/sun/crypto/provider/GHASH.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/com/sun/crypto/provider/GHASH.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015 Red Hat, Inc.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -28,9 +29,7 @@
package com.sun.crypto.provider;
-import java.util.Arrays;
-import java.security.*;
-import static com.sun.crypto.provider.AESConstants.AES_BLOCK_SIZE;
+import java.security.ProviderException;
/**
* This class represents the GHASH function defined in NIST 800-38D
@@ -44,62 +43,90 @@
*/
final class GHASH {
- private static final byte P128 = (byte) 0xe1; //reduction polynomial
-
- private static boolean getBit(byte[] b, int pos) {
- int p = pos / 8;
- pos %= 8;
- int i = (b[p] >>> (7 - pos)) & 1;
- return i != 0;
+ private static long getLong(byte[] buffer, int offset) {
+ long result = 0;
+ int end = offset + 8;
+ for (int i = offset; i < end; ++i) {
+ result = (result << 8) + (buffer[i] & 0xFF);
+ }
+ return result;
}
- private static void shift(byte[] b) {
- byte temp, temp2;
- temp2 = 0;
- for (int i = 0; i < b.length; i++) {
- temp = (byte) ((b[i] & 0x01) << 7);
- b[i] = (byte) ((b[i] & 0xff) >>> 1);
- b[i] = (byte) (b[i] | temp2);
- temp2 = temp;
+ private static void putLong(byte[] buffer, int offset, long value) {
+ int end = offset + 8;
+ for (int i = end - 1; i >= offset; --i) {
+ buffer[i] = (byte) value;
+ value >>= 8;
}
}
- // Given block X and Y, returns the muliplication of X * Y
- private static byte[] blockMult(byte[] x, byte[] y) {
- if (x.length != AES_BLOCK_SIZE || y.length != AES_BLOCK_SIZE) {
- throw new RuntimeException("illegal input sizes");
- }
- byte[] z = new byte[AES_BLOCK_SIZE];
- byte[] v = y.clone();
- // calculate Z1-Z127 and V1-V127
- for (int i = 0; i < 127; i++) {
+ private static final int AES_BLOCK_SIZE = 16;
+
+ // Multiplies state0, state1 by V0, V1.
+ private void blockMult(long V0, long V1) {
+ long Z0 = 0;
+ long Z1 = 0;
+ long X;
+
+ // Separate loops for processing state0 and state1.
+ X = state0;
+ for (int i = 0; i < 64; i++) {
// Zi+1 = Zi if bit i of x is 0
- if (getBit(x, i)) {
- for (int n = 0; n < z.length; n++) {
- z[n] ^= v[n];
- }
- }
- boolean lastBitOfV = getBit(v, 127);
- shift(v);
- if (lastBitOfV) v[0] ^= P128;
+ long mask = X >> 63;
+ Z0 ^= V0 & mask;
+ Z1 ^= V1 & mask;
+
+ // Save mask for conditional reduction below.
+ mask = (V1 << 63) >> 63;
+
+ // V = rightshift(V)
+ long carry = V0 & 1;
+ V0 = V0 >>> 1;
+ V1 = (V1 >>> 1) | (carry << 63);
+
+ // Conditional reduction modulo P128.
+ V0 ^= 0xe100000000000000L & mask;
+ X <<= 1;
}
+
+ X = state1;
+ for (int i = 64; i < 127; i++) {
+ // Zi+1 = Zi if bit i of x is 0
+ long mask = X >> 63;
+ Z0 ^= V0 & mask;
+ Z1 ^= V1 & mask;
+
+ // Save mask for conditional reduction below.
+ mask = (V1 << 63) >> 63;
+
+ // V = rightshift(V)
+ long carry = V0 & 1;
+ V0 = V0 >>> 1;
+ V1 = (V1 >>> 1) | (carry << 63);
+
+ // Conditional reduction.
+ V0 ^= 0xe100000000000000L & mask;
+ X <<= 1;
+ }
+
// calculate Z128
- if (getBit(x, 127)) {
- for (int n = 0; n < z.length; n++) {
- z[n] ^= v[n];
- }
- }
- return z;
+ long mask = X >> 63;
+ Z0 ^= V0 & mask;
+ Z1 ^= V1 & mask;
+
+ // Save result.
+ state0 = Z0;
+ state1 = Z1;
}
// hash subkey H; should not change after the object has been constructed
- private final byte[] subkeyH;
+ private final long subkeyH0, subkeyH1;
// buffer for storing hash
- private byte[] state;
+ private long state0, state1;
// variables for save/restore calls
- private byte[] stateSave = null;
+ private long stateSave0, stateSave1;
/**
* Initializes the cipher in the specified mode with the given key
@@ -114,8 +141,8 @@
if ((subkeyH == null) || subkeyH.length != AES_BLOCK_SIZE) {
throw new ProviderException("Internal error");
}
- this.subkeyH = subkeyH;
- this.state = new byte[AES_BLOCK_SIZE];
+ this.subkeyH0 = getLong(subkeyH, 0);
+ this.subkeyH1 = getLong(subkeyH, 8);
}
/**
@@ -124,31 +151,33 @@
* this object for different data w/ the same H.
*/
void reset() {
- Arrays.fill(state, (byte) 0);
+ state0 = 0;
+ state1 = 0;
}
/**
* Save the current snapshot of this GHASH object.
*/
void save() {
- stateSave = state.clone();
+ stateSave0 = state0;
+ stateSave1 = state1;
}
/**
* Restores this object using the saved snapshot.
*/
void restore() {
- state = stateSave;
+ state0 = stateSave0;
+ state1 = stateSave1;
}
private void processBlock(byte[] data, int ofs) {
if (data.length - ofs < AES_BLOCK_SIZE) {
throw new RuntimeException("need complete block");
}
- for (int n = 0; n < state.length; n++) {
- state[n] ^= data[ofs + n];
- }
- state = blockMult(state, subkeyH);
+ state0 ^= getLong(data, ofs);
+ state1 ^= getLong(data, ofs + 8);
+ blockMult(subkeyH0, subkeyH1);
}
void update(byte[] in) {
@@ -169,10 +198,10 @@
}
byte[] digest() {
- try {
- return state.clone();
- } finally {
- reset();
- }
+ byte[] result = new byte[AES_BLOCK_SIZE];
+ putLong(result, 0, state0);
+ putLong(result, 8, state1);
+ reset();
+ return result;
}
}
--- a/jdk/src/java.base/share/classes/java/io/PushbackInputStream.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/io/PushbackInputStream.java Wed Feb 18 19:27:49 2015 -0800
@@ -28,9 +28,10 @@
/**
* A <code>PushbackInputStream</code> adds
* functionality to another input stream, namely
- * the ability to "push back" or "unread"
- * one byte. This is useful in situations where
- * it is convenient for a fragment of code
+ * the ability to "push back" or "unread" bytes,
+ * by storing pushed-back bytes in an internal buffer.
+ * This is useful in situations where
+ * it is convenient for a fragment of code
* to read an indefinite number of data bytes
* that are delimited by a particular byte
* value; after reading the terminating byte,
@@ -77,11 +78,9 @@
/**
* Creates a <code>PushbackInputStream</code>
* with a pushback buffer of the specified <code>size</code>,
- * and saves its argument, the input stream
+ * and saves its argument, the input stream
* <code>in</code>, for later use. Initially,
- * there is no pushed-back byte (the field
- * <code>pushBack</code> is initialized to
- * <code>-1</code>).
+ * the pushback buffer is empty.
*
* @param in the input stream from which bytes will be read.
* @param size the size of the pushback buffer.
@@ -99,11 +98,9 @@
/**
* Creates a <code>PushbackInputStream</code>
- * and saves its argument, the input stream
+ * with a 1-byte pushback buffer, and saves its argument, the input stream
* <code>in</code>, for later use. Initially,
- * there is no pushed-back byte (the field
- * <code>pushBack</code> is initialized to
- * <code>-1</code>).
+ * the pushback buffer is empty.
*
* @param in the input stream from which bytes will be read.
*/
--- a/jdk/src/java.base/share/classes/java/lang/Number.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/lang/Number.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -37,7 +37,7 @@
*
* For platform classes, the conversion is often analogous to a
* narrowing primitive conversion or a widening primitive conversion
- * as defining in <cite>The Java™ Language Specification</cite>
+ * as defined in <cite>The Java™ Language Specification</cite>
* for converting between primitive types. Therefore, conversions may
* lose information about the overall magnitude of a numeric value, may
* lose precision, and may even return a result of a different sign
@@ -54,8 +54,7 @@
*/
public abstract class Number implements java.io.Serializable {
/**
- * Returns the value of the specified number as an {@code int},
- * which may involve rounding or truncation.
+ * Returns the value of the specified number as an {@code int}.
*
* @return the numeric value represented by this object after conversion
* to type {@code int}.
@@ -63,8 +62,7 @@
public abstract int intValue();
/**
- * Returns the value of the specified number as a {@code long},
- * which may involve rounding or truncation.
+ * Returns the value of the specified number as a {@code long}.
*
* @return the numeric value represented by this object after conversion
* to type {@code long}.
@@ -72,8 +70,7 @@
public abstract long longValue();
/**
- * Returns the value of the specified number as a {@code float},
- * which may involve rounding.
+ * Returns the value of the specified number as a {@code float}.
*
* @return the numeric value represented by this object after conversion
* to type {@code float}.
@@ -81,8 +78,7 @@
public abstract float floatValue();
/**
- * Returns the value of the specified number as a {@code double},
- * which may involve rounding.
+ * Returns the value of the specified number as a {@code double}.
*
* @return the numeric value represented by this object after conversion
* to type {@code double}.
@@ -90,8 +86,7 @@
public abstract double doubleValue();
/**
- * Returns the value of the specified number as a {@code byte},
- * which may involve rounding or truncation.
+ * Returns the value of the specified number as a {@code byte}.
*
* <p>This implementation returns the result of {@link #intValue} cast
* to a {@code byte}.
@@ -105,8 +100,7 @@
}
/**
- * Returns the value of the specified number as a {@code short},
- * which may involve rounding or truncation.
+ * Returns the value of the specified number as a {@code short}.
*
* <p>This implementation returns the result of {@link #intValue} cast
* to a {@code short}.
--- a/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/lang/ProcessBuilder.java Wed Feb 18 19:27:49 2015 -0800
@@ -964,6 +964,9 @@
* of the exception is system-dependent, but it will always be a
* subclass of {@link IOException}.
*
+ * <p>If the operating system does not support the creation of
+ * processes, an {@link UnsupportedOperationException} will be thrown.
+ *
* <p>Subsequent modifications to this process builder will not
* affect the returned {@link Process}.
*
@@ -998,6 +1001,9 @@
*
* </ul>
*
+ * @throws UnsupportedOperationException
+ * If the operating system does not support the creation of processes.
+ *
* @throws IOException if an I/O error occurs
*
* @see Runtime#exec(String[], String[], java.io.File)
--- a/jdk/src/java.base/share/classes/java/lang/Runtime.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/lang/Runtime.java Wed Feb 18 19:27:49 2015 -0800
@@ -576,6 +576,9 @@
* of the exception is system-dependent, but it will always be a
* subclass of {@link IOException}.
*
+ * <p>If the operating system does not support the creation of
+ * processes, an {@link UnsupportedOperationException} will be thrown.
+ *
*
* @param cmdarray array containing the command to call and
* its arguments.
@@ -597,6 +600,9 @@
* {@link SecurityManager#checkExec checkExec}
* method doesn't allow creation of the subprocess
*
+ * @throws UnsupportedOperationException
+ * If the operating system does not support the creation of processes.
+ *
* @throws IOException
* If an I/O error occurs
*
--- a/jdk/src/java.base/share/classes/java/lang/reflect/Executable.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/lang/reflect/Executable.java Wed Feb 18 19:27:49 2015 -0800
@@ -662,7 +662,7 @@
*
* If this {@code Executable} object represents a static method or
* represents a constructor of a top level, static member, local, or
- * anoymous class, then the return value is null.
+ * anonymous class, then the return value is null.
*
* @return an object representing the receiver type of the method or
* constructor represented by this {@code Executable} or {@code null} if
--- a/jdk/src/java.base/share/classes/java/math/BigDecimal.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/math/BigDecimal.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -4814,41 +4814,61 @@
if (dividendHi >= divisor) {
return null;
}
+
final int shift = Long.numberOfLeadingZeros(divisor);
divisor <<= shift;
final long v1 = divisor >>> 32;
final long v0 = divisor & LONG_MASK;
- long q1, q0;
- long r_tmp;
-
long tmp = dividendLo << shift;
long u1 = tmp >>> 32;
long u0 = tmp & LONG_MASK;
tmp = (dividendHi << shift) | (dividendLo >>> 64 - shift);
long u2 = tmp & LONG_MASK;
- tmp = divWord(tmp,v1);
- q1 = tmp & LONG_MASK;
- r_tmp = tmp >>> 32;
+ long q1, r_tmp;
+ if (v1 == 1) {
+ q1 = tmp;
+ r_tmp = 0;
+ } else if (tmp >= 0) {
+ q1 = tmp / v1;
+ r_tmp = tmp - q1 * v1;
+ } else {
+ long[] rq = divRemNegativeLong(tmp, v1);
+ q1 = rq[1];
+ r_tmp = rq[0];
+ }
+
while(q1 >= DIV_NUM_BASE || unsignedLongCompare(q1*v0, make64(r_tmp, u1))) {
q1--;
r_tmp += v1;
if (r_tmp >= DIV_NUM_BASE)
break;
}
+
tmp = mulsub(u2,u1,v1,v0,q1);
u1 = tmp & LONG_MASK;
- tmp = divWord(tmp,v1);
- q0 = tmp & LONG_MASK;
- r_tmp = tmp >>> 32;
+ long q0;
+ if (v1 == 1) {
+ q0 = tmp;
+ r_tmp = 0;
+ } else if (tmp >= 0) {
+ q0 = tmp / v1;
+ r_tmp = tmp - q0 * v1;
+ } else {
+ long[] rq = divRemNegativeLong(tmp, v1);
+ q0 = rq[1];
+ r_tmp = rq[0];
+ }
+
while(q0 >= DIV_NUM_BASE || unsignedLongCompare(q0*v0,make64(r_tmp,u0))) {
q0--;
r_tmp += v1;
if (r_tmp >= DIV_NUM_BASE)
break;
}
+
if((int)q1 < 0) {
// result (which is positive and unsigned here)
// can't fit into long due to sign bit is used for value
@@ -4871,10 +4891,13 @@
}
}
}
+
long q = make64(q1,q0);
q*=sign;
+
if (roundingMode == ROUND_DOWN && scale == preferredScale)
return valueOf(q, scale);
+
long r = mulsub(u1, u0, v1, v0, q0) >>> shift;
if (r != 0) {
boolean increment = needIncrement(divisor >>> shift, roundingMode, sign, q, r);
@@ -4917,28 +4940,35 @@
}
}
- private static long divWord(long n, long dLong) {
- long r;
- long q;
- if (dLong == 1) {
- q = (int)n;
- return (q & LONG_MASK);
- }
+ /**
+ * Calculate the quotient and remainder of dividing a negative long by
+ * another long.
+ *
+ * @param n the numerator; must be negative
+ * @param d the denominator; must not be unity
+ * @return a two-element {@long} array with the remainder and quotient in
+ * the initial and final elements, respectively
+ */
+ private static long[] divRemNegativeLong(long n, long d) {
+ assert n < 0 : "Non-negative numerator " + n;
+ assert d != 1 : "Unity denominator";
+
// Approximate the quotient and remainder
- q = (n >>> 1) / (dLong >>> 1);
- r = n - q*dLong;
+ long q = (n >>> 1) / (d >>> 1);
+ long r = n - q * d;
// Correct the approximation
while (r < 0) {
- r += dLong;
+ r += d;
q--;
}
- while (r >= dLong) {
- r -= dLong;
+ while (r >= d) {
+ r -= d;
q++;
}
- // n - q*dlong == r && 0 <= r <dLong, hence we're done.
- return (r << 32) | (q & LONG_MASK);
+
+ // n - q*d == r && 0 <= r < d, hence we're done.
+ return new long[] {r, q};
}
private static long make64(long hi, long lo) {
--- a/jdk/src/java.base/share/classes/java/net/DatagramSocket.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/net/DatagramSocket.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, 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
@@ -1308,6 +1308,7 @@
/**
* Sets the value of a socket option.
*
+ * @param <T> The type of the socket option value
* @param name The socket option
* @param value The value of the socket option. A value of {@code null}
* may be valid for some options.
@@ -1342,6 +1343,7 @@
/**
* Returns the value of a socket option.
*
+ * @param <T> The type of the socket option value
* @param name The socket option
*
* @return The value of the socket option.
--- a/jdk/src/java.base/share/classes/java/net/DatagramSocketImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/net/DatagramSocketImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -267,6 +267,7 @@
/**
* Called to set a socket option.
*
+ * @param <T> The type of the socket option value
* @param name The socket option
*
* @param value The value of the socket option. A value of {@code null}
@@ -276,7 +277,7 @@
* support the option
*
* @throws NullPointerException if name is {@code null}
- *
+ * @throws IOException if an I/O problem occurs while attempting to set the option
* @since 1.9
*/
protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
@@ -308,12 +309,15 @@
/**
* Called to get a socket option.
*
+ * @return the socket option
+ * @param <T> The type of the socket option value
* @param name The socket option
*
* @throws UnsupportedOperationException if the DatagramSocketImpl does not
* support the option
*
* @throws NullPointerException if name is {@code null}
+ * @throws IOException if an I/O problem occurs while attempting to set the option
*
* @since 1.9
*/
--- a/jdk/src/java.base/share/classes/java/net/ServerSocket.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/net/ServerSocket.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, 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
@@ -924,6 +924,7 @@
/**
* Sets the value of a socket option.
*
+ * @param <T> The type of the socket option value
* @param name The socket option
* @param value The value of the socket option. A value of {@code null}
* may be valid for some options.
@@ -957,6 +958,7 @@
/**
* Returns the value of a socket option.
*
+ * @param <T> The type of the socket option value
* @param name The socket option
*
* @return The value of the socket option.
--- a/jdk/src/java.base/share/classes/java/net/Socket.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/net/Socket.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, 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
@@ -1727,6 +1727,7 @@
/**
* Sets the value of a socket option.
*
+ * @param <T> The type of the socket option value
* @param name The socket option
* @param value The value of the socket option. A value of {@code null}
* may be valid for some options.
@@ -1758,6 +1759,7 @@
/**
* Returns the value of a socket option.
*
+ * @param <T> The type of the socket option value
* @param name The socket option
*
* @return The value of the socket option.
--- a/jdk/src/java.base/share/classes/java/net/SocketImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/net/SocketImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, 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
@@ -362,6 +362,7 @@
/**
* Called to set a socket option.
*
+ * @param <T> The type of the socket option value
* @param name The socket option
*
* @param value The value of the socket option. A value of {@code null}
@@ -397,6 +398,7 @@
/**
* Called to get a socket option.
*
+ * @param <T> The type of the socket option value
* @param name The socket option
*
* @return the value of the named option
--- a/jdk/src/java.base/share/classes/java/nio/channels/FileLock.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/nio/channels/FileLock.java Wed Feb 18 19:27:49 2015 -0800
@@ -26,6 +26,7 @@
package java.nio.channels;
import java.io.IOException;
+import java.util.Objects;
/**
* A token representing a lock on a region of a file.
@@ -147,6 +148,7 @@
protected FileLock(FileChannel channel,
long position, long size, boolean shared)
{
+ Objects.requireNonNull(channel, "Null channel");
if (position < 0)
throw new IllegalArgumentException("Negative position");
if (size < 0)
@@ -185,6 +187,7 @@
protected FileLock(AsynchronousFileChannel channel,
long position, long size, boolean shared)
{
+ Objects.requireNonNull(channel, "Null channel");
if (position < 0)
throw new IllegalArgumentException("Negative position");
if (size < 0)
--- a/jdk/src/java.base/share/classes/java/security/KeyStore.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/security/KeyStore.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -1618,11 +1618,13 @@
* integrity check.
*
* <p>
- * This method traverses the list of registered security {@link Providers},
- * starting with the most preferred Provider.
- * For each {@link KeyStoreSpi} implementation supported by a Provider,
- * it invokes the {@link engineProbe} method to determine if it supports
- * the specified keystore.
+ * This method traverses the list of registered security
+ * {@linkplain Provider providers}, starting with the most
+ * preferred Provider.
+ * For each {@link KeyStoreSpi} implementation supported by a
+ * Provider, it invokes the {@link
+ * KeyStoreSpi#engineProbe(InputStream) engineProbe} method to
+ * determine if it supports the specified keystore.
* A new KeyStore object is returned that encapsulates the KeyStoreSpi
* implementation from the first Provider that supports the specified file.
*
@@ -1672,11 +1674,12 @@
* unlock the keystore data or perform an integrity check.
*
* <p>
- * This method traverses the list of registered security {@link Providers},
- * starting with the most preferred Provider.
- * For each {@link KeyStoreSpi} implementation supported by a Provider,
- * it invokes the {@link engineProbe} method to determine if it supports
- * the specified keystore.
+ * This method traverses the list of registered security {@linkplain
+ * Provider providers}, starting with the most preferred Provider.
+ * For each {@link KeyStoreSpi} implementation supported by a
+ * Provider, it invokes the {@link
+ * KeyStoreSpi#engineProbe(InputStream) engineProbe} method to
+ * determine if it supports the specified keystore.
* A new KeyStore object is returned that encapsulates the KeyStoreSpi
* implementation from the first Provider that supports the specified file.
*
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/security/acl/Acl.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,241 @@
+/*
+ * Copyright (c) 1996, 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.
+ */
+
+package java.security.acl;
+
+import java.util.Enumeration;
+import java.security.Principal;
+
+/**
+ * Interface representing an Access Control List (ACL). An Access
+ * Control List is a data structure used to guard access to
+ * resources.<p>
+ *
+ * An ACL can be thought of as a data structure with multiple ACL
+ * entries. Each ACL entry, of interface type AclEntry, contains a
+ * set of permissions associated with a particular principal. (A
+ * principal represents an entity such as an individual user or a
+ * group). Additionally, each ACL entry is specified as being either
+ * positive or negative. If positive, the permissions are to be
+ * granted to the associated principal. If negative, the permissions
+ * are to be denied.<p>
+ *
+ * The ACL Entries in each ACL observe the following rules:
+ *
+ * <ul> <li>Each principal can have at most one positive ACL entry and
+ * one negative entry; that is, multiple positive or negative ACL
+ * entries are not allowed for any principal. Each entry specifies
+ * the set of permissions that are to be granted (if positive) or
+ * denied (if negative).
+ *
+ * <li>If there is no entry for a particular principal, then the
+ * principal is considered to have a null (empty) permission set.
+ *
+ * <li>If there is a positive entry that grants a principal a
+ * particular permission, and a negative entry that denies the
+ * principal the same permission, the result is as though the
+ * permission was never granted or denied.
+ *
+ * <li>Individual permissions always override permissions of the
+ * group(s) to which the individual belongs. That is, individual
+ * negative permissions (specific denial of permissions) override the
+ * groups' positive permissions. And individual positive permissions
+ * override the groups' negative permissions.
+ *
+ * </ul>
+ *
+ * The {@code java.security.acl } package provides the
+ * interfaces to the ACL and related data structures (ACL entries,
+ * groups, permissions, etc.), and the {@code sun.security.acl }
+ * classes provide a default implementation of the interfaces. For
+ * example, {@code java.security.acl.Acl } provides the
+ * interface to an ACL and the {@code sun.security.acl.AclImpl }
+ * class provides the default implementation of the interface.<p>
+ *
+ * The {@code java.security.acl.Acl } interface extends the
+ * {@code java.security.acl.Owner } interface. The Owner
+ * interface is used to maintain a list of owners for each ACL. Only
+ * owners are allowed to modify an ACL. For example, only an owner can
+ * call the ACL's {@code addEntry} method to add a new ACL entry
+ * to the ACL.
+ *
+ * @see java.security.acl.AclEntry
+ * @see java.security.acl.Owner
+ * @see java.security.acl.Acl#getPermissions
+ *
+ * @author Satish Dharmaraj
+ */
+
+public interface Acl extends Owner {
+
+ /**
+ * Sets the name of this ACL.
+ *
+ * @param caller the principal invoking this method. It must be an
+ * owner of this ACL.
+ *
+ * @param name the name to be given to this ACL.
+ *
+ * @exception NotOwnerException if the caller principal
+ * is not an owner of this ACL.
+ *
+ * @see #getName
+ */
+ public void setName(Principal caller, String name)
+ throws NotOwnerException;
+
+ /**
+ * Returns the name of this ACL.
+ *
+ * @return the name of this ACL.
+ *
+ * @see #setName
+ */
+ public String getName();
+
+ /**
+ * Adds an ACL entry to this ACL. An entry associates a principal
+ * (e.g., an individual or a group) with a set of
+ * permissions. Each principal can have at most one positive ACL
+ * entry (specifying permissions to be granted to the principal)
+ * and one negative ACL entry (specifying permissions to be
+ * denied). If there is already an ACL entry of the same type
+ * (negative or positive) already in the ACL, false is returned.
+ *
+ * @param caller the principal invoking this method. It must be an
+ * owner of this ACL.
+ *
+ * @param entry the ACL entry to be added to this ACL.
+ *
+ * @return true on success, false if an entry of the same type
+ * (positive or negative) for the same principal is already
+ * present in this ACL.
+ *
+ * @exception NotOwnerException if the caller principal
+ * is not an owner of this ACL.
+ */
+ public boolean addEntry(Principal caller, AclEntry entry)
+ throws NotOwnerException;
+
+ /**
+ * Removes an ACL entry from this ACL.
+ *
+ * @param caller the principal invoking this method. It must be an
+ * owner of this ACL.
+ *
+ * @param entry the ACL entry to be removed from this ACL.
+ *
+ * @return true on success, false if the entry is not part of this ACL.
+ *
+ * @exception NotOwnerException if the caller principal is not
+ * an owner of this Acl.
+ */
+ public boolean removeEntry(Principal caller, AclEntry entry)
+ throws NotOwnerException;
+
+ /**
+ * Returns an enumeration for the set of allowed permissions for the
+ * specified principal (representing an entity such as an individual or
+ * a group). This set of allowed permissions is calculated as
+ * follows:
+ *
+ * <ul>
+ *
+ * <li>If there is no entry in this Access Control List for the
+ * specified principal, an empty permission set is returned.
+ *
+ * <li>Otherwise, the principal's group permission sets are determined.
+ * (A principal can belong to one or more groups, where a group is a
+ * group of principals, represented by the Group interface.)
+ * The group positive permission set is the union of all
+ * the positive permissions of each group that the principal belongs to.
+ * The group negative permission set is the union of all
+ * the negative permissions of each group that the principal belongs to.
+ * If there is a specific permission that occurs in both
+ * the positive permission set and the negative permission set,
+ * it is removed from both.<p>
+ *
+ * The individual positive and negative permission sets are also
+ * determined. The positive permission set contains the permissions
+ * specified in the positive ACL entry (if any) for the principal.
+ * Similarly, the negative permission set contains the permissions
+ * specified in the negative ACL entry (if any) for the principal.
+ * The individual positive (or negative) permission set is considered
+ * to be null if there is not a positive (negative) ACL entry for the
+ * principal in this ACL.<p>
+ *
+ * The set of permissions granted to the principal is then calculated
+ * using the simple rule that individual permissions always override
+ * the group permissions. That is, the principal's individual negative
+ * permission set (specific denial of permissions) overrides the group
+ * positive permission set, and the principal's individual positive
+ * permission set overrides the group negative permission set.
+ *
+ * </ul>
+ *
+ * @param user the principal whose permission set is to be returned.
+ *
+ * @return the permission set specifying the permissions the principal
+ * is allowed.
+ */
+ public Enumeration<Permission> getPermissions(Principal user);
+
+ /**
+ * Returns an enumeration of the entries in this ACL. Each element in
+ * the enumeration is of type AclEntry.
+ *
+ * @return an enumeration of the entries in this ACL.
+ */
+ public Enumeration<AclEntry> entries();
+
+ /**
+ * Checks whether or not the specified principal has the specified
+ * permission. If it does, true is returned, otherwise false is returned.
+ *
+ * More specifically, this method checks whether the passed permission
+ * is a member of the allowed permission set of the specified principal.
+ * The allowed permission set is determined by the same algorithm as is
+ * used by the {@code getPermissions} method.
+ *
+ * @param principal the principal, assumed to be a valid authenticated
+ * Principal.
+ *
+ * @param permission the permission to be checked for.
+ *
+ * @return true if the principal has the specified permission, false
+ * otherwise.
+ *
+ * @see #getPermissions
+ */
+ public boolean checkPermission(Principal principal, Permission permission);
+
+ /**
+ * Returns a string representation of the
+ * ACL contents.
+ *
+ * @return a string representation of the ACL contents.
+ */
+ public String toString();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/security/acl/AclEntry.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,154 @@
+/*
+ * Copyright (c) 1996, 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.
+ */
+
+package java.security.acl;
+
+import java.util.Enumeration;
+import java.security.Principal;
+
+/**
+ * This is the interface used for representing one entry in an Access
+ * Control List (ACL).<p>
+ *
+ * An ACL can be thought of as a data structure with multiple ACL entry
+ * objects. Each ACL entry object contains a set of permissions associated
+ * with a particular principal. (A principal represents an entity such as
+ * an individual user or a group). Additionally, each ACL entry is specified
+ * as being either positive or negative. If positive, the permissions are
+ * to be granted to the associated principal. If negative, the permissions
+ * are to be denied. Each principal can have at most one positive ACL entry
+ * and one negative entry; that is, multiple positive or negative ACL
+ * entries are not allowed for any principal.
+ *
+ * Note: ACL entries are by default positive. An entry becomes a
+ * negative entry only if the
+ * {@link #setNegativePermissions() setNegativePermissions}
+ * method is called on it.
+ *
+ * @see java.security.acl.Acl
+ *
+ * @author Satish Dharmaraj
+ */
+public interface AclEntry extends Cloneable {
+
+ /**
+ * Specifies the principal for which permissions are granted or denied
+ * by this ACL entry. If a principal was already set for this ACL entry,
+ * false is returned, otherwise true is returned.
+ *
+ * @param user the principal to be set for this entry.
+ *
+ * @return true if the principal is set, false if there was
+ * already a principal set for this entry.
+ *
+ * @see #getPrincipal
+ */
+ public boolean setPrincipal(Principal user);
+
+ /**
+ * Returns the principal for which permissions are granted or denied by
+ * this ACL entry. Returns null if there is no principal set for this
+ * entry yet.
+ *
+ * @return the principal associated with this entry.
+ *
+ * @see #setPrincipal
+ */
+ public Principal getPrincipal();
+
+ /**
+ * Sets this ACL entry to be a negative one. That is, the associated
+ * principal (e.g., a user or a group) will be denied the permission set
+ * specified in the entry.
+ *
+ * Note: ACL entries are by default positive. An entry becomes a
+ * negative entry only if this {@code setNegativePermissions}
+ * method is called on it.
+ */
+ public void setNegativePermissions();
+
+ /**
+ * Returns true if this is a negative ACL entry (one denying the
+ * associated principal the set of permissions in the entry), false
+ * otherwise.
+ *
+ * @return true if this is a negative ACL entry, false if it's not.
+ */
+ public boolean isNegative();
+
+ /**
+ * Adds the specified permission to this ACL entry. Note: An entry can
+ * have multiple permissions.
+ *
+ * @param permission the permission to be associated with
+ * the principal in this entry.
+ *
+ * @return true if the permission was added, false if the
+ * permission was already part of this entry's permission set.
+ */
+ public boolean addPermission(Permission permission);
+
+ /**
+ * Removes the specified permission from this ACL entry.
+ *
+ * @param permission the permission to be removed from this entry.
+ *
+ * @return true if the permission is removed, false if the
+ * permission was not part of this entry's permission set.
+ */
+ public boolean removePermission(Permission permission);
+
+ /**
+ * Checks if the specified permission is part of the
+ * permission set in this entry.
+ *
+ * @param permission the permission to be checked for.
+ *
+ * @return true if the permission is part of the
+ * permission set in this entry, false otherwise.
+ */
+ public boolean checkPermission(Permission permission);
+
+ /**
+ * Returns an enumeration of the permissions in this ACL entry.
+ *
+ * @return an enumeration of the permissions in this ACL entry.
+ */
+ public Enumeration<Permission> permissions();
+
+ /**
+ * Returns a string representation of the contents of this ACL entry.
+ *
+ * @return a string representation of the contents.
+ */
+ public String toString();
+
+ /**
+ * Clones this ACL entry.
+ *
+ * @return a clone of this ACL entry.
+ */
+ public Object clone();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/security/acl/AclNotFoundException.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1996, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.security.acl;
+
+/**
+ * This is an exception that is thrown whenever a reference is made to a
+ * non-existent ACL (Access Control List).
+ *
+ * @author Satish Dharmaraj
+ */
+public class AclNotFoundException extends Exception {
+
+ private static final long serialVersionUID = 5684295034092681791L;
+
+ /**
+ * Constructs an AclNotFoundException.
+ */
+ public AclNotFoundException() {
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/security/acl/Group.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,87 @@
+/*
+ * Copyright (c) 1996, 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.
+ */
+
+package java.security.acl;
+
+import java.util.Enumeration;
+import java.security.Principal;
+
+/**
+ * This interface is used to represent a group of principals. (A principal
+ * represents an entity such as an individual user or a company). <p>
+ *
+ * Note that Group extends Principal. Thus, either a Principal or a Group can
+ * be passed as an argument to methods containing a Principal parameter. For
+ * example, you can add either a Principal or a Group to a Group object by
+ * calling the object's {@code addMember} method, passing it the
+ * Principal or Group.
+ *
+ * @author Satish Dharmaraj
+ */
+public interface Group extends Principal {
+
+ /**
+ * Adds the specified member to the group.
+ *
+ * @param user the principal to add to this group.
+ *
+ * @return true if the member was successfully added,
+ * false if the principal was already a member.
+ */
+ public boolean addMember(Principal user);
+
+ /**
+ * Removes the specified member from the group.
+ *
+ * @param user the principal to remove from this group.
+ *
+ * @return true if the principal was removed, or
+ * false if the principal was not a member.
+ */
+ public boolean removeMember(Principal user);
+
+ /**
+ * Returns true if the passed principal is a member of the group.
+ * This method does a recursive search, so if a principal belongs to a
+ * group which is a member of this group, true is returned.
+ *
+ * @param member the principal whose membership is to be checked.
+ *
+ * @return true if the principal is a member of this group,
+ * false otherwise.
+ */
+ public boolean isMember(Principal member);
+
+
+ /**
+ * Returns an enumeration of the members in the group.
+ * The returned objects can be instances of either Principal
+ * or Group (which is a subclass of Principal).
+ *
+ * @return an enumeration of the group members.
+ */
+ public Enumeration<? extends Principal> members();
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/security/acl/LastOwnerException.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 1996, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.security.acl;
+
+/**
+ * This is an exception that is thrown whenever an attempt is made to delete
+ * the last owner of an Access Control List.
+ *
+ * @see java.security.acl.Owner#deleteOwner
+ *
+ * @author Satish Dharmaraj
+ */
+public class LastOwnerException extends Exception {
+
+ private static final long serialVersionUID = -5141997548211140359L;
+
+ /**
+ * Constructs a LastOwnerException.
+ */
+ public LastOwnerException() {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/security/acl/NotOwnerException.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 1996, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.security.acl;
+
+/**
+ * This is an exception that is thrown whenever the modification of an object
+ * (such as an Access Control List) is only allowed to be done by an owner of
+ * the object, but the Principal attempting the modification is not an owner.
+ *
+ * @author Satish Dharmaraj
+ */
+public class NotOwnerException extends Exception {
+
+ private static final long serialVersionUID = -5555597911163362399L;
+
+ /**
+ * Constructs a NotOwnerException.
+ */
+ public NotOwnerException() {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/security/acl/Owner.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 1996, 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.
+ */
+
+package java.security.acl;
+
+import java.security.Principal;
+
+/**
+ * Interface for managing owners of Access Control Lists (ACLs) or ACL
+ * configurations. (Note that the Acl interface in the
+ * {@code java.security.acl} package extends this Owner
+ * interface.) The initial owner Principal should be specified as an
+ * argument to the constructor of the class implementing this interface.
+ *
+ * @see java.security.acl.Acl
+ *
+ */
+public interface Owner {
+
+ /**
+ * Adds an owner. Only owners can modify ACL contents. The caller
+ * principal must be an owner of the ACL in order to invoke this method.
+ * That is, only an owner can add another owner. The initial owner is
+ * configured at ACL construction time.
+ *
+ * @param caller the principal invoking this method. It must be an owner
+ * of the ACL.
+ *
+ * @param owner the owner that should be added to the list of owners.
+ *
+ * @return true if successful, false if owner is already an owner.
+ * @exception NotOwnerException if the caller principal is not an owner
+ * of the ACL.
+ */
+ public boolean addOwner(Principal caller, Principal owner)
+ throws NotOwnerException;
+
+ /**
+ * Deletes an owner. If this is the last owner in the ACL, an exception is
+ * raised.<p>
+ *
+ * The caller principal must be an owner of the ACL in order to invoke
+ * this method.
+ *
+ * @param caller the principal invoking this method. It must be an owner
+ * of the ACL.
+ *
+ * @param owner the owner to be removed from the list of owners.
+ *
+ * @return true if the owner is removed, false if the owner is not part
+ * of the list of owners.
+ *
+ * @exception NotOwnerException if the caller principal is not an owner
+ * of the ACL.
+ *
+ * @exception LastOwnerException if there is only one owner left, so that
+ * deleteOwner would leave the ACL owner-less.
+ */
+ public boolean deleteOwner(Principal caller, Principal owner)
+ throws NotOwnerException, LastOwnerException;
+
+ /**
+ * Returns true if the given principal is an owner of the ACL.
+ *
+ * @param owner the principal to be checked to determine whether or not
+ * it is an owner.
+ *
+ * @return true if the passed principal is in the list of owners, false
+ * if not.
+ */
+ public boolean isOwner(Principal owner);
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/security/acl/Permission.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package java.security.acl;
+
+
+/**
+ * This interface represents a permission, such as that used to grant
+ * a particular type of access to a resource.
+ *
+ * @author Satish Dharmaraj
+ */
+public interface Permission {
+
+ /**
+ * Returns true if the object passed matches the permission represented
+ * in this interface.
+ *
+ * @param another the Permission object to compare with.
+ *
+ * @return true if the Permission objects are equal, false otherwise
+ */
+ public boolean equals(Object another);
+
+ /**
+ * Prints a string representation of this permission.
+ *
+ * @return the string representation of the permission.
+ */
+ public String toString();
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/java/security/acl/package-info.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 1998, 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.
+ */
+
+/**
+ * The classes and interfaces in this package have been
+ * superseded by classes in the java.security package.
+ * See that package and, for example, java.security.Permission for details.
+ *
+ * @since 1.1
+ */
+package java.security.acl;
--- a/jdk/src/java.base/share/classes/java/time/Clock.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/time/Clock.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -61,12 +61,15 @@
*/
package java.time;
+import java.io.IOException;
+import java.io.ObjectInputStream;
import static java.time.LocalTime.NANOS_PER_MINUTE;
import static java.time.LocalTime.NANOS_PER_SECOND;
import java.io.Serializable;
import java.util.Objects;
import java.util.TimeZone;
+import sun.misc.VM;
/**
* A clock providing access to the current instant, date and time using a time-zone.
@@ -446,10 +449,22 @@
*/
static final class SystemClock extends Clock implements Serializable {
private static final long serialVersionUID = 6740630888130243051L;
+ private static final long OFFSET_SEED =
+ System.currentTimeMillis()/1000 - 1024; // initial offest
private final ZoneId zone;
+ // We don't actually need a volatile here.
+ // We don't care if offset is set or read concurrently by multiple
+ // threads - we just need a value which is 'recent enough' - in other
+ // words something that has been updated at least once in the last
+ // 2^32 secs (~136 years). And even if we by chance see an invalid
+ // offset, the worst that can happen is that we will get a -1 value
+ // from getNanoTimeAdjustment, forcing us to update the offset
+ // once again.
+ private transient long offset;
SystemClock(ZoneId zone) {
this.zone = zone;
+ this.offset = OFFSET_SEED;
}
@Override
public ZoneId getZone() {
@@ -464,11 +479,50 @@
}
@Override
public long millis() {
+ // System.currentTimeMillis() and VM.getNanoTimeAdjustment(offset)
+ // use the same time source - System.currentTimeMillis() simply
+ // limits the resolution to milliseconds.
+ // So we take the faster path and call System.currentTimeMillis()
+ // directly - in order to avoid the performance penalty of
+ // VM.getNanoTimeAdjustment(offset) which is less efficient.
return System.currentTimeMillis();
}
@Override
public Instant instant() {
- return Instant.ofEpochMilli(millis());
+ // Take a local copy of offset. offset can be updated concurrently
+ // by other threads (even if we haven't made it volatile) so we will
+ // work with a local copy.
+ long localOffset = offset;
+ long adjustment = VM.getNanoTimeAdjustment(localOffset);
+
+ if (adjustment == -1) {
+ // -1 is a sentinel value returned by VM.getNanoTimeAdjustment
+ // when the offset it is given is too far off the current UTC
+ // time. In principle, this should not happen unless the
+ // JVM has run for more than ~136 years (not likely) or
+ // someone is fiddling with the system time, or the offset is
+ // by chance at 1ns in the future (very unlikely).
+ // We can easily recover from all these conditions by bringing
+ // back the offset in range and retry.
+
+ // bring back the offset in range. We use -1024 to make
+ // it more unlikely to hit the 1ns in the future condition.
+ localOffset = System.currentTimeMillis()/1000 - 1024;
+
+ // retry
+ adjustment = VM.getNanoTimeAdjustment(localOffset);
+
+ if (adjustment == -1) {
+ // Should not happen: we just recomputed a new offset.
+ // It should have fixed the issue.
+ throw new InternalError("Offset " + localOffset + " is not in range");
+ } else {
+ // OK - recovery succeeded. Update the offset for the
+ // next call...
+ offset = localOffset;
+ }
+ }
+ return Instant.ofEpochSecond(localOffset, adjustment);
}
@Override
public boolean equals(Object obj) {
@@ -485,6 +539,12 @@
public String toString() {
return "SystemClock[" + zone + "]";
}
+ private void readObject(ObjectInputStream is)
+ throws IOException, ClassNotFoundException {
+ // ensure that offset is initialized
+ is.defaultReadObject();
+ offset = OFFSET_SEED;
+ }
}
//-----------------------------------------------------------------------
--- a/jdk/src/java.base/share/classes/java/time/chrono/Chronology.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/time/chrono/Chronology.java Wed Feb 18 19:27:49 2015 -0800
@@ -538,7 +538,14 @@
* <ul>
* <li>a leap-year must imply a year-length longer than a non leap-year.
* <li>a chronology that does not support the concept of a year must return false.
+ * <li>the correct result must be returned for all years within the
+ * valid range of years for the chronology.
* </ul>
+ * <p>
+ * Outside the range of valid years an implementation is free to return
+ * either a best guess or false.
+ * An implementation must not throw an exception, even if the year is
+ * outside the range of valid years.
*
* @param prolepticYear the proleptic-year to check, not validated for range
* @return true if the year is a leap year
--- a/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/time/chrono/HijrahChronology.java Wed Feb 18 19:27:49 2015 -0800
@@ -475,10 +475,10 @@
@Override
public boolean isLeapYear(long prolepticYear) {
checkCalendarInit();
+ if (prolepticYear < getMinimumYear() || prolepticYear > getMaximumYear()) {
+ return false;
+ }
int epochMonth = yearToEpochMonth((int) prolepticYear);
- if (epochMonth < 0 || epochMonth > maxEpochDay) {
- throw new DateTimeException("Hijrah date out of range");
- }
int len = getYearLength((int) prolepticYear);
return (len > 354);
}
--- a/jdk/src/java.base/share/classes/java/time/chrono/JapaneseEra.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/time/chrono/JapaneseEra.java Wed Feb 18 19:27:49 2015 -0800
@@ -195,10 +195,11 @@
* @throws DateTimeException if the value is invalid
*/
public static JapaneseEra of(int japaneseEra) {
- if (japaneseEra < MEIJI.eraValue || japaneseEra + ERA_OFFSET > KNOWN_ERAS.length) {
+ int i = ordinal(japaneseEra);
+ if (i < 0 || i >= KNOWN_ERAS.length) {
throw new DateTimeException("Invalid era: " + japaneseEra);
}
- return KNOWN_ERAS[ordinal(japaneseEra)];
+ return KNOWN_ERAS[i];
}
/**
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatter.java Wed Feb 18 19:27:49 2015 -0800
@@ -117,8 +117,9 @@
* {@code parse(CharSequence text, DateTimeFormatter formatter)}.
* <p>For example:
* <blockquote><pre>
+ * LocalDate date = LocalDate.now();
* String text = date.format(formatter);
- * LocalDate date = LocalDate.parse(text, formatter);
+ * LocalDate parsedDate = LocalDate.parse(text, formatter);
* </pre></blockquote>
* <p>
* In addition to the format, formatters can be created with desired Locale,
@@ -265,9 +266,10 @@
* <p>
* For example:
* <blockquote><pre>
+ * LocalDate date = LocalDate.now();
* DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy MM dd");
* String text = date.format(formatter);
- * LocalDate date = LocalDate.parse(text, formatter);
+ * LocalDate parsedDate = LocalDate.parse(text, formatter);
* </pre></blockquote>
* <p>
* All letters 'A' to 'Z' and 'a' to 'z' are reserved as pattern letters. The
--- a/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/time/format/DateTimeFormatterBuilder.java Wed Feb 18 19:27:49 2015 -0800
@@ -849,6 +849,7 @@
* @param fractionalDigits the number of fractional second digits to format with,
* from 0 to 9, or -1 to use as many digits as necessary
* @return this, for chaining, not null
+ * @throws IllegalArgumentException if the number of fractional digits is invalid
*/
public DateTimeFormatterBuilder appendInstant(int fractionalDigits) {
if (fractionalDigits < -1 || fractionalDigits > 9) {
@@ -909,6 +910,7 @@
* @param pattern the pattern to use, not null
* @param noOffsetText the text to use when the offset is zero, not null
* @return this, for chaining, not null
+ * @throws IllegalArgumentException if the pattern is invalid
*/
public DateTimeFormatterBuilder appendOffset(String pattern, String noOffsetText) {
appendInternal(new OffsetIdPrinterParser(pattern, noOffsetText));
--- a/jdk/src/java.base/share/classes/java/time/package-info.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/time/package-info.java Wed Feb 18 19:27:49 2015 -0800
@@ -65,7 +65,7 @@
* The main API for dates, times, instants, and durations.
* </p>
* <p>
- * The classes defined here represent the principal date-time concepts,
+ * The classes defined here represent the principle date-time concepts,
* including instants, durations, dates, times, time-zones and periods.
* They are based on the ISO calendar system, which is the <i>de facto</i> world
* calendar following the proleptic Gregorian rules.
@@ -247,8 +247,8 @@
* </ul>
* <p>
* Multiple calendar systems is an awkward addition to the design challenges.
- * The first principal is that most users want the standard ISO calendar system.
- * As such, the main classes are ISO-only. The second principal is that most of those that want a
+ * The first principle is that most users want the standard ISO calendar system.
+ * As such, the main classes are ISO-only. The second principle is that most of those that want a
* non-ISO calendar system want it for user interaction, thus it is a UI localization issue.
* As such, date and time objects should be held as ISO objects in the data model and persistent
* storage, only being converted to and from a local calendar for display.
--- a/jdk/src/java.base/share/classes/java/util/ComparableTimSort.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/util/ComparableTimSort.java Wed Feb 18 19:27:49 2015 -0800
@@ -147,7 +147,7 @@
*/
int stackLen = (len < 120 ? 5 :
len < 1542 ? 10 :
- len < 119151 ? 24 : 40);
+ len < 119151 ? 24 : 49);
runBase = new int[stackLen];
runLen = new int[stackLen];
}
--- a/jdk/src/java.base/share/classes/java/util/Formatter.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/util/Formatter.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2013, 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
@@ -57,6 +57,7 @@
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalAccessor;
import java.time.temporal.TemporalQueries;
+import java.time.temporal.UnsupportedTemporalTypeException;
import sun.misc.DoubleConsts;
import sun.misc.FormattedFloatingDecimal;
@@ -4056,7 +4057,12 @@
break;
}
case DateTime.NANOSECOND: { // 'N' (000000000 - 999999999)
- int i = t.get(ChronoField.MILLI_OF_SECOND) * 1000000;
+ int i;
+ try {
+ i = t.get(ChronoField.NANO_OF_SECOND);
+ } catch (UnsupportedTemporalTypeException u) {
+ i = t.get(ChronoField.MILLI_OF_SECOND) * 1000000;
+ }
Flags flags = Flags.ZERO_PAD;
sb.append(localizedMagnitude(null, i, flags, 9, l));
break;
--- a/jdk/src/java.base/share/classes/java/util/Optional.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/util/Optional.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -28,6 +28,7 @@
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
+import java.util.stream.Stream;
/**
* A container object which may or may not contain a non-null value.
@@ -155,8 +156,9 @@
* null
*/
public void ifPresent(Consumer<? super T> consumer) {
- if (value != null)
+ if (value != null) {
consumer.accept(value);
+ }
}
/**
@@ -172,10 +174,11 @@
*/
public Optional<T> filter(Predicate<? super T> predicate) {
Objects.requireNonNull(predicate);
- if (!isPresent())
+ if (!isPresent()) {
return this;
- else
+ } else {
return predicate.test(value) ? this : empty();
+ }
}
/**
@@ -209,9 +212,9 @@
*/
public<U> Optional<U> map(Function<? super T, ? extends U> mapper) {
Objects.requireNonNull(mapper);
- if (!isPresent())
+ if (!isPresent()) {
return empty();
- else {
+ } else {
return Optional.ofNullable(mapper.apply(value));
}
}
@@ -235,14 +238,37 @@
*/
public<U> Optional<U> flatMap(Function<? super T, Optional<U>> mapper) {
Objects.requireNonNull(mapper);
- if (!isPresent())
+ if (!isPresent()) {
return empty();
- else {
+ } else {
return Objects.requireNonNull(mapper.apply(value));
}
}
/**
+ * If a value is present return a sequential {@link Stream} containing only
+ * that value, otherwise return an empty {@code Stream}.
+ *
+ * @apiNote This method can be used to transform a {@code Stream} of
+ * optional elements to a {@code Stream} of present value elements:
+ *
+ * <pre>{@code
+ * Stream<Optional<T>> os = ..
+ * Stream<T> s = os.flatMap(Optional::stream)
+ * }</pre>
+ *
+ * @return the optional value as a {@code Stream}
+ * @since 1.9
+ */
+ public Stream<T> stream() {
+ if (!isPresent()) {
+ return Stream.empty();
+ } else {
+ return Stream.of(value);
+ }
+ }
+
+ /**
* Return the value if present, otherwise return {@code other}.
*
* @param other the value to be returned if there is no value present, may
--- a/jdk/src/java.base/share/classes/java/util/OptionalDouble.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/util/OptionalDouble.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -27,6 +27,7 @@
import java.util.function.DoubleConsumer;
import java.util.function.DoubleSupplier;
import java.util.function.Supplier;
+import java.util.stream.DoubleStream;
/**
* A container object which may or may not contain a {@code double} value.
@@ -138,8 +139,32 @@
* null
*/
public void ifPresent(DoubleConsumer consumer) {
- if (isPresent)
+ if (isPresent) {
consumer.accept(value);
+ }
+ }
+
+ /**
+ * If a value is present return a sequential {@link DoubleStream} containing
+ * only that value, otherwise return an empty {@code DoubleStream}.
+ *
+ * @apiNote This method can be used to transform a {@code Stream} of
+ * optional doubles to a {@code DoubleStream} of present doubles:
+ *
+ * <pre>{@code
+ * Stream<OptionalDouble> os = ..
+ * DoubleStream s = os.flatMapToDouble(OptionalDouble::stream)
+ * }</pre>
+ *
+ * @return the optional value as a {@code DoubleStream}
+ * @since 1.9
+ */
+ public DoubleStream stream() {
+ if (isPresent) {
+ return DoubleStream.of(value);
+ } else {
+ return DoubleStream.empty();
+ }
}
/**
@@ -182,7 +207,7 @@
* @throws NullPointerException if no value is present and
* {@code exceptionSupplier} is null
*/
- public<X extends Throwable> double orElseThrow(Supplier<X> exceptionSupplier) throws X {
+ public<X extends Throwable> double orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
if (isPresent) {
return value;
} else {
--- a/jdk/src/java.base/share/classes/java/util/OptionalInt.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/util/OptionalInt.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -27,6 +27,7 @@
import java.util.function.IntConsumer;
import java.util.function.IntSupplier;
import java.util.function.Supplier;
+import java.util.stream.IntStream;
/**
* A container object which may or may not contain a {@code int} value.
@@ -138,8 +139,32 @@
* null
*/
public void ifPresent(IntConsumer consumer) {
- if (isPresent)
+ if (isPresent) {
consumer.accept(value);
+ }
+ }
+
+ /**
+ * If a value is present return a sequential {@link IntStream} containing
+ * only that value, otherwise return an empty {@code IntStream}.
+ *
+ * @apiNote This method can be used to transform a {@code Stream} of
+ * optional integers to an {@code IntStream} of present integers:
+ *
+ * <pre>{@code
+ * Stream<OptionalInt> os = ..
+ * IntStream s = os.flatMapToInt(OptionalInt::stream)
+ * }</pre>
+ *
+ * @return the optional value as an {@code IntStream}
+ * @since 1.9
+ */
+ public IntStream stream() {
+ if (isPresent) {
+ return IntStream.of(value);
+ } else {
+ return IntStream.empty();
+ }
}
/**
@@ -182,7 +207,7 @@
* @throws NullPointerException if no value is present and
* {@code exceptionSupplier} is null
*/
- public<X extends Throwable> int orElseThrow(Supplier<X> exceptionSupplier) throws X {
+ public<X extends Throwable> int orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
if (isPresent) {
return value;
} else {
--- a/jdk/src/java.base/share/classes/java/util/OptionalLong.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/util/OptionalLong.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -27,6 +27,7 @@
import java.util.function.LongConsumer;
import java.util.function.LongSupplier;
import java.util.function.Supplier;
+import java.util.stream.LongStream;
/**
* A container object which may or may not contain a {@code long} value.
@@ -138,8 +139,32 @@
* null
*/
public void ifPresent(LongConsumer consumer) {
- if (isPresent)
+ if (isPresent) {
consumer.accept(value);
+ }
+ }
+
+ /**
+ * If a value is present return a sequential {@link LongStream} containing
+ * only that value, otherwise return an empty {@code LongStream}.
+ *
+ * @apiNote This method can be used to transform a {@code Stream} of
+ * optional longs to a {@code LongStream} of present longs:
+ *
+ * <pre>{@code
+ * Stream<OptionalLong> os = ..
+ * LongStream s = os.flatMapToLong(OptionalLong::stream)
+ * }</pre>
+ *
+ * @return the optional value as a {@code LongStream}
+ * @since 1.9
+ */
+ public LongStream stream() {
+ if (isPresent) {
+ return LongStream.of(value);
+ } else {
+ return LongStream.empty();
+ }
}
/**
@@ -182,7 +207,7 @@
* @throws NullPointerException if no value is present and
* {@code exceptionSupplier} is null
*/
- public<X extends Throwable> long orElseThrow(Supplier<X> exceptionSupplier) throws X {
+ public<X extends Throwable> long orElseThrow(Supplier<? extends X> exceptionSupplier) throws X {
if (isPresent) {
return value;
} else {
--- a/jdk/src/java.base/share/classes/java/util/TimSort.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/util/TimSort.java Wed Feb 18 19:27:49 2015 -0800
@@ -177,7 +177,7 @@
*/
int stackLen = (len < 120 ? 5 :
len < 1542 ? 10 :
- len < 119151 ? 24 : 40);
+ len < 119151 ? 24 : 49);
runBase = new int[stackLen];
runLen = new int[stackLen];
}
--- a/jdk/src/java.base/share/classes/java/util/concurrent/TimeUnit.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/TimeUnit.java Wed Feb 18 19:27:49 2015 -0800
@@ -131,6 +131,7 @@
/**
* Time unit representing sixty seconds
+ * @since 1.6
*/
MINUTES {
public long toNanos(long d) { return x(d, C4/C0, MAX/(C4/C0)); }
@@ -146,6 +147,7 @@
/**
* Time unit representing sixty minutes
+ * @since 1.6
*/
HOURS {
public long toNanos(long d) { return x(d, C5/C0, MAX/(C5/C0)); }
@@ -161,6 +163,7 @@
/**
* Time unit representing twenty four hours
+ * @since 1.6
*/
DAYS {
public long toNanos(long d) { return x(d, C6/C0, MAX/(C6/C0)); }
--- a/jdk/src/java.base/share/classes/java/util/stream/BaseStream.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/util/stream/BaseStream.java Wed Feb 18 19:27:49 2015 -0800
@@ -79,6 +79,14 @@
* <p>This is a <a href="package-summary.html#StreamOps">terminal
* operation</a>.
*
+ * <p>
+ * The returned spliterator should report the set of characteristics derived
+ * from the stream pipeline (namely the characteristics derived from the
+ * stream source spliterator and the intermediate operations).
+ * Implementations may report a sub-set of those characteristics. For
+ * example, it may be too expensive to compute the entire set for some or
+ * all possible stream pipelines.
+ *
* @return the element spliterator for this stream
*/
Spliterator<T> spliterator();
--- a/jdk/src/java.base/share/classes/java/util/stream/Stream.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/java/util/stream/Stream.java Wed Feb 18 19:27:49 2015 -0800
@@ -988,6 +988,21 @@
}
/**
+ * Returns a sequential {@code Stream} containing a single element, if
+ * non-null, otherwise returns an empty {@code Stream}.
+ *
+ * @param t the single element
+ * @param <T> the type of stream elements
+ * @return a stream with a single element if the specified element
+ * is non-null, otherwise an empty stream
+ * @since 1.9
+ */
+ public static<T> Stream<T> ofNullable(T t) {
+ return t == null ? Stream.empty()
+ : StreamSupport.stream(new Streams.StreamBuilderImpl<>(t), false);
+ }
+
+ /**
* Returns a sequential ordered stream whose elements are the specified values.
*
* @param <T> the type of stream elements
--- a/jdk/src/java.base/share/classes/sun/misc/VM.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/sun/misc/VM.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -402,6 +402,36 @@
*/
public static native long getegid();
+ /**
+ * Get a nanosecond time stamp adjustment in the form of a single long.
+ *
+ * This value can be used to create an instant using
+ * {@link java.time.Instant#ofEpochSecond(long, long)
+ * java.time.Instant.ofEpochSecond(offsetInSeconds,
+ * getNanoTimeAdjustment(offsetInSeconds))}.
+ * <p>
+ * The value returned has the best resolution available to the JVM on
+ * the current system.
+ * This is usually down to microseconds - or tenth of microseconds -
+ * depending on the OS/Hardware and the JVM implementation.
+ *
+ * @param offsetInSeconds The offset in seconds from which the nanosecond
+ * time stamp should be computed.
+ *
+ * @apiNote The offset should be recent enough - so that
+ * {@code offsetInSeconds} is within {@code +/- 2^32} seconds of the
+ * current UTC time. If the offset is too far off, {@code -1} will be
+ * returned. As such, {@code -1} must not be considered as a valid
+ * nano time adjustment, but as an exception value indicating
+ * that an offset closer to the current time should be used.
+ *
+ * @return A nanosecond time stamp adjustment in the form of a single long.
+ * If the offset is too far off the current time, this method returns -1.
+ * In that case, the caller should call this method again, passing a
+ * more accurate offset.
+ */
+ public static native long getNanoTimeAdjustment(long offsetInSeconds);
+
static {
initialize();
}
--- a/jdk/src/java.base/share/classes/sun/nio/cs/SingleByte.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/sun/nio/cs/SingleByte.java Wed Feb 18 19:27:49 2015 -0800
@@ -160,22 +160,18 @@
byte[] da = dst.array();
int dp = dst.arrayOffset() + dst.position();
int dl = dst.arrayOffset() + dst.limit();
+ int len = Math.min(dl - dp, sl - sp);
- CoderResult cr = CoderResult.UNDERFLOW;
- if ((dl - dp) < (sl - sp)) {
- sl = sp + (dl - dp);
- cr = CoderResult.OVERFLOW;
- }
-
- while (sp < sl) {
+ while (len-- > 0) {
char c = sa[sp];
int b = encode(c);
if (b == UNMAPPABLE_ENCODING) {
if (Character.isSurrogate(c)) {
if (sgp == null)
sgp = new Surrogate.Parser();
- if (sgp.parse(c, sa, sp, sl) < 0)
+ if (sgp.parse(c, sa, sp, sl) < 0) {
return withResult(sgp.error(), src, sp, dst, dp);
+ }
return withResult(sgp.unmappableResult(), src, sp, dst, dp);
}
return withResult(CoderResult.unmappableForLength(1),
@@ -184,7 +180,8 @@
da[dp++] = (byte)b;
sp++;
}
- return withResult(cr, src, sp, dst, dp);
+ return withResult(sp < sl ? CoderResult.OVERFLOW : CoderResult.UNDERFLOW,
+ src, sp, dst, dp);
}
private CoderResult encodeBufferLoop(CharBuffer src, ByteBuffer dst) {
--- a/jdk/src/java.base/share/classes/sun/nio/cs/StreamEncoder.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/sun/nio/cs/StreamEncoder.java Wed Feb 18 19:27:49 2015 -0800
@@ -243,8 +243,11 @@
if (cr.isUnderflow()) {
if (lcb.hasRemaining()) {
leftoverChar = lcb.get();
- if (cb != null && cb.hasRemaining())
- flushLeftoverChar(cb, endOfInput);
+ if (cb != null && cb.hasRemaining()) {
+ lcb.clear();
+ lcb.put(leftoverChar).put(cb.get()).flip();
+ continue;
+ }
return;
}
break;
@@ -265,24 +268,24 @@
CharBuffer cb = CharBuffer.wrap(cbuf, off, len);
if (haveLeftoverChar)
- flushLeftoverChar(cb, false);
+ flushLeftoverChar(cb, false);
while (cb.hasRemaining()) {
- CoderResult cr = encoder.encode(cb, bb, false);
- if (cr.isUnderflow()) {
- assert (cb.remaining() <= 1) : cb.remaining();
- if (cb.remaining() == 1) {
- haveLeftoverChar = true;
- leftoverChar = cb.get();
+ CoderResult cr = encoder.encode(cb, bb, false);
+ if (cr.isUnderflow()) {
+ assert (cb.remaining() <= 1) : cb.remaining();
+ if (cb.remaining() == 1) {
+ haveLeftoverChar = true;
+ leftoverChar = cb.get();
+ }
+ break;
}
- break;
- }
- if (cr.isOverflow()) {
- assert bb.position() > 0;
- writeBytes();
- continue;
- }
- cr.throwException();
+ if (cr.isOverflow()) {
+ assert bb.position() > 0;
+ writeBytes();
+ continue;
+ }
+ cr.throwException();
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/acl/AclEntryImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+package sun.security.acl;
+
+import java.util.*;
+import java.security.Principal;
+import java.security.acl.*;
+
+/**
+ * This is a class that describes one entry that associates users
+ * or groups with permissions in the ACL.
+ * The entry may be used as a way of granting or denying permissions.
+ * @author Satish Dharmaraj
+ */
+public class AclEntryImpl implements AclEntry {
+ private Principal user = null;
+ private Vector<Permission> permissionSet = new Vector<>(10, 10);
+ private boolean negative = false;
+
+ /**
+ * Construct an ACL entry that associates a user with permissions
+ * in the ACL.
+ * @param user The user that is associated with this entry.
+ */
+ public AclEntryImpl(Principal user) {
+ this.user = user;
+ }
+
+ /**
+ * Construct a null ACL entry
+ */
+ public AclEntryImpl() {
+ }
+
+ /**
+ * Sets the principal in the entity. If a group or a
+ * principal had already been set, a false value is
+ * returned, otherwise a true value is returned.
+ * @param user The user that is associated with this entry.
+ * @return true if the principal is set, false if there is
+ * one already.
+ */
+ public boolean setPrincipal(Principal user) {
+ if (this.user != null)
+ return false;
+ this.user = user;
+ return true;
+ }
+
+ /**
+ * This method sets the ACL to have negative permissions.
+ * That is the user or group is denied the permission set
+ * specified in the entry.
+ */
+ public void setNegativePermissions() {
+ negative = true;
+ }
+
+ /**
+ * Returns true if this is a negative ACL.
+ */
+ public boolean isNegative() {
+ return negative;
+ }
+
+ /**
+ * A principal or a group can be associated with multiple
+ * permissions. This method adds a permission to the ACL entry.
+ * @param permission The permission to be associated with
+ * the principal or the group in the entry.
+ * @return true if the permission was added, false if the
+ * permission was already part of the permission set.
+ */
+ public boolean addPermission(Permission permission) {
+
+ if (permissionSet.contains(permission))
+ return false;
+
+ permissionSet.addElement(permission);
+
+ return true;
+ }
+
+ /**
+ * The method disassociates the permission from the Principal
+ * or the Group in this ACL entry.
+ * @param permission The permission to be disassociated with
+ * the principal or the group in the entry.
+ * @return true if the permission is removed, false if the
+ * permission is not part of the permission set.
+ */
+ public boolean removePermission(Permission permission) {
+ return permissionSet.removeElement(permission);
+ }
+
+ /**
+ * Checks if the passed permission is part of the allowed
+ * permission set in this entry.
+ * @param permission The permission that has to be part of
+ * the permission set in the entry.
+ * @return true if the permission passed is part of the
+ * permission set in the entry, false otherwise.
+ */
+ public boolean checkPermission(Permission permission) {
+ return permissionSet.contains(permission);
+ }
+
+ /**
+ * return an enumeration of the permissions in this ACL entry.
+ */
+ public Enumeration<Permission> permissions() {
+ return permissionSet.elements();
+ }
+
+ /**
+ * Return a string representation of the contents of the ACL entry.
+ */
+ public String toString() {
+ StringBuffer s = new StringBuffer();
+ if (negative)
+ s.append("-");
+ else
+ s.append("+");
+ if (user instanceof Group)
+ s.append("Group.");
+ else
+ s.append("User.");
+ s.append(user + "=");
+ Enumeration<Permission> e = permissions();
+ while(e.hasMoreElements()) {
+ Permission p = e.nextElement();
+ s.append(p);
+ if (e.hasMoreElements())
+ s.append(",");
+ }
+ return new String(s);
+ }
+
+ /**
+ * Clones an AclEntry.
+ */
+ @SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
+ public synchronized Object clone() {
+ AclEntryImpl cloned;
+ cloned = new AclEntryImpl(user);
+ cloned.permissionSet = (Vector<Permission>) permissionSet.clone();
+ cloned.negative = negative;
+ return cloned;
+ }
+
+ /**
+ * Return the Principal associated in this ACL entry.
+ * The method returns null if the entry uses a group
+ * instead of a principal.
+ */
+ public Principal getPrincipal() {
+ return user;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/acl/AclImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,408 @@
+/*
+ * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.acl;
+
+import java.io.*;
+import java.util.*;
+import java.security.Principal;
+import java.security.acl.*;
+
+/**
+ * An Access Control List (ACL) is encapsulated by this class.
+ * @author Satish Dharmaraj
+ */
+public class AclImpl extends OwnerImpl implements Acl {
+ //
+ // Maintain four tables. one each for positive and negative
+ // ACLs. One each depending on whether the entity is a group
+ // or principal.
+ //
+ private Hashtable<Principal, AclEntry> allowedUsersTable =
+ new Hashtable<>(23);
+ private Hashtable<Principal, AclEntry> allowedGroupsTable =
+ new Hashtable<>(23);
+ private Hashtable<Principal, AclEntry> deniedUsersTable =
+ new Hashtable<>(23);
+ private Hashtable<Principal, AclEntry> deniedGroupsTable =
+ new Hashtable<>(23);
+ private String aclName = null;
+ private Vector<Permission> zeroSet = new Vector<>(1,1);
+
+
+ /**
+ * Constructor for creating an empty ACL.
+ */
+ public AclImpl(Principal owner, String name) {
+ super(owner);
+ try {
+ setName(owner, name);
+ } catch (Exception e) {}
+ }
+
+ /**
+ * Sets the name of the ACL.
+ * @param caller the principal who is invoking this method.
+ * @param name the name of the ACL.
+ * @exception NotOwnerException if the caller principal is
+ * not on the owners list of the Acl.
+ */
+ public void setName(Principal caller, String name)
+ throws NotOwnerException
+ {
+ if (!isOwner(caller))
+ throw new NotOwnerException();
+
+ aclName = name;
+ }
+
+ /**
+ * Returns the name of the ACL.
+ * @return the name of the ACL.
+ */
+ public String getName() {
+ return aclName;
+ }
+
+ /**
+ * Adds an ACL entry to this ACL. An entry associates a
+ * group or a principal with a set of permissions. Each
+ * user or group can have one positive ACL entry and one
+ * negative ACL entry. If there is one of the type (negative
+ * or positive) already in the table, a false value is returned.
+ * The caller principal must be a part of the owners list of
+ * the ACL in order to invoke this method.
+ * @param caller the principal who is invoking this method.
+ * @param entry the ACL entry that must be added to the ACL.
+ * @return true on success, false if the entry is already present.
+ * @exception NotOwnerException if the caller principal
+ * is not on the owners list of the Acl.
+ */
+ public synchronized boolean addEntry(Principal caller, AclEntry entry)
+ throws NotOwnerException
+ {
+ if (!isOwner(caller))
+ throw new NotOwnerException();
+
+ Hashtable<Principal, AclEntry> aclTable = findTable(entry);
+ Principal key = entry.getPrincipal();
+
+ if (aclTable.get(key) != null)
+ return false;
+
+ aclTable.put(key, entry);
+ return true;
+ }
+
+ /**
+ * Removes an ACL entry from this ACL.
+ * The caller principal must be a part of the owners list of the ACL
+ * in order to invoke this method.
+ * @param caller the principal who is invoking this method.
+ * @param entry the ACL entry that must be removed from the ACL.
+ * @return true on success, false if the entry is not part of the ACL.
+ * @exception NotOwnerException if the caller principal is not
+ * the owners list of the Acl.
+ */
+ public synchronized boolean removeEntry(Principal caller, AclEntry entry)
+ throws NotOwnerException
+ {
+ if (!isOwner(caller))
+ throw new NotOwnerException();
+
+ Hashtable<Principal, AclEntry> aclTable = findTable(entry);
+ Principal key = entry.getPrincipal();
+
+ AclEntry o = aclTable.remove(key);
+ return (o != null);
+ }
+
+ /**
+ * This method returns the set of allowed permissions for the
+ * specified principal. This set of allowed permissions is calculated
+ * as follows:
+ *
+ * If there is no entry for a group or a principal an empty permission
+ * set is assumed.
+ *
+ * The group positive permission set is the union of all
+ * the positive permissions of each group that the individual belongs to.
+ * The group negative permission set is the union of all
+ * the negative permissions of each group that the individual belongs to.
+ * If there is a specific permission that occurs in both
+ * the postive permission set and the negative permission set,
+ * it is removed from both. The group positive and negatoive permission
+ * sets are calculated.
+ *
+ * The individial positive permission set and the individual negative
+ * permission set is then calculated. Again abscence of an entry means
+ * the empty set.
+ *
+ * The set of permissions granted to the principal is then calculated using
+ * the simple rule: Individual permissions always override the Group permissions.
+ * Specifically, individual negative permission set (specific
+ * denial of permissions) overrides the group positive permission set.
+ * And the individual positive permission set override the group negative
+ * permission set.
+ *
+ * @param user the principal for which the ACL entry is returned.
+ * @return The resulting permission set that the principal is allowed.
+ */
+ public synchronized Enumeration<Permission> getPermissions(Principal user) {
+
+ Enumeration<Permission> individualPositive;
+ Enumeration<Permission> individualNegative;
+ Enumeration<Permission> groupPositive;
+ Enumeration<Permission> groupNegative;
+
+ //
+ // canonicalize the sets. That is remove common permissions from
+ // positive and negative sets.
+ //
+ groupPositive =
+ subtract(getGroupPositive(user), getGroupNegative(user));
+ groupNegative =
+ subtract(getGroupNegative(user), getGroupPositive(user));
+ individualPositive =
+ subtract(getIndividualPositive(user), getIndividualNegative(user));
+ individualNegative =
+ subtract(getIndividualNegative(user), getIndividualPositive(user));
+
+ //
+ // net positive permissions is individual positive permissions
+ // plus (group positive - individual negative).
+ //
+ Enumeration<Permission> temp1 =
+ subtract(groupPositive, individualNegative);
+ Enumeration<Permission> netPositive =
+ union(individualPositive, temp1);
+
+ // recalculate the enumeration since we lost it in performing the
+ // subtraction
+ //
+ individualPositive =
+ subtract(getIndividualPositive(user), getIndividualNegative(user));
+ individualNegative =
+ subtract(getIndividualNegative(user), getIndividualPositive(user));
+
+ //
+ // net negative permissions is individual negative permissions
+ // plus (group negative - individual positive).
+ //
+ temp1 = subtract(groupNegative, individualPositive);
+ Enumeration<Permission> netNegative = union(individualNegative, temp1);
+
+ return subtract(netPositive, netNegative);
+ }
+
+ /**
+ * This method checks whether or not the specified principal
+ * has the required permission. If permission is denied
+ * permission false is returned, a true value is returned otherwise.
+ * This method does not authenticate the principal. It presumes that
+ * the principal is a valid authenticated principal.
+ * @param principal the name of the authenticated principal
+ * @param permission the permission that the principal must have.
+ * @return true of the principal has the permission desired, false
+ * otherwise.
+ */
+ public boolean checkPermission(Principal principal, Permission permission)
+ {
+ Enumeration<Permission> permSet = getPermissions(principal);
+ while (permSet.hasMoreElements()) {
+ Permission p = permSet.nextElement();
+ if (p.equals(permission))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * returns an enumeration of the entries in this ACL.
+ */
+ public synchronized Enumeration<AclEntry> entries() {
+ return new AclEnumerator(this,
+ allowedUsersTable, allowedGroupsTable,
+ deniedUsersTable, deniedGroupsTable);
+ }
+
+ /**
+ * return a stringified version of the
+ * ACL.
+ */
+ public String toString() {
+ StringBuilder sb = new StringBuilder();
+ Enumeration<AclEntry> entries = entries();
+ while (entries.hasMoreElements()) {
+ AclEntry entry = entries.nextElement();
+ sb.append(entry.toString().trim());
+ sb.append("\n");
+ }
+
+ return sb.toString();
+ }
+
+ //
+ // Find the table that this entry belongs to. There are 4
+ // tables that are maintained. One each for postive and
+ // negative ACLs and one each for groups and users.
+ // This method figures out which
+ // table is the one that this AclEntry belongs to.
+ //
+ private Hashtable<Principal, AclEntry> findTable(AclEntry entry) {
+ Hashtable<Principal, AclEntry> aclTable = null;
+
+ Principal p = entry.getPrincipal();
+ if (p instanceof Group) {
+ if (entry.isNegative())
+ aclTable = deniedGroupsTable;
+ else
+ aclTable = allowedGroupsTable;
+ } else {
+ if (entry.isNegative())
+ aclTable = deniedUsersTable;
+ else
+ aclTable = allowedUsersTable;
+ }
+ return aclTable;
+ }
+
+ //
+ // returns the set e1 U e2.
+ //
+ private static Enumeration<Permission> union(Enumeration<Permission> e1,
+ Enumeration<Permission> e2) {
+ Vector<Permission> v = new Vector<>(20, 20);
+
+ while (e1.hasMoreElements())
+ v.addElement(e1.nextElement());
+
+ while (e2.hasMoreElements()) {
+ Permission o = e2.nextElement();
+ if (!v.contains(o))
+ v.addElement(o);
+ }
+
+ return v.elements();
+ }
+
+ //
+ // returns the set e1 - e2.
+ //
+ private Enumeration<Permission> subtract(Enumeration<Permission> e1,
+ Enumeration<Permission> e2) {
+ Vector<Permission> v = new Vector<>(20, 20);
+
+ while (e1.hasMoreElements())
+ v.addElement(e1.nextElement());
+
+ while (e2.hasMoreElements()) {
+ Permission o = e2.nextElement();
+ if (v.contains(o))
+ v.removeElement(o);
+ }
+
+ return v.elements();
+ }
+
+ private Enumeration<Permission> getGroupPositive(Principal user) {
+ Enumeration<Permission> groupPositive = zeroSet.elements();
+ Enumeration<Principal> e = allowedGroupsTable.keys();
+ while (e.hasMoreElements()) {
+ Group g = (Group)e.nextElement();
+ if (g.isMember(user)) {
+ AclEntry ae = allowedGroupsTable.get(g);
+ groupPositive = union(ae.permissions(), groupPositive);
+ }
+ }
+ return groupPositive;
+ }
+
+ private Enumeration<Permission> getGroupNegative(Principal user) {
+ Enumeration<Permission> groupNegative = zeroSet.elements();
+ Enumeration<Principal> e = deniedGroupsTable.keys();
+ while (e.hasMoreElements()) {
+ Group g = (Group)e.nextElement();
+ if (g.isMember(user)) {
+ AclEntry ae = deniedGroupsTable.get(g);
+ groupNegative = union(ae.permissions(), groupNegative);
+ }
+ }
+ return groupNegative;
+ }
+
+ private Enumeration<Permission> getIndividualPositive(Principal user) {
+ Enumeration<Permission> individualPositive = zeroSet.elements();
+ AclEntry ae = allowedUsersTable.get(user);
+ if (ae != null)
+ individualPositive = ae.permissions();
+ return individualPositive;
+ }
+
+ private Enumeration<Permission> getIndividualNegative(Principal user) {
+ Enumeration<Permission> individualNegative = zeroSet.elements();
+ AclEntry ae = deniedUsersTable.get(user);
+ if (ae != null)
+ individualNegative = ae.permissions();
+ return individualNegative;
+ }
+}
+
+final class AclEnumerator implements Enumeration<AclEntry> {
+ Acl acl;
+ Enumeration<AclEntry> u1, u2, g1, g2;
+
+ AclEnumerator(Acl acl, Hashtable<?,AclEntry> u1, Hashtable<?,AclEntry> g1,
+ Hashtable<?,AclEntry> u2, Hashtable<?,AclEntry> g2) {
+ this.acl = acl;
+ this.u1 = u1.elements();
+ this.u2 = u2.elements();
+ this.g1 = g1.elements();
+ this.g2 = g2.elements();
+ }
+
+ public boolean hasMoreElements() {
+ return (u1.hasMoreElements() ||
+ u2.hasMoreElements() ||
+ g1.hasMoreElements() ||
+ g2.hasMoreElements());
+ }
+
+ public AclEntry nextElement()
+ {
+ AclEntry o;
+ synchronized (acl) {
+ if (u1.hasMoreElements())
+ return u1.nextElement();
+ if (u2.hasMoreElements())
+ return u2.nextElement();
+ if (g1.hasMoreElements())
+ return g1.nextElement();
+ if (g2.hasMoreElements())
+ return g2.nextElement();
+ }
+ throw new NoSuchElementException("Acl Enumerator");
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/acl/AllPermissionsImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 1996, 1997, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.acl;
+
+import java.security.Principal;
+import java.security.acl.*;
+
+/**
+ * This class implements the principal interface for the set of all permissions.
+ * @author Satish Dharmaraj
+ */
+public class AllPermissionsImpl extends PermissionImpl {
+
+ public AllPermissionsImpl(String s) {
+ super(s);
+ }
+
+ /**
+ * This function returns true if the permission passed matches the permission represented in
+ * this interface.
+ * @param another The Permission object to compare with.
+ * @returns true always
+ */
+ public boolean equals(Permission another) {
+ return true;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/acl/GroupImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,186 @@
+/*
+ * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.acl;
+
+import java.util.*;
+import java.security.*;
+import java.security.acl.*;
+
+/**
+ * This class implements a group of principals.
+ * @author Satish Dharmaraj
+ */
+public class GroupImpl implements Group {
+ private Vector<Principal> groupMembers = new Vector<>(50, 100);
+ private String group;
+
+ /**
+ * Constructs a Group object with no members.
+ * @param groupName the name of the group
+ */
+ public GroupImpl(String groupName) {
+ this.group = groupName;
+ }
+
+ /**
+ * adds the specified member to the group.
+ * @param user The principal to add to the group.
+ * @return true if the member was added - false if the
+ * member could not be added.
+ */
+ public boolean addMember(Principal user) {
+ if (groupMembers.contains(user))
+ return false;
+
+ // do not allow groups to be added to itself.
+ if (group.equals(user.toString()))
+ throw new IllegalArgumentException();
+
+ groupMembers.addElement(user);
+ return true;
+ }
+
+ /**
+ * removes the specified member from the group.
+ * @param user The principal to remove from the group.
+ * @param true if the principal was removed false if
+ * the principal was not a member
+ */
+ public boolean removeMember(Principal user) {
+ return groupMembers.removeElement(user);
+ }
+
+ /**
+ * returns the enumeration of the members in the group.
+ */
+ public Enumeration<? extends Principal> members() {
+ return groupMembers.elements();
+ }
+
+ /**
+ * This function returns true if the group passed matches
+ * the group represented in this interface.
+ * @param another The group to compare this group to.
+ */
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj instanceof Group == false) {
+ return false;
+ }
+ Group another = (Group)obj;
+ return group.equals(another.toString());
+ }
+
+ // equals(Group) for compatibility
+ public boolean equals(Group another) {
+ return equals((Object)another);
+ }
+
+ /**
+ * Prints a stringified version of the group.
+ */
+ public String toString() {
+ return group;
+ }
+
+ /**
+ * return a hashcode for the principal.
+ */
+ public int hashCode() {
+ return group.hashCode();
+ }
+
+ /**
+ * returns true if the passed principal is a member of the group.
+ * @param member The principal whose membership must be checked for.
+ * @return true if the principal is a member of this group,
+ * false otherwise
+ */
+ public boolean isMember(Principal member) {
+
+ //
+ // if the member is part of the group (common case), return true.
+ // if not, recursively search depth first in the group looking for the
+ // principal.
+ //
+ if (groupMembers.contains(member)) {
+ return true;
+ } else {
+ Vector<Group> alreadySeen = new Vector<>(10);
+ return isMemberRecurse(member, alreadySeen);
+ }
+ }
+
+ /**
+ * return the name of the principal.
+ */
+ public String getName() {
+ return group;
+ }
+
+ //
+ // This function is the recursive search of groups for this
+ // implementation of the Group. The search proceeds building up
+ // a vector of already seen groups. Only new groups are considered,
+ // thereby avoiding loops.
+ //
+ boolean isMemberRecurse(Principal member, Vector<Group> alreadySeen) {
+ Enumeration<? extends Principal> e = members();
+ while (e.hasMoreElements()) {
+ boolean mem = false;
+ Principal p = (Principal) e.nextElement();
+
+ // if the member is in this collection, return true
+ if (p.equals(member)) {
+ return true;
+ } else if (p instanceof GroupImpl) {
+ //
+ // if not recurse if the group has not been checked already.
+ // Can call method in this package only if the object is an
+ // instance of this class. Otherwise call the method defined
+ // in the interface. (This can lead to a loop if a mixture of
+ // implementations form a loop, but we live with this improbable
+ // case rather than clutter the interface by forcing the
+ // implementation of this method.)
+ //
+ GroupImpl g = (GroupImpl) p;
+ alreadySeen.addElement(this);
+ if (!alreadySeen.contains(g))
+ mem = g.isMemberRecurse(member, alreadySeen);
+ } else if (p instanceof Group) {
+ Group g = (Group) p;
+ if (!alreadySeen.contains(g))
+ mem = g.isMember(member);
+ }
+
+ if (mem)
+ return mem;
+ }
+ return false;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/acl/OwnerImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 1996, 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. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.acl;
+
+import java.util.*;
+import java.security.*;
+import java.security.acl.*;
+
+/**
+ * Class implementing the Owner interface. The
+ * initial owner principal is configured as
+ * part of the constructor.
+ * @author Satish Dharmaraj
+ */
+public class OwnerImpl implements Owner {
+ private Group ownerGroup;
+
+ public OwnerImpl(Principal owner) {
+ ownerGroup = new GroupImpl("AclOwners");
+ ownerGroup.addMember(owner);
+ }
+
+ /**
+ * Adds an owner. Owners can modify ACL contents and can disassociate
+ * ACLs from the objects they protect in the AclConfig interface.
+ * The caller principal must be a part of the owners list of the ACL in
+ * order to invoke this method. The initial owner is configured
+ * at ACL construction time.
+ * @param caller the principal who is invoking this method.
+ * @param owner The owner that should be added to the owners list.
+ * @return true if success, false if already an owner.
+ * @exception NotOwnerException if the caller principal is not on
+ * the owners list of the Acl.
+ */
+ public synchronized boolean addOwner(Principal caller, Principal owner)
+ throws NotOwnerException
+ {
+ if (!isOwner(caller))
+ throw new NotOwnerException();
+
+ ownerGroup.addMember(owner);
+ return false;
+ }
+
+ /**
+ * Delete owner. If this is the last owner in the ACL, an exception is
+ * raised.
+ * The caller principal must be a part of the owners list of the ACL in
+ * order to invoke this method.
+ * @param caller the principal who is invoking this method.
+ * @param owner The owner to be removed from the owners list.
+ * @return true if the owner is removed, false if the owner is not part
+ * of the owners list.
+ * @exception NotOwnerException if the caller principal is not on
+ * the owners list of the Acl.
+ * @exception LastOwnerException if there is only one owner left in the group, then
+ * deleteOwner would leave the ACL owner-less. This exception is raised in such a case.
+ */
+ public synchronized boolean deleteOwner(Principal caller, Principal owner)
+ throws NotOwnerException, LastOwnerException
+ {
+ if (!isOwner(caller))
+ throw new NotOwnerException();
+
+ Enumeration<? extends Principal> e = ownerGroup.members();
+ //
+ // check if there is atleast 2 members left.
+ //
+ Object o = e.nextElement();
+ if (e.hasMoreElements())
+ return ownerGroup.removeMember(owner);
+ else
+ throw new LastOwnerException();
+
+ }
+
+ /**
+ * returns if the given principal belongs to the owner list.
+ * @param owner The owner to check if part of the owners list
+ * @return true if the passed principal is in the owner list, false if not.
+ */
+ public synchronized boolean isOwner(Principal owner) {
+ return ownerGroup.isMember(owner);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/acl/PermissionImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.acl;
+
+import java.security.Principal;
+import java.security.acl.*;
+
+/**
+ * The PermissionImpl class implements the permission
+ * interface for permissions that are strings.
+ * @author Satish Dharmaraj
+ */
+public class PermissionImpl implements Permission {
+
+ private String permission;
+
+ /**
+ * Construct a permission object using a string.
+ * @param permission the stringified version of the permission.
+ */
+ public PermissionImpl(String permission) {
+ this.permission = permission;
+ }
+
+ /**
+ * This function returns true if the object passed matches the permission
+ * represented in this interface.
+ * @param another The Permission object to compare with.
+ * @return true if the Permission objects are equal, false otherwise
+ */
+ public boolean equals(Object another) {
+ if (another instanceof Permission) {
+ Permission p = (Permission) another;
+ return permission.equals(p.toString());
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Prints a stringified version of the permission.
+ * @return the string representation of the Permission.
+ */
+ public String toString() {
+ return permission;
+ }
+
+ /**
+ * Returns a hashcode for this PermissionImpl.
+ *
+ * @return a hashcode for this PermissionImpl.
+ */
+ public int hashCode() {
+ return toString().hashCode();
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/acl/PrincipalImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.acl;
+
+import java.security.*;
+
+/**
+ * This class implements the principal interface.
+ *
+ * @author Satish Dharmaraj
+ */
+public class PrincipalImpl implements Principal {
+
+ private String user;
+
+ /**
+ * Construct a principal from a string user name.
+ * @param user The string form of the principal name.
+ */
+ public PrincipalImpl(String user) {
+ this.user = user;
+ }
+
+ /**
+ * This function returns true if the object passed matches
+ * the principal represented in this implementation
+ * @param another the Principal to compare with.
+ * @return true if the Principal passed is the same as that
+ * encapsulated in this object, false otherwise
+ */
+ public boolean equals(Object another) {
+ if (another instanceof PrincipalImpl) {
+ PrincipalImpl p = (PrincipalImpl) another;
+ return user.equals(p.toString());
+ } else
+ return false;
+ }
+
+ /**
+ * Prints a stringified version of the principal.
+ */
+ public String toString() {
+ return user;
+ }
+
+ /**
+ * return a hashcode for the principal.
+ */
+ public int hashCode() {
+ return user.hashCode();
+ }
+
+ /**
+ * return the name of the principal.
+ */
+ public String getName() {
+ return user;
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.base/share/classes/sun/security/acl/WorldGroupImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package sun.security.acl;
+
+import java.security.*;
+
+/**
+ * This class implements a group of principals.
+ * @author Satish Dharmaraj
+ */
+public class WorldGroupImpl extends GroupImpl {
+
+ public WorldGroupImpl(String s) {
+ super(s);
+ }
+
+ /**
+ * returns true for all passed principals
+ * @param member The principal whose membership must be checked in this Group.
+ * @return true always since this is the "world" group.
+ */
+ public boolean isMember(Principal member) {
+ return true;
+ }
+}
--- a/jdk/src/java.base/share/classes/sun/security/util/HostnameChecker.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/sun/security/util/HostnameChecker.java Wed Feb 18 19:27:49 2015 -0800
@@ -26,6 +26,8 @@
package sun.security.util;
import java.io.IOException;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
import java.util.*;
import java.security.Principal;
@@ -148,6 +150,17 @@
String ipAddress = (String)next.get(1);
if (expectedIP.equalsIgnoreCase(ipAddress)) {
return;
+ } else {
+ // compare InetAddress objects in order to ensure
+ // equality between a long IPv6 address and its
+ // abbreviated form.
+ try {
+ if (InetAddress.getByName(expectedIP).equals(
+ InetAddress.getByName(ipAddress))) {
+ return;
+ }
+ } catch (UnknownHostException e) {
+ } catch (SecurityException e) {}
}
}
}
--- a/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/classes/sun/util/resources/TimeZoneNames.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -408,7 +408,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"Venezuela Time", "VET",
"Venezuela Summer Time", "VEST",
"Venezuela Time", "VET"}},
--- a/jdk/src/java.base/share/conf/security/java.policy Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/conf/security/java.policy Wed Feb 18 19:27:49 2015 -0800
@@ -55,6 +55,29 @@
permission java.io.FilePermission "<<ALL FILES>>", "read";
};
+grant codeBase "jrt:/java.xml.ws" {
+ permission java.lang.RuntimePermission "accessClassInPackage.com.sun.xml.internal.*";
+ permission java.lang.RuntimePermission "accessClassInPackage.com.sun.istack.internal";
+ permission java.lang.RuntimePermission "accessClassInPackage.com.sun.istack.internal.*";
+ permission java.lang.RuntimePermission "accessClassInPackage.com.sun.org.apache.xerces.internal.*";
+ permission java.lang.RuntimePermission "accessDeclaredMembers";
+ permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
+ permission java.util.PropertyPermission "*", "read";
+};
+
+grant codeBase "jrt:/java.xml.bind" {
+ permission java.lang.RuntimePermission "accessClassInPackage.com.sun.xml.internal.*";
+ permission java.lang.RuntimePermission "accessClassInPackage.com.sun.istack.internal";
+ permission java.lang.RuntimePermission "accessClassInPackage.com.sun.istack.internal.*";
+ permission java.lang.RuntimePermission "accessDeclaredMembers";
+ permission java.lang.reflect.ReflectPermission "suppressAccessChecks";
+ permission java.util.PropertyPermission "*", "read";
+};
+
+grant codeBase "jrt:/java.activation" {
+ permission java.security.AllPermission;
+};
+
// default permissions granted to all domains
grant {
--- a/jdk/src/java.base/share/native/include/jvm.h Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/native/include/jvm.h Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -104,6 +104,9 @@
JNIEXPORT jlong JNICALL
JVM_NanoTime(JNIEnv *env, jclass ignored);
+JNIEXPORT jlong JNICALL
+JVM_GetNanoTimeAdjustment(JNIEnv *env, jclass ignored, jlong offset_secs);
+
JNIEXPORT void JNICALL
JVM_ArrayCopy(JNIEnv *env, jclass ignored, jobject src, jint src_pos,
jobject dst, jint dst_pos, jint length);
--- a/jdk/src/java.base/share/native/libjava/VM.c Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/native/libjava/VM.c Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2004, 2014, 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
@@ -33,6 +33,11 @@
#include "sun_misc_VM.h"
+/* Only register the performance-critical methods */
+static JNINativeMethod methods[] = {
+ {"getNanoTimeAdjustment", "(J)J", (void *)&JVM_GetNanoTimeAdjustment}
+};
+
JNIEXPORT jobject JNICALL
Java_sun_misc_VM_latestUserDefinedLoader(JNIEnv *env, jclass cls) {
return JVM_LatestUserDefinedLoader(env);
@@ -49,6 +54,14 @@
return;
}
+ // Registers implementations of native methods described in methods[]
+ // above.
+ // In particular, registers JVM_GetNanoTimeAdjustment as the implementation
+ // of the native sun.misc.VM.getNanoTimeAdjustment - avoiding the cost of
+ // introducing a Java_sun_misc_VM_getNanoTimeAdjustment wrapper
+ (*env)->RegisterNatives(env, cls,
+ methods, sizeof(methods)/sizeof(methods[0]));
+
func_p = (GetJvmVersionInfo_fp) JDK_FindJvmEntry("JVM_GetVersionInfo");
if (func_p != NULL) {
jvm_version_info info;
--- a/jdk/src/java.base/share/native/libjli/java.c Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/native/libjli/java.c Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -350,12 +350,6 @@
} \
} while (JNI_FALSE)
-#define CHECK_EXCEPTION_RETURN() \
- do { \
- if ((*env)->ExceptionOccurred(env)) { \
- return; \
- } \
- } while (JNI_FALSE)
int JNICALL
JavaMain(void * _args)
@@ -466,6 +460,7 @@
* of the application class.
*/
PostJVMInit(env, appClass, vm);
+ CHECK_EXCEPTION_LEAVE(1);
/*
* The LoadMainClass not only loads the main class, it will also ensure
* that the main method's signature is correct, therefore further checking
--- a/jdk/src/java.base/share/native/libjli/java.h Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/share/native/libjli/java.h Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2014, 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
@@ -254,4 +254,11 @@
#define NULL_CHECK(NC_check_pointer) \
NULL_CHECK_RETURN_VALUE(NC_check_pointer, )
+#define CHECK_EXCEPTION_RETURN() \
+ do { \
+ if ((*env)->ExceptionOccurred(env)) { \
+ return; \
+ } \
+ } while (JNI_FALSE)
+
#endif /* _JAVA_H_ */
--- a/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/windows/classes/sun/nio/fs/WindowsPath.java Wed Feb 18 19:27:49 2015 -0800
@@ -391,6 +391,10 @@
if (!this.root.equalsIgnoreCase(other.root))
throw new IllegalArgumentException("'other' has different root");
+ // this path is the empty path
+ if (this.isEmpty())
+ return other;
+
int bn = this.getNameCount();
int cn = other.getNameCount();
--- a/jdk/src/java.base/windows/native/libjava/ProcessImpl_md.c Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/windows/native/libjava/ProcessImpl_md.c Wed Feb 18 19:27:49 2015 -0800
@@ -30,6 +30,7 @@
#include "jvm.h"
#include "jni_util.h"
#include "io_util.h"
+#include "io_util_md.h"
#include <windows.h>
#include <io.h>
@@ -467,26 +468,6 @@
return (jboolean) CloseHandle((HANDLE) handle);
}
-/**
- * Returns a copy of the Unicode characters of a string. Fow now this
- * function doesn't handle long path names and other issues.
- */
-static WCHAR* getPath(JNIEnv *env, jstring ps) {
- WCHAR *pathbuf = NULL;
- const jchar *chars = (*(env))->GetStringChars(env, ps, NULL);
- if (chars != NULL) {
- size_t pathlen = wcslen(chars);
- pathbuf = (WCHAR*)malloc((pathlen + 6) * sizeof(WCHAR));
- if (pathbuf == NULL) {
- JNU_ThrowOutOfMemoryError(env, NULL);
- } else {
- wcscpy(pathbuf, chars);
- }
- (*env)->ReleaseStringChars(env, ps, chars);
- }
- return pathbuf;
-}
-
JNIEXPORT jlong JNICALL
Java_java_lang_ProcessImpl_openForAtomicAppend(JNIEnv *env, jclass ignored, jstring path)
{
@@ -495,7 +476,7 @@
const DWORD disposition = OPEN_ALWAYS;
const DWORD flagsAndAttributes = FILE_ATTRIBUTE_NORMAL;
HANDLE h;
- WCHAR *pathbuf = getPath(env, path);
+ WCHAR *pathbuf = pathToNTPath(env, path, JNI_FALSE);
if (pathbuf == NULL) {
/* Exception already pending */
return -1;
--- a/jdk/src/java.base/windows/native/libjava/io_util_md.h Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.base/windows/native/libjava/io_util_md.h Wed Feb 18 19:27:49 2015 -0800
@@ -33,7 +33,8 @@
/*
* Prototypes for functions in io_util_md.c called from io_util.c,
- * FileDescriptor.c, FileInputStream.c, FileOutputStream.c
+ * FileDescriptor.c, FileInputStream.c, FileOutputStream.c,
+ * ProcessImpl_md.c
*/
WCHAR* pathToNTPath(JNIEnv *env, jstring path, jboolean throwFNFE);
WCHAR* fileToNTPath(JNIEnv *env, jobject file, jfieldID id);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.management/share/classes/META-INF/services/sun.management.spi.PlatformMBeanProvider Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,25 @@
+#
+# 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.
+#
+com.sun.management.internal.PlatformMBeanProviderImpl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.management/share/classes/com/sun/management/internal/PlatformMBeanProviderImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,209 @@
+/*
+ * 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.
+ */
+package com.sun.management.internal;
+
+import java.lang.management.ManagementFactory;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.management.DynamicMBean;
+import javax.management.ObjectName;
+import sun.management.ManagementFactoryHelper;
+import sun.management.spi.PlatformMBeanProvider;
+
+public final class PlatformMBeanProviderImpl extends PlatformMBeanProvider {
+ private final List<PlatformComponent<?>> mxbeanList;
+
+ public PlatformMBeanProviderImpl() {
+ mxbeanList = Collections.unmodifiableList(init());
+ }
+
+ @Override
+ public List<PlatformComponent<?>> getPlatformComponentList() {
+ return mxbeanList;
+ }
+
+ private List<PlatformComponent<?>> init() {
+ ArrayList<PlatformComponent<?>> initMBeanList = new ArrayList<>();
+ /**
+ * Garbage Collector in the Java virtual machine.
+ */
+ initMBeanList.add(new PlatformComponent<java.lang.management.MemoryManagerMXBean>() {
+ private final Set<String> garbageCollectorMXBeanInterfaceNames
+ = Collections.unmodifiableSet(
+ Stream.of("java.lang.management.MemoryManagerMXBean",
+ "java.lang.management.GarbageCollectorMXBean",
+ "com.sun.management.GarbageCollectorMXBean")
+ .collect(Collectors.toSet()));
+
+ @Override
+ public Set<Class<? extends java.lang.management.MemoryManagerMXBean>> mbeanInterfaces() {
+ return Stream.of(java.lang.management.MemoryManagerMXBean.class,
+ java.lang.management.GarbageCollectorMXBean.class,
+ com.sun.management.GarbageCollectorMXBean.class)
+ .collect(Collectors.toSet());
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return garbageCollectorMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=*";
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false; // zero or more instances
+ }
+
+ @Override
+ public Map<String, java.lang.management.MemoryManagerMXBean> nameToMBeanMap() {
+ List<java.lang.management.GarbageCollectorMXBean> list
+ = ManagementFactoryHelper.getGarbageCollectorMXBeans();;
+ Map<String, java.lang.management.MemoryManagerMXBean> map;
+ if (list.isEmpty()) {
+ map = Collections.<String, java.lang.management.MemoryManagerMXBean>emptyMap();
+ } else {
+ map = new HashMap<>(list.size());
+ for (java.lang.management.MemoryManagerMXBean gcm : list) {
+ map.put(gcm.getObjectName().getCanonicalName(),
+ gcm);
+ }
+ }
+ return map;
+ }
+ });
+
+ /**
+ * OperatingSystemMXBean
+ */
+ initMBeanList.add(new PlatformComponent<java.lang.management.OperatingSystemMXBean>() {
+ private final Set<String> operatingSystemMXBeanInterfaceNames
+ = Collections.unmodifiableSet(
+ Stream.of("java.lang.management.OperatingSystemMXBean",
+ "com.sun.management.OperatingSystemMXBean",
+ "com.sun.management.UnixOperatingSystemMXBean")
+ .collect(Collectors.toSet()));
+
+ @Override
+ public Set<Class<? extends java.lang.management.OperatingSystemMXBean>> mbeanInterfaces() {
+ return Stream.of(java.lang.management.OperatingSystemMXBean.class,
+ com.sun.management.OperatingSystemMXBean.class,
+ com.sun.management.UnixOperatingSystemMXBean.class)
+ .collect(Collectors.toSet());
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return operatingSystemMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME;
+ }
+
+ @Override
+ public Map<String, java.lang.management.OperatingSystemMXBean> nameToMBeanMap() {
+ return Collections.<String, java.lang.management.OperatingSystemMXBean>singletonMap(
+ ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME,
+ ManagementFactoryHelper.getOperatingSystemMXBean());
+ }
+ });
+
+ /**
+ * Diagnostic support for the HotSpot Virtual Machine.
+ */
+ initMBeanList.add(new PlatformComponent<com.sun.management.HotSpotDiagnosticMXBean>() {
+ private final Set<String> hotSpotDiagnosticMXBeanInterfaceNames =
+ Collections.unmodifiableSet(Collections.<String>singleton("com.sun.management.HotSpotDiagnosticMXBean"));
+
+ @Override
+ public Set<Class<? extends com.sun.management.HotSpotDiagnosticMXBean>> mbeanInterfaces() {
+ return Collections.singleton(com.sun.management.HotSpotDiagnosticMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return hotSpotDiagnosticMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return "com.sun.management:type=HotSpotDiagnostic";
+ }
+
+ @Override
+ public Map<String, com.sun.management.HotSpotDiagnosticMXBean> nameToMBeanMap() {
+ return Collections.<String, com.sun.management.HotSpotDiagnosticMXBean>singletonMap(
+ "com.sun.management:type=HotSpotDiagnostic",
+ ManagementFactoryHelper.getDiagnosticMXBean());
+ }
+ });
+
+ /**
+ * DynamicMBean
+ */
+ HashMap<ObjectName, DynamicMBean> dynmbeans
+ = ManagementFactoryHelper.getPlatformDynamicMBeans();
+ final Set<String> dynamicMBeanInterfaceNames =
+ Collections.unmodifiableSet(Collections.<String>singleton("javax.management.DynamicMBean"));
+ for (Map.Entry<ObjectName, DynamicMBean> e : dynmbeans.entrySet()) {
+ initMBeanList.add(new PlatformComponent<DynamicMBean>() {
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return dynamicMBeanInterfaceNames;
+ }
+
+ @Override
+ public Set<Class<? extends DynamicMBean>> mbeanInterfaces() {
+ return Collections.emptySet(); // DynamicMBean cannot be used to find an MBean by ManagementFactory
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return e.getKey().getCanonicalName();
+ }
+
+ @Override
+ public Map<String, DynamicMBean> nameToMBeanMap() {
+ return Collections.<String, DynamicMBean>singletonMap(
+ e.getKey().getCanonicalName(),
+ e.getValue());
+ }
+ });
+ }
+ initMBeanList.trimToSize();
+ return initMBeanList;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.management/share/classes/java/lang/management/DefaultPlatformMBeanProvider.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,503 @@
+/*
+ * 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.
+ */
+package java.lang.management;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+import javax.management.DynamicMBean;
+import javax.management.ObjectName;
+import sun.management.ManagementFactoryHelper;
+import sun.management.spi.PlatformMBeanProvider;
+
+class DefaultPlatformMBeanProvider extends PlatformMBeanProvider {
+ private final List<PlatformComponent<?>> mxbeanList;
+
+ DefaultPlatformMBeanProvider() {
+ mxbeanList = Collections.unmodifiableList(init());
+ }
+
+ @Override
+ public List<PlatformComponent<?>> getPlatformComponentList() {
+ return mxbeanList;
+ }
+
+ private List<PlatformComponent<?>> init() {
+ ArrayList<PlatformComponent<?>> initMBeanList = new ArrayList<>();
+ /**
+ * Class loading system of the Java virtual machine.
+ */
+ initMBeanList.add(new PlatformComponent<ClassLoadingMXBean>() {
+ private final Set<String> classLoadingInterfaceNames =
+ Collections.unmodifiableSet(Collections.singleton(
+ "java.lang.management.ClassLoadingMXBean"));
+
+ @Override
+ public Set<Class<? extends ClassLoadingMXBean>> mbeanInterfaces() {
+ return Collections.singleton(ClassLoadingMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return classLoadingInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.CLASS_LOADING_MXBEAN_NAME;
+ }
+
+ @Override
+ public Map<String, ClassLoadingMXBean> nameToMBeanMap() {
+ return Collections.singletonMap(
+ ManagementFactory.CLASS_LOADING_MXBEAN_NAME,
+ ManagementFactoryHelper.getClassLoadingMXBean());
+ }
+ });
+
+ /**
+ * Compilation system of the Java virtual machine.
+ */
+ initMBeanList.add(new PlatformComponent<CompilationMXBean>() {
+ private final Set<String> compilationMXBeanInterfaceNames
+ = Collections.unmodifiableSet(Collections.singleton(
+ "java.lang.management.CompilationMXBean"));
+
+ @Override
+ public Set<Class<? extends CompilationMXBean>> mbeanInterfaces() {
+ return Collections.singleton(CompilationMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return compilationMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.COMPILATION_MXBEAN_NAME;
+ }
+
+ @Override
+ public Map<String, CompilationMXBean> nameToMBeanMap() {
+ CompilationMXBean m = ManagementFactoryHelper.getCompilationMXBean();
+ if (m == null) {
+ return Collections.emptyMap();
+ } else {
+ return Collections.singletonMap(
+ ManagementFactory.COMPILATION_MXBEAN_NAME,
+ ManagementFactoryHelper.getCompilationMXBean());
+ }
+ }
+ });
+
+ /**
+ * Memory system of the Java virtual machine.
+ */
+ initMBeanList.add(new PlatformComponent<MemoryMXBean>() {
+ private final Set<String> memoryMXBeanInterfaceNames
+ = Collections.unmodifiableSet(Collections.singleton(
+ "java.lang.management.MemoryMXBean"));
+
+ @Override
+ public Set<Class<? extends MemoryMXBean>> mbeanInterfaces() {
+ return Collections.singleton(MemoryMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return memoryMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.MEMORY_MXBEAN_NAME;
+ }
+
+ @Override
+ public Map<String, MemoryMXBean> nameToMBeanMap() {
+ return Collections.singletonMap(
+ ManagementFactory.MEMORY_MXBEAN_NAME,
+ ManagementFactoryHelper.getMemoryMXBean());
+ }
+ });
+
+ /**
+ * Garbage Collector in the Java virtual machine.
+ */
+ initMBeanList.add(new PlatformComponent<MemoryManagerMXBean>() {
+ private final Set<String> garbageCollectorMXBeanInterfaceNames
+ = Collections.unmodifiableSet(
+ Stream.of("java.lang.management.MemoryManagerMXBean",
+ "java.lang.management.GarbageCollectorMXBean")
+ .collect(Collectors.toSet()));
+ @Override
+ public Set<Class<? extends MemoryManagerMXBean>> mbeanInterfaces() {
+ return Stream.of(MemoryManagerMXBean.class,
+ GarbageCollectorMXBean.class,
+ com.sun.management.GarbageCollectorMXBean.class).collect(Collectors.toSet());
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return garbageCollectorMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.GARBAGE_COLLECTOR_MXBEAN_DOMAIN_TYPE + ",name=*";
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false; // zero or more instances
+ }
+
+ @Override
+ public Map<String, MemoryManagerMXBean> nameToMBeanMap() {
+ List<GarbageCollectorMXBean> list
+ = ManagementFactoryHelper.getGarbageCollectorMXBeans();
+ Map<String, MemoryManagerMXBean> map;
+ if (list.isEmpty()) {
+ map = Collections.emptyMap();
+ } else {
+ map = new HashMap<>(list.size());
+ for (MemoryManagerMXBean gcm : list) {
+ map.put(gcm.getObjectName().getCanonicalName(),
+ gcm);
+ }
+ }
+ return map;
+ }
+
+ });
+
+ /**
+ * Memory manager in the Java virtual machine.
+ */
+ initMBeanList.add(new PlatformComponent<MemoryManagerMXBean>() {
+ private final Set<String> memoryManagerMXBeanInterfaceNames
+ = Collections.unmodifiableSet(Collections.singleton(
+ "java.lang.management.MemoryManagerMXBean"));
+
+ @Override
+ public Set<Class<? extends MemoryManagerMXBean>> mbeanInterfaces() {
+ return Collections.singleton(MemoryManagerMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return memoryManagerMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE + ",name=*";
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false; // zero or more instances
+ }
+
+ @Override
+ public Map<String, MemoryManagerMXBean> nameToMBeanMap() {
+ List<MemoryManagerMXBean> list
+ = ManagementFactoryHelper.getMemoryManagerMXBeans();
+ return list.stream()
+ .filter(this::isMemoryManager)
+ .collect(Collectors.toMap(
+ pmo -> pmo.getObjectName().getCanonicalName(), Function.identity()));
+ }
+
+ // ManagementFactoryHelper.getMemoryManagerMXBeans() returns all
+ // memory managers - we need to filter out those that do not match
+ // the pattern for which we are registered
+ private boolean isMemoryManager(MemoryManagerMXBean mbean) {
+ final ObjectName name = mbean.getObjectName();
+ return ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE.startsWith(name.getDomain())
+ && ManagementFactory.MEMORY_MANAGER_MXBEAN_DOMAIN_TYPE.contains(
+ "type="+name.getKeyProperty("type"));
+ }
+ });
+
+ /**
+ * Memory pool in the Java virtual machine.
+ */
+ initMBeanList.add(new PlatformComponent<MemoryPoolMXBean>() {
+ private final Set<String> memoryPoolMXBeanInterfaceNames
+ = Collections.unmodifiableSet(Collections.singleton(
+ "java.lang.management.MemoryPoolMXBean"));
+
+ @Override
+ public Set<Class<? extends MemoryPoolMXBean>> mbeanInterfaces() {
+ return Collections.singleton(MemoryPoolMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return memoryPoolMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.MEMORY_POOL_MXBEAN_DOMAIN_TYPE + ",name=*";
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false; // zero or more instances
+ }
+
+ @Override
+ public Map<String, MemoryPoolMXBean> nameToMBeanMap() {
+ List<MemoryPoolMXBean> list
+ = ManagementFactoryHelper.getMemoryPoolMXBeans();
+ Map<String, MemoryPoolMXBean> map;
+ if (list.isEmpty()) {
+ map = Collections.<String, MemoryPoolMXBean>emptyMap();
+ } else {
+ map = new HashMap<>(list.size());
+ for (MemoryPoolMXBean mpm : list) {
+ map.put(mpm.getObjectName().getCanonicalName(),
+ mpm);
+ }
+ }
+ return map;
+ }
+ });
+
+ /**
+ * Runtime system of the Java virtual machine.
+ */
+ initMBeanList.add(new PlatformComponent<RuntimeMXBean>() {
+ private final Set<String> runtimeMXBeanInterfaceNames
+ = Collections.unmodifiableSet(Collections.singleton(
+ "java.lang.management.RuntimeMXBean"));
+
+ @Override
+ public Set<Class<? extends RuntimeMXBean>> mbeanInterfaces() {
+ return Collections.singleton(RuntimeMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return runtimeMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.RUNTIME_MXBEAN_NAME;
+ }
+
+ @Override
+ public Map<String, RuntimeMXBean> nameToMBeanMap() {
+ return Collections.singletonMap(
+ ManagementFactory.RUNTIME_MXBEAN_NAME,
+ ManagementFactoryHelper.getRuntimeMXBean());
+ }
+ });
+
+ /**
+ * Threading system of the Java virtual machine.
+ */
+ initMBeanList.add(new PlatformComponent<ThreadMXBean>() {
+ private final Set<String> threadMXBeanInterfaceNames
+ = Collections.unmodifiableSet(Collections.singleton(
+ "java.lang.management.ThreadMXBean"));
+
+ @Override
+ public Set<Class<? extends ThreadMXBean>> mbeanInterfaces() {
+ return Collections.singleton(ThreadMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return threadMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.THREAD_MXBEAN_NAME;
+ }
+
+ @Override
+ public Map<String, ThreadMXBean> nameToMBeanMap() {
+ return Collections.singletonMap(
+ ManagementFactory.THREAD_MXBEAN_NAME,
+ ManagementFactoryHelper.getThreadMXBean());
+ }
+ });
+
+ /**
+ * Logging facility.
+ */
+ initMBeanList.add(new PlatformComponent<PlatformLoggingMXBean>() {
+ private final Set<String> platformLoggingMXBeanInterfaceNames
+ = Collections.unmodifiableSet(Collections.singleton(
+ "java.lang.management.PlatformLoggingMXBean"));
+
+ @Override
+ public Set<Class<? extends PlatformLoggingMXBean>> mbeanInterfaces() {
+ return Collections.singleton(PlatformLoggingMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return platformLoggingMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return "java.util.logging:type=Logging";
+ }
+
+ @Override
+ public Map<String, PlatformLoggingMXBean> nameToMBeanMap() {
+ return Collections.singletonMap(
+ "java.util.logging:type=Logging",
+ ManagementFactoryHelper.getPlatformLoggingMXBean());
+ }
+ });
+
+ /**
+ * Buffer pools.
+ */
+ initMBeanList.add(new PlatformComponent<BufferPoolMXBean>() {
+ private final Set<String> bufferPoolMXBeanInterfaceNames
+ = Collections.unmodifiableSet(Collections.singleton(
+ "java.lang.management.BufferPoolMXBean"));
+
+ @Override
+ public Set<Class<? extends BufferPoolMXBean>> mbeanInterfaces() {
+ return Collections.singleton(BufferPoolMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return bufferPoolMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return "java.nio:type=BufferPool,name=*";
+ }
+
+ @Override
+ public boolean isSingleton() {
+ return false; // zero or more instances
+ }
+
+ @Override
+ public Map<String, BufferPoolMXBean> nameToMBeanMap() {
+ List<BufferPoolMXBean> list
+ = ManagementFactoryHelper.getBufferPoolMXBeans();
+ Map<String, BufferPoolMXBean> map;
+ if (list.isEmpty()) {
+ map = Collections.<String, BufferPoolMXBean>emptyMap();
+ } else {
+ map = new HashMap<>(list.size());
+ list.stream()
+ .forEach(mbean -> map.put(mbean.getObjectName().getCanonicalName(),mbean));
+ }
+ return map;
+ }
+ });
+
+ /**
+ * OperatingSystemMXBean
+ */
+ initMBeanList.add(new PlatformComponent<OperatingSystemMXBean>() {
+ private final Set<String> operatingSystemMXBeanInterfaceNames
+ = Collections.unmodifiableSet(Collections.singleton(
+ "java.lang.management.OperatingSystemMXBean"));
+
+ @Override
+ public Set<Class<? extends OperatingSystemMXBean>> mbeanInterfaces() {
+ return Collections.singleton(OperatingSystemMXBean.class);
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return operatingSystemMXBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME;
+ }
+
+ @Override
+ public Map<String, OperatingSystemMXBean> nameToMBeanMap() {
+ return Collections.singletonMap(
+ ManagementFactory.OPERATING_SYSTEM_MXBEAN_NAME,
+ ManagementFactoryHelper.getOperatingSystemMXBean());
+ }
+
+ });
+
+ /**
+ * DynamicMBean
+ */
+ HashMap<ObjectName, DynamicMBean> dynmbeans
+ = ManagementFactoryHelper.getPlatformDynamicMBeans();
+ final Set<String> dynamicMBeanInterfaceNames =
+ Collections.unmodifiableSet(Collections.singleton("javax.management.DynamicMBean"));
+ for (Map.Entry<ObjectName, DynamicMBean> e : dynmbeans.entrySet()) {
+ initMBeanList.add(new PlatformComponent<DynamicMBean>() {
+ @Override
+ public Set<Class<? extends DynamicMBean>> mbeanInterfaces() {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public Set<String> mbeanInterfaceNames() {
+ return dynamicMBeanInterfaceNames;
+ }
+
+ @Override
+ public String getObjectNamePattern() {
+ return e.getKey().getCanonicalName();
+ }
+
+ @Override
+ public Map<String, DynamicMBean> nameToMBeanMap() {
+ return Collections.<String, DynamicMBean>singletonMap(
+ e.getKey().getCanonicalName(),
+ e.getValue());
+ }
+ });
+ }
+
+ initMBeanList.trimToSize();
+ return initMBeanList;
+ }
+}
--- a/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.management/share/classes/java/lang/management/ManagementFactory.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, 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
@@ -24,35 +24,40 @@
*/
package java.lang.management;
+import java.io.FilePermission;
+import java.io.IOException;
import javax.management.DynamicMBean;
import javax.management.MBeanServer;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerFactory;
import javax.management.MBeanServerPermission;
import javax.management.NotificationEmitter;
-import javax.management.ObjectInstance;
import javax.management.ObjectName;
-import javax.management.InstanceAlreadyExistsException;
import javax.management.InstanceNotFoundException;
import javax.management.MalformedObjectNameException;
-import javax.management.MBeanRegistrationException;
-import javax.management.NotCompliantMBeanException;
import javax.management.StandardEmitterMBean;
import javax.management.StandardMBean;
import java.util.Collections;
import java.util.List;
import java.util.Set;
-import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
import java.security.AccessController;
import java.security.Permission;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Optional;
+import java.util.ServiceLoader;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import static java.util.stream.Collectors.toMap;
+import java.util.stream.Stream;
import javax.management.JMX;
-import sun.management.ManagementFactoryHelper;
-import sun.management.ExtendedPlatformComponent;
+import sun.management.Util;
+import sun.management.spi.PlatformMBeanProvider;
+import sun.management.spi.PlatformMBeanProvider.PlatformComponent;
/**
* The {@code ManagementFactory} class is a factory class for getting
@@ -316,7 +321,7 @@
* the Java virtual machine.
*/
public static ClassLoadingMXBean getClassLoadingMXBean() {
- return ManagementFactoryHelper.getClassLoadingMXBean();
+ return getPlatformMXBean(ClassLoadingMXBean.class);
}
/**
@@ -326,7 +331,7 @@
* @return a {@link MemoryMXBean} object for the Java virtual machine.
*/
public static MemoryMXBean getMemoryMXBean() {
- return ManagementFactoryHelper.getMemoryMXBean();
+ return getPlatformMXBean(MemoryMXBean.class);
}
/**
@@ -336,7 +341,7 @@
* @return a {@link ThreadMXBean} object for the Java virtual machine.
*/
public static ThreadMXBean getThreadMXBean() {
- return ManagementFactoryHelper.getThreadMXBean();
+ return getPlatformMXBean(ThreadMXBean.class);
}
/**
@@ -347,7 +352,7 @@
*/
public static RuntimeMXBean getRuntimeMXBean() {
- return ManagementFactoryHelper.getRuntimeMXBean();
+ return getPlatformMXBean(RuntimeMXBean.class);
}
/**
@@ -360,7 +365,7 @@
* no compilation system.
*/
public static CompilationMXBean getCompilationMXBean() {
- return ManagementFactoryHelper.getCompilationMXBean();
+ return getPlatformMXBean(CompilationMXBean.class);
}
/**
@@ -371,7 +376,7 @@
* the Java virtual machine.
*/
public static OperatingSystemMXBean getOperatingSystemMXBean() {
- return ManagementFactoryHelper.getOperatingSystemMXBean();
+ return getPlatformMXBean(OperatingSystemMXBean.class);
}
/**
@@ -384,7 +389,7 @@
*
*/
public static List<MemoryPoolMXBean> getMemoryPoolMXBeans() {
- return ManagementFactoryHelper.getMemoryPoolMXBeans();
+ return getPlatformMXBeans(MemoryPoolMXBean.class);
}
/**
@@ -397,7 +402,7 @@
*
*/
public static List<MemoryManagerMXBean> getMemoryManagerMXBeans() {
- return ManagementFactoryHelper.getMemoryManagerMXBeans();
+ return getPlatformMXBeans(MemoryManagerMXBean.class);
}
@@ -413,7 +418,7 @@
*
*/
public static List<GarbageCollectorMXBean> getGarbageCollectorMXBeans() {
- return ManagementFactoryHelper.getGarbageCollectorMXBeans();
+ return getPlatformMXBeans(GarbageCollectorMXBean.class);
}
private static MBeanServer platformMBeanServer;
@@ -467,35 +472,11 @@
if (platformMBeanServer == null) {
platformMBeanServer = MBeanServerFactory.createMBeanServer();
- for (PlatformComponent pc : PlatformComponent.values()) {
- List<? extends PlatformManagedObject> list =
- pc.getMXBeans(pc.getMXBeanInterface());
- for (PlatformManagedObject o : list) {
- // Each PlatformComponent represents one management
- // interface. Some MXBean may extend another one.
- // The MXBean instances for one platform component
- // (returned by pc.getMXBeans()) might be also
- // the MXBean instances for another platform component.
- // e.g. com.sun.management.GarbageCollectorMXBean
- //
- // So need to check if an MXBean instance is registered
- // before registering into the platform MBeanServer
- if (!platformMBeanServer.isRegistered(o.getObjectName())) {
- addMXBean(platformMBeanServer, o);
- }
- }
- }
- HashMap<ObjectName, DynamicMBean> dynmbeans =
- ManagementFactoryHelper.getPlatformDynamicMBeans();
- for (Map.Entry<ObjectName, DynamicMBean> e : dynmbeans.entrySet()) {
- addDynamicMBean(platformMBeanServer, e.getValue(), e.getKey());
- }
- for (final PlatformManagedObject o :
- ExtendedPlatformComponent.getMXBeans()) {
- if (!platformMBeanServer.isRegistered(o.getObjectName())) {
- addMXBean(platformMBeanServer, o);
- }
- }
+ platformComponents()
+ .stream()
+ .filter(PlatformComponent::shouldRegister)
+ .flatMap(pc -> pc.nameToMBeanMap().entrySet().stream())
+ .forEach(entry -> addMXBean(platformMBeanServer, entry.getKey(), entry.getValue()));
}
return platformMBeanServer;
}
@@ -600,11 +581,8 @@
// bootstrap class loader
final Class<?> cls = mxbeanInterface;
ClassLoader loader =
- AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
- public ClassLoader run() {
- return cls.getClassLoader();
- }
- });
+ AccessController.doPrivileged(
+ (PrivilegedAction<ClassLoader>) () -> cls.getClassLoader());
if (!sun.misc.VM.isSystemDomainLoader(loader)) {
throw new IllegalArgumentException(mxbeanName +
" is not a platform MXBean");
@@ -619,7 +597,6 @@
" is not an instance of " + mxbeanInterface);
}
- final Class<?>[] interfaces;
// check if the registered MBean is a notification emitter
boolean emitter = connection.isInstanceOf(objName, NOTIF_EMITTER);
@@ -661,20 +638,11 @@
*/
public static <T extends PlatformManagedObject>
T getPlatformMXBean(Class<T> mxbeanInterface) {
- PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
- if (pc == null) {
- T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface);
- if (mbean != null) {
- return mbean;
- }
- throw new IllegalArgumentException(mxbeanInterface.getName() +
- " is not a platform management interface");
- }
- if (!pc.isSingleton())
- throw new IllegalArgumentException(mxbeanInterface.getName() +
- " can have zero or more than one instances");
+ PlatformComponent<?> pc = PlatformMBeanFinder.findSingleton(mxbeanInterface);
- return pc.getSingletonMXBean(mxbeanInterface);
+ List<? extends T> mbeans = pc.getMBeans(mxbeanInterface);
+ assert mbeans.isEmpty() || mbeans.size() == 1;
+ return mbeans.isEmpty() ? null : mbeans.get(0);
}
/**
@@ -701,16 +669,19 @@
*/
public static <T extends PlatformManagedObject> List<T>
getPlatformMXBeans(Class<T> mxbeanInterface) {
- PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
+ // Validates at first the specified interface by finding at least one
+ // PlatformComponent whose MXBean implements this interface.
+ // An interface can be implemented by different MBeans, provided by
+ // different platform components.
+ PlatformComponent<?> pc = PlatformMBeanFinder.findFirst(mxbeanInterface);
if (pc == null) {
- T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface);
- if (mbean != null) {
- return Collections.singletonList(mbean);
- }
- throw new IllegalArgumentException(mxbeanInterface.getName() +
- " is not a platform management interface");
+ throw new IllegalArgumentException(mxbeanInterface.getName()
+ + " is not a platform management interface");
}
- return Collections.unmodifiableList(pc.getMXBeans(mxbeanInterface));
+
+ return platformComponents().stream()
+ .flatMap(p -> p.getMBeans(mxbeanInterface).stream())
+ .collect(Collectors.toList());
}
/**
@@ -753,22 +724,8 @@
Class<T> mxbeanInterface)
throws java.io.IOException
{
- PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
- if (pc == null) {
- T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface);
- if (mbean != null) {
- ObjectName on = mbean.getObjectName();
- return ManagementFactory.newPlatformMXBeanProxy(connection,
- on.getCanonicalName(),
- mxbeanInterface);
- }
- throw new IllegalArgumentException(mxbeanInterface.getName() +
- " is not a platform management interface");
- }
- if (!pc.isSingleton())
- throw new IllegalArgumentException(mxbeanInterface.getName() +
- " can have zero or more than one instances");
- return pc.getSingletonMXBean(connection, mxbeanInterface);
+ PlatformComponent<?> pc = PlatformMBeanFinder.findSingleton(mxbeanInterface);
+ return newPlatformMXBeanProxy(connection, pc.getObjectNamePattern(), mxbeanInterface);
}
/**
@@ -804,19 +761,56 @@
Class<T> mxbeanInterface)
throws java.io.IOException
{
- PlatformComponent pc = PlatformComponent.getPlatformComponent(mxbeanInterface);
+ // Validates at first the specified interface by finding at least one
+ // PlatformComponent whose MXBean implements this interface.
+ // An interface can be implemented by different MBeans, provided by
+ // different platform components.
+ PlatformComponent<?> pc = PlatformMBeanFinder.findFirst(mxbeanInterface);
if (pc == null) {
- T mbean = ExtendedPlatformComponent.getMXBean(mxbeanInterface);
- if (mbean != null) {
- ObjectName on = mbean.getObjectName();
- T proxy = ManagementFactory.newPlatformMXBeanProxy(connection,
- on.getCanonicalName(), mxbeanInterface);
- return Collections.singletonList(proxy);
+ throw new IllegalArgumentException(mxbeanInterface.getName()
+ + " is not a platform management interface");
+ }
+
+ // Collect all names, eliminate duplicates.
+ Stream<String> names = Stream.empty();
+ for (PlatformComponent<?> p : platformComponents()) {
+ names = Stream.concat(names, getProxyNames(p, connection, mxbeanInterface));
+ }
+ Set<String> objectNames = names.collect(Collectors.toSet());
+ if (objectNames.isEmpty()) return Collections.emptyList();
+
+ // Map names on proxies.
+ List<T> proxies = new ArrayList<>();
+ for (String name : objectNames) {
+ proxies.add(newPlatformMXBeanProxy(connection, name, mxbeanInterface));
+ }
+ return proxies;
+ }
+
+ // Returns a stream containing all ObjectNames of the MBeans represented by
+ // the specified PlatformComponent and implementing the specified interface.
+ // If the PlatformComponent is a singleton, the name returned by
+ // PlatformComponent.getObjectNamePattern() will be used, otherwise
+ // we will query the specified MBeanServerConnection (conn.queryNames)
+ // with the pattern returned by PlatformComponent.getObjectNamePattern()
+ // in order to find the names of matching MBeans.
+ // In case of singleton, we do not check whether the MBean is registered
+ // in the connection because the caller "getPlatformMXBeans" will do the check
+ // when creating a proxy.
+ private static Stream<String> getProxyNames(PlatformComponent<?> pc,
+ MBeanServerConnection conn,
+ Class<?> intf)
+ throws IOException
+ {
+ if (pc.mbeanInterfaceNames().contains(intf.getName())) {
+ if (pc.isSingleton()) {
+ return Stream.of(pc.getObjectNamePattern());
+ } else {
+ return conn.queryNames(Util.newObjectName(pc.getObjectNamePattern()), null)
+ .stream().map(ObjectName::getCanonicalName);
}
- throw new IllegalArgumentException(mxbeanInterface.getName() +
- " is not a platform management interface");
}
- return Collections.unmodifiableList(pc.getMXBeans(connection, mxbeanInterface));
+ return Stream.empty();
}
/**
@@ -835,63 +829,145 @@
public static Set<Class<? extends PlatformManagedObject>>
getPlatformManagementInterfaces()
{
- Set<Class<? extends PlatformManagedObject>> result =
- new HashSet<>();
- for (PlatformComponent component: PlatformComponent.values()) {
- result.add(component.getMXBeanInterface());
- }
- return Collections.unmodifiableSet(result);
+ return platformComponents()
+ .stream()
+ .flatMap(pc -> pc.mbeanInterfaces().stream())
+ .filter(clazz -> PlatformManagedObject.class.isAssignableFrom(clazz))
+ .map(clazz -> clazz.asSubclass(PlatformManagedObject.class))
+ .collect(Collectors.toSet());
}
private static final String NOTIF_EMITTER =
"javax.management.NotificationEmitter";
- /**
- * Registers an MXBean.
- */
- private static void addMXBean(final MBeanServer mbs, final PlatformManagedObject pmo) {
- // Make DynamicMBean out of MXBean by wrapping it with a StandardMBean
+ private static void addMXBean(final MBeanServer mbs, String name, final Object pmo)
+ {
try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- public Void run() throws InstanceAlreadyExistsException,
- MBeanRegistrationException,
- NotCompliantMBeanException {
- final DynamicMBean dmbean;
- if (pmo instanceof DynamicMBean) {
- dmbean = DynamicMBean.class.cast(pmo);
- } else if (pmo instanceof NotificationEmitter) {
- dmbean = new StandardEmitterMBean(pmo, null, true, (NotificationEmitter) pmo);
- } else {
- dmbean = new StandardMBean(pmo, null, true);
- }
+ ObjectName oname = ObjectName.getInstance(name);
+ // Make DynamicMBean out of MXBean by wrapping it with a StandardMBean
+ AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
+ final DynamicMBean dmbean;
+ if (pmo instanceof DynamicMBean) {
+ dmbean = DynamicMBean.class.cast(pmo);
+ } else if (pmo instanceof NotificationEmitter) {
+ dmbean = new StandardEmitterMBean(pmo, null, true, (NotificationEmitter) pmo);
+ } else {
+ dmbean = new StandardMBean(pmo, null, true);
+ }
- mbs.registerMBean(dmbean, pmo.getObjectName());
- return null;
- }
+ mbs.registerMBean(dmbean, oname);
+ return null;
});
+ } catch (MalformedObjectNameException mone) {
+ throw new IllegalArgumentException(mone);
} catch (PrivilegedActionException e) {
throw new RuntimeException(e.getException());
}
}
- /**
- * Registers a DynamicMBean.
- */
- private static void addDynamicMBean(final MBeanServer mbs,
- final DynamicMBean dmbean,
- final ObjectName on) {
- try {
- AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() {
- @Override
- public Void run() throws InstanceAlreadyExistsException,
- MBeanRegistrationException,
- NotCompliantMBeanException {
- mbs.registerMBean(dmbean, on);
- return null;
- }
- });
- } catch (PrivilegedActionException e) {
- throw new RuntimeException(e.getException());
+ private static Collection<PlatformComponent<?>> platformComponents()
+ {
+ return PlatformMBeanFinder.getMap().values();
+ }
+
+ private static class PlatformMBeanFinder
+ {
+ private static final Map<String, PlatformComponent<?>> componentMap;
+ static {
+ // get all providers
+ List<PlatformMBeanProvider> providers = AccessController.doPrivileged(
+ (PrivilegedAction<List<PlatformMBeanProvider>>) () -> {
+ List<PlatformMBeanProvider> all = new ArrayList<>();
+ ServiceLoader.loadInstalled(PlatformMBeanProvider.class)
+ .forEach(all::add);
+ all.add(new DefaultPlatformMBeanProvider());
+ return all;
+ }, null, new FilePermission("<<ALL FILES>>", "read"),
+ new RuntimePermission("sun.management.spi.PlatformMBeanProvider"));
+
+ // load all platform components into a map
+ componentMap = providers.stream()
+ .flatMap(p -> toPlatformComponentStream(p))
+ // The first one wins if multiple PlatformComponents
+ // with same ObjectName pattern,
+ .collect(toMap(PlatformComponent::getObjectNamePattern,
+ Function.identity(),
+ (p1, p2) -> p1));
+ }
+
+ static Map<String, PlatformComponent<?>> getMap() {
+ return componentMap;
+ }
+
+ // Loads all platform components from a provider into a stream
+ // Ensures that two different components are not declared with the same
+ // object name pattern. Throws InternalError if the provider incorrectly
+ // declares two platform components with the same pattern.
+ private static Stream<PlatformComponent<?>>
+ toPlatformComponentStream(PlatformMBeanProvider provider)
+ {
+ return provider.getPlatformComponentList()
+ .stream()
+ .collect(toMap(PlatformComponent::getObjectNamePattern,
+ Function.identity(),
+ (p1, p2) -> {
+ throw new InternalError(
+ p1.getObjectNamePattern() +
+ " has been used as key for " + p1 +
+ ", it cannot be reused for " + p2);
+ }))
+ .values().stream();
+ }
+
+ // Finds the first PlatformComponent whose mbeanInterfaceNames() list
+ // contains the specified class name. An MBean interface can be implemented
+ // by different MBeans, provided by different platform components.
+ // For instance the MemoryManagerMXBean interface is implemented both by
+ // regular memory managers, and garbage collector MXBeans. This method is
+ // mainly used to verify that there is at least one PlatformComponent
+ // which provides an implementation of the desired interface.
+ static PlatformComponent<?> findFirst(Class<?> mbeanIntf)
+ {
+ String name = mbeanIntf.getName();
+ Optional<PlatformComponent<?>> op = getMap().values()
+ .stream()
+ .filter(pc -> pc.mbeanInterfaceNames().contains(name))
+ .findFirst();
+
+ if (op.isPresent()) {
+ return op.get();
+ } else {
+ return null;
+ }
+ }
+
+ // Finds a PlatformComponent whose mbeanInterface name list contains
+ // the specified class name, and make sure that one and only one exists.
+ static PlatformComponent<?> findSingleton(Class<?> mbeanIntf)
+ {
+ String name = mbeanIntf.getName();
+ Optional<PlatformComponent<?>> op = getMap().values()
+ .stream()
+ .filter(pc -> pc.mbeanInterfaceNames().contains(name))
+ .reduce((p1, p2) -> {
+ if (p2 != null) {
+ throw new IllegalArgumentException(mbeanIntf.getName() +
+ " can have more than one instance");
+ } else {
+ return p1;
+ }
+ });
+
+ PlatformComponent<?> singleton = op.isPresent() ? op.get() : null;
+ if (singleton == null) {
+ throw new IllegalArgumentException(mbeanIntf.getName() +
+ " is not a platform management interface");
+ }
+ if (!singleton.isSingleton()) {
+ throw new IllegalArgumentException(mbeanIntf.getName() +
+ " can have more than one instance");
+ }
+ return singleton;
}
}
}
--- a/jdk/src/java.management/share/classes/java/lang/management/PlatformComponent.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,468 +0,0 @@
-/*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.lang.management;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.HashSet;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import javax.management.MBeanServerConnection;
-import javax.management.ObjectName;
-
-import com.sun.management.HotSpotDiagnosticMXBean;
-import com.sun.management.UnixOperatingSystemMXBean;
-
-import sun.management.ManagementFactoryHelper;
-import sun.management.Util;
-
-/**
- * This enum class defines the list of platform components
- * that provides monitoring and management support.
- * Each enum represents one MXBean interface. A MXBean
- * instance could implement one or more MXBean interfaces.
- *
- * For example, com.sun.management.GarbageCollectorMXBean
- * extends java.lang.management.GarbageCollectorMXBean
- * and there is one set of garbage collection MXBean instances,
- * each of which implements both c.s.m. and j.l.m. interfaces.
- * There are two separate enums GARBAGE_COLLECTOR
- * and SUN_GARBAGE_COLLECTOR so that ManagementFactory.getPlatformMXBeans(Class)
- * will return the list of MXBeans of the specified type.
- *
- * To add a new MXBean interface for the Java platform,
- * add a new enum constant and implement the MXBeanFetcher.
- */
-enum PlatformComponent {
-
- /**
- * Class loading system of the Java virtual machine.
- */
- CLASS_LOADING(
- "java.lang.management.ClassLoadingMXBean",
- "java.lang", "ClassLoading", defaultKeyProperties(),
- true, // singleton
- new MXBeanFetcher<ClassLoadingMXBean>() {
- public List<ClassLoadingMXBean> getMXBeans() {
- return Collections.singletonList(ManagementFactoryHelper.getClassLoadingMXBean());
- }
- }),
-
- /**
- * Compilation system of the Java virtual machine.
- */
- COMPILATION(
- "java.lang.management.CompilationMXBean",
- "java.lang", "Compilation", defaultKeyProperties(),
- true, // singleton
- new MXBeanFetcher<CompilationMXBean>() {
- public List<CompilationMXBean> getMXBeans() {
- CompilationMXBean m = ManagementFactoryHelper.getCompilationMXBean();
- if (m == null) {
- return Collections.emptyList();
- } else {
- return Collections.singletonList(m);
- }
- }
- }),
-
- /**
- * Memory system of the Java virtual machine.
- */
- MEMORY(
- "java.lang.management.MemoryMXBean",
- "java.lang", "Memory", defaultKeyProperties(),
- true, // singleton
- new MXBeanFetcher<MemoryMXBean>() {
- public List<MemoryMXBean> getMXBeans() {
- return Collections.singletonList(ManagementFactoryHelper.getMemoryMXBean());
- }
- }),
-
- /**
- * Garbage Collector in the Java virtual machine.
- */
- GARBAGE_COLLECTOR(
- "java.lang.management.GarbageCollectorMXBean",
- "java.lang", "GarbageCollector", keyProperties("name"),
- false, // zero or more instances
- new MXBeanFetcher<GarbageCollectorMXBean>() {
- public List<GarbageCollectorMXBean> getMXBeans() {
- return ManagementFactoryHelper.
- getGarbageCollectorMXBeans();
- }
- }),
-
- /**
- * Memory manager in the Java virtual machine.
- */
- MEMORY_MANAGER(
- "java.lang.management.MemoryManagerMXBean",
- "java.lang", "MemoryManager", keyProperties("name"),
- false, // zero or more instances
- new MXBeanFetcher<MemoryManagerMXBean>() {
- public List<MemoryManagerMXBean> getMXBeans() {
- return ManagementFactoryHelper.getMemoryManagerMXBeans();
- }
- },
- GARBAGE_COLLECTOR),
-
- /**
- * Memory pool in the Java virtual machine.
- */
- MEMORY_POOL(
- "java.lang.management.MemoryPoolMXBean",
- "java.lang", "MemoryPool", keyProperties("name"),
- false, // zero or more instances
- new MXBeanFetcher<MemoryPoolMXBean>() {
- public List<MemoryPoolMXBean> getMXBeans() {
- return ManagementFactoryHelper.getMemoryPoolMXBeans();
- }
- }),
-
- /**
- * Operating system on which the Java virtual machine is running
- */
- OPERATING_SYSTEM(
- "java.lang.management.OperatingSystemMXBean",
- "java.lang", "OperatingSystem", defaultKeyProperties(),
- true, // singleton
- new MXBeanFetcher<OperatingSystemMXBean>() {
- public List<OperatingSystemMXBean> getMXBeans() {
- return Collections.singletonList(ManagementFactoryHelper.getOperatingSystemMXBean());
- }
- }),
-
- /**
- * Runtime system of the Java virtual machine.
- */
- RUNTIME(
- "java.lang.management.RuntimeMXBean",
- "java.lang", "Runtime", defaultKeyProperties(),
- true, // singleton
- new MXBeanFetcher<RuntimeMXBean>() {
- public List<RuntimeMXBean> getMXBeans() {
- return Collections.singletonList(ManagementFactoryHelper.getRuntimeMXBean());
- }
- }),
-
- /**
- * Threading system of the Java virtual machine.
- */
- THREADING(
- "java.lang.management.ThreadMXBean",
- "java.lang", "Threading", defaultKeyProperties(),
- true, // singleton
- new MXBeanFetcher<ThreadMXBean>() {
- public List<ThreadMXBean> getMXBeans() {
- return Collections.singletonList(ManagementFactoryHelper.getThreadMXBean());
- }
- }),
-
-
- /**
- * Logging facility.
- */
- LOGGING(
- "java.lang.management.PlatformLoggingMXBean",
- "java.util.logging", "Logging", defaultKeyProperties(),
- true, // singleton
- new MXBeanFetcher<PlatformLoggingMXBean>() {
- public List<PlatformLoggingMXBean> getMXBeans() {
- PlatformLoggingMXBean m = ManagementFactoryHelper.getPlatformLoggingMXBean();
- if (m == null) {
- return Collections.emptyList();
- } else {
- return Collections.singletonList(m);
- }
- }
- }),
-
- /**
- * Buffer pools.
- */
- BUFFER_POOL(
- "java.lang.management.BufferPoolMXBean",
- "java.nio", "BufferPool", keyProperties("name"),
- false, // zero or more instances
- new MXBeanFetcher<BufferPoolMXBean>() {
- public List<BufferPoolMXBean> getMXBeans() {
- return ManagementFactoryHelper.getBufferPoolMXBeans();
- }
- }),
-
-
- // Sun Platform Extension
-
- /**
- * Sun extension garbage collector that performs collections in cycles.
- */
- SUN_GARBAGE_COLLECTOR(
- "com.sun.management.GarbageCollectorMXBean",
- "java.lang", "GarbageCollector", keyProperties("name"),
- false, // zero or more instances
- new MXBeanFetcher<com.sun.management.GarbageCollectorMXBean>() {
- public List<com.sun.management.GarbageCollectorMXBean> getMXBeans() {
- return getGcMXBeanList(com.sun.management.GarbageCollectorMXBean.class);
- }
- }),
-
- /**
- * Sun extension operating system on which the Java virtual machine
- * is running.
- */
- SUN_OPERATING_SYSTEM(
- "com.sun.management.OperatingSystemMXBean",
- "java.lang", "OperatingSystem", defaultKeyProperties(),
- true, // singleton
- new MXBeanFetcher<com.sun.management.OperatingSystemMXBean>() {
- public List<com.sun.management.OperatingSystemMXBean> getMXBeans() {
- return getOSMXBeanList(com.sun.management.OperatingSystemMXBean.class);
- }
- }),
-
- /**
- * Unix operating system.
- */
- SUN_UNIX_OPERATING_SYSTEM(
- "com.sun.management.UnixOperatingSystemMXBean",
- "java.lang", "OperatingSystem", defaultKeyProperties(),
- true, // singleton
- new MXBeanFetcher<UnixOperatingSystemMXBean>() {
- public List<UnixOperatingSystemMXBean> getMXBeans() {
- return getOSMXBeanList(com.sun.management.UnixOperatingSystemMXBean.class);
- }
- }),
-
- /**
- * Diagnostic support for the HotSpot Virtual Machine.
- */
- HOTSPOT_DIAGNOSTIC(
- "com.sun.management.HotSpotDiagnosticMXBean",
- "com.sun.management", "HotSpotDiagnostic", defaultKeyProperties(),
- true, // singleton
- new MXBeanFetcher<HotSpotDiagnosticMXBean>() {
- public List<HotSpotDiagnosticMXBean> getMXBeans() {
- return Collections.singletonList(ManagementFactoryHelper.getDiagnosticMXBean());
- }
- });
-
-
- /**
- * A task that returns the MXBeans for a component.
- */
- interface MXBeanFetcher<T extends PlatformManagedObject> {
- public List<T> getMXBeans();
- }
-
- /*
- * Returns a list of the GC MXBeans of the given type.
- */
- private static <T extends GarbageCollectorMXBean>
- List<T> getGcMXBeanList(Class<T> gcMXBeanIntf) {
- List<GarbageCollectorMXBean> list =
- ManagementFactoryHelper.getGarbageCollectorMXBeans();
- List<T> result = new ArrayList<>(list.size());
- for (GarbageCollectorMXBean m : list) {
- if (gcMXBeanIntf.isInstance(m)) {
- result.add(gcMXBeanIntf.cast(m));
- }
- }
- return result;
- }
-
- /*
- * Returns the OS mxbean instance of the given type.
- */
- private static <T extends OperatingSystemMXBean>
- List<T> getOSMXBeanList(Class<T> osMXBeanIntf) {
- OperatingSystemMXBean m =
- ManagementFactoryHelper.getOperatingSystemMXBean();
- if (osMXBeanIntf.isInstance(m)) {
- return Collections.singletonList(osMXBeanIntf.cast(m));
- } else {
- return Collections.emptyList();
- }
- }
-
- private final String mxbeanInterfaceName;
- private final String domain;
- private final String type;
- private final Set<String> keyProperties;
- private final MXBeanFetcher<?> fetcher;
- private final PlatformComponent[] subComponents;
- private final boolean singleton;
-
- private PlatformComponent(String intfName,
- String domain, String type,
- Set<String> keyProperties,
- boolean singleton,
- MXBeanFetcher<?> fetcher,
- PlatformComponent... subComponents) {
- this.mxbeanInterfaceName = intfName;
- this.domain = domain;
- this.type = type;
- this.keyProperties = keyProperties;
- this.singleton = singleton;
- this.fetcher = fetcher;
- this.subComponents = subComponents;
- }
-
- private static Set<String> defaultKeyProps;
- private static Set<String> defaultKeyProperties() {
- if (defaultKeyProps == null) {
- defaultKeyProps = Collections.singleton("type");
- }
- return defaultKeyProps;
- }
-
- private static Set<String> keyProperties(String... keyNames) {
- Set<String> set = new HashSet<>();
- set.add("type");
- for (String s : keyNames) {
- set.add(s);
- }
- return set;
- }
-
- boolean isSingleton() {
- return singleton;
- }
-
- String getMXBeanInterfaceName() {
- return mxbeanInterfaceName;
- }
-
- @SuppressWarnings("unchecked")
- Class<? extends PlatformManagedObject> getMXBeanInterface() {
- try {
- // Lazy loading the MXBean interface only when it is needed
- return (Class<? extends PlatformManagedObject>)
- Class.forName(mxbeanInterfaceName, false,
- PlatformManagedObject.class.getClassLoader());
- } catch (ClassNotFoundException x) {
- throw new AssertionError(x);
- }
- }
-
- @SuppressWarnings("unchecked")
- <T extends PlatformManagedObject>
- List<T> getMXBeans(Class<T> mxbeanInterface)
- {
- return (List<T>) fetcher.getMXBeans();
- }
-
- <T extends PlatformManagedObject> T getSingletonMXBean(Class<T> mxbeanInterface)
- {
- if (!singleton)
- throw new IllegalArgumentException(mxbeanInterfaceName +
- " can have zero or more than one instances");
-
- List<T> list = getMXBeans(mxbeanInterface);
- assert list.size() == 1;
- return list.isEmpty() ? null : list.get(0);
- }
-
- <T extends PlatformManagedObject>
- T getSingletonMXBean(MBeanServerConnection mbs, Class<T> mxbeanInterface)
- throws java.io.IOException
- {
- if (!singleton)
- throw new IllegalArgumentException(mxbeanInterfaceName +
- " can have zero or more than one instances");
-
- // ObjectName of a singleton MXBean contains only domain and type
- assert keyProperties.size() == 1;
- String on = domain + ":type=" + type;
- return ManagementFactory.newPlatformMXBeanProxy(mbs,
- on,
- mxbeanInterface);
- }
-
- <T extends PlatformManagedObject>
- List<T> getMXBeans(MBeanServerConnection mbs, Class<T> mxbeanInterface)
- throws java.io.IOException
- {
- List<T> result = new ArrayList<>();
- for (ObjectName on : getObjectNames(mbs)) {
- result.add(ManagementFactory.
- newPlatformMXBeanProxy(mbs,
- on.getCanonicalName(),
- mxbeanInterface)
- );
- }
- return result;
- }
-
- private Set<ObjectName> getObjectNames(MBeanServerConnection mbs)
- throws java.io.IOException
- {
- String domainAndType = domain + ":type=" + type;
- if (keyProperties.size() > 1) {
- // if there are more than 1 key properties (i.e. other than "type")
- domainAndType += ",*";
- }
- ObjectName on = Util.newObjectName(domainAndType);
- Set<ObjectName> set = mbs.queryNames(on, null);
- for (PlatformComponent pc : subComponents) {
- set.addAll(pc.getObjectNames(mbs));
- }
- return set;
- }
-
- // a map from MXBean interface name to PlatformComponent
- private static Map<String, PlatformComponent> enumMap;
- private static synchronized void ensureInitialized() {
- if (enumMap == null) {
- enumMap = new HashMap<>();
- for (PlatformComponent pc: PlatformComponent.values()) {
- // Use String as the key rather than Class<?> to avoid
- // causing unnecessary class loading of management interface
- enumMap.put(pc.getMXBeanInterfaceName(), pc);
- }
- }
- }
-
- static boolean isPlatformMXBean(String cn) {
- ensureInitialized();
- return enumMap.containsKey(cn);
- }
-
- static <T extends PlatformManagedObject>
- PlatformComponent getPlatformComponent(Class<T> mxbeanInterface)
- {
- ensureInitialized();
- String cn = mxbeanInterface.getName();
- PlatformComponent pc = enumMap.get(cn);
- if (pc != null && pc.getMXBeanInterface() == mxbeanInterface)
- return pc;
- return null;
- }
-
- private static final long serialVersionUID = 6992337162326171013L;
-}
--- a/jdk/src/java.management/share/classes/sun/management/ExtendedPlatformComponent.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.management;
-
-import java.util.Collections;
-import java.util.List;
-import java.lang.management.PlatformManagedObject;
-
-/**
- * Class to allow for an extended set of platform MXBeans
- */
-public final class ExtendedPlatformComponent {
- private ExtendedPlatformComponent() {} // Don't create any instances
-
- /**
- * Get the extended set of platform MXBeans that should be registered in the
- * platform MBeanServer, or an empty list if there are no such MXBeans.
- */
- public static List<? extends PlatformManagedObject> getMXBeans() {
- return Collections.emptyList();
- }
-
- /**
- * Returns the extended platform MXBean implementing the given
- * mxbeanInterface, or null if there is no such MXBean.
- */
- public static <T extends PlatformManagedObject>
- T getMXBean(Class<T> mxbeanInterface) {
- return null;
- }
-}
--- a/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.management/share/classes/sun/management/ManagementFactoryHelper.java Wed Feb 18 19:27:49 2015 -0800
@@ -42,14 +42,11 @@
import sun.util.logging.LoggingSupport;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import com.sun.management.DiagnosticCommandMBean;
import com.sun.management.HotSpotDiagnosticMXBean;
-import static java.lang.management.ManagementFactory.*;
-
/**
* ManagementFactoryHelper provides static factory methods to create
* instances of the management interface.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/src/java.management/share/classes/sun/management/spi/PlatformMBeanProvider.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,233 @@
+/*
+ * 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.
+ */
+
+package sun.management.spi;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.ServiceLoader;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+/**
+ * The PlatformMBeanProvider class defines the abstract service interface
+ * that the {@link java.lang.management.ManagementFactory} will invoke to find,
+ * load, and register Platform MBeans.
+ *
+ * ManagementFactory loads the {@linkplain ServiceLoader#loadInstalled(java.lang.Class)
+ * installed providers} of this service interface and each provides the
+ * {@linkplain PlatformComponent platform components} that defines MXBean
+ * or DynamicMBean to be registered in the platform MBeanServer.
+ *
+ * A {@code PlatformMBeanProvider} will implement the {@code getPlatformComponentList()}
+ * method to return the list of {@code PlatformComponents} it provides.
+ */
+public abstract class PlatformMBeanProvider {
+ /**
+ * {@code PlatformComponent} models MBeans of a management interface supported
+ * by the platform.
+ *
+ * If a PlatformComponent models a singleton MBean, the {@link #getObjectNamePattern()
+ * ObjectName pattern} must be the {@link
+ * javax.management.ObjectName#getCanonicalName() canonical name} of that
+ * singleton MBean. Otherwise, it must be an ObjectName pattern
+ * that can be used to query the MBeans for this
+ * PlatformComponent registered in a {@code MBeanServer}.
+ * <br>
+ * The {@link #getObjectNamePattern() ObjectName pattern} serves as a unique
+ * key for identifying the instance of PlatformComponent. It is thus illegal
+ * for a given {@link PlatformMBeanProvider} to export several instance of
+ * PlatformComponent with the same
+ * {@link #getObjectNamePattern() ObjectName pattern} string.
+ * <br>
+ * If two different provider instances export a PlatformComponent for the
+ * same ObjectName pattern, only the PlatformComponent instance of the first
+ * provider will be taken into account.
+ *
+ * @param <T> The higher level interface for which the MBeans modeled by
+ * this object should be recognized. For instance, for the {@link
+ * java.lang.management.ManagementFactory#getOperatingSystemMXBean()
+ * Operating System MXBean}, this should be {@link
+ * java.lang.management.OperatingSystemMXBean
+ * java.lang.management.OperatingSystemMXBean}.
+ */
+ public interface PlatformComponent<T> {
+ /**
+ * Returns the names of the management interfaces implemented by the
+ * MBeans modeled by this {@code PlatformComponent}.
+ *
+ * @implNote
+ * When {@link java.lang.management.ManagementFactory#getPlatformMXBean(java.lang.Class)
+ * ManagementFactory.getPlatformMXBean(mxbeanInterface)} or {@link
+ * java.lang.management.ManagementFactory#getPlatformMXBeans(java.lang.Class)
+ * ManagementFactory.getPlatformMXBeans(mxbeanInterface)} are invoked,
+ * this PlatformComponent instance will match only if the name of the
+ * given {@code mxbeanInterface} is found in this list.
+ *
+ * @return the names of the management interfaces exported by the MBeans
+ * modeled by this object.
+ */
+ public Set<String> mbeanInterfaceNames();
+
+ /**
+ * A map from ObjectName string to the MBean instance this
+ * {@code PlatformComponent} creates.
+ *
+ * @implNote
+ * If {@link #shouldRegister()} is {@code true}, this method
+ * will be called when the {@link java.lang.management.ManagementFactory
+ * #getPlatformMBeanServer() Platform MBeanServer} is initialized.
+ * By default, this method will also be called by {@link
+ * #getMBeans(java.lang.Class)}, when {@link
+ * java.lang.management.ManagementFactory#getPlatformMXBean(java.lang.Class)
+ * ManagementFactory.getPlatformMXBean(mxbeanInterface)} or {@link
+ * java.lang.management.ManagementFactory#getPlatformMXBeans(java.lang.Class)
+ * ManagementFactory.getPlatformMXBeans(mxbeanInterface)} are invoked,
+ * and when the name of the given {@code mxbeanInterface} is contained
+ * in the names of management interfaces returned by {@link
+ * #mbeanInterfaceNames()}.
+ *
+ * @return A map with, for each MBean, the ObjectName string as key
+ * and the MBean as value.
+ */
+ public Map<String, T> nameToMBeanMap();
+
+ /**
+ * An ObjectName pattern uniquely identifies the MBeans
+ * modeled by this {@code PlatformComponent}.
+ * If this instance models a singleton MBean, this must be
+ * the {@link
+ * javax.management.ObjectName#getCanonicalName() canonical name}
+ * of that singleton MBean.
+ *
+ * @return An ObjectName pattern uniquely identifies the MBeans
+ * modeled by this instance.
+ */
+ public String getObjectNamePattern();
+
+ /**
+ * Returns {@code true} if this {@code PlatformComponent} models
+ * a singleton MBean. By default, {@code true} is assumed.
+ *
+ * @return {@code true} if this instance models a singleton MBean.
+ */
+ public default boolean isSingleton() {
+ return true;
+ }
+
+ /**
+ * Returns {@code true} if the MBeans modeled by this {@code PlatformComponent}
+ * should automatically be registered in the {@link
+ * java.lang.management.ManagementFactory#getPlatformMBeanServer()
+ * Platform MBeanServer}. By default, {@code true} is assumed.
+ *
+ * @return {@code true} if the MBeans modeled by this instance should
+ * automatically be registered in the Platform MBeanServer.
+ */
+ public default boolean shouldRegister() {
+ return true;
+ }
+
+ /**
+ * The set of interfaces implemented by the MBeans modeled
+ * by this {@code PlatformComponent}.
+ *
+ * @implNote
+ * {@link java.lang.management.ManagementFactory#getPlatformManagementInterfaces()
+ * ManagementFactory.getPlatformManagementInterfaces()} calls this
+ * method to find the management interfaces supported by the platform.
+ *
+ * @return The set of interfaces implemented by the MBeans modeled
+ * by this instance
+ */
+ public Set<Class<? extends T>> mbeanInterfaces();
+
+ /**
+ * Return the list of MBeans that implement the given {@code mbeanIntf}
+ * modeled by this {@code PlatformComponent}. This method returns an
+ * empty list if no MBean implements the given {@code mbeanIntf}.
+ *
+ * @implNote This method will be called when {@link
+ * java.lang.management.ManagementFactory#getPlatformMXBean(java.lang.Class)
+ * ManagementFactory.getPlatformMXBean(mbeanIntf)} or {@link
+ * java.lang.management.ManagementFactory#getPlatformMXBeans(java.lang.Class)
+ * ManagementFactory.getPlatformMXBeans(mbeanIntf)} are invoked.
+ * By default it first checks whether the specified {@code mbeanIntf}
+ * name is contained in the returned list from the {@link #mbeanInterfaceNames()}
+ * method. If yes, it proceeds and calls
+ * {@link #mbeans().values()} and filters out all
+ * MBeans which are not instances of the given {@code mbeanIntf}.
+ * Otherwise, it returns an empty list.
+ *
+ * @param mbeanIntf A management interface.
+ * @return A (possibly empty) list of MBeans implementing the given
+ * {@code mbeanIntf}.
+ */
+ public default <I> List<? extends I> getMBeans(Class<I> mbeanIntf) {
+ List<I> list;
+
+ if (!mbeanInterfaceNames().contains(mbeanIntf.getName())) {
+ list = Collections.emptyList();
+ } else {
+ list = nameToMBeanMap().values().stream()
+ .filter(mbeanIntf::isInstance)
+ .map(mbeanIntf::cast)
+ .collect(Collectors.toList());
+ }
+ return list;
+ }
+ }
+
+ /**
+ * Instantiates a new PlatformMBeanProvider.
+ *
+ * @throws SecurityException if the subclass (and calling code) does not
+ * have {@code RuntimePermission("sun.management.spi.PlatformMBeanProvider", "subclass")}
+ */
+ protected PlatformMBeanProvider () {
+ this(checkSubclassPermission());
+ }
+
+ private PlatformMBeanProvider(Void unused) {
+ }
+
+ /**
+ * Returns a list of PlatformComponent instances describing the Platform
+ * MBeans provided by this provider.
+ *
+ * @return a list of PlatformComponent instances describing the Platform
+ * MBeans provided by this provider.
+ */
+ public abstract List<PlatformComponent<?>> getPlatformComponentList();
+
+ private static Void checkSubclassPermission() {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPermission(new RuntimePermission(PlatformMBeanProvider.class.getName(), "subclass"));
+ }
+ return null;
+ }
+}
--- a/jdk/src/java.scripting/share/classes/javax/script/ScriptEngineFactory.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.scripting/share/classes/javax/script/ScriptEngineFactory.java Wed Feb 18 19:27:49 2015 -0800
@@ -138,6 +138,7 @@
* @return The value for the given parameter. Returns <code>null</code> if no
* value is assigned to the key.
*
+ * @throws NullPointerException if the key is null.
*/
public Object getParameter(String key);
--- a/jdk/src/java.security.acl/share/classes/java/security/acl/Acl.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,241 +0,0 @@
-/*
- * Copyright (c) 1996, 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.
- */
-
-package java.security.acl;
-
-import java.util.Enumeration;
-import java.security.Principal;
-
-/**
- * Interface representing an Access Control List (ACL). An Access
- * Control List is a data structure used to guard access to
- * resources.<p>
- *
- * An ACL can be thought of as a data structure with multiple ACL
- * entries. Each ACL entry, of interface type AclEntry, contains a
- * set of permissions associated with a particular principal. (A
- * principal represents an entity such as an individual user or a
- * group). Additionally, each ACL entry is specified as being either
- * positive or negative. If positive, the permissions are to be
- * granted to the associated principal. If negative, the permissions
- * are to be denied.<p>
- *
- * The ACL Entries in each ACL observe the following rules:
- *
- * <ul> <li>Each principal can have at most one positive ACL entry and
- * one negative entry; that is, multiple positive or negative ACL
- * entries are not allowed for any principal. Each entry specifies
- * the set of permissions that are to be granted (if positive) or
- * denied (if negative).
- *
- * <li>If there is no entry for a particular principal, then the
- * principal is considered to have a null (empty) permission set.
- *
- * <li>If there is a positive entry that grants a principal a
- * particular permission, and a negative entry that denies the
- * principal the same permission, the result is as though the
- * permission was never granted or denied.
- *
- * <li>Individual permissions always override permissions of the
- * group(s) to which the individual belongs. That is, individual
- * negative permissions (specific denial of permissions) override the
- * groups' positive permissions. And individual positive permissions
- * override the groups' negative permissions.
- *
- * </ul>
- *
- * The {@code java.security.acl } package provides the
- * interfaces to the ACL and related data structures (ACL entries,
- * groups, permissions, etc.), and the {@code sun.security.acl }
- * classes provide a default implementation of the interfaces. For
- * example, {@code java.security.acl.Acl } provides the
- * interface to an ACL and the {@code sun.security.acl.AclImpl }
- * class provides the default implementation of the interface.<p>
- *
- * The {@code java.security.acl.Acl } interface extends the
- * {@code java.security.acl.Owner } interface. The Owner
- * interface is used to maintain a list of owners for each ACL. Only
- * owners are allowed to modify an ACL. For example, only an owner can
- * call the ACL's {@code addEntry} method to add a new ACL entry
- * to the ACL.
- *
- * @see java.security.acl.AclEntry
- * @see java.security.acl.Owner
- * @see java.security.acl.Acl#getPermissions
- *
- * @author Satish Dharmaraj
- */
-
-public interface Acl extends Owner {
-
- /**
- * Sets the name of this ACL.
- *
- * @param caller the principal invoking this method. It must be an
- * owner of this ACL.
- *
- * @param name the name to be given to this ACL.
- *
- * @exception NotOwnerException if the caller principal
- * is not an owner of this ACL.
- *
- * @see #getName
- */
- public void setName(Principal caller, String name)
- throws NotOwnerException;
-
- /**
- * Returns the name of this ACL.
- *
- * @return the name of this ACL.
- *
- * @see #setName
- */
- public String getName();
-
- /**
- * Adds an ACL entry to this ACL. An entry associates a principal
- * (e.g., an individual or a group) with a set of
- * permissions. Each principal can have at most one positive ACL
- * entry (specifying permissions to be granted to the principal)
- * and one negative ACL entry (specifying permissions to be
- * denied). If there is already an ACL entry of the same type
- * (negative or positive) already in the ACL, false is returned.
- *
- * @param caller the principal invoking this method. It must be an
- * owner of this ACL.
- *
- * @param entry the ACL entry to be added to this ACL.
- *
- * @return true on success, false if an entry of the same type
- * (positive or negative) for the same principal is already
- * present in this ACL.
- *
- * @exception NotOwnerException if the caller principal
- * is not an owner of this ACL.
- */
- public boolean addEntry(Principal caller, AclEntry entry)
- throws NotOwnerException;
-
- /**
- * Removes an ACL entry from this ACL.
- *
- * @param caller the principal invoking this method. It must be an
- * owner of this ACL.
- *
- * @param entry the ACL entry to be removed from this ACL.
- *
- * @return true on success, false if the entry is not part of this ACL.
- *
- * @exception NotOwnerException if the caller principal is not
- * an owner of this Acl.
- */
- public boolean removeEntry(Principal caller, AclEntry entry)
- throws NotOwnerException;
-
- /**
- * Returns an enumeration for the set of allowed permissions for the
- * specified principal (representing an entity such as an individual or
- * a group). This set of allowed permissions is calculated as
- * follows:
- *
- * <ul>
- *
- * <li>If there is no entry in this Access Control List for the
- * specified principal, an empty permission set is returned.
- *
- * <li>Otherwise, the principal's group permission sets are determined.
- * (A principal can belong to one or more groups, where a group is a
- * group of principals, represented by the Group interface.)
- * The group positive permission set is the union of all
- * the positive permissions of each group that the principal belongs to.
- * The group negative permission set is the union of all
- * the negative permissions of each group that the principal belongs to.
- * If there is a specific permission that occurs in both
- * the positive permission set and the negative permission set,
- * it is removed from both.<p>
- *
- * The individual positive and negative permission sets are also
- * determined. The positive permission set contains the permissions
- * specified in the positive ACL entry (if any) for the principal.
- * Similarly, the negative permission set contains the permissions
- * specified in the negative ACL entry (if any) for the principal.
- * The individual positive (or negative) permission set is considered
- * to be null if there is not a positive (negative) ACL entry for the
- * principal in this ACL.<p>
- *
- * The set of permissions granted to the principal is then calculated
- * using the simple rule that individual permissions always override
- * the group permissions. That is, the principal's individual negative
- * permission set (specific denial of permissions) overrides the group
- * positive permission set, and the principal's individual positive
- * permission set overrides the group negative permission set.
- *
- * </ul>
- *
- * @param user the principal whose permission set is to be returned.
- *
- * @return the permission set specifying the permissions the principal
- * is allowed.
- */
- public Enumeration<Permission> getPermissions(Principal user);
-
- /**
- * Returns an enumeration of the entries in this ACL. Each element in
- * the enumeration is of type AclEntry.
- *
- * @return an enumeration of the entries in this ACL.
- */
- public Enumeration<AclEntry> entries();
-
- /**
- * Checks whether or not the specified principal has the specified
- * permission. If it does, true is returned, otherwise false is returned.
- *
- * More specifically, this method checks whether the passed permission
- * is a member of the allowed permission set of the specified principal.
- * The allowed permission set is determined by the same algorithm as is
- * used by the {@code getPermissions} method.
- *
- * @param principal the principal, assumed to be a valid authenticated
- * Principal.
- *
- * @param permission the permission to be checked for.
- *
- * @return true if the principal has the specified permission, false
- * otherwise.
- *
- * @see #getPermissions
- */
- public boolean checkPermission(Principal principal, Permission permission);
-
- /**
- * Returns a string representation of the
- * ACL contents.
- *
- * @return a string representation of the ACL contents.
- */
- public String toString();
-}
--- a/jdk/src/java.security.acl/share/classes/java/security/acl/AclEntry.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,154 +0,0 @@
-/*
- * Copyright (c) 1996, 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.
- */
-
-package java.security.acl;
-
-import java.util.Enumeration;
-import java.security.Principal;
-
-/**
- * This is the interface used for representing one entry in an Access
- * Control List (ACL).<p>
- *
- * An ACL can be thought of as a data structure with multiple ACL entry
- * objects. Each ACL entry object contains a set of permissions associated
- * with a particular principal. (A principal represents an entity such as
- * an individual user or a group). Additionally, each ACL entry is specified
- * as being either positive or negative. If positive, the permissions are
- * to be granted to the associated principal. If negative, the permissions
- * are to be denied. Each principal can have at most one positive ACL entry
- * and one negative entry; that is, multiple positive or negative ACL
- * entries are not allowed for any principal.
- *
- * Note: ACL entries are by default positive. An entry becomes a
- * negative entry only if the
- * {@link #setNegativePermissions() setNegativePermissions}
- * method is called on it.
- *
- * @see java.security.acl.Acl
- *
- * @author Satish Dharmaraj
- */
-public interface AclEntry extends Cloneable {
-
- /**
- * Specifies the principal for which permissions are granted or denied
- * by this ACL entry. If a principal was already set for this ACL entry,
- * false is returned, otherwise true is returned.
- *
- * @param user the principal to be set for this entry.
- *
- * @return true if the principal is set, false if there was
- * already a principal set for this entry.
- *
- * @see #getPrincipal
- */
- public boolean setPrincipal(Principal user);
-
- /**
- * Returns the principal for which permissions are granted or denied by
- * this ACL entry. Returns null if there is no principal set for this
- * entry yet.
- *
- * @return the principal associated with this entry.
- *
- * @see #setPrincipal
- */
- public Principal getPrincipal();
-
- /**
- * Sets this ACL entry to be a negative one. That is, the associated
- * principal (e.g., a user or a group) will be denied the permission set
- * specified in the entry.
- *
- * Note: ACL entries are by default positive. An entry becomes a
- * negative entry only if this {@code setNegativePermissions}
- * method is called on it.
- */
- public void setNegativePermissions();
-
- /**
- * Returns true if this is a negative ACL entry (one denying the
- * associated principal the set of permissions in the entry), false
- * otherwise.
- *
- * @return true if this is a negative ACL entry, false if it's not.
- */
- public boolean isNegative();
-
- /**
- * Adds the specified permission to this ACL entry. Note: An entry can
- * have multiple permissions.
- *
- * @param permission the permission to be associated with
- * the principal in this entry.
- *
- * @return true if the permission was added, false if the
- * permission was already part of this entry's permission set.
- */
- public boolean addPermission(Permission permission);
-
- /**
- * Removes the specified permission from this ACL entry.
- *
- * @param permission the permission to be removed from this entry.
- *
- * @return true if the permission is removed, false if the
- * permission was not part of this entry's permission set.
- */
- public boolean removePermission(Permission permission);
-
- /**
- * Checks if the specified permission is part of the
- * permission set in this entry.
- *
- * @param permission the permission to be checked for.
- *
- * @return true if the permission is part of the
- * permission set in this entry, false otherwise.
- */
- public boolean checkPermission(Permission permission);
-
- /**
- * Returns an enumeration of the permissions in this ACL entry.
- *
- * @return an enumeration of the permissions in this ACL entry.
- */
- public Enumeration<Permission> permissions();
-
- /**
- * Returns a string representation of the contents of this ACL entry.
- *
- * @return a string representation of the contents.
- */
- public String toString();
-
- /**
- * Clones this ACL entry.
- *
- * @return a clone of this ACL entry.
- */
- public Object clone();
-}
--- a/jdk/src/java.security.acl/share/classes/java/security/acl/AclNotFoundException.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1996, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.security.acl;
-
-/**
- * This is an exception that is thrown whenever a reference is made to a
- * non-existent ACL (Access Control List).
- *
- * @author Satish Dharmaraj
- */
-public class AclNotFoundException extends Exception {
-
- private static final long serialVersionUID = 5684295034092681791L;
-
- /**
- * Constructs an AclNotFoundException.
- */
- public AclNotFoundException() {
- }
-
-}
--- a/jdk/src/java.security.acl/share/classes/java/security/acl/Group.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,87 +0,0 @@
-/*
- * Copyright (c) 1996, 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.
- */
-
-package java.security.acl;
-
-import java.util.Enumeration;
-import java.security.Principal;
-
-/**
- * This interface is used to represent a group of principals. (A principal
- * represents an entity such as an individual user or a company). <p>
- *
- * Note that Group extends Principal. Thus, either a Principal or a Group can
- * be passed as an argument to methods containing a Principal parameter. For
- * example, you can add either a Principal or a Group to a Group object by
- * calling the object's {@code addMember} method, passing it the
- * Principal or Group.
- *
- * @author Satish Dharmaraj
- */
-public interface Group extends Principal {
-
- /**
- * Adds the specified member to the group.
- *
- * @param user the principal to add to this group.
- *
- * @return true if the member was successfully added,
- * false if the principal was already a member.
- */
- public boolean addMember(Principal user);
-
- /**
- * Removes the specified member from the group.
- *
- * @param user the principal to remove from this group.
- *
- * @return true if the principal was removed, or
- * false if the principal was not a member.
- */
- public boolean removeMember(Principal user);
-
- /**
- * Returns true if the passed principal is a member of the group.
- * This method does a recursive search, so if a principal belongs to a
- * group which is a member of this group, true is returned.
- *
- * @param member the principal whose membership is to be checked.
- *
- * @return true if the principal is a member of this group,
- * false otherwise.
- */
- public boolean isMember(Principal member);
-
-
- /**
- * Returns an enumeration of the members in the group.
- * The returned objects can be instances of either Principal
- * or Group (which is a subclass of Principal).
- *
- * @return an enumeration of the group members.
- */
- public Enumeration<? extends Principal> members();
-
-}
--- a/jdk/src/java.security.acl/share/classes/java/security/acl/LastOwnerException.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 1996, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.security.acl;
-
-/**
- * This is an exception that is thrown whenever an attempt is made to delete
- * the last owner of an Access Control List.
- *
- * @see java.security.acl.Owner#deleteOwner
- *
- * @author Satish Dharmaraj
- */
-public class LastOwnerException extends Exception {
-
- private static final long serialVersionUID = -5141997548211140359L;
-
- /**
- * Constructs a LastOwnerException.
- */
- public LastOwnerException() {
- }
-}
--- a/jdk/src/java.security.acl/share/classes/java/security/acl/NotOwnerException.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 1996, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.security.acl;
-
-/**
- * This is an exception that is thrown whenever the modification of an object
- * (such as an Access Control List) is only allowed to be done by an owner of
- * the object, but the Principal attempting the modification is not an owner.
- *
- * @author Satish Dharmaraj
- */
-public class NotOwnerException extends Exception {
-
- private static final long serialVersionUID = -5555597911163362399L;
-
- /**
- * Constructs a NotOwnerException.
- */
- public NotOwnerException() {
- }
-}
--- a/jdk/src/java.security.acl/share/classes/java/security/acl/Owner.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 1996, 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.
- */
-
-package java.security.acl;
-
-import java.security.Principal;
-
-/**
- * Interface for managing owners of Access Control Lists (ACLs) or ACL
- * configurations. (Note that the Acl interface in the
- * {@code java.security.acl} package extends this Owner
- * interface.) The initial owner Principal should be specified as an
- * argument to the constructor of the class implementing this interface.
- *
- * @see java.security.acl.Acl
- *
- */
-public interface Owner {
-
- /**
- * Adds an owner. Only owners can modify ACL contents. The caller
- * principal must be an owner of the ACL in order to invoke this method.
- * That is, only an owner can add another owner. The initial owner is
- * configured at ACL construction time.
- *
- * @param caller the principal invoking this method. It must be an owner
- * of the ACL.
- *
- * @param owner the owner that should be added to the list of owners.
- *
- * @return true if successful, false if owner is already an owner.
- * @exception NotOwnerException if the caller principal is not an owner
- * of the ACL.
- */
- public boolean addOwner(Principal caller, Principal owner)
- throws NotOwnerException;
-
- /**
- * Deletes an owner. If this is the last owner in the ACL, an exception is
- * raised.<p>
- *
- * The caller principal must be an owner of the ACL in order to invoke
- * this method.
- *
- * @param caller the principal invoking this method. It must be an owner
- * of the ACL.
- *
- * @param owner the owner to be removed from the list of owners.
- *
- * @return true if the owner is removed, false if the owner is not part
- * of the list of owners.
- *
- * @exception NotOwnerException if the caller principal is not an owner
- * of the ACL.
- *
- * @exception LastOwnerException if there is only one owner left, so that
- * deleteOwner would leave the ACL owner-less.
- */
- public boolean deleteOwner(Principal caller, Principal owner)
- throws NotOwnerException, LastOwnerException;
-
- /**
- * Returns true if the given principal is an owner of the ACL.
- *
- * @param owner the principal to be checked to determine whether or not
- * it is an owner.
- *
- * @return true if the passed principal is in the list of owners, false
- * if not.
- */
- public boolean isOwner(Principal owner);
-
-}
--- a/jdk/src/java.security.acl/share/classes/java/security/acl/Permission.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package java.security.acl;
-
-
-/**
- * This interface represents a permission, such as that used to grant
- * a particular type of access to a resource.
- *
- * @author Satish Dharmaraj
- */
-public interface Permission {
-
- /**
- * Returns true if the object passed matches the permission represented
- * in this interface.
- *
- * @param another the Permission object to compare with.
- *
- * @return true if the Permission objects are equal, false otherwise
- */
- public boolean equals(Object another);
-
- /**
- * Prints a string representation of this permission.
- *
- * @return the string representation of the permission.
- */
- public String toString();
-
-}
--- a/jdk/src/java.security.acl/share/classes/java/security/acl/package-info.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 1998, 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.
- */
-
-/**
- * The classes and interfaces in this package have been
- * superseded by classes in the java.security package.
- * See that package and, for example, java.security.Permission for details.
- *
- * @since 1.1
- */
-package java.security.acl;
--- a/jdk/src/java.security.acl/share/classes/sun/security/acl/AclEntryImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,181 +0,0 @@
-/*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-package sun.security.acl;
-
-import java.util.*;
-import java.security.Principal;
-import java.security.acl.*;
-
-/**
- * This is a class that describes one entry that associates users
- * or groups with permissions in the ACL.
- * The entry may be used as a way of granting or denying permissions.
- * @author Satish Dharmaraj
- */
-public class AclEntryImpl implements AclEntry {
- private Principal user = null;
- private Vector<Permission> permissionSet = new Vector<>(10, 10);
- private boolean negative = false;
-
- /**
- * Construct an ACL entry that associates a user with permissions
- * in the ACL.
- * @param user The user that is associated with this entry.
- */
- public AclEntryImpl(Principal user) {
- this.user = user;
- }
-
- /**
- * Construct a null ACL entry
- */
- public AclEntryImpl() {
- }
-
- /**
- * Sets the principal in the entity. If a group or a
- * principal had already been set, a false value is
- * returned, otherwise a true value is returned.
- * @param user The user that is associated with this entry.
- * @return true if the principal is set, false if there is
- * one already.
- */
- public boolean setPrincipal(Principal user) {
- if (this.user != null)
- return false;
- this.user = user;
- return true;
- }
-
- /**
- * This method sets the ACL to have negative permissions.
- * That is the user or group is denied the permission set
- * specified in the entry.
- */
- public void setNegativePermissions() {
- negative = true;
- }
-
- /**
- * Returns true if this is a negative ACL.
- */
- public boolean isNegative() {
- return negative;
- }
-
- /**
- * A principal or a group can be associated with multiple
- * permissions. This method adds a permission to the ACL entry.
- * @param permission The permission to be associated with
- * the principal or the group in the entry.
- * @return true if the permission was added, false if the
- * permission was already part of the permission set.
- */
- public boolean addPermission(Permission permission) {
-
- if (permissionSet.contains(permission))
- return false;
-
- permissionSet.addElement(permission);
-
- return true;
- }
-
- /**
- * The method disassociates the permission from the Principal
- * or the Group in this ACL entry.
- * @param permission The permission to be disassociated with
- * the principal or the group in the entry.
- * @return true if the permission is removed, false if the
- * permission is not part of the permission set.
- */
- public boolean removePermission(Permission permission) {
- return permissionSet.removeElement(permission);
- }
-
- /**
- * Checks if the passed permission is part of the allowed
- * permission set in this entry.
- * @param permission The permission that has to be part of
- * the permission set in the entry.
- * @return true if the permission passed is part of the
- * permission set in the entry, false otherwise.
- */
- public boolean checkPermission(Permission permission) {
- return permissionSet.contains(permission);
- }
-
- /**
- * return an enumeration of the permissions in this ACL entry.
- */
- public Enumeration<Permission> permissions() {
- return permissionSet.elements();
- }
-
- /**
- * Return a string representation of the contents of the ACL entry.
- */
- public String toString() {
- StringBuffer s = new StringBuffer();
- if (negative)
- s.append("-");
- else
- s.append("+");
- if (user instanceof Group)
- s.append("Group.");
- else
- s.append("User.");
- s.append(user + "=");
- Enumeration<Permission> e = permissions();
- while(e.hasMoreElements()) {
- Permission p = e.nextElement();
- s.append(p);
- if (e.hasMoreElements())
- s.append(",");
- }
- return new String(s);
- }
-
- /**
- * Clones an AclEntry.
- */
- @SuppressWarnings("unchecked") // Safe casts assuming clone() works correctly
- public synchronized Object clone() {
- AclEntryImpl cloned;
- cloned = new AclEntryImpl(user);
- cloned.permissionSet = (Vector<Permission>) permissionSet.clone();
- cloned.negative = negative;
- return cloned;
- }
-
- /**
- * Return the Principal associated in this ACL entry.
- * The method returns null if the entry uses a group
- * instead of a principal.
- */
- public Principal getPrincipal() {
- return user;
- }
-}
--- a/jdk/src/java.security.acl/share/classes/sun/security/acl/AclImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,408 +0,0 @@
-/*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.acl;
-
-import java.io.*;
-import java.util.*;
-import java.security.Principal;
-import java.security.acl.*;
-
-/**
- * An Access Control List (ACL) is encapsulated by this class.
- * @author Satish Dharmaraj
- */
-public class AclImpl extends OwnerImpl implements Acl {
- //
- // Maintain four tables. one each for positive and negative
- // ACLs. One each depending on whether the entity is a group
- // or principal.
- //
- private Hashtable<Principal, AclEntry> allowedUsersTable =
- new Hashtable<>(23);
- private Hashtable<Principal, AclEntry> allowedGroupsTable =
- new Hashtable<>(23);
- private Hashtable<Principal, AclEntry> deniedUsersTable =
- new Hashtable<>(23);
- private Hashtable<Principal, AclEntry> deniedGroupsTable =
- new Hashtable<>(23);
- private String aclName = null;
- private Vector<Permission> zeroSet = new Vector<>(1,1);
-
-
- /**
- * Constructor for creating an empty ACL.
- */
- public AclImpl(Principal owner, String name) {
- super(owner);
- try {
- setName(owner, name);
- } catch (Exception e) {}
- }
-
- /**
- * Sets the name of the ACL.
- * @param caller the principal who is invoking this method.
- * @param name the name of the ACL.
- * @exception NotOwnerException if the caller principal is
- * not on the owners list of the Acl.
- */
- public void setName(Principal caller, String name)
- throws NotOwnerException
- {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- aclName = name;
- }
-
- /**
- * Returns the name of the ACL.
- * @return the name of the ACL.
- */
- public String getName() {
- return aclName;
- }
-
- /**
- * Adds an ACL entry to this ACL. An entry associates a
- * group or a principal with a set of permissions. Each
- * user or group can have one positive ACL entry and one
- * negative ACL entry. If there is one of the type (negative
- * or positive) already in the table, a false value is returned.
- * The caller principal must be a part of the owners list of
- * the ACL in order to invoke this method.
- * @param caller the principal who is invoking this method.
- * @param entry the ACL entry that must be added to the ACL.
- * @return true on success, false if the entry is already present.
- * @exception NotOwnerException if the caller principal
- * is not on the owners list of the Acl.
- */
- public synchronized boolean addEntry(Principal caller, AclEntry entry)
- throws NotOwnerException
- {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- Hashtable<Principal, AclEntry> aclTable = findTable(entry);
- Principal key = entry.getPrincipal();
-
- if (aclTable.get(key) != null)
- return false;
-
- aclTable.put(key, entry);
- return true;
- }
-
- /**
- * Removes an ACL entry from this ACL.
- * The caller principal must be a part of the owners list of the ACL
- * in order to invoke this method.
- * @param caller the principal who is invoking this method.
- * @param entry the ACL entry that must be removed from the ACL.
- * @return true on success, false if the entry is not part of the ACL.
- * @exception NotOwnerException if the caller principal is not
- * the owners list of the Acl.
- */
- public synchronized boolean removeEntry(Principal caller, AclEntry entry)
- throws NotOwnerException
- {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- Hashtable<Principal, AclEntry> aclTable = findTable(entry);
- Principal key = entry.getPrincipal();
-
- AclEntry o = aclTable.remove(key);
- return (o != null);
- }
-
- /**
- * This method returns the set of allowed permissions for the
- * specified principal. This set of allowed permissions is calculated
- * as follows:
- *
- * If there is no entry for a group or a principal an empty permission
- * set is assumed.
- *
- * The group positive permission set is the union of all
- * the positive permissions of each group that the individual belongs to.
- * The group negative permission set is the union of all
- * the negative permissions of each group that the individual belongs to.
- * If there is a specific permission that occurs in both
- * the postive permission set and the negative permission set,
- * it is removed from both. The group positive and negatoive permission
- * sets are calculated.
- *
- * The individial positive permission set and the individual negative
- * permission set is then calculated. Again abscence of an entry means
- * the empty set.
- *
- * The set of permissions granted to the principal is then calculated using
- * the simple rule: Individual permissions always override the Group permissions.
- * Specifically, individual negative permission set (specific
- * denial of permissions) overrides the group positive permission set.
- * And the individual positive permission set override the group negative
- * permission set.
- *
- * @param user the principal for which the ACL entry is returned.
- * @return The resulting permission set that the principal is allowed.
- */
- public synchronized Enumeration<Permission> getPermissions(Principal user) {
-
- Enumeration<Permission> individualPositive;
- Enumeration<Permission> individualNegative;
- Enumeration<Permission> groupPositive;
- Enumeration<Permission> groupNegative;
-
- //
- // canonicalize the sets. That is remove common permissions from
- // positive and negative sets.
- //
- groupPositive =
- subtract(getGroupPositive(user), getGroupNegative(user));
- groupNegative =
- subtract(getGroupNegative(user), getGroupPositive(user));
- individualPositive =
- subtract(getIndividualPositive(user), getIndividualNegative(user));
- individualNegative =
- subtract(getIndividualNegative(user), getIndividualPositive(user));
-
- //
- // net positive permissions is individual positive permissions
- // plus (group positive - individual negative).
- //
- Enumeration<Permission> temp1 =
- subtract(groupPositive, individualNegative);
- Enumeration<Permission> netPositive =
- union(individualPositive, temp1);
-
- // recalculate the enumeration since we lost it in performing the
- // subtraction
- //
- individualPositive =
- subtract(getIndividualPositive(user), getIndividualNegative(user));
- individualNegative =
- subtract(getIndividualNegative(user), getIndividualPositive(user));
-
- //
- // net negative permissions is individual negative permissions
- // plus (group negative - individual positive).
- //
- temp1 = subtract(groupNegative, individualPositive);
- Enumeration<Permission> netNegative = union(individualNegative, temp1);
-
- return subtract(netPositive, netNegative);
- }
-
- /**
- * This method checks whether or not the specified principal
- * has the required permission. If permission is denied
- * permission false is returned, a true value is returned otherwise.
- * This method does not authenticate the principal. It presumes that
- * the principal is a valid authenticated principal.
- * @param principal the name of the authenticated principal
- * @param permission the permission that the principal must have.
- * @return true of the principal has the permission desired, false
- * otherwise.
- */
- public boolean checkPermission(Principal principal, Permission permission)
- {
- Enumeration<Permission> permSet = getPermissions(principal);
- while (permSet.hasMoreElements()) {
- Permission p = permSet.nextElement();
- if (p.equals(permission))
- return true;
- }
- return false;
- }
-
- /**
- * returns an enumeration of the entries in this ACL.
- */
- public synchronized Enumeration<AclEntry> entries() {
- return new AclEnumerator(this,
- allowedUsersTable, allowedGroupsTable,
- deniedUsersTable, deniedGroupsTable);
- }
-
- /**
- * return a stringified version of the
- * ACL.
- */
- public String toString() {
- StringBuilder sb = new StringBuilder();
- Enumeration<AclEntry> entries = entries();
- while (entries.hasMoreElements()) {
- AclEntry entry = entries.nextElement();
- sb.append(entry.toString().trim());
- sb.append("\n");
- }
-
- return sb.toString();
- }
-
- //
- // Find the table that this entry belongs to. There are 4
- // tables that are maintained. One each for postive and
- // negative ACLs and one each for groups and users.
- // This method figures out which
- // table is the one that this AclEntry belongs to.
- //
- private Hashtable<Principal, AclEntry> findTable(AclEntry entry) {
- Hashtable<Principal, AclEntry> aclTable = null;
-
- Principal p = entry.getPrincipal();
- if (p instanceof Group) {
- if (entry.isNegative())
- aclTable = deniedGroupsTable;
- else
- aclTable = allowedGroupsTable;
- } else {
- if (entry.isNegative())
- aclTable = deniedUsersTable;
- else
- aclTable = allowedUsersTable;
- }
- return aclTable;
- }
-
- //
- // returns the set e1 U e2.
- //
- private static Enumeration<Permission> union(Enumeration<Permission> e1,
- Enumeration<Permission> e2) {
- Vector<Permission> v = new Vector<>(20, 20);
-
- while (e1.hasMoreElements())
- v.addElement(e1.nextElement());
-
- while (e2.hasMoreElements()) {
- Permission o = e2.nextElement();
- if (!v.contains(o))
- v.addElement(o);
- }
-
- return v.elements();
- }
-
- //
- // returns the set e1 - e2.
- //
- private Enumeration<Permission> subtract(Enumeration<Permission> e1,
- Enumeration<Permission> e2) {
- Vector<Permission> v = new Vector<>(20, 20);
-
- while (e1.hasMoreElements())
- v.addElement(e1.nextElement());
-
- while (e2.hasMoreElements()) {
- Permission o = e2.nextElement();
- if (v.contains(o))
- v.removeElement(o);
- }
-
- return v.elements();
- }
-
- private Enumeration<Permission> getGroupPositive(Principal user) {
- Enumeration<Permission> groupPositive = zeroSet.elements();
- Enumeration<Principal> e = allowedGroupsTable.keys();
- while (e.hasMoreElements()) {
- Group g = (Group)e.nextElement();
- if (g.isMember(user)) {
- AclEntry ae = allowedGroupsTable.get(g);
- groupPositive = union(ae.permissions(), groupPositive);
- }
- }
- return groupPositive;
- }
-
- private Enumeration<Permission> getGroupNegative(Principal user) {
- Enumeration<Permission> groupNegative = zeroSet.elements();
- Enumeration<Principal> e = deniedGroupsTable.keys();
- while (e.hasMoreElements()) {
- Group g = (Group)e.nextElement();
- if (g.isMember(user)) {
- AclEntry ae = deniedGroupsTable.get(g);
- groupNegative = union(ae.permissions(), groupNegative);
- }
- }
- return groupNegative;
- }
-
- private Enumeration<Permission> getIndividualPositive(Principal user) {
- Enumeration<Permission> individualPositive = zeroSet.elements();
- AclEntry ae = allowedUsersTable.get(user);
- if (ae != null)
- individualPositive = ae.permissions();
- return individualPositive;
- }
-
- private Enumeration<Permission> getIndividualNegative(Principal user) {
- Enumeration<Permission> individualNegative = zeroSet.elements();
- AclEntry ae = deniedUsersTable.get(user);
- if (ae != null)
- individualNegative = ae.permissions();
- return individualNegative;
- }
-}
-
-final class AclEnumerator implements Enumeration<AclEntry> {
- Acl acl;
- Enumeration<AclEntry> u1, u2, g1, g2;
-
- AclEnumerator(Acl acl, Hashtable<?,AclEntry> u1, Hashtable<?,AclEntry> g1,
- Hashtable<?,AclEntry> u2, Hashtable<?,AclEntry> g2) {
- this.acl = acl;
- this.u1 = u1.elements();
- this.u2 = u2.elements();
- this.g1 = g1.elements();
- this.g2 = g2.elements();
- }
-
- public boolean hasMoreElements() {
- return (u1.hasMoreElements() ||
- u2.hasMoreElements() ||
- g1.hasMoreElements() ||
- g2.hasMoreElements());
- }
-
- public AclEntry nextElement()
- {
- AclEntry o;
- synchronized (acl) {
- if (u1.hasMoreElements())
- return u1.nextElement();
- if (u2.hasMoreElements())
- return u2.nextElement();
- if (g1.hasMoreElements())
- return g1.nextElement();
- if (g2.hasMoreElements())
- return g2.nextElement();
- }
- throw new NoSuchElementException("Acl Enumerator");
- }
-}
--- a/jdk/src/java.security.acl/share/classes/sun/security/acl/AllPermissionsImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 1996, 1997, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.acl;
-
-import java.security.Principal;
-import java.security.acl.*;
-
-/**
- * This class implements the principal interface for the set of all permissions.
- * @author Satish Dharmaraj
- */
-public class AllPermissionsImpl extends PermissionImpl {
-
- public AllPermissionsImpl(String s) {
- super(s);
- }
-
- /**
- * This function returns true if the permission passed matches the permission represented in
- * this interface.
- * @param another The Permission object to compare with.
- * @returns true always
- */
- public boolean equals(Permission another) {
- return true;
- }
-}
--- a/jdk/src/java.security.acl/share/classes/sun/security/acl/GroupImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,186 +0,0 @@
-/*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.acl;
-
-import java.util.*;
-import java.security.*;
-import java.security.acl.*;
-
-/**
- * This class implements a group of principals.
- * @author Satish Dharmaraj
- */
-public class GroupImpl implements Group {
- private Vector<Principal> groupMembers = new Vector<>(50, 100);
- private String group;
-
- /**
- * Constructs a Group object with no members.
- * @param groupName the name of the group
- */
- public GroupImpl(String groupName) {
- this.group = groupName;
- }
-
- /**
- * adds the specified member to the group.
- * @param user The principal to add to the group.
- * @return true if the member was added - false if the
- * member could not be added.
- */
- public boolean addMember(Principal user) {
- if (groupMembers.contains(user))
- return false;
-
- // do not allow groups to be added to itself.
- if (group.equals(user.toString()))
- throw new IllegalArgumentException();
-
- groupMembers.addElement(user);
- return true;
- }
-
- /**
- * removes the specified member from the group.
- * @param user The principal to remove from the group.
- * @param true if the principal was removed false if
- * the principal was not a member
- */
- public boolean removeMember(Principal user) {
- return groupMembers.removeElement(user);
- }
-
- /**
- * returns the enumeration of the members in the group.
- */
- public Enumeration<? extends Principal> members() {
- return groupMembers.elements();
- }
-
- /**
- * This function returns true if the group passed matches
- * the group represented in this interface.
- * @param another The group to compare this group to.
- */
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj instanceof Group == false) {
- return false;
- }
- Group another = (Group)obj;
- return group.equals(another.toString());
- }
-
- // equals(Group) for compatibility
- public boolean equals(Group another) {
- return equals((Object)another);
- }
-
- /**
- * Prints a stringified version of the group.
- */
- public String toString() {
- return group;
- }
-
- /**
- * return a hashcode for the principal.
- */
- public int hashCode() {
- return group.hashCode();
- }
-
- /**
- * returns true if the passed principal is a member of the group.
- * @param member The principal whose membership must be checked for.
- * @return true if the principal is a member of this group,
- * false otherwise
- */
- public boolean isMember(Principal member) {
-
- //
- // if the member is part of the group (common case), return true.
- // if not, recursively search depth first in the group looking for the
- // principal.
- //
- if (groupMembers.contains(member)) {
- return true;
- } else {
- Vector<Group> alreadySeen = new Vector<>(10);
- return isMemberRecurse(member, alreadySeen);
- }
- }
-
- /**
- * return the name of the principal.
- */
- public String getName() {
- return group;
- }
-
- //
- // This function is the recursive search of groups for this
- // implementation of the Group. The search proceeds building up
- // a vector of already seen groups. Only new groups are considered,
- // thereby avoiding loops.
- //
- boolean isMemberRecurse(Principal member, Vector<Group> alreadySeen) {
- Enumeration<? extends Principal> e = members();
- while (e.hasMoreElements()) {
- boolean mem = false;
- Principal p = (Principal) e.nextElement();
-
- // if the member is in this collection, return true
- if (p.equals(member)) {
- return true;
- } else if (p instanceof GroupImpl) {
- //
- // if not recurse if the group has not been checked already.
- // Can call method in this package only if the object is an
- // instance of this class. Otherwise call the method defined
- // in the interface. (This can lead to a loop if a mixture of
- // implementations form a loop, but we live with this improbable
- // case rather than clutter the interface by forcing the
- // implementation of this method.)
- //
- GroupImpl g = (GroupImpl) p;
- alreadySeen.addElement(this);
- if (!alreadySeen.contains(g))
- mem = g.isMemberRecurse(member, alreadySeen);
- } else if (p instanceof Group) {
- Group g = (Group) p;
- if (!alreadySeen.contains(g))
- mem = g.isMember(member);
- }
-
- if (mem)
- return mem;
- }
- return false;
- }
-}
--- a/jdk/src/java.security.acl/share/classes/sun/security/acl/OwnerImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,108 +0,0 @@
-/*
- * Copyright (c) 1996, 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.acl;
-
-import java.util.*;
-import java.security.*;
-import java.security.acl.*;
-
-/**
- * Class implementing the Owner interface. The
- * initial owner principal is configured as
- * part of the constructor.
- * @author Satish Dharmaraj
- */
-public class OwnerImpl implements Owner {
- private Group ownerGroup;
-
- public OwnerImpl(Principal owner) {
- ownerGroup = new GroupImpl("AclOwners");
- ownerGroup.addMember(owner);
- }
-
- /**
- * Adds an owner. Owners can modify ACL contents and can disassociate
- * ACLs from the objects they protect in the AclConfig interface.
- * The caller principal must be a part of the owners list of the ACL in
- * order to invoke this method. The initial owner is configured
- * at ACL construction time.
- * @param caller the principal who is invoking this method.
- * @param owner The owner that should be added to the owners list.
- * @return true if success, false if already an owner.
- * @exception NotOwnerException if the caller principal is not on
- * the owners list of the Acl.
- */
- public synchronized boolean addOwner(Principal caller, Principal owner)
- throws NotOwnerException
- {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- ownerGroup.addMember(owner);
- return false;
- }
-
- /**
- * Delete owner. If this is the last owner in the ACL, an exception is
- * raised.
- * The caller principal must be a part of the owners list of the ACL in
- * order to invoke this method.
- * @param caller the principal who is invoking this method.
- * @param owner The owner to be removed from the owners list.
- * @return true if the owner is removed, false if the owner is not part
- * of the owners list.
- * @exception NotOwnerException if the caller principal is not on
- * the owners list of the Acl.
- * @exception LastOwnerException if there is only one owner left in the group, then
- * deleteOwner would leave the ACL owner-less. This exception is raised in such a case.
- */
- public synchronized boolean deleteOwner(Principal caller, Principal owner)
- throws NotOwnerException, LastOwnerException
- {
- if (!isOwner(caller))
- throw new NotOwnerException();
-
- Enumeration<? extends Principal> e = ownerGroup.members();
- //
- // check if there is atleast 2 members left.
- //
- Object o = e.nextElement();
- if (e.hasMoreElements())
- return ownerGroup.removeMember(owner);
- else
- throw new LastOwnerException();
-
- }
-
- /**
- * returns if the given principal belongs to the owner list.
- * @param owner The owner to check if part of the owners list
- * @return true if the passed principal is in the owner list, false if not.
- */
- public synchronized boolean isOwner(Principal owner) {
- return ownerGroup.isMember(owner);
- }
-}
--- a/jdk/src/java.security.acl/share/classes/sun/security/acl/PermissionImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
- * Copyright (c) 1996, 1999, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.acl;
-
-import java.security.Principal;
-import java.security.acl.*;
-
-/**
- * The PermissionImpl class implements the permission
- * interface for permissions that are strings.
- * @author Satish Dharmaraj
- */
-public class PermissionImpl implements Permission {
-
- private String permission;
-
- /**
- * Construct a permission object using a string.
- * @param permission the stringified version of the permission.
- */
- public PermissionImpl(String permission) {
- this.permission = permission;
- }
-
- /**
- * This function returns true if the object passed matches the permission
- * represented in this interface.
- * @param another The Permission object to compare with.
- * @return true if the Permission objects are equal, false otherwise
- */
- public boolean equals(Object another) {
- if (another instanceof Permission) {
- Permission p = (Permission) another;
- return permission.equals(p.toString());
- } else {
- return false;
- }
- }
-
- /**
- * Prints a stringified version of the permission.
- * @return the string representation of the Permission.
- */
- public String toString() {
- return permission;
- }
-
- /**
- * Returns a hashcode for this PermissionImpl.
- *
- * @return a hashcode for this PermissionImpl.
- */
- public int hashCode() {
- return toString().hashCode();
- }
-
-}
--- a/jdk/src/java.security.acl/share/classes/sun/security/acl/PrincipalImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,83 +0,0 @@
-/*
- * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.acl;
-
-import java.security.*;
-
-/**
- * This class implements the principal interface.
- *
- * @author Satish Dharmaraj
- */
-public class PrincipalImpl implements Principal {
-
- private String user;
-
- /**
- * Construct a principal from a string user name.
- * @param user The string form of the principal name.
- */
- public PrincipalImpl(String user) {
- this.user = user;
- }
-
- /**
- * This function returns true if the object passed matches
- * the principal represented in this implementation
- * @param another the Principal to compare with.
- * @return true if the Principal passed is the same as that
- * encapsulated in this object, false otherwise
- */
- public boolean equals(Object another) {
- if (another instanceof PrincipalImpl) {
- PrincipalImpl p = (PrincipalImpl) another;
- return user.equals(p.toString());
- } else
- return false;
- }
-
- /**
- * Prints a stringified version of the principal.
- */
- public String toString() {
- return user;
- }
-
- /**
- * return a hashcode for the principal.
- */
- public int hashCode() {
- return user.hashCode();
- }
-
- /**
- * return the name of the principal.
- */
- public String getName() {
- return user;
- }
-
-}
--- a/jdk/src/java.security.acl/share/classes/sun/security/acl/WorldGroupImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 1996, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.security.acl;
-
-import java.security.*;
-
-/**
- * This class implements a group of principals.
- * @author Satish Dharmaraj
- */
-public class WorldGroupImpl extends GroupImpl {
-
- public WorldGroupImpl(String s) {
- super(s);
- }
-
- /**
- * returns true for all passed principals
- * @param member The principal whose membership must be checked in this Group.
- * @return true always since this is the "world" group.
- */
- public boolean isMember(Principal member) {
- return true;
- }
-}
--- a/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbApReq.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/java.security.jgss/share/classes/sun/security/krb5/KrbApReq.java Wed Feb 18 19:27:49 2015 -0800
@@ -60,16 +60,6 @@
private static boolean DEBUG = Krb5.DEBUG;
private static final char[] hexConst = "0123456789ABCDEF".toCharArray();
- private static final MessageDigest md;
-
- static {
- try {
- md = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException ex) {
- throw new RuntimeException("Impossible");
- }
- }
-
/**
* Constructs an AP-REQ message to send to the peer.
* @param tgsCred the <code>Credentials</code> to be used to construct the
@@ -99,10 +89,10 @@
* @param tgsCred the <code>Credentials</code> to be used to construct the
* AP Request protocol message.
* @param mutualRequired Whether mutual authentication is required
- * @param useSubkey Whether the subkey is to be used to protect this
+ * @param useSubKey Whether the subkey is to be used to protect this
* specific application session. If this is not set then the
* session key from the ticket will be used.
- * @param checksum checksum of the application data that accompanies
+ * @param cksum checksum of the application data that accompanies
* the KRB_AP_REQ.
* @throws KrbException for any Kerberos protocol specific error
* @throws IOException for any IO related errors
@@ -142,8 +132,8 @@
* Constructs an AP-REQ message from the bytes received from the
* peer.
* @param message The message received from the peer
- * @param keys <code>EncrtyptionKey</code>s to decrypt the message;
- * key selected will depend on etype used to encrypte data
+ * @param cred <code>KrbAcceptCredential</code> containing keys to decrypt
+ * the message; key selected will depend on etype used to encrypt data
* @throws KrbException for any Kerberos protocol specific error
* @throws IOException for any IO related errors
* (e.g. socket operations)
@@ -311,7 +301,14 @@
if (!authenticator.ctime.inClockSkew())
throw new KrbApErrException(Krb5.KRB_AP_ERR_SKEW);
- byte[] hash = md.digest(apReqMessg.authenticator.cipher);
+ byte[] hash;
+ try {
+ hash = MessageDigest.getInstance("MD5")
+ .digest(apReqMessg.authenticator.cipher);
+ } catch (NoSuchAlgorithmException ex) {
+ throw new AssertionError("Impossible");
+ }
+
char[] h = new char[hash.length * 2];
for (int i=0; i<hash.length; i++) {
h[2*i] = hexConst[(hash[i]&0xff)>>4];
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/de/TimeZoneNames_de.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/de/TimeZoneNames_de.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -409,7 +409,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"Venezuelanische Zeit", "VET",
"Venezuelanische Sommerzeit", "VEST",
"Venezuelanische Zeit", "VET"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/es/TimeZoneNames_es.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/es/TimeZoneNames_es.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -409,7 +409,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"Hora de Venezuela", "VET",
"Hora de verano de Venezuela", "VEST",
"Hora de Venezuela", "VET"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/fr/TimeZoneNames_fr.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -409,7 +409,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"Heure du Venezuela", "VET",
"Heure d'\u00e9t\u00e9 du Venezuela", "VEST",
"Heure du Venezuela", "VET"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/it/TimeZoneNames_it.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/it/TimeZoneNames_it.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -409,7 +409,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"Ora del Venezuela", "VET",
"Ora estiva del Venezuela", "VEST",
"Ora del Venezuela", "VET"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ja/TimeZoneNames_ja.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -409,7 +409,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"\u30d9\u30cd\u30ba\u30a8\u30e9\u6642\u9593", "VET",
"\u30d9\u30cd\u30ba\u30a8\u30e9\u590f\u6642\u9593", "VEST",
"\u30D9\u30CD\u30BA\u30A8\u30E9\u6642\u9593", "VET"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/ko/TimeZoneNames_ko.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -409,7 +409,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"\ubca0\ub124\uc218\uc5d8\ub77c \uc2dc\uac04", "VET",
"\ubca0\ub124\uc218\uc5d8\ub77c \uc77c\uad11\uc808\uc57d\uc2dc\uac04", "VEST",
"\uBCA0\uB124\uC218\uC5D8\uB77C \uD45C\uC900\uC2DC", "VET"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/pt/TimeZoneNames_pt_BR.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -409,7 +409,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"Fuso hor\u00e1rio da Venezuela", "VET",
"Fuso hor\u00e1rio de ver\u00e3o da Venezuela", "VEST",
"Hor\u00E1rio da Venezuela", "VET"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/sv/TimeZoneNames_sv.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -409,7 +409,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"Venezuela, normaltid", "VET",
"Venezuela, sommartid", "VEST",
"Venezuelansk tid", "VET"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_CN.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -409,7 +409,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"\u59d4\u5185\u745e\u62c9\u65f6\u95f4", "VET",
"\u59d4\u5185\u745e\u62c9\u590f\u4ee4\u65f6", "VEST",
"\u59D4\u5185\u745E\u62C9\u65F6\u95F4", "VET"}},
--- a/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.localedata/share/classes/sun/util/resources/zh/TimeZoneNames_zh_TW.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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
@@ -409,7 +409,7 @@
{"America/Buenos_Aires", AGT},
{"America/Cambridge_Bay", MST},
{"America/Campo_Grande", AMT},
- {"America/Cancun", CST},
+ {"America/Cancun", EST},
{"America/Caracas", new String[] {"\u59d4\u5167\u745e\u62c9\u6642\u9593", "VET",
"\u59d4\u5167\u745e\u62c9\u590f\u4ee4\u6642\u9593", "VEST",
"\u59D4\u5167\u745E\u62C9\u6642\u9593", "VET"}},
--- a/jdk/src/jdk.rmic/share/classes/sun/rmi/rmic/BatchEnvironment.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.rmic/share/classes/sun/rmi/rmic/BatchEnvironment.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -61,6 +61,7 @@
* they are subject to change or removal without notice.
*/
+@SuppressWarnings("deprecation")
public class BatchEnvironment extends sun.tools.javac.BatchEnvironment {
/** instance of Main which created this environment */
--- a/jdk/src/jdk.rmic/share/classes/sun/rmi/rmic/Main.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.rmic/share/classes/sun/rmi/rmic/Main.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 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
@@ -676,7 +676,7 @@
* Compile a single class.
* Fallthrough is intentional
*/
- @SuppressWarnings("fallthrough")
+ @SuppressWarnings({"fallthrough", "deprecation"})
public boolean compileClass (ClassDeclaration c,
ByteArrayOutputStream buf,
BatchEnvironment env)
--- a/jdk/src/jdk.rmic/share/classes/sun/tools/java/BinaryClass.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.rmic/share/classes/sun/tools/java/BinaryClass.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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 @@
* supported API. Code that depends on them does so at its own risk:
* they are subject to change or removal without notice.
*/
+@SuppressWarnings("deprecation")
public final
class BinaryClass extends ClassDefinition implements Constants {
BinaryConstantPool cpool;
--- a/jdk/src/jdk.rmic/share/classes/sun/tools/java/ClassDefinition.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.rmic/share/classes/sun/tools/java/ClassDefinition.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -41,6 +41,7 @@
* supported API. Code that depends on them does so at its own risk:
* they are subject to change or removal without notice.
*/
+@SuppressWarnings("deprecation")
public
class ClassDefinition implements Constants {
--- a/jdk/src/jdk.rmic/share/classes/sun/tools/java/MemberDefinition.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.rmic/share/classes/sun/tools/java/MemberDefinition.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -44,6 +44,7 @@
* supported API. Code that depends on them does so at its own risk:
* they are subject to change or removal without notice.
*/
+@SuppressWarnings("deprecation")
public
class MemberDefinition implements Constants {
protected long where;
--- a/jdk/src/jdk.rmic/share/classes/sun/tools/java/Scanner.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/src/jdk.rmic/share/classes/sun/tools/java/Scanner.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1994, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1994, 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
@@ -58,6 +58,7 @@
* @author Arthur van Hoff
*/
+@SuppressWarnings("deprecation")
public
class Scanner implements Constants {
/**
--- a/jdk/test/Makefile Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/Makefile Wed Feb 18 19:27:49 2015 -0800
@@ -267,8 +267,8 @@
EXTRA_JTREG_OPTIONS += -concurrency:$(CONCURRENCY)
endif
-# Default JTREG to run (win32 script works for everybody)
-JTREG = $(JT_HOME)/win32/bin/jtreg
+# Default JTREG to run
+JTREG = $(JT_HOME)/bin/jtreg
# run in agentvm mode
JTREG_BASIC_OPTIONS += -agentvm
# Only run automatic tests
--- a/jdk/test/ProblemList.txt Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/ProblemList.txt Wed Feb 18 19:27:49 2015 -0800
@@ -1,6 +1,6 @@
###########################################################################
#
-# Copyright (c) 2009, 2014, 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
@@ -123,7 +123,6 @@
# 8029891
java/lang/ClassLoader/deadlock/GetResource.java generic-all
-
############################################################################
# jdk_instrument
@@ -132,6 +131,9 @@
java/lang/instrument/RedefineBigClass.sh generic-all
java/lang/instrument/RetransformBigClass.sh generic-all
+# 8072130
+java/lang/instrument/BootClassPath/BootClassPathTest.sh macosx-all
+
############################################################################
# jdk_management
@@ -139,6 +141,9 @@
# 8058492
java/lang/management/ThreadMXBean/FindDeadlocks.java generic-all
+# 8069286
+java/lang/management/MemoryMXBean/LowMemoryTest.java generic-all
+
############################################################################
# jdk_jmx
@@ -162,6 +167,9 @@
# 6988950
demo/jvmti/compiledMethodLoad/CompiledMethodLoadTest.java generic-all
+# 8071968
+javax/xml/ws/8046817/GenerateEnumSchema.java windows-all
+
############################################################################
# jdk_net
@@ -290,15 +298,18 @@
# 8043571
com/sun/jdi/RepStep.java generic-all
-# 8044419
-com/sun/jdi/JdbReadTwiceTest.sh generic-all
-
# 8058616
com/sun/jdi/RedefinePop.sh generic-all
# 8068645
com/sun/jdi/CatchPatternTest.sh generic-all
+# 8069402
+com/sun/jdi/ConnectedVMs.java generic-all
+
+# 8067354
+com/sun/jdi/GetLocalVariables4Test.sh windows-all
+
############################################################################
# jdk_util
@@ -317,6 +328,9 @@
# 8031482
sun/tools/jcmd/TestJcmdSanity.java windows-all
+# 8072131
+sun/tools/jmap/heapconfig/JMapHeapConfigTest.java macosx-all
+
# 8027668
sun/tools/jstatd/TestJstatdDefaults.java generic-all
sun/tools/jstatd/TestJstatdServer.java generic-all
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/com/sun/crypto/provider/Cipher/AES/TestGHASH.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2015, Red Hat, Inc.
+ * 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 8069072
+ * @summary Test vectors for com.sun.crypto.provider.GHASH
+ */
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.nio.ByteBuffer;
+
+public class TestGHASH {
+
+ private final Constructor<?> GHASH;
+ private final Method UPDATE;
+ private final Method DIGEST;
+
+ TestGHASH(String className) throws Exception {
+ Class<?> cls = Class.forName(className);
+ GHASH = cls.getDeclaredConstructor(byte[].class);
+ GHASH.setAccessible(true);
+ UPDATE = cls.getDeclaredMethod("update", byte[].class);
+ UPDATE.setAccessible(true);
+ DIGEST = cls.getDeclaredMethod("digest");
+ DIGEST.setAccessible(true);
+ }
+
+
+ private Object newGHASH(byte[] H) throws Exception {
+ return GHASH.newInstance(H);
+ }
+
+ private void updateGHASH(Object hash, byte[] data)
+ throws Exception {
+ UPDATE.invoke(hash, data);
+ }
+
+ private byte[] digestGHASH(Object hash) throws Exception {
+ return (byte[]) DIGEST.invoke(hash);
+ }
+
+ private static final String HEX_DIGITS = "0123456789abcdef";
+
+ private static String hex(byte[] bs) {
+ StringBuilder sb = new StringBuilder(2 * bs.length);
+ for (byte b : bs) {
+ sb.append(HEX_DIGITS.charAt((b >> 4) & 0xF));
+ sb.append(HEX_DIGITS.charAt(b & 0xF));
+ }
+ return sb.toString();
+ }
+
+ private static byte[] bytes(String hex) {
+ if ((hex.length() & 1) != 0) {
+ throw new AssertionError();
+ }
+ byte[] result = new byte[hex.length() / 2];
+ for (int i = 0; i < result.length; ++i) {
+ int a = HEX_DIGITS.indexOf(hex.charAt(2 * i));
+ int b = HEX_DIGITS.indexOf(hex.charAt(2 * i + 1));
+ if ((a | b) < 0) {
+ if (a < 0) {
+ throw new AssertionError(
+ "bad character " + (int) hex.charAt(2 * i));
+ }
+ throw new AssertionError(
+ "bad character " + (int) hex.charAt(2 * i + 1));
+ }
+ result[i] = (byte) ((a << 4) | b);
+ }
+ return result;
+ }
+
+ private static byte[] bytes(long L0, long L1) {
+ return ByteBuffer.allocate(16)
+ .putLong(L0)
+ .putLong(L1)
+ .array();
+ }
+
+ private void check(int testCase, String H, String A,
+ String C, String expected) throws Exception {
+ int lenA = A.length() * 4;
+ while ((A.length() % 32) != 0) {
+ A += '0';
+ }
+ int lenC = C.length() * 4;
+ while ((C.length() % 32) != 0) {
+ C += '0';
+ }
+
+ Object hash = newGHASH(bytes(H));
+ updateGHASH(hash, bytes(A));
+ updateGHASH(hash, bytes(C));
+ updateGHASH(hash, bytes(lenA, lenC));
+ byte[] digest = digestGHASH(hash);
+ String actual = hex(digest);
+ if (!expected.equals(actual)) {
+ throw new AssertionError(String.format("%d: expected %s, got %s",
+ testCase, expected, actual));
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ TestGHASH test;
+ if (args.length == 0) {
+ test = new TestGHASH("com.sun.crypto.provider.GHASH");
+ } else {
+ test = new TestGHASH(args[0]);
+ }
+
+ // Test vectors from David A. McGrew, John Viega,
+ // "The Galois/Counter Mode of Operation (GCM)", 2005.
+ // <http://csrc.nist.gov/groups/ST/toolkit/BCM/documents/proposedmodes/gcm/gcm-revised-spec.pdf>
+
+ test.check(1, "66e94bd4ef8a2c3b884cfa59ca342b2e", "", "",
+ "00000000000000000000000000000000");
+ test.check(2,
+ "66e94bd4ef8a2c3b884cfa59ca342b2e", "",
+ "0388dace60b6a392f328c2b971b2fe78",
+ "f38cbb1ad69223dcc3457ae5b6b0f885");
+ test.check(3,
+ "b83b533708bf535d0aa6e52980d53b78", "",
+ "42831ec2217774244b7221b784d0d49c" +
+ "e3aa212f2c02a4e035c17e2329aca12e" +
+ "21d514b25466931c7d8f6a5aac84aa05" +
+ "1ba30b396a0aac973d58e091473f5985",
+ "7f1b32b81b820d02614f8895ac1d4eac");
+ test.check(4,
+ "b83b533708bf535d0aa6e52980d53b78",
+ "feedfacedeadbeeffeedfacedeadbeef" + "abaddad2",
+ "42831ec2217774244b7221b784d0d49c" +
+ "e3aa212f2c02a4e035c17e2329aca12e" +
+ "21d514b25466931c7d8f6a5aac84aa05" +
+ "1ba30b396a0aac973d58e091",
+ "698e57f70e6ecc7fd9463b7260a9ae5f");
+ test.check(5, "b83b533708bf535d0aa6e52980d53b78",
+ "feedfacedeadbeeffeedfacedeadbeef" + "abaddad2",
+ "61353b4c2806934a777ff51fa22a4755" +
+ "699b2a714fcdc6f83766e5f97b6c7423" +
+ "73806900e49f24b22b097544d4896b42" +
+ "4989b5e1ebac0f07c23f4598",
+ "df586bb4c249b92cb6922877e444d37b");
+ }
+}
--- a/jdk/test/com/sun/jdi/ImmutableResourceTest.sh Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/jdi/ImmutableResourceTest.sh Wed Feb 18 19:27:49 2015 -0800
@@ -92,7 +92,7 @@
#
echo "JDK under test is: $TESTJAVA"
#
-CP="-classpath ${TESTCLASSES}${PATHSEP}${TESTJAVA}/lib/tools.jar"
+CP="-classpath ${TESTCLASSES}"
# Compile the test class using the classpath we need:
#
env
--- a/jdk/test/com/sun/jdi/JITDebug.sh Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/jdi/JITDebug.sh Wed Feb 18 19:27:49 2015 -0800
@@ -103,15 +103,15 @@
#if running standalone (no test harness of any kind), compile the
#support files and the test case
${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
- -classpath "$TESTJAVA/lib/tools.jar${PATHSEP}${TESTSRC}" \
+ -classpath "${TESTSRC}" \
TestScaffold.java VMConnection.java TargetListener.java TargetAdapter.java
${TESTJAVA}/bin/javac -d ${TESTCLASSES} \
- -classpath "$TESTJAVA/lib/tools.jar${PATHSEP}${TESTSRC}" -g \
+ -classpath "${TESTSRC}" -g \
JITDebug.java
fi
echo "JDK under test is: $TESTJAVA"
#
-CLASSPATH="$TESTJAVA/lib/tools.jar${PATHSEP}${TESTCLASSES}"
+CLASSPATH="${TESTCLASSES}"
export CLASSPATH
CP="-classpath \"${CLASSPATH}\""
#
--- a/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/jdi/JdbReadTwiceTest.sh Wed Feb 18 19:27:49 2015 -0800
@@ -204,27 +204,37 @@
clean
fi
+echo
+echo "+++++++++++++++++++++++++++++++++++"
+echo "Read an unreadable file - verify the read fails."
-if [ ! -r c:/ ] ; then
- # Can't make a file unreadable under MKS.
- echo
- echo "+++++++++++++++++++++++++++++++++++"
- echo "Read an unreadable file - verify the read fails."
- # If the file exists, we try to read it. The
- # read will fail.
- mkFiles $HOME/jdb.ini
- id > $HOME/jdb.ini
- chmod a-r $HOME/jdb.ini
- if grep -q "uid=" $HOME/jdb.ini ; then
- echo "Unable to make file unreadable, so test will fail. chmod: $HOME/jdb.ini"
- if grep -q "uid=0" $HOME/jdb.ini ; then
- echo "The test is running as root. Fix infrastructure!"
- fi
- fi
+canMakeUnreadable=No
+id > $HOME/jdb.ini
+if chmod a-r $HOME/jdb.ini
+then
+ grep -q 'uid=0(' $HOME/jdb.ini 2> /dev/null
+ case $? in
+ 0)
+ echo "Error! Can't make file unreadable running as root"
+ ;;
+ 1)
+ echo "Error! Can't make file unreadable for some other reason (windows?)"
+ ;;
+ *)
+ echo "OK. the file is unreadable"
+ canMakeUnreadable=Yes
+ ;;
+ esac
+else
+ echo "Error! Can't create or chmod file"
+fi
+
+if [ "$canMakeUnreadable" = "Yes" ]
+then
doit
failIfNot 1 "open: $HOME/jdb.ini"
- clean
fi
+clean
echo
@@ -246,8 +256,8 @@
doit
failIfNot 1 "from $fred"
- if [ ! -r c:/ ] ; then
- # Can't make a file unreadable under MKS
+ if [ "$canMakeUnreadable" = "Yes" ]
+ then
chmod a-r $fred
doit
failIfNot 1 "open: $fred"
--- a/jdk/test/com/sun/jdi/ShellScaffold.sh Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/jdi/ShellScaffold.sh Wed Feb 18 19:27:49 2015 -0800
@@ -259,7 +259,7 @@
;;
esac
- if [ -r $jdk/bin/dt_shmem.dll -o -r $jdk/jre/bin/dt_shmem.dll ] ; then
+ if [ -r $jdk/bin/dt_shmem.dll ] ; then
transport=dt_shmem
address=kkkk.$$
else
@@ -933,18 +933,10 @@
debuggeeCmd=`$jdk/bin/jps -v | $grep $debuggeeKeyword`
realDebuggeePid=`echo "$debuggeeCmd" | sed -e 's@ .*@@'`
if [ ! -z "$realDebuggeePid" ] ; then
- if [ -r "$jdk/lib/sa-jdi.jar" ] ; then
- # disableVersionCheck can be removed after 6475822
- # is fixed.
- moption="-m -J-Dsun.jvm.hotspot.runtime.VM.disableVersionCheck"
- else
- moption=
- fi
-
echo "-- debuggee process info ----------------------" >&2
echo " $debuggeeCmd" >&2
echo "-- debuggee threads: jstack $moption $realDebuggeePid" >&2
- $jdk/bin/$jstack $moption $realDebuggeePid >&2
+ $jdk/bin/$jstack $realDebuggeePid >&2
echo "=============================================" >&2
echo >&2
fi
--- a/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.java Wed Feb 18 19:27:49 2015 -0800
@@ -22,9 +22,8 @@
*/
/*
- * Creates a URLClassLoader from 2 file URLs. The first
- * file URL is constructed from the given argument. The
- * second is the SDK tools.jar. Once created the test
+ * Creates a URLClassLoader from a file URL. The file URL
+ * is constructed from the given argument. Once created the test
* attempts to load another test case (ListConnectors)
* using the class loader and then it invokes the list()
* method.
@@ -39,13 +38,9 @@
public static void main(String args[]) throws Exception {
// create files from given arguments and tools.jar
File f1 = new File(args[0]);
- String home = System.getProperty("java.home");
- String tools = ".." + File.separatorChar + "lib" +
- File.separatorChar + "tools.jar";
- File f2 = (new File(home, tools)).getCanonicalFile();
// create class loader
- URL[] urls = { f1.toURL(), f2.toURL() };
+ URL[] urls = { f1.toURL() };
URLClassLoader cl = new URLClassLoader(urls);
// load ListConnectors using the class loader
--- a/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/jdi/connect/spi/JdiLoadedByCustomLoader.sh Wed Feb 18 19:27:49 2015 -0800
@@ -68,7 +68,7 @@
$JAVAC -d "${TESTCLASSES}" "${TESTSRC}"/JdiLoadedByCustomLoader.java
mkdir "${SOMEOTHERDIR}"
-$JAVAC -d "${SOMEOTHERDIR}" -classpath "${TESTSRC}${PS}${TESTJAVA}/lib/tools.jar" \
+$JAVAC -d "${SOMEOTHERDIR}" -classpath "${TESTSRC}" \
"${TESTSRC}"/ListConnectors.java
# Run the test
--- a/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/management/HotSpotDiagnosticMXBean/CheckOrigin.java Wed Feb 18 19:27:49 2015 -0800
@@ -62,7 +62,7 @@
"-XX:+UseConcMarkSweepGC", // this will cause UseParNewGC to be FLAG_SET_ERGO
"-XX:+PrintGCDetails",
"-XX:Flags=" + flagsFile.getAbsolutePath(),
- "-cp", System.getProperty("test.class.path") + File.pathSeparator + getToolsJarPath(),
+ "-cp", System.getProperty("test.class.path"),
"CheckOrigin",
"-runtests");
@@ -137,8 +137,4 @@
vm.detach();
}
- private static String getToolsJarPath() {
- return System.getProperty("java.home") +
- "/../lib/tools.jar".replace("/", File.separator);
- }
}
--- a/jdk/test/com/sun/tools/attach/BasicTests.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/tools/attach/BasicTests.java Wed Feb 18 19:27:49 2015 -0800
@@ -80,8 +80,7 @@
// Need to add jdk/lib/tools.jar to classpath.
String classpath =
- System.getProperty("test.class.path", "") + File.pathSeparator +
- System.getProperty("test.jdk", ".") + sep + "lib" + sep + "tools.jar";
+ System.getProperty("test.class.path", "");
String testClassDir = System.getProperty("test.classes", "") + sep;
// Argumenta : -classpath cp BasicTests$TestMain pid agent badagent redefineagent
--- a/jdk/test/com/sun/tools/attach/PermissionTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/tools/attach/PermissionTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -71,10 +71,8 @@
private static void runTests(long pid) throws Throwable {
final String sep = File.separator;
- // Need to add jdk/lib/tools.jar to classpath.
String classpath =
- System.getProperty("test.class.path", "") + File.pathSeparator +
- System.getProperty("test.jdk", ".") + sep + "lib" + sep + "tools.jar";
+ System.getProperty("test.class.path", "");
String testSrc = System.getProperty("test.src", "") + sep;
// Use a policy that will NOT allow attach. Test will verify exception.
--- a/jdk/test/com/sun/tools/attach/ProviderTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/tools/attach/ProviderTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -68,11 +68,10 @@
String testClasses = System.getProperty("test.classes", "") + sep;
String jdkLib = System.getProperty("test.jdk", ".") + sep + "lib" + sep;
- // Need to add SimpleProvider.jar and tools.jar to classpath.
+ // Need to add SimpleProvider.jar to classpath.
String classpath =
testClassPath + File.pathSeparator +
- testClasses + "SimpleProvider.jar" + File.pathSeparator +
- jdkLib + "tools.jar";
+ testClasses + "SimpleProvider.jar";
String[] args = {
"-classpath",
--- a/jdk/test/com/sun/tools/attach/TempDirTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/com/sun/tools/attach/TempDirTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -120,10 +120,8 @@
private static void launchTests(long pid, Path clientTmpDir) throws Throwable {
final String sep = File.separator;
- // Need to add jdk/lib/tools.jar to classpath.
String classpath =
- System.getProperty("test.class.path", "") + File.pathSeparator +
- System.getProperty("test.jdk", ".") + sep + "lib" + sep + "tools.jar";
+ System.getProperty("test.class.path", "");
String[] tmpDirArg = null;
if (clientTmpDir != null) {
--- a/jdk/test/demo/jvmti/DemoRun.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/demo/jvmti/DemoRun.java Wed Feb 18 19:27:49 2015 -0800
@@ -115,10 +115,7 @@
*/
public void runit(String class_name, String vm_options[])
{
- String jre_home = System.getProperty("java.home");
- String sdk_home = (jre_home.endsWith("jre") ?
- (jre_home + File.separator + "..") :
- jre_home );
+ String sdk_home = System.getProperty("java.home");
String cdir = System.getProperty("test.classes", ".");
String os_arch = System.getProperty("os.arch");
String os_name = System.getProperty("os.name");
@@ -126,7 +123,7 @@
String libsuffix = os_name.contains("Windows")?".dll":
os_name.contains("OS X")?".dylib":".so";
boolean hprof = demo_name.equals("hprof");
- String java = jre_home
+ String java = sdk_home
+ File.separator + "bin"
+ File.separator + "java";
/* Array of strings to be passed in for exec:
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/lang/ProcessBuilder/RedirectWithLongFilename.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,79 @@
+/*
+ * Copyright 2015 SAP SE. All Rights Reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * 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 8072611
+ * @summary ProcessBuilder Redirect to file appending on Windows should work with long file names
+ * @author Thomas Stuefe
+ */
+
+import java.io.File;
+import java.lang.ProcessBuilder.Redirect;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+public class RedirectWithLongFilename {
+
+ public static void main(String[] args) throws Exception {
+
+ // windows only
+ if (!Basic.Windows.is()) {
+ return;
+ }
+
+ // Redirect ProcessBuilder output to a file whose pathlen is > 255.
+ Path tmpDir = Paths.get(System.getProperty("java.io.tmpdir"));
+ File dir2 = null;
+ File longFileName = null;
+
+ try {
+ dir2 = Files.createTempDirectory(tmpDir, "RedirectWithLongFilename").toFile();
+ dir2.mkdirs();
+ longFileName = new File(dir2,
+ "012345678901234567890123456789012345678901234567890123456789" +
+ "012345678901234567890123456789012345678901234567890123456789" +
+ "012345678901234567890123456789012345678901234567890123456789" +
+ "012345678901234567890123456789012345678901234567890123456789" +
+ "0123456789");
+
+ ProcessBuilder pb = new ProcessBuilder("hostname.exe");
+ pb.redirectOutput(Redirect.appendTo(longFileName));
+ Process p = pb.start();
+ p.waitFor();
+
+ if (longFileName.exists()) {
+ System.out.println("OK");
+ } else {
+ throw new RuntimeException("Test failed.");
+ }
+
+ } finally {
+ longFileName.delete();
+ dir2.delete();
+ }
+
+ }
+
+}
--- a/jdk/test/java/lang/instrument/IsModifiableClassAgent.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/lang/instrument/IsModifiableClassAgent.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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,7 +23,6 @@
/**
* @test
- * @ignore JDK-8068162
* @bug 6331574
* @summary test isModifiableClass
* @author Robert Field, Sun Microsystems
--- a/jdk/test/java/lang/management/MemoryMXBean/Pending.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/lang/management/MemoryMXBean/Pending.java Wed Feb 18 19:27:49 2015 -0800
@@ -39,7 +39,7 @@
public class Pending {
final static int NO_REF_COUNT = 600;
- final static int REF_COUNT = 600;
+ final static int REF_COUNT = 500;
final static int TOTAL_FINALIZABLE = (NO_REF_COUNT + REF_COUNT);
private static int finalized = 0;
private static MemoryMXBean mbean
@@ -83,31 +83,22 @@
// Clean the memory and remove all objects that are pending
// finalization
System.gc();
- Runtime.getRuntime().runFinalization();
-
- // Let the finalizer to finish
- try {
- Thread.sleep(200);
- } catch (Exception e) {
- throw e;
- }
-
- // Create a number of new objects but no references to them
- int startCount = mbean.getObjectPendingFinalizationCount();
+ Snapshot snapshot = getSnapshotAfterFinalization();
System.out.println("Number of objects pending for finalization:");
- System.out.println(" Before creating object: " + startCount +
- " finalized = " + finalized);
+ System.out.println(" Before creating object: " + snapshot);
printFinalizerInstanceCount();
+ // Create objects without saving reference. Should be removed at next GC.
for (int i = 0; i < NO_REF_COUNT; i++) {
new MyObject();
}
- Snapshot snapshot = getSnapshot();
+ snapshot = getSnapshot();
System.out.println(" Afer creating objects with no ref: " + snapshot);
printFinalizerInstanceCount();
+ // Create objects and save references.
objs = new Object[REF_COUNT];
for (int i = 0; i < REF_COUNT; i++) {
objs[i] = new MyObject();
@@ -139,9 +130,8 @@
+ TOTAL_FINALIZABLE);
}
- if (startCount != 0 || snapshot.curPending != 0) {
+ if (snapshot.curPending != 0) {
throw new RuntimeException("Wrong number of objects pending "
- + "finalization start = " + startCount
+ " end = " + snapshot);
}
@@ -161,29 +151,8 @@
snapshot.curFinalized != expectedTotal && i <= MAX_GC_LOOP;
i++) {
System.gc();
-
- // Pause to give a chance to Finalizer thread to run
- pause();
+ snapshot = getSnapshotAfterFinalization();
- printFinalizerInstanceCount();
- // Race condition may occur; attempt to check this
- // a few times before throwing exception.
- for (int j = 0; j < 5; j++) {
- // poll for another current pending count
- snapshot = getSnapshot();
- if (snapshot.curFinalized == expectedTotal ||
- snapshot.curPending != 0) {
- break;
- }
- }
- System.out.println(" After GC " + i + ": " + snapshot);
-
- Runtime.getRuntime().runFinalization();
-
- // Pause to give a chance to Finalizer thread to run
- pause();
-
- snapshot = getSnapshot();
if (snapshot.curFinalized == expectedTotal &&
snapshot.curPending != 0) {
throw new RuntimeException(
@@ -237,17 +206,21 @@
}
}
- private static Object pauseObj = new Object();
- private static void pause() {
- // Enter lock a without blocking
- synchronized (pauseObj) {
- try {
- // may need to tune this timeout for different platforms
- pauseObj.wait(20);
- } catch (Exception e) {
- System.err.println("Unexpected exception.");
- e.printStackTrace(System.err);
+ // Repeat getSnapshot until no pending finalization.
+ private static Snapshot getSnapshotAfterFinalization() throws Exception {
+ int loopCount = 0;
+ Snapshot snapshot = null;
+ while (loopCount < 100) {
+ Runtime.getRuntime().runFinalization();
+ Thread.sleep(50);
+ snapshot = getSnapshot();
+ if (snapshot.curPending == 0) {
+ return snapshot;
}
+ ++loopCount;
+ System.out.println("Waiting for curPending to be 0. snapshot=" + snapshot);
}
+ String msg = "Objects pending finalization is not 0. snapshot=%s";
+ throw new RuntimeException(String.format(msg, snapshot));
}
}
--- a/jdk/test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/lang/management/ThreadMXBean/SynchronizationStatistics.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, 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
@@ -75,7 +75,7 @@
}
private static void waitForThreadState(Thread t, Thread.State state) throws InterruptedException {
- while (!t.isInterrupted() && t.getState() != state) {
+ while (t.getState() != state) {
Thread.sleep(3);
}
}
@@ -109,7 +109,9 @@
synchronized(lock1) {
p.arriveAndAwaitAdvance(); // phase[1]
waitForThreadState(lt, Thread.State.BLOCKED);
- lockName = mbean.getThreadInfo(tid).getLockName();
+ do {
+ lockName = mbean.getThreadInfo(tid).getLockName();
+ } while (lockName == null);
}
p.arriveAndAwaitAdvance(); // phase[2]
@@ -159,7 +161,9 @@
synchronized(lock1) {
p.arriveAndAwaitAdvance(); // phase[1]
waitForThreadState(lt, Thread.State.BLOCKED);
- lockName = mbean.getThreadInfo(tid).getLockName();
+ do {
+ lockName = mbean.getThreadInfo(tid).getLockName();
+ } while (lockName == null);
}
p.arriveAndAwaitAdvance(); // phase[2]
@@ -168,7 +172,9 @@
synchronized(lock2) {
p.arriveAndAwaitAdvance(); // phase [3]
waitForThreadState(lt, Thread.State.BLOCKED);
- lockName = mbean.getThreadInfo(tid).getLockName();
+ do {
+ lockName = mbean.getThreadInfo(tid).getLockName();
+ } while (lockName == null);
}
p.arriveAndAwaitAdvance(); // phase [4]
testBlocked(ti, () -> mbean.getThreadInfo(tid), lockName, lock2);
--- a/jdk/test/java/math/BigDecimal/DivideTests.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/math/BigDecimal/DivideTests.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2005, 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
@@ -23,7 +23,7 @@
/*
* @test
- * @bug 4851776 4907265 6177836 6876282
+ * @bug 4851776 4907265 6177836 6876282 8066842
* @summary Some tests for the divide methods.
* @author Joseph D. Darcy
*/
@@ -358,6 +358,57 @@
return failures;
}
+ private static int divideByOneTests() {
+ int failures = 0;
+
+ //problematic divisor: one with scale 17
+ BigDecimal one = BigDecimal.ONE.setScale(17);
+ RoundingMode rounding = RoundingMode.UNNECESSARY;
+
+ long[][] unscaledAndScale = new long[][] {
+ { Long.MAX_VALUE, 17},
+ {-Long.MAX_VALUE, 17},
+ { Long.MAX_VALUE, 0},
+ {-Long.MAX_VALUE, 0},
+ { Long.MAX_VALUE, 100},
+ {-Long.MAX_VALUE, 100}
+ };
+
+ for (long[] uas : unscaledAndScale) {
+ long unscaled = uas[0];
+ int scale = (int)uas[1];
+
+ BigDecimal noRound = null;
+ try {
+ noRound = BigDecimal.valueOf(unscaled, scale).
+ divide(one, RoundingMode.UNNECESSARY);
+ } catch (ArithmeticException e) {
+ failures++;
+ System.err.println("ArithmeticException for value " + unscaled
+ + " and scale " + scale + " without rounding");
+ }
+
+ BigDecimal roundDown = null;
+ try {
+ roundDown = BigDecimal.valueOf(unscaled, scale).
+ divide(one, RoundingMode.DOWN);
+ } catch (ArithmeticException e) {
+ failures++;
+ System.err.println("ArithmeticException for value " + unscaled
+ + " and scale " + scale + " with rounding down");
+ }
+
+ if (noRound != null && roundDown != null
+ && noRound.compareTo(roundDown) != 0) {
+ failures++;
+ System.err.println("Equality failure for value " + unscaled
+ + " and scale " + scale);
+ }
+ }
+
+ return failures;
+ }
+
public static void main(String argv[]) {
int failures = 0;
@@ -366,10 +417,11 @@
failures += properScaleTests();
failures += trailingZeroTests();
failures += scaledRoundedDivideTests();
+ failures += divideByOneTests();
if (failures > 0) {
throw new RuntimeException("Incurred " + failures +
- " failures while testing exact divide.");
+ " failures while testing division.");
}
}
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/nio/channels/FileLock/FileLockConstructor.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,169 @@
+/*
+ * 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.io.File;
+import java.io.IOException;
+import java.nio.channels.AsynchronousFileChannel;
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
+import java.nio.file.StandardOpenOption;
+
+/*
+ * @test
+ * @bug 6880737
+ * @summary Test FileLock constructor parameter validation.
+ */
+public class FileLockConstructor {
+ public static void main(String[] args) throws IOException {
+ FileLock fileLock = null;
+ int failures = 0;
+
+ // null FileChannel
+ boolean exceptionThrown = false;
+ try {
+ fileLock = new FileLockSub((FileChannel)null, 0, 0, false);
+ } catch (NullPointerException npe) {
+ exceptionThrown = true;
+ }
+ if (!exceptionThrown) {
+ System.err.println("FileLock constructor did not throw NPE for null FileChannel");
+ failures++;
+ }
+
+ // null AsynchronousFileChannel
+ exceptionThrown = false;
+ try {
+ fileLock = new FileLockSub((AsynchronousFileChannel)null, 0, 0, true);
+ } catch (NullPointerException npe) {
+ exceptionThrown = true;
+ }
+ if (!exceptionThrown) {
+ System.err.println("FileLock constructor did not throw NPE for null AsynchronousFileChannel");
+ failures++;
+ }
+
+ // create temporary file
+ File tmpFile = File.createTempFile("FileLock", "tmp");
+ tmpFile.deleteOnExit();
+
+ // position and size preconditions
+ long[][] posAndSize = new long[][] {
+ {0, 42}, // valid
+ {-1, 42}, // invalid: position < 0
+ {0, -1}, // invalid: size < 0
+ {Long.MAX_VALUE, 1} // invalid: position + size < 0
+ };
+
+ // test position and size preconditions for FileChannel case
+ try (FileChannel syncChannel = FileChannel.open(tmpFile.toPath(),
+ StandardOpenOption.READ, StandardOpenOption.WRITE)) {
+
+ for (int i = 0; i < posAndSize.length; i++) {
+ boolean preconditionsHold = i == 0;
+ exceptionThrown = false;
+ try {
+ fileLock = new FileLockSub(syncChannel, posAndSize[i][0],
+ posAndSize[i][1], true);
+ } catch (IllegalArgumentException iae) {
+ exceptionThrown = true;
+ } catch (Exception e) {
+ System.err.println("Unexpected exception \"" + e + "\" caught"
+ + " for position " + posAndSize[i][0] + " and size "
+ + posAndSize[i][1] + " for FileChannel variant");
+ failures++;
+ continue;
+ }
+ if (preconditionsHold && exceptionThrown) {
+ System.err.println("FileLock constructor incorrectly threw IAE"
+ + " for position " + posAndSize[i][0] + " and size "
+ + posAndSize[i][1] + " for FileChannel variant");
+ failures++;
+ } else if (!preconditionsHold && !exceptionThrown) {
+ System.err.println("FileLock constructor did not throw IAE"
+ + " for position " + posAndSize[i][0] + " and size "
+ + posAndSize[i][1] + " for FileChannel variant");
+ failures++;
+ }
+ }
+ }
+
+ // test position and size preconditions for AsynchronousFileChannel case
+ try (AsynchronousFileChannel asyncChannel
+ = AsynchronousFileChannel.open(tmpFile.toPath(),
+ StandardOpenOption.READ, StandardOpenOption.WRITE)) {
+ for (int i = 0; i < posAndSize.length; i++) {
+ boolean preconditionsHold = i == 0;
+ exceptionThrown = false;
+ try {
+ fileLock = new FileLockSub(asyncChannel, posAndSize[i][0],
+ posAndSize[i][1], true);
+ } catch (IllegalArgumentException iae) {
+ exceptionThrown = true;
+ } catch (Exception e) {
+ System.err.println("Unexpected exception \"" + e + "\" caught"
+ + " for position " + posAndSize[i][0] + " and size "
+ + posAndSize[i][1] + " for AsynchronousFileChannel variant");
+ failures++;
+ continue;
+ }
+ if (preconditionsHold && exceptionThrown) {
+ System.err.println("FileLock constructor incorrectly threw IAE"
+ + " for position " + posAndSize[i][0] + " and size "
+ + posAndSize[i][1] + " for AsynchronousFileChannel variant");
+ failures++;
+ } else if (!preconditionsHold && !exceptionThrown) {
+ System.err.println("FileLock constructor did not throw IAE"
+ + " for position " + posAndSize[i][0] + " and size "
+ + posAndSize[i][1] + " for AsynchronousFileChannel variant");
+ failures++;
+ }
+ }
+ }
+
+ if (failures > 0) {
+ throw new RuntimeException("Incurred " + failures +
+ " failures while testing FileLock.");
+ }
+ }
+}
+
+class FileLockSub extends FileLock {
+ FileLockSub(FileChannel channel, long position, long size, boolean shared) {
+ super(channel, position, size, shared);
+ }
+
+ FileLockSub(AsynchronousFileChannel channel, long position, long size,
+ boolean shared) {
+ super(channel, position, size, shared);
+ }
+
+ @Override
+ public boolean isValid() {
+ return false;
+ }
+
+ @Override
+ public void release() throws IOException {
+ // do nothing
+ }
+}
--- a/jdk/test/java/nio/file/Path/PathOps.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/nio/file/Path/PathOps.java Wed Feb 18 19:27:49 2015 -0800
@@ -22,7 +22,7 @@
*/
/* @test
- * @bug 4313887 6838333 6925932 7006126 8037945
+ * @bug 4313887 6838333 6925932 7006126 8037945 8072495
* @summary Unit test for java.nio.file.Path path operations
*/
@@ -516,7 +516,9 @@
.relativize("\\\\server\\share\\bar", "..\\bar")
.relativize("\\\\server\\share\\foo", "");
test("")
- .relativize("", "");
+ .relativize("", "")
+ .relativize("a", "a")
+ .relativize("a\\b\\c", "a\\b\\c");
// normalize
test("C:\\")
--- a/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/time/tck/java/time/TCKLocalDateTime.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -292,7 +292,8 @@
expected = LocalDateTime.now(Clock.system(zone));
test = LocalDateTime.now(zone);
}
- assertEquals(test, expected);
+ assertEquals(test.truncatedTo(ChronoUnit.SECONDS),
+ expected.truncatedTo(ChronoUnit.SECONDS));
}
//-----------------------------------------------------------------------
--- a/jdk/test/java/time/tck/java/time/TCKLocalTime.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/time/tck/java/time/TCKLocalTime.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -246,7 +246,8 @@
expected = LocalTime.now(Clock.system(zone));
test = LocalTime.now(zone);
}
- assertEquals(test, expected);
+ assertEquals(test.truncatedTo(ChronoUnit.SECONDS),
+ expected.truncatedTo(ChronoUnit.SECONDS));
}
//-----------------------------------------------------------------------
--- a/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/time/tck/java/time/TCKZonedDateTime.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -260,7 +260,8 @@
expected = ZonedDateTime.now(Clock.system(zone));
test = ZonedDateTime.now(zone);
}
- assertEquals(test, expected);
+ assertEquals(test.truncatedTo(ChronoUnit.SECONDS),
+ expected.truncatedTo(ChronoUnit.SECONDS));
}
//-----------------------------------------------------------------------
--- a/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/time/tck/java/time/chrono/TCKJapaneseEra.java Wed Feb 18 19:27:49 2015 -0800
@@ -59,6 +59,7 @@
import static java.time.temporal.ChronoField.ERA;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
import java.time.chrono.Era;
import java.time.chrono.JapaneseChronology;
@@ -69,7 +70,8 @@
import org.testng.annotations.Test;
/**
- * Test.
+ * Tests for JapaneseEra
+ * @bug 8068278
*/
@Test
public class TCKJapaneseEra {
@@ -84,6 +86,20 @@
};
}
+ @DataProvider(name = "InvalidJapaneseEras")
+ Object[][] data_of_invalid_eras() {
+ return new Object[][] {
+ {-2},
+ {-3},
+ {3},
+ {Integer.MIN_VALUE},
+ {Integer.MAX_VALUE},
+ };
+ }
+
+ //-----------------------------------------------------------------------
+ // JapaneseEra value test
+ //-----------------------------------------------------------------------
@Test(dataProvider="JapaneseEras")
public void test_valueOf(JapaneseEra era , String eraName, int eraValue) {
assertEquals(era.getValue(), eraValue);
@@ -118,4 +134,11 @@
}
}
+ //-----------------------------------------------------------------------
+ // JapaneseChronology.INSTANCE.eraOf invalid era test
+ //-----------------------------------------------------------------------
+ @Test(dataProvider="InvalidJapaneseEras", expectedExceptions=java.time.DateTimeException.class)
+ public void test_outofrange(int era) {
+ JapaneseChronology.INSTANCE.eraOf(era);
+ }
}
--- a/jdk/test/java/time/test/java/time/TestClock_System.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/time/test/java/time/TestClock_System.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -62,7 +62,9 @@
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertSame;
+import java.lang.reflect.Field;
import java.time.Clock;
+import java.time.Instant;
import java.time.ZoneId;
import org.testng.annotations.Test;
@@ -87,4 +89,298 @@
assertEquals(test.toString(), "SystemClock[Europe/Paris]");
}
+ //-----------------------------------------------------------------------
+
+ private static String formatTime(String prefix, Instant time) {
+ return prefix + ": " + time + " - seconds: "
+ + time.getEpochSecond() + ", nanos: "
+ + time.getNano();
+ }
+
+ public void test_ClockResolution() {
+ Clock highestUTC = Clock.systemUTC();
+
+ Instant start = Instant.ofEpochMilli(System.currentTimeMillis());
+
+ try {
+ // smoke test
+ Instant system1 = Instant.ofEpochMilli(System.currentTimeMillis());
+ Instant system2 = Instant.ofEpochMilli(System.currentTimeMillis());
+ Instant highest1 = highestUTC.instant();
+ Instant highest2 = highestUTC.instant();
+ System.out.println(formatTime("\nsystemUTC #1 ", system1));
+ System.out.println(formatTime("systemUTC #2 ", system2));
+ System.out.println(formatTime("highestResolutionUTC #1 ", highest1));
+ System.out.println(formatTime("highestResolutionUTC #2 ", highest2));
+
+ if (system2.isBefore(system1)) {
+ System.err.println("system2 is before system1!");
+ System.err.println(formatTime("\n\tsystem1", system1));
+ System.err.println(formatTime("\n\tsystem2", system2));
+ throw new RuntimeException("system2 is before system1!"
+ + formatTime("\n\tsystem1", system1)
+ + formatTime("\n\tsystem2", system2));
+ }
+ if (highest2.isBefore(highest1)) {
+ System.err.println("highest2 is before highest1!");
+ System.err.println(formatTime("\n\thighest1", system1));
+ System.err.println(formatTime("\n\tsystem2", highest2));
+ throw new RuntimeException("highest2 is before system1!"
+ + formatTime("\n\thighest1", system1)
+ + formatTime("\n\tsystem2", highest2));
+ }
+
+ // better test - but depends on implementation details.
+ // we're not rounding - so highest1 should be greater or equal to
+ // system1
+ system1 = Instant.ofEpochMilli(System.currentTimeMillis());
+ highest1 = highestUTC.instant();
+
+ System.out.println(formatTime("\nsystemUTC ", system1));
+ System.out.println(formatTime("highestResolutionUTC ", highest1));
+
+ if (highest1.isBefore(system1)) {
+ System.err.println("highest1 is before system1!");
+ System.err.println(formatTime("\n\tsystem1", system1));
+ System.err.println(formatTime("\n\thighest1", highest1));
+ throw new RuntimeException("highest1 is before system1!"
+ + formatTime("\n\tsystem1", system1)
+ + formatTime("\n\thighest1", highest1));
+ }
+
+ int count=0;
+ // let's preheat the system a bit:
+ for (int i = 0; i < 1000 ; i++) {
+ system1 = Instant.ofEpochMilli(System.currentTimeMillis());
+ highest1 = highestUTC.instant();
+ final int sysnan = system1.getNano();
+ final int nanos = highest1.getNano();
+ if ((nanos % 1000000) > 0) {
+ count++; // we have micro seconds
+ }
+ if ((sysnan % 1000000) > 0) {
+ throw new RuntimeException("Expected only millisecconds "
+ + "precision for systemUTC, found "
+ + (sysnan % 1000000) + " remainder.");
+ }
+ }
+ System.out.println("\nNumber of time stamps which had better than"
+ + " millisecond precision: "+count+"/"+1000);
+ System.out.println(formatTime("\nsystemUTC ", system1));
+ System.out.println(formatTime("highestResolutionUTC ", highest1));
+ if (count == 0) {
+ System.err.println("Something is strange: no microsecond "
+ + "precision with highestResolutionUTC?");
+ throw new RuntimeException("Micro second preccision not reached");
+ }
+
+ // check again
+ if (highest1.isBefore(system1)) {
+ System.err.println("highest1 is before system1!");
+ System.err.println(formatTime("\n\tsystem1", system1));
+ System.err.println(formatTime("\n\thighest1", highest1));
+ throw new RuntimeException("highest1 is before system1!"
+ + formatTime("\n\tsystem1", system1)
+ + formatTime("\n\thighest1", highest1));
+ }
+
+ // leap of faith: ensure that highest1 is from within 10 secs of
+ // system1
+ if (highest1.toEpochMilli() != system1.toEpochMilli()) {
+ long delta = highest1.getEpochSecond() - system1.getEpochSecond();
+ if (delta > 10) {
+ throw new RuntimeException("Unexpected long delay between two clocks ("
+ + delta + " seconds)"
+ + formatTime("\n\t system1", system1)
+ + formatTime("\n\t highest1", highest1));
+
+ }
+ } else {
+ System.out.println("You won the lottery: the two dates are within 1 millisecond!\n");
+ }
+
+ } finally {
+ Instant stop = Instant.ofEpochMilli(System.currentTimeMillis());
+ if (start.isAfter(stop)) {
+ // This should not happen - but can (un)probably be observed
+ // when switching to summer time, or if another application
+ // is switching the system date...
+ System.err.println("Cannot test - date was setback: "
+ + formatTime("\n\tstarted at", start)
+ + formatTime("\n\tstopped at", stop) + "\n");
+ return; // will prevent exceptions from being propagated.
+ }
+ }
+ }
+
+ static final long MAX_OFFSET = 0x0100000000L;
+ static final long MIN_OFFSET = -MAX_OFFSET;
+
+ // A helper class to test that SystemClock correctly recomputes
+ // its offset.
+ static class SystemClockOffset {
+
+ static final int MILLIS_IN_SECOND = 1000;
+ static final int NANOS_IN_MILLI = 1000_000;
+ static final int NANOS_IN_MICRO = 1000;
+ static final int NANOS_IN_SECOND = 1000_000_000;
+
+ static final boolean verbose = true;
+ static final Clock systemUTC = Clock.systemUTC();
+ static final Field offsetField;
+
+ static {
+ try {
+ offsetField = Class.forName("java.time.Clock$SystemClock").getDeclaredField("offset");
+ offsetField.setAccessible(true);
+ } catch (ClassNotFoundException | NoSuchFieldException ex) {
+ throw new ExceptionInInitializerError(ex);
+ }
+ }
+
+ static enum Answer {
+
+ YES, // isOffLimit = YES: we must get -1
+ NO, // isOffLimit = NO: we must not not get -1
+ MAYBE // isOffLimit = MAYBE: we might get -1 or a valid adjustment.
+ };
+
+ static long distance(long one, long two) {
+ return one > two ? Math.subtractExact(one, two)
+ : Math.subtractExact(two, one);
+ }
+
+ static Answer isOffLimits(long before, long after, long offset) {
+ long relativeDistanceBefore = distance(before, offset);
+ long relativeDistanceAfter = distance(after, offset);
+ if (relativeDistanceBefore >= MAX_OFFSET && relativeDistanceAfter >= MAX_OFFSET) {
+ return Answer.YES;
+ }
+ if (relativeDistanceBefore < MAX_OFFSET && relativeDistanceAfter < MAX_OFFSET) {
+ if (relativeDistanceBefore == 0 || relativeDistanceAfter == 0) {
+ return Answer.MAYBE; // unlucky case where
+ }
+ return Answer.NO;
+ }
+ return Answer.MAYBE;
+ }
+
+ static void testWithOffset(String name, long offset)
+ throws IllegalAccessException {
+ testWithOffset(name, offset, systemUTC);
+ }
+
+ static void testWithOffset(String name, long offset, Clock clock)
+ throws IllegalAccessException {
+ offsetField.set(clock, offset);
+ long beforeMillis = System.currentTimeMillis();
+ final Instant instant = clock.instant();
+ long afterMillis = System.currentTimeMillis();
+ long actualOffset = offsetField.getLong(clock);
+ long instantMillis = instant.getEpochSecond() * MILLIS_IN_SECOND
+ + instant.getNano() / NANOS_IN_MILLI;
+ if (instantMillis < beforeMillis || instantMillis > afterMillis) {
+ throw new RuntimeException(name
+ + ": Invalid instant: " + instant
+ + " (~" + instantMillis + "ms)"
+ + " when time in millis is in ["
+ + beforeMillis + ", " + afterMillis
+ + "] and offset in seconds is " + offset);
+ }
+ Answer isOffLimits = isOffLimits(beforeMillis / MILLIS_IN_SECOND,
+ afterMillis / MILLIS_IN_SECOND, offset);
+ switch (isOffLimits) {
+ case YES:
+ if (actualOffset == offset) {
+ throw new RuntimeException(name
+ + ": offset was offlimit but was not recomputed "
+ + " when time in millis is in ["
+ + beforeMillis + ", " + afterMillis
+ + "] and offset in seconds was " + offset);
+ }
+ break;
+ case NO:
+ if (actualOffset != offset) {
+ throw new RuntimeException(name
+ + ": offset was not offlimit but was recomputed.");
+ }
+ break;
+ default:
+ break;
+ }
+ if (distance(actualOffset, instant.getEpochSecond()) >= MAX_OFFSET) {
+ throw new RuntimeException(name + ": Actual offset is too far off:"
+ + " offset=" + actualOffset
+ + "instant.seconds=" + instant.getEpochSecond());
+ }
+ long adjustment = (instant.getEpochSecond() - actualOffset) * NANOS_IN_SECOND
+ + instant.getNano();
+ validateAdjustment(name, actualOffset, beforeMillis, afterMillis, adjustment);
+ }
+
+ static void validateAdjustment(String name, long offset, long beforeMillis,
+ long afterMillis, long adjustment) {
+ System.out.println("Validating adjustment: " + adjustment);
+ long expectedMax = distance(offset, beforeMillis / MILLIS_IN_SECOND)
+ * NANOS_IN_SECOND
+ + (beforeMillis % MILLIS_IN_SECOND) * NANOS_IN_MILLI
+ + (afterMillis - beforeMillis + 1) * NANOS_IN_MILLI;
+ long absoluteAdjustment = distance(0, adjustment);
+ if (absoluteAdjustment > expectedMax) {
+ long adjSec = absoluteAdjustment / NANOS_IN_SECOND;
+ long adjMil = (absoluteAdjustment % NANOS_IN_SECOND) / NANOS_IN_MILLI;
+ long adjMic = (absoluteAdjustment % NANOS_IN_MILLI) / NANOS_IN_MICRO;
+ long adjNan = (absoluteAdjustment % NANOS_IN_MICRO);
+ long expSec = expectedMax / NANOS_IN_SECOND;
+ long expMil = (expectedMax % NANOS_IN_SECOND) / NANOS_IN_MILLI;
+ long expMic = (expectedMax % NANOS_IN_MILLI) / NANOS_IN_MICRO;
+ long expNan = (expectedMax % NANOS_IN_MICRO);
+ System.err.println("Excessive adjustment: " + adjSec + "s, "
+ + adjMil + "ms, " + adjMic + "mics, " + adjNan + "ns");
+ System.err.println("Epected max: " + expSec + "s, "
+ + expMil + "ms, " + expMic + "mics, " + expNan + "ns");
+
+ throw new RuntimeException(name
+ + ": Excessive adjustment: " + adjustment
+ + " when time in millis is in ["
+ + beforeMillis + ", " + afterMillis
+ + "] and offset in seconds is " + offset);
+ }
+ }
+ }
+
+ public void test_OffsetRegular() throws IllegalAccessException {
+ System.out.println("*** Testing regular cases ***");
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000",
+ System.currentTimeMillis()/1000);
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - 1024",
+ System.currentTimeMillis()/1000 - 1024);
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 + 1024",
+ System.currentTimeMillis()/1000 + 1024);
+ }
+
+ public void test_OffsetLimits() throws IllegalAccessException {
+ System.out.println("*** Testing limits ***");
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET + 1",
+ System.currentTimeMillis()/1000 - MAX_OFFSET + 1);
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET - 1",
+ System.currentTimeMillis()/1000 + MAX_OFFSET - 1);
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET",
+ System.currentTimeMillis()/1000 - MAX_OFFSET);
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET",
+ System.currentTimeMillis()/1000 + MAX_OFFSET);
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET - 1024",
+ System.currentTimeMillis()/1000 - MAX_OFFSET - 1024);
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET + 1024",
+ System.currentTimeMillis()/1000 + MAX_OFFSET + 1024);
+ SystemClockOffset.testWithOffset("0", 0);
+ SystemClockOffset.testWithOffset("-1", -1);
+ SystemClockOffset.testWithOffset("Integer.MAX_VALUE + System.currentTimeMillis()/1000",
+ ((long)Integer.MAX_VALUE) + System.currentTimeMillis()/1000);
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - Integer.MIN_VALUE",
+ System.currentTimeMillis()/1000 - Integer.MIN_VALUE);
+ SystemClockOffset.testWithOffset("Long.MAX_VALUE", Long.MAX_VALUE);
+ SystemClockOffset.testWithOffset("System.currentTimeMillis()/1000 - Long.MIN_VALUE",
+ (Long.MIN_VALUE + System.currentTimeMillis()/1000)*-1);
+ }
}
--- a/jdk/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/time/test/java/time/chrono/TestUmmAlQuraChronology.java Wed Feb 18 19:27:49 2015 -0800
@@ -30,6 +30,7 @@
import static java.time.temporal.ChronoField.MONTH_OF_YEAR;
import static java.time.temporal.ChronoField.YEAR;
import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import static org.testng.Assert.fail;
@@ -71,6 +72,7 @@
/**
* Tests for the Umm alQura chronology and data.
* Note: The dates used for testing are just a sample of calendar data.
+ * @bug 8067800
*/
@Test
public class TestUmmAlQuraChronology {
@@ -530,6 +532,24 @@
assertEquals(date.isLeapYear(), leapyear);
}
+ // Data provider to verify that a given hijrah year is outside the range of supported years
+ // The values are dependent on the currently configured UmmAlQura calendar data
+ @DataProvider(name="OutOfRangeLeapYears")
+ Object[][] data_invalid_leapyears() {
+ return new Object[][] {
+ {1299},
+ {1601},
+ {Integer.MAX_VALUE},
+ {Integer.MIN_VALUE},
+ };
+ }
+
+ @Test(dataProvider="OutOfRangeLeapYears")
+ public void test_notLeapYears(int y) {
+ assertFalse(HijrahChronology.INSTANCE.isLeapYear(y), "Out of range leap year");
+ }
+
+
// Date samples to convert HijrahDate to LocalDate and vice versa
@DataProvider(name="samples")
Object[][] data_samples() {
--- a/jdk/test/java/time/test/java/util/TestFormatter.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/time/test/java/util/TestFormatter.java Wed Feb 18 19:27:49 2015 -0800
@@ -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 @@
import java.time.temporal.ChronoField;
import java.time.temporal.TemporalQueries;
import java.time.temporal.TemporalAccessor;
+import java.time.temporal.UnsupportedTemporalTypeException;
import java.util.*;
@@ -153,6 +154,44 @@
if (verbose) {
System.out.printf("%-24s : %s%n", getClassName(dt), out);
}
+
+ // expected usually comes from Calendar which only has milliseconds
+ // precision. So we're going to replace it's N:[nanos] stamp with
+ // the correct value for nanos.
+ if ((dt instanceof TemporalAccessor) && expected != null) {
+ try {
+ // Get millis & nanos from the dt
+ final TemporalAccessor ta = (TemporalAccessor) dt;
+ final int nanos = ta.get(ChronoField.NANO_OF_SECOND);
+ final int millis = ta.get(ChronoField.MILLI_OF_SECOND);
+ final String nanstr = String.valueOf(nanos);
+ final String mistr = String.valueOf(millis);
+
+ // Compute the value of the N:[nanos] field that we expect
+ // to find in 'out'
+ final StringBuilder sb = new StringBuilder();
+ sb.append("N:[");
+ for (int i=nanstr.length(); i<9; i++) {
+ sb.append('0');
+ }
+ sb.append(nanos).append("]");
+
+ // Compute the truncated value of N:[nanos] field that might
+ // be in 'expected' when expected was built from Calendar.
+ final StringBuilder sbm = new StringBuilder();
+ sbm.append("N:[");
+ for (int i=mistr.length(); i<3; i++) {
+ sbm.append('0');
+ }
+ sbm.append(mistr).append("000000]");
+
+ // if expected contains the truncated value, replace it with
+ // the complete value.
+ expected = expected.replace(sbm.toString(), sb.toString());
+ } catch (UnsupportedTemporalTypeException e) {
+ // nano seconds unsupported - nothing to do...
+ }
+ }
if (expected != null && !out.equals(expected)) {
System.out.printf("%-24s actual: %s%n FAILED; expected: %s%n",
getClassName(dt), out, expected);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/util/Arrays/TimSortStackSize2.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,169 @@
+/*
+ * 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 8072909
+ * @run main/othervm TimSortStackSize2 67108864
+ * not for regular execution on all platforms:
+ * run main/othervm -Xmx8g TimSortStackSize2 1073741824
+ * run main/othervm -Xmx32g TimSortStackSize2 2147483644
+ * @summary Test TimSort stack size on big arrays
+ */
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+public class TimSortStackSize2 {
+
+ public static void main(String[] args) {
+ int lengthOfTest = Integer.parseInt(args[0]);
+ boolean passed = true;
+ try {
+ Arrays.sort(new TimSortStackSize2(lengthOfTest).createArray(),
+ new Comparator<Object>() {
+ @SuppressWarnings("unchecked")
+ public int compare(Object first, Object second) {
+ return ((Comparable<Object>)first).compareTo(second);
+ }
+ });
+ System.out.println("TimSort OK");
+ } catch (ArrayIndexOutOfBoundsException e){
+ System.out.println("TimSort broken");
+ e.printStackTrace();
+ passed = false;
+ }
+ try {
+ Arrays.sort(new TimSortStackSize2(lengthOfTest).createArray());
+ System.out.println("ComparableTimSort OK");
+ } catch (ArrayIndexOutOfBoundsException e){
+ System.out.println("ComparableTimSort broken:");
+ e.printStackTrace();
+ passed = false;
+ }
+ if ( !passed ){
+ throw new RuntimeException();
+ }
+ }
+
+ private static final int MIN_MERGE = 32;
+ private final int minRun;
+ private final int length;
+ private final List<Long> runs = new ArrayList<Long>();
+
+ public TimSortStackSize2(int len) {
+ this.length = len;
+ minRun = minRunLength(len);
+ fillRunsJDKWorstCase();
+ }
+
+ private static int minRunLength(int n) {
+ assert n >= 0;
+ int r = 0; // Becomes 1 if any 1 bits are shifted off
+ while (n >= MIN_MERGE) {
+ r |= (n & 1);
+ n >>= 1;
+ }
+ return n + r;
+ }
+
+ /**
+ * Adds a sequence x_1, ..., x_n of run lengths to <code>runs</code> such that:<br>
+ * 1. X = x_1 + ... + x_n <br>
+ * 2. x_j >= minRun for all j <br>
+ * 3. x_1 + ... + x_{j-2} < x_j < x_1 + ... + x_{j-1} for all j <br>
+ * These conditions guarantee that TimSort merges all x_j's one by one
+ * (resulting in X) using only merges on the second-to-last element.
+ * @param X The sum of the sequence that should be added to runs.
+ */
+ private void generateJDKWrongElem(long X) {
+ for(long newTotal; X >= 2*minRun+1; X = newTotal) {
+ //Default strategy
+ newTotal = X/2 + 1;
+ //Specialized strategies
+ if(3*minRun+3 <= X && X <= 4*minRun+1) {
+ // add x_1=MIN+1, x_2=MIN, x_3=X-newTotal to runs
+ newTotal = 2*minRun+1;
+ } else if(5*minRun+5 <= X && X <= 6*minRun+5) {
+ // add x_1=MIN+1, x_2=MIN, x_3=MIN+2, x_4=X-newTotal to runs
+ newTotal = 3*minRun+3;
+ } else if(8*minRun+9 <= X && X <= 10*minRun+9) {
+ // add x_1=MIN+1, x_2=MIN, x_3=MIN+2, x_4=2MIN+2, x_5=X-newTotal to runs
+ newTotal = 5*minRun+5;
+ } else if(13*minRun+15 <= X && X <= 16*minRun+17) {
+ // add x_1=MIN+1, x_2=MIN, x_3=MIN+2, x_4=2MIN+2, x_5=3MIN+4, x_6=X-newTotal to runs
+ newTotal = 8*minRun+9;
+ }
+ runs.add(0, X-newTotal);
+ }
+ runs.add(0, X);
+ }
+
+ /**
+ * Fills <code>runs</code> with a sequence of run lengths of the form<br>
+ * Y_n x_{n,1} x_{n,2} ... x_{n,l_n} <br>
+ * Y_{n-1} x_{n-1,1} x_{n-1,2} ... x_{n-1,l_{n-1}} <br>
+ * ... <br>
+ * Y_1 x_{1,1} x_{1,2} ... x_{1,l_1}<br>
+ * The Y_i's are chosen to satisfy the invariant throughout execution,
+ * but the x_{i,j}'s are merged (by <code>TimSort.mergeCollapse</code>)
+ * into an X_i that violates the invariant.
+ * X is the sum of all run lengths that will be added to <code>runs</code>.
+ */
+ private void fillRunsJDKWorstCase() {
+ long runningTotal = 0;
+ long Y = minRun + 4;
+ long X = minRun;
+
+ while(runningTotal+Y+X <= length) {
+ runningTotal += X + Y;
+ generateJDKWrongElem(X);
+ runs.add(0,Y);
+
+ // X_{i+1} = Y_i + x_{i,1} + 1, since runs.get(1) = x_{i,1}
+ X = Y + runs.get(1) + 1;
+
+ // Y_{i+1} = X_{i+1} + Y_i + 1
+ Y += X + 1;
+ }
+
+ if(runningTotal + X <= length) {
+ runningTotal += X;
+ generateJDKWrongElem(X);
+ }
+
+ runs.add(length-runningTotal);
+ }
+
+ private Integer[] createArray() {
+ Integer[] a = new Integer[length];
+ Arrays.fill(a, 0);
+ int endRun = -1;
+ for(long len : runs)
+ a[endRun+=len] = 1;
+ a[length-1]=0;
+ return a;
+ }
+
+}
--- a/jdk/test/java/util/Optional/Basic.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/util/Optional/Basic.java Wed Feb 18 19:27:49 2015 -0800
@@ -29,6 +29,7 @@
import java.util.NoSuchElementException;
import java.util.Optional;
+import java.util.stream.Stream;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
@@ -54,8 +55,8 @@
assertSame(null, empty.orElse(null));
RuntimeException orElse = new RuntimeException() { };
assertSame(Boolean.FALSE, empty.orElse(Boolean.FALSE));
- assertSame(null, empty.orElseGet(()-> null));
- assertSame(Boolean.FALSE, empty.orElseGet(()-> Boolean.FALSE));
+ assertSame(null, empty.orElseGet(() -> null));
+ assertSame(Boolean.FALSE, empty.orElseGet(() -> Boolean.FALSE));
}
@Test(expectedExceptions=NoSuchElementException.class)
@@ -104,15 +105,15 @@
try {
present.ifPresent(v -> { throw new ObscureException(); });
fail();
- } catch(ObscureException expected) {
+ } catch (ObscureException expected) {
}
assertSame(Boolean.TRUE, present.orElse(null));
assertSame(Boolean.TRUE, present.orElse(Boolean.FALSE));
assertSame(Boolean.TRUE, present.orElseGet(null));
- assertSame(Boolean.TRUE, present.orElseGet(()-> null));
- assertSame(Boolean.TRUE, present.orElseGet(()-> Boolean.FALSE));
- assertSame(Boolean.TRUE, present.<RuntimeException>orElseThrow( null));
+ assertSame(Boolean.TRUE, present.orElseGet(() -> null));
+ assertSame(Boolean.TRUE, present.orElseGet(() -> Boolean.FALSE));
+ assertSame(Boolean.TRUE, present.<RuntimeException>orElseThrow(null));
assertSame(Boolean.TRUE, present.<RuntimeException>orElseThrow(ObscureException::new));
}
@@ -226,6 +227,26 @@
assertSame(l, fixture);
}
+ @Test(groups = "unit")
+ public void testStream() {
+ {
+ Stream<String> s = Optional.<String>empty().stream();
+ assertFalse(s.isParallel());
+
+ Object[] es = s.toArray();
+ assertEquals(es.length, 0);
+ }
+
+ {
+ Stream<String> s = Optional.of("Duke").stream();
+ assertFalse(s.isParallel());
+
+ String[] es = s.toArray(String[]::new);
+ assertEquals(es.length, 1);
+ assertEquals(es[0], "Duke");
+ }
+ }
+
private static class ObscureException extends RuntimeException {
}
--- a/jdk/test/java/util/Optional/BasicDouble.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/util/Optional/BasicDouble.java Wed Feb 18 19:27:49 2015 -0800
@@ -29,6 +29,7 @@
import java.util.NoSuchElementException;
import java.util.OptionalDouble;
+import java.util.stream.DoubleStream;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
@@ -109,6 +110,26 @@
assertEquals(1.0, present.<RuntimeException>orElseThrow(ObscureException::new));
}
+ @Test(groups = "unit")
+ public void testStream() {
+ {
+ DoubleStream s = OptionalDouble.empty().stream();
+ assertFalse(s.isParallel());
+
+ double[] es = s.toArray();
+ assertEquals(es.length, 0);
+ }
+
+ {
+ DoubleStream s = OptionalDouble.of(42.0).stream();
+ assertFalse(s.isParallel());
+
+ double[] es = s.toArray();
+ assertEquals(es.length, 1);
+ assertEquals(es[0], 42.0);
+ }
+ }
+
private static class ObscureException extends RuntimeException {
}
--- a/jdk/test/java/util/Optional/BasicInt.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/util/Optional/BasicInt.java Wed Feb 18 19:27:49 2015 -0800
@@ -29,6 +29,7 @@
import java.util.NoSuchElementException;
import java.util.OptionalInt;
+import java.util.stream.IntStream;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
@@ -53,36 +54,36 @@
assertEquals(2, empty.orElseGet(()-> 2));
}
- @Test(expectedExceptions=NoSuchElementException.class)
- public void testEmptyGet() {
- OptionalInt empty = OptionalInt.empty();
+ @Test(expectedExceptions=NoSuchElementException.class)
+ public void testEmptyGet() {
+ OptionalInt empty = OptionalInt.empty();
- int got = empty.getAsInt();
- }
+ int got = empty.getAsInt();
+ }
- @Test(expectedExceptions=NullPointerException.class)
- public void testEmptyOrElseGetNull() {
- OptionalInt empty = OptionalInt.empty();
+ @Test(expectedExceptions=NullPointerException.class)
+ public void testEmptyOrElseGetNull() {
+ OptionalInt empty = OptionalInt.empty();
- int got = empty.orElseGet(null);
- }
+ int got = empty.orElseGet(null);
+ }
- @Test(expectedExceptions=NullPointerException.class)
- public void testEmptyOrElseThrowNull() throws Throwable {
- OptionalInt empty = OptionalInt.empty();
+ @Test(expectedExceptions=NullPointerException.class)
+ public void testEmptyOrElseThrowNull() throws Throwable {
+ OptionalInt empty = OptionalInt.empty();
- int got = empty.orElseThrow(null);
- }
+ int got = empty.orElseThrow(null);
+ }
- @Test(expectedExceptions=ObscureException.class)
- public void testEmptyOrElseThrow() throws Exception {
- OptionalInt empty = OptionalInt.empty();
+ @Test(expectedExceptions=ObscureException.class)
+ public void testEmptyOrElseThrow() throws Exception {
+ OptionalInt empty = OptionalInt.empty();
- int got = empty.orElseThrow(ObscureException::new);
- }
+ int got = empty.orElseThrow(ObscureException::new);
+ }
- @Test(groups = "unit")
- public void testPresent() {
+ @Test(groups = "unit")
+ public void testPresent() {
OptionalInt empty = OptionalInt.empty();
OptionalInt present = OptionalInt.of(1);
@@ -109,6 +110,26 @@
assertEquals(1, present.<RuntimeException>orElseThrow(ObscureException::new));
}
+ @Test(groups = "unit")
+ public void testStream() {
+ {
+ IntStream s = OptionalInt.empty().stream();
+ assertFalse(s.isParallel());
+
+ int[] es = s.toArray();
+ assertEquals(es.length, 0);
+ }
+
+ {
+ IntStream s = OptionalInt.of(42).stream();
+ assertFalse(s.isParallel());
+
+ int[] es = OptionalInt.of(42).stream().toArray();
+ assertEquals(es.length, 1);
+ assertEquals(es[0], 42);
+ }
+ }
+
private static class ObscureException extends RuntimeException {
}
--- a/jdk/test/java/util/Optional/BasicLong.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/util/Optional/BasicLong.java Wed Feb 18 19:27:49 2015 -0800
@@ -29,6 +29,7 @@
import java.util.NoSuchElementException;
import java.util.OptionalLong;
+import java.util.stream.LongStream;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
@@ -109,6 +110,24 @@
assertEquals(1, present.<RuntimeException>orElseThrow(ObscureException::new));
}
+ @Test(groups = "unit")
+ public void testStream() {
+ {
+ LongStream s = OptionalLong.empty().stream();
+
+ long[] es = s.toArray();
+ assertEquals(es.length, 0);
+ }
+
+ {
+ LongStream s = OptionalLong.of(42L).stream();
+
+ long[] es = s.toArray();
+ assertEquals(es.length, 1);
+ assertEquals(es[0], 42L);
+ }
+ }
+
private static class ObscureException extends RuntimeException {
}
--- a/jdk/test/java/util/concurrent/CompletableFuture/ThenComposeExceptionTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/util/concurrent/CompletableFuture/ThenComposeExceptionTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -36,7 +36,7 @@
/**
* @test
- * @bug 8068432
+ * @bug 8068432 8072030
* @run testng ThenComposeExceptionTest
* @summary Test that CompletableFuture.thenCompose works correctly if the
* composing future completes exceptionally
@@ -92,7 +92,8 @@
Assert.assertNotSame(f_thenCompose, fe, "Composed CompletableFuture returned directly");
AtomicReference<Throwable> eOnWhenComplete = new AtomicReference<>();
- f_thenCompose.whenComplete((r, e) -> eOnWhenComplete.set(e));
+ CompletableFuture<String> f_whenComplete = f_thenCompose.
+ whenComplete((r, e) -> eOnWhenComplete.set(e));
afterAction.accept(fe);
@@ -103,10 +104,20 @@
catch (Throwable t) {
eOnJoined = t;
}
-
- Assert.assertTrue(eOnWhenComplete.get() instanceof CompletionException,
- "Incorrect exception reported on whenComplete");
Assert.assertTrue(eOnJoined instanceof CompletionException,
- "Incorrect exception reported when joined");
+ "Incorrect exception reported when joined on thenCompose: " + eOnJoined);
+
+ // Need to wait for f_whenComplete to complete to avoid
+ // race condition when updating eOnWhenComplete
+ eOnJoined = null;
+ try {
+ f_whenComplete.join();
+ } catch (Throwable t) {
+ eOnJoined = t;
+ }
+ Assert.assertTrue(eOnJoined instanceof CompletionException,
+ "Incorrect exception reported when joined on whenComplete: " + eOnJoined);
+ Assert.assertTrue(eOnWhenComplete.get() instanceof CompletionException,
+ "Incorrect exception passed to whenComplete: " + eOnWhenComplete.get());
}
-}
+}
\ No newline at end of file
--- a/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/java/util/stream/test/org/openjdk/tests/java/util/stream/StreamBuilderTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -55,8 +55,30 @@
@Test
+ public void testOfNullableWithNonNull() {
+ TestData.OfRef<Integer> data = TestData.Factory.ofSupplier("{1}",
+ () -> Stream.ofNullable(1));
+
+ withData(data).
+ stream(s -> s).
+ expectedResult(Collections.singletonList(1)).
+ exercise();
+ }
+
+ @Test
+ public void testOfNullableWithNull() {
+ TestData.OfRef<Integer> data = TestData.Factory.ofSupplier("{null})",
+ () -> Stream.ofNullable(null));
+
+ withData(data).
+ stream(s -> s).
+ expectedResult(Collections.emptyList()).
+ exercise();
+ }
+
+ @Test
public void testSingleton() {
- TestData.OfRef<Integer> data = TestData.Factory.ofSupplier("[0, 1)",
+ TestData.OfRef<Integer> data = TestData.Factory.ofSupplier("{1}",
() -> Stream.of(1));
withData(data).
@@ -118,7 +140,7 @@
@Test
public void testIntSingleton() {
- TestData.OfInt data = TestData.Factory.ofIntSupplier("[0, 1)",
+ TestData.OfInt data = TestData.Factory.ofIntSupplier("{1}",
() -> IntStream.of(1));
withData(data).
@@ -180,7 +202,7 @@
@Test
public void testLongSingleton() {
- TestData.OfLong data = TestData.Factory.ofLongSupplier("[0, 1)",
+ TestData.OfLong data = TestData.Factory.ofLongSupplier("{1}",
() -> LongStream.of(1));
withData(data).
@@ -242,7 +264,7 @@
@Test
public void testDoubleSingleton() {
- TestData.OfDouble data = TestData.Factory.ofDoubleSupplier("[0, 1)", () -> DoubleStream.of(1));
+ TestData.OfDouble data = TestData.Factory.ofDoubleSupplier("{1}", () -> DoubleStream.of(1));
withData(data).
stream(s -> s).
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/ProcessTools.java Wed Feb 18 19:27:49 2015 -0800
@@ -218,19 +218,8 @@
* @return Process id
*/
public static int getProcessId() throws Exception {
-
- // Get the current process id using a reflection hack
RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
- Field jvm = runtime.getClass().getDeclaredField("jvm");
-
- jvm.setAccessible(true);
- VMManagement mgmt = (sun.management.VMManagement) jvm.get(runtime);
-
- Method pid_method = mgmt.getClass().getDeclaredMethod("getProcessId");
-
- pid_method.setAccessible(true);
-
- int pid = (Integer) pid_method.invoke(mgmt);
+ int pid = Integer.parseInt(runtime.getName().split("@")[0]);
return pid;
}
--- a/jdk/test/lib/testlibrary/jdk/testlibrary/SimpleSSLContext.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/lib/testlibrary/jdk/testlibrary/SimpleSSLContext.java Wed Feb 18 19:27:49 2015 -0800
@@ -56,7 +56,7 @@
*/
public SimpleSSLContext () throws IOException {
String paths = System.getProperty("test.src.path");
- StringTokenizer st = new StringTokenizer(paths,":");
+ StringTokenizer st = new StringTokenizer(paths, File.pathSeparator);
boolean securityExceptions = false;
while (st.hasMoreTokens()) {
String path = st.nextToken();
--- a/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/management/jmxremote/bootstrap/CustomLauncherTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -145,13 +145,7 @@
ProcessBuilder client = ProcessTools.createJavaProcessBuilder(
"-cp",
- TEST_CLASSPATH +
- File.pathSeparator +
- TEST_JDK +
- File.separator +
- "lib" +
- File.separator +
- "tools.jar",
+ TEST_CLASSPATH,
"TestManager",
String.valueOf(serverPrc.getPid()),
port.get(),
--- a/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/management/jmxremote/bootstrap/LocalManagementTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -132,13 +132,7 @@
ProcessBuilder client = ProcessTools.createJavaProcessBuilder(
"-cp",
- TEST_CLASSPATH +
- File.pathSeparator +
- TEST_JDK +
- File.separator +
- "lib" +
- File.separator +
- "tools.jar",
+ TEST_CLASSPATH,
"TestManager",
String.valueOf(serverPrc.getPid()),
port.get(),
--- a/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/management/jmxremote/startstop/JMXStartStopTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -23,7 +23,9 @@
import java.io.File;
import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
+import java.net.BindException;
import java.net.ConnectException;
import java.net.ServerSocket;
import java.rmi.RemoteException;
@@ -31,15 +33,15 @@
import java.rmi.registry.Registry;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
import java.util.Objects;
+import java.util.Random;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.function.Consumer;
+import java.util.stream.Collectors;
import javax.management.*;
import javax.management.remote.*;
@@ -47,6 +49,8 @@
import jdk.testlibrary.ProcessTools;
import jdk.testlibrary.JDKToolLauncher;
+import sun.management.Agent;
+import sun.management.AgentConfigurationError;
/**
* @test
@@ -54,65 +58,55 @@
* @library /lib/testlibrary
* @build jdk.testlibrary.* JMXStartStopTest JMXStartStopDoSomething
* @run main/othervm/timeout=600 -XX:+UsePerfData JMXStartStopTest
- * @summary Makes sure that enabling/disabling the management agent through
- * JCMD achieves the desired results
+ * @summary Makes sure that enabling/disabling the management agent through JCMD
+ * achieves the desired results
*/
public class JMXStartStopTest {
+
private static final String TEST_SRC = System.getProperty("test.src");
private static final boolean verbose = false;
/**
- * Dynamically allocates two distinct ports using {@linkplain java.net.ServerSocket}
- * It keeps each of those ports blocked until it is first accessed by its getter
+ * Dynamically allocates distinct ports from the ephemeral range 49152-65535
*/
private static class PortAllocator {
- private final int port1, port2;
- private final ServerSocket ss1, ss2;
- PortAllocator() {
- try {
- ss1 = new ServerSocket(0);
- ss2 = new ServerSocket(0);
- port1 = ss1.getLocalPort();
- port2 = ss2.getLocalPort();
- } catch (IOException e) {
- throw new Error("Error while obtaining free ports", e);
- }
- }
+
+ private final static int LOWER_BOUND = 49152;
+ private final static int UPPER_BOUND = 65535;
+
+ private final static Random RND = new Random(System.currentTimeMillis());
- public int getPort1() {
- if (!ss1.isClosed()) {
- try {
- ss1.close();
- } catch (IOException e) {
- // just ignore
+ private static int[] allocatePorts(final int numPorts) {
+ int[] ports = new int[numPorts];
+ for (int i = 0; i < numPorts; i++) {
+ int port = -1;
+ while (port == -1) {
+ port = RND.nextInt(UPPER_BOUND - LOWER_BOUND + 1) + LOWER_BOUND;
+ for (int j = 0; j < i; j++) {
+ if (ports[j] == port) {
+ port = -1;
+ break;
+ }
+ }
}
+ System.err.println("*** port = " + port);
+ ports[i] = port;
}
- return port1;
- }
-
- public int getPort2() {
- if (!ss2.isClosed()) {
- try {
- ss2.close();
- } catch (IOException e) {
- // just ignore
- }
- }
- return port2;
+ return ports;
}
}
- private static void dbg_print(String msg){
+ private static void dbg_print(String msg) {
if (verbose) {
- System.out.println("DBG: " +msg);
+ System.out.println("DBG: " + msg);
}
}
private static int listMBeans(MBeanServerConnection server,
- ObjectName pattern,
- QueryExp query)
- throws Exception {
+ ObjectName pattern,
+ QueryExp query)
+ throws Exception {
Set<ObjectName> names = server.queryNames(pattern,query);
for (ObjectName name : names) {
@@ -131,9 +125,8 @@
return names.size();
}
-
private static void testConnectLocal(long pid)
- throws Exception {
+ throws Exception {
String jmxUrlStr = null;
@@ -208,12 +201,12 @@
String jmxUrlStr = (rmiPort != 0) ?
String.format(
- "service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi",
- rmiPort,
+ "service:jmx:rmi://localhost:%d/jndi/rmi://localhost:%d/jmxrmi",
+ rmiPort,
port) :
String.format(
- "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi",
- port);
+ "service:jmx:rmi:///jndi/rmi://localhost:%d/jmxrmi",
+ port);
JMXServiceURL url = new JMXServiceURL(jmxUrlStr);
@@ -292,7 +285,21 @@
if (m.getName().startsWith("test_")) {
long t1 = System.currentTimeMillis();
try {
- m.invoke(null);
+ boolean retry = false;
+ do {
+ try {
+ m.invoke(null);
+ retry = false;
+ } catch (InvocationTargetException e) {
+ if (e.getCause() instanceof BindException ||
+ e.getCause() instanceof java.rmi.ConnectException) {
+ System.out.println("Failed to allocate ports. Retrying ...");
+ retry = true;
+ } else {
+ throw e;
+ }
+ }
+ } while (retry);
System.out.println("=== PASSED");
} catch (Throwable e) {
failures.add(new Failure(e, m.getName() + " failed"));
@@ -326,13 +333,23 @@
public synchronized void start() throws InterruptedException, IOException, TimeoutException {
if (started.compareAndSet(false, true)) {
try {
+ AtomicBoolean error = new AtomicBoolean(false);
p = ProcessTools.startProcess(
- "JMXStartStopDoSomething",
- pb,
- (line) -> line.equals("main enter"),
- 5,
- TimeUnit.SECONDS
+ "JMXStartStopDoSomething{" + name + "}",
+ pb,
+ (line) -> {
+ boolean ok = line.equals("main enter");
+ error.set(line.contains("BindException"));
+
+ return ok || error.get();
+ },
+ 5,
+ TimeUnit.SECONDS
);
+ if (error.get()) {
+ throw new BindException("Starting process failed due to " +
+ "the requested port not being available");
+ }
pid = p.getPid();
} catch (TimeoutException e) {
p.destroy();
@@ -347,7 +364,7 @@
}
public synchronized void stop()
- throws IOException, InterruptedException {
+ throws IOException, InterruptedException {
if (started.compareAndSet(true, false)) {
p.getOutputStream().write(0);
p.getOutputStream().flush();
@@ -374,16 +391,16 @@
* @throws TimeoutException
*/
private static Something doSomething(String name, String ... args)
- throws Exception {
+ throws Exception {
List<String> pbArgs = new ArrayList<>(Arrays.asList(
- "-cp",
- System.getProperty("test.class.path")
+ "-cp",
+ System.getProperty("test.class.path")
));
pbArgs.addAll(Arrays.asList(args));
pbArgs.add("JMXStartStopDoSomething");
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
- pbArgs.toArray(new String[pbArgs.size()])
+ pbArgs.toArray(new String[pbArgs.size()])
);
Something s = new Something(pb, name);
s.start();
@@ -399,7 +416,7 @@
*/
private static void jcmd(String ... command) throws IOException, InterruptedException {
if (command.length == 0) {
- jcmd(null, (Consumer<String>)null);
+ jcmd(null, c->{});
} else {
jcmd(null, command);
}
@@ -408,7 +425,7 @@
/**
* Run the "jcmd" command
*
- * @param c {@linkplain Consumer} instance; may be null
+ * @param c {@linkplain Consumer} instance
* @param command Command with parameters; space separated string
* @throws IOException
* @throws InterruptedException
@@ -419,8 +436,9 @@
/**
* Run the "jcmd" command
+ *
* @param target The target application name (or PID)
- * @param c {@linkplain Consumer} instance; may be null
+ * @param c {@linkplain Consumer} instance
* @param command Command with parameters; space separated string
* @throws IOException
* @throws InterruptedException
@@ -430,21 +448,37 @@
JDKToolLauncher l = JDKToolLauncher.createUsingTestJDK("jcmd");
l.addToolArg(target);
- for(String cmd : command) {
+ for (String cmd : command) {
l.addToolArg(cmd);
}
+
+ AtomicBoolean portUnavailable = new AtomicBoolean(false);
Process p = ProcessTools.startProcess(
"jcmd",
new ProcessBuilder(l.getCommand()),
- c
+ line -> {
+ if (line.contains("BindException") ||
+ line.contains(Agent.getText(AgentConfigurationError.CONNECTOR_SERVER_IO_ERROR))) {
+ portUnavailable.set(true);
+ } else {
+ c.accept(line);
+ }
+ }
);
p.waitFor();
dbg_print("[jcmd] --------");
+ if (portUnavailable.get()) {
+ String cmd = Arrays.asList(l.getCommand()).stream()
+ .collect(
+ Collectors.joining(" ", "", ": Unable to bind address")
+ );
+ throw new BindException(cmd);
+ }
}
private static final String CMD_STOP = "ManagementAgent.stop";
- private static final String CMD_START= "ManagementAgent.start";
+ private static final String CMD_START = "ManagementAgent.start";
private static final String CMD_START_LOCAL = "ManagementAgent.start_local";
static void test_01() throws Exception {
@@ -452,22 +486,22 @@
// restart on other port
System.out.println("**** Test one ****");
- PortAllocator pa = new PortAllocator();
+ int ports[] = PortAllocator.allocatePorts(2);
Something s = doSomething(
- "test_01",
- "-Dcom.sun.management.jmxremote.port=" + pa.getPort1(),
- "-Dcom.sun.management.jmxremote.authenticate=false",
- "-Dcom.sun.management.jmxremote.ssl=false");
+ "test_01",
+ "-Dcom.sun.management.jmxremote.port=" + ports[0],
+ "-Dcom.sun.management.jmxremote.authenticate=false",
+ "-Dcom.sun.management.jmxremote.ssl=false");
try {
- testConnect(pa.getPort1());
+ testConnect(ports[0]);
jcmd(CMD_STOP);
- testNoConnect(pa.getPort1());
+ testNoConnect(ports[0]);
- jcmd(CMD_START, "jmxremote.port=" + pa.getPort2());
- testConnect(pa.getPort2());
+ jcmd(CMD_START, "jmxremote.port=" + ports[1]);
+ testConnect(ports[1]);
} finally {
s.stop();
}
@@ -479,15 +513,15 @@
System.out.println("**** Test two ****");
+ int[] ports = PortAllocator.allocatePorts(1);
Something s = doSomething("test_02");
- PortAllocator pa = new PortAllocator();
try {
jcmd(CMD_START,
- "jmxremote.port=" + pa.getPort1(),
- "jmxremote.authenticate=false",
- "jmxremote.ssl=false");
+ "jmxremote.port=" + ports[0],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false");
- testConnect(pa.getPort1());
+ testConnect(ports[0]);
} finally {
// debugPortUsage(pa);
s.stop();
@@ -500,25 +534,25 @@
System.out.println("**** Test three ****");
+ int[] ports = PortAllocator.allocatePorts(2);
Something s = doSomething("test_03");
- PortAllocator pa = new PortAllocator();
try {
jcmd(CMD_START,
- "jmxremote.port=" + pa.getPort1(),
- "jmxremote.authenticate=false",
- "jmxremote.ssl=false");
+ "jmxremote.port=" + ports[0],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false");
// Second agent shouldn't start
jcmd(CMD_START,
- "jmxremote.port=" + pa.getPort2(),
- "jmxremote.authenticate=false",
- "jmxremote.ssl=false");
+ "jmxremote.port=" + ports[1],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false");
// First agent should connect
- testConnect(pa.getPort1());
+ testConnect(ports[0]);
// Second agent should not connect
- testNoConnect(pa.getPort2());
+ testNoConnect(ports[1]);
} finally {
s.stop();
}
@@ -530,16 +564,16 @@
System.out.println("**** Test four ****");
+ int[] ports = PortAllocator.allocatePorts(2);
Something s = doSomething("test_04");
- PortAllocator pa = new PortAllocator();
try {
jcmd(CMD_START,
- "jmxremote.port=" + pa.getPort1(),
- "jmxremote.rmi.port=" + pa.getPort2(),
- "jmxremote.authenticate=false",
- "jmxremote.ssl=false");
+ "jmxremote.port=" + ports[0],
+ "jmxremote.rmi.port=" + ports[1],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false");
- testConnect(pa.getPort1(), pa.getPort2());
+ testConnect(ports[0], ports[1]);
} finally {
s.stop();
}
@@ -550,13 +584,12 @@
// but should leave remote server disabled
System.out.println("**** Test five ****");
-
+ int[] ports = PortAllocator.allocatePorts(1);
Something s = doSomething("test_05");
- PortAllocator pa = new PortAllocator();
try {
jcmd(CMD_START_LOCAL);
- testNoConnect(pa.getPort1());
+ testNoConnect(ports[0]);
testConnectLocal(s.getPid());
} finally {
s.stop();
@@ -566,94 +599,36 @@
static void test_06() throws Exception {
// Run an app without JMX enabled
// start JMX by jcmd on one port, specify rmi port explicitly
- // attempt to start it again
- // 1) with the same port
- // 2) with other port
- // 3) attempt to stop it twice
+ // attempt to start it again with the same port
// Check for valid messages in the output
System.out.println("**** Test six ****");
+ int[] ports = PortAllocator.allocatePorts(2);
Something s = doSomething("test_06");
- PortAllocator pa = new PortAllocator();
try {
jcmd(CMD_START,
- "jmxremote.port=" + pa.getPort1(),
- "jmxremote.authenticate=false",
- "jmxremote.ssl=false");
-
- testConnect(pa.getPort1(), pa.getPort2());
+ "jmxremote.port=" + ports[0],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false");
- final AtomicInteger checks = new AtomicInteger();
- jcmd(
- line -> {
- if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
- checks.getAndUpdate((op) -> op | 1);
- }
- },
- CMD_START,
- "jmxremote.port=" + pa.getPort1(),
- "jmxremote.authenticate=false",
- "jmxremote.ssl=false");
-
- jcmd(
- line -> {
- if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
- checks.getAndUpdate((op) -> op | 2);
- }
- },
- CMD_START,
- "jmxremote.port=" + pa.getPort2(),
- "jmxremote.authenticate=false",
- "jmxremote.ssl=false");
-
- jcmd(CMD_STOP);
- jcmd(CMD_STOP);
+ testConnect(ports[0], ports[1]);
- int busyPort;
- try (ServerSocket ss = new ServerSocket(0))
- {
- busyPort = ss.getLocalPort();
- int retryCntr = 1;
- do {
- final boolean[] retry = new boolean[]{false};
- jcmd(
- line -> {
- boolean match = line.contains("Port already in use: " +
- busyPort);
- System.out.println("[match] " + line + " => " + match);
- if (match) {
- checks.getAndUpdate((op) -> op | 4);
- retry[0] = false;
- } else if (line.contains("Exception thrown by the agent")) {
- retry[0] = true;
- }
- },
- CMD_START,
- "jmxremote.port=" + ss.getLocalPort(),
- "jmxremote.rmi.port=" + pa.getPort2(),
- "jmxremote.authenticate=false",
- "jmxremote.ssl=false"
- );
- if (!retry[0]) {
- break;
- }
- System.out.println("Attempt " + retryCntr + " >>>");
- System.out.println("Unexpected reply from the agent. Retrying in 500ms ...");
- Thread.sleep(500);
- } while (retryCntr++ < 10);
- }
- if ((checks.get() & 1) == 0) {
- throw new Exception("Starting agent on port " + pa.getPort1() + " should " +
- "report an invalid agent state");
- }
- if ((checks.get() & 2) == 0) {
- throw new Exception("Starting agent on poprt " + pa.getPort2() + " should " +
- "report an invalid agent state");
- }
- if ((checks.get() & 4) == 0) {
- throw new Exception("Starting agent on port " + busyPort + " should " +
- "report port in use");
+ final AtomicBoolean checks = new AtomicBoolean(false);
+ jcmd(
+ line -> {
+ if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
+ checks.set(true);
+ }
+ },
+ CMD_START,
+ "jmxremote.port=" + ports[0],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false");
+
+ if (!checks.get()) {
+ throw new Exception("Starting agent on port " + ports[0] + " should "
+ + "report an invalid agent state");
}
} finally {
s.stop();
@@ -661,68 +636,188 @@
}
static void test_07() throws Exception {
- // Run an app without JMX enabled, but with some properties set
- // in command line.
- // make sure these properties overridden corectly
+ // Run an app without JMX enabled
+ // start JMX by jcmd on one port, specify rmi port explicitly
+ // attempt to start it again with other port
+ // Check for valid messages in the output
System.out.println("**** Test seven ****");
- Something s = doSomething(
- "test_07",
- "-Dcom.sun.management.jmxremote.authenticate=false",
- "-Dcom.sun.management.jmxremote.ssl=true");
- PortAllocator pa = new PortAllocator();
-
+ int[] ports = PortAllocator.allocatePorts(2);
+ Something s = doSomething("test_07");
try {
- testNoConnect(pa.getPort1());
+ jcmd(CMD_START,
+ "jmxremote.port=" + ports[0],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false");
+
+ testConnect(ports[0], ports[1]);
+
+ final AtomicBoolean checks = new AtomicBoolean(false);
+
jcmd(
- CMD_START,
- "jmxremote.port=" + pa.getPort2(),
- "jmxremote.authenticate=false",
- "jmxremote.ssl=false"
- );
- testConnect(pa.getPort2());
+ line -> {
+ if (line.contains("java.lang.RuntimeException: Invalid agent state")) {
+ checks.set(true);
+ }
+ },
+ CMD_START,
+ "jmxremote.port=" + ports[1],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false");
+
+ if (!checks.get()) {
+ throw new Exception("Starting agent on poprt " + ports[1] + " should "
+ + "report an invalid agent state");
+ }
} finally {
s.stop();
}
}
static void test_08() throws Exception {
- // Run an app with JMX enabled and with some properties set
- // in command line.
- // stop JMX agent and then start it again with different property values
- // make sure these properties overridden corectly
+ // Run an app without JMX enabled
+ // start JMX by jcmd on one port, specify rmi port explicitly
+ // attempt to stop it twice
+ // Check for valid messages in the output
System.out.println("**** Test eight ****");
- PortAllocator pa = new PortAllocator();
- Something s = doSomething(
- "test_08",
- "-Dcom.sun.management.jmxremote.port=" + pa.getPort1(),
- "-Dcom.sun.management.jmxremote.authenticate=false",
- "-Dcom.sun.management.jmxremote.ssl=true");
+ int[] ports = PortAllocator.allocatePorts(2);
+ Something s = doSomething("test_08");
+ try {
+ jcmd(CMD_START,
+ "jmxremote.port=" + ports[0],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false");
- try {
- testNoConnect(pa.getPort1());
+ testConnect(ports[0], ports[1]);
jcmd(CMD_STOP);
-
- testNoConnect(pa.getPort1());
-
- jcmd(
- CMD_START,
- "jmxremote.port=" + pa.getPort2(),
- "jmxremote.authenticate=false",
- "jmxremote.ssl=false"
- );
-
- testConnect(pa.getPort2());
+ jcmd(CMD_STOP);
} finally {
s.stop();
}
}
static void test_09() throws Exception {
+ // Run an app without JMX enabled
+ // attempt to start JMX using a non-available port
+ // Check for valid messages in the output
+
+ System.out.println("**** Test nine ****");
+
+ Something s = doSomething("test_09");
+
+ try (ServerSocket ss = new ServerSocket(0)) {
+ int localPort = ss.getLocalPort();
+ int[] ports;
+ do {
+ ports = PortAllocator.allocatePorts(1);
+ } while (localPort == ports[0]);
+
+ final AtomicBoolean checks = new AtomicBoolean(false);
+
+ int retryCntr = 1;
+ do {
+ final AtomicBoolean retry = new AtomicBoolean(false);
+
+ try {
+ jcmd(
+ line -> {
+ if (line.contains(Agent.getText(AgentConfigurationError.AGENT_EXCEPTION))) {
+ retry.set(true);
+ }
+ },
+ CMD_START,
+ "jmxremote.port=" + ports[0],
+ "jmxremote.rmi.port=" + localPort,
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false"
+ );
+ } catch (BindException e) {
+ checks.set(true);
+ }
+ if (!retry.get()) {
+ break;
+ }
+ System.out.println("Attempt " + retryCntr + " >>>");
+ System.out.println("Unexpected reply from the agent. Retrying in 500ms ...");
+ Thread.sleep(500);
+ } while (retryCntr++ < 10);
+
+ if (!checks.get()) {
+ throw new Exception("Starting agent on port " + ports[0] + " should "
+ + "report port in use");
+ }
+ } finally {
+ s.stop();
+ }
+
+ }
+
+ static void test_10() throws Exception {
+ // Run an app without JMX enabled, but with some properties set
+ // in command line.
+ // make sure these properties overridden corectly
+
+ System.out.println("**** Test ten ****");
+
+ int[] ports = PortAllocator.allocatePorts(2);
+ Something s = doSomething(
+ "test_10",
+ "-Dcom.sun.management.jmxremote.authenticate=false",
+ "-Dcom.sun.management.jmxremote.ssl=true");
+
+ try {
+ testNoConnect(ports[0]);
+ jcmd(
+ CMD_START,
+ "jmxremote.port=" + ports[1],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false"
+ );
+ testConnect(ports[1]);
+ } finally {
+ s.stop();
+ }
+ }
+
+ static void test_11() throws Exception {
+ // Run an app with JMX enabled and with some properties set
+ // in command line.
+ // stop JMX agent and then start it again with different property values
+ // make sure these properties overridden corectly
+
+ System.out.println("**** Test eleven ****");
+ int[] ports = PortAllocator.allocatePorts(2);
+ Something s = doSomething(
+ "test_11",
+ "-Dcom.sun.management.jmxremote.port=" + ports[0],
+ "-Dcom.sun.management.jmxremote.authenticate=false",
+ "-Dcom.sun.management.jmxremote.ssl=true");
+
+ try {
+ testNoConnect(ports[0]);
+
+ jcmd(CMD_STOP);
+
+ testNoConnect(ports[0]);
+
+ jcmd(
+ CMD_START,
+ "jmxremote.port=" + ports[1],
+ "jmxremote.authenticate=false",
+ "jmxremote.ssl=false"
+ );
+
+ testConnect(ports[1]);
+ } finally {
+ s.stop();
+ }
+ }
+
+ static void test_12() throws Exception {
// Run an app with JMX enabled and with some properties set
// in command line.
// stop JMX agent and then start it again with different property values
@@ -730,87 +825,85 @@
// in command line
// make sure these properties overridden corectly
- System.out.println("**** Test nine ****");
+ System.out.println("**** Test twelve ****");
- Something s = doSomething("test_09",
- "-Dcom.sun.management.config.file=" +
- TEST_SRC + File.separator + "management_cl.properties",
- "-Dcom.sun.management.jmxremote.authenticate=false"
+ int[] ports = PortAllocator.allocatePorts(2);
+ Something s = doSomething("test_12",
+ "-Dcom.sun.management.config.file="
+ + TEST_SRC + File.separator + "management_cl.properties",
+ "-Dcom.sun.management.jmxremote.authenticate=false"
);
- PortAllocator pa = new PortAllocator();
try {
- testNoConnect(pa.getPort1());
+ testNoConnect(ports[0]);
jcmd(CMD_STOP);
- testNoConnect(pa.getPort1());
+ testNoConnect(ports[0]);
jcmd(CMD_START,
- "config.file=" + TEST_SRC + File.separator +
- "management_jcmd.properties",
- "jmxremote.authenticate=false",
- "jmxremote.port=" + pa.getPort2()
+ "config.file=" + TEST_SRC + File.separator
+ + "management_jcmd.properties",
+ "jmxremote.authenticate=false",
+ "jmxremote.port=" + ports[1]
);
- testConnect(pa.getPort2());
+ testConnect(ports[1]);
} finally {
s.stop();
}
}
- static void test_10() throws Exception {
+ static void test_13() throws Exception {
// Run an app with JMX enabled and with some properties set
// in command line.
// stop JMX agent and then start it again with different property values
// stop JMX agent again and then start it without property value
// make sure these properties overridden corectly
- System.out.println("**** Test ten ****");
- PortAllocator pa = new PortAllocator();
-
+ System.out.println("**** Test thirteen ****");
+ int[] ports = PortAllocator.allocatePorts(1);
Something s = doSomething(
- "test_10",
- "-Dcom.sun.management.jmxremote.port=" + pa.getPort1(),
- "-Dcom.sun.management.jmxremote.authenticate=false",
- "-Dcom.sun.management.jmxremote.ssl=true");
+ "test_13",
+ "-Dcom.sun.management.jmxremote.port=" + ports[0],
+ "-Dcom.sun.management.jmxremote.authenticate=false",
+ "-Dcom.sun.management.jmxremote.ssl=true");
try {
- testNoConnect(pa.getPort1());
+ testNoConnect(ports[0]);
jcmd(CMD_STOP);
jcmd(CMD_START,
- "jmxremote.ssl=false",
- "jmxremote.port=" + pa.getPort1()
+ "jmxremote.ssl=false",
+ "jmxremote.port=" + ports[0]
);
- testConnect(pa.getPort1());
+ testConnect(ports[0]);
jcmd(CMD_STOP);
jcmd(CMD_START,
- "jmxremote.port=" + pa.getPort1()
+ "jmxremote.port=" + ports[0]
);
- testNoConnect(pa.getPort1());
+ testNoConnect(ports[0]);
} finally {
s.stop();
}
}
- static void test_11() throws Exception {
+ static void test_14() throws Exception {
// Run an app with JMX enabled
// stop remote agent
// make sure local agent is not affected
- System.out.println("**** Test eleven ****");
- PortAllocator pa = new PortAllocator();
-
+ System.out.println("**** Test fourteen ****");
+ int[] ports = PortAllocator.allocatePorts(1);
Something s = doSomething(
- "test_11",
- "-Dcom.sun.management.jmxremote.port=" + pa.getPort1(),
- "-Dcom.sun.management.jmxremote.authenticate=false",
- "-Dcom.sun.management.jmxremote.ssl=false");
+ "test_14",
+ "-Dcom.sun.management.jmxremote.port=" + ports[0],
+ "-Dcom.sun.management.jmxremote.authenticate=false",
+ "-Dcom.sun.management.jmxremote.ssl=false");
try {
- testConnect(pa.getPort1());
+ testConnect(ports[0]);
jcmd(CMD_STOP);
testConnectLocal(s.getPid());
} finally {
@@ -818,17 +911,17 @@
}
}
- static void test_12() throws Exception {
+ static void test_15() throws Exception {
// Run an app with JMX disabled
// start local agent only
- System.out.println("**** Test twelve ****");
+ System.out.println("**** Test fifteen ****");
- Something s = doSomething("test_12");
- PortAllocator pa = new PortAllocator();
+ int[] ports = PortAllocator.allocatePorts(1);
+ Something s = doSomething("test_15");
try {
- testNoConnect(pa.getPort1());
+ testNoConnect(ports[0]);
jcmd(CMD_START + "_local");
testConnectLocal(s.getPid());
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/misc/VM/GetNanoTimeAdjustment.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,249 @@
+/*
+ * 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.util.Objects;
+import sun.misc.VM;
+
+/**
+ * @test
+ * @bug 8068730
+ * @summary tests that VM.getgetNanoTimeAdjustment() works as expected.
+ * @run main GetNanoTimeAdjustment
+ * @author danielfuchs
+ */
+public class GetNanoTimeAdjustment {
+
+ static final int MILLIS_IN_SECOND = 1000;
+ static final int NANOS_IN_MILLI = 1000_000;
+ static final int NANOS_IN_MICRO = 1000;
+ static final int NANOS_IN_SECOND = 1000_000_000;
+
+ static final boolean verbose = true;
+
+ static final class TestAssertException extends RuntimeException {
+ TestAssertException(String msg) { super(msg); }
+ }
+
+ private static void assertEquals(long expected, long received, String msg) {
+ if (expected != received) {
+ throw new TestAssertException("Unexpected result for " + msg
+ + ".\n\texpected: " + expected
+ + "\n\tactual: " + received);
+ } else if (verbose) {
+ System.out.println("Got expected " + msg + ": " + received);
+ }
+ }
+
+ private static void assertEquals(Object expected, Object received, String msg) {
+ if (!Objects.equals(expected, received)) {
+ throw new TestAssertException("Unexpected result for " + msg
+ + ".\n\texpected: " + expected
+ + "\n\tactual: " + received);
+ } else if (verbose) {
+ System.out.println("Got expected " + msg + ": " + received);
+ }
+ }
+
+ static final long MAX_OFFSET = 0x0100000000L;
+ static final long MIN_OFFSET = -MAX_OFFSET;
+ static enum Answer {
+ YES, // isOffLimit = YES: we must get -1
+ NO, // isOffLimit = NO: we must not not get -1
+ MAYBE // isOffLimit = MAYBE: we might get -1 or a valid adjustment.
+ };
+ static long distance(long one, long two) {
+ return one > two ? Math.subtractExact(one, two)
+ : Math.subtractExact(two, one);
+ }
+
+
+ static Answer isOffLimits(long before, long after, long offset) {
+ long relativeDistanceBefore = distance(before, offset);
+ long relativeDistanceAfter = distance(after, offset);
+ if (relativeDistanceBefore >= MAX_OFFSET && relativeDistanceAfter >= MAX_OFFSET) {
+ return Answer.YES;
+ }
+ if (relativeDistanceBefore < MAX_OFFSET && relativeDistanceAfter < MAX_OFFSET) {
+ if (relativeDistanceBefore == 0 || relativeDistanceAfter == 0) {
+ return Answer.MAYBE; // unlucky case where
+ }
+ return Answer.NO;
+ }
+ return Answer.MAYBE;
+ }
+
+ static void testWithOffset(String name, long offset) {
+ System.out.println("Testing with offset: " + name);
+ long beforeMillis = System.currentTimeMillis();
+ long adjustment = VM.getNanoTimeAdjustment(offset);
+ long afterMillis = System.currentTimeMillis();
+
+ if (offset >= beforeMillis/MILLIS_IN_SECOND
+ && offset <= afterMillis/MILLIS_IN_SECOND) {
+ if (adjustment == -1) {
+ // it's possible that we have fallen in the unlucky case
+ // where -1 was the genuine result. let's go backward a bit.
+ offset = offset - 10;
+ beforeMillis = System.currentTimeMillis();
+ adjustment = VM.getNanoTimeAdjustment(offset);
+ afterMillis = System.currentTimeMillis();
+ if (adjustment == -1) {
+ throw new RuntimeException(name + ": VM says " + offset
+ + " secs is too far off, "
+ + " when time in seconds is in ["
+ + beforeMillis/MILLIS_IN_SECOND + ", "
+ + afterMillis/MILLIS_IN_SECOND
+ + "]");
+ }
+ }
+ }
+
+ Answer isOffLimit = isOffLimits(beforeMillis/MILLIS_IN_SECOND,
+ afterMillis/MILLIS_IN_SECOND, offset);
+ switch (isOffLimit) {
+ case YES:
+ if (adjustment != -1) {
+ throw new RuntimeException(name
+ + ": VM should have returned -1 for "
+ + offset
+ + " when time in seconds is in ["
+ + beforeMillis/MILLIS_IN_SECOND + ", "
+ + afterMillis/MILLIS_IN_SECOND + "]");
+ }
+ System.out.println("Got expected exception value: " + adjustment);
+ break;
+ case NO:
+ if (adjustment == -1) {
+ throw new RuntimeException(name
+ + "VM says " + offset
+ + " secs is too far off, "
+ + " when time in seconds is in ["
+ + beforeMillis/MILLIS_IN_SECOND + ", "
+ + afterMillis/MILLIS_IN_SECOND
+ + "]");
+ }
+ break;
+ case MAYBE:
+ System.out.println("Adjustment: " + adjustment);
+ System.out.println("Can't assert for -1 with offset "
+ + offset + "(" + name + ")"
+ + " when time in seconds is in ["
+ + beforeMillis/MILLIS_IN_SECOND + ", "
+ + afterMillis/MILLIS_IN_SECOND
+ + "]");
+ // not conclusive
+ }
+
+ if (isOffLimit == Answer.NO || adjustment != -1) {
+ System.out.println("Validating adjustment: " + adjustment);
+ long expectedMax = distance(offset, beforeMillis/MILLIS_IN_SECOND)
+ * NANOS_IN_SECOND
+ + (beforeMillis % MILLIS_IN_SECOND) * NANOS_IN_MILLI
+ + (afterMillis - beforeMillis + 1) * NANOS_IN_MILLI;
+ long absoluteAdjustment = distance(0, adjustment);
+ if (absoluteAdjustment > expectedMax) {
+ long adjSec = absoluteAdjustment / NANOS_IN_SECOND;
+ long adjMil = (absoluteAdjustment % NANOS_IN_SECOND) / NANOS_IN_MILLI;
+ long adjMic = (absoluteAdjustment % NANOS_IN_MILLI) / NANOS_IN_MICRO;
+ long adjNan = (absoluteAdjustment % NANOS_IN_MICRO);
+ long expSec = expectedMax / NANOS_IN_SECOND;
+ long expMil = (expectedMax % NANOS_IN_SECOND) / NANOS_IN_MILLI;
+ long expMic = (expectedMax % NANOS_IN_MILLI) / NANOS_IN_MICRO;
+ long expNan = (expectedMax % NANOS_IN_MICRO);
+ System.err.println("Excessive adjustment: " + adjSec + "s, "
+ + adjMil + "ms, " + adjMic + "mics, " + adjNan + "ns");
+ System.err.println("Epected max: " + expSec + "s, "
+ + expMil + "ms, " + expMic + "mics, " + expNan + "ns");
+
+ throw new RuntimeException(name
+ + ": Excessive adjustment: " + adjustment
+ + " when time in millis is in ["
+ + beforeMillis + ", " + afterMillis
+ + "] and offset in seconds is " + offset);
+ }
+ }
+
+ }
+
+ static void regular() {
+ System.out.println("*** Testing regular cases ***");
+ final long start = System.currentTimeMillis();
+ long offset = start/1000;
+ long adjustment = VM.getNanoTimeAdjustment(offset);
+ if (start != offset*1000) {
+ if (adjustment == -1) {
+ throw new RuntimeException("VM says " + offset
+ + " secs is too far off, but time millis is "
+ + System.currentTimeMillis());
+ }
+ }
+ if (adjustment == -1) {
+ offset = System.currentTimeMillis()/1000 - 1024;
+ adjustment = VM.getNanoTimeAdjustment(offset);
+ if (adjustment == -1) {
+ throw new RuntimeException("VM says " + offset
+ + " secs is too far off, but time millis is "
+ + System.currentTimeMillis());
+ }
+ }
+ if (adjustment > (start/1000 - offset + 20)*NANOS_IN_SECOND) {
+ throw new RuntimeException("Excessive adjustment: " + adjustment);
+ }
+ testWithOffset("System.currentTimeMillis()/1000",
+ System.currentTimeMillis()/1000);
+ testWithOffset("System.currentTimeMillis()/1000 - 1024",
+ System.currentTimeMillis()/1000 - 1024);
+ testWithOffset("System.currentTimeMillis()/1000 + 1024",
+ System.currentTimeMillis()/1000 + 1024);
+ }
+
+ static void testLimits() {
+ System.out.println("*** Testing limits ***");
+ testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET + 1",
+ System.currentTimeMillis()/1000 - MAX_OFFSET + 1);
+ testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET - 1",
+ System.currentTimeMillis()/1000 + MAX_OFFSET - 1);
+ testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET",
+ System.currentTimeMillis()/1000 - MAX_OFFSET);
+ testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET",
+ System.currentTimeMillis()/1000 + MAX_OFFSET);
+ testWithOffset("System.currentTimeMillis()/1000 - MAX_OFFSET - 1024",
+ System.currentTimeMillis()/1000 - MAX_OFFSET - 1024);
+ testWithOffset("System.currentTimeMillis()/1000 + MAX_OFFSET + 1024",
+ System.currentTimeMillis()/1000 + MAX_OFFSET + 1024);
+ testWithOffset("0", 0);
+ testWithOffset("-1", -1);
+ testWithOffset("Integer.MAX_VALUE + System.currentTimeMillis()/1000",
+ ((long)Integer.MAX_VALUE) + System.currentTimeMillis()/1000);
+ testWithOffset("System.currentTimeMillis()/1000 - Integer.MIN_VALUE",
+ System.currentTimeMillis()/1000 - Integer.MIN_VALUE);
+ testWithOffset("Long.MAX_VALUE", Long.MAX_VALUE);
+ testWithOffset("System.currentTimeMillis()/1000 - Long.MIN_VALUE",
+ (Long.MIN_VALUE + System.currentTimeMillis()/1000)*-1);
+ }
+
+ public static void main(String[] args) throws Exception {
+ regular();
+ testLimits();
+ }
+
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/nio/cs/StreamEncoderOut.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,90 @@
+/*
+ * 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 8030179
+ @summary test if the charset encoder deails with surrogate correctly
+ * @run testng/othervm -esa StreamEncoderOut
+ */
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Test;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.nio.charset.Charset;
+import java.util.stream.Stream;
+
+import static java.util.stream.Collectors.joining;
+
+@Test
+public class StreamEncoderOut {
+
+ enum Input {
+ HIGH("\ud834"),
+ LOW("\udd1e"),
+ HIGH_LOW("\ud834\udd1e");
+
+ final String value;
+
+ Input(String value) {
+ this.value = value;
+ }
+
+ @Override
+ public String toString() {
+ return name() + " : \'" + value + "\"";
+ }
+ }
+
+ @DataProvider(name = "CharsetAndString")
+ // [Charset, Input]
+ public static Object[][] makeStreamTestData() {
+ // Cross product of supported charsets and inputs
+ return Charset.availableCharsets().values().stream().
+ filter(Charset::canEncode).
+ flatMap(cs -> Stream.of(Input.values()).map(i -> new Object[]{cs, i})).
+ toArray(Object[][]::new);
+ }
+
+ private static String generate(String s, int n) {
+ return Stream.generate(() -> s).limit(n).collect(joining());
+ }
+
+ static final OutputStream DEV_NULL = new OutputStream() {
+ @Override
+ public void write(byte b[], int off, int len) throws IOException {}
+
+ @Override
+ public void write(int b) throws IOException {}
+ };
+
+ @Test(dataProvider = "CharsetAndString")
+ public void test(Charset cs, Input input) throws IOException {
+ OutputStreamWriter w = new OutputStreamWriter(DEV_NULL, cs);
+ String t = generate(input.value, 8193);
+ for (int i = 0; i < 10; i++) {
+ w.append(t);
+ }
+ }
+}
--- a/jdk/test/sun/security/util/HostnameMatcher/TestHostnameChecker.java Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/security/util/HostnameMatcher/TestHostnameChecker.java Wed Feb 18 19:27:49 2015 -0800
@@ -187,6 +187,9 @@
in = new FileInputStream(new File(PATH, "cert4.crt"));
X509Certificate cert4 = (X509Certificate)cf.generateCertificate(in);
in.close();
+ in = new FileInputStream(new File(PATH, "cert5.crt"));
+ X509Certificate cert5 = (X509Certificate)cf.generateCertificate(in);
+ in.close();
HostnameChecker checker = HostnameChecker.getInstance(
HostnameChecker.TYPE_TLS);
@@ -202,6 +205,9 @@
check(checker, "5.6.7.8", cert3, true);
check(checker, "foo.bar.com", cert4, true);
check(checker, "altfoo.bar.com", cert4, true);
+ check(checker, "2001:db8:3c4d:15::1a2f:1a2b", cert5, true);
+ check(checker, "2001:0db8:3c4d:0015:0000:0000:1a2f:1a2b", cert5, true);
+ check(checker, "2002:db8:3c4d:15::1a2f:1a2b", cert5, false);
checker = HostnameChecker.getInstance(
HostnameChecker.TYPE_LDAP);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/sun/security/util/HostnameMatcher/cert5.crt Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,24 @@
+-----BEGIN CERTIFICATE-----
+MIIECDCCAvCgAwIBAgIJAJaBmuUlfY8sMA0GCSqGSIb3DQEBBQUAMIGmMQswCQYD
+VQQGEwJVUzETMBEGA1UECAwKU29tZS1TdGF0ZTESMBAGA1UEBwwJU29tZS1DaXR5
+MSowKAYDVQQKDCFVbmNvbmZpZ3VyZWQgT3BlblNTTCBJbnN0YWxsYXRpb24xEDAO
+BgNVBAsMB3NlY3Rpb24xMDAuBgNVBAMMJzIwMDE6MGRiODozYzRkOjAwMTU6MDAw
+MDowMDAwOjFhMmY6MWEyYjAeFw0xNTAyMTAxODMzMjBaFw0xNTAzMTIxODMzMjBa
+MIGmMQswCQYDVQQGEwJVUzETMBEGA1UECAwKU29tZS1TdGF0ZTESMBAGA1UEBwwJ
+U29tZS1DaXR5MSowKAYDVQQKDCFVbmNvbmZpZ3VyZWQgT3BlblNTTCBJbnN0YWxs
+YXRpb24xEDAOBgNVBAsMB3NlY3Rpb24xMDAuBgNVBAMMJzIwMDE6MGRiODozYzRk
+OjAwMTU6MDAwMDowMDAwOjFhMmY6MWEyYjCCASIwDQYJKoZIhvcNAQEBBQADggEP
+ADCCAQoCggEBAMcigWxmeF6Dmo3xAw3y/8d3vB8Th4YsmvwXb9DxwNWV+B3vxJgq
+ww6T6VBxrle1bgu/RtZDJwLf5vMhVElxuuE86di2qyurKFbpe29C9xnCxuMlXpje
+X2pNknz4ZzOqD4opmIAFjXZ2Xp1kLt+HJX7ABoz7Uga+IbVfDRPPf2KOqYNpBQkp
+dgI5VOZDQNVNb+8vdXDwyanMQ0TgPXKL4BQIkGB4RM8sgpPMUvB+tEB7zmUtgSco
+2a5M84wIhxv85CmFFoTVSzXsRCDhVAZj0aHRkkmAsMSmzPa4HiPnuVRV740oQjDy
+oMGLndaEs2nxIqckUFHOHcSTf0/wmcvPbIsCAwEAAaM3MDUwCQYDVR0TBAIwADAL
+BgNVHQ8EBAMCBeAwGwYDVR0RBBQwEocQIAENuDxNABUAAAAAGi8aKzANBgkqhkiG
+9w0BAQUFAAOCAQEAtnelRbYPPZRgTd4oxOiPqwc01EE9JgtkFWlooCwVUDChOR2k
+us1qlhKsvbN2Tcsm1Ss3p0Uxk/g1o2/mY8rA/dJ8qiN6jbfjpEi8b2MirP5tQSE0
+QNXbVGr5FnLbuUmn+82pB0vBSaq7gxehbV6S7dteyQUnb2imltC5wS9PwYb8wWx7
+IpyXWt0jkYkC8KJEevVYI7qtwpjYhyc1FqwzUiPmdqGz2AFLQ4RgTXJi93SPoyKM
+s65oPV+r6/0qwnslScxVfszHxxFn1Yfsc5Oseare1MnlNzH69PmWs523C/fBvnB2
+MsHKLPdoN7uSpBLB7j46g5jQG/ceri/cquZKYA==
+-----END CERTIFICATE-----
--- a/jdk/test/sun/util/calendar/zi/tzdata/VERSION Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/util/calendar/zi/tzdata/VERSION Wed Feb 18 19:27:49 2015 -0800
@@ -21,4 +21,4 @@
# or visit www.oracle.com if you need additional information or have any
# questions.
#
-tzdata2014j
+tzdata2015a
--- a/jdk/test/sun/util/calendar/zi/tzdata/antarctica Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/util/calendar/zi/tzdata/antarctica Wed Feb 18 19:27:49 2015 -0800
@@ -70,8 +70,8 @@
Rule ChileAQ 2010 only - Apr Sun>=1 3:00u 0 -
Rule ChileAQ 2011 only - May Sun>=2 3:00u 0 -
Rule ChileAQ 2011 only - Aug Sun>=16 4:00u 1:00 S
-Rule ChileAQ 2012 max - Apr Sun>=23 3:00u 0 -
-Rule ChileAQ 2012 max - Sep Sun>=2 4:00u 1:00 S
+Rule ChileAQ 2012 2015 - Apr Sun>=23 3:00u 0 -
+Rule ChileAQ 2012 2014 - Sep Sun>=2 4:00u 1:00 S
# Argentina - year-round bases
# Belgrano II, Confin Coast, -770227-0343737, since 1972-02-05
@@ -377,9 +377,10 @@
#
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Antarctica/Palmer 0 - zzz 1965
- -4:00 ArgAQ AR%sT 1969 Oct 5
+ -4:00 ArgAQ AR%sT 1969 Oct 5
-3:00 ArgAQ AR%sT 1982 May
- -4:00 ChileAQ CL%sT
+ -4:00 ChileAQ CL%sT 2015 Apr 26 3:00u
+ -3:00 - CLT
#
#
# McMurdo Station, Ross Island, since 1955-12
--- a/jdk/test/sun/util/calendar/zi/tzdata/asia Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/util/calendar/zi/tzdata/asia Wed Feb 18 19:27:49 2015 -0800
@@ -168,10 +168,7 @@
4:00 Azer AZ%sT
# Bahrain
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Bahrain 3:22:20 - LMT 1920 # Manamah
- 4:00 - GST 1972 Jun
- 3:00 - AST
+# See Asia/Qatar.
# Bangladesh
# From Alexander Krivenyshev (2009-05-13):
@@ -1754,9 +1751,7 @@
###############################################################################
# Kuwait
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Kuwait 3:11:56 - LMT 1950
- 3:00 - AST
+# See Asia/Riyadh.
# Laos
# See Asia/Bangkok.
@@ -1977,12 +1972,7 @@
5:45 - NPT # Nepal Time
# Oman
-
-# Milne says 3:54:24 was the meridian of the Muscat Tidal Observatory.
-
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Muscat 3:54:24 - LMT 1920
- 4:00 - GST
+# See Asia/Dubai.
# Pakistan
@@ -2476,6 +2466,7 @@
Zone Asia/Qatar 3:26:08 - LMT 1920 # Al Dawhah / Doha
4:00 - GST 1972 Jun
3:00 - AST
+Link Asia/Qatar Asia/Bahrain
# Saudi Arabia
#
@@ -2502,6 +2493,8 @@
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Riyadh 3:06:52 - LMT 1947 Mar 14
3:00 - AST
+Link Asia/Riyadh Asia/Aden # Yemen
+Link Asia/Riyadh Asia/Kuwait
# Singapore
# taken from Mok Ly Yng (2003-10-30)
@@ -2790,6 +2783,7 @@
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
Zone Asia/Dubai 3:41:12 - LMT 1920
4:00 - GST
+Link Asia/Dubai Asia/Muscat # Oman
# Uzbekistan
# Byalokoz 1919 says Uzbekistan was 4:27:53.
@@ -2874,10 +2868,4 @@
7:00 - ICT
# Yemen
-
-# Milne says 2:59:54 was the meridian of the saluting battery at Aden,
-# and that Yemen was at 1:55:56, the meridian of the Hagia Sophia.
-
-# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Asia/Aden 2:59:54 - LMT 1950
- 3:00 - AST
+# See Asia/Riyadh.
--- a/jdk/test/sun/util/calendar/zi/tzdata/backward Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/util/calendar/zi/tzdata/backward Wed Feb 18 19:27:49 2015 -0800
@@ -28,7 +28,7 @@
# and their old names. Many names changed in late 1993.
# Link TARGET LINK-NAME
-Link Africa/Asmara Africa/Asmera
+Link Africa/Nairobi Africa/Asmera
Link Africa/Abidjan Africa/Timbuktu
Link America/Argentina/Catamarca America/Argentina/ComodRivadavia
Link America/Adak America/Atka
--- a/jdk/test/sun/util/calendar/zi/tzdata/europe Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/util/calendar/zi/tzdata/europe Wed Feb 18 19:27:49 2015 -0800
@@ -1430,35 +1430,32 @@
# might be a reference to the Julian calendar as opposed to Gregorian, or it
# might mean something else (???).
#
-# From Paul Eggert (2006-03-22):
-# The Iceland Almanak, Shanks & Pottenger, and Whitman disagree on many points.
-# We go with the Almanak, except for one claim from Shanks & Pottenger, namely
-# that Reykavik was 21W57 from 1837 to 1908, local mean time before that.
+# From Paul Eggert (2014-11-22):
+# The information below is taken from the 1988 Almanak; see
+# http://www.almanak.hi.is/klukkan.html
#
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
-Rule Iceland 1917 1918 - Feb 19 23:00 1:00 S
+Rule Iceland 1917 1919 - Feb 19 23:00 1:00 S
Rule Iceland 1917 only - Oct 21 1:00 0 -
-Rule Iceland 1918 only - Nov 16 1:00 0 -
+Rule Iceland 1918 1919 - Nov 16 1:00 0 -
+Rule Iceland 1921 only - Mar 19 23:00 1:00 S
+Rule Iceland 1921 only - Jun 23 1:00 0 -
Rule Iceland 1939 only - Apr 29 23:00 1:00 S
-Rule Iceland 1939 only - Nov 29 2:00 0 -
+Rule Iceland 1939 only - Oct 29 2:00 0 -
Rule Iceland 1940 only - Feb 25 2:00 1:00 S
-Rule Iceland 1940 only - Nov 3 2:00 0 -
-Rule Iceland 1941 only - Mar 2 1:00s 1:00 S
-Rule Iceland 1941 only - Nov 2 1:00s 0 -
-Rule Iceland 1942 only - Mar 8 1:00s 1:00 S
-Rule Iceland 1942 only - Oct 25 1:00s 0 -
+Rule Iceland 1940 1941 - Nov Sun>=2 1:00s 0 -
+Rule Iceland 1941 1942 - Mar Sun>=2 1:00s 1:00 S
# 1943-1946 - first Sunday in March until first Sunday in winter
Rule Iceland 1943 1946 - Mar Sun>=1 1:00s 1:00 S
-Rule Iceland 1943 1948 - Oct Sun>=22 1:00s 0 -
+Rule Iceland 1942 1948 - Oct Sun>=22 1:00s 0 -
# 1947-1967 - first Sunday in April until first Sunday in winter
Rule Iceland 1947 1967 - Apr Sun>=1 1:00s 1:00 S
-# 1949 Oct transition delayed by 1 week
+# 1949 and 1967 Oct transitions delayed by 1 week
Rule Iceland 1949 only - Oct 30 1:00s 0 -
Rule Iceland 1950 1966 - Oct Sun>=22 1:00s 0 -
Rule Iceland 1967 only - Oct 29 1:00s 0 -
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
-Zone Atlantic/Reykjavik -1:27:24 - LMT 1837
- -1:27:48 - RMT 1908 # Reykjavik Mean Time?
+Zone Atlantic/Reykjavik -1:28 - LMT 1908
-1:00 Iceland IS%sT 1968 Apr 7 1:00s
0:00 - GMT
--- a/jdk/test/sun/util/calendar/zi/tzdata/leapseconds Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/util/calendar/zi/tzdata/leapseconds Wed Feb 18 19:27:49 2015 -0800
@@ -77,3 +77,7 @@
Leap 2005 Dec 31 23:59:60 + S
Leap 2008 Dec 31 23:59:60 + S
Leap 2012 Jun 30 23:59:60 + S
+Leap 2015 Jun 30 23:59:60 + S
+
+# Updated through IERS Bulletin C49
+# File expires on: 28 December 2015
--- a/jdk/test/sun/util/calendar/zi/tzdata/northamerica Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/util/calendar/zi/tzdata/northamerica Wed Feb 18 19:27:49 2015 -0800
@@ -147,7 +147,7 @@
Rule US 1918 1919 - Oct lastSun 2:00 0 S
Rule US 1942 only - Feb 9 2:00 1:00 W # War
Rule US 1945 only - Aug 14 23:00u 1:00 P # Peace
-Rule US 1945 only - Sep 30 2:00 0 S
+Rule US 1945 only - Sep lastSun 2:00 0 S
Rule US 1967 2006 - Oct lastSun 2:00 0 S
Rule US 1967 1973 - Apr lastSun 2:00 1:00 D
Rule US 1974 only - Jan 6 2:00 1:00 D
@@ -2147,11 +2147,11 @@
# Mexico
-# From Paul Eggert (2001-03-05):
+# From Paul Eggert (2014-12-07):
# The Investigation and Analysis Service of the
# Mexican Library of Congress (MLoC) has published a
# history of Mexican local time (in Spanish)
-# http://www.cddhcu.gob.mx/bibliot/publica/inveyana/polisoc/horver/
+# http://www.diputados.gob.mx/bibliot/publica/inveyana/polisoc/horver/index.htm
#
# Here are the discrepancies between Shanks & Pottenger (S&P) and the MLoC.
# (In all cases we go with the MLoC.)
@@ -2320,6 +2320,24 @@
# efecto desde las dos horas del segundo domingo de marzo y concluirá a
# las dos horas del primer domingo de noviembre.
+# From Steffen Thorsen (2014-12-08), translated by Gwillim Law:
+# The Mexican state of Quintana Roo will likely change to EST in 2015.
+#
+# http://www.unioncancun.mx/articulo/2014/12/04/medio-ambiente/congreso-aprueba-una-hora-mas-de-sol-en-qroo
+# "With this change, the time conflict that has existed between the municipios
+# of Quintana Roo and the municipio of Felipe Carrillo Puerto may come to an
+# end. The latter declared itself in rebellion 15 years ago when a time change
+# was initiated in Mexico, and since then it has refused to change its time
+# zone along with the rest of the country."
+#
+# From Steffen Thorsen (2015-01-14), translated by Gwillim Law:
+# http://sipse.com/novedades/confirman-aplicacion-de-nueva-zona-horaria-para-quintana-roo-132331.html
+# "...the new time zone will come into effect at two o'clock on the first Sunday
+# of February, when we will have to advance the clock one hour from its current
+# time..."
+#
+# Also, the new zone will not use DST.
+
# Rule NAME FROM TO TYPE IN ON AT SAVE LETTER/S
Rule Mexico 1939 only - Feb 5 0:00 1:00 D
Rule Mexico 1939 only - Jun 25 0:00 0 S
@@ -2340,7 +2358,8 @@
Zone America/Cancun -5:47:04 - LMT 1922 Jan 1 0:12:56
-6:00 - CST 1981 Dec 23
-5:00 Mexico E%sT 1998 Aug 2 2:00
- -6:00 Mexico C%sT
+ -6:00 Mexico C%sT 2015 Feb 1 2:00
+ -5:00 - EST
# Campeche, Yucatán; represented by Mérida
Zone America/Merida -5:58:28 - LMT 1922 Jan 1 0:01:32
-6:00 - CST 1981 Dec 23
--- a/jdk/test/sun/util/calendar/zi/tzdata/southamerica Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/util/calendar/zi/tzdata/southamerica Wed Feb 18 19:27:49 2015 -0800
@@ -1229,6 +1229,11 @@
# DST Start: first Saturday of September 2014 (Sun 07 Sep 2014 04:00 UTC)
# http://www.diariooficial.interior.gob.cl//media/2014/02/19/do-20140219.pdf
+# From Juan Correa (2015-01-28):
+# ... today the Ministry of Energy announced that Chile will drop DST, will keep
+# "summer time" (UTC -3 / UTC -5) all year round....
+# http://www.minenergia.cl/ministerio/noticias/generales/ministerio-de-energia-anuncia.html
+
# NOTE: ChileAQ rules for Antarctic bases are stored separately in the
# 'antarctica' file.
@@ -1270,8 +1275,8 @@
Rule Chile 2010 only - Apr Sun>=1 3:00u 0 -
Rule Chile 2011 only - May Sun>=2 3:00u 0 -
Rule Chile 2011 only - Aug Sun>=16 4:00u 1:00 S
-Rule Chile 2012 max - Apr Sun>=23 3:00u 0 -
-Rule Chile 2012 max - Sep Sun>=2 4:00u 1:00 S
+Rule Chile 2012 2015 - Apr Sun>=23 3:00u 0 -
+Rule Chile 2012 2014 - Sep Sun>=2 4:00u 1:00 S
# IATA SSIM anomalies: (1992-02) says 1992-03-14;
# (1996-09) says 1998-03-08. Ignore these.
# Zone NAME GMTOFF RULES FORMAT [UNTIL]
@@ -1282,11 +1287,13 @@
-4:00 - CLT 1919 Jul 1 # Chile Time
-4:42:46 - SMT 1927 Sep 1 # Santiago Mean Time
-5:00 Chile CL%sT 1947 May 22 # Chile Time
- -4:00 Chile CL%sT
+ -4:00 Chile CL%sT 2015 Apr 26 3:00u
+ -3:00 - CLT
Zone Pacific/Easter -7:17:44 - LMT 1890
-7:17:28 - EMT 1932 Sep # Easter Mean Time
- -7:00 Chile EAS%sT 1982 Mar 13 21:00 # Easter Time
- -6:00 Chile EAS%sT
+ -7:00 Chile EAS%sT 1982 Mar 13 3:00u # Easter Time
+ -6:00 Chile EAS%sT 2015 Apr 26 3:00u
+ -5:00 - EAST
#
# Salas y Gómez Island is uninhabited.
# Other Chilean locations, including Juan Fernández Is, Desventuradas Is,
--- a/jdk/test/sun/util/calendar/zi/tzdata/zone.tab Tue Feb 17 13:19:23 2015 -0500
+++ b/jdk/test/sun/util/calendar/zi/tzdata/zone.tab Wed Feb 18 19:27:49 2015 -0800
@@ -297,7 +297,7 @@
MV +0410+07330 Indian/Maldives
MW -1547+03500 Africa/Blantyre
MX +1924-09909 America/Mexico_City Central Time - most locations
-MX +2105-08646 America/Cancun Central Time - Quintana Roo
+MX +2105-08646 America/Cancun Eastern Standard Time - Quintana Roo
MX +2058-08937 America/Merida Central Time - Campeche, Yucatan
MX +2540-10019 America/Monterrey Mexican Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas away from US border
MX +2550-09730 America/Matamoros US Central Time - Coahuila, Durango, Nuevo Leon, Tamaulipas near US border
--- a/langtools/.hgtags Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/.hgtags Wed Feb 18 19:27:49 2015 -0800
@@ -291,3 +291,5 @@
e272d9be5f90edb6bb6b40f7816ec85eec0f5dc2 jdk9-b46
230c139552501e612dd0d4423ac30f94c1201c0d jdk9-b47
5b102fc29edf8b7eee7df208d8a8bba0e0a52f3a jdk9-b48
+15c79f28e30a1be561abe0d67674232ad5034d32 jdk9-b49
+1ccb6ef2f40bf9961b27adac390a6fc5181aa1fc jdk9-b50
--- a/langtools/make/tools/propertiesparser/gen/ClassGenerator.java Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/make/tools/propertiesparser/gen/ClassGenerator.java Wed Feb 18 19:27:49 2015 -0800
@@ -192,8 +192,8 @@
*/
String packageName(File file) {
String path = file.getAbsolutePath();
- int begin = path.indexOf("com" + File.separatorChar);
- String packagePath = path.substring(begin, path.lastIndexOf(File.separatorChar));
+ int begin = path.lastIndexOf(File.separatorChar + "com" + File.separatorChar);
+ String packagePath = path.substring(begin + 1, path.lastIndexOf(File.separatorChar));
String packageName = packagePath.replace(File.separatorChar, '.');
return packageName;
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2014, 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
@@ -1931,6 +1931,11 @@
* Return the (most specific) base type of t that starts with the
* given symbol. If none exists, return null.
*
+ * Caveat Emptor: Since javac represents the class of all arrays with a singleton
+ * symbol Symtab.arrayClass, which by being a singleton cannot hold any discriminant,
+ * this method could yield surprising answers when invoked on arrays. For example when
+ * invoked with t being byte [] and sym being t.sym itself, asSuper would answer null.
+ *
* @param t a type
* @param sym a symbol
*/
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/DeferredAttr.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -236,7 +236,8 @@
DeferredStuckPolicy deferredStuckPolicy;
if (resultInfo.pt.hasTag(NONE) || resultInfo.pt.isErroneous()) {
deferredStuckPolicy = dummyStuckPolicy;
- } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE) {
+ } else if (resultInfo.checkContext.deferredAttrContext().mode == AttrMode.SPECULATIVE ||
+ resultInfo.checkContext.deferredAttrContext().insideOverloadPhase()) {
deferredStuckPolicy = new OverloadStuckPolicy(resultInfo, this);
} else {
deferredStuckPolicy = new CheckStuckPolicy(resultInfo, this);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TransTypes.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 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
@@ -720,7 +720,7 @@
public void visitParens(JCParens tree) {
tree.expr = translate(tree.expr, pt);
- tree.type = erasure(tree.type);
+ tree.type = erasure(tree.expr.type);
result = tree;
}
@@ -755,7 +755,7 @@
tree.clazz = translate(tree.clazz, null);
Type originalTarget = tree.type;
tree.type = erasure(tree.type);
- JCExpression newExpression = translate(tree.expr, erasure(tree.expr.type));
+ JCExpression newExpression = translate(tree.expr, tree.type);
if (newExpression != tree.expr) {
JCTypeCast typeCast = newExpression.hasTag(Tag.TYPECAST)
? (JCTypeCast) newExpression
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/jvm/Gen.java Wed Feb 18 19:27:49 2015 -0800
@@ -2145,7 +2145,8 @@
// For basic types, the coerce(...) in genExpr(...) will do
// the conversion.
if (!tree.clazz.type.isPrimitive() &&
- types.asSuper(tree.expr.type, tree.clazz.type.tsym) == null) {
+ !types.isSameType(tree.expr.type, tree.clazz.type) &&
+ types.asSuper(tree.expr.type, tree.clazz.type.tsym) == null) {
code.emitop2(checkcast, makeRef(tree.pos(), tree.clazz.type));
}
}
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/ct.properties Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/resources/ct.properties Wed Feb 18 19:27:49 2015 -0800
@@ -477,7 +477,7 @@
java.rmi.registry.*: compact2
java.rmi.server.*: compact2
java.security.*: compact1
-java.security.acl.*: compact3
+java.security.acl.*: compact1
java.security.cert.*: compact1
java.security.interfaces.*: compact1
java.security.spec.*: compact1
@@ -687,7 +687,7 @@
sun.rmi.transport.*: proprietary compact2
sun.rmi.transport.proxy.*: proprietary compact2
sun.rmi.transport.tcp.*: proprietary compact2
-sun.security.acl.*: proprietary compact3
+sun.security.acl.*: proprietary compact1
sun.security.action.*: proprietary compact1
sun.security.jca.*: proprietary compact1
sun.security.jgss.*: proprietary compact3
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JavacMessages.java Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/util/JavacMessages.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 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
@@ -56,7 +56,7 @@
private Map<Locale, SoftReference<List<ResourceBundle>>> bundleCache;
- private List<String> bundleNames;
+ private List<ResourceBundleHelper> bundleHelpers;
private Locale currentLocale;
private List<ResourceBundle> currentBundles;
@@ -91,7 +91,7 @@
* @param bundleName the name to identify the resource bundle of localized messages.
*/
public JavacMessages(String bundleName, Locale locale) throws MissingResourceException {
- bundleNames = List.nil();
+ bundleHelpers = List.nil();
bundleCache = new HashMap<>();
add(bundleName);
setCurrentLocale(locale);
@@ -101,8 +101,13 @@
this(defaultBundleName);
}
+ @Override
public void add(String bundleName) throws MissingResourceException {
- bundleNames = bundleNames.prepend(bundleName);
+ add(locale -> ResourceBundle.getBundle(bundleName, locale));
+ }
+
+ public void add(ResourceBundleHelper ma) {
+ bundleHelpers = bundleHelpers.prepend(ma);
if (!bundleCache.isEmpty())
bundleCache.clear();
currentBundles = null;
@@ -115,12 +120,13 @@
List<ResourceBundle> bundleList = bundles == null ? null : bundles.get();
if (bundleList == null) {
bundleList = List.nil();
- for (String bundleName : bundleNames) {
+ for (ResourceBundleHelper helper : bundleHelpers) {
try {
- ResourceBundle rb = ResourceBundle.getBundle(bundleName, locale);
+ ResourceBundle rb = helper.getResourceBundle(locale);
bundleList = bundleList.prepend(rb);
} catch (MissingResourceException e) {
- throw new InternalError("Cannot find javac resource bundle for locale " + locale);
+ throw new InternalError("Cannot find requested resource bundle for locale " +
+ locale, e);
}
}
bundleCache.put(locale, new SoftReference<>(bundleList));
@@ -134,6 +140,7 @@
return getLocalizedString(currentLocale, key, args);
}
+ @Override
public String getLocalizedString(Locale l, String key, Object... args) {
if (l == null)
l = getCurrentLocale();
@@ -146,8 +153,7 @@
* easy access to simple localized strings.
*/
- private static final String defaultBundleName =
- "com.sun.tools.javac.resources.compiler";
+ private static final String defaultBundleName = "com.sun.tools.javac.resources.compiler";
private static ResourceBundle defaultBundle;
private static JavacMessages defaultMessages;
@@ -198,4 +204,17 @@
}
return MessageFormat.format(msg, args);
}
+
+ /**
+ * This provides a way for the JavacMessager to retrieve a
+ * ResourceBundle from another module such as jdk.javadoc.
+ */
+ public interface ResourceBundleHelper {
+ /**
+ * Gets the ResourceBundle.
+ * @param locale the requested bundle's locale
+ * @return ResourceBundle
+ */
+ ResourceBundle getResourceBundle(Locale locale);
+ }
}
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Messager.java Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/javadoc/Messager.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 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,6 +27,7 @@
import java.io.PrintWriter;
import java.util.Locale;
+import java.util.ResourceBundle;
import com.sun.javadoc.*;
import com.sun.tools.javac.util.Context;
@@ -126,9 +127,11 @@
PrintWriter noticeWriter) {
super(context, errWriter, warnWriter, noticeWriter);
messages = JavacMessages.instance(context);
- messages.add("com.sun.tools.javadoc.resources.javadoc");
+ messages.add(locale -> ResourceBundle.getBundle("com.sun.tools.javadoc.resources.javadoc",
+ locale));
javadocDiags = new JCDiagnostic.Factory(messages, "javadoc");
this.programName = programName;
+
}
public void setLocale(Locale locale) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/CheckNoClassCastException.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,69 @@
+/*
+ * 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 8069265
+ * @summary ClassCastException when compiled with JDK 9b08+, JDK8 compiles OK.
+ * @run main CheckNoClassCastException
+ */
+import java.util.*;
+
+public class CheckNoClassCastException {
+ static String result = "";
+ public static void main(String[] args) {
+ ListFail.main(null);
+ MapFail.main(null);
+ if (!result.equals("ListFailDoneMapFailDone"))
+ throw new AssertionError("Incorrect result");
+ }
+}
+
+class ListFail {
+ static interface Foo {
+ }
+
+ public static void main(String[] args) {
+ List<Date> list = new ArrayList<>();
+ list.add(new Date());
+
+ List<Foo> cList = (List<Foo>) (List<?>) list;
+ Date date = (Date) cList.get(0);
+ CheckNoClassCastException.result += "ListFailDone";
+ }
+}
+
+
+class MapFail {
+ static interface Foo {
+ }
+
+ public static void main(String[] args) {
+ Map<String,Date> aMap = new HashMap<>();
+ aMap.put("test",new Date());
+
+ Map<String,Foo> m = (Map<String,Foo>) (Map<?,?>) aMap;
+ Date q = (Date) m.get("test");
+ CheckNoClassCastException.result += "MapFailDone";
+ }
+}
--- a/langtools/test/tools/javac/T7053059/DoubleCastTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/test/tools/javac/T7053059/DoubleCastTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -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
@@ -47,6 +47,7 @@
m1((byte[])m());
m1((byte[])os[0]);
m1((byte[])this.x);
+ m1((byte[])((byte []) (o = null)));
}
}
--- a/langtools/test/tools/javac/lambda/8016177/T8016177g.java Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/test/tools/javac/lambda/8016177/T8016177g.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,6 +1,6 @@
/*
* @test /nodynamiccopyright/
- * @bug 8016081 8016178
+ * @bug 8016081 8016178 8069545
* @summary structural most specific and stuckness
* @compile/fail/ref=T8016177g.out -XDrawDiagnostics T8016177g.java
*/
--- a/langtools/test/tools/javac/lambda/8016177/T8016177g.out Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/test/tools/javac/lambda/8016177/T8016177g.out Wed Feb 18 19:27:49 2015 -0800
@@ -1,2 +1,3 @@
-T8016177g.java:35:20: compiler.err.prob.found.req: (compiler.misc.possible.loss.of.precision: double, int)
-1 error
+T8016177g.java:34:14: compiler.err.cant.apply.symbol: kindname.method, print, java.lang.String, Test.Person, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.inferred.do.not.conform.to.upper.bounds: Test.Person, java.lang.String,java.lang.Object))
+T8016177g.java:35:20: compiler.err.cant.apply.symbol: kindname.method, abs, int, java.lang.Double, kindname.class, Test, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.instance.exists: , R, int))
+2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/8068399/T8068399.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,119 @@
+/*
+ * 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.
+ */
+/*
+ * @test
+ * @bug 8068399
+ * @summary structural most specific and stuckness
+ */
+
+import java.util.function.Function;
+import java.util.stream.IntStream;
+import java.util.stream.Stream;
+
+public class T8068399 {
+
+ public static class Spectrum {
+ public double[] getEnergy() {
+ return new double[0];
+ }
+ }
+
+ protected Spectrum spectrum;
+
+ public static class Ref<T> {
+
+ T value;
+
+ public Ref() {
+ }
+
+ public Ref(T value) {
+ this.value = value;
+ }
+
+ public boolean isNull() {
+ return value == null;
+ }
+
+ public T get() {
+ return value;
+ }
+
+ public void set(T value) {
+ this.value = value;
+ }
+ }
+
+ public static <T>T maxKey(Stream<T> stream, Function<T, Double> function) {
+ Ref<Double> max = new Ref<>();
+ Ref<T> index = new Ref<>();
+ stream.forEach(v -> {
+ Double value = function.apply(v);
+
+ if (max.isNull() || value > max.get()) {
+ max.set(value);
+ index.set(v);
+ }
+ });
+
+ return index.get();
+ }
+
+ public static int interpolate(int x, int x0, int x1, int y0, int y1) {
+ return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
+ }
+
+ public static double interpolate(double x, double x0, double x1, double y0, double y1) {
+ return y0 + (x - x0) * (y1 - y0) / (x1 - x0);
+ }
+
+ protected int getXByFrequency(double frequency) {
+ return (int) Math.round(interpolate(frequency,
+ getMinSpectrumCoord(),
+ getMaxSpectrumCoord(),
+ 0, getWidth()));
+ }
+
+ private int getWidth() {
+ return 0;
+ }
+
+ private double getMaxSpectrumCoord() {
+ return 0;
+ }
+
+ private double getMinSpectrumCoord() {
+ return 0;
+ }
+
+ void foo() {
+ int maxBpmIndex = 0;
+ int xcur = getXByFrequency(maxKey(IntStream.range(0, maxBpmIndex).boxed(),
+ i -> Math.abs(spectrum.getEnergy()[i])));
+ }
+
+ public static void main(String [] args) {
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/8068430/T8068430.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,46 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @bug 8068430
+ * @summary structural most specific and stuckness
+ */
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class T8068430 {
+ public static void main(String[] args) {
+ Map<Integer, String> mp = new HashMap<>();
+ mp.put(1, "a");
+ mp.put(2, "b");
+ mp.put(3, "c");
+ mp.put(4, "d");
+ System.out.println(mp.entrySet().stream().reduce(0,
+ (i, e) -> i + e.getKey(),
+ (i1, i2) -> i1 + i2));
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/8071432/T8071432.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,50 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 8071432
+ * @summary structural most specific and stuckness
+ * @compile/fail/ref=T8071432.out -XDrawDiagnostics T8071432.java
+ */
+
+import java.util.Arrays;
+import java.util.Collection;
+
+class T8071432 {
+
+ static class Point {
+
+ private double x, y;
+
+ public Point(double x, double y) {
+ this.x = x;
+ this.y = y;
+ }
+
+ public double getX() {
+ return x;
+ }
+
+ public double getY() {
+ return y;
+ }
+
+ public double distance(Point p) {
+ return Math.sqrt((this.x - p.x) * (this.x - p.x) +
+ (this.y - p.y) * (this.y - p.y));
+ }
+
+ public double distance() {
+ return Math.sqrt(this.x * this.x + this.y * this.y);
+ }
+
+ public String toString() {
+ return "(" + x + ":" + y + ")";
+ }
+ }
+
+ public static void main(String[] args) {
+ Collection<Point> c = Arrays.asList(new Point(1.0, 0.1));
+ System.out.println("------- 1 ---------------");
+ System.out.println(c.stream().reduce(0.0,
+ (s, p) -> s += p.distance(), (d1, d2) -> 0));
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/lambda/8071432/T8071432.out Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,3 @@
+T8071432.java:47:45: compiler.err.prob.found.req: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.Double)))
+T8071432.java:47:27: compiler.err.cant.apply.symbol: kindname.method, println, java.lang.Object, <any>, kindname.class, java.io.PrintStream, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.infer.no.conforming.assignment.exists: U, (compiler.misc.incompatible.ret.type.in.lambda: (compiler.misc.inconvertible.types: int, java.lang.Double))))
+2 errors
--- a/langtools/test/tools/javac/lambda/MethodReference55.java Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/test/tools/javac/lambda/MethodReference55.java Wed Feb 18 19:27:49 2015 -0800
@@ -1,29 +1,6 @@
/*
- * Copyright (c) 2012, 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 8004101
+ * @test /nodynamiccopyright/
+ * @bug 8004101 8072445
* @summary Add checks for method reference well-formedness
* @compile/fail/ref=MethodReference55.out -XDrawDiagnostics MethodReference55.java
*/
--- a/langtools/test/tools/javac/lambda/MethodReference55.out Tue Feb 17 13:19:23 2015 -0500
+++ b/langtools/test/tools/javac/lambda/MethodReference55.out Wed Feb 18 19:27:49 2015 -0800
@@ -1,3 +1,3 @@
-MethodReference55.java:36:11: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.bad.static.method.in.bound.lookup: kindname.method, m(java.lang.Object)))
-MethodReference55.java:39:9: compiler.err.cant.apply.symbol: kindname.method, g, MethodReference55.V, @1384, kindname.class, MethodReference55<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.bad.static.method.in.bound.lookup: kindname.method, m(java.lang.Object))))
+MethodReference55.java:13:11: compiler.err.prob.found.req: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.bad.static.method.in.bound.lookup: kindname.method, m(java.lang.Object)))
+MethodReference55.java:16:9: compiler.err.cant.apply.symbol: kindname.method, g, MethodReference55.V, @361, kindname.class, MethodReference55<X>, (compiler.misc.no.conforming.assignment.exists: (compiler.misc.invalid.mref: kindname.method, (compiler.misc.bad.static.method.in.bound.lookup: kindname.method, m(java.lang.Object))))
2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/sjavac/ParallelCompilations.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ */
+
+/*
+ * @test
+ * @summary Test to check that -j option works with more than one value
+ * @bug 8071629
+ * @author sogoel
+ * @library /tools/lib
+ * @build Wrapper ToolBox
+ * @run main Wrapper ParallelCompilations
+ */
+
+import java.io.*;
+import java.nio.file.*;
+import com.sun.tools.sjavac.Main;
+
+class ParallelCompilations extends SJavacTester {
+ public static void main(String[] args) throws Exception {
+ new ParallelCompilations().run();
+ }
+
+ public void run() throws Exception {
+ ToolBox tb = new ToolBox();
+ final String SERVER_ARG = "--server:"
+ + "portfile=testportfile,"
+ + "background=false";
+
+ // Generate 10 files
+ for (int i = 0; i < 10; i++) {
+ String fileName = "Test" + i;
+ String content = "package foo"+ i + ";\n" +
+ "public class "+ fileName + "{\n" +
+ " public static void main(String[] args) {}\n" +
+ "\n}";
+ Path srcDir = Paths.get("src");
+ tb.writeJavaFiles(srcDir,content);
+ }
+ //Method will throw an exception if compilation fails
+ compile("src", "-d", "classes", "-j", "10", SERVER_ARG, "--log=debug");
+ }
+}
--- a/make/Main.gmk Tue Feb 17 13:19:23 2015 -0500
+++ b/make/Main.gmk Wed Feb 18 19:27:49 2015 -0800
@@ -212,7 +212,7 @@
@$(RM) $@
@$(call GetSourceTips)
-BOOTCYCLE_TARGET := images
+BOOTCYCLE_TARGET := product-images
bootcycle-images:
@$(ECHO) Boot cycle build step 2: Building a new JDK image using previously built image
+$(MAKE) $(MAKE_ARGS) -f Main.gmk SPEC=$(dir $(SPEC))bootcycle-spec.gmk $(BOOTCYCLE_TARGET)
@@ -443,31 +443,45 @@
ALL_MODULE_TARGETS := $(sort $(GENSRC_MODULES) $(JAVA_MODULES) \
$(GENDATA_MODULES) $(LIBS_MODULES) $(LAUNCHER_MODULES) $(COPY_MODULES))
+# The "exploded image" is a locally runnable JDK in $(BUILD_OUTPUT)/jdk.
exploded-image: $(ALL_MODULE_TARGETS)
-# The old 'jdk' target most closely matches the new exploded-image. Keep an
-# alias for ease of use.
-jdk: exploded-image
+
+# The $(BUILD_OUTPUT)/images directory contain the resulting deliverables,
+# and in line with this, our targets for creating these are named *-image[s].
-images: test-image jimages demos samples zip-security verify-modules
+# This target builds the product images, e.g. the JRE and JDK image
+# (and possibly other, more specific versions)
+product-images: jimages demos samples zip-security verify-modules
ifeq ($(OPENJDK_TARGET_OS), macosx)
- images: mac-bundles
+ product-images: mac-bundles
endif
-docs: docs-javadoc docs-jvmtidoc
+# This target builds the documentation image
+docs-image: docs-javadoc docs-jvmtidoc
+# This target builds the test image
test-image: prepare-test-image
+# all-images is the top-most target, it builds all our deliverables ("images").
+all-images: product-images test-image docs-image
+
ALL_TARGETS += buildtools gensrc gendata copy java rmic libs launchers \
- jdk.jdwp.agent-gensrc $(ALL_MODULE_TARGETS) exploded-image jdk images \
- docs test-image
+ jdk.jdwp.agent-gensrc $(ALL_MODULE_TARGETS) exploded-image \
+ product-images docs-image test-image all-images
################################################################################
-all: images
+# Traditional targets typically run by users.
+# These can be considered aliases for the targets now named by a more
+# "modern" naming scheme.
default: exploded-image
+jdk: exploded-image
+images: product-images
+docs: docs-image
+all: all-images
-ALL_TARGETS += default all
+ALL_TARGETS += default jdk images docs all
################################################################################
################################################################################
@@ -553,7 +567,8 @@
else
@$(ECHO) "Re-running configure using default settings"
endif
- @( cd $(OUTPUT_ROOT) && $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) )
+ @( cd $(OUTPUT_ROOT) && PATH="$(ORIGINAL_PATH)" \
+ $(BASH) $(TOPDIR)/configure $(CONFIGURE_COMMAND_LINE) )
ALL_TARGETS += reconfigure
--- a/make/StripBinaries.gmk Tue Feb 17 13:19:23 2015 -0500
+++ b/make/StripBinaries.gmk Wed Feb 18 19:27:49 2015 -0800
@@ -53,7 +53,7 @@
endif
# Don't include debug info for executables.
-ALL_CMDS_SRC := $(filter-out %.debuginfo %.diz %.map %.pdb, \
+ALL_CMDS_SRC := $(filter-out %.bc %.debuginfo %.diz %.map %.pdb, \
$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_cmds -type f -o -type l))
COPY_CMDS_SRC := $(filter %.cgi, $(ALL_CMDS_SRC))
STRIP_CMDS_SRC := $(filter-out $(COPY_CMDS_SRC), $(ALL_CMDS_SRC))
--- a/make/common/NativeCompilation.gmk Tue Feb 17 13:19:23 2015 -0500
+++ b/make/common/NativeCompilation.gmk Wed Feb 18 19:27:49 2015 -0800
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2011, 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
@@ -53,6 +53,8 @@
UNIX_PATH_PREFIX :=
endif
+# This pattern is used to transform the output of the microsoft CL compiler
+# into a make syntax dependency file (.d)
WINDOWS_SHOWINCLUDE_SED_PATTERN := \
-e '/^Note: including file:/!d' \
-e 's|Note: including file: *||' \
@@ -62,6 +64,16 @@
-e 's|$$$$| \\|g' \
#
+# This pattern is used to transform a dependency file (.d) to a list
+# of make targets for dependent files (.d.targets)
+DEPENDENCY_TARGET_SED_PATTERN := \
+ -e 's/\#.*//' \
+ -e 's/^[^:]*: *//' \
+ -e 's/ *\\$$$$//' \
+ -e '/^$$$$/ d' \
+ -e 's/$$$$/ :/' \
+ #
+
define add_native_source
# param 1 = BUILD_MYPACKAGE
# parma 2 = the source file name (..../alfa.c or .../beta.cpp)
@@ -75,12 +87,12 @@
ifneq (,$$(filter %.c,$2))
# Compile as a C file
- $1_$2_FLAGS=$4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
+ $1_$2_FLAGS=$(CFLAGS_CCACHE) $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
$1_$2_COMP=$5
$1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
else ifneq (,$$(filter %.m,$2))
# Compile as a objective-c file
- $1_$2_FLAGS=-x objective-c $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
+ $1_$2_FLAGS=-x objective-c $(CFLAGS_CCACHE) $4 $$($1_$(notdir $2)_CFLAGS) -DTHIS_FILE='"$$(<F)"' -c
$1_$2_COMP=$8
$1_$2_DEP_FLAG:=$(C_FLAG_DEPS)
else ifneq (,$$(filter %.s,$2))
@@ -90,7 +102,7 @@
$1_$2_DEP_FLAG:=
else ifneq (,$$(filter %.cpp,$2)$$(filter %.mm,$2))
# Compile as a C++ file
- $1_$2_FLAGS=$6 $$($1_$(notdir $2)_CXXFLAGS) -DTHIS_FILE='"$$(<F)"' -c
+ $1_$2_FLAGS=$(CFLAGS_CCACHE) $6 $$($1_$(notdir $2)_CXXFLAGS) -DTHIS_FILE='"$$(<F)"' -c
$1_$2_COMP=$7
$1_$2_DEP_FLAG:=$(CXX_FLAG_DEPS)
else
@@ -105,8 +117,13 @@
ifeq (,$$(filter %.s,$2))
# And this is the dependency file for this obj file.
$1_$2_DEP:=$$(patsubst %$(OBJ_SUFFIX),%.d,$$($1_$2_OBJ))
+ # The dependency target file lists all dependencies as empty targets
+ # to avoid make error "No rule to make target" for removed files
+ $1_$2_DEP_TARGETS:=$$(patsubst %$(OBJ_SUFFIX),%.d.targets,$$($1_$2_OBJ))
+
# Include previously generated dependency information. (if it exists)
-include $$($1_$2_DEP)
+ -include $$($1_$2_DEP_TARGETS)
ifeq ($(TOOLCHAIN_TYPE), microsoft)
$1_$2_DEBUG_OUT_FLAGS:=-Fd$$(patsubst %$(OBJ_SUFFIX),%.pdb,$$($1_$2_OBJ)) \
@@ -139,6 +156,11 @@
($(ECHO) $$@: \\ \
&& $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_$2_DEP).raw) > $$($1_$2_DEP)
endif
+ # Create a dependency target file from the dependency file.
+ # Solution suggested by http://make.mad-scientist.net/papers/advanced-auto-dependency-generation/
+ ifneq ($$($1_$2_DEP),)
+ $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_$2_DEP) > $$($1_$2_DEP_TARGETS)
+ endif
endif
endef
@@ -428,7 +450,7 @@
$1_BUILD_INFO := $$($1_OBJECT_DIR)/_build-info.marker
# Track variable changes for all variables that affect the compilation command
- # lines for all object files in this setup. This includes at least all the
+ # lines for all object files in this setup. This includes at least all the
# variables used in the call to add_native_source below.
$1_COMPILE_VARDEPS := $$($1_CFLAGS) $$($1_EXTRA_CFLAGS) $(SYSROOT_CFLAGS) \
$$($1_CXXFLAGS) $$($1_EXTRA_CXXFLAGS) \
@@ -452,7 +474,10 @@
ifeq ($$(wildcard $$($1_TARGET)),)
$(ECHO) 'Creating $$($1_BASENAME) from $$(words $$(filter-out %.vardeps, $$?)) file(s)'
else
- $(ECHO) 'Updating $$($1_BASENAME) from $$(words $$(filter-out %.vardeps, $$?)) file(s)'
+ $(ECHO) $$(strip 'Updating $$($1_BASENAME)' \
+ $$(if $$(filter-out %.vardeps, $$?), \
+ 'from $$(words $$(filter-out %.vardeps, $$?)) file(s)') \
+ $$(if $$(filter %.vardeps, $$?), 'due to makefile changes'))
endif
$(TOUCH) $$@
@@ -461,7 +486,9 @@
ifneq (,$$($1_VERSIONINFO_RESOURCE))
$1_RES:=$$($1_OBJECT_DIR)/$$($1_BASENAME).res
$1_RES_DEP:=$$($1_RES).d
+ $1_RES_DEP_TARGETS:=$$($1_RES).d.targets
-include $$($1_RES_DEP)
+ -include $$($1_RES_DEP_TARGETS)
$1_RES_VARDEPS := $(RC) $$($1_RC_FLAGS)
$1_RES_VARDEPS_FILE := $$(call DependOnVariable, $1_RES_VARDEPS, \
@@ -469,12 +496,14 @@
$$($1_RES): $$($1_VERSIONINFO_RESOURCE) $$($1_RES_VARDEPS_FILE)
$(ECHO) $(LOG_INFO) "Compiling resource $$(notdir $$($1_VERSIONINFO_RESOURCE)) (for $$(notdir $$($1_TARGET)))"
- $(RC) $$($1_RC_FLAGS) $(CC_OUT_OPTION)$$@ $$($1_VERSIONINFO_RESOURCE)
+ $(RC) $$($1_RC_FLAGS) $(SYSROOT_CFLAGS) $(CC_OUT_OPTION)$$@ \
+ $$($1_VERSIONINFO_RESOURCE)
# Windows RC compiler does not support -showIncludes, so we mis-use CL for this.
- $(CC) $$($1_RC_FLAGS) -showIncludes -nologo -TC \
+ $(CC) $$($1_RC_FLAGS) $(SYSROOT_CFLAGS) -showIncludes -nologo -TC \
$(CC_OUT_OPTION)$$($1_RES_DEP).obj $$($1_VERSIONINFO_RESOURCE) > $$($1_RES_DEP).raw 2>&1 || exit 0
($(ECHO) $$($1_RES): \\ \
&& $(SED) $(WINDOWS_SHOWINCLUDE_SED_PATTERN) $$($1_RES_DEP).raw) > $$($1_RES_DEP)
+ $(SED) $(DEPENDENCY_TARGET_SED_PATTERN) $$($1_RES_DEP) > $$($1_RES_DEP_TARGETS)
endif
ifneq (,$$($1_MANIFEST))
$1_GEN_MANIFEST:=$$($1_OBJECT_DIR)/$$($1_PROGRAM).manifest
--- a/modules.xml Tue Feb 17 13:19:23 2015 -0500
+++ b/modules.xml Wed Feb 18 19:27:49 2015 -0800
@@ -108,6 +108,9 @@
<name>java.security</name>
</export>
<export>
+ <name>java.security.acl</name>
+ </export>
+ <export>
<name>java.security.cert</name>
</export>
<export>
@@ -446,7 +449,6 @@
<depend re-exports="true">java.management</depend>
<depend re-exports="true">java.naming</depend>
<depend re-exports="true">java.prefs</depend>
- <depend re-exports="true">java.security.acl</depend>
<depend re-exports="true">java.security.jgss</depend>
<depend re-exports="true">java.security.sasl</depend>
<depend re-exports="true">java.sql.rowset</depend>
@@ -891,13 +893,6 @@
<depend re-exports="true">java.xml.ws</depend>
</module>
<module>
- <name>java.security.acl</name>
- <depend>java.base</depend>
- <export>
- <name>java.security.acl</name>
- </export>
- </module>
- <module>
<name>java.security.jgss</name>
<depend>java.base</depend>
<depend>java.naming</depend>
--- a/nashorn/.hgtags Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/.hgtags Wed Feb 18 19:27:49 2015 -0800
@@ -282,3 +282,5 @@
2ecf0a617f0f9af1ffd278a0c70e76f1946ce773 jdk9-b46
29046d42a95e5b9f105ab086a628bbd7f81c915d jdk9-b47
f08660f30051ba0b38ad00e692979b37d107c9c4 jdk9-b48
+2ae58b5f05f803a469f0f6c1ed72c6b5313f4ff0 jdk9-b49
+32e48a0d59e186df8a041e1e5f8bfb0b8d2bc4cd jdk9-b50
--- a/nashorn/make/build.xml Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/make/build.xml Wed Feb 18 19:27:49 2015 -0800
@@ -504,7 +504,7 @@
<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
- <jvmarg line="${ext.class.path}"/>
+ <jvmarg line="${boot.class.path}"/>
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} -Dbuild.dir=${build.dir}"/>
<propertyset>
<propertyref prefix="testjfx-test-sys-prop."/>
@@ -524,7 +524,7 @@
<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
- <jvmarg line="${ext.class.path}"/>
+ <jvmarg line="${boot.class.path}"/>
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
<propertyset>
<propertyref prefix="testmarkdown-test-sys-prop."/>
@@ -543,7 +543,7 @@
<testng outputdir="${build.test.results.dir}" classfilesetref="test.classes"
verbose="${testng.verbose}" haltonfailure="true" useDefaultListeners="false" listeners="${testng.listeners}" workingDir="${basedir}">
- <jvmarg line="${ext.class.path}"/>
+ <jvmarg line="${boot.class.path}"/>
<jvmarg line="${run.test.jvmargs} -Xmx${run.test.xmx} ${run.test.jvmsecurityargs} -Dbuild.dir=${build.dir}"/>
<propertyset>
<propertyref prefix="nashorn."/>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/samples/getclassnpe.js Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,122 @@
+#// Usage: jjs getclassnpe.js -- <directory>
+
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Oracle nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * java.lang.Object.getClass() is sometimes used to do null check. This
+ * obfuscating Object.getClass() check relies on non-related intrinsic
+ * performance, which is potentially not available everywhere.
+ * See also http://cr.openjdk.java.net/~shade/scratch/NullChecks.java
+ * This nashorn script checks for such uses in your .java files in the
+ * given directory (recursively).
+ */
+
+if (arguments.length == 0) {
+ print("Usage: jjs getclassnpe.js -- <directory>");
+ exit(1);
+}
+
+// Java types used
+var File = Java.type("java.io.File");
+var Files = Java.type("java.nio.file.Files");
+var StringArray = Java.type("java.lang.String[]");
+var ToolProvider = Java.type("javax.tools.ToolProvider");
+var MethodInvocationTree = Java.type("com.sun.source.tree.MethodInvocationTree");
+var TreeScanner = Java.type("com.sun.source.util.TreeScanner");
+
+// parse a specific .java file to check if it uses
+// Object.getClass() for null check.
+function checkGetClassNPE() {
+ // get the system compiler tool
+ var compiler = ToolProvider.systemJavaCompiler;
+ // get standard file manager
+ var fileMgr = compiler.getStandardFileManager(null, null, null);
+ // Using Java.to convert script array (arguments) to a Java String[]
+ var compUnits = fileMgr.getJavaFileObjects(
+ Java.to(arguments, StringArray));
+ // create a new compilation task
+ var task = compiler.getTask(null, fileMgr, null, null, null, compUnits);
+ // subclass SimpleTreeVisitor - to check for obj.getClass(); statements
+ var GetClassNPEChecker = Java.extend(TreeScanner);
+
+ var visitor = new GetClassNPEChecker() {
+ lineMap: null,
+ sourceFile: null,
+
+ // save compilation unit details for reporting
+ visitCompilationUnit: function(node, p) {
+ this.sourceFile = node.sourceFile;
+ this.lineMap = node.lineMap;
+ return Java.super(visitor).visitCompilationUnit(node, p);
+ },
+
+ // look for "foo.getClass();" expression statements
+ visitExpressionStatement: function(node, p) {
+ var expr = node.expression;
+ if (expr instanceof MethodInvocationTree) {
+ var name = String(expr.methodSelect.identifier);
+
+ // will match any "getClass" call with zero arguments!
+ if (name == "getClass" && expr.arguments.size() == 0) {
+ print(this.sourceFile.getName()
+ + " @ "
+ + this.lineMap.getLineNumber(node.pos)
+ + ":"
+ + this.lineMap.getColumnNumber(node.pos));
+
+ print("\t", node);
+ }
+ }
+ }
+ }
+
+ for each (var cu in task.parse()) {
+ cu.accept(visitor, null);
+ }
+}
+
+// for each ".java" file in the directory (recursively)
+function main(dir) {
+ Files.walk(dir.toPath()).
+ forEach(function(p) {
+ var name = p.toFile().absolutePath;
+ if (name.endsWith(".java")) {
+ try {
+ checkGetClassNPE(p.toFile().getAbsolutePath());
+ } catch (e) {
+ print(e);
+ }
+ }
+ });
+}
+
+main(new File(arguments[0]));
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/DynamicLinker.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/DynamicLinker.java Wed Feb 18 19:27:49 2015 -0800
@@ -88,6 +88,7 @@
import java.lang.invoke.MethodType;
import java.lang.invoke.MutableCallSite;
import java.util.List;
+import java.util.Objects;
import jdk.internal.dynalink.linker.GuardedInvocation;
import jdk.internal.dynalink.linker.GuardingDynamicLinker;
import jdk.internal.dynalink.linker.LinkRequest;
@@ -252,7 +253,7 @@
// Make sure we filter the invocation before linking it into the call site. This is typically used to match the
// return type of the invocation to the call site.
guardedInvocation = prelinkFilter.filter(guardedInvocation, linkRequest, linkerServices);
- guardedInvocation.getClass(); // null pointer check
+ Objects.requireNonNull(guardedInvocation);
int newRelinkCount = relinkCount;
// Note that the short-circuited "&&" evaluation below ensures we'll increment the relinkCount until
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/DynamicLinkerFactory.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/DynamicLinkerFactory.java Wed Feb 18 19:27:49 2015 -0800
@@ -97,6 +97,8 @@
import jdk.internal.dynalink.linker.GuardingDynamicLinker;
import jdk.internal.dynalink.linker.GuardingTypeConverterFactory;
import jdk.internal.dynalink.linker.LinkRequest;
+import jdk.internal.dynalink.linker.LinkerServices;
+import jdk.internal.dynalink.linker.MethodHandleTransformer;
import jdk.internal.dynalink.linker.MethodTypeConversionStrategy;
import jdk.internal.dynalink.support.AutoDiscovery;
import jdk.internal.dynalink.support.BottomGuardingDynamicLinker;
@@ -132,6 +134,7 @@
private int unstableRelinkThreshold = DEFAULT_UNSTABLE_RELINK_THRESHOLD;
private GuardedInvocationFilter prelinkFilter;
private MethodTypeConversionStrategy autoConversionStrategy;
+ private MethodHandleTransformer internalObjectsFilter;
/**
* Sets the class loader for automatic discovery of available linkers. If not set explicitly, then the thread
@@ -284,6 +287,15 @@
}
/**
+ * Sets a method handle transformer that is supposed to act as the implementation of this linker factory's linkers'
+ * services {@link LinkerServices#filterInternalObjects(java.lang.invoke.MethodHandle)} method.
+ * @param internalObjectsFilter a method handle transformer filtering out internal objects, or null.
+ */
+ public void setInternalObjectsFilter(final MethodHandleTransformer internalObjectsFilter) {
+ this.internalObjectsFilter = internalObjectsFilter;
+ }
+
+ /**
* Creates a new dynamic linker consisting of all the prioritized, autodiscovered, and fallback linkers as well as
* the pre-link filter.
*
@@ -350,8 +362,8 @@
}
return new DynamicLinker(new LinkerServicesImpl(new TypeConverterFactory(typeConverters,
- autoConversionStrategy), composite), prelinkFilter, runtimeContextArgCount, syncOnRelink,
- unstableRelinkThreshold);
+ autoConversionStrategy), composite, internalObjectsFilter), prelinkFilter, runtimeContextArgCount,
+ syncOnRelink, unstableRelinkThreshold);
}
private static ClassLoader getThreadContextClassLoader() {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/AbstractJavaLinker.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/AbstractJavaLinker.java Wed Feb 18 19:27:49 2015 -0800
@@ -570,7 +570,7 @@
private static final MethodHandle CONSTANT_NULL_DROP_ANNOTATED_METHOD = MethodHandles.dropArguments(
MethodHandles.constant(Object.class, null), 0, AnnotatedDynamicMethod.class);
private static final MethodHandle GET_ANNOTATED_METHOD = privateLookup.findVirtual(AnnotatedDynamicMethod.class,
- "getTarget", MethodType.methodType(MethodHandle.class, MethodHandles.Lookup.class));
+ "getTarget", MethodType.methodType(MethodHandle.class, MethodHandles.Lookup.class, LinkerServices.class));
private static final MethodHandle GETTER_INVOKER = MethodHandles.invoker(MethodType.methodType(Object.class, Object.class));
private GuardedInvocationComponent getPropertyGetter(final CallSiteDescriptor callSiteDescriptor,
@@ -593,7 +593,7 @@
final MethodHandle typedGetter = linkerServices.asType(getPropertyGetterHandle, type.changeReturnType(
AnnotatedDynamicMethod.class));
final MethodHandle callSiteBoundMethodGetter = MethodHandles.insertArguments(
- GET_ANNOTATED_METHOD, 1, callSiteDescriptor.getLookup());
+ GET_ANNOTATED_METHOD, 1, callSiteDescriptor.getLookup(), linkerServices);
final MethodHandle callSiteBoundInvoker = MethodHandles.filterArguments(GETTER_INVOKER, 0,
callSiteBoundMethodGetter);
// Object(AnnotatedDynamicMethod, Object)->Object(AnnotatedDynamicMethod, T0)
@@ -873,8 +873,8 @@
}
@SuppressWarnings("unused")
- MethodHandle getTarget(final MethodHandles.Lookup lookup) {
- final MethodHandle inv = method.getTarget(lookup);
+ MethodHandle getTarget(final MethodHandles.Lookup lookup, final LinkerServices linkerServices) {
+ final MethodHandle inv = linkerServices.filterInternalObjects(method.getTarget(lookup));
assert inv != null;
return inv;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/BeanLinker.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/BeanLinker.java Wed Feb 18 19:27:49 2015 -0800
@@ -165,6 +165,10 @@
private static MethodHandle LIST_GUARD = Guards.getInstanceOfGuard(List.class);
private static MethodHandle MAP_GUARD = Guards.getInstanceOfGuard(Map.class);
+ private enum CollectionType {
+ ARRAY, LIST, MAP
+ };
+
private GuardedInvocationComponent getElementGetter(final CallSiteDescriptor callSiteDescriptor,
final LinkerServices linkerServices, final List<String> operations) throws Exception {
final MethodType callSiteType = callSiteDescriptor.getMethodType();
@@ -178,27 +182,27 @@
// Note that for arrays and lists, using LinkerServices.asType() will ensure that any language specific linkers
// in use will get a chance to perform any (if there's any) implicit conversion to integer for the indices.
final GuardedInvocationComponent gic;
- final boolean isMap;
+ final CollectionType collectionType;
if(declaredType.isArray()) {
- gic = new GuardedInvocationComponent(MethodHandles.arrayElementGetter(declaredType));
- isMap = false;
+ gic = createInternalFilteredGuardedInvocationComponent(MethodHandles.arrayElementGetter(declaredType), linkerServices);
+ collectionType = CollectionType.ARRAY;
} else if(List.class.isAssignableFrom(declaredType)) {
- gic = new GuardedInvocationComponent(GET_LIST_ELEMENT);
- isMap = false;
+ gic = createInternalFilteredGuardedInvocationComponent(GET_LIST_ELEMENT, linkerServices);
+ collectionType = CollectionType.LIST;
} else if(Map.class.isAssignableFrom(declaredType)) {
- gic = new GuardedInvocationComponent(GET_MAP_ELEMENT);
- isMap = true;
+ gic = createInternalFilteredGuardedInvocationComponent(GET_MAP_ELEMENT, linkerServices);
+ collectionType = CollectionType.MAP;
} else if(clazz.isArray()) {
- gic = getClassGuardedInvocationComponent(MethodHandles.arrayElementGetter(clazz), callSiteType);
- isMap = false;
+ gic = getClassGuardedInvocationComponent(linkerServices.filterInternalObjects(MethodHandles.arrayElementGetter(clazz)), callSiteType);
+ collectionType = CollectionType.ARRAY;
} else if(List.class.isAssignableFrom(clazz)) {
- gic = new GuardedInvocationComponent(GET_LIST_ELEMENT, Guards.asType(LIST_GUARD, callSiteType), List.class,
- ValidationType.INSTANCE_OF);
- isMap = false;
+ gic = createInternalFilteredGuardedInvocationComponent(GET_LIST_ELEMENT, Guards.asType(LIST_GUARD, callSiteType), List.class, ValidationType.INSTANCE_OF,
+ linkerServices);
+ collectionType = CollectionType.LIST;
} else if(Map.class.isAssignableFrom(clazz)) {
- gic = new GuardedInvocationComponent(GET_MAP_ELEMENT, Guards.asType(MAP_GUARD, callSiteType), Map.class,
- ValidationType.INSTANCE_OF);
- isMap = true;
+ gic = createInternalFilteredGuardedInvocationComponent(GET_MAP_ELEMENT, Guards.asType(MAP_GUARD, callSiteType), Map.class, ValidationType.INSTANCE_OF,
+ linkerServices);
+ collectionType = CollectionType.MAP;
} else {
// Can't retrieve elements for objects that are neither arrays, nor list, nor maps.
return nextComponent;
@@ -208,7 +212,7 @@
final String fixedKey = getFixedKey(callSiteDescriptor);
// Convert the key to a number if we're working with a list or array
final Object typedFixedKey;
- if(!isMap && fixedKey != null) {
+ if(collectionType != CollectionType.MAP && fixedKey != null) {
typedFixedKey = convertKeyToInteger(fixedKey, linkerServices);
if(typedFixedKey == null) {
// key is not numeric, it can never succeed
@@ -227,15 +231,21 @@
}
final MethodHandle checkGuard;
- if(invocation == GET_LIST_ELEMENT) {
+ switch(collectionType) {
+ case LIST:
checkGuard = convertArgToInt(RANGE_CHECK_LIST, linkerServices, callSiteDescriptor);
- } else if(invocation == GET_MAP_ELEMENT) {
+ break;
+ case MAP:
// TODO: A more complex solution could be devised for maps, one where we do a get() first, and fold it
// into a GWT that tests if it returned null, and if it did, do another GWT with containsKey()
// that returns constant null (on true), or falls back to next component (on false)
- checkGuard = CONTAINS_MAP;
- } else {
+ checkGuard = linkerServices.filterInternalObjects(CONTAINS_MAP);
+ break;
+ case ARRAY:
checkGuard = convertArgToInt(RANGE_CHECK_ARRAY, linkerServices, callSiteDescriptor);
+ break;
+ default:
+ throw new AssertionError();
}
final MethodPair matchedInvocations = matchReturnTypes(binder.bind(invocation),
nextComponent.getGuardedInvocation().getInvocation());
@@ -243,6 +253,18 @@
gic.getValidatorClass(), gic.getValidationType());
}
+ private static GuardedInvocationComponent createInternalFilteredGuardedInvocationComponent(
+ final MethodHandle invocation, final LinkerServices linkerServices) {
+ return new GuardedInvocationComponent(linkerServices.filterInternalObjects(invocation));
+ }
+
+ private static GuardedInvocationComponent createInternalFilteredGuardedInvocationComponent(
+ final MethodHandle invocation, final MethodHandle guard, final Class<?> validatorClass,
+ final ValidationType validationType, final LinkerServices linkerServices) {
+ return new GuardedInvocationComponent(linkerServices.filterInternalObjects(invocation), guard,
+ validatorClass, validationType);
+ }
+
private static String getFixedKey(final CallSiteDescriptor callSiteDescriptor) {
return callSiteDescriptor.getNameTokenCount() == 2 ? null : callSiteDescriptor.getNameToken(
CallSiteDescriptor.NAME_OPERAND);
@@ -381,37 +403,38 @@
// dealing with an array, or a list or map, but hey...
// Note that for arrays and lists, using LinkerServices.asType() will ensure that any language specific linkers
// in use will get a chance to perform any (if there's any) implicit conversion to integer for the indices.
- final boolean isMap;
+ final CollectionType collectionType;
if(declaredType.isArray()) {
- gic = new GuardedInvocationComponent(MethodHandles.arrayElementSetter(declaredType));
- isMap = false;
+ gic = createInternalFilteredGuardedInvocationComponent(MethodHandles.arrayElementSetter(declaredType), linkerServices);
+ collectionType = CollectionType.ARRAY;
} else if(List.class.isAssignableFrom(declaredType)) {
- gic = new GuardedInvocationComponent(SET_LIST_ELEMENT);
- isMap = false;
+ gic = createInternalFilteredGuardedInvocationComponent(SET_LIST_ELEMENT, linkerServices);
+ collectionType = CollectionType.LIST;
} else if(Map.class.isAssignableFrom(declaredType)) {
- gic = new GuardedInvocationComponent(PUT_MAP_ELEMENT);
- isMap = true;
+ gic = createInternalFilteredGuardedInvocationComponent(PUT_MAP_ELEMENT, linkerServices);
+ collectionType = CollectionType.MAP;
} else if(clazz.isArray()) {
- gic = getClassGuardedInvocationComponent(MethodHandles.arrayElementSetter(clazz), callSiteType);
- isMap = false;
+ gic = getClassGuardedInvocationComponent(linkerServices.filterInternalObjects(
+ MethodHandles.arrayElementSetter(clazz)), callSiteType);
+ collectionType = CollectionType.ARRAY;
} else if(List.class.isAssignableFrom(clazz)) {
- gic = new GuardedInvocationComponent(SET_LIST_ELEMENT, Guards.asType(LIST_GUARD, callSiteType), List.class,
- ValidationType.INSTANCE_OF);
- isMap = false;
+ gic = createInternalFilteredGuardedInvocationComponent(SET_LIST_ELEMENT, Guards.asType(LIST_GUARD, callSiteType), List.class, ValidationType.INSTANCE_OF,
+ linkerServices);
+ collectionType = CollectionType.LIST;
} else if(Map.class.isAssignableFrom(clazz)) {
- gic = new GuardedInvocationComponent(PUT_MAP_ELEMENT, Guards.asType(MAP_GUARD, callSiteType), Map.class,
- ValidationType.INSTANCE_OF);
- isMap = true;
+ gic = createInternalFilteredGuardedInvocationComponent(PUT_MAP_ELEMENT, Guards.asType(MAP_GUARD, callSiteType),
+ Map.class, ValidationType.INSTANCE_OF, linkerServices);
+ collectionType = CollectionType.MAP;
} else {
// Can't set elements for objects that are neither arrays, nor list, nor maps.
gic = null;
- isMap = false;
+ collectionType = null;
}
// In contrast to, say, getElementGetter, we only compute the nextComponent if the target object is not a map,
// as maps will always succeed in setting the element and will never need to fall back to the next component
// operation.
- final GuardedInvocationComponent nextComponent = isMap ? null : getGuardedInvocationComponent(
+ final GuardedInvocationComponent nextComponent = collectionType == CollectionType.MAP ? null : getGuardedInvocationComponent(
callSiteDescriptor, linkerServices, operations);
if(gic == null) {
return nextComponent;
@@ -421,7 +444,7 @@
final String fixedKey = getFixedKey(callSiteDescriptor);
// Convert the key to a number if we're working with a list or array
final Object typedFixedKey;
- if(!isMap && fixedKey != null) {
+ if(collectionType != CollectionType.MAP && fixedKey != null) {
typedFixedKey = convertKeyToInteger(fixedKey, linkerServices);
if(typedFixedKey == null) {
// key is not numeric, it can never succeed
@@ -439,7 +462,8 @@
return gic.replaceInvocation(binder.bind(invocation));
}
- final MethodHandle checkGuard = convertArgToInt(invocation == SET_LIST_ELEMENT ? RANGE_CHECK_LIST :
+ assert collectionType == CollectionType.LIST || collectionType == CollectionType.ARRAY;
+ final MethodHandle checkGuard = convertArgToInt(collectionType == CollectionType.LIST ? RANGE_CHECK_LIST :
RANGE_CHECK_ARRAY, linkerServices, callSiteDescriptor);
final MethodPair matchedInvocations = matchReturnTypes(binder.bind(invocation),
nextComponent.getGuardedInvocation().getInvocation());
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/OverloadedMethod.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/OverloadedMethod.java Wed Feb 18 19:27:49 2015 -0800
@@ -139,7 +139,8 @@
final MethodHandle bound = SELECT_METHOD.bindTo(this);
final MethodHandle collecting = SingleDynamicMethod.collectArguments(bound, argNum).asType(
callSiteType.changeReturnType(MethodHandle.class));
- invoker = MethodHandles.foldArguments(MethodHandles.exactInvoker(this.callSiteType), collecting);
+ invoker = linkerServices.asTypeLosslessReturn(MethodHandles.foldArguments(
+ MethodHandles.exactInvoker(this.callSiteType), collecting), callSiteType);
}
MethodHandle getInvoker() {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/SingleDynamicMethod.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/SingleDynamicMethod.java Wed Feb 18 19:27:49 2015 -0800
@@ -165,10 +165,11 @@
* @return the adapted method handle.
*/
static MethodHandle getInvocation(final MethodHandle target, final MethodType callSiteType, final LinkerServices linkerServices) {
- final MethodType methodType = target.type();
+ final MethodHandle filteredTarget = linkerServices.filterInternalObjects(target);
+ final MethodType methodType = filteredTarget.type();
final int paramsLen = methodType.parameterCount();
final boolean varArgs = target.isVarargsCollector();
- final MethodHandle fixTarget = varArgs ? target.asFixedArity() : target;
+ final MethodHandle fixTarget = varArgs ? filteredTarget.asFixedArity() : filteredTarget;
final int fixParamsLen = varArgs ? paramsLen - 1 : paramsLen;
final int argsLen = callSiteType.parameterCount();
if(argsLen < fixParamsLen) {
@@ -204,7 +205,7 @@
if(varArgType.isAssignableFrom(callSiteLastArgType)) {
// Call site signature guarantees we'll always be passed a single compatible array; just link directly
// to the method, introducing necessary conversions. Also, preserve it being a variable arity method.
- return createConvertingInvocation(target, linkerServices, callSiteType).asVarargsCollector(
+ return createConvertingInvocation(filteredTarget, linkerServices, callSiteType).asVarargsCollector(
callSiteLastArgType);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/StaticClass.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/beans/StaticClass.java Wed Feb 18 19:27:49 2015 -0800
@@ -84,6 +84,7 @@
package jdk.internal.dynalink.beans;
import java.io.Serializable;
+import java.util.Objects;
/**
* Object that represents the static facet of a class (its static methods, properties, and fields, as well as
@@ -106,8 +107,7 @@
private final Class<?> clazz;
/*private*/ StaticClass(final Class<?> clazz) {
- clazz.getClass(); // NPE check
- this.clazz = clazz;
+ this.clazz = Objects.requireNonNull(clazz);
}
/**
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/GuardedInvocation.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/GuardedInvocation.java Wed Feb 18 19:27:49 2015 -0800
@@ -91,6 +91,7 @@
import java.lang.invoke.SwitchPoint;
import java.lang.invoke.WrongMethodTypeException;
import java.util.List;
+import java.util.Objects;
import jdk.internal.dynalink.CallSiteDescriptor;
import jdk.internal.dynalink.support.Guards;
@@ -170,8 +171,7 @@
* @throws NullPointerException if invocation is null.
*/
public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint switchPoint, final Class<? extends Throwable> exception) {
- invocation.getClass(); // NPE check
- this.invocation = invocation;
+ this.invocation = Objects.requireNonNull(invocation);
this.guard = guard;
this.switchPoints = switchPoint == null ? null : new SwitchPoint[] { switchPoint };
this.exception = exception;
@@ -190,8 +190,7 @@
* @throws NullPointerException if invocation is null.
*/
public GuardedInvocation(final MethodHandle invocation, final MethodHandle guard, final SwitchPoint[] switchPoints, final Class<? extends Throwable> exception) {
- invocation.getClass(); // NPE check
- this.invocation = invocation;
+ this.invocation = Objects.requireNonNull(invocation);
this.guard = guard;
this.switchPoints = switchPoints == null ? null : switchPoints.clone();
this.exception = exception;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/LinkerServices.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/LinkerServices.java Wed Feb 18 19:27:49 2015 -0800
@@ -181,6 +181,15 @@
public Comparison compareConversion(Class<?> sourceType, Class<?> targetType1, Class<?> targetType2);
/**
+ * Modifies the method handle so that any parameters that can receive potentially internal language runtime objects
+ * will have a filter added on them to prevent them from escaping, potentially by wrapping them.
+ * It can also potentially add an unwrapping filter to the return value.
+ * @param target the target method handle
+ * @return a method handle with parameters and/or return type potentially filtered for wrapping and unwrapping.
+ */
+ public MethodHandle filterInternalObjects(final MethodHandle target);
+
+ /**
* If we could just use Java 8 constructs, then {@code asTypeSafeReturn} would be a method with default
* implementation. Since we can't do that, we extract common default implementations into this static class.
*/
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/linker/MethodHandleTransformer.java Wed Feb 18 19:27:49 2015 -0800
@@ -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. 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 file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file, and Oracle licenses the original version of this file under the BSD
+ * license:
+ */
+/*
+ Copyright 2009-2015 Attila Szegedi
+
+ Licensed under both the Apache License, Version 2.0 (the "Apache License")
+ and the BSD License (the "BSD License"), with licensee being free to
+ choose either of the two at their discretion.
+
+ You may not use this file except in compliance with either the Apache
+ License or the BSD License.
+
+ If you choose to use this file in compliance with the Apache License, the
+ following notice applies to you:
+
+ You may obtain a copy of the Apache 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.
+
+ If you choose to use this file in compliance with the BSD License, the
+ following notice applies to you:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package jdk.internal.dynalink.linker;
+
+import java.lang.invoke.MethodHandle;
+
+/**
+ * A generic interface describing operations that transform method handles.
+ */
+public interface MethodHandleTransformer {
+ /**
+ * Transforms a method handle.
+ * @param target the method handle being transformed.
+ * @return transformed method handle.
+ */
+ public MethodHandle transform(final MethodHandle target);
+}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/CallSiteDescriptorFactory.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/CallSiteDescriptorFactory.java Wed Feb 18 19:27:49 2015 -0800
@@ -91,6 +91,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.StringTokenizer;
import java.util.WeakHashMap;
import jdk.internal.dynalink.CallSiteDescriptor;
@@ -123,9 +124,9 @@
* in fact return a weakly-referenced canonical instance.
*/
public static CallSiteDescriptor create(final Lookup lookup, final String name, final MethodType methodType) {
- name.getClass(); // NPE check
- methodType.getClass(); // NPE check
- lookup.getClass(); // NPE check
+ Objects.requireNonNull(name);
+ Objects.requireNonNull(methodType);
+ Objects.requireNonNull(lookup);
final String[] tokenizedName = tokenizeName(name);
if(isPublicLookup(lookup)) {
return getCanonicalPublicDescriptor(createPublicCallSiteDescriptor(tokenizedName, methodType));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/DefaultInternalObjectFilter.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,177 @@
+/*
+ * 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 file is available under and governed by the GNU General Public
+ * License version 2 only, as published by the Free Software Foundation.
+ * However, the following notice accompanied the original version of this
+ * file, and Oracle licenses the original version of this file under the BSD
+ * license:
+ */
+/*
+ Copyright 2009-2015 Attila Szegedi
+
+ Licensed under both the Apache License, Version 2.0 (the "Apache License")
+ and the BSD License (the "BSD License"), with licensee being free to
+ choose either of the two at their discretion.
+
+ You may not use this file except in compliance with either the Apache
+ License or the BSD License.
+
+ If you choose to use this file in compliance with the Apache License, the
+ following notice applies to you:
+
+ You may obtain a copy of the Apache 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.
+
+ If you choose to use this file in compliance with the BSD License, the
+ following notice applies to you:
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are
+ met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of the copyright holder nor the names of
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER
+ BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+
+package jdk.internal.dynalink.support;
+
+import java.lang.invoke.MethodHandle;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.MethodType;
+import jdk.internal.dynalink.DynamicLinkerFactory;
+import jdk.internal.dynalink.linker.MethodHandleTransformer;
+
+/**
+ * Default implementation for a {@link DynamicLinkerFactory#setInternalObjectsFilter(MethodHandleTransformer)}.
+ * Given a method handle of {@code Object(Object)} type for filtering parameter and another one of the same type for
+ * filtering return values, applies them to passed method handles where their parameter types and/or return value types
+ * are declared to be {@link Object}.
+ */
+public class DefaultInternalObjectFilter implements MethodHandleTransformer {
+ private static final MethodHandle FILTER_VARARGS = new Lookup(MethodHandles.lookup()).findStatic(
+ DefaultInternalObjectFilter.class, "filterVarArgs", MethodType.methodType(Object[].class, MethodHandle.class, Object[].class));
+
+ private final MethodHandle parameterFilter;
+ private final MethodHandle returnFilter;
+ private final MethodHandle varArgFilter;
+
+ /**
+ * Creates a new filter.
+ * @param parameterFilter the filter for method parameters. Must be of type {@code Object(Object)}, or null.
+ * @param returnFilter the filter for return values. Must be of type {@code Object(Object)}, or null.
+ * @throws IllegalArgumentException if one or both filters are not of the expected type.
+ */
+ public DefaultInternalObjectFilter(final MethodHandle parameterFilter, final MethodHandle returnFilter) {
+ this.parameterFilter = checkHandle(parameterFilter, "parameterFilter");
+ this.returnFilter = checkHandle(returnFilter, "returnFilter");
+ this.varArgFilter = parameterFilter == null ? null : FILTER_VARARGS.bindTo(parameterFilter);
+ }
+
+ @Override
+ public MethodHandle transform(final MethodHandle target) {
+ assert target != null;
+ MethodHandle[] filters = null;
+ final MethodType type = target.type();
+ final boolean isVarArg = target.isVarargsCollector();
+ final int paramCount = type.parameterCount();
+ final MethodHandle paramsFiltered;
+ // Filter parameters
+ if (parameterFilter != null) {
+ int firstFilter = -1;
+ // Ignore receiver, start from argument 1
+ for(int i = 1; i < paramCount; ++i) {
+ final Class<?> paramType = type.parameterType(i);
+ final boolean filterVarArg = isVarArg && i == paramCount - 1 && paramType == Object[].class;
+ if (filterVarArg || paramType == Object.class) {
+ if (filters == null) {
+ firstFilter = i;
+ filters = new MethodHandle[paramCount - firstFilter];
+ }
+ filters[i - firstFilter] = filterVarArg ? varArgFilter : parameterFilter;
+ }
+ }
+ paramsFiltered = filters != null ? MethodHandles.filterArguments(target, firstFilter, filters) : target;
+ } else {
+ paramsFiltered = target;
+ }
+ // Filter return value if needed
+ final MethodHandle returnFiltered = returnFilter != null && type.returnType() == Object.class ? MethodHandles.filterReturnValue(paramsFiltered, returnFilter) : paramsFiltered;
+ // Preserve varargs collector state
+ return isVarArg && !returnFiltered.isVarargsCollector() ? returnFiltered.asVarargsCollector(type.parameterType(paramCount - 1)) : returnFiltered;
+
+ }
+
+ private static MethodHandle checkHandle(final MethodHandle handle, final String handleKind) {
+ if (handle != null) {
+ final MethodType objectObjectType = MethodType.methodType(Object.class, Object.class);
+ if (!handle.type().equals(objectObjectType)) {
+ throw new IllegalArgumentException("Method type for " + handleKind + " must be " + objectObjectType);
+ }
+ }
+ return handle;
+ }
+
+ @SuppressWarnings("unused")
+ private static Object[] filterVarArgs(final MethodHandle parameterFilter, final Object[] args) throws Throwable {
+ Object[] newArgs = null;
+ for(int i = 0; i < args.length; ++i) {
+ final Object arg = args[i];
+ final Object newArg = parameterFilter.invokeExact(arg);
+ if (arg != newArg) {
+ if (newArgs == null) {
+ newArgs = args.clone();
+ }
+ newArgs[i] = newArg;
+ }
+ }
+ return newArgs == null ? args : newArgs;
+ }
+}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/LinkerServicesImpl.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/internal/dynalink/support/LinkerServicesImpl.java Wed Feb 18 19:27:49 2015 -0800
@@ -90,6 +90,7 @@
import jdk.internal.dynalink.linker.GuardingDynamicLinker;
import jdk.internal.dynalink.linker.LinkRequest;
import jdk.internal.dynalink.linker.LinkerServices;
+import jdk.internal.dynalink.linker.MethodHandleTransformer;
/**
* Default implementation of the {@link LinkerServices} interface.
@@ -103,17 +104,21 @@
private final TypeConverterFactory typeConverterFactory;
private final GuardingDynamicLinker topLevelLinker;
+ private final MethodHandleTransformer internalObjectsFilter;
/**
* Creates a new linker services object.
*
* @param typeConverterFactory the type converter factory exposed by the services.
* @param topLevelLinker the top level linker used by the services.
+ * @param internalObjectsFilter a method handle transformer that is supposed to act as the implementation of this
+ * services' {@link #filterInternalObjects(java.lang.invoke.MethodHandle)} method.
*/
public LinkerServicesImpl(final TypeConverterFactory typeConverterFactory,
- final GuardingDynamicLinker topLevelLinker) {
+ final GuardingDynamicLinker topLevelLinker, final MethodHandleTransformer internalObjectsFilter) {
this.typeConverterFactory = typeConverterFactory;
this.topLevelLinker = topLevelLinker;
+ this.internalObjectsFilter = internalObjectsFilter;
}
@Override
@@ -152,6 +157,11 @@
}
}
+ @Override
+ public MethodHandle filterInternalObjects(final MethodHandle target) {
+ return internalObjectsFilter != null ? internalObjectsFilter.transform(target) : target;
+ }
+
/**
* Returns the currently processed link request, or null if the method is invoked outside of the linking process.
* @return the currently processed link request, or null.
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornScriptEngine.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornScriptEngine.java Wed Feb 18 19:27:49 2015 -0800
@@ -39,6 +39,7 @@
import java.security.ProtectionDomain;
import java.text.MessageFormat;
import java.util.Locale;
+import java.util.Objects;
import java.util.ResourceBundle;
import javax.script.AbstractScriptEngine;
import javax.script.Bindings;
@@ -360,7 +361,7 @@
}
private Object invokeImpl(final Object selfObject, final String name, final Object... args) throws ScriptException, NoSuchMethodException {
- name.getClass(); // null check
+ Objects.requireNonNull(name);
assert !(selfObject instanceof ScriptObject) : "raw ScriptObject not expected here";
Global invokeGlobal = null;
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/NashornScriptEngineFactory.java Wed Feb 18 19:27:49 2015 -0800
@@ -28,6 +28,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineFactory;
import jdk.nashorn.internal.runtime.Context;
@@ -177,7 +178,7 @@
* denies {@code RuntimePermission("nashorn.setConfig")}
*/
public ScriptEngine getScriptEngine(final ClassFilter classFilter) {
- classFilter.getClass(); // null check
+ Objects.requireNonNull(classFilter);
return newEngine(DEFAULT_OPTIONS, getAppClassLoader(), classFilter);
}
@@ -192,7 +193,7 @@
* denies {@code RuntimePermission("nashorn.setConfig")}
*/
public ScriptEngine getScriptEngine(final String... args) {
- args.getClass(); // null check
+ Objects.requireNonNull(args);
return newEngine(args, getAppClassLoader(), null);
}
@@ -208,7 +209,7 @@
* denies {@code RuntimePermission("nashorn.setConfig")}
*/
public ScriptEngine getScriptEngine(final String[] args, final ClassLoader appLoader) {
- args.getClass(); // null check
+ Objects.requireNonNull(args);
return newEngine(args, appLoader, null);
}
@@ -225,8 +226,8 @@
* denies {@code RuntimePermission("nashorn.setConfig")}
*/
public ScriptEngine getScriptEngine(final String[] args, final ClassLoader appLoader, final ClassFilter classFilter) {
- args.getClass(); // null check
- classFilter.getClass(); // null check
+ Objects.requireNonNull(args);
+ Objects.requireNonNull(classFilter);
return newEngine(args, appLoader, classFilter);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/ScriptObjectMirror.java Wed Feb 18 19:27:49 2015 -0800
@@ -39,6 +39,7 @@
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Callable;
import javax.script.Bindings;
@@ -180,7 +181,7 @@
* @return return value of function
*/
public Object callMember(final String functionName, final Object... args) {
- functionName.getClass(); // null check
+ Objects.requireNonNull(functionName);
final Global oldGlobal = Context.getGlobal();
final boolean globalChanged = (oldGlobal != global);
@@ -213,7 +214,7 @@
@Override
public Object getMember(final String name) {
- name.getClass();
+ Objects.requireNonNull(name);
return inGlobal(new Callable<Object>() {
@Override public Object call() {
return wrap(sobj.get(name), global);
@@ -232,7 +233,7 @@
@Override
public boolean hasMember(final String name) {
- name.getClass();
+ Objects.requireNonNull(name);
return inGlobal(new Callable<Boolean>() {
@Override public Boolean call() {
return sobj.has(name);
@@ -251,13 +252,13 @@
@Override
public void removeMember(final String name) {
- name.getClass();
+ Objects.requireNonNull(name);
remove(name);
}
@Override
public void setMember(final String name, final Object value) {
- name.getClass();
+ Objects.requireNonNull(name);
put(name, value);
}
@@ -425,9 +426,7 @@
@Override
public void putAll(final Map<? extends String, ? extends Object> map) {
- if (map == null) {
- throw new NullPointerException("map is null");
- }
+ Objects.requireNonNull(map, "map is null");
final ScriptObject oldGlobal = Context.getGlobal();
final boolean globalChanged = (oldGlobal != global);
inGlobal(new Callable<Object>() {
@@ -449,7 +448,7 @@
checkKey(key);
return inGlobal(new Callable<Object>() {
@Override public Object call() {
- return wrap(sobj.remove(key, strict), global);
+ return translateUndefined(wrap(sobj.remove(key, strict), global));
}
});
}
@@ -804,9 +803,9 @@
* @throws IllegalArgumentException if key is empty string
*/
private static void checkKey(final Object key) {
- if (key == null) {
- throw new NullPointerException("key can not be null");
- } else if (!(key instanceof String)) {
+ Objects.requireNonNull(key, "key can not be null");
+
+ if (!(key instanceof String)) {
throw new ClassCastException("key should be a String. It is " + key.getClass().getName() + " instead.");
} else if (((String)key).length() == 0) {
throw new IllegalArgumentException("key can not be empty");
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/URLReader.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/api/scripting/URLReader.java Wed Feb 18 19:27:49 2015 -0800
@@ -30,6 +30,7 @@
import java.io.Reader;
import java.net.URL;
import java.nio.charset.Charset;
+import java.util.Objects;
import jdk.nashorn.internal.runtime.Source;
/**
@@ -77,8 +78,7 @@
* @throws NullPointerException if url is null
*/
public URLReader(final URL url, final Charset cs) {
- // null check
- url.getClass();
+ Objects.requireNonNull(url);
this.url = url;
this.cs = cs;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CompileUnit.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/CompileUnit.java Wed Feb 18 19:27:49 2015 -0800
@@ -26,6 +26,7 @@
package jdk.nashorn.internal.codegen;
import java.io.Serializable;
+import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import jdk.nashorn.internal.ir.CompileUnitHolder;
@@ -113,7 +114,7 @@
* @param clazz class with code for this compile unit
*/
void setCode(final Class<?> clazz) {
- clazz.getClass(); // null check
+ Objects.requireNonNull(clazz);
this.clazz = clazz;
// Revisit this - refactor to avoid null-ed out non-final fields
// null out emitter
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/Lower.java Wed Feb 18 19:27:49 2015 -0800
@@ -326,6 +326,7 @@
return addStatement(throwNode); //ThrowNodes are always terminal, marked as such in constructor
}
+ @SuppressWarnings("unchecked")
private static <T extends Node> T ensureUniqueNamesIn(final T node) {
return (T)node.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) {
@Override
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/ir/debug/ObjectSizeCalculator.java Wed Feb 18 19:27:49 2015 -0800
@@ -38,6 +38,7 @@
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
/**
* Contains utility methods for calculating the memory usage of objects. It
@@ -150,7 +151,7 @@
* @param memoryLayoutSpecification a description of the JVM memory layout.
*/
public ObjectSizeCalculator(final MemoryLayoutSpecification memoryLayoutSpecification) {
- memoryLayoutSpecification.getClass();
+ Objects.requireNonNull(memoryLayoutSpecification);
arrayHeaderSize = memoryLayoutSpecification.getArrayHeaderSize();
objectHeaderSize = memoryLayoutSpecification.getObjectHeaderSize();
objectPadding = memoryLayoutSpecification.getObjectPadding();
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/Global.java Wed Feb 18 19:27:49 2015 -0800
@@ -41,6 +41,7 @@
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;
import javax.script.ScriptContext;
@@ -463,8 +464,7 @@
sm.checkPermission(new RuntimePermission(Context.NASHORN_CREATE_GLOBAL));
}
- // null check on context
- context.getClass();
+ Objects.requireNonNull(context);
return $nasgenmap$;
}
@@ -488,7 +488,7 @@
*/
public static Global instance() {
final Global global = Context.getGlobal();
- global.getClass(); // null check
+ Objects.requireNonNull(global);
return global;
}
@@ -580,13 +580,15 @@
} else if (obj instanceof String || obj instanceof ConsString) {
return new NativeString((CharSequence)obj, this);
} else if (obj instanceof Object[]) { // extension
- return new NativeArray((Object[])obj);
+ return new NativeArray(ArrayData.allocate((Object[])obj), this);
} else if (obj instanceof double[]) { // extension
- return new NativeArray((double[])obj);
+ return new NativeArray(ArrayData.allocate((double[])obj), this);
} else if (obj instanceof long[]) {
- return new NativeArray((long[])obj);
+ return new NativeArray(ArrayData.allocate((long[])obj), this);
} else if (obj instanceof int[]) {
- return new NativeArray((int[])obj);
+ return new NativeArray(ArrayData.allocate((int[]) obj), this);
+ } else if (obj instanceof ArrayData) {
+ return new NativeArray((ArrayData) obj, this);
} else {
// FIXME: more special cases? Map? List?
return obj;
@@ -1028,14 +1030,19 @@
}
// builtin prototype accessors
+
+ /**
+ * Get the builtin Object prototype.
+ * @return the object prototype.
+ */
+ public ScriptObject getObjectPrototype() {
+ return ScriptFunction.getPrototype(builtinObject);
+ }
+
ScriptObject getFunctionPrototype() {
return ScriptFunction.getPrototype(builtinFunction);
}
- ScriptObject getObjectPrototype() {
- return ScriptFunction.getPrototype(builtinObject);
- }
-
ScriptObject getArrayPrototype() {
return ScriptFunction.getPrototype(builtinArray);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeArray.java Wed Feb 18 19:27:49 2015 -0800
@@ -120,9 +120,6 @@
this(ArrayData.allocate(array.length));
ArrayData arrayData = this.getArray();
- if (array.length > 0) {
- arrayData.ensure(array.length - 1);
- }
for (int index = 0; index < array.length; index++) {
final Object value = array[index];
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/JSONParser.java Wed Feb 18 19:27:49 2015 -0800
@@ -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,38 +25,59 @@
package jdk.nashorn.internal.parser;
-import static jdk.nashorn.internal.parser.TokenType.COLON;
-import static jdk.nashorn.internal.parser.TokenType.COMMARIGHT;
-import static jdk.nashorn.internal.parser.TokenType.EOF;
-import static jdk.nashorn.internal.parser.TokenType.ESCSTRING;
-import static jdk.nashorn.internal.parser.TokenType.RBRACE;
-import static jdk.nashorn.internal.parser.TokenType.RBRACKET;
-import static jdk.nashorn.internal.parser.TokenType.STRING;
import java.util.ArrayList;
import java.util.List;
-import jdk.nashorn.internal.ir.Expression;
-import jdk.nashorn.internal.ir.LiteralNode;
-import jdk.nashorn.internal.ir.Node;
-import jdk.nashorn.internal.ir.ObjectNode;
-import jdk.nashorn.internal.ir.PropertyNode;
-import jdk.nashorn.internal.ir.UnaryNode;
+import jdk.nashorn.internal.codegen.ObjectClassGenerator;
+import jdk.nashorn.internal.objects.Global;
+import jdk.nashorn.internal.runtime.ECMAErrors;
import jdk.nashorn.internal.runtime.ErrorManager;
+import jdk.nashorn.internal.runtime.JSErrorType;
+import jdk.nashorn.internal.runtime.JSType;
+import jdk.nashorn.internal.runtime.ParserException;
+import jdk.nashorn.internal.runtime.Property;
+import jdk.nashorn.internal.runtime.PropertyMap;
+import jdk.nashorn.internal.runtime.ScriptObject;
import jdk.nashorn.internal.runtime.Source;
+import jdk.nashorn.internal.runtime.SpillProperty;
+import jdk.nashorn.internal.runtime.arrays.ArrayData;
+import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
+import jdk.nashorn.internal.scripts.JO;
+
+import static jdk.nashorn.internal.parser.TokenType.STRING;
/**
* Parses JSON text and returns the corresponding IR node. This is derived from the objectLiteral production of the main parser.
*
* See: 15.12.1.2 The JSON Syntactic Grammar
*/
-public class JSONParser extends AbstractParser {
+public class JSONParser {
+
+ final private String source;
+ final private Global global;
+ final int length;
+ int pos = 0;
+
+ private static PropertyMap EMPTY_MAP = PropertyMap.newMap();
+
+ private static final int EOF = -1;
+
+ private static final String TRUE = "true";
+ private static final String FALSE = "false";
+ private static final String NULL = "null";
+
+ private static final int STATE_EMPTY = 0;
+ private static final int STATE_ELEMENT_PARSED = 1;
+ private static final int STATE_COMMA_PARSED = 2;
/**
* Constructor
* @param source the source
- * @param errors the error manager
+ * @param global the global object
*/
- public JSONParser(final Source source, final ErrorManager errors) {
- super(source, errors, false, 0);
+ public JSONParser(final String source, final Global global ) {
+ this.source = source;
+ this.global = global;
+ this.length = source.length();
}
/**
@@ -114,329 +135,409 @@
}
/**
- * Public parsed method - start lexing a new token stream for
- * a JSON script
+ * Public parse method. Parse a string into a JSON object.
*
- * @return the JSON literal
+ * @return the parsed JSON Object
*/
- public Node parse() {
- stream = new TokenStream();
-
- lexer = new Lexer(source, stream) {
-
- @Override
- protected boolean skipComments() {
- return false;
- }
-
- @Override
- protected boolean isStringDelimiter(final char ch) {
- return ch == '\"';
- }
-
- // ECMA 15.12.1.1 The JSON Lexical Grammar - JSONWhiteSpace
- @Override
- protected boolean isWhitespace(final char ch) {
- return Lexer.isJsonWhitespace(ch);
- }
-
- @Override
- protected boolean isEOL(final char ch) {
- return Lexer.isJsonEOL(ch);
- }
+ public Object parse() {
+ final Object value = parseLiteral();
+ skipWhiteSpace();
+ if (pos < length) {
+ throw expectedError(pos, "eof", toString(peek()));
+ }
+ return value;
+ }
- // ECMA 15.12.1.1 The JSON Lexical Grammar - JSONNumber
- @Override
- protected void scanNumber() {
- // Record beginning of number.
- final int startPosition = position;
- // Assume value is a decimal.
- TokenType valueType = TokenType.DECIMAL;
-
- // floating point can't start with a "." with no leading digit before
- if (ch0 == '.') {
- error(Lexer.message("json.invalid.number"), STRING, position, limit);
- }
-
- // First digit of number.
- final int digit = convertDigit(ch0, 10);
-
- // skip first digit
- skip(1);
-
- if (digit != 0) {
- // Skip over remaining digits.
- while (convertDigit(ch0, 10) != -1) {
- skip(1);
- }
- }
-
- if (ch0 == '.' || ch0 == 'E' || ch0 == 'e') {
- // Must be a double.
- if (ch0 == '.') {
- // Skip period.
- skip(1);
+ private Object parseLiteral() {
+ skipWhiteSpace();
- boolean mantissa = false;
- // Skip mantissa.
- while (convertDigit(ch0, 10) != -1) {
- mantissa = true;
- skip(1);
- }
-
- if (! mantissa) {
- // no digit after "."
- error(Lexer.message("json.invalid.number"), STRING, position, limit);
- }
- }
-
- // Detect exponent.
- if (ch0 == 'E' || ch0 == 'e') {
- // Skip E.
- skip(1);
- // Detect and skip exponent sign.
- if (ch0 == '+' || ch0 == '-') {
- skip(1);
- }
- boolean exponent = false;
- // Skip exponent.
- while (convertDigit(ch0, 10) != -1) {
- exponent = true;
- skip(1);
- }
-
- if (! exponent) {
- // no digit after "E"
- error(Lexer.message("json.invalid.number"), STRING, position, limit);
- }
- }
-
- valueType = TokenType.FLOATING;
- }
-
- // Add number token.
- add(valueType, startPosition);
+ final int c = peek();
+ if (c == EOF) {
+ throw expectedError(pos, "json literal", "eof");
+ }
+ switch (c) {
+ case '{':
+ return parseObject();
+ case '[':
+ return parseArray();
+ case '"':
+ return parseString();
+ case 'f':
+ return parseKeyword(FALSE, Boolean.FALSE);
+ case 't':
+ return parseKeyword(TRUE, Boolean.TRUE);
+ case 'n':
+ return parseKeyword(NULL, null);
+ default:
+ if (isDigit(c) || c == '-') {
+ return parseNumber();
+ } else if (c == '.') {
+ throw numberError(pos);
+ } else {
+ throw expectedError(pos, "json literal", toString(c));
}
-
- // ECMA 15.12.1.1 The JSON Lexical Grammar - JSONEscapeCharacter
- @Override
- protected boolean isEscapeCharacter(final char ch) {
- switch (ch) {
- case '"':
- case '/':
- case '\\':
- case 'b':
- case 'f':
- case 'n':
- case 'r':
- case 't':
- // could be unicode escape
- case 'u':
- return true;
- default:
- return false;
- }
- }
- };
-
- k = -1;
-
- next();
-
- final Node resultNode = jsonLiteral();
- expect(EOF);
-
- return resultNode;
+ }
}
- @SuppressWarnings("fallthrough")
- private LiteralNode<?> getStringLiteral() {
- final LiteralNode<?> literal = getLiteral();
- final String str = (String)literal.getValue();
+ private Object parseObject() {
+ PropertyMap propertyMap = EMPTY_MAP;
+ ArrayData arrayData = ArrayData.EMPTY_ARRAY;
+ final ArrayList<Object> values = new ArrayList<>();
+ int state = STATE_EMPTY;
+
+ assert peek() == '{';
+ pos++;
+
+ while (pos < length) {
+ skipWhiteSpace();
+ final int c = peek();
- for (int i = 0; i < str.length(); i++) {
- final char ch = str.charAt(i);
- switch (ch) {
+ switch (c) {
+ case '"':
+ if (state == STATE_ELEMENT_PARSED) {
+ throw expectedError(pos - 1, ", or }", toString(c));
+ }
+ final String id = parseString();
+ expectColon();
+ final Object value = parseLiteral();
+ final int index = ArrayIndex.getArrayIndex(id);
+ if (ArrayIndex.isValidArrayIndex(index)) {
+ arrayData = addArrayElement(arrayData, index, value);
+ } else {
+ propertyMap = addObjectProperty(propertyMap, values, id, value);
+ }
+ state = STATE_ELEMENT_PARSED;
+ break;
+ case ',':
+ if (state != STATE_ELEMENT_PARSED) {
+ throw error(AbstractParser.message("trailing.comma.in.json"), pos);
+ }
+ state = STATE_COMMA_PARSED;
+ pos++;
+ break;
+ case '}':
+ if (state == STATE_COMMA_PARSED) {
+ throw error(AbstractParser.message("trailing.comma.in.json"), pos);
+ }
+ pos++;
+ return createObject(propertyMap, values, arrayData);
default:
- if (ch > 0x001f) {
- break;
- }
- case '"':
- case '\\':
- throw error(AbstractParser.message("unexpected.token", str));
+ throw expectedError(pos, ", or }", toString(c));
+ }
+ }
+ throw expectedError(pos, ", or }", "eof");
+ }
+
+ private static ArrayData addArrayElement(final ArrayData arrayData, final int index, final Object value) {
+ final long oldLength = arrayData.length();
+ final long longIndex = ArrayIndex.toLongIndex(index);
+ ArrayData newArrayData = arrayData;
+ if (longIndex >= oldLength) {
+ newArrayData = newArrayData.ensure(longIndex);
+ if (longIndex > oldLength) {
+ newArrayData = newArrayData.delete(oldLength, longIndex - 1);
+ }
+ }
+ return newArrayData.set(index, value, false);
+ }
+
+ private static PropertyMap addObjectProperty(final PropertyMap propertyMap, final List<Object> values,
+ final String id, final Object value) {
+ final Property oldProperty = propertyMap.findProperty(id);
+ final Property newProperty;
+ final PropertyMap newMap;
+ final Class<?> type = ObjectClassGenerator.OBJECT_FIELDS_ONLY ? Object.class : getType(value);
+
+ if (oldProperty != null) {
+ values.set(oldProperty.getSlot(), value);
+ newProperty = new SpillProperty(id, 0, oldProperty.getSlot());
+ newProperty.setType(type);
+ newMap = propertyMap.replaceProperty(oldProperty, newProperty);;
+ } else {
+ values.add(value);
+ newProperty = new SpillProperty(id, 0, propertyMap.size());
+ newProperty.setType(type);
+ newMap = propertyMap.addProperty(newProperty);
+ }
+
+ return newMap;
+ }
+
+ private Object createObject(final PropertyMap propertyMap, final List<Object> values, final ArrayData arrayData) {
+ final long[] primitiveSpill = new long[values.size()];
+ final Object[] objectSpill = new Object[values.size()];
+
+ for (final Property property : propertyMap.getProperties()) {
+ if (property.getType() == Object.class) {
+ objectSpill[property.getSlot()] = values.get(property.getSlot());
+ } else {
+ primitiveSpill[property.getSlot()] = ObjectClassGenerator.pack((Number) values.get(property.getSlot()));
}
}
- return literal;
+ final ScriptObject object = new JO(propertyMap, primitiveSpill, objectSpill);
+ object.setInitialProto(global.getObjectPrototype());
+ object.setArray(arrayData);
+ return object;
+ }
+
+ private static Class<?> getType(final Object value) {
+ if (value instanceof Integer) {
+ return int.class;
+ } else if (value instanceof Long) {
+ return long.class;
+ } else if (value instanceof Double) {
+ return double.class;
+ } else {
+ return Object.class;
+ }
+ }
+
+ private void expectColon() {
+ skipWhiteSpace();
+ final int n = next();
+ if (n != ':') {
+ throw expectedError(pos - 1, ":", toString(n));
+ }
}
- /**
- * Parse a JSON literal from the token stream
- * @return the JSON literal as a Node
- */
- private Expression jsonLiteral() {
- final long literalToken = token;
+ private Object parseArray() {
+ ArrayData arrayData = ArrayData.EMPTY_ARRAY;
+ int state = STATE_EMPTY;
- switch (type) {
- case STRING:
- return getStringLiteral();
- case ESCSTRING:
- case DECIMAL:
- case FLOATING:
- return getLiteral();
- case FALSE:
- next();
- return LiteralNode.newInstance(literalToken, finish, false);
- case TRUE:
- next();
- return LiteralNode.newInstance(literalToken, finish, true);
- case NULL:
- next();
- return LiteralNode.newInstance(literalToken, finish);
- case LBRACKET:
- return arrayLiteral();
- case LBRACE:
- return objectLiteral();
- /*
- * A.8.1 JSON Lexical Grammar
- *
- * JSONNumber :: See 15.12.1.1
- * -opt DecimalIntegerLiteral JSONFractionopt ExponentPartopt
- */
- case SUB:
- next();
+ assert peek() == '[';
+ pos++;
- final long realToken = token;
- final Object value = getValue();
-
- if (value instanceof Number) {
- next();
- return new UnaryNode(literalToken, LiteralNode.newInstance(realToken, finish, (Number)value));
- }
+ while (pos < length) {
+ skipWhiteSpace();
+ final int c = peek();
- throw error(AbstractParser.message("expected", "number", type.getNameOrType()));
- default:
- break;
- }
-
- throw error(AbstractParser.message("expected", "json literal", type.getNameOrType()));
- }
-
- /**
- * Parse an array literal from the token stream
- * @return the array literal as a Node
- */
- private LiteralNode<Expression[]> arrayLiteral() {
- // Unlike JavaScript array literals, elison is not permitted in JSON.
-
- // Capture LBRACKET token.
- final long arrayToken = token;
- // LBRACKET tested in caller.
- next();
-
- LiteralNode<Expression[]> result = null;
- // Prepare to accummulating elements.
- final List<Expression> elements = new ArrayList<>();
-
-loop:
- while (true) {
- switch (type) {
- case RBRACKET:
- next();
- result = LiteralNode.newInstance(arrayToken, finish, elements);
- break loop;
-
- case COMMARIGHT:
- next();
- // check for trailing comma - not allowed in JSON
- if (type == RBRACKET) {
- throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
+ switch (c) {
+ case ',':
+ if (state != STATE_ELEMENT_PARSED) {
+ throw error(AbstractParser.message("trailing.comma.in.json"), pos);
}
+ state = STATE_COMMA_PARSED;
+ pos++;
break;
-
+ case ']':
+ if (state == STATE_COMMA_PARSED) {
+ throw error(AbstractParser.message("trailing.comma.in.json"), pos);
+ }
+ pos++;
+ return global.wrapAsObject(arrayData);
default:
- // Add expression element.
- elements.add(jsonLiteral());
- // Comma between array elements is mandatory in JSON.
- if (type != COMMARIGHT && type != RBRACKET) {
- throw error(AbstractParser.message("expected", ", or ]", type.getNameOrType()));
+ if (state == STATE_ELEMENT_PARSED) {
+ throw expectedError(pos, ", or ]", toString(c));
}
+ final long index = arrayData.length();
+ arrayData = arrayData.ensure(index).set((int) index, parseLiteral(), true);
+ state = STATE_ELEMENT_PARSED;
break;
}
}
- return result;
+ throw expectedError(pos, ", or ]", "eof");
}
- /**
- * Parse an object literal from the token stream
- * @return the object literal as a Node
- */
- private ObjectNode objectLiteral() {
- // Capture LBRACE token.
- final long objectToken = token;
- // LBRACE tested in caller.
- next();
+ private String parseString() {
+ // String buffer is only instantiated if string contains escape sequences.
+ int start = ++pos;
+ StringBuilder sb = null;
- // Prepare to accumulate elements.
- final List<PropertyNode> elements = new ArrayList<>();
+ while (pos < length) {
+ final int c = next();
+ if (c <= 0x1f) {
+ // Characters < 0x1f are not allowed in JSON strings.
+ throw syntaxError(pos, "String contains control character");
- // Create a block for the object literal.
-loop:
- while (true) {
- switch (type) {
- case RBRACE:
- next();
- break loop;
+ } else if (c == '\\') {
+ if (sb == null) {
+ sb = new StringBuilder(pos - start + 16);
+ }
+ sb.append(source, start, pos - 1);
+ sb.append(parseEscapeSequence());
+ start = pos;
- case COMMARIGHT:
- next();
- // check for trailing comma - not allowed in JSON
- if (type == RBRACE) {
- throw error(AbstractParser.message("trailing.comma.in.json", type.getNameOrType()));
+ } else if (c == '"') {
+ if (sb != null) {
+ sb.append(source, start, pos - 1);
+ return sb.toString();
}
- break;
-
- default:
- // Get and add the next property.
- final PropertyNode property = propertyAssignment();
- elements.add(property);
-
- // Comma between property assigments is mandatory in JSON.
- if (type != RBRACE && type != COMMARIGHT) {
- throw error(AbstractParser.message("expected", ", or }", type.getNameOrType()));
- }
- break;
+ return source.substring(start, pos - 1);
}
}
- // Construct new object literal.
- return new ObjectNode(objectToken, finish, elements);
+ throw error(Lexer.message("missing.close.quote"), pos, length);
+ }
+
+ private char parseEscapeSequence() {
+ final int c = next();
+ switch (c) {
+ case '"':
+ return '"';
+ case '\\':
+ return '\\';
+ case '/':
+ return '/';
+ case 'b':
+ return '\b';
+ case 'f':
+ return '\f';
+ case 'n':
+ return '\n';
+ case 'r':
+ return '\r';
+ case 't':
+ return '\t';
+ case 'u':
+ return parseUnicodeEscape();
+ default:
+ throw error(Lexer.message("invalid.escape.char"), pos - 1, length);
+ }
+ }
+
+ private char parseUnicodeEscape() {
+ return (char) (parseHexDigit() << 12 | parseHexDigit() << 8 | parseHexDigit() << 4 | parseHexDigit());
+ }
+
+ private int parseHexDigit() {
+ final int c = next();
+ if (c >= '0' && c <= '9') {
+ return c - '0';
+ } else if (c >= 'A' && c <= 'F') {
+ return c + 10 - 'A';
+ } else if (c >= 'a' && c <= 'f') {
+ return c + 10 - 'a';
+ }
+ throw error(Lexer.message("invalid.hex"), pos - 1, length);
+ }
+
+ private boolean isDigit(final int c) {
+ return c >= '0' && c <= '9';
+ }
+
+ private void skipDigits() {
+ while (pos < length) {
+ final int c = peek();
+ if (!isDigit(c)) {
+ break;
+ }
+ pos++;
+ }
}
- /**
- * Parse a property assignment from the token stream
- * @return the property assignment as a Node
- */
- private PropertyNode propertyAssignment() {
- // Capture firstToken.
- final long propertyToken = token;
- LiteralNode<?> name = null;
+ private Number parseNumber() {
+ final int start = pos;
+ int c = next();
+
+ if (c == '-') {
+ c = next();
+ }
+ if (!isDigit(c)) {
+ throw numberError(start);
+ }
+ // no more digits allowed after 0
+ if (c != '0') {
+ skipDigits();
+ }
- if (type == STRING) {
- name = getStringLiteral();
- } else if (type == ESCSTRING) {
- name = getLiteral();
+ // fraction
+ if (peek() == '.') {
+ pos++;
+ if (!isDigit(next())) {
+ throw numberError(pos - 1);
+ }
+ skipDigits();
+ }
+
+ // exponent
+ c = peek();
+ if (c == 'e' || c == 'E') {
+ pos++;
+ c = next();
+ if (c == '-' || c == '+') {
+ c = next();
+ }
+ if (!isDigit(c)) {
+ throw numberError(pos - 1);
+ }
+ skipDigits();
}
- if (name != null) {
- expect(COLON);
- final Expression value = jsonLiteral();
- return new PropertyNode(propertyToken, value.getFinish(), name, value, null, null);
+ final double d = Double.parseDouble(source.substring(start, pos));
+ if (JSType.isRepresentableAsInt(d)) {
+ return (int) d;
+ } else if (JSType.isRepresentableAsLong(d)) {
+ return (long) d;
+ }
+ return d;
+ }
+
+ private Object parseKeyword(final String keyword, final Object value) {
+ if (!source.regionMatches(pos, keyword, 0, keyword.length())) {
+ throw expectedError(pos, "json literal", "ident");
}
+ pos += keyword.length();
+ return value;
+ }
- // Raise an error.
- throw error(AbstractParser.message("expected", "string", type.getNameOrType()));
+ private int peek() {
+ if (pos >= length) {
+ return -1;
+ }
+ return source.charAt(pos);
+ }
+
+ private int next() {
+ final int next = peek();
+ pos++;
+ return next;
}
+ private void skipWhiteSpace() {
+ while (pos < length) {
+ switch (peek()) {
+ case '\t':
+ case '\r':
+ case '\n':
+ case ' ':
+ pos++;
+ break;
+ default:
+ return;
+ }
+ }
+ }
+
+ private static String toString(final int c) {
+ return c == EOF ? "eof" : String.valueOf((char) c);
+ }
+
+ ParserException error(final String message, final int start, final int length) throws ParserException {
+ final long token = Token.toDesc(STRING, start, length);
+ final int pos = Token.descPosition(token);
+ final Source src = Source.sourceFor("<json>", source);
+ final int lineNum = src.getLine(pos);
+ final int columnNum = src.getColumn(pos);
+ final String formatted = ErrorManager.format(message, src, lineNum, columnNum, token);
+ return new ParserException(JSErrorType.SYNTAX_ERROR, formatted, src, lineNum, columnNum, token);
+ }
+
+ private ParserException error(final String message, final int start) {
+ return error(message, start, length);
+ }
+
+ private ParserException numberError(final int start) {
+ return error(Lexer.message("json.invalid.number"), start);
+ }
+
+ private ParserException expectedError(final int start, final String expected, final String found) {
+ return error(AbstractParser.message("expected", expected, found), start);
+ }
+
+ private ParserException syntaxError(final int start, final String reason) {
+ final String message = ECMAErrors.getMessage("syntax.error.invalid.json", reason);
+ return error(message, start);
+ }
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Lexer.java Wed Feb 18 19:27:49 2015 -0800
@@ -93,9 +93,6 @@
private static final String SPACETAB = " \t"; // ASCII space and tab
private static final String LFCR = "\n\r"; // line feed and carriage return (ctrl-m)
- private static final String JSON_WHITESPACE_EOL = LFCR;
- private static final String JSON_WHITESPACE = SPACETAB + LFCR;
-
private static final String JAVASCRIPT_WHITESPACE_EOL =
LFCR +
"\u2028" + // line separator
@@ -385,24 +382,6 @@
}
/**
- * Test whether a char is valid JSON whitespace
- * @param ch a char
- * @return true if valid JSON whitespace
- */
- public static boolean isJsonWhitespace(final char ch) {
- return JSON_WHITESPACE.indexOf(ch) != -1;
- }
-
- /**
- * Test whether a char is valid JSON end of line
- * @param ch a char
- * @return true if valid JSON end of line
- */
- public static boolean isJsonEOL(final char ch) {
- return JSON_WHITESPACE_EOL.indexOf(ch) != -1;
- }
-
- /**
* Test if char is a string delimiter, e.g. '\' or '"'. Also scans exec
* strings ('`') in scripting mode.
* @param ch a char
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/Context.java Wed Feb 18 19:27:49 2015 -0800
@@ -60,6 +60,7 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicLong;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Consumer;
@@ -904,7 +905,7 @@
* @throw SecurityException if not accessible
*/
private static void checkPackageAccess(final SecurityManager sm, final String fullName) {
- sm.getClass(); // null check
+ Objects.requireNonNull(sm);
final int index = fullName.lastIndexOf('.');
if (index != -1) {
final String pkgName = fullName.substring(0, index);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONFunctions.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/JSONFunctions.java Wed Feb 18 19:27:49 2015 -0800
@@ -25,19 +25,11 @@
package jdk.nashorn.internal.runtime;
-import static jdk.nashorn.internal.runtime.Source.sourceFor;
-
import java.lang.invoke.MethodHandle;
import java.util.Iterator;
import java.util.concurrent.Callable;
-import jdk.nashorn.internal.ir.LiteralNode;
-import jdk.nashorn.internal.ir.Node;
-import jdk.nashorn.internal.ir.ObjectNode;
-import jdk.nashorn.internal.ir.PropertyNode;
-import jdk.nashorn.internal.ir.UnaryNode;
import jdk.nashorn.internal.objects.Global;
import jdk.nashorn.internal.parser.JSONParser;
-import jdk.nashorn.internal.parser.TokenType;
import jdk.nashorn.internal.runtime.arrays.ArrayIndex;
import jdk.nashorn.internal.runtime.linker.Bootstrap;
@@ -78,20 +70,18 @@
* @return Object representation of JSON text given
*/
public static Object parse(final Object text, final Object reviver) {
- final String str = JSType.toString(text);
- final JSONParser parser = new JSONParser(sourceFor("<json>", str), new Context.ThrowErrorManager());
-
- Node node;
+ final String str = JSType.toString(text);
+ final Global global = Context.getGlobal();
+ final JSONParser parser = new JSONParser(str, global);
+ final Object value;
try {
- node = parser.parse();
+ value = parser.parse();
} catch (final ParserException e) {
throw ECMAErrors.syntaxError(e, "invalid.json", e.getMessage());
}
- final Global global = Context.getGlobal();
- final Object unfiltered = convertNode(global, node);
- return applyReviver(global, unfiltered, reviver);
+ return applyReviver(global, value, reviver);
}
// -- Internals only below this point
@@ -137,61 +127,6 @@
}
}
- // Converts IR node to runtime value
- private static Object convertNode(final Global global, final Node node) {
- if (node instanceof LiteralNode) {
- // check for array literal
- if (node.tokenType() == TokenType.ARRAY) {
- assert node instanceof LiteralNode.ArrayLiteralNode;
- final Node[] elements = ((LiteralNode.ArrayLiteralNode)node).getValue();
-
- // NOTE: We cannot use LiteralNode.isNumericArray() here as that
- // method uses symbols of element nodes. Since we don't do lower
- // pass, there won't be any symbols!
- if (isNumericArray(elements)) {
- final double[] values = new double[elements.length];
- int index = 0;
-
- for (final Node elem : elements) {
- values[index++] = JSType.toNumber(convertNode(global, elem));
- }
- return global.wrapAsObject(values);
- }
-
- final Object[] values = new Object[elements.length];
- int index = 0;
-
- for (final Node elem : elements) {
- values[index++] = convertNode(global, elem);
- }
-
- return global.wrapAsObject(values);
- }
-
- return ((LiteralNode<?>)node).getValue();
-
- } else if (node instanceof ObjectNode) {
- final ObjectNode objNode = (ObjectNode) node;
- final ScriptObject object = global.newObject();
-
- for (final PropertyNode pNode: objNode.getElements()) {
- final Node valueNode = pNode.getValue();
-
- final String name = pNode.getKeyName();
- final Object value = convertNode(global, valueNode);
- setPropertyValue(object, name, value);
- }
-
- return object;
- } else if (node instanceof UnaryNode) {
- // UnaryNode used only to represent negative number JSON value
- final UnaryNode unaryNode = (UnaryNode)node;
- return -((LiteralNode<?>)unaryNode.getExpression()).getNumber();
- } else {
- return null;
- }
- }
-
// add a new property if does not exist already, or else set old property
private static void setPropertyValue(final ScriptObject sobj, final String name, final Object value) {
final int index = ArrayIndex.getArrayIndex(name);
@@ -207,14 +142,4 @@
}
}
- // does the given IR node represent a numeric array?
- private static boolean isNumericArray(final Node[] values) {
- for (final Node node : values) {
- if (node instanceof LiteralNode && ((LiteralNode<?>)node).getValue() instanceof Number) {
- continue;
- }
- return false;
- }
- return true;
- }
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/PropertyMap.java Wed Feb 18 19:27:49 2015 -0800
@@ -486,7 +486,7 @@
*
* @return New {@link PropertyMap} with {@link Property} replaced.
*/
- PropertyMap replaceProperty(final Property oldProperty, final Property newProperty) {
+ public PropertyMap replaceProperty(final Property oldProperty, final Property newProperty) {
if (listeners != null) {
listeners.propertyModified(oldProperty, newProperty);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptLoader.java Wed Feb 18 19:27:49 2015 -0800
@@ -26,6 +26,7 @@
package jdk.nashorn.internal.runtime;
import java.security.CodeSource;
+import java.util.Objects;
/**
* Responsible for loading script generated classes.
@@ -69,8 +70,7 @@
* @return Installed class.
*/
synchronized Class<?> installClass(final String name, final byte[] data, final CodeSource cs) {
- // null check
- cs.getClass();
+ Objects.requireNonNull(cs);
return defineClass(name, data, 0, data.length, cs);
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/ScriptObject.java Wed Feb 18 19:27:49 2015 -0800
@@ -722,8 +722,12 @@
public void defineOwnProperty(final int index, final Object value) {
assert isValidArrayIndex(index) : "invalid array index";
final long longIndex = ArrayIndex.toLongIndex(index);
- doesNotHaveEnsureDelete(longIndex, getArray().length(), false);
- setArray(getArray().ensure(longIndex).set(index,value, false));
+ final long oldLength = getArray().length();
+ if (longIndex >= oldLength) {
+ setArray(getArray().ensure(longIndex));
+ doesNotHaveEnsureDelete(longIndex, oldLength, false);
+ }
+ setArray(getArray().set(index,value, false));
}
private void checkIntegerKey(final String key) {
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ArrayData.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ArrayData.java Wed Feb 18 19:27:49 2015 -0800
@@ -118,7 +118,7 @@
return new SparseArrayData(this, safeIndex + 1);
}
//known to fit in int
- return toRealArrayData((int)safeIndex).ensure(safeIndex);
+ return toRealArrayData((int)safeIndex);
}
return this;
}
@@ -497,7 +497,9 @@
public abstract ArrayData shiftRight(final int by);
/**
- * Ensure that the given index exists and won't fail subsequent
+ * Ensure that the given index exists and won't fail in a subsequent access.
+ * If {@code safeIndex} is equal or greater than the current length the length is
+ * updated to {@code safeIndex + 1}.
*
* @param safeIndex the index to ensure wont go out of bounds
* @return new array data (or same)
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java Wed Feb 18 19:27:49 2015 -0800
@@ -57,7 +57,7 @@
}
/**
- * Check if we can put one more element at the end of this continous
+ * Check if we can put one more element at the end of this continuous
* array without reallocating, or if we are overwriting an already
* allocated element
*
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/IntArrayData.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/IntArrayData.java Wed Feb 18 19:27:49 2015 -0800
@@ -221,7 +221,9 @@
final int newLength = ArrayData.nextSize((int)safeIndex);
array = Arrays.copyOf(array, newLength);
}
- setLength(safeIndex + 1);
+ if (safeIndex >= length()) {
+ setLength(safeIndex + 1);
+ }
return this;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Wed Feb 18 19:27:49 2015 -0800
@@ -157,7 +157,9 @@
final int newLength = ArrayData.nextSize((int)safeIndex);
array = Arrays.copyOf(array, newLength);
}
- setLength(safeIndex + 1);
+ if (safeIndex >= length()) {
+ setLength(safeIndex + 1);
+ }
return this;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java Wed Feb 18 19:27:49 2015 -0800
@@ -139,7 +139,9 @@
final int newLength = ArrayData.nextSize((int)safeIndex);
array = Arrays.copyOf(array, newLength); //todo fill with nan or never accessed?
}
- setLength(safeIndex + 1);
+ if (safeIndex >= length()) {
+ setLength(safeIndex + 1);
+ }
return this;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java Wed Feb 18 19:27:49 2015 -0800
@@ -123,7 +123,9 @@
final int newLength = ArrayData.nextSize((int)safeIndex);
array = Arrays.copyOf(array, newLength); //fill with undefined or OK? TODO
}
- setLength(safeIndex + 1);
+ if (safeIndex >= length()) {
+ setLength(safeIndex + 1);
+ }
return this;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java Wed Feb 18 19:27:49 2015 -0800
@@ -135,10 +135,17 @@
@Override
public ArrayData ensure(final long safeIndex) {
+ // Usually #ensure only needs to be called if safeIndex is greater or equal current length.
+ // SparseArrayData is an exception as an index smaller than our current length may still
+ // exceed the underlying ArrayData's capacity. Because of this, SparseArrayData invokes
+ // its ensure method internally in various places where other ArrayData subclasses don't,
+ // making it safe for outside uses to only call ensure(safeIndex) if safeIndex >= length.
if (safeIndex < maxDenseLength && underlying.length() <= safeIndex) {
underlying = underlying.ensure(safeIndex);
}
- setLength(Math.max(safeIndex + 1, length()));
+ if (safeIndex >= length()) {
+ setLength(safeIndex + 1);
+ }
return this;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/Bootstrap.java Wed Feb 18 19:27:49 2015 -0800
@@ -119,6 +119,7 @@
return unboxReturnType(target, newType);
}
});
+ factory.setInternalObjectsFilter(NashornBeansLinker.createHiddenObjectFilter());
final int relinkThreshold = Options.getIntProperty("nashorn.unstable.relink.threshold", NASHORN_DEFAULT_UNSTABLE_RELINK_THRESHOLD);
if (relinkThreshold > -1) {
factory.setUnstableRelinkThreshold(relinkThreshold);
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaSuperAdapter.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/JavaSuperAdapter.java Wed Feb 18 19:27:49 2015 -0800
@@ -25,6 +25,8 @@
package jdk.nashorn.internal.runtime.linker;
+import java.util.Objects;
+
/**
* Represents a an adapter for invoking superclass methods on an adapter instance generated by
* {@code JavaAdapterBytecodeGenerator}. Note that objects of this class are just wrappers around the adapter instances,
@@ -34,7 +36,7 @@
private final Object adapter;
JavaSuperAdapter(final Object adapter) {
- adapter.getClass(); // NPE check
+ Objects.requireNonNull(adapter);
this.adapter = adapter;
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java Wed Feb 18 19:27:49 2015 -0800
@@ -40,10 +40,11 @@
import jdk.internal.dynalink.linker.GuardingDynamicLinker;
import jdk.internal.dynalink.linker.LinkRequest;
import jdk.internal.dynalink.linker.LinkerServices;
+import jdk.internal.dynalink.linker.MethodHandleTransformer;
+import jdk.internal.dynalink.support.DefaultInternalObjectFilter;
import jdk.internal.dynalink.support.Guards;
import jdk.internal.dynalink.support.Lookup;
import jdk.nashorn.api.scripting.ScriptUtils;
-import jdk.nashorn.internal.objects.NativeArray;
import jdk.nashorn.internal.runtime.ConsString;
import jdk.nashorn.internal.runtime.Context;
import jdk.nashorn.internal.runtime.ScriptObject;
@@ -52,10 +53,14 @@
/**
* This linker delegates to a {@code BeansLinker} but passes it a special linker services object that has a modified
- * {@code asType} method that will ensure that we never pass internal engine objects that should not be externally
- * observable (currently ConsString and ScriptObject) to Java APIs, but rather that we flatten it into a String. We can't just add
- * this functionality as custom converters via {@code GuaardingTypeConverterFactory}, since they are not consulted when
- * the target method handle parameter signature is {@code Object}.
+ * {@code compareConversion} method that favors conversion of {@link ConsString} to either {@link String} or
+ * {@link CharSequence}. It also provides a {@link #createHiddenObjectFilter()} method for use with bootstrap that will
+ * ensure that we never pass internal engine objects that should not be externally observable (currently ConsString and
+ * ScriptObject) to Java APIs, but rather that we flatten it into a String. We can't just add this functionality as
+ * custom converters via {@code GuaardingTypeConverterFactory}, since they are not consulted when
+ * the target method handle parameter signature is {@code Object}. This linker also makes sure that primitive
+ * {@link String} operations can be invoked on a {@link ConsString}, and allows invocation of objects implementing
+ * the {@link FunctionalInterface} attribute.
*/
public class NashornBeansLinker implements GuardingDynamicLinker {
// System property to control whether to wrap ScriptObject->ScriptObjectMirror for
@@ -63,16 +68,12 @@
private static final boolean MIRROR_ALWAYS = Options.getBooleanProperty("nashorn.mirror.always", true);
private static final MethodHandle EXPORT_ARGUMENT;
- private static final MethodHandle EXPORT_NATIVE_ARRAY;
- private static final MethodHandle EXPORT_SCRIPT_OBJECT;
private static final MethodHandle IMPORT_RESULT;
private static final MethodHandle FILTER_CONSSTRING;
static {
final Lookup lookup = new Lookup(MethodHandles.lookup());
EXPORT_ARGUMENT = lookup.findOwnStatic("exportArgument", Object.class, Object.class);
- EXPORT_NATIVE_ARRAY = lookup.findOwnStatic("exportNativeArray", Object.class, NativeArray.class);
- EXPORT_SCRIPT_OBJECT = lookup.findOwnStatic("exportScriptObject", Object.class, ScriptObject.class);
IMPORT_RESULT = lookup.findOwnStatic("importResult", Object.class, Object.class);
FILTER_CONSSTRING = lookup.findOwnStatic("consStringFilter", Object.class, Object.class);
}
@@ -115,9 +116,10 @@
}
return new GuardedInvocation(
// drop 'thiz' passed from the script.
- MH.dropArguments(desc.getLookup().unreflect(m), 1, callType.parameterType(1)),
- Guards.getInstanceOfGuard(m.getDeclaringClass())).asTypeSafeReturn(
- new NashornBeansLinkerServices(linkerServices), callType);
+ MH.dropArguments(linkerServices.filterInternalObjects(desc.getLookup().unreflect(m)), 1,
+ callType.parameterType(1)), Guards.getInstanceOfGuard(
+ m.getDeclaringClass())).asTypeSafeReturn(
+ new NashornBeansLinkerServices(linkerServices), callType);
}
}
return getGuardedInvocation(beansLinker, linkRequest, linkerServices);
@@ -141,21 +143,6 @@
return exportArgument(arg, MIRROR_ALWAYS);
}
- @SuppressWarnings("unused")
- private static Object exportNativeArray(final NativeArray arg) {
- return exportArgument(arg, MIRROR_ALWAYS);
- }
-
- @SuppressWarnings("unused")
- private static Object exportScriptObject(final ScriptObject arg) {
- return exportArgument(arg, MIRROR_ALWAYS);
- }
-
- @SuppressWarnings("unused")
- private static Object exportScriptArray(final NativeArray arg) {
- return exportArgument(arg, MIRROR_ALWAYS);
- }
-
static Object exportArgument(final Object arg, final boolean mirrorAlways) {
if (arg instanceof ConsString) {
return arg.toString();
@@ -208,6 +195,10 @@
return FUNCTIONAL_IFACE_METHOD.get(clazz);
}
+ static MethodHandleTransformer createHiddenObjectFilter() {
+ return new DefaultInternalObjectFilter(EXPORT_ARGUMENT, MIRROR_ALWAYS ? IMPORT_RESULT : null);
+ }
+
private static class NashornBeansLinkerServices implements LinkerServices {
private final LinkerServices linkerServices;
@@ -217,50 +208,7 @@
@Override
public MethodHandle asType(final MethodHandle handle, final MethodType fromType) {
- final MethodType handleType = handle.type();
- final int paramCount = handleType.parameterCount();
- assert fromType.parameterCount() == handleType.parameterCount();
-
- MethodType newFromType = fromType;
- MethodHandle[] filters = null;
- for(int i = 0; i < paramCount; ++i) {
- final MethodHandle filter = argConversionFilter(handleType.parameterType(i), fromType.parameterType(i));
- if (filter != null) {
- if (filters == null) {
- filters = new MethodHandle[paramCount];
- }
- // "erase" specific type with Object type or else we'll get filter mismatch
- newFromType = newFromType.changeParameterType(i, Object.class);
- filters[i] = filter;
- }
- }
-
- final MethodHandle typed = linkerServices.asType(handle, newFromType);
- MethodHandle result = filters != null ? MethodHandles.filterArguments(typed, 0, filters) : typed;
- // Filter Object typed return value for possible ScriptObjectMirror. We convert
- // ScriptObjectMirror as ScriptObject (if it is mirror from current global).
- if (MIRROR_ALWAYS && areBothObjects(handleType.returnType(), fromType.returnType())) {
- result = MethodHandles.filterReturnValue(result, IMPORT_RESULT);
- }
-
- return result;
- }
-
- private static MethodHandle argConversionFilter(final Class<?> handleType, final Class<?> fromType) {
- if (handleType == Object.class) {
- if (fromType == Object.class) {
- return EXPORT_ARGUMENT;
- } else if (fromType == NativeArray.class) {
- return EXPORT_NATIVE_ARRAY;
- } else if (fromType == ScriptObject.class) {
- return EXPORT_SCRIPT_OBJECT;
- }
- }
- return null;
- }
-
- private static boolean areBothObjects(final Class<?> handleType, final Class<?> fromType) {
- return handleType == Object.class && fromType == Object.class;
+ return linkerServices.asType(handle, fromType);
}
@Override
@@ -296,5 +244,10 @@
}
return linkerServices.compareConversion(sourceType, targetType1, targetType2);
}
+
+ @Override
+ public MethodHandle filterInternalObjects(MethodHandle target) {
+ return linkerServices.filterInternalObjects(target);
+ }
}
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/Options.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/options/Options.java Wed Feb 18 19:27:49 2015 -0800
@@ -42,6 +42,7 @@
import java.util.Locale;
import java.util.Map;
import java.util.MissingResourceException;
+import java.util.Objects;
import java.util.PropertyPermission;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
@@ -143,7 +144,7 @@
* @return true if set to true, default value if unset or set to false
*/
public static boolean getBooleanProperty(final String name, final Boolean defValue) {
- name.getClass(); // null check
+ Objects.requireNonNull(name);
if (!name.startsWith("nashorn.")) {
throw new IllegalArgumentException(name);
}
@@ -184,7 +185,7 @@
* @return string property if set or default value
*/
public static String getStringProperty(final String name, final String defValue) {
- name.getClass(); // null check
+ Objects.requireNonNull(name);
if (! name.startsWith("nashorn.")) {
throw new IllegalArgumentException(name);
}
@@ -211,7 +212,7 @@
* @return integer property if set or default value
*/
public static int getIntProperty(final String name, final int defValue) {
- name.getClass(); // null check
+ Objects.requireNonNull(name);
if (! name.startsWith("nashorn.")) {
throw new IllegalArgumentException(name);
}
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JO.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/scripts/JO.java Wed Feb 18 19:27:49 2015 -0800
@@ -25,7 +25,6 @@
package jdk.nashorn.internal.scripts;
-import jdk.nashorn.internal.codegen.SpillObjectCreator;
import jdk.nashorn.internal.runtime.PropertyMap;
import jdk.nashorn.internal.runtime.ScriptObject;
@@ -64,8 +63,9 @@
}
/**
- * Constructor that takes a pre-initialized spill pool. Used for
- * by {@link SpillObjectCreator} for intializing object literals
+ * Constructor that takes a pre-initialized spill pool. Used by
+ * {@link jdk.nashorn.internal.codegen.SpillObjectCreator} and
+ * {@link jdk.nashorn.internal.parser.JSONParser} for initializing object literals
*
* @param map property map
* @param primitiveSpill primitive spill pool
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/examples/json-parser-micro.js Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,315 @@
+/*
+ * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of Oracle nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+ * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+function bench() {
+ var start = Date.now();
+ for (var i = 0; i < 2000; i++) {
+ JSON.parse(String(json));
+ }
+ print("1000 iterations in", Date.now() - start, "millis");
+}
+
+var json = '[\
+ {\
+ "_id": "54ca34171d3ade49782294c8",\
+ "index": 0,\
+ "guid": "ed0e74d5-ac63-47b6-8938-1750abab5770",\
+ "isActive": false,\
+ "balance": "$1,996.19",\
+ "picture": "http://placehold.it/32x32",\
+ "age": 39,\
+ "eyeColor": "green",\
+ "name": "Rose Graham",\
+ "gender": "male",\
+ "company": "PRIMORDIA",\
+ "email": "rosegraham@primordia.com",\
+ "phone": "+1 (985) 600-3551",\
+ "address": "364 Melba Court, Succasunna, Texas, 8393",\
+ "about": "Sunt commodo cillum occaecat velit eu eiusmod ex eiusmod sunt deserunt nulla proident incididunt. Incididunt ullamco Lorem elit do culpa esse do ex dolor aliquip labore. Ullamco velit laboris incididunt dolor. Nostrud dolor sint pariatur fugiat ullamco exercitation. Eu laboris do cupidatat eiusmod incididunt mollit occaecat voluptate.",\
+ "registered": "2014-03-13T12:05:14 -01:00",\
+ "latitude": 18.55665,\
+ "longitude": 81.641001,\
+ "tags": [\
+ "sint",\
+ "Lorem",\
+ "veniam",\
+ "quis",\
+ "proident",\
+ "consectetur",\
+ "consequat"\
+ ],\
+ "friends": [\
+ {\
+ "id": 0,\
+ "name": "Evangelina Morgan"\
+ },\
+ {\
+ "id": 1,\
+ "name": "Saunders Snyder"\
+ },\
+ {\
+ "id": 2,\
+ "name": "Walker Wood"\
+ }\
+ ],\
+ "greeting": "Hello, Rose Graham! You have 1 unread messages.",\
+ "favoriteFruit": "strawberry"\
+ },\
+ {\
+ "_id": "54ca34176790c4c60fcae085",\
+ "index": 1,\
+ "guid": "9dc42e4c-b58f-4d92-a2ee-968d2b627d92",\
+ "isActive": true,\
+ "balance": "$3,832.97",\
+ "picture": "http://placehold.it/32x32",\
+ "age": 40,\
+ "eyeColor": "brown",\
+ "name": "Delaney Cherry",\
+ "gender": "male",\
+ "company": "INJOY",\
+ "email": "delaneycherry@injoy.com",\
+ "phone": "+1 (807) 463-2295",\
+ "address": "470 Hale Avenue, Mulberry, District Of Columbia, 5455",\
+ "about": "Deserunt sit cupidatat elit Lorem excepteur ex. Magna officia minim cupidatat nulla enim deserunt. Amet ex in tempor commodo consequat non ad qui elit cupidatat esse labore sint.",\
+ "registered": "2014-03-27T23:06:33 -01:00",\
+ "latitude": -4.984238,\
+ "longitude": 116.039285,\
+ "tags": [\
+ "minim",\
+ "velit",\
+ "aute",\
+ "minim",\
+ "id",\
+ "enim",\
+ "enim"\
+ ],\
+ "friends": [\
+ {\
+ "id": 0,\
+ "name": "Barrera Flowers"\
+ },\
+ {\
+ "id": 1,\
+ "name": "Leann Larson"\
+ },\
+ {\
+ "id": 2,\
+ "name": "Latoya Petty"\
+ }\
+ ],\
+ "greeting": "Hello, Delaney Cherry! You have 2 unread messages.",\
+ "favoriteFruit": "strawberry"\
+ },\
+ {\
+ "_id": "54ca3417920666f00c54bfc4",\
+ "index": 2,\
+ "guid": "f91e08f8-1598-49bc-a08b-bb48f0cc1751",\
+ "isActive": true,\
+ "balance": "$2,932.84",\
+ "picture": "http://placehold.it/32x32",\
+ "age": 28,\
+ "eyeColor": "brown",\
+ "name": "Mosley Hammond",\
+ "gender": "male",\
+ "company": "AQUACINE",\
+ "email": "mosleyhammond@aquacine.com",\
+ "phone": "+1 (836) 598-2591",\
+ "address": "879 Columbia Place, Seymour, Montana, 4897",\
+ "about": "Sunt laborum incididunt et elit in deserunt deserunt irure enim ea qui non. Minim nisi sint aute veniam reprehenderit veniam reprehenderit. Elit enim eu voluptate eu cupidatat nulla ea incididunt exercitation voluptate ut aliquip excepteur ipsum. Consequat anim fugiat irure Lorem anim consectetur est.",\
+ "registered": "2014-07-27T05:05:58 -02:00",\
+ "latitude": -43.608015,\
+ "longitude": -38.33894,\
+ "tags": [\
+ "proident",\
+ "incididunt",\
+ "eiusmod",\
+ "anim",\
+ "consectetur",\
+ "qui",\
+ "excepteur"\
+ ],\
+ "friends": [\
+ {\
+ "id": 0,\
+ "name": "Hanson Davidson"\
+ },\
+ {\
+ "id": 1,\
+ "name": "Autumn Kaufman"\
+ },\
+ {\
+ "id": 2,\
+ "name": "Tammy Foley"\
+ }\
+ ],\
+ "greeting": "Hello, Mosley Hammond! You have 4 unread messages.",\
+ "favoriteFruit": "apple"\
+ },\
+ {\
+ "_id": "54ca341753b67572a2b04935",\
+ "index": 3,\
+ "guid": "3377416b-43a2-4f9e-ada3-2479e13b44b8",\
+ "isActive": false,\
+ "balance": "$3,821.54",\
+ "picture": "http://placehold.it/32x32",\
+ "age": 31,\
+ "eyeColor": "green",\
+ "name": "Mueller Barrett",\
+ "gender": "male",\
+ "company": "GROK",\
+ "email": "muellerbarrett@grok.com",\
+ "phone": "+1 (890) 535-2834",\
+ "address": "571 Norwood Avenue, Westwood, Arkansas, 2164",\
+ "about": "Occaecat est sunt commodo ut ex excepteur elit nulla velit minim commodo commodo esse. Lorem quis eu minim consectetur. Cupidatat cupidatat consequat sit eu ex non quis nulla veniam sint enim excepteur. Consequat minim duis do do minim fugiat minim elit laborum ut velit. Occaecat laboris veniam sint reprehenderit.",\
+ "registered": "2014-07-18T17:15:35 -02:00",\
+ "latitude": 10.746577,\
+ "longitude": -160.266041,\
+ "tags": [\
+ "reprehenderit",\
+ "veniam",\
+ "sint",\
+ "commodo",\
+ "exercitation",\
+ "cillum",\
+ "sunt"\
+ ],\
+ "friends": [\
+ {\
+ "id": 0,\
+ "name": "Summers Finch"\
+ },\
+ {\
+ "id": 1,\
+ "name": "Tracie Mcdaniel"\
+ },\
+ {\
+ "id": 2,\
+ "name": "Ayers Patrick"\
+ }\
+ ],\
+ "greeting": "Hello, Mueller Barrett! You have 7 unread messages.",\
+ "favoriteFruit": "apple"\
+ },\
+ {\
+ "_id": "54ca34172775ab9615db0d1d",\
+ "index": 4,\
+ "guid": "a3102a3e-3f08-4df3-b5b5-62eff985d5ca",\
+ "isActive": true,\
+ "balance": "$3,962.27",\
+ "picture": "http://placehold.it/32x32",\
+ "age": 34,\
+ "eyeColor": "green",\
+ "name": "Patrick Foster",\
+ "gender": "male",\
+ "company": "QUAREX",\
+ "email": "patrickfoster@quarex.com",\
+ "phone": "+1 (805) 577-2362",\
+ "address": "640 Richards Street, Roberts, American Samoa, 5530",\
+ "about": "Aute occaecat occaecat ad eiusmod esse aliqua ullamco minim. Exercitation aute ut ex nostrud deserunt laboris officia amet enim do. Cillum officia laborum occaecat eiusmod reprehenderit ex et aliqua minim elit ex aliqua mollit. Occaecat dolor in fugiat laboris aliquip nisi ad voluptate duis eiusmod ad do.",\
+ "registered": "2014-07-22T16:45:35 -02:00",\
+ "latitude": 6.609025,\
+ "longitude": -5.357026,\
+ "tags": [\
+ "ea",\
+ "ut",\
+ "excepteur",\
+ "enim",\
+ "ad",\
+ "non",\
+ "sit"\
+ ],\
+ "friends": [\
+ {\
+ "id": 0,\
+ "name": "Duncan Lewis"\
+ },\
+ {\
+ "id": 1,\
+ "name": "Alyce Benton"\
+ },\
+ {\
+ "id": 2,\
+ "name": "Angelique Larsen"\
+ }\
+ ],\
+ "greeting": "Hello, Patrick Foster! You have 1 unread messages.",\
+ "favoriteFruit": "strawberry"\
+ },\
+ {\
+ "_id": "54ca3417a190f26fef815f6d",\
+ "index": 5,\
+ "guid": "c09663dd-bb0e-45a4-960c-232c0e8a9486",\
+ "isActive": false,\
+ "balance": "$1,871.12",\
+ "picture": "http://placehold.it/32x32",\
+ "age": 20,\
+ "eyeColor": "blue",\
+ "name": "Foreman Chaney",\
+ "gender": "male",\
+ "company": "DEMINIMUM",\
+ "email": "foremanchaney@deminimum.com",\
+ "phone": "+1 (966) 523-2182",\
+ "address": "960 Granite Street, Sunnyside, Tennessee, 1097",\
+ "about": "Adipisicing nisi qui id sit incididunt aute exercitation veniam consequat ipsum sit irure. Aute officia commodo Lorem consequat. Labore exercitation consequat voluptate deserunt consequat do est fugiat nisi eu dolor minim id ea.",\
+ "registered": "2015-01-21T00:18:00 -01:00",\
+ "latitude": -69.841726,\
+ "longitude": 121.809383,\
+ "tags": [\
+ "laboris",\
+ "sunt",\
+ "exercitation",\
+ "enim",\
+ "anim",\
+ "excepteur",\
+ "tempor"\
+ ],\
+ "friends": [\
+ {\
+ "id": 0,\
+ "name": "Espinoza Johnston"\
+ },\
+ {\
+ "id": 1,\
+ "name": "Doreen Holder"\
+ },\
+ {\
+ "id": 2,\
+ "name": "William Ellison"\
+ }\
+ ],\
+ "greeting": "Hello, Foreman Chaney! You have 5 unread messages.",\
+ "favoriteFruit": "strawberry"\
+ }\
+]';
+
+for (var i = 0; i < 100; i++) {
+ bench();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8062141.js Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,91 @@
+/*
+ * 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-8062141: Various performance issues parsing JSON
+ *
+ * @test
+ * @run
+ */
+
+function testJson(json) {
+ try {
+ print(JSON.stringify(JSON.parse(json)));
+ } catch (error) {
+ print(error);
+ }
+}
+
+testJson('"\\u003f"');
+testJson('"\\u0"');
+testJson('"\\u0"');
+testJson('"\\u00"');
+testJson('"\\u003"');
+testJson('"\\u003x"');
+testJson('"\\"');
+testJson('"');
+testJson('+1');
+testJson('-1');
+testJson('1.');
+testJson('.1');
+testJson('01');
+testJson('1e');
+testJson('1e0');
+testJson('1a');
+testJson('1e+');
+testJson('1e-');
+testJson('0.0e+0');
+testJson('0.0e-0');
+testJson('[]');
+testJson('[ 1 ]');
+testJson('[1,]');
+testJson('[ 1 , 2 ]');
+testJson('[1, 2');
+testJson('{}');
+testJson('{ "a" : "b" }');
+testJson('{ "a" : "b" ');
+testJson('{ "a" : }');
+testJson('true');
+testJson('tru');
+testJson('true1');
+testJson('false');
+testJson('fals');
+testJson('falser');
+testJson('null');
+testJson('nul');
+testJson('null0');
+testJson('{} 0');
+testJson('{} a');
+testJson('[] 0');
+testJson('[] a');
+testJson('1 0');
+testJson('1 a');
+testJson('["a":true]');
+testJson('{"a",truer}');
+testJson('{"a":truer}');
+testJson('[1, 2, 3]');
+testJson('[9223372036854774000, 9223372036854775000, 9223372036854776000]');
+testJson('[1.1, 1.2, 1.3]');
+testJson('[1, 1.2, 9223372036854776000, null, true]');
+testJson('{ "a" : "string" , "b": 1 , "c" : 1.2 , "d" : 9223372036854776000 , "e" : null , "f" : true }');
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8062141.js.EXPECTED Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,120 @@
+"?"
+SyntaxError: Invalid JSON: <json>:1:4 Invalid hex digit
+"\u0"
+ ^
+SyntaxError: Invalid JSON: <json>:1:4 Invalid hex digit
+"\u0"
+ ^
+SyntaxError: Invalid JSON: <json>:1:5 Invalid hex digit
+"\u00"
+ ^
+SyntaxError: Invalid JSON: <json>:1:6 Invalid hex digit
+"\u003"
+ ^
+SyntaxError: Invalid JSON: <json>:1:6 Invalid hex digit
+"\u003x"
+ ^
+SyntaxError: Invalid JSON: <json>:1:3 Missing close quote
+"\"
+ ^
+SyntaxError: Invalid JSON: <json>:1:1 Missing close quote
+"
+ ^
+SyntaxError: Invalid JSON: <json>:1:0 Expected json literal but found +
++1
+^
+-1
+SyntaxError: Invalid JSON: <json>:1:2 Invalid JSON number format
+1.
+ ^
+SyntaxError: Invalid JSON: <json>:1:0 Invalid JSON number format
+.1
+^
+SyntaxError: Invalid JSON: <json>:1:1 Expected eof but found 1
+01
+ ^
+SyntaxError: Invalid JSON: <json>:1:2 Invalid JSON number format
+1e
+ ^
+1
+SyntaxError: Invalid JSON: <json>:1:1 Expected eof but found a
+1a
+ ^
+SyntaxError: Invalid JSON: <json>:1:3 Invalid JSON number format
+1e+
+ ^
+SyntaxError: Invalid JSON: <json>:1:3 Invalid JSON number format
+1e-
+ ^
+0
+0
+[]
+[1]
+SyntaxError: Invalid JSON: <json>:1:3 Trailing comma is not allowed in JSON
+[1,]
+ ^
+[1,2]
+SyntaxError: Invalid JSON: <json>:1:5 Expected , or ] but found eof
+[1, 2
+ ^
+{}
+{"a":"b"}
+SyntaxError: Invalid JSON: <json>:1:12 Expected , or } but found eof
+{ "a" : "b"
+ ^
+SyntaxError: Invalid JSON: <json>:1:8 Expected json literal but found }
+{ "a" : }
+ ^
+true
+SyntaxError: Invalid JSON: <json>:1:0 Expected json literal but found ident
+tru
+^
+SyntaxError: Invalid JSON: <json>:1:4 Expected eof but found 1
+true1
+ ^
+false
+SyntaxError: Invalid JSON: <json>:1:0 Expected json literal but found ident
+fals
+^
+SyntaxError: Invalid JSON: <json>:1:5 Expected eof but found r
+falser
+ ^
+null
+SyntaxError: Invalid JSON: <json>:1:0 Expected json literal but found ident
+nul
+^
+SyntaxError: Invalid JSON: <json>:1:4 Expected eof but found 0
+null0
+ ^
+SyntaxError: Invalid JSON: <json>:1:3 Expected eof but found 0
+{} 0
+ ^
+SyntaxError: Invalid JSON: <json>:1:3 Expected eof but found a
+{} a
+ ^
+SyntaxError: Invalid JSON: <json>:1:3 Expected eof but found 0
+[] 0
+ ^
+SyntaxError: Invalid JSON: <json>:1:3 Expected eof but found a
+[] a
+ ^
+SyntaxError: Invalid JSON: <json>:1:2 Expected eof but found 0
+1 0
+ ^
+SyntaxError: Invalid JSON: <json>:1:2 Expected eof but found a
+1 a
+ ^
+SyntaxError: Invalid JSON: <json>:1:4 Expected , or ] but found :
+["a":true]
+ ^
+SyntaxError: Invalid JSON: <json>:1:4 Expected : but found ,
+{"a",truer}
+ ^
+SyntaxError: Invalid JSON: <json>:1:9 Expected , or } but found r
+{"a":truer}
+ ^
+[1,2,3]
+[9223372036854773800,9223372036854774800,9223372036854776000]
+[1.1,1.2,1.3]
+[1,1.2,9223372036854776000,null,true]
+{"a":"string","b":1,"c":1.2,"d":9223372036854776000,"e":null,"f":true}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8068872.js Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,34 @@
+/*
+ * 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-8068872: Nashorn JSON.parse drops numeric keys
+ *
+ * @test
+ * @run
+ */
+
+print(JSON.stringify(JSON.parse('{"3": 1, "5": "a"}')));
+print(JSON.stringify(JSON.parse('{"5": 1, "3": "a"}')));
+print(JSON.stringify(JSON.parse('{"0": 1, "4294967294": "a"}')));
+print(JSON.stringify(JSON.parse('{"4294967294": 1, "0": "a"}')));
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8068872.js.EXPECTED Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,4 @@
+{"3":1,"5":"a"}
+{"3":"a","5":1}
+{"0":1,"4294967294":"a"}
+{"0":"a","4294967294":1}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/script/basic/JDK-8072596.js Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,69 @@
+/*
+ * 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-8072596: Arrays.asList results in ClassCastException with a JS array
+ *
+ * @test
+ * @run
+ */
+var arr = java.util.Arrays.asList("hello world".split(' '));
+// We split it into a list of two elements: [hello, world]
+Assert.assertTrue(arr instanceof java.util.List);
+Assert.assertEquals(arr.length, 2);
+Assert.assertEquals(arr[0], "hello");
+Assert.assertEquals(arr[1], "world");
+
+var Jdk8072596TestSubject = Java.type("jdk.nashorn.test.models.Jdk8072596TestSubject");
+var testSubject = new Jdk8072596TestSubject({bar: 0});
+testSubject.test1(true, {foo: 1}, {bar: 2});
+testSubject.test2(true, {foo: 1}, {bar: 2}, {baz: 3}, {bing: 4});
+var h = "h";
+var ello = "ello";
+testSubject.test3(true, {foo: 5}, /* ConsString, why not */ h + ello, [6, 7], 8);
+Jdk8072596TestSubject.test4({foo: 9});
+
+// Test wrapping setters arguments and unwrapping getters return values on list.
+var list = new java.util.ArrayList();
+list.add(null);
+var obj0 = {valueOf: function() { return 0; }};
+var obj1 = {foo: 10};
+list[obj0] = obj1;
+testSubject.testListHasWrappedObject(list);
+// NOTE: can't use Assert.assertSame(obj1, list[obj0]), as the arguments would end up being wrapped...
+Assert.assertTrue(obj1 === list[obj0]);
+
+// Test wrapping setters arguments and unwrapping getters return values on array.
+var arr2 = new (Java.type("java.lang.Object[]"))(1);
+var obj2 = {bar: 11};
+arr2[obj0] = obj2;
+testSubject.testArrayHasWrappedObject(arr2);
+Assert.assertTrue(obj2 === arr2[obj0]);
+
+// Test wrapping setters index and arguments and getters index, and unwrapping getters return values on map.
+// Since ScriptObjectMirror.equals() uses underlying ScriptObject identity, using them as map keys works.
+var map = new java.util.HashMap();
+var obj3 = {bar: 12};
+map[obj0] = obj3;
+testSubject.testMapHasWrappedObject(map, obj0);
+Assert.assertTrue(obj3 === map[obj0]);
--- a/nashorn/test/script/basic/NASHORN-623.js.EXPECTED Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/test/script/basic/NASHORN-623.js.EXPECTED Wed Feb 18 19:27:49 2015 -0800
@@ -1,3 +1,3 @@
-SyntaxError: Invalid JSON: <json>:1:12 Expected number but found ident
+SyntaxError: Invalid JSON: <json>:1:11 Invalid JSON number format
{ "test" : -xxx }
- ^
+ ^
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScopeTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScopeTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -706,4 +706,74 @@
}
}
+ // @bug 8071678: NashornScriptEngine returns javax.script.ScriptContext instance
+ // with get/setAttribute methods insonsistent for GLOBAL_SCOPE
+ @Test
+ public void testGlobalScopeSearch() throws Exception {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final ScriptContext c = e.getContext();
+ c.setAttribute("name1234", "value", ScriptContext.GLOBAL_SCOPE);
+ assertEquals(c.getAttribute("name1234"), "value");
+ assertEquals(c.getAttributesScope("name1234"),
+ ScriptContext.GLOBAL_SCOPE);
+ }
+
+ // @bug 8071594: NashornScriptEngine returns javax.script.ScriptContext instance
+ // which doesn't completely conform to the spec regarding exceptions throwing
+ @Test
+ public void testScriptContext_NPE_IAE() throws Exception {
+ final ScriptEngineManager m = new ScriptEngineManager();
+ final ScriptEngine e = m.getEngineByName("nashorn");
+ final ScriptContext c = e.getContext();
+ try {
+ c.getAttribute("");
+ throw new AssertionError("should have thrown IAE");
+ } catch (IllegalArgumentException iae1) {}
+
+ try {
+ c.getAttribute(null);
+ throw new AssertionError("should have thrown NPE");
+ } catch (NullPointerException npe1) {}
+
+ try {
+ c.getAttribute("", ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown IAE");
+ } catch (IllegalArgumentException iae2) {}
+
+ try {
+ c.getAttribute(null, ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown NPE");
+ } catch (NullPointerException npe2) {}
+
+ try {
+ c.removeAttribute("", ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown IAE");
+ } catch (IllegalArgumentException iae3) {}
+
+ try {
+ c.removeAttribute(null, ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown NPE");
+ } catch (NullPointerException npe3) {}
+
+ try {
+ c.setAttribute("", "value", ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown IAE");
+ } catch (IllegalArgumentException iae4) {}
+
+ try {
+ c.setAttribute(null, "value", ScriptContext.ENGINE_SCOPE);
+ throw new AssertionError("should have thrown NPE");
+ } catch (NullPointerException npe4) {}
+
+ try {
+ c.getAttributesScope("");
+ throw new AssertionError("should have thrown IAE");
+ } catch (IllegalArgumentException iae5) {}
+
+ try {
+ c.getAttributesScope(null);
+ throw new AssertionError("should have thrown NPE");
+ } catch (NullPointerException npe5) {}
+ }
}
--- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java Tue Feb 17 13:19:23 2015 -0500
+++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java Wed Feb 18 19:27:49 2015 -0800
@@ -721,6 +721,15 @@
assertTrue(invoked.get());
}
+ @Test
+ public void testLengthOnArrayLikeObjects() throws Exception {
+ final ScriptEngine e = new ScriptEngineManager().getEngineByName("nashorn");
+ final Object val = e.eval("var arr = { length: 1, 0: 1}; arr.length");
+
+ assertTrue(Number.class.isAssignableFrom(val.getClass()));
+ assertTrue(((Number)val).intValue() == 1);
+ }
+
// @bug JDK-8068603: NashornScriptEngine.put/get() impls don't conform to NPE, IAE spec assertions
@Test
public void illegalBindingsValuesTest() throws Exception {
@@ -843,6 +852,17 @@
}
}
+ // @bug 8071989: NashornScriptEngine returns javax.script.ScriptContext instance
+ // with insonsistent get/remove methods behavior for undefined attributes
+ @Test
+ public void testScriptContextGetRemoveUndefined() throws Exception {
+ final ScriptEngineManager manager = new ScriptEngineManager();
+ final ScriptEngine e = manager.getEngineByName("nashorn");
+ final ScriptContext ctx = e.getContext();
+ assertNull(ctx.getAttribute("undefinedname", ScriptContext.ENGINE_SCOPE));
+ assertNull(ctx.removeAttribute("undefinedname", ScriptContext.ENGINE_SCOPE));
+ }
+
private static void checkProperty(final ScriptEngine e, final String name)
throws ScriptException {
final String value = System.getProperty(name);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/nashorn/test/src/jdk/nashorn/test/models/Jdk8072596TestSubject.java Wed Feb 18 19:27:49 2015 -0800
@@ -0,0 +1,106 @@
+/*
+ * 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.
+ */
+
+package jdk.nashorn.test.models;
+
+import java.util.List;
+import java.util.Map;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
+import jdk.nashorn.internal.runtime.ScriptObject;
+import org.testng.Assert;
+
+public class Jdk8072596TestSubject {
+
+ public Jdk8072596TestSubject(final Object x) {
+ Assert.assertTrue(x instanceof ScriptObjectMirror);
+ Assert.assertEquals(((ScriptObjectMirror)x).get("bar"), 0);
+ }
+
+ // Test having to wrap some arguments but not others
+ public void test1(final String x, final Object y, final ScriptObject w) {
+ Assert.assertEquals(x, "true");
+
+ Assert.assertTrue(y instanceof ScriptObjectMirror);
+ Assert.assertEquals(((ScriptObjectMirror)y).get("foo"), 1);
+
+ Assert.assertEquals(w.get("bar"), 2);
+ }
+
+ // Test having to wrap some arguments but not others, and a vararg array
+ public void test2(String x, final Object y, final ScriptObject w, final Object... z) {
+ test1(x, y, w);
+
+ Assert.assertEquals(z.length, 2);
+
+ Assert.assertTrue(z[0] instanceof ScriptObjectMirror);
+ Assert.assertEquals(((ScriptObjectMirror)z[0]).get("baz"), 3);
+
+ Assert.assertTrue(z[1] instanceof ScriptObjectMirror);
+ Assert.assertEquals(((ScriptObjectMirror)z[1]).get("bing"), 4);
+ }
+
+ // Test mixed (wrappable and non-wrappable) elements in a vararg array
+ public void test3(final Object... z) {
+ Assert.assertEquals(z.length, 5);
+
+ Assert.assertEquals(z[0], true);
+
+ Assert.assertTrue(z[1] instanceof ScriptObjectMirror);
+ Assert.assertEquals(((ScriptObjectMirror)z[1]).get("foo"), 5);
+
+ Assert.assertEquals(z[2], "hello");
+
+ Assert.assertTrue(z[3] instanceof ScriptObjectMirror);
+ Assert.assertEquals(((ScriptObjectMirror)z[3]).getSlot(0), 6);
+ Assert.assertEquals(((ScriptObjectMirror)z[3]).getSlot(1), 7);
+
+ Assert.assertEquals(z[4], 8);
+ }
+
+ // test wrapping the first argument of a static method
+ public static void test4(final Object x) {
+ Assert.assertTrue(x instanceof ScriptObjectMirror);
+ Assert.assertEquals(((ScriptObjectMirror)x).get("foo"), 9);
+ }
+
+ public void testListHasWrappedObject(final List<?> l) {
+ Assert.assertEquals(l.size(), 1);
+ Assert.assertTrue(l.get(0) instanceof ScriptObjectMirror);
+ Assert.assertEquals(((ScriptObjectMirror)l.get(0)).get("foo"), 10);
+ }
+
+ public void testArrayHasWrappedObject(final Object[] a) {
+ Assert.assertEquals(a.length, 1);
+ Assert.assertTrue(a[0] instanceof ScriptObjectMirror);
+ Assert.assertEquals(((ScriptObjectMirror)a[0]).get("bar"), 11);
+ }
+
+ public void testMapHasWrappedObject(final Map<?, ?> m, final Object key) {
+ Assert.assertEquals(m.size(), 1);
+ Assert.assertTrue(key instanceof ScriptObjectMirror);
+ Assert.assertTrue(m.get(key) instanceof ScriptObjectMirror);
+ Assert.assertEquals(((ScriptObjectMirror)m.get(key)).get("bar"), 12);
+ }
+}