This commit is contained in:
David Dehaven 2014-11-12 09:36:25 -08:00
commit 1ce0119e15
355 changed files with 10452 additions and 3533 deletions

View File

@ -280,3 +280,4 @@ f0c5e4b732da823bdaa4184133675f384e7cd68d jdk9-b33
a137992d750c72f6f944f341aa19b0d0d96afe0c jdk9-b35
41df50e7303daf73c0d661ef601c4fe250915de5 jdk9-b36
b409bc51bc23cfd51f2bd04ea919ec83535af9d0 jdk9-b37
948cceef81ba4cb34bc233e7cc5952951ff04e88 jdk9-b38

View File

@ -280,3 +280,4 @@ e4ba01b726e263953ae129be37c94de6ed145b1d jdk9-b33
c173ba994245380fb11ef077d1e59823386840eb jdk9-b35
201d4e235d597a25a2d3ee1404394789ba386119 jdk9-b36
723a67b0c442391447b1d8aad8b249d06d1032e8 jdk9-b37
d42c0a90afc3c66ca87543076ec9aafd4b4680de jdk9-b38

View File

@ -684,8 +684,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
AC_SUBST(CONF_NAME, $CONF_NAME)
AC_SUBST(OUTPUT_ROOT, $OUTPUT_ROOT)
# Most of the probed defines are put into config.h
AC_CONFIG_HEADERS([$OUTPUT_ROOT/config.h:$AUTOCONF_DIR/config.h.in])
# The spec.gmk file contains all variables for the make system.
AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in])
# The hotspot-spec.gmk file contains legacy variables for the hotspot make system.
@ -694,8 +692,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_OUTPUT_DIR],
AC_CONFIG_FILES([$OUTPUT_ROOT/bootcycle-spec.gmk:$AUTOCONF_DIR/bootcycle-spec.gmk.in])
# The compare.sh is used to compare the build output to other builds.
AC_CONFIG_FILES([$OUTPUT_ROOT/compare.sh:$AUTOCONF_DIR/compare.sh.in])
# Spec.sh is currently used by compare-objects.sh
AC_CONFIG_FILES([$OUTPUT_ROOT/spec.sh:$AUTOCONF_DIR/spec.sh.in])
# The generated Makefile knows where the spec.gmk is and where the source is.
# You can run make from the OUTPUT_ROOT, or from the top-level Makefile
# which will look for generated configurations

File diff suppressed because it is too large Load Diff

View File

@ -131,7 +131,7 @@ yum_help() {
pulse)
PKGHANDLER_COMMAND="sudo yum install pulseaudio-libs-devel" ;;
x11)
PKGHANDLER_COMMAND="sudo yum install libXtst-devel libXt-devel libXrender-devel" ;;
PKGHANDLER_COMMAND="sudo yum install libXtst-devel libXt-devel libXrender-devel libXi-devel" ;;
ccache)
PKGHANDLER_COMMAND="sudo yum install ccache" ;;
esac

View File

@ -91,85 +91,93 @@ AC_DEFUN_ONCE([LIB_SETUP_X11],
# Check for X Windows
#
# Check if the user has specified sysroot, but not --x-includes or --x-libraries.
# Make a simple check for the libraries at the sysroot, and setup --x-includes and
# --x-libraries for the sysroot, if that seems to be correct.
if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
if test "x$SYSROOT" != "x"; then
if test "x$x_includes" = xNONE; then
if test -f "$SYSROOT/usr/X11R6/include/X11/Xlib.h"; then
x_includes="$SYSROOT/usr/X11R6/include"
elif test -f "$SYSROOT/usr/include/X11/Xlib.h"; then
x_includes="$SYSROOT/usr/include"
if test "x$X11_NOT_NEEDED" = xyes; then
if test "x${with_x}" != x; then
AC_MSG_WARN([X11 is not used, so --with-x is ignored])
fi
X_CFLAGS=
X_LIBS=
else
# Check if the user has specified sysroot, but not --x-includes or --x-libraries.
# Make a simple check for the libraries at the sysroot, and setup --x-includes and
# --x-libraries for the sysroot, if that seems to be correct.
if test "x$OPENJDK_TARGET_OS" = "xlinux"; then
if test "x$SYSROOT" != "x"; then
if test "x$x_includes" = xNONE; then
if test -f "$SYSROOT/usr/X11R6/include/X11/Xlib.h"; then
x_includes="$SYSROOT/usr/X11R6/include"
elif test -f "$SYSROOT/usr/include/X11/Xlib.h"; then
x_includes="$SYSROOT/usr/include"
fi
fi
fi
if test "x$x_libraries" = xNONE; then
if test -f "$SYSROOT/usr/X11R6/lib/libX11.so"; then
x_libraries="$SYSROOT/usr/X11R6/lib"
elif test "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
x_libraries="$SYSROOT/usr/lib64"
elif test -f "$SYSROOT/usr/lib/libX11.so"; then
x_libraries="$SYSROOT/usr/lib"
if test "x$x_libraries" = xNONE; then
if test -f "$SYSROOT/usr/X11R6/lib/libX11.so"; then
x_libraries="$SYSROOT/usr/X11R6/lib"
elif test "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
x_libraries="$SYSROOT/usr/lib64"
elif test -f "$SYSROOT/usr/lib/libX11.so"; then
x_libraries="$SYSROOT/usr/lib"
fi
fi
fi
fi
fi
# Now let autoconf do it's magic
AC_PATH_X
AC_PATH_XTRA
# Now let autoconf do it's magic
AC_PATH_X
AC_PATH_XTRA
# AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
# this doesn't make sense so we remove it.
if test "x$COMPILE_TYPE" = xcross; then
X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
fi
# AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
# this doesn't make sense so we remove it.
if test "x$COMPILE_TYPE" = xcross; then
X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
fi
if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then
HELP_MSG_MISSING_DEPENDENCY([x11])
AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
fi
if test "x$no_x" = xyes; then
HELP_MSG_MISSING_DEPENDENCY([x11])
AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
fi
if test "x$OPENJDK_TARGET_OS" = xsolaris; then
OPENWIN_HOME="/usr/openwin"
X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions"
X_LIBS="-L$SYSROOT$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
-L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \
-R$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
-R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"
fi
if test "x$OPENJDK_TARGET_OS" = xsolaris; then
OPENWIN_HOME="/usr/openwin"
X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions"
X_LIBS="-L$SYSROOT$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
-L$SYSROOT$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR \
-R$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
-R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"
fi
AC_LANG_PUSH(C)
OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $SYSROOT_CFLAGS $X_CFLAGS"
AC_LANG_PUSH(C)
OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $SYSROOT_CFLAGS $X_CFLAGS"
# Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
[X11_A_OK=yes],
[X11_A_OK=no; break],
[
# include <X11/Xlib.h>
# include <X11/Xutil.h>
]
)
# Need to include Xlib.h and Xutil.h to avoid "present but cannot be compiled" warnings on Solaris 10
AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
[X11_HEADERS_OK=yes],
[X11_HEADERS_OK=no; break],
[
# include <X11/Xlib.h>
# include <X11/Xutil.h>
]
)
# If XLinearGradient isn't available in Xrender.h, signal that it needs to be
# defined in libawt_xawt.
AC_MSG_CHECKING([if XlinearGradient is defined in Xrender.h])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],
[[XLinearGradient x;]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
X_CFLAGS="$X_CFLAGS -DSOLARIS10_NO_XRENDER_STRUCTS"])
if test "x$X11_HEADERS_OK" = xno; then
HELP_MSG_MISSING_DEPENDENCY([x11])
AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
fi
CFLAGS="$OLD_CFLAGS"
AC_LANG_POP(C)
# If XLinearGradient isn't available in Xrender.h, signal that it needs to be
# defined in libawt_xawt.
AC_MSG_CHECKING([if XlinearGradient is defined in Xrender.h])
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([[#include <X11/extensions/Xrender.h>]],
[[XLinearGradient x;]])],
[AC_MSG_RESULT([yes])],
[AC_MSG_RESULT([no])
X_CFLAGS="$X_CFLAGS -DSOLARIS10_NO_XRENDER_STRUCTS"])
if test "x$X11_A_OK" = xno && test "x$X11_NOT_NEEDED" != xyes; then
HELP_MSG_MISSING_DEPENDENCY([x11])
AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
fi
CFLAGS="$OLD_CFLAGS"
AC_LANG_POP(C)
fi # X11_NOT_NEEDED
AC_SUBST(X_CFLAGS)
AC_SUBST(X_LIBS)
@ -264,7 +272,7 @@ AC_DEFUN([LIB_BUILD_FREETYPE],
fi
# Now check if configure found a version of 'msbuild.exe'
if test "x$BUILD_FREETYPE" = xyes && test "x$MSBUILD" == x ; then
AC_MSG_WARN([Can't find an msbuild.exe executable (you may try to install .NET 4.0) - ignoring --with-freetype-src])
AC_MSG_WARN([Can not find an msbuild.exe executable (you may try to install .NET 4.0) - ignoring --with-freetype-src])
BUILD_FREETYPE=no
fi
@ -335,27 +343,50 @@ AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE],
POTENTIAL_FREETYPE_LIB_PATH="$2"
METHOD="$3"
# First check if the files exists.
if test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
# We found an arbitrary include file. That's a good sign.
AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD])
FOUND_FREETYPE=yes
# Let's start with an optimistic view of the world :-)
FOUND_FREETYPE=yes
FREETYPE_LIB_NAME="${LIBRARY_PREFIX}freetype${SHARED_LIBRARY_SUFFIX}"
if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then
AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.])
# First look for the canonical freetype main include file ft2build.h.
if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
# Oh no! Let's try in the freetype2 directory. This is needed at least at Mac OS X Yosemite.
POTENTIAL_FREETYPE_INCLUDE_PATH="$POTENTIAL_FREETYPE_INCLUDE_PATH/freetype2"
if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
# Fail.
FOUND_FREETYPE=no
fi
fi
if test "x$FOUND_FREETYPE" = xyes; then
# Include file found, let's continue the sanity check.
AC_MSG_NOTICE([Found freetype include files at $POTENTIAL_FREETYPE_INCLUDE_PATH using $METHOD])
# Reset to default value
FREETYPE_BASE_NAME=freetype
FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}"
if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then
if test "x$OPENJDK_TARGET_OS" = xmacosx \
&& test -s "$POTENTIAL_FREETYPE_LIB_PATH/${LIBRARY_PREFIX}freetype.6${SHARED_LIBRARY_SUFFIX}"; then
# On Mac OS X Yosemite, the symlink from libfreetype.dylib to libfreetype.6.dylib disappeared. Check
# for the .6 version explicitly.
FREETYPE_BASE_NAME=freetype.6
FREETYPE_LIB_NAME="${LIBRARY_PREFIX}${FREETYPE_BASE_NAME}${SHARED_LIBRARY_SUFFIX}"
AC_MSG_NOTICE([Compensating for missing symlink by using version 6 explicitly])
else
AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.])
FOUND_FREETYPE=no
fi
else
if test "x$OPENJDK_TARGET_OS" = xwindows; then
# On Windows, we will need both .lib and .dll file.
if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/freetype.lib"; then
AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/freetype.lib. Ignoring location.])
if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib"; then
AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib. Ignoring location.])
FOUND_FREETYPE=no
fi
elif test "x$OPENJDK_TARGET_OS" = xsolaris \
&& test -s "$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR/$FREETYPE_LIB_NAME"; then
# Found lib in isa dir, use that instead.
POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR"
AC_MSG_NOTICE([Rewriting to use $POTENTIAL_FREETYPE_LIB_PATH instead])
fi
fi
fi
@ -392,6 +423,8 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling],
[disable bundling of the freetype library with the build result @<:@enabled on Windows or when using --with-freetype, disabled otherwise@:>@])])
# Need to specify explicitly since it needs to be overridden on some versions of macosx
FREETYPE_BASE_NAME=freetype
FREETYPE_CFLAGS=
FREETYPE_LIBS=
FREETYPE_BUNDLE_LIB_PATH=
@ -575,9 +608,9 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
if test "x$FREETYPE_LIBS" = x; then
BASIC_FIXUP_PATH(FREETYPE_LIB_PATH)
if test "x$OPENJDK_TARGET_OS" = xwindows; then
FREETYPE_LIBS="$FREETYPE_LIB_PATH/freetype.lib"
FREETYPE_LIBS="$FREETYPE_LIB_PATH/$FREETYPE_BASE_NAME.lib"
else
FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -lfreetype"
FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -l$FREETYPE_BASE_NAME"
fi
fi

View File

@ -1,36 +0,0 @@
#
# Copyright (c) 2011, 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.
#
CAT="@CAT@"
CD=cd
CP="@CP@"
DIFF="@DIFF@"
ECHO="@ECHO@"
FIND="@FIND@"
GREP="@GREP@"
RM="@RM@"
SED="@SED@"
POST_STRIP_CMD="@POST_STRIP_CMD@"

View File

@ -1,77 +0,0 @@
#!/bin/bash
#
# 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.
#
# The boot_cycle.sh script performs two complete image builds (no javadoc though....)
# where the second build uses the first build as the boot jdk.
#
# This is useful to verify that the build is self hoisting and assists
# in flushing out bugs. You can follow up with compare_objects.sh to check
# that the two boot_cycle_?/images/j2sdk are identical. They should be.
#
# Usage:
# Specify the configure arguments to boot_cycle.sh, for example:
#
# sh common/bin/boot_cycle.sh --enable-debug --with-jvm-variants=server
#
# The same arguments will be used for both builds, except of course --with-boot-jdk
# that will be adjusted to boot_cycle_1 for the second build.
SCRIPT_DIR=`pwd`/`dirname $0`
ROOT_DIR=`(cd $SCRIPT_DIR/../.. ; pwd)`
BUILD_DIR=$ROOT_DIR/build
mkdir -p $BUILD_DIR
AUTOCONF_DIR=`(cd $SCRIPT_DIR/../autoconf ; pwd)`
BOOT_CYCLE_1_DIR=$BUILD_DIR/boot_cycle_1
BOOT_CYCLE_2_DIR=$BUILD_DIR/boot_cycle_2
# Create the boot cycle dirs in the build directory.
mkdir -p $BOOT_CYCLE_1_DIR
mkdir -p $BOOT_CYCLE_2_DIR
cd $BOOT_CYCLE_1_DIR
# Configure!
sh $AUTOCONF_DIR/configure "$@"
# Now build!
make images
if ! test -x $BOOT_CYCLE_1_DIR/images/j2sdk-image/bin/java ; then
echo Failed to build the executable $BOOT_CYCLE_1_DIR/images/j2sdk-image/bin/java
exit 1
fi
cd $BOOT_CYCLE_2_DIR
# Pickup the configure arguments, but drop any --with-boot-jdk=....
# and add the correct --with-boot-jdk=...boot_cycle_1... at the end.
ARGUMENTS="`cat $BOOT_CYCLE_1_DIR/configure-arguments|sed 's/--with-boot-jdk=[^ ]*//'` --with-boot-jdk=$BOOT_CYCLE_1_DIR/images/j2sdk-image"
# Configure using these adjusted arguments.
sh $AUTOCONF_DIR/configure $ARGUMENTS
# Now build!
make images
if ! test -x $BOOT_CYCLE_2_DIR/images/j2sdk-image/bin/java ; then
echo Failed to build the final executable $BOOT_CYCLE_2_DIR/images/j2sdk-image/bin/java
exit 1
fi

View File

@ -1,235 +0,0 @@
#!/bin/bash
#
# 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.
#
# MANUAL
#
# ./common/bin/compare-objects.sh old_jdk_build_dir new_jdk_build_dir
#
# Compares object files
#
if [ "x$1" = "x-h" ] || [ "x$1" = "x--help" ] || [ "x$1" == "x" ]; then
echo "bash ./common/bin/compare-objects.sh old_jdk_build_dir new_jdk_build_dir <pattern>"
echo ""
echo "Compare object files"
echo ""
exit 10
fi
#######
#
# List of files (grep patterns) that are ignored
#
# 1) hotspot object files
IGNORE="-e hotspot"
# 2) various build artifacts: sizer.32.o sizer.64.o dummyodbc.o
# these are produced during build and then e.g run to produce other data
# i.e not directly put into build => safe to ignore
IGNORE="${IGNORE} -e sizer.32.o -e sizer.64.o"
IGNORE="${IGNORE} -e dummyodbc.o"
IGNORE="${IGNORE} -e genSolarisConstants.o"
IGNORE="${IGNORE} -e genUnixConstants.o"
OLD="$1"
NEW="$2"
shift; shift
PATTERN="$*"
if [ -f $NEW/spec.sh ]; then
. $NEW/spec.sh
elif [ -f $NEW/../../spec.sh ]; then
. $NEW/../../spec.sh
elif [ -f $OLD/spec.sh ]; then
. $OLD/spec.sh
elif [ -f $OLD/../../spec.sh ]; then
. $OLD/../../spec.sh
else
echo "Unable to find spec.sh"
echo "Giving up"
exit 1
fi
export COMPARE_ROOT=/tmp/cimages.$USER/objects
mkdir -p $COMPARE_ROOT
(${CD} $OLD && ${FIND} . -name '*.o') > $COMPARE_ROOT/list.old
(${CD} $NEW && ${FIND} . -name '*.o') > $COMPARE_ROOT/list.new
# On macosx JobjC is build in both i386 and x86_64 variant (universial binary)
# but new build only builds the x86_64
# Remove the 386 variants from comparison...to avoid "false" positives
${GREP} -v 'JObjC.dst/Objects-normal/i386' $COMPARE_ROOT/list.old > $COMPARE_ROOT/list.old.new
${CP} $COMPARE_ROOT/list.old $COMPARE_ROOT/list.old.full
${CP} $COMPARE_ROOT/list.old.new $COMPARE_ROOT/list.old
findnew() {
arg_1=$1
arg_2=$2
# special case 1 unpack-cmd => unpackexe
arg_1=`${ECHO} $arg_1 | ${SED} 's!unpack-cmd!unpackexe!g'`
arg_2=`${ECHO} $arg_2 | ${SED} 's!unpack-cmd!unpackexe!g'`
# special case 2 /JObjC.dst/ => /libjobjc/
arg_1=`${ECHO} $arg_1 | ${SED} 's!/JObjC.dst/!/libjobjc/!g'`
arg_2=`${ECHO} $arg_2 | ${SED} 's!/JObjC.dst/!/libjobjc/!g'`
full=`${ECHO} $arg_1 | ${SED} 's!\.!\\\.!g'`
medium=`${ECHO} $arg_1 | ${SED} 's!.*/\([^/]*/[^/]*\)!\1!'`
short=`${ECHO} $arg_2 | ${SED} 's!\.!\\\.!g'`
if [ "`${GREP} -c "/$full" $COMPARE_ROOT/list.new`" -eq 1 ]
then
${ECHO} $NEW/$arg_1
return
fi
if [ "`${GREP} -c "$medium" $COMPARE_ROOT/list.new`" -eq 1 ]
then
${GREP} "$medium" $COMPARE_ROOT/list.new
return
fi
if [ "`${GREP} -c "/$short" $COMPARE_ROOT/list.new`" -eq 1 ]
then
${GREP} "/$short" $COMPARE_ROOT/list.new
return
fi
# old style has "dir" before obj{64}
dir=`${ECHO} $arg_1 | ${SED} 's!.*/\([^/]*\)/obj[64]*.*!\1!g'`
if [ -n "$dir" -a "$dir" != "$arg_1" ]
then
if [ "`${GREP} $dir $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ]
then
${GREP} $dir $COMPARE_ROOT/list.new | ${GREP} "/$short"
return
fi
# Try with lib$dir/
if [ "`${GREP} "lib$dir/" $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ]
then
${GREP} "lib$dir/" $COMPARE_ROOT/list.new | ${GREP} "/$short"
return
fi
# Try with $dir_objs
if [ "`${GREP} "${dir}_objs" $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ]
then
${GREP} "${dir}_objs" $COMPARE_ROOT/list.new | ${GREP} "/$short"
return
fi
fi
# check for some specifics...
for i in demo hotspot jobjc
do
if [ "`${ECHO} $full | ${GREP} -c $i`" -gt 0 ]
then
if [ "`${GREP} $i $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ]
then
${GREP} $i $COMPARE_ROOT/list.new | ${GREP} "/$short"
return
fi
fi
done
# check for specific demo
demo=`${ECHO} $arg_1 | ${SED} 's!.*/demo/jvmti/\([^/]*\)/.*!\1!g'`
if [ -n "$demo" -a "$dir" != "$demo" ]
then
if [ "`${GREP} $demo $COMPARE_ROOT/list.new | ${GREP} -c "/$short"`" -eq 1 ]
then
${GREP} $demo $COMPARE_ROOT/list.new | ${GREP} "/$short"
return
fi
fi
return
}
compare() {
old=$1
new=$2
${DIFF} $old $new > /dev/null
res=$?
if [ $res -eq 0 ]
then
${ECHO} 0
return
fi
# check if stripped objects gives equality
${CP} $old $COMPARE_ROOT/`basename $old`.old
${CP} $new $COMPARE_ROOT/`basename $old`.new
${POST_STRIP_CMD} $COMPARE_ROOT/`basename $old`.old $COMPARE_ROOT/`basename $old`.new > /dev/null 2>&1
${DIFF} $COMPARE_ROOT/`basename $old`.old $COMPARE_ROOT/`basename $old`.new > /dev/null
res=$?
${RM} $COMPARE_ROOT/`basename $old`.old $COMPARE_ROOT/`basename $old`.new
if [ $res -eq 0 ]
then
${ECHO} S
return
fi
name=`basename $1 | ${SED} 's!\.o!!'`
cntold=`strings $old | ${GREP} -c $name`
cntnew=`strings $new | ${GREP} -c $name`
if [ $cntold -gt 0 -a $cntnew -gt 0 ]
then
${ECHO} F
return
fi
${ECHO} 1
}
for F in `${CAT} $COMPARE_ROOT/list.old`
do
if [ "${IGNORE}" ] && [ "`${ECHO} $F | ${GREP} ${IGNORE}`" ]
then
#
# skip ignored files
#
continue;
fi
if [ "$PATTERN" ] && [ `${ECHO} $F | ${GREP} -c $PATTERN` -eq 0 ]
then
continue;
fi
f=`basename $F`
o=$OLD/$F
n=`findnew $F $f`
if [ "$n" ]
then
n="$NEW/$n"
${ECHO} `compare $o $n` : $f : $o : $n
else
${ECHO} "- : $f : $o "
fi
done

View File

@ -280,3 +280,4 @@ cfdac5887952c2dd73c73a1d8d9aa880d0539bbf jdk9-b33
9bc2dbd3dfb8c9fa88e00056b8b93a81ee6d306e jdk9-b35
ffd90c81d4ef9d94d880fc852e2fc482ecd9b374 jdk9-b36
7e9add74ad50841fb39dae75db56374aefa1de4c jdk9-b37
8acf056126e819cf536eef02aee0f61f207a6b52 jdk9-b38

View File

@ -440,3 +440,4 @@ af46576a8d7cb4003028b8ee8bf408cfe227315b jdk9-b32
438cb613151c4bd290bb732697517cba1cafcb04 jdk9-b35
464ab653fbb17eb518d8ef60f8df301de7ef00d0 jdk9-b36
b1c2dd843f247a1db19e1e85eb62ca405f72dc26 jdk9-b37
c363a8b87e477ee45d6d3cb2a36cb365141bc596 jdk9-b38

View File

@ -280,3 +280,4 @@ b940ca3d2c7e8a279ca850706b89c2ad3a841e82 jdk9-b32
b9370464572fc663a38956047aa612d6e7854c3d jdk9-b35
61b4c9acaa58e482db6601ec5dc4fc3d2d8dbb55 jdk9-b36
48e4ec70cc1c8651e4a0324d91f193c4edd83af9 jdk9-b37
6c6b34477e93e6fb350035f73ed7c02266b78380 jdk9-b38

View File

@ -383,6 +383,8 @@ public class XMLDocumentFragmentScannerImpl
protected boolean foundBuiltInRefs = false;
/** Built-in reference character event */
protected boolean builtInRefCharacterHandled = false;
//skip element algorithm
static final short MAX_DEPTH_LIMIT = 5 ;
@ -1949,7 +1951,10 @@ public class XMLDocumentFragmentScannerImpl
fDocumentHandler.startGeneralEntity(entity, null, null, null);
}
fTempString.setValues(fSingleChar, 0, 1);
//fDocumentHandler.characters(fTempString, null);
if(!fIsCoalesce){
fDocumentHandler.characters(fTempString, null);
builtInRefCharacterHandled = true;
}
if (fNotifyBuiltInRefs) {
fDocumentHandler.endGeneralEntity(entity, null);
@ -3068,7 +3073,12 @@ public class XMLDocumentFragmentScannerImpl
//return CHARACTERS
if(fScannerState == SCANNER_STATE_BUILT_IN_REFS && !fIsCoalesce){
setScannerState(SCANNER_STATE_CONTENT);
return XMLEvent.CHARACTERS;
if (builtInRefCharacterHandled) {
builtInRefCharacterHandled = false;
return XMLEvent.ENTITY_REFERENCE;
} else {
return XMLEvent.CHARACTERS;
}
}
//if there was a text declaration, call next() it will be taken care.

View File

@ -283,3 +283,4 @@ e58d3ea638c3824f01547596b2a98aa5f77c4a5c jdk9-b30
afe0c89e2edbdfb1a7ceff3d9b3ff46c4186202f jdk9-b35
84803c3be7f79d29c7dc40749d7743675f64107a jdk9-b36
90de6ecbff46386a3f9d6f7ca876e7aa6381f50a jdk9-b37
dd4ba422dba858b1c3c4b38f49a3e514be4e2790 jdk9-b38

View File

@ -280,3 +280,4 @@ f0870554049807d3392bd7976ab114f7f2b7bafa jdk9-b27
e549291a0227031310fa91c574891f892d27f959 jdk9-b35
cdcf2e599e42935c2d1d19a24bb19e808aeb43b5 jdk9-b36
27c3345d6dce39a22c262f30bb1f0e0b00c3709e jdk9-b37
d2d745313c81d1fc01f426983b9f784ab1f750e8 jdk9-b38

View File

@ -29,12 +29,10 @@ import java.io.IOException;
import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.net.URL;
import java.security.AccessController;
import java.security.AccessControlContext;
import java.security.CodeSource;
import java.security.Policy;
import java.security.PrivilegedAction;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
@ -54,7 +52,6 @@ import java.util.concurrent.ConcurrentHashMap;
import sun.misc.CompoundEnumeration;
import sun.misc.Resource;
import sun.misc.URLClassPath;
import sun.misc.VM;
import sun.reflect.CallerSensitive;
import sun.reflect.Reflection;
import sun.reflect.misc.ReflectUtil;
@ -268,8 +265,8 @@ public abstract class ClassLoader {
// The packages defined in this class loader. Each package name is mapped
// to its corresponding Package object.
// @GuardedBy("itself")
private final HashMap<String, Package> packages = new HashMap<>();
private final ConcurrentHashMap<String, Package> packages
= new ConcurrentHashMap<>();
private static Void checkCreateClassLoader() {
SecurityManager security = System.getSecurityManager();
@ -1575,17 +1572,17 @@ public abstract class ClassLoader {
String implVendor, URL sealBase)
throws IllegalArgumentException
{
synchronized (packages) {
Package pkg = getPackage(name);
if (pkg != null) {
throw new IllegalArgumentException(name);
}
pkg = new Package(name, specTitle, specVersion, specVendor,
implTitle, implVersion, implVendor,
sealBase, this);
packages.put(name, pkg);
return pkg;
Package pkg = getPackage(name);
if (pkg != null) {
throw new IllegalArgumentException(name);
}
pkg = new Package(name, specTitle, specVersion, specVendor,
implTitle, implVersion, implVendor,
sealBase, this);
if (packages.putIfAbsent(name, pkg) != null) {
throw new IllegalArgumentException(name);
}
return pkg;
}
/**
@ -1601,26 +1598,13 @@ public abstract class ClassLoader {
* @since 1.2
*/
protected Package getPackage(String name) {
Package pkg;
synchronized (packages) {
pkg = packages.get(name);
}
Package pkg = packages.get(name);
if (pkg == null) {
if (parent != null) {
pkg = parent.getPackage(name);
} else {
pkg = Package.getSystemPackage(name);
}
if (pkg != null) {
synchronized (packages) {
Package pkg2 = packages.get(name);
if (pkg2 == null) {
packages.put(name, pkg);
} else {
pkg = pkg2;
}
}
}
}
return pkg;
}
@ -1635,22 +1619,18 @@ public abstract class ClassLoader {
* @since 1.2
*/
protected Package[] getPackages() {
Map<String, Package> map;
synchronized (packages) {
map = new HashMap<>(packages);
}
Package[] pkgs;
if (parent != null) {
pkgs = parent.getPackages();
} else {
pkgs = Package.getSystemPackages();
}
Map<String, Package> map = packages;
if (pkgs != null) {
map = new HashMap<>(packages);
for (Package pkg : pkgs) {
String pkgName = pkg.getName();
if (map.get(pkgName) == null) {
map.put(pkgName, pkg);
}
map.putIfAbsent(pkg.getName(), pkg);
}
}
return map.values().toArray(new Package[map.size()]);

View File

@ -26,27 +26,21 @@
package java.lang;
import java.lang.reflect.AnnotatedElement;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.net.MalformedURLException;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.JarInputStream;
import java.util.jar.Manifest;
import java.util.jar.Attributes;
import java.util.jar.Attributes.Name;
import java.util.jar.JarException;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import sun.net.www.ParseUtil;
import sun.reflect.CallerSensitive;
@ -538,17 +532,15 @@ public class Package implements java.lang.reflect.AnnotatedElement {
* Returns the loaded system package for the specified name.
*/
static Package getSystemPackage(String name) {
synchronized (pkgs) {
Package pkg = pkgs.get(name);
if (pkg == null) {
name = name.replace('.', '/').concat("/");
String fn = getSystemPackage0(name);
if (fn != null) {
pkg = defineSystemPackage(name, fn);
}
Package pkg = pkgs.get(name);
if (pkg == null) {
name = name.replace('.', '/').concat("/");
String fn = getSystemPackage0(name);
if (fn != null) {
pkg = defineSystemPackage(name, fn);
}
return pkg;
}
return pkg;
}
/*
@ -557,74 +549,98 @@ public class Package implements java.lang.reflect.AnnotatedElement {
static Package[] getSystemPackages() {
// First, update the system package map with new package names
String[] names = getSystemPackages0();
synchronized (pkgs) {
for (String name : names) {
for (String name : names) {
if (!pkgs.containsKey(name)) {
defineSystemPackage(name, getSystemPackage0(name));
}
return pkgs.values().toArray(new Package[pkgs.size()]);
}
return pkgs.values().toArray(new Package[pkgs.size()]);
}
private static Package defineSystemPackage(final String iname,
final String fn)
{
return AccessController.doPrivileged(new PrivilegedAction<Package>() {
public Package run() {
String name = iname;
// Get the cached code source url for the file name
URL url = urls.get(fn);
if (url == null) {
// URL not found, so create one
File file = new File(fn);
try {
url = ParseUtil.fileToEncodedURL(file);
} catch (MalformedURLException e) {
}
if (url != null) {
urls.put(fn, url);
// If loading a JAR file, then also cache the manifest
if (file.isFile()) {
mans.put(fn, loadManifest(fn));
}
}
}
// Convert to "."-separated package name
name = name.substring(0, name.length() - 1).replace('/', '.');
Package pkg;
Manifest man = mans.get(fn);
if (man != null) {
pkg = new Package(name, man, url, null);
} else {
pkg = new Package(name, null, null, null,
null, null, null, null, null);
}
pkgs.put(name, pkg);
return pkg;
}
});
// Convert to "."-separated package name
String name = iname.substring(0, iname.length() - 1).replace('/', '.');
// Creates a cached manifest for the file name, allowing
// only-once, lazy reads of manifest from jar files
CachedManifest cachedManifest = createCachedManifest(fn);
pkgs.putIfAbsent(name, new Package(name, cachedManifest.getManifest(),
cachedManifest.getURL(), null));
// Ensure we only expose one Package object
return pkgs.get(name);
}
/*
* Returns the Manifest for the specified JAR file name.
*/
private static Manifest loadManifest(String fn) {
try (FileInputStream fis = new FileInputStream(fn);
JarInputStream jis = new JarInputStream(fis, false))
{
return jis.getManifest();
} catch (IOException e) {
return null;
private static CachedManifest createCachedManifest(String fn) {
if (!manifests.containsKey(fn)) {
manifests.putIfAbsent(fn, new CachedManifest(fn));
}
return manifests.get(fn);
}
// The map of loaded system packages
private static Map<String, Package> pkgs = new HashMap<>(31);
private static final ConcurrentHashMap<String, Package> pkgs
= new ConcurrentHashMap<>();
// Maps each directory or zip file name to its corresponding url
private static Map<String, URL> urls = new HashMap<>(10);
// Maps each directory or zip file name to its corresponding manifest, if
// it exists
private static final ConcurrentHashMap<String, CachedManifest> manifests
= new ConcurrentHashMap<>();
// Maps each code source url for a jar file to its manifest
private static Map<String, Manifest> mans = new HashMap<>(10);
private static class CachedManifest {
private static final Manifest EMPTY_MANIFEST = new Manifest();
private final String fileName;
private final URL url;
private volatile Manifest manifest;
CachedManifest(final String fileName) {
this.fileName = fileName;
this.url = AccessController.doPrivileged(new PrivilegedAction<URL>() {
public URL run() {
final File file = new File(fileName);
if (file.isFile()) {
try {
return ParseUtil.fileToEncodedURL(file);
} catch (MalformedURLException e) {
}
}
return null;
}
});
}
public URL getURL() {
return url;
}
public Manifest getManifest() {
if (url == null) {
return EMPTY_MANIFEST;
}
Manifest m = manifest;
if (m != null) {
return m;
}
synchronized (this) {
m = manifest;
if (m != null) {
return m;
}
m = AccessController.doPrivileged(new PrivilegedAction<Manifest>() {
public Manifest run() {
try (FileInputStream fis = new FileInputStream(fileName);
JarInputStream jis = new JarInputStream(fis, false)) {
return jis.getManifest();
} catch (IOException e) {
return null;
}
}
});
manifest = m = (m == null ? EMPTY_MANIFEST : m);
}
return m;
}
}
private static native String getSystemPackage0(String name);
private static native String[] getSystemPackages0();

View File

@ -1388,16 +1388,26 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
Object a4, Object a5, Object a6, Object a7,
Object a8, Object a9)
{ return makeArray(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
private static final int ARRAYS_COUNT = 11;
private static MethodHandle[] makeArrays() {
ArrayList<MethodHandle> mhs = new ArrayList<>();
for (;;) {
MethodHandle mh = findCollector("array", mhs.size(), Object[].class);
if (mh == null) break;
MethodHandle[] mhs = new MethodHandle[MAX_ARITY + 1];
for (int i = 0; i < ARRAYS_COUNT; i++) {
MethodHandle mh = findCollector("array", i, Object[].class);
mh = makeIntrinsic(mh, Intrinsic.NEW_ARRAY);
mhs.add(mh);
mhs[i] = mh;
}
assert(mhs.size() == 11); // current number of methods
return mhs.toArray(new MethodHandle[MAX_ARITY+1]);
assert(assertArrayMethodCount(mhs));
return mhs;
}
private static boolean assertArrayMethodCount(MethodHandle[] mhs) {
assert(findCollector("array", ARRAYS_COUNT, Object[].class) == null);
for (int i = 0; i < ARRAYS_COUNT; i++) {
assert(mhs[i] != null);
}
return true;
}
// filling versions of the above:
@ -1449,15 +1459,22 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
private static final int FILL_ARRAYS_COUNT = 11; // current number of fillArray methods
private static MethodHandle[] makeFillArrays() {
ArrayList<MethodHandle> mhs = new ArrayList<>();
mhs.add(null); // there is no empty fill; at least a0 is required
for (;;) {
MethodHandle mh = findCollector("fillArray", mhs.size(), Object[].class, Integer.class, Object[].class);
if (mh == null) break;
mhs.add(mh);
MethodHandle[] mhs = new MethodHandle[FILL_ARRAYS_COUNT];
mhs[0] = null; // there is no empty fill; at least a0 is required
for (int i = 1; i < FILL_ARRAYS_COUNT; i++) {
MethodHandle mh = findCollector("fillArray", i, Object[].class, Integer.class, Object[].class);
mhs[i] = mh;
}
assert(mhs.size() == FILL_ARRAYS_COUNT);
return mhs.toArray(new MethodHandle[0]);
assert(assertFillArrayMethodCount(mhs));
return mhs;
}
private static boolean assertFillArrayMethodCount(MethodHandle[] mhs) {
assert(findCollector("fillArray", FILL_ARRAYS_COUNT, Object[].class, Integer.class, Object[].class) == null);
for (int i = 1; i < FILL_ARRAYS_COUNT; i++) {
assert(mhs[i] != null);
}
return true;
}
private static Object copyAsPrimitiveArray(Wrapper w, Object... boxes) {
@ -1472,9 +1489,6 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
static MethodHandle varargsArray(int nargs) {
MethodHandle mh = Lazy.ARRAYS[nargs];
if (mh != null) return mh;
mh = findCollector("array", nargs, Object[].class);
if (mh != null) mh = makeIntrinsic(mh, Intrinsic.NEW_ARRAY);
if (mh != null) return Lazy.ARRAYS[nargs] = mh;
mh = buildVarargsArray(Lazy.MH_fillNewArray, Lazy.MH_arrayIdentity, nargs);
assert(assertCorrectArity(mh, nargs));
mh = makeIntrinsic(mh, Intrinsic.NEW_ARRAY);

View File

@ -285,6 +285,53 @@ public abstract class Executable extends AccessibleObject
return getParameterTypes();
}
/**
* Behaves like {@code getGenericParameterTypes}, but returns type
* information for all parameters, including synthetic parameters.
*/
Type[] getAllGenericParameterTypes() {
final boolean genericInfo = hasGenericInformation();
// Easy case: we don't have generic parameter information. In
// this case, we just return the result of
// getParameterTypes().
if (!genericInfo) {
return getParameterTypes();
} else {
final boolean realParamData = hasRealParameterData();
final Type[] genericParamTypes = getGenericParameterTypes();
final Type[] nonGenericParamTypes = getParameterTypes();
final Type[] out = new Type[nonGenericParamTypes.length];
final Parameter[] params = getParameters();
int fromidx = 0;
// If we have real parameter data, then we use the
// synthetic and mandate flags to our advantage.
if (realParamData) {
for (int i = 0; i < out.length; i++) {
final Parameter param = params[i];
if (param.isSynthetic() || param.isImplicit()) {
// If we hit a synthetic or mandated parameter,
// use the non generic parameter info.
out[i] = nonGenericParamTypes[i];
} else {
// Otherwise, use the generic parameter info.
out[i] = genericParamTypes[fromidx];
fromidx++;
}
}
} else {
// Otherwise, use the non-generic parameter data.
// Without method parameter reflection data, we have
// no way to figure out which parameters are
// synthetic/mandated, thus, no way to match up the
// indexes.
return genericParamTypes.length == nonGenericParamTypes.length ?
genericParamTypes : nonGenericParamTypes;
}
return out;
}
}
/**
* Returns an array of {@code Parameter} objects that represent
* all the parameters to the underlying executable represented by
@ -646,7 +693,7 @@ public abstract class Executable extends AccessibleObject
getConstantPool(getDeclaringClass()),
this,
getDeclaringClass(),
getGenericParameterTypes(),
getAllGenericParameterTypes(),
TypeAnnotation.TypeAnnotationTarget.METHOD_FORMAL_PARAMETER);
}

View File

@ -198,7 +198,7 @@ public final class Parameter implements AnnotatedElement {
public Type getParameterizedType() {
Type tmp = parameterTypeCache;
if (null == tmp) {
tmp = executable.getGenericParameterTypes()[index];
tmp = executable.getAllGenericParameterTypes()[index];
parameterTypeCache = tmp;
}

View File

@ -446,6 +446,7 @@ public abstract class SocketImpl implements SocketOptions {
serverSocketOptions.add(StandardSocketOptions.SO_RCVBUF);
serverSocketOptions.add(StandardSocketOptions.SO_REUSEADDR);
serverSocketOptions.add(StandardSocketOptions.IP_TOS);
};
/**

View File

@ -276,6 +276,7 @@ public class Sockets {
set = new HashSet<>();
set.add(StandardSocketOptions.SO_RCVBUF);
set.add(StandardSocketOptions.SO_REUSEADDR);
set.add(StandardSocketOptions.IP_TOS);
set = Collections.unmodifiableSet(set);
options.put(ServerSocket.class, set);

View File

@ -32,7 +32,7 @@ import java.lang.reflect.Constructor;
bootstrapping. */
class BootstrapConstructorAccessorImpl extends ConstructorAccessorImpl {
private Constructor<?> constructor;
private final Constructor<?> constructor;
BootstrapConstructorAccessorImpl(Constructor<?> c) {
this.constructor = c;

View File

@ -33,7 +33,7 @@ import java.lang.reflect.InvocationTargetException;
class InstantiationExceptionConstructorAccessorImpl
extends ConstructorAccessorImpl {
private String message;
private final String message;
InstantiationExceptionConstructorAccessorImpl(String message) {
this.message = message;

View File

@ -47,10 +47,10 @@ class Label {
}
// This won't work for more than one assembler anyway, so this is
// unnecessary
ClassFileAssembler asm;
short instrBCI;
short patchBCI;
int stackDepth;
final ClassFileAssembler asm;
final short instrBCI;
final short patchBCI;
final int stackDepth;
}
private List<PatchInfo> patches = new ArrayList<>();

View File

@ -32,7 +32,7 @@ import sun.reflect.misc.ReflectUtil;
afterward, switches to bytecode-based implementation */
class NativeConstructorAccessorImpl extends ConstructorAccessorImpl {
private Constructor<?> c;
private final Constructor<?> c;
private DelegatingConstructorAccessorImpl parent;
private int numInvocations;

View File

@ -32,7 +32,7 @@ import sun.reflect.misc.ReflectUtil;
switches to bytecode-based implementation */
class NativeMethodAccessorImpl extends MethodAccessorImpl {
private Method method;
private final Method method;
private DelegatingMethodAccessorImpl parent;
private int numInvocations;

View File

@ -50,9 +50,9 @@ import sun.reflect.misc.ReflectUtil;
public class ReflectionFactory {
private static boolean initted = false;
private static Permission reflectionFactoryAccessPerm
private static final Permission reflectionFactoryAccessPerm
= new RuntimePermission("reflectionFactoryAccess");
private static ReflectionFactory soleInstance = new ReflectionFactory();
private static final ReflectionFactory soleInstance = new ReflectionFactory();
// Provides access to package-private mechanisms in java.lang.reflect
private static volatile LangReflectAccess langReflectAccess;

View File

@ -28,7 +28,7 @@ package sun.reflect;
/** Assists in iterating down a method's signature */
public class SignatureIterator {
private String sig;
private final String sig;
private int idx;
public SignatureIterator(String sig) {

View File

@ -45,8 +45,8 @@ import sun.reflect.generics.tree.FieldTypeSignature;
* core reflection (java.lang.reflect).
*/
public class CoreReflectionFactory implements GenericsFactory {
private GenericDeclaration decl;
private Scope scope;
private final GenericDeclaration decl;
private final Scope scope;
private CoreReflectionFactory(GenericDeclaration d, Scope s) {
decl = d;

View File

@ -34,7 +34,7 @@ import java.util.Objects;
*/
public class GenericArrayTypeImpl
implements GenericArrayType {
private Type genericComponentType;
private final Type genericComponentType;
// private constructor enforces use of static factory
private GenericArrayTypeImpl(Type ct) {

View File

@ -40,7 +40,7 @@ import sun.reflect.generics.visitor.Reifier;
*
*/
public abstract class LazyReflectiveObjectGenerator {
private GenericsFactory factory; // cached factory
private final GenericsFactory factory; // cached factory
protected LazyReflectiveObjectGenerator(GenericsFactory f) {
factory = f;

View File

@ -38,9 +38,9 @@ import java.util.Objects;
/** Implementing class for ParameterizedType interface. */
public class ParameterizedTypeImpl implements ParameterizedType {
private Type[] actualTypeArguments;
private Class<?> rawType;
private Type ownerType;
private final Type[] actualTypeArguments;
private final Class<?> rawType;
private final Type ownerType;
private ParameterizedTypeImpl(Class<?> rawType,
Type[] actualTypeArguments,

View File

@ -40,9 +40,9 @@ public abstract class AbstractRepository<T extends Tree> {
// A factory used to produce reflective objects. Provided when the
//repository is created. Will vary across implementations.
private GenericsFactory factory;
private final GenericsFactory factory;
private T tree; // the AST for the generic type info
private final T tree; // the AST for the generic type info
//accessors
private GenericsFactory getFactory() { return factory;}

View File

@ -41,7 +41,7 @@ import java.lang.reflect.TypeVariable;
public abstract class AbstractScope<D extends GenericDeclaration>
implements Scope {
private D recvr; // the declaration whose scope this instance represents
private final D recvr; // the declaration whose scope this instance represents
private Scope enclosingScope; // the enclosing scope of this scope
/**

View File

@ -38,7 +38,7 @@ import java.lang.reflect.TypeVariable;
public class DummyScope implements Scope {
// Caches the unique instance of this class; instances contain no data
// so we can use the singleton pattern
private static DummyScope singleton = new DummyScope();
private static final DummyScope singleton = new DummyScope();
// constructor is private to enforce use of factory method
private DummyScope(){}

View File

@ -28,7 +28,7 @@ package sun.reflect.generics.tree;
import sun.reflect.generics.visitor.TypeTreeVisitor;
public class ArrayTypeSignature implements FieldTypeSignature {
private TypeSignature componentType;
private final TypeSignature componentType;
private ArrayTypeSignature(TypeSignature ct) {componentType = ct;}

View File

@ -29,7 +29,7 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
/** AST that represents the type boolean. */
public class BooleanSignature implements BaseType {
private static BooleanSignature singleton = new BooleanSignature();
private static final BooleanSignature singleton = new BooleanSignature();
private BooleanSignature(){}

View File

@ -28,7 +28,7 @@ package sun.reflect.generics.tree;
import sun.reflect.generics.visitor.TypeTreeVisitor;
public class BottomSignature implements FieldTypeSignature {
private static BottomSignature singleton = new BottomSignature();
private static final BottomSignature singleton = new BottomSignature();
private BottomSignature(){}

View File

@ -29,7 +29,7 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
/** AST that represents the type byte. */
public class ByteSignature implements BaseType {
private static ByteSignature singleton = new ByteSignature();
private static final ByteSignature singleton = new ByteSignature();
private ByteSignature(){}

View File

@ -29,7 +29,7 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
/** AST that represents the type char. */
public class CharSignature implements BaseType {
private static CharSignature singleton = new CharSignature();
private static final CharSignature singleton = new CharSignature();
private CharSignature(){}

View File

@ -28,9 +28,9 @@ package sun.reflect.generics.tree;
import sun.reflect.generics.visitor.Visitor;
public class ClassSignature implements Signature {
private FormalTypeParameter[] formalTypeParams;
private ClassTypeSignature superclass;
private ClassTypeSignature[] superInterfaces;
private final FormalTypeParameter[] formalTypeParams;
private final ClassTypeSignature superclass;
private final ClassTypeSignature[] superInterfaces;
private ClassSignature(FormalTypeParameter[] ftps,
ClassTypeSignature sc,

View File

@ -33,7 +33,7 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
* AST representing class types.
*/
public class ClassTypeSignature implements FieldTypeSignature {
private List<SimpleClassTypeSignature> path;
private final List<SimpleClassTypeSignature> path;
private ClassTypeSignature(List<SimpleClassTypeSignature> p) {

View File

@ -29,7 +29,7 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
/** AST that represents the type double. */
public class DoubleSignature implements BaseType {
private static DoubleSignature singleton = new DoubleSignature();
private static final DoubleSignature singleton = new DoubleSignature();
private DoubleSignature(){}

View File

@ -29,7 +29,7 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
/** AST that represents the type float. */
public class FloatSignature implements BaseType {
private static FloatSignature singleton = new FloatSignature();
private static final FloatSignature singleton = new FloatSignature();
private FloatSignature(){}

View File

@ -29,8 +29,8 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
/** AST that represents a formal type parameter. */
public class FormalTypeParameter implements TypeTree {
private String name;
private FieldTypeSignature[] bounds;
private final String name;
private final FieldTypeSignature[] bounds;
private FormalTypeParameter(String n, FieldTypeSignature[] bs) {
name = n;

View File

@ -29,7 +29,7 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
/** AST that represents the type int. */
public class IntSignature implements BaseType {
private static IntSignature singleton = new IntSignature();
private static final IntSignature singleton = new IntSignature();
private IntSignature(){}

View File

@ -29,7 +29,7 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
/** AST that represents the type long. */
public class LongSignature implements BaseType {
private static LongSignature singleton = new LongSignature();
private static final LongSignature singleton = new LongSignature();
private LongSignature(){}

View File

@ -28,10 +28,10 @@ package sun.reflect.generics.tree;
import sun.reflect.generics.visitor.Visitor;
public class MethodTypeSignature implements Signature {
private FormalTypeParameter[] formalTypeParams;
private TypeSignature[] parameterTypes;
private ReturnType returnType;
private FieldTypeSignature[] exceptionTypes;
private final FormalTypeParameter[] formalTypeParams;
private final TypeSignature[] parameterTypes;
private final ReturnType returnType;
private final FieldTypeSignature[] exceptionTypes;
private MethodTypeSignature(FormalTypeParameter[] ftps,
TypeSignature[] pts,

View File

@ -29,7 +29,7 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
/** AST that represents the type short. */
public class ShortSignature implements BaseType {
private static ShortSignature singleton = new ShortSignature();
private static final ShortSignature singleton = new ShortSignature();
private ShortSignature(){}

View File

@ -28,9 +28,9 @@ package sun.reflect.generics.tree;
import sun.reflect.generics.visitor.TypeTreeVisitor;
public class SimpleClassTypeSignature implements FieldTypeSignature {
private boolean dollar;
private String name;
private TypeArgument[] typeArgs;
private final boolean dollar;
private final String name;
private final TypeArgument[] typeArgs;
private SimpleClassTypeSignature(String n, boolean dollar, TypeArgument[] tas) {
name = n;

View File

@ -28,7 +28,7 @@ package sun.reflect.generics.tree;
import sun.reflect.generics.visitor.TypeTreeVisitor;
public class TypeVariableSignature implements FieldTypeSignature {
private String identifier;
private final String identifier;
private TypeVariableSignature(String id) {identifier = id;}

View File

@ -30,7 +30,7 @@ import sun.reflect.generics.visitor.TypeTreeVisitor;
/** AST that represents the pseudo-type void. */
public class VoidDescriptor implements ReturnType {
private static VoidDescriptor singleton = new VoidDescriptor();
private static final VoidDescriptor singleton = new VoidDescriptor();
private VoidDescriptor(){}

View File

@ -76,9 +76,9 @@ class Trampoline {
* Create a trampoline class.
*/
public final class MethodUtil extends SecureClassLoader {
private static String MISC_PKG = "sun.reflect.misc.";
private static String TRAMPOLINE = MISC_PKG + "Trampoline";
private static Method bounce = getTrampoline();
private static final String MISC_PKG = "sun.reflect.misc.";
private static final String TRAMPOLINE = MISC_PKG + "Trampoline";
private static final Method bounce = getTrampoline();
private MethodUtil() {
super();

View File

@ -1608,7 +1608,7 @@ public final class Main {
private static String getCompatibleSigAlgName(String keyAlgName)
throws Exception {
if ("DSA".equalsIgnoreCase(keyAlgName)) {
return "SHA1WithDSA";
return "SHA256WithDSA";
} else if ("RSA".equalsIgnoreCase(keyAlgName)) {
return "SHA256WithRSA";
} else if ("EC".equalsIgnoreCase(keyAlgName)) {
@ -1628,10 +1628,8 @@ public final class Main {
if (keysize == -1) {
if ("EC".equalsIgnoreCase(keyAlgName)) {
keysize = 256;
} else if ("RSA".equalsIgnoreCase(keyAlgName)) {
keysize = 2048;
} else {
keysize = 1024;
keysize = 2048; // RSA and DSA
}
}

View File

@ -83,9 +83,9 @@ Java_java_nio_MappedByteBuffer_force0(JNIEnv *env, jobject obj, jobject fdo,
HANDLE h;
if (handle_fdID == NULL) {
jclass clazz = (*env)->FindClass(env, "java/io/FileDescriptor");
if (clazz == NULL)
return; // exception thrown
CHECK_NULL(clazz); //exception thrown
handle_fdID = (*env)->GetFieldID(env, clazz, "handle", "J");
CHECK_NULL(handle_fdID);
}
h = jlong_to_ptr((*env)->GetLongField(env, fdo, handle_fdID));
result = FlushFileBuffers(h);

View File

@ -205,28 +205,4 @@ public class JmxProperties {
*/
public static final Logger MISC_LOGGER =
Logger.getLogger(MISC_LOGGER_NAME);
/**
* Logger name for SNMP.
*/
public static final String SNMP_LOGGER_NAME =
"javax.management.snmp";
/**
* Logger for SNMP.
*/
public static final Logger SNMP_LOGGER =
Logger.getLogger(SNMP_LOGGER_NAME);
/**
* Logger name for SNMP Adaptor.
*/
public static final String SNMP_ADAPTOR_LOGGER_NAME =
"javax.management.snmp.daemon";
/**
* Logger for SNMP Adaptor.
*/
public static final Logger SNMP_ADAPTOR_LOGGER =
Logger.getLogger(SNMP_ADAPTOR_LOGGER_NAME);
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@ -25,7 +25,6 @@
package com.sun.management;
import java.util.List;
import java.lang.management.PlatformManagedObject;
/**
@ -109,7 +108,7 @@ public interface HotSpotDiagnosticMXBean extends PlatformManagedObject {
* @throws IllegalArgumentException if the VM option of the given name
* does not exist.
* @throws IllegalArgumentException if the new value is invalid.
* @throws IllegalArgumentException if the VM option is not writeable.
* @throws IllegalArgumentException if the VM option is not writable.
* @throws NullPointerException if name or value is <tt>null</tt>.
*
* @throws java.lang.SecurityException

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -110,6 +110,7 @@ class Flag {
// These set* methods are synchronized on the class object
// to avoid multiple threads updating the same flag at the same time.
static synchronized native void setLongValue(String name, long value);
static synchronized native void setDoubleValue(String name, double value);
static synchronized native void setBooleanValue(String name, boolean value);
static synchronized native void setStringValue(String name, String value);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@ -40,6 +40,7 @@ public class HotSpotDiagnostic implements HotSpotDiagnosticMXBean {
public HotSpotDiagnostic() {
}
@Override
public void dumpHeap(String outputFile, boolean live) throws IOException {
SecurityManager security = System.getSecurityManager();
if (security != null) {
@ -52,6 +53,7 @@ public class HotSpotDiagnostic implements HotSpotDiagnosticMXBean {
private native void dumpHeap0(String outputFile, boolean live) throws IOException;
@Override
public List<VMOption> getDiagnosticOptions() {
List<Flag> allFlags = Flag.getAllFlags();
List<VMOption> result = new ArrayList<>();
@ -63,6 +65,7 @@ public class HotSpotDiagnostic implements HotSpotDiagnosticMXBean {
return result;
}
@Override
public VMOption getVMOption(String name) {
if (name == null) {
throw new NullPointerException("name cannot be null");
@ -76,6 +79,7 @@ public class HotSpotDiagnostic implements HotSpotDiagnosticMXBean {
return f.getVMOption();
}
@Override
public void setVMOption(String name, String value) {
if (name == null) {
throw new NullPointerException("name cannot be null");
@ -102,12 +106,18 @@ public class HotSpotDiagnostic implements HotSpotDiagnosticMXBean {
long l = Long.parseLong(value);
Flag.setLongValue(name, l);
} catch (NumberFormatException e) {
IllegalArgumentException iae =
new IllegalArgumentException("Invalid value:" +
throw new IllegalArgumentException("Invalid value:" +
" VM Option \"" + name + "\"" +
" expects numeric value");
iae.initCause(e);
throw iae;
" expects numeric value", e);
}
} else if (v instanceof Double) {
try {
double d = Double.parseDouble(value);
Flag.setDoubleValue(name, d);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Invalid value:" +
" VM Option \"" + name + "\"" +
" expects numeric value", e);
}
} else if (v instanceof Boolean) {
if (!value.equalsIgnoreCase("true") &&
@ -126,6 +136,7 @@ public class HotSpotDiagnostic implements HotSpotDiagnosticMXBean {
}
}
@Override
public ObjectName getObjectName() {
return Util.newObjectName("com.sun.management:type=HotSpotDiagnostic");
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -143,7 +143,8 @@ typedef enum {
JMM_VMGLOBAL_TYPE_UNKNOWN = 0,
JMM_VMGLOBAL_TYPE_JBOOLEAN = 1,
JMM_VMGLOBAL_TYPE_JSTRING = 2,
JMM_VMGLOBAL_TYPE_JLONG = 3
JMM_VMGLOBAL_TYPE_JLONG = 3,
JMM_VMGLOBAL_TYPE_JDOUBLE = 4
} jmmVMGlobalType;
typedef enum {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -133,6 +133,10 @@ Java_sun_management_Flag_getFlags
valueObj = JNU_NewObjectByName(env, "java/lang/Long", "(J)V",
globals[i].value.j);
break;
case JMM_VMGLOBAL_TYPE_JDOUBLE:
valueObj = JNU_NewObjectByName(env, "java/lang/Double", "(D)V",
globals[i].value.d);
break;
default:
// ignore unsupported type
continue;
@ -201,6 +205,16 @@ Java_sun_management_Flag_setLongValue
jmm_interface->SetVMGlobal(env, name, v);
}
JNIEXPORT void JNICALL
Java_sun_management_Flag_setDoubleValue
(JNIEnv *env, jclass cls, jstring name, jdouble value)
{
jvalue v;
v.d = value;
jmm_interface->SetVMGlobal(env, name, v);
}
JNIEXPORT void JNICALL
Java_sun_management_Flag_setBooleanValue
(JNIEnv *env, jclass cls, jstring name, jboolean value)

View File

@ -141,8 +141,8 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Encrypt
(CK_BYTE_PTR)(outBufP + jOutOfs),
&ckEncryptedPartLen);
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
ckAssertReturnValueOK(env, rv);
return ckEncryptedPartLen;
@ -214,7 +214,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptUpdate
}
if (directOut == 0) {
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
}
ckAssertReturnValueOK(env, rv);
@ -266,7 +266,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1EncryptFinal
//printf("EF: ckLastEncryptedPartLen=%i", ckLastEncryptedPartLen);
if (directOut == 0) {
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
}
ckAssertReturnValueOK(env, rv);
@ -361,8 +361,8 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1Decrypt
(CK_BYTE_PTR)(outBufP + jOutOfs),
&ckPartLen);
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, jIn, inBufP, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
ckAssertReturnValueOK(env, rv);
@ -429,7 +429,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptUpdate
}
if (directOut == 0) {
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
}
ckAssertReturnValueOK(env, rv);
@ -478,7 +478,7 @@ Java_sun_security_pkcs11_wrapper_PKCS11_C_1DecryptFinal
&ckLastPartLen);
if (directOut == 0) {
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_ABORT);
(*env)->ReleasePrimitiveArrayCritical(env, jOut, outBufP, JNI_COMMIT);
}

View File

@ -294,11 +294,11 @@ public final class KeychainStore extends KeyStoreSpi {
if (entry instanceof TrustedCertEntry) {
return ((TrustedCertEntry)entry).cert;
} else {
if (((KeyEntry)entry).chain == null) {
KeyEntry ke = (KeyEntry)entry;
if (ke.chain == null || ke.chain.length == 0) {
return null;
} else {
return ((KeyEntry)entry).chain[0];
}
return ke.chain[0];
}
} else {
return null;
@ -618,10 +618,12 @@ public final class KeychainStore extends KeyStoreSpi {
Object entry = entries.get(alias);
if (entry instanceof TrustedCertEntry) {
certElem = ((TrustedCertEntry)entry).cert;
} else if (((KeyEntry)entry).chain != null) {
certElem = ((KeyEntry)entry).chain[0];
} else {
continue;
KeyEntry ke = (KeyEntry)entry;
if (ke.chain == null || ke.chain.length == 0) {
continue;
}
certElem = ke.chain[0];
}
if (certElem.equals(cert)) {
return alias;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, 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
@ -279,7 +279,8 @@ static void addIdentitiesToKeystore(JNIEnv *env, jobject keyStore)
// Search the user keychain list for all identities. Identities are a certificate/private key association that
// can be chosen for a purpose such as signing or an SSL connection.
SecIdentitySearchRef identitySearch = NULL;
OSStatus err = SecIdentitySearchCreate(NULL, CSSM_KEYUSE_ANY, &identitySearch);
// Pass 0 if you want all identities returned by this search
OSStatus err = SecIdentitySearchCreate(NULL, 0, &identitySearch);
SecIdentityRef theIdentity = NULL;
OSErr searchResult = noErr;

View File

@ -2358,7 +2358,7 @@ class SignatureFile {
if (sigalg == null) {
if (keyAlgorithm.equalsIgnoreCase("DSA"))
signatureAlgorithm = "SHA1withDSA";
signatureAlgorithm = "SHA256withDSA";
else if (keyAlgorithm.equalsIgnoreCase("RSA"))
signatureAlgorithm = "SHA256withRSA";
else if (keyAlgorithm.equalsIgnoreCase("EC"))

View File

@ -1400,7 +1400,13 @@ class ToolWindow extends JFrame {
if (t instanceof NoDisplayException) {
return;
}
displayErrorDialog(w, t.toString());
if (t.getClass() == Exception.class) {
// Exception is usually thrown inside policytool for user
// interaction error. There is no need to show the type.
displayErrorDialog(w, t.getLocalizedMessage());
} else {
displayErrorDialog(w, t.toString());
}
}
/**

View File

@ -138,9 +138,6 @@ com/sun/management/GarbageCollectorMXBean/GarbageCollectionNotificationTest.java
# 8058492
java/lang/management/ThreadMXBean/FindDeadlocks.java generic-all
# 8058506
java/lang/management/ThreadMXBean/ThreadMXBeanStateTest.java generic-all
############################################################################
# jdk_jmx
@ -285,6 +282,9 @@ com/sun/jdi/JdbReadTwiceTest.sh generic-all
# 8058616
com/sun/jdi/RedefinePop.sh generic-all
# 8061114
com/sun/jdi/Redefine-g.sh generic-all
############################################################################
# jdk_util
@ -318,4 +318,7 @@ sun/tools/jps/TestJpsJarRelative.java generic-all
# 8057732
sun/jvmstat/monitor/MonitoredVm/MonitorVmStartTerminate.java generic-all
# 8060736
sun/jvmstat/monitor/MonitoredVm/CR6672135.java generic-all
############################################################################

View File

@ -46,8 +46,7 @@ import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.TimeUnit.NANOSECONDS;
public class LdapTimeoutTest {
private static final ScheduledExecutorService pool =
Executors.newScheduledThreadPool(1);
static volatile int passed = 0, failed = 0;
static void pass() {passed++;}
static void fail() {failed++; Thread.dumpStack();}
@ -80,7 +79,6 @@ public class LdapTimeoutTest {
new LdapTimeoutTest().simpleAuthConnectTest(env);
} finally {
s.interrupt();
LdapTimeoutTest.pool.shutdown();
}
System.out.printf("%nPassed = %d, failed = %d%n%n", passed, failed);
@ -90,7 +88,6 @@ public class LdapTimeoutTest {
void ldapReadTimeoutTest(Hashtable env, boolean ssl) {
InitialContext ctx = null;
if (ssl) env.put(Context.SECURITY_PROTOCOL, "ssl");
ScheduledFuture killer = killSwitch(5_000);
long start = System.nanoTime();
try {
ctx = new InitialDirContext(env);
@ -112,13 +109,12 @@ public class LdapTimeoutTest {
pass();
}
} finally {
if (!shutItDown(killer, ctx)) fail();
if (!shutItDown(ctx)) fail();
}
}
void simpleAuthConnectTest(Hashtable env) {
InitialContext ctx = null;
ScheduledFuture killer = killSwitch(5_000);
long start = System.nanoTime();
try {
ctx = new InitialDirContext(env);
@ -141,13 +137,12 @@ public class LdapTimeoutTest {
fail();
}
} finally {
if (!shutItDown(killer, ctx)) fail();
if (!shutItDown(ctx)) fail();
}
}
void deadServerNoTimeout(Hashtable env) {
InitialContext ctx = null;
ScheduledFuture killer = killSwitch(30_000);
long start = System.currentTimeMillis();
try {
ctx = new InitialDirContext(env);
@ -169,12 +164,11 @@ public class LdapTimeoutTest {
pass();
}
} finally {
if (!shutItDown(killer, ctx)) fail();
if (!shutItDown(ctx)) fail();
}
}
boolean shutItDown(ScheduledFuture killer, InitialContext ctx) {
killer.cancel(true);
boolean shutItDown(InitialContext ctx) {
try {
if (ctx != null) ctx.close();
return true;
@ -183,17 +177,6 @@ public class LdapTimeoutTest {
}
}
ScheduledFuture killSwitch(int ms) {
final Thread current = Thread.currentThread();
return LdapTimeoutTest.pool.schedule(new Callable<Void>() {
public Void call() throws Exception {
System.err.println("Fail: killSwitch()");
System.exit(0);
return null;
}
}, ms, MILLISECONDS);
}
static class Server extends Thread {
final ServerSocket serverSock;

View File

@ -0,0 +1,65 @@
/*
* 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.
*
* 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 8061616
* @summary Basic Test for HotSpotDiagnosticMXBean.getVMOption() and double values
* @author Jaroslav Bachorik
*
* @run main/othervm -XX:CompileThresholdScaling=0.14 GetDoubleVMOption
*/
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
import java.lang.management.ManagementFactory;
import java.util.List;
import javax.management.MBeanServer;
public class GetDoubleVMOption {
private static final String COMPILE_THRESHOLD_SCALING = "CompileThresholdScaling";
private static final String EXPECTED_VALUE = "0.14";
private static final String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
"com.sun.management:type=HotSpotDiagnostic";
public static void main(String[] args) throws Exception {
List<HotSpotDiagnosticMXBean> list =
ManagementFactory.getPlatformMXBeans(HotSpotDiagnosticMXBean.class);
HotSpotDiagnosticMXBean mbean = list.get(0);
checkVMOption(mbean);
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
mbean = ManagementFactory.newPlatformMXBeanProxy(mbs,
HOTSPOT_DIAGNOSTIC_MXBEAN_NAME,
HotSpotDiagnosticMXBean.class);
checkVMOption(mbean);
}
private static void checkVMOption(HotSpotDiagnosticMXBean mbean) {
VMOption option = mbean.getVMOption(COMPILE_THRESHOLD_SCALING);
if (!option.getValue().equalsIgnoreCase(EXPECTED_VALUE)) {
throw new RuntimeException("Unexpected value: " +
option.getValue() + " expected: " + EXPECTED_VALUE);
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2008, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@ -32,16 +32,15 @@
import com.sun.management.HotSpotDiagnosticMXBean;
import com.sun.management.VMOption;
import com.sun.management.VMOption.Origin;
import java.lang.management.ManagementFactory;
import java.util.List;
import javax.management.MBeanServer;
public class GetVMOption {
private static String PRINT_GC_DETAILS = "PrintGCDetails";
private static String EXPECTED_VALUE = "true";
private static String BAD_OPTION = "BadOption";
private static String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
private static final String PRINT_GC_DETAILS = "PrintGCDetails";
private static final String EXPECTED_VALUE = "true";
private static final String BAD_OPTION = "BadOption";
private static final String HOTSPOT_DIAGNOSTIC_MXBEAN_NAME =
"com.sun.management:type=HotSpotDiagnostic";
public static void main(String[] args) throws Exception {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@ -39,11 +39,11 @@ import com.sun.management.VMOption;
import com.sun.management.VMOption.Origin;
public class SetVMOption {
private static String PRINT_GC_DETAILS = "PrintGCDetails";
private static String EXPECTED_VALUE = "true";
private static String BAD_VALUE = "yes";
private static String NEW_VALUE = "false";
private static String MANAGEMENT_SERVER = "ManagementServer";
private static final String PRINT_GC_DETAILS = "PrintGCDetails";
private static final String EXPECTED_VALUE = "true";
private static final String BAD_VALUE = "yes";
private static final String NEW_VALUE = "false";
private static final String MANAGEMENT_SERVER = "ManagementServer";
private static HotSpotDiagnosticMXBean mbean;
public static void main(String[] args) throws Exception {

View File

@ -0,0 +1,3 @@
//NoPermission Test
grant{
};

View File

@ -0,0 +1,249 @@
/*
* 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.
*
* 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 8060130
* @library /lib/testlibrary
* @build package2.Class2 GetSystemPackage jdk.testlibrary.*
* @summary Test if getSystemPackage() return consistent values for cases
* where a manifest is provided or not and ensure only jars on
* bootclasspath gets resolved via Package.getSystemPackage
* @run main GetSystemPackage
*/
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.jar.Attributes;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
import java.util.jar.Manifest;
import jdk.testlibrary.ProcessTools;
public class GetSystemPackage {
static final String testClassesDir = System.getProperty("test.classes", ".");
static final File tmpFolder = new File(testClassesDir);
static final String manifestTitle = "Special JAR";
public static void main(String ... args) throws Exception {
if (args.length == 0) {
buildJarsAndInitiateSystemPackageTest();
return;
}
switch (args[0]) {
case "system-manifest":
verifyPackage(true, true);
break;
case "system-no-manifest":
verifyPackage(false, true);
break;
case "non-system-manifest":
verifyPackage(true, false);
break;
case "non-system-no-manifest":
default:
verifyPackage(false, false);
break;
}
}
private static void buildJarsAndInitiateSystemPackageTest()
throws Exception
{
Manifest m = new Manifest();
// not setting MANIFEST_VERSION prevents META-INF/MANIFEST.MF from
// getting written
m.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
m.getMainAttributes().put(Attributes.Name.SPECIFICATION_TITLE,
manifestTitle);
buildJar("manifest.jar", m);
buildJar("no-manifest.jar", null);
runSubProcess("System package with manifest improperly resolved.",
"-Xbootclasspath/p:" + testClassesDir + "/manifest.jar",
"GetSystemPackage", "system-manifest");
runSubProcess("System package from directory improperly resolved.",
"-Xbootclasspath/p:" + testClassesDir, "GetSystemPackage",
"system-no-manifest");
runSubProcess("System package with no manifest improperly resolved",
"-Xbootclasspath/p:" + testClassesDir + "/no-manifest.jar",
"GetSystemPackage", "system-no-manifest");
runSubProcess("Classpath package with manifest improperly resolved",
"-cp", testClassesDir + "/manifest.jar", "GetSystemPackage",
"non-system-manifest");
runSubProcess("Classpath package with no manifest improperly resolved",
"-cp", testClassesDir + "/no-manifest.jar", "GetSystemPackage",
"non-system-no-manifest");
}
private static void buildJar(String name, Manifest man) throws Exception {
JarBuilder jar = new JarBuilder(tmpFolder, name, man);
jar.addClassFile("package2/Class2.class",
testClassesDir + "/package2/Class2.class");
jar.addClassFile("GetSystemPackage.class",
testClassesDir + "/GetSystemPackage.class");
jar.addClassFile("GetSystemPackageClassLoader.class",
testClassesDir + "/GetSystemPackageClassLoader.class");
jar.build();
}
private static void runSubProcess(String messageOnError, String ... args)
throws Exception
{
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(args);
int res = pb.directory(tmpFolder).inheritIO().start().waitFor();
if (res != 0) {
throw new RuntimeException(messageOnError);
}
}
private static void verifyPackage(boolean hasManifest,
boolean isSystemPackage) throws Exception
{
Class c = Class.forName("package2.Class2");
Package pkg = c.getPackage();
if (pkg == null || pkg != Package.getPackage("package2") ||
!"package2".equals(pkg.getName())) {
fail("package2 not found via Package.getPackage()");
}
String specificationTitle = pkg.getSpecificationTitle();
if (!"package2".equals(pkg.getName())) {
fail("Invalid package for Class2");
}
if (hasManifest && (specificationTitle == null
|| !manifestTitle.equals(specificationTitle))) {
fail("Invalid manifest for package " + pkg.getName());
}
if (!hasManifest && specificationTitle != null) {
fail("Invalid manifest for package " + pkg.getName() + ": was " +
specificationTitle + " expected: null");
}
// force the use of a classloader with no parent, then retrieve the
// package in a way that bypasses the classloader pkg maps
GetSystemPackageClassLoader classLoader =
new GetSystemPackageClassLoader();
Package systemPkg = classLoader.getSystemPackage("package2");
if (findPackage("java.lang") == null) {
fail("java.lang not found via Package.getPackages()");
}
Package foundPackage = findPackage("package2");
if (isSystemPackage) {
if (systemPkg == null) {
fail("System package could not be found via getSystemPackage");
}
if (foundPackage != systemPkg || systemPkg != pkg) {
fail("Inconsistent package found via Package.getPackages()");
}
} else {
if (systemPkg != null) {
fail("Non-system package could be found via getSystemPackage");
}
if (foundPackage == null) {
fail("Non-system package not found via Package.getPackages()");
}
}
}
private static Package findPackage(String name) {
Package[] packages = Package.getPackages();
for (Package p : packages) {
System.out.println(p);
if (p.getName().equals(name)) {
return p;
}
}
return null;
}
private static void fail(String message) {
throw new RuntimeException(message);
}
}
/*
* This classloader bypasses the system classloader to give as direct access
* to Package.getSystemPackage() as possible
*/
class GetSystemPackageClassLoader extends ClassLoader {
public GetSystemPackageClassLoader() {
super(null);
}
public Package getSystemPackage(String name) {
return super.getPackage(name);
}
}
/*
* Helper class for building jar files
*/
class JarBuilder {
private JarOutputStream os;
public JarBuilder(File tmpFolder, String jarName, Manifest manifest)
throws FileNotFoundException, IOException
{
File jarFile = new File(tmpFolder, jarName);
if (manifest != null) {
this.os = new JarOutputStream(new FileOutputStream(jarFile),
manifest);
} else {
this.os = new JarOutputStream(new FileOutputStream(jarFile));
}
}
public void addClassFile(String pathFromRoot, String file)
throws IOException
{
byte[] buf = new byte[1024];
try (FileInputStream in = new FileInputStream(file)) {
JarEntry entry = new JarEntry(pathFromRoot);
os.putNextEntry(entry);
int len;
while ((len = in.read(buf)) > 0) {
os.write(buf, 0, len);
}
os.closeEntry();
}
}
public void build() throws IOException {
os.close();
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 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
@ -27,6 +27,8 @@ import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.LockSupport;
import jdk.testlibrary.LockFreeLogManager;
/**
* ThreadStateController allows a thread to request this thread to transition
* to a specific thread state. The {@linkplain #transitionTo request} is
@ -94,8 +96,12 @@ public class ThreadStateController extends Thread {
private static final int S_TERMINATE = 8;
// for debugging
private AtomicInteger iterations = new AtomicInteger();
private AtomicInteger interrupted = new AtomicInteger();
private final AtomicInteger iterations = new AtomicInteger();
private final AtomicInteger interrupted = new AtomicInteger();
private final LockFreeLogManager logManager = new LockFreeLogManager();
@Override
public void run() {
// this thread has started
while (!done) {
@ -119,13 +125,13 @@ public class ThreadStateController extends Thread {
break;
}
case S_BLOCKED: {
System.out.format("%d: %s is going to block (interations %d)%n",
getId(), getName(), iterations.get());
log("%d: %s is going to block (iterations %d)%n",
getId(), getName(), iterations.get());
stateChange(nextState);
// going to block on lock
synchronized (lock) {
System.out.format("%d: %s acquired the lock (interations %d)%n",
getId(), getName(), iterations.get());
log("%d: %s acquired the lock (iterations %d)%n",
getId(), getName(), iterations.get());
try {
// this thread has escaped the BLOCKED state
// release the lock and a short wait before continue
@ -139,13 +145,13 @@ public class ThreadStateController extends Thread {
}
case S_WAITING: {
synchronized (lock) {
System.out.format("%d: %s is going to waiting (interations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get());
log("%d: %s is going to waiting (iterations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get());
try {
stateChange(nextState);
lock.wait();
System.out.format("%d: %s wakes up from waiting (interations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get());
log("%d: %s wakes up from waiting (iterations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get());
} catch (InterruptedException e) {
// ignore
interrupted.incrementAndGet();
@ -155,13 +161,13 @@ public class ThreadStateController extends Thread {
}
case S_TIMED_WAITING: {
synchronized (lock) {
System.out.format("%d: %s is going to timed waiting (interations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get());
log("%d: %s is going to timed waiting (iterations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get());
try {
stateChange(nextState);
lock.wait(10000);
System.out.format("%d: %s wakes up from timed waiting (interations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get());
log("%d: %s wakes up from timed waiting (iterations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get());
} catch (InterruptedException e) {
// ignore
interrupted.incrementAndGet();
@ -170,23 +176,23 @@ public class ThreadStateController extends Thread {
break;
}
case S_PARKED: {
System.out.format("%d: %s is going to park (interations %d)%n",
getId(), getName(), iterations.get());
log("%d: %s is going to park (iterations %d)%n",
getId(), getName(), iterations.get());
stateChange(nextState);
LockSupport.park();
break;
}
case S_TIMED_PARKED: {
System.out.format("%d: %s is going to timed park (interations %d)%n",
getId(), getName(), iterations.get());
log("%d: %s is going to timed park (iterations %d)%n",
getId(), getName(), iterations.get());
long deadline = System.currentTimeMillis() + 10000*1000;
stateChange(nextState);
LockSupport.parkUntil(deadline);
break;
}
case S_SLEEPING: {
System.out.format("%d: %s is going to sleep (interations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get());
log("%d: %s is going to sleep (iterations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get());
try {
stateChange(nextState);
Thread.sleep(1000000);
@ -219,8 +225,8 @@ public class ThreadStateController extends Thread {
if (newState == nextState) {
state = nextState;
phaser.arrive();
System.out.format("%d: state change: %s %s%n",
getId(), toStateName(nextState), phaserToString(phaser));
log("%d: state change: %s %s%n",
getId(), toStateName(nextState), phaserToString(phaser));
return;
}
@ -270,12 +276,12 @@ public class ThreadStateController extends Thread {
private void nextState(int s) throws InterruptedException {
final long id = Thread.currentThread().getId();
System.out.format("%d: wait until the thread transitions to %s %s%n",
id, toStateName(s), phaserToString(phaser));
log("%d: wait until the thread transitions to %s %s%n",
id, toStateName(s), phaserToString(phaser));
this.newState = s;
int phase = phaser.arrive();
System.out.format("%d: awaiting party arrive %s %s%n",
id, toStateName(s), phaserToString(phaser));
log("%d: awaiting party arrive %s %s%n",
id, toStateName(s), phaserToString(phaser));
for (;;) {
// when this thread has changed its state before it waits or parks
// on a lock, a potential race might happen if it misses the notify
@ -301,20 +307,22 @@ public class ThreadStateController extends Thread {
}
try {
phaser.awaitAdvanceInterruptibly(phase, 100, TimeUnit.MILLISECONDS);
System.out.format("%d: arrived at %s %s%n",
id, toStateName(s), phaserToString(phaser));
log("%d: arrived at %s %s%n",
id, toStateName(s), phaserToString(phaser));
return;
} catch (TimeoutException ex) {
// this thread hasn't arrived at this phase
System.out.format("%d: Timeout: %s%n", id, phaser);
log("%d: Timeout: %s%n", id, phaser);
}
}
}
private String phaserToString(Phaser p) {
return "[phase = " + p.getPhase() +
" parties = " + p.getRegisteredParties() +
" arrived = " + p.getArrivedParties() + "]";
}
private String toStateName(int state) {
switch (state) {
case S_RUNNABLE:
@ -337,4 +345,20 @@ public class ThreadStateController extends Thread {
return "unknown " + state;
}
}
private void log(String msg, Object ... params) {
logManager.log(msg, params);
}
/**
* Waits for the controller to complete the test run and returns the
* generated log
* @return The controller log
* @throws InterruptedException
*/
public String getLog() throws InterruptedException {
this.join();
return logManager.toString();
}
}

View File

@ -30,6 +30,8 @@ import static java.lang.Thread.State.*;
* Thread.getState().
*
* @author Mandy Chung
* @library /lib/testlibrary
* @build jdk.testlibrary.*
* @build ThreadStateTest ThreadStateController
* @run main/othervm -Xmixed ThreadStateTest
*/

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -31,6 +31,8 @@
* @author Mandy Chung
*
* @library ../../Thread
* @library /lib/testlibrary
* @build jdk.testlibrary.*
* @build ThreadMXBeanStateTest ThreadStateController
* @run main ThreadMXBeanStateTest
*/
@ -44,15 +46,17 @@ public class ThreadMXBeanStateTest {
private static final ThreadMXBean tm = ManagementFactory.getThreadMXBean();
static class Lock {
private String name;
private final String name;
Lock(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
}
private static Lock globalLock = new Lock("my lock");
private static final Lock globalLock = new Lock("my lock");
public static void main(String[] argv) throws Exception {
// Force thread state initialization now before the test
@ -109,7 +113,7 @@ public class ThreadMXBeanStateTest {
thread.checkThreadState(TERMINATED);
try {
thread.join();
System.out.println(thread.getLog());
} catch (InterruptedException e) {
e.printStackTrace();
System.out.println("TEST FAILED: Unexpected exception.");

View File

@ -0,0 +1,129 @@
/*
* Copyright 2014 Google Inc. All Rights Reserved.
* 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 8062771 8016236
* @summary Test publication of Class objects via a data race
* @run testng ThreadSafety
*/
import java.net.URL;
import java.net.URLClassLoader;
import java.util.Collections;
import java.util.concurrent.BrokenBarrierException;
import java.util.concurrent.Callable;
import java.util.concurrent.CyclicBarrier;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeoutException;
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
/**
* A test resulting from an attempt to repro this failure (in guice):
*
* java.lang.NullPointerException
* at sun.reflect.generics.visitor.Reifier.visitClassTypeSignature(Reifier.java:125)
* at sun.reflect.generics.tree.ClassTypeSignature.accept(ClassTypeSignature.java:49)
* at sun.reflect.generics.repository.ClassRepository.getSuperclass(ClassRepository.java:84)
* at java.lang.Class.getGenericSuperclass(Class.java:692)
* at com.google.inject.TypeLiteral.getSuperclassTypeParameter(TypeLiteral.java:99)
* at com.google.inject.TypeLiteral.<init>(TypeLiteral.java:79)
*
* However, as one would expect with thread safety problems in reflection, these
* are very hard to reproduce. This very test has never been observed to fail,
* but a similar test has been observed to fail about once in 2000 executions
* (about once every 6 CPU-hours), in jdk7 only. It appears to be fixed in jdk8+ by:
*
* 8016236: Class.getGenericInterfaces performance improvement.
* (by making Class.genericInfo volatile)
*/
public class ThreadSafety {
public static class EmptyClass {
public static class EmptyGenericSuperclass<T> {}
public static class EmptyGenericSubclass<T> extends EmptyGenericSuperclass<T> {}
}
/** published via data race */
private Class<?> racyClass = Object.class;
private URL[] urls = ((URLClassLoader) ThreadSafety.class.getClassLoader()).getURLs();
private Class<?> createNewEmptyGenericSubclassClass() throws Exception {
URLClassLoader ucl = new URLClassLoader(urls, null);
return Class.forName("ThreadSafety$EmptyClass$EmptyGenericSubclass", true, ucl);
}
@Test
public void testRacy_getGenericSuperclass() throws Exception {
final int nThreads = 10;
final int iterations = 30;
final int timeout = 10;
final CyclicBarrier newCycle = new CyclicBarrier(nThreads);
final Callable<Void> task = new Callable<Void>() {
public Void call() throws Exception {
for (int i = 0; i < iterations; i++) {
final int threadId;
try {
threadId = newCycle.await(timeout, SECONDS);
} catch (BrokenBarrierException e) {
return null;
}
for (int j = 0; j < iterations; j++) {
// one thread publishes the class object via a data
// race, for the other threads to consume.
if (threadId == 0) {
racyClass = createNewEmptyGenericSubclassClass();
} else {
racyClass.getGenericSuperclass();
}
}
}
return null;
}};
final ExecutorService pool = Executors.newFixedThreadPool(nThreads);
try {
for (Future<Void> future :
pool.invokeAll(Collections.nCopies(nThreads, task))) {
try {
future.get(iterations * timeout, SECONDS);
} catch (ExecutionException e) {
// ignore "collateral damage"
if (!(e.getCause() instanceof BrokenBarrierException)
&&
!(e.getCause() instanceof TimeoutException)) {
throw e;
}
}
}
} finally {
pool.shutdownNow();
assertTrue(pool.awaitTermination(2 * timeout, SECONDS));
}
}
}

View File

@ -0,0 +1,95 @@
/*
* 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.
*
* 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 8055063
* @summary javac should generate method parameters correctly.
* @clean InnerClassToString
* @compile -parameters InnerClassToString.java
* @run main InnerClassToString
* @clean InnerClassToString
* @compile InnerClassToString.java
* @run main InnerClassToString
*/
import java.lang.reflect.Constructor;
import java.lang.reflect.Parameter;
import java.util.Set;
// Test copied and expanded from webbug group report.
public class InnerClassToString {
private static final Class<?>[] genericParamClasses = new Class<?>[] {
InnerClassToString.class, Set.class
};
private static final Class<?>[] nongenericParamClasses = new Class<?>[] {
InnerClassToString.class, String.class
};
private int errors = 0;
private void test(Constructor<MyEntity> constructor,
Class<?>[] paramClasses) {
final Parameter[] params = constructor.getParameters();
for (int i = 0; i < params.length; i++) {
final Parameter parameter = params[i];
System.out.println(parameter.toString());
if (!parameter.getType().equals(paramClasses[i])) {
errors++;
System.err.println("Expected type " + paramClasses[i] +
" but got " + parameter.getType());
}
System.out.println(parameter.getParameterizedType());
System.out.println(parameter.getAnnotatedType());
}
}
private void run() throws Exception {
final Constructor<MyEntity> genericConstructor =
MyEntity.class.getConstructor(InnerClassToString.class, Set.class);
test(genericConstructor, genericParamClasses);
final Constructor<MyEntity> nongenericConstructor =
MyEntity.class.getConstructor(InnerClassToString.class, String.class);
test(nongenericConstructor, nongenericParamClasses);
if (errors != 0)
throw new RuntimeException(errors + " errors in test");
}
public static void main(String[] args) throws Exception {
new InnerClassToString().run();
}
public class MyEntity {
public MyEntity(Set<?> names) {}
public MyEntity(String names) {}
}
}

View File

@ -68,10 +68,9 @@ public class InitialContextTest {
Path dst = tmp.resolve("Test.java");
Files.copy(src, dst);
javac(tmp, dst);
Path build = Files.createDirectory(tmp.resolve("build"));
Files.copy(tmp.resolve("Test.class"), build.resolve("Test.class"));
javac(build, dst);
Map<String, String> props
= singletonMap(Context.INITIAL_CONTEXT_FACTORY, factoryClassFqn);
@ -107,13 +106,13 @@ public class InitialContextTest {
Path dst1 = createFactoryFrom(templatesHome().resolve("factory.template"),
factoryClassFqn, tmp);
javac(tmp, dst);
Path build = Files.createDirectory(tmp.resolve("build"));
javac(build, dst);
Path explodedJar = Files.createDirectory(tmp.resolve("exploded-jar"));
javac(explodedJar, dst1);
jar(tmp.resolve("test.jar"), explodedJar);
Path build = Files.createDirectory(tmp.resolve("build"));
Files.copy(tmp.resolve("Test.class"), build.resolve("Test.class"));
Files.copy(tmp.resolve("test.jar"), build.resolve("test.jar"));
Map<String, String> props
@ -191,7 +190,9 @@ public class InitialContextTest {
Path dst1 = createFactoryFrom(templatesHome().resolve("broken_factory.template"),
factoryClassFqn, tmp);
javac(tmp, dst);
Path build = Files.createDirectory(tmp.resolve("build"));
javac(build, dst);
Path explodedJar = Files.createDirectory(tmp.resolve("exploded-jar"));
Path services = Files.createDirectories(explodedJar.resolve("META-INF")
@ -208,15 +209,12 @@ public class InitialContextTest {
javac(explodedJar, dst1);
jar(tmp.resolve("test.jar"), explodedJar);
Path build = Files.createDirectory(tmp.resolve("build"));
Files.copy(tmp.resolve("Test.class"), build.resolve("Test.class"));
Files.copy(tmp.resolve("test.jar"), build.resolve("test.jar"));
Map<String, String> props = new HashMap<>();
props.put("java.ext.dirs", build.toString());
props.put(Context.INITIAL_CONTEXT_FACTORY, factoryClassFqn);
Map<String, String> props
= singletonMap(Context.INITIAL_CONTEXT_FACTORY, factoryClassFqn);
Result r = java(props, singleton(build), "Test");
Result r = java(props, asList(build.resolve("test.jar"), build), "Test");
if (r.exitValue == 0 || !verifyOutput(r.output, factoryClassFqn))
throw new RuntimeException(r.output);

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,211 @@
/*
* 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.
*
* 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 test.rowset.serial;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Ref;
import java.sql.SQLException;
import java.sql.Struct;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import javax.sql.rowset.serial.SQLInputImpl;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import util.BaseTest;
import util.StubArray;
import util.StubBlob;
import util.StubClob;
import util.StubRef;
import util.StubStruct;
import util.SuperHero;
import util.TestSQLDataImpl;
public class SQLInputImplTests extends BaseTest {
// Copy of the array of data type values
private Object[] typeValues;
private TestSQLDataImpl impl;
private Map<String, Class<?>> map ;
private SuperHero hero;
private final String sqlType = "SUPERHERO";
@BeforeMethod
@Override
public void setUpMethod() throws Exception {
map = new HashMap<>();
impl = new TestSQLDataImpl("TestSQLData");
typeValues = Arrays.copyOf(TestSQLDataImpl.attributes,
TestSQLDataImpl.attributes.length);
hero = new SuperHero(sqlType, "Bruce", "Wayne",
1939, "Batman");
}
/*
* Validate that a SQLException is thrown if the attribute value is
* null
*/
@Test(expectedExceptions = SQLException.class)
public void test() throws Exception {
SQLInputImpl x = new SQLInputImpl(null, map);
}
/*
* Validate that a SQLException is thrown if the map value is
* null
*/
@Test(expectedExceptions = SQLException.class)
public void test02() throws Exception {
SQLInputImpl x = new SQLInputImpl(typeValues, null);
}
/*
* Read in the various datatypes via readSQL (which will exercise the
* various readXXX methods and validate that results are as expected
*/
@Test()
public void test03() throws Exception {
impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
assertTrue(Arrays.equals(impl.toArray(), typeValues));
// Null out a field and make sure the arrays do not match
typeValues[2] = null;
assertFalse(Arrays.equals(impl.toArray(), typeValues));
}
/*
* Validate that wasNull indicates if a null was read in
*/
@Test()
public void test04() throws Exception {
Object[] values = {"Hello", null, 1};
SQLInputImpl sqli = new SQLInputImpl(values, map);
String s = sqli.readString();
assertFalse(sqli.wasNull());
s = sqli.readString();
assertTrue(sqli.wasNull());
int i = sqli.readInt();
assertFalse(sqli.wasNull());
}
/*
* Validate that readObject returns the correct value
*/
@Test()
public void test05() throws Exception {
Object[] values = {hero};
SQLInputImpl sqli = new SQLInputImpl(values, map);
Object o = sqli.readObject();
assertTrue(hero.equals(o));
}
/*
* Validate a Array can be read
*/
@Test(enabled = true)
public void test06() throws Exception {
Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast",
"Cappuccino"};
Array a = new StubArray("VARCHAR", coffees);
Object[] values = {a};
SQLInputImpl sqli = new SQLInputImpl(values, map);
Array a2 = sqli.readArray();
assertTrue(Arrays.equals((Object[]) a2.getArray(), (Object[]) a.getArray()));
assertTrue(a.getBaseTypeName().equals(a2.getBaseTypeName()));
}
/*
* Validate a Blob can be read
*/
@Test(enabled = true)
public void test07() throws Exception {
Blob b = new StubBlob();
Object[] values = {b};
SQLInputImpl sqli = new SQLInputImpl(values, map);
Blob b2 = sqli.readBlob();
assertTrue(Arrays.equals(
b.getBytes(1, (int) b.length()),
b2.getBytes(1, (int) b2.length())));
}
/*
* Validate a Clob can be read
*/
@Test(enabled = true)
public void test08() throws Exception {
Clob c = new StubClob();
Object[] values = {c};
SQLInputImpl sqli = new SQLInputImpl(values, map);
Clob c2 = sqli.readClob();
assertTrue(c.getSubString(1,
(int) c.length()).equals(c2.getSubString(1, (int) c2.length())));
}
/*
* Validate a Ref can be read
*/
@Test(enabled = true)
public void test09() throws Exception {
Ref ref = new StubRef(sqlType, hero);
Object[] values = {ref};
SQLInputImpl sqli = new SQLInputImpl(values, map);
Ref ref2 = sqli.readRef();
assertTrue(ref.getObject().equals(ref2.getObject()));
assertTrue(ref.getBaseTypeName().equals(ref2.getBaseTypeName()));
}
/*
* Validate a URL can be read
*/
@Test(enabled = true)
public void test10() throws Exception {
URL u = new URL("http://www.oracle.com/");;
Object[] values = {u};
SQLInputImpl sqli = new SQLInputImpl(values, map);
URL u2 = sqli.readURL();
assertTrue(u2.equals(u));
assertTrue(u2.sameFile(u));
}
/*
* Validate that readObject returns the correct value when a Struct is
* next on the stream
*/
@Test()
public void test11() throws Exception {
Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
"Batman"};
map.put(sqlType, Class.forName("util.SuperHero"));
Struct struct = new StubStruct(sqlType, attributes);
Object[] values = {struct};
SQLInputImpl sqli = new SQLInputImpl(values, map);
Object o = sqli.readObject();
assertTrue(hero.equals(o));
}
}

View File

@ -0,0 +1,199 @@
/*
* 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.
*
* 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 test.rowset.serial;
import java.net.URL;
import java.sql.Array;
import java.sql.Blob;
import java.sql.Clob;
import java.sql.Ref;
import java.sql.SQLException;
import java.sql.Struct;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Vector;
import javax.sql.rowset.serial.SQLInputImpl;
import javax.sql.rowset.serial.SQLOutputImpl;
import javax.sql.rowset.serial.SerialArray;
import javax.sql.rowset.serial.SerialBlob;
import javax.sql.rowset.serial.SerialClob;
import javax.sql.rowset.serial.SerialDatalink;
import javax.sql.rowset.serial.SerialRef;
import javax.sql.rowset.serial.SerialStruct;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import util.BaseTest;
import util.StubArray;
import util.StubBlob;
import util.StubClob;
import util.StubRef;
import util.StubStruct;
import util.SuperHero;
import util.TestSQLDataImpl;
public class SQLOutputImplTests extends BaseTest {
// Copy of the array of data type values
private Object[] typeValues;
private TestSQLDataImpl impl;
private Map<String, Class<?>> map = new HashMap<>();
private Vector results;
private final String sqlType = "SUPERHERO";
private SuperHero hero;
private SQLOutputImpl outImpl;
@BeforeMethod
@Override
public void setUpMethod() throws Exception {
results = new Vector();
impl = new TestSQLDataImpl("TestSQLData");
typeValues = Arrays.copyOf(TestSQLDataImpl.attributes,
TestSQLDataImpl.attributes.length);
hero = new SuperHero(sqlType, "Bruce", "Wayne", 1939, "Batman");
outImpl = new SQLOutputImpl(results, map);
}
/*
* Validate that a SQLException is thrown if the attribute value is
* null
*/
@Test(expectedExceptions = SQLException.class)
public void test() throws Exception {
SQLOutputImpl x = new SQLOutputImpl(null, map);
}
/*
* Validate that a SQLException is thrown if the map value is
* null
*/
@Test(expectedExceptions = SQLException.class)
public void test02() throws Exception {
SQLOutputImpl x = new SQLOutputImpl(results, null);
}
/*
* Read in the various datatypes via readSQL (which will exercise the
* various readXXX methods and validate that results are as expected
*/
@Test()
public void test03() throws Exception {
impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
impl.writeSQL(outImpl);
assertTrue(Arrays.equals(results.toArray(), typeValues));
// Null out a field and make sure the arrays do not match
typeValues[2] = null;
assertFalse(Arrays.equals(results.toArray(), typeValues));
}
/*
* Validate a Array can be written and returned
*/
@Test(enabled = true)
public void test04() throws Exception {
Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast",
"Cappuccino"};
Array a = new StubArray("VARCHAR", coffees);
outImpl.writeArray(a);
SerialArray sa = (SerialArray) results.get(0);
assertTrue(Arrays.equals(coffees, (Object[]) sa.getArray()));
assertTrue(a.getBaseTypeName().equals(sa.getBaseTypeName()));
}
/*
* Validate a Blob can be written and returned
*/
@Test(enabled = true)
public void test05() throws Exception {
Blob b = new StubBlob();
outImpl.writeBlob(b);
SerialBlob sb = (SerialBlob) results.get(0);
assertTrue(Arrays.equals(
b.getBytes(1, (int) b.length()),
sb.getBytes(1, (int) sb.length())));
}
/*
* Validate a Clob can be written and returned
*/
@Test(enabled = true)
public void test06() throws Exception {
Clob c = new StubClob();
outImpl.writeClob(c);
SerialClob sc = (SerialClob) results.get(0);
assertTrue(c.getSubString(1,
(int) c.length()).equals(sc.getSubString(1, (int) sc.length())));
}
/*
* Validate a Ref can be written and returned
*/
@Test(enabled = true)
public void test07() throws Exception {
Ref ref = new StubRef(sqlType, hero);
outImpl.writeRef(ref);
SerialRef sr = (SerialRef) results.get(0);
assertTrue(hero.equals(sr.getObject()));
}
/*
* Validate a Struct can be written and returned
*/
@Test(enabled = true)
public void test08() throws Exception {
Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
"Batman"};
Struct s = new StubStruct(sqlType, attributes);
outImpl.writeStruct(s);
SerialStruct ss = (SerialStruct) results.get(0);
assertTrue(Arrays.equals(attributes, (Object[]) ss.getAttributes()));
assertTrue(sqlType.equals(ss.getSQLTypeName()));
}
/*
* Validate a DataLink can be written and returned
*/
@Test(enabled = true)
public void test09() throws Exception {
URL u = new URL("http://www.oracle.com/");
outImpl.writeURL(u);
SerialDatalink sdl = (SerialDatalink) results.get(0);
URL u2 = sdl.getDatalink();
assertTrue(u2.equals(u));
assertTrue(u2.sameFile(u));
}
/*
* Validate an Object implementing SQLData can be written and returned
*/
@Test(enabled = true)
public void test10() throws Exception {
Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
"Batman"};
outImpl.writeObject(hero);
SerialStruct ss = (SerialStruct) results.get(0);
assertTrue(Arrays.equals(attributes, (Object[]) ss.getAttributes()));
assertTrue(sqlType.equals(ss.getSQLTypeName()));
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,29 @@
/*
* 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.
*
* 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 util;
import java.sql.NClob;
public class StubNClob extends StubClob implements NClob {
}

View File

@ -0,0 +1,34 @@
/*
* 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.
*
* 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 util;
import java.sql.RowId;
public class StubRowId implements RowId {
@Override
public byte[] getBytes() {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -0,0 +1,81 @@
/*
* 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.
*
* 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 util;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.Reader;
import java.io.Writer;
import java.sql.SQLException;
import java.sql.SQLXML;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
public class StubSQLXML implements SQLXML{
@Override
public void free() throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public InputStream getBinaryStream() throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public OutputStream setBinaryStream() throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Reader getCharacterStream() throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Writer setCharacterStream() throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getString() throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setString(String value) throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T extends Source> T getSource(Class<T> sourceClass) throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public <T extends Result> T setResult(Class<T> resultClass) throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -32,10 +32,14 @@ public class SuperHero implements SQLData, Serializable {
private String first;
private String last;
private final String type;
private String type = "SUPERHERO";
private Integer firstYear;
private String secretIdentity;
public SuperHero() {
}
public SuperHero(String sqlType, String fname, String lname, Integer year,
String identity) {
first = fname;

View File

@ -0,0 +1,64 @@
/*
* 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.
*
* 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 util;
import javax.sql.RowSetEvent;
import javax.sql.RowSetListener;
public class TestRowSetListener implements RowSetListener {
// Flags to indicate which listener events should have been notified
public final static int ROWSET_CHANGED = 1;
public final static int ROW_CHANGED = 2;
public final static int CURSOR_MOVED = 4;
private int flag;
@Override
public void rowSetChanged(RowSetEvent event) {
flag |= ROWSET_CHANGED;
}
@Override
public void rowChanged(RowSetEvent event) {
flag |= ROW_CHANGED;
}
@Override
public void cursorMoved(RowSetEvent event) {
flag |= CURSOR_MOVED;
}
/*
* Clear the flag indicating which events we were notified for
*/
public void resetFlag() {
flag = 0;
}
/*
* Method used to validate that the correct event was notified
*/
public boolean isNotified( int val) {
return flag == val;
}
}

View File

@ -0,0 +1,125 @@
/*
* 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.
*
* 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 util;
import java.math.BigDecimal;
import java.sql.Date;
import java.sql.SQLData;
import java.sql.SQLException;
import java.sql.SQLInput;
import java.sql.SQLOutput;
import java.sql.Time;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.Arrays;
public class TestSQLDataImpl implements SQLData {
private final int stringPos = 0;
private final int datePos = 1;
private final int timePos = 2;
private final int timestampPos = 3;
private final int intPos = 4;
private final int longPos = 5;
private final int shortPos = 6;
private final int bigDecimalPos = 7;
private final int doublePos = 8;
private final int booleanPos = 9;
private final int floatPos = 10;
private final int bytePos = 11;
private final int bytesPos = 12;
private final int MAX_TYPES = bytesPos + 1;
private final Object[] types = new Object[MAX_TYPES];
private final static byte[] b = {1, 2, 3};
// attributes entries must line up with the ordering of the reading and
// writing of the fields in readSQL and writeSQL
public final static Object[] attributes = {"The Dark Knight",
Date.valueOf(LocalDate.now()), Time.valueOf(LocalTime.now()),
Timestamp.valueOf(LocalDateTime.now()), Integer.MAX_VALUE,
Long.MAX_VALUE, Short.MIN_VALUE, BigDecimal.ONE,
Double.MAX_VALUE, true, 1.5f, Byte.MAX_VALUE, b};
private String sqlType;
public TestSQLDataImpl(String type) {
sqlType = type;
}
@Override
public String getSQLTypeName() throws SQLException {
return sqlType;
}
@Override
public void readSQL(SQLInput stream, String typeName) throws SQLException {
sqlType = typeName;
types[stringPos] = stream.readString();
types[datePos] = stream.readDate();
types[timePos] = stream.readTime();
types[timestampPos] = stream.readTimestamp();
types[intPos] = stream.readInt();
types[longPos] = stream.readLong();
types[shortPos] = stream.readShort();
types[bigDecimalPos] = stream.readBigDecimal();
types[doublePos] = stream.readDouble();
types[booleanPos] = stream.readBoolean();
types[floatPos] = stream.readFloat();
types[bytePos] = stream.readByte();
types[bytesPos] = stream.readBytes();
}
@Override
public void writeSQL(SQLOutput stream) throws SQLException {
stream.writeString((String) types[stringPos]);
stream.writeDate((Date) types[datePos]);
stream.writeTime((Time) types[timePos]);
stream.writeTimestamp((Timestamp) types[timestampPos]);
stream.writeInt((Integer) types[intPos]);
stream.writeLong((Long) types[longPos]);
stream.writeShort((Short) types[shortPos]);
stream.writeBigDecimal((BigDecimal) types[bigDecimalPos]);
stream.writeDouble((Double) types[doublePos]);
stream.writeBoolean((Boolean) types[booleanPos]);
stream.writeFloat((Float) types[floatPos]);
stream.writeByte((Byte) types[bytePos]);
stream.writeBytes((byte[]) types[bytesPos]);
}
public Object[] toArray() {
Object[] result = Arrays.copyOf(types, types.length);
return result;
}
@Override
public String toString() {
return "[" + sqlType + " " + types + "]";
}
}

View File

@ -0,0 +1,116 @@
package parse;
import java.io.IOException;
import java.io.StringReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.Test;
import org.xml.sax.Attributes;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.ext.DefaultHandler2;
import org.xml.sax.helpers.XMLReaderFactory;
/**
* JDK-6770436: Entity callback order differs between Java1.5 and Java1.6
* https://bugs.openjdk.java.net/browse/JDK-6770436
*
*/
public class EntityCharacterEventOrder {
protected final static String xmlEncoding = "ISO-8859-15";
protected static Charset xmlEncodingCharset = null;
String _xml;
static {
xmlEncodingCharset = Charset.forName(xmlEncoding);
}
/**
public static void main(String[] args) {
TestRunner.run(JDK6770436Test.class);
}
*/
@Test
public void entityCallbackOrderJava() throws SAXException, IOException {
final String input = "<element> &amp; some more text</element>";
final MockContentHandler handler = new MockContentHandler();
final XMLReader xmlReader = XMLReaderFactory.createXMLReader();
xmlReader.setContentHandler(handler);
xmlReader.setProperty("http://xml.org/sax/properties/lexical-handler", handler);
xmlReader.parse(new InputSource(new StringReader(input)));
final List<String> events = handler.getEvents();
printEvents(events);
assertCallbackOrder(events); //regression from JDK5
}
private void assertCallbackOrder(final List<String> events) {
assertEquals("startDocument", events.get(0));
assertEquals("startElement 'element'", events.get(1));
assertEquals("characters ' '", events.get(2));
assertEquals("startEntity 'amp'", events.get(3));
assertEquals("characters '&'", events.get(4));
assertEquals("endEntity 'amp'", events.get(5));
assertEquals("characters ' some more text'", events.get(6));
assertEquals("endElement 'element'", events.get(7));
assertEquals("endDocument", events.get(8));
}
private void printEvents(final List<String> events) {
events.stream().forEach((e) -> {
System.out.println(e);
});
}
private class MockContentHandler extends DefaultHandler2 {
private List<String> events;
public List<String> getEvents() {
return events;
}
@Override
public void startDocument() throws SAXException {
events = new ArrayList<String>();
events.add("startDocument");
}
@Override
public void characters(char[] ch, int start, int length) throws SAXException {
events.add("characters '" + new String(ch, start, length) + "'");
}
@Override
public void startElement(String uri, String localName, String name, Attributes atts) throws SAXException {
events.add("startElement '" + name + "'");
}
@Override
public void endElement(String uri, String localName, String name) throws SAXException {
events.add("endElement '" + name + "'");
}
@Override
public void endDocument() throws SAXException {
events.add("endDocument");
}
@Override
public void startEntity(String name) throws SAXException {
events.add("startEntity '" + name + "'");
}
@Override
public void endEntity(String name) throws SAXException {
events.add("endEntity '" + name + "'");
}
}
}

View File

@ -0,0 +1,52 @@
package parse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import static org.testng.Assert.assertEquals;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import org.w3c.dom.Document;
import org.xml.sax.SAXException;
/**
* JDK-8059327: XML parser returns corrupt attribute value
* https://bugs.openjdk.java.net/browse/JDK-8059327
*
* Also:
* JDK-8061550: XMLEntityScanner can corrupt corrupt content during parsing
* https://bugs.openjdk.java.net/browse/JDK-8061550
*
* @Summary: verify that the character cache in XMLEntityScanner is reset properly
*/
public class XMLEntityScannerLoad {
@Test(dataProvider = "xmls")
public void test(String xml) throws SAXException, IOException, ParserConfigurationException {
Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new ChunkInputStream(xml));
String value = d.getDocumentElement().getAttribute("a1");
assertEquals(value, "w");
}
static class ChunkInputStream extends ByteArrayInputStream {
ChunkInputStream(String xml) {
super(xml.getBytes());
}
@Override
public synchronized int read(byte[] b, int off, int len) {
return super.read(b, off, 7);
}
}
@DataProvider(name = "xmls")
private Object[][] xmls() {
return new Object[][] {
{"<?xml version=\"1.0\"?><element a1=\"w\" a2=\"&quot;&quot;\"/>"},
{"<?xml version=\"1.1\"?><element a1=\"w\" a2=\"&quot;&quot;\"/>"}
};
}
}

View File

@ -0,0 +1,48 @@
/*
* 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.
*
* 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 8062744
* @run main SupportedOptions
*/
import java.net.*;
import java.io.IOException;
import jdk.net.*;
public class SupportedOptions {
public static void main(String[] args) throws Exception {
if (!Sockets.supportedOptions(ServerSocket.class)
.contains(StandardSocketOptions.IP_TOS)) {
throw new RuntimeException("Test failed");
}
// Now set the option
ServerSocket ss = new ServerSocket();
if (!ss.supportedOptions().contains(StandardSocketOptions.IP_TOS)) {
throw new RuntimeException("Test failed");
}
Sockets.setOption(ss, java.net.StandardSocketOptions.IP_TOS, 128);
}
}

View File

@ -0,0 +1,90 @@
/*
* 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.
*
* 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.testlibrary;
import java.util.Collection;
import java.util.Formatter;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
* A log manager designed specifically to allow collecting ordered log messages
* in a multi-threaded environment without involving any kind of locking.
* <p>
* It is particularly useful in situations when one needs to assert various
* details about the tested thread state or the locks it hold while also wanting
* to produce diagnostic log messages.
* <p>
* The log manager does not provide any guarantees about the completness of the
* logs written from different threads - it is up to the caller to make sure
* {@code toString()} method is called only when all the activity has ceased
* and the per-thread logs contain all the necessary data.
*
* @author Jaroslav Bachorik
**/
public class LockFreeLogManager {
private final AtomicInteger logCntr = new AtomicInteger(0);
private final Collection<Map<Integer, String>> allRecords = new ConcurrentLinkedQueue<>();
private final ThreadLocal<Map<Integer, String>> records = new ThreadLocal<Map<Integer, String>>() {
@Override
protected Map<Integer, String> initialValue() {
Map<Integer, String> m = new ConcurrentHashMap<>();
allRecords.add(m);
return m;
}
};
/**
* Log a message
* @param format Message format
* @param params Message parameters
*/
public void log(String format, Object ... params) {
int id = logCntr.getAndIncrement();
try (Formatter formatter = new Formatter()) {
records.get().put(id, formatter.format(format, params).toString());
}
}
/**
* Will generate an aggregated log of chronologically ordered messages.
* <p>
* Make sure that you call this method only when all the related threads
* have finished; otherwise you might get incomplete data.
*
* @return An aggregated log of chronologically ordered messages
*/
@Override
public String toString() {
return allRecords.stream()
.flatMap(m->m.entrySet().stream())
.sorted((l, r)->l.getKey().compareTo(r.getKey()))
.map(e->e.getValue())
.collect(Collectors.joining());
}
}

View File

@ -34,6 +34,7 @@ import sun.jvmstat.monitor.VmIdentifier;
* @bug 6672135
* @summary setInterval() for local MonitoredHost and local MonitoredVm
* @author Tomas Hurka
* @run main/othervm -XX:+UsePerfData CR6672135
*/
public class CR6672135 {

View File

@ -0,0 +1,64 @@
/*
* 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.
*
* 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 8063700
* @run main/othervm -Xcheck:jni JNICheck
*/
import javax.crypto.Cipher;
import javax.crypto.SealedObject;
import javax.crypto.SecretKey;
import javax.crypto.KeyGenerator;
import java.security.NoSuchProviderException;
public class JNICheck {
/* This test is similar to the JCK test that found 8063700. */
static class SealedObjectTest {
Cipher c;
SealedObjectTest() throws Exception {
try {
c = Cipher.getInstance("AES", "SunPKCS11-Solaris");
} catch (NoSuchProviderException nspe) {
System.out.println("No SunPKCS11-Solaris provider. Test skipped");
return;
}
String s = "Test string";
SealedObject so;
SecretKey key = KeyGenerator.getInstance("AES").generateKey();
c.init(Cipher.ENCRYPT_MODE, key);
so = new SealedObject(s, c);
so.getObject(key, "SunPKCS11-Solaris");
}
}
public static void main(String args[]) throws Exception {
new SealedObjectTest();
}
}

View File

@ -0,0 +1,106 @@
/*
* 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.
*
* 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 8057810
* @summary New defaults for DSA keys in jarsigner and keytool
*/
import sun.security.pkcs.PKCS7;
import sun.security.util.KeyUtil;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.security.KeyStore;
import java.security.cert.X509Certificate;
import java.util.jar.JarFile;
public class DefaultSigalg {
public static void main(String[] args) throws Exception {
// Three test cases
String[] keyalgs = {"DSA", "RSA", "EC"};
// Expected default keytool sigalg
String[] sigalgs = {"SHA256withDSA", "SHA256withRSA", "SHA256withECDSA"};
// Expected keysizes
int[] keysizes = {2048, 2048, 256};
// Expected jarsigner digest alg used in signature
String[] digestalgs = {"SHA-256", "SHA-256", "SHA-256"};
// Create a jar file
sun.tools.jar.Main m =
new sun.tools.jar.Main(System.out, System.err, "jar");
Files.write(Paths.get("x"), new byte[10]);
if (!m.run("cvf a.jar x".split(" "))) {
throw new Exception("jar creation failed");
}
// Generate keypairs and sign the jar
Files.deleteIfExists(Paths.get("jks"));
for (String keyalg: keyalgs) {
sun.security.tools.keytool.Main.main(
("-keystore jks -storepass changeit -keypass changeit " +
"-dname CN=A -alias " + keyalg + " -genkeypair " +
"-keyalg " + keyalg).split(" "));
sun.security.tools.jarsigner.Main.main(
("-keystore jks -storepass changeit a.jar " + keyalg).split(" "));
}
// Check result
KeyStore ks = KeyStore.getInstance("JKS");
try (FileInputStream jks = new FileInputStream("jks");
JarFile jf = new JarFile("a.jar")) {
ks.load(jks, null);
for (int i = 0; i<keyalgs.length; i++) {
String keyalg = keyalgs[i];
// keytool
X509Certificate c = (X509Certificate) ks.getCertificate(keyalg);
String sigalg = c.getSigAlgName();
if (!sigalg.equals(sigalgs[i])) {
throw new Exception(
"keytool sigalg for " + keyalg + " is " + sigalg);
}
int keysize = KeyUtil.getKeySize(c.getPublicKey());
if (keysize != keysizes[i]) {
throw new Exception(
"keytool keysize for " + keyalg + " is " + keysize);
}
// jarsigner
String bk = "META-INF/" + keyalg + "." + keyalg;
try (InputStream is = jf.getInputStream(jf.getEntry(bk))) {
String digestalg = new PKCS7(is).getSignerInfos()[0]
.getDigestAlgorithmId().toString();
if (!digestalg.equals(digestalgs[i])) {
throw new Exception(
"jarsigner digest of sig for " + keyalg
+ " is " + digestalg);
}
}
}
}
}
}

View File

@ -170,6 +170,13 @@ public class KeyToolTest {
*/
void testOK(String input, String cmd) throws Exception {
try {
// Workaround for "8057810: Make SHA256withDSA the default
// jarsigner and keytool algorithm for DSA keys". Unfortunately
// SunPKCS11-NSS does not support SHA256withDSA yet.
if (cmd.contains("p11-nss.txt") && cmd.contains("-genkey")
&& !cmd.contains("-keyalg")) {
cmd += " -sigalg SHA1withDSA -keysize 1024";
}
test(input, cmd);
} catch(Exception e) {
afterFail(input, cmd, "OK");
@ -245,6 +252,9 @@ public class KeyToolTest {
* Helper method, print some output after a test does not do as expected
*/
void afterFail(String input, String cmd, String should) {
if (cmd.contains("p11-nss.txt")) {
cmd = "-J-Dnss.lib=" + System.getProperty("nss.lib") + " " + cmd;
}
System.err.println("\nTest fails for the command ---\n" +
"keytool " + cmd + "\nOr its debug version ---\n" +
"keytool -debug " + cmd);
@ -799,7 +809,7 @@ public class KeyToolTest {
remove("x.jks.p1.cert");
remove("csr1");
// PrivateKeyEntry can do certreq
testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala");
testOK("", "-keystore x.jks -storepass changeit -keypass changeit -genkeypair -dname CN=olala -keysize 1024");
testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1 -alias mykey");
testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1");
testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1 -sigalg SHA1withDSA");

View File

@ -22,7 +22,7 @@
#
# @test
# @bug 7133495 8041740 8062264
# @bug 7133495 8041740 8062264 8046777
# @summary [macosx] KeyChain KeyStore implementation retrieves only one private key entry
if [ "${TESTJAVA}" = "" ] ; then
@ -117,6 +117,26 @@ if [ $? -ne 0 ]; then
fi
echo "Imported keypairs from PKCS12 keystore into the keychain"
# Generate a 2048-bit RSA keypair and import into the temporary keychain
# (its private key is configured with non-default key usage settings)
certtool c k=$TEMPORARY_KC <<EOF
test
r
2048
y
b
s
y
A
US
A
A
y
EOF
# Adjust the keychain search order
echo "\"$TEMPORARY_KC\"" > $TEMPORARY_LIST
@ -127,10 +147,11 @@ echo "Temporary keychain search order:"
security list-keychains
# Recount the number of private key entries in the Keychain keystores
# (3 private keys imported from PKCS12, 1 private key generated by 'certtool')
RECOUNT=`$KEYTOOL -list | grep PrivateKeyEntry | wc -l`
echo "Found $RECOUNT private key entries in the Keychain keystore"
if [ $RECOUNT -lt `expr $COUNT + 3` ]; then
if [ $RECOUNT -lt `expr $COUNT + 4` ]; then
echo "Error: expected >$COUNT private key entries in the Keychain keystores"
RESULT=`$CLEANUP_P12`
RESULT=`$CLEANUP_KC`
@ -141,7 +162,7 @@ fi
# Access controls have already been lowered (see 'security import ... -A' above)
${TESTJAVA}/bin/javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . ${TESTSRC}/ExportPrivateKeyNoPwd.java || exit 6
echo | ${TESTJAVA}/bin/java ${TESTVMOPTS} ExportPrivateKeyNoPwd x
${TESTJAVA}/bin/java ${TESTVMOPTS} ExportPrivateKeyNoPwd x
if [ $? -ne 0 ]; then
echo "Error exporting private key from the temporary keychain"
RESULT=`$CLEANUP_P12`

Some files were not shown because too many files have changed in this diff Show More