This commit is contained in:
J. Duke 2017-07-05 20:06:36 +02:00
commit 348b0166d1
48 changed files with 4095 additions and 1082 deletions

View File

@ -280,3 +280,4 @@ e4ba01b726e263953ae129be37c94de6ed145b1d jdk9-b33
c173ba994245380fb11ef077d1e59823386840eb jdk9-b35 c173ba994245380fb11ef077d1e59823386840eb jdk9-b35
201d4e235d597a25a2d3ee1404394789ba386119 jdk9-b36 201d4e235d597a25a2d3ee1404394789ba386119 jdk9-b36
723a67b0c442391447b1d8aad8b249d06d1032e8 jdk9-b37 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(CONF_NAME, $CONF_NAME)
AC_SUBST(OUTPUT_ROOT, $OUTPUT_ROOT) 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. # The spec.gmk file contains all variables for the make system.
AC_CONFIG_FILES([$OUTPUT_ROOT/spec.gmk:$AUTOCONF_DIR/spec.gmk.in]) 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. # 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]) 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. # 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]) 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. # 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 # You can run make from the OUTPUT_ROOT, or from the top-level Makefile
# which will look for generated configurations # 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) pulse)
PKGHANDLER_COMMAND="sudo yum install pulseaudio-libs-devel" ;; PKGHANDLER_COMMAND="sudo yum install pulseaudio-libs-devel" ;;
x11) 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) ccache)
PKGHANDLER_COMMAND="sudo yum install ccache" ;; PKGHANDLER_COMMAND="sudo yum install ccache" ;;
esac esac

View File

@ -91,85 +91,93 @@ AC_DEFUN_ONCE([LIB_SETUP_X11],
# Check for X Windows # Check for X Windows
# #
# Check if the user has specified sysroot, but not --x-includes or --x-libraries. if test "x$X11_NOT_NEEDED" = xyes; then
# Make a simple check for the libraries at the sysroot, and setup --x-includes and if test "x${with_x}" != x; then
# --x-libraries for the sysroot, if that seems to be correct. AC_MSG_WARN([X11 is not used, so --with-x is ignored])
if test "x$OPENJDK_TARGET_OS" = "xlinux"; then fi
if test "x$SYSROOT" != "x"; then X_CFLAGS=
if test "x$x_includes" = xNONE; then X_LIBS=
if test -f "$SYSROOT/usr/X11R6/include/X11/Xlib.h"; then else
x_includes="$SYSROOT/usr/X11R6/include" # Check if the user has specified sysroot, but not --x-includes or --x-libraries.
elif test -f "$SYSROOT/usr/include/X11/Xlib.h"; then # Make a simple check for the libraries at the sysroot, and setup --x-includes and
x_includes="$SYSROOT/usr/include" # --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
fi if test "x$x_libraries" = xNONE; then
if test "x$x_libraries" = xNONE; then if test -f "$SYSROOT/usr/X11R6/lib/libX11.so"; then
if test -f "$SYSROOT/usr/X11R6/lib/libX11.so"; then x_libraries="$SYSROOT/usr/X11R6/lib"
x_libraries="$SYSROOT/usr/X11R6/lib" elif test "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then
elif test "$SYSROOT/usr/lib64/libX11.so" && test "x$OPENJDK_TARGET_CPU_BITS" = x64; then x_libraries="$SYSROOT/usr/lib64"
x_libraries="$SYSROOT/usr/lib64" elif test -f "$SYSROOT/usr/lib/libX11.so"; then
elif test -f "$SYSROOT/usr/lib/libX11.so"; then x_libraries="$SYSROOT/usr/lib"
x_libraries="$SYSROOT/usr/lib" fi
fi fi
fi fi
fi fi
fi
# Now let autoconf do it's magic # Now let autoconf do it's magic
AC_PATH_X AC_PATH_X
AC_PATH_XTRA AC_PATH_XTRA
# AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling # AC_PATH_XTRA creates X_LIBS and sometimes adds -R flags. When cross compiling
# this doesn't make sense so we remove it. # this doesn't make sense so we remove it.
if test "x$COMPILE_TYPE" = xcross; then if test "x$COMPILE_TYPE" = xcross; then
X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'` X_LIBS=`$ECHO $X_LIBS | $SED 's/-R \{0,1\}[[^ ]]*//g'`
fi fi
if test "x$no_x" = xyes && test "x$X11_NOT_NEEDED" != xyes; then if test "x$no_x" = xyes; then
HELP_MSG_MISSING_DEPENDENCY([x11]) HELP_MSG_MISSING_DEPENDENCY([x11])
AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG]) AC_MSG_ERROR([Could not find X11 libraries. $HELP_MSG])
fi fi
if test "x$OPENJDK_TARGET_OS" = xsolaris; then if test "x$OPENJDK_TARGET_OS" = xsolaris; then
OPENWIN_HOME="/usr/openwin" OPENWIN_HOME="/usr/openwin"
X_CFLAGS="-I$SYSROOT$OPENWIN_HOME/include -I$SYSROOT$OPENWIN_HOME/include/X11/extensions" 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 \ X_LIBS="-L$SYSROOT$OPENWIN_HOME/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
-L$SYSROOT$OPENWIN_HOME/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/sfw/lib$OPENJDK_TARGET_CPU_ISADIR \
-R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR" -R$OPENWIN_HOME/lib$OPENJDK_TARGET_CPU_ISADIR"
fi fi
AC_LANG_PUSH(C) AC_LANG_PUSH(C)
OLD_CFLAGS="$CFLAGS" OLD_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS $SYSROOT_CFLAGS $X_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 # 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], AC_CHECK_HEADERS([X11/extensions/shape.h X11/extensions/Xrender.h X11/extensions/XTest.h X11/Intrinsic.h],
[X11_A_OK=yes], [X11_HEADERS_OK=yes],
[X11_A_OK=no; break], [X11_HEADERS_OK=no; break],
[ [
# include <X11/Xlib.h> # include <X11/Xlib.h>
# include <X11/Xutil.h> # include <X11/Xutil.h>
] ]
) )
# If XLinearGradient isn't available in Xrender.h, signal that it needs to be if test "x$X11_HEADERS_OK" = xno; then
# defined in libawt_xawt. HELP_MSG_MISSING_DEPENDENCY([x11])
AC_MSG_CHECKING([if XlinearGradient is defined in Xrender.h]) AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG])
AC_COMPILE_IFELSE( fi
[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"])
CFLAGS="$OLD_CFLAGS" # If XLinearGradient isn't available in Xrender.h, signal that it needs to be
AC_LANG_POP(C) # 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 CFLAGS="$OLD_CFLAGS"
HELP_MSG_MISSING_DEPENDENCY([x11]) AC_LANG_POP(C)
AC_MSG_ERROR([Could not find all X11 headers (shape.h Xrender.h XTest.h Intrinsic.h). $HELP_MSG]) fi # X11_NOT_NEEDED
fi
AC_SUBST(X_CFLAGS) AC_SUBST(X_CFLAGS)
AC_SUBST(X_LIBS) AC_SUBST(X_LIBS)
@ -264,7 +272,7 @@ AC_DEFUN([LIB_BUILD_FREETYPE],
fi fi
# Now check if configure found a version of 'msbuild.exe' # Now check if configure found a version of 'msbuild.exe'
if test "x$BUILD_FREETYPE" = xyes && test "x$MSBUILD" == x ; then 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 BUILD_FREETYPE=no
fi fi
@ -335,27 +343,50 @@ AC_DEFUN([LIB_CHECK_POTENTIAL_FREETYPE],
POTENTIAL_FREETYPE_LIB_PATH="$2" POTENTIAL_FREETYPE_LIB_PATH="$2"
METHOD="$3" METHOD="$3"
# First check if the files exists. # Let's start with an optimistic view of the world :-)
if test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then FOUND_FREETYPE=yes
# 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
FREETYPE_LIB_NAME="${LIBRARY_PREFIX}freetype${SHARED_LIBRARY_SUFFIX}" # First look for the canonical freetype main include file ft2build.h.
if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME"; then if ! test -s "$POTENTIAL_FREETYPE_INCLUDE_PATH/ft2build.h"; then
AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/$FREETYPE_LIB_NAME. Ignoring location.]) # 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 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 else
if test "x$OPENJDK_TARGET_OS" = xwindows; then if test "x$OPENJDK_TARGET_OS" = xwindows; then
# On Windows, we will need both .lib and .dll file. # On Windows, we will need both .lib and .dll file.
if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/freetype.lib"; then if ! test -s "$POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib"; then
AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/freetype.lib. Ignoring location.]) AC_MSG_NOTICE([Could not find $POTENTIAL_FREETYPE_LIB_PATH/${FREETYPE_BASE_NAME}.lib. Ignoring location.])
FOUND_FREETYPE=no FOUND_FREETYPE=no
fi fi
elif test "x$OPENJDK_TARGET_OS" = xsolaris \ elif test "x$OPENJDK_TARGET_OS" = xsolaris \
&& test -s "$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR/$FREETYPE_LIB_NAME"; then && test -s "$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR/$FREETYPE_LIB_NAME"; then
# Found lib in isa dir, use that instead. # Found lib in isa dir, use that instead.
POTENTIAL_FREETYPE_LIB_PATH="$POTENTIAL_FREETYPE_LIB_PATH$OPENJDK_TARGET_CPU_ISADIR" 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 fi
fi fi
@ -392,6 +423,8 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
AC_ARG_ENABLE(freetype-bundling, [AS_HELP_STRING([--disable-freetype-bundling], 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@:>@])]) [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_CFLAGS=
FREETYPE_LIBS= FREETYPE_LIBS=
FREETYPE_BUNDLE_LIB_PATH= FREETYPE_BUNDLE_LIB_PATH=
@ -575,9 +608,9 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
if test "x$FREETYPE_LIBS" = x; then if test "x$FREETYPE_LIBS" = x; then
BASIC_FIXUP_PATH(FREETYPE_LIB_PATH) BASIC_FIXUP_PATH(FREETYPE_LIB_PATH)
if test "x$OPENJDK_TARGET_OS" = xwindows; then 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 else
FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -lfreetype" FREETYPE_LIBS="-L$FREETYPE_LIB_PATH -l$FREETYPE_BASE_NAME"
fi fi
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 9bc2dbd3dfb8c9fa88e00056b8b93a81ee6d306e jdk9-b35
ffd90c81d4ef9d94d880fc852e2fc482ecd9b374 jdk9-b36 ffd90c81d4ef9d94d880fc852e2fc482ecd9b374 jdk9-b36
7e9add74ad50841fb39dae75db56374aefa1de4c jdk9-b37 7e9add74ad50841fb39dae75db56374aefa1de4c jdk9-b37
8acf056126e819cf536eef02aee0f61f207a6b52 jdk9-b38

View File

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

View File

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

View File

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

View File

@ -26,27 +26,21 @@
package java.lang; package java.lang;
import java.lang.reflect.AnnotatedElement; import java.lang.reflect.AnnotatedElement;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.StringTokenizer;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.security.AccessController; import java.security.AccessController;
import java.security.PrivilegedAction; import java.security.PrivilegedAction;
import java.util.concurrent.ConcurrentHashMap;
import java.util.jar.JarInputStream; import java.util.jar.JarInputStream;
import java.util.jar.Manifest; import java.util.jar.Manifest;
import java.util.jar.Attributes; import java.util.jar.Attributes;
import java.util.jar.Attributes.Name; import java.util.jar.Attributes.Name;
import java.util.jar.JarException;
import java.util.Map; import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import sun.net.www.ParseUtil; import sun.net.www.ParseUtil;
import sun.reflect.CallerSensitive; 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. * Returns the loaded system package for the specified name.
*/ */
static Package getSystemPackage(String name) { static Package getSystemPackage(String name) {
synchronized (pkgs) { Package pkg = pkgs.get(name);
Package pkg = pkgs.get(name); if (pkg == null) {
if (pkg == null) { name = name.replace('.', '/').concat("/");
name = name.replace('.', '/').concat("/"); String fn = getSystemPackage0(name);
String fn = getSystemPackage0(name); if (fn != null) {
if (fn != null) { pkg = defineSystemPackage(name, fn);
pkg = defineSystemPackage(name, fn);
}
} }
return pkg;
} }
return pkg;
} }
/* /*
@ -557,74 +549,98 @@ public class Package implements java.lang.reflect.AnnotatedElement {
static Package[] getSystemPackages() { static Package[] getSystemPackages() {
// First, update the system package map with new package names // First, update the system package map with new package names
String[] names = getSystemPackages0(); String[] names = getSystemPackages0();
synchronized (pkgs) { for (String name : names) {
for (String name : names) { if (!pkgs.containsKey(name)) {
defineSystemPackage(name, getSystemPackage0(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, private static Package defineSystemPackage(final String iname,
final String fn) final String fn)
{ {
return AccessController.doPrivileged(new PrivilegedAction<Package>() { // Convert to "."-separated package name
public Package run() { String name = iname.substring(0, iname.length() - 1).replace('/', '.');
String name = iname; // Creates a cached manifest for the file name, allowing
// Get the cached code source url for the file name // only-once, lazy reads of manifest from jar files
URL url = urls.get(fn); CachedManifest cachedManifest = createCachedManifest(fn);
if (url == null) { pkgs.putIfAbsent(name, new Package(name, cachedManifest.getManifest(),
// URL not found, so create one cachedManifest.getURL(), null));
File file = new File(fn); // Ensure we only expose one Package object
try { return pkgs.get(name);
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;
}
});
} }
/* private static CachedManifest createCachedManifest(String fn) {
* Returns the Manifest for the specified JAR file name. if (!manifests.containsKey(fn)) {
*/ manifests.putIfAbsent(fn, new CachedManifest(fn));
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;
} }
return manifests.get(fn);
} }
// The map of loaded system packages // 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 // Maps each directory or zip file name to its corresponding manifest, if
private static Map<String, URL> urls = new HashMap<>(10); // 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 class CachedManifest {
private static Map<String, Manifest> mans = new HashMap<>(10); 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 getSystemPackage0(String name);
private static native String[] getSystemPackages0(); 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 a4, Object a5, Object a6, Object a7,
Object a8, Object a9) Object a8, Object a9)
{ return makeArray(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); } { return makeArray(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); }
private static final int ARRAYS_COUNT = 11;
private static MethodHandle[] makeArrays() { private static MethodHandle[] makeArrays() {
ArrayList<MethodHandle> mhs = new ArrayList<>(); MethodHandle[] mhs = new MethodHandle[MAX_ARITY + 1];
for (;;) { for (int i = 0; i < ARRAYS_COUNT; i++) {
MethodHandle mh = findCollector("array", mhs.size(), Object[].class); MethodHandle mh = findCollector("array", i, Object[].class);
if (mh == null) break;
mh = makeIntrinsic(mh, Intrinsic.NEW_ARRAY); mh = makeIntrinsic(mh, Intrinsic.NEW_ARRAY);
mhs.add(mh); mhs[i] = mh;
} }
assert(mhs.size() == 11); // current number of methods assert(assertArrayMethodCount(mhs));
return mhs.toArray(new MethodHandle[MAX_ARITY+1]); 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: // 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 final int FILL_ARRAYS_COUNT = 11; // current number of fillArray methods
private static MethodHandle[] makeFillArrays() { private static MethodHandle[] makeFillArrays() {
ArrayList<MethodHandle> mhs = new ArrayList<>(); MethodHandle[] mhs = new MethodHandle[FILL_ARRAYS_COUNT];
mhs.add(null); // there is no empty fill; at least a0 is required mhs[0] = null; // there is no empty fill; at least a0 is required
for (;;) { for (int i = 1; i < FILL_ARRAYS_COUNT; i++) {
MethodHandle mh = findCollector("fillArray", mhs.size(), Object[].class, Integer.class, Object[].class); MethodHandle mh = findCollector("fillArray", i, Object[].class, Integer.class, Object[].class);
if (mh == null) break; mhs[i] = mh;
mhs.add(mh);
} }
assert(mhs.size() == FILL_ARRAYS_COUNT); assert(assertFillArrayMethodCount(mhs));
return mhs.toArray(new MethodHandle[0]); 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) { 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) { static MethodHandle varargsArray(int nargs) {
MethodHandle mh = Lazy.ARRAYS[nargs]; MethodHandle mh = Lazy.ARRAYS[nargs];
if (mh != null) return mh; 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); mh = buildVarargsArray(Lazy.MH_fillNewArray, Lazy.MH_arrayIdentity, nargs);
assert(assertCorrectArity(mh, nargs)); assert(assertCorrectArity(mh, nargs));
mh = makeIntrinsic(mh, Intrinsic.NEW_ARRAY); mh = makeIntrinsic(mh, Intrinsic.NEW_ARRAY);

View File

@ -122,18 +122,18 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
AccessController.doPrivileged( AccessController.doPrivileged(
new PrivilegedAction<Void>() { new PrivilegedAction<Void>() {
public Void run() { public Void run() {
ThreadGroup tg = Thread.currentThread().getThreadGroup(); ThreadGroup tg = Thread.currentThread().getThreadGroup();
for (ThreadGroup tgn = tg; for (ThreadGroup tgn = tg;
tgn != null; tgn != null;
tg = tgn, tgn = tg.getParent()); tg = tgn, tgn = tg.getParent());
Thread sft = new Thread(tg, proc, "Secondary finalizer"); Thread sft = new Thread(tg, proc, "Secondary finalizer");
sft.start(); sft.start();
try { try {
sft.join(); sft.join();
} catch (InterruptedException x) { } catch (InterruptedException x) {
/* Ignore */ Thread.currentThread().interrupt();
} }
return null; return null;
}}); }});
} }
@ -146,6 +146,7 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
forkSecondaryFinalizer(new Runnable() { forkSecondaryFinalizer(new Runnable() {
private volatile boolean running; private volatile boolean running;
public void run() { public void run() {
// in case of recursive call to run()
if (running) if (running)
return; return;
final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
@ -168,6 +169,7 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
forkSecondaryFinalizer(new Runnable() { forkSecondaryFinalizer(new Runnable() {
private volatile boolean running; private volatile boolean running;
public void run() { public void run() {
// in case of recursive call to run()
if (running) if (running)
return; return;
final JavaLangAccess jla = SharedSecrets.getJavaLangAccess(); final JavaLangAccess jla = SharedSecrets.getJavaLangAccess();
@ -189,6 +191,7 @@ final class Finalizer extends FinalReference<Object> { /* Package-private; must
super(g, "Finalizer"); super(g, "Finalizer");
} }
public void run() { public void run() {
// in case of recursive call to run()
if (running) if (running)
return; return;

View File

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

View File

@ -303,7 +303,7 @@ public final class Files {
* is a {@link java.nio.channels.FileChannel}. * is a {@link java.nio.channels.FileChannel}.
* *
* <p> <b>Usage Examples:</b> * <p> <b>Usage Examples:</b>
* <pre> * <pre>{@code
* Path path = ... * Path path = ...
* *
* // open file for reading * // open file for reading
@ -314,9 +314,10 @@ public final class Files {
* WritableByteChannel wbc = Files.newByteChannel(path, EnumSet.of(CREATE,APPEND)); * WritableByteChannel wbc = Files.newByteChannel(path, EnumSet.of(CREATE,APPEND));
* *
* // create file with initial permissions, opening it for both reading and writing * // create file with initial permissions, opening it for both reading and writing
* {@code FileAttribute<Set<PosixFilePermission>> perms = ...} * FileAttribute<Set<PosixFilePermission>> perms = ...
* SeekableByteChannel sbc = Files.newByteChannel(path, EnumSet.of(CREATE_NEW,READ,WRITE), perms); * SeekableByteChannel sbc =
* </pre> * Files.newByteChannel(path, EnumSet.of(CREATE_NEW,READ,WRITE), perms);
* }</pre>
* *
* @param path * @param path
* the path to the file to open or create * the path to the file to open or create
@ -1702,7 +1703,8 @@ public final class Files {
* Alternatively, suppose we want to read file's POSIX attributes without * Alternatively, suppose we want to read file's POSIX attributes without
* following symbolic links: * following symbolic links:
* <pre> * <pre>
* PosixFileAttributes attrs = Files.readAttributes(path, PosixFileAttributes.class, NOFOLLOW_LINKS); * PosixFileAttributes attrs =
* Files.readAttributes(path, PosixFileAttributes.class, NOFOLLOW_LINKS);
* </pre> * </pre>
* *
* @param <A> * @param <A>
@ -2840,6 +2842,8 @@ public final class Files {
* @return a new buffered writer, with default buffer size, to write text * @return a new buffered writer, with default buffer size, to write text
* to the file * to the file
* *
* @throws IllegalArgumentException
* if {@code options} contains an invalid combination of options
* @throws IOException * @throws IOException
* if an I/O error occurs opening or creating the file * if an I/O error occurs opening or creating the file
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
@ -2880,6 +2884,8 @@ public final class Files {
* @return a new buffered writer, with default buffer size, to write text * @return a new buffered writer, with default buffer size, to write text
* to the file * to the file
* *
* @throws IllegalArgumentException
* if {@code options} contains an invalid combination of options
* @throws IOException * @throws IOException
* if an I/O error occurs opening or creating the file * if an I/O error occurs opening or creating the file
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
@ -2891,7 +2897,9 @@ public final class Files {
* *
* @since 1.8 * @since 1.8
*/ */
public static BufferedWriter newBufferedWriter(Path path, OpenOption... options) throws IOException { public static BufferedWriter newBufferedWriter(Path path, OpenOption... options)
throws IOException
{
return newBufferedWriter(path, StandardCharsets.UTF_8, options); return newBufferedWriter(path, StandardCharsets.UTF_8, options);
} }
@ -3273,6 +3281,8 @@ public final class Files {
* *
* @return the path * @return the path
* *
* @throws IllegalArgumentException
* if {@code options} contains an invalid combination of options
* @throws IOException * @throws IOException
* if an I/O error occurs writing to or creating the file * if an I/O error occurs writing to or creating the file
* @throws UnsupportedOperationException * @throws UnsupportedOperationException
@ -3330,6 +3340,8 @@ public final class Files {
* *
* @return the path * @return the path
* *
* @throws IllegalArgumentException
* if {@code options} contains an invalid combination of options
* @throws IOException * @throws IOException
* if an I/O error occurs writing to or creating the file, or the * if an I/O error occurs writing to or creating the file, or the
* text cannot be encoded using the specified charset * text cannot be encoded using the specified charset
@ -3376,6 +3388,8 @@ public final class Files {
* *
* @return the path * @return the path
* *
* @throws IllegalArgumentException
* if {@code options} contains an invalid combination of options
* @throws IOException * @throws IOException
* if an I/O error occurs writing to or creating the file, or the * if an I/O error occurs writing to or creating the file, or the
* text cannot be encoded as {@code UTF-8} * text cannot be encoded as {@code UTF-8}
@ -3452,7 +3466,7 @@ public final class Files {
final Iterator<Path> delegate = ds.iterator(); final Iterator<Path> delegate = ds.iterator();
// Re-wrap DirectoryIteratorException to UncheckedIOException // Re-wrap DirectoryIteratorException to UncheckedIOException
Iterator<Path> it = new Iterator<Path>() { Iterator<Path> iterator = new Iterator<Path>() {
@Override @Override
public boolean hasNext() { public boolean hasNext() {
try { try {
@ -3471,7 +3485,9 @@ public final class Files {
} }
}; };
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(it, Spliterator.DISTINCT), false) Spliterator<Path> spliterator =
Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT);
return StreamSupport.stream(spliterator, false)
.onClose(asUncheckedRunnable(ds)); .onClose(asUncheckedRunnable(ds));
} catch (Error|RuntimeException e) { } catch (Error|RuntimeException e) {
try { try {
@ -3572,7 +3588,9 @@ public final class Files {
{ {
FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options); FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options);
try { try {
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT), false) Spliterator<FileTreeWalker.Event> spliterator =
Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT);
return StreamSupport.stream(spliterator, false)
.onClose(iterator::close) .onClose(iterator::close)
.map(entry -> entry.file()); .map(entry -> entry.file());
} catch (Error|RuntimeException e) { } catch (Error|RuntimeException e) {
@ -3685,7 +3703,9 @@ public final class Files {
{ {
FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options); FileTreeIterator iterator = new FileTreeIterator(start, maxDepth, options);
try { try {
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT), false) Spliterator<FileTreeWalker.Event> spliterator =
Spliterators.spliteratorUnknownSize(iterator, Spliterator.DISTINCT);
return StreamSupport.stream(spliterator, false)
.onClose(iterator::close) .onClose(iterator::close)
.filter(entry -> matcher.test(entry.file(), entry.attributes())) .filter(entry -> matcher.test(entry.file(), entry.attributes()))
.map(entry -> entry.file()); .map(entry -> entry.file());

View File

@ -86,8 +86,8 @@
* <p> Unless otherwise noted, passing a {@code null} argument to a constructor * <p> Unless otherwise noted, passing a {@code null} argument to a constructor
* or method of any class or interface in this package will cause a {@link * or method of any class or interface in this package will cause a {@link
* java.lang.NullPointerException NullPointerException} to be thrown. Additionally, * java.lang.NullPointerException NullPointerException} to be thrown. Additionally,
* invoking a method with a collection containing a {@code null} element will * invoking a method with an array or collection containing a {@code null} element
* cause a {@code NullPointerException}, unless otherwise specified. </p> * will cause a {@code NullPointerException}, unless otherwise specified. </p>
* *
* <p> Unless otherwise noted, methods that attempt to access the file system * <p> Unless otherwise noted, methods that attempt to access the file system
* will throw {@link java.nio.file.ClosedFileSystemException} when invoked on * will throw {@link java.nio.file.ClosedFileSystemException} when invoked on

View File

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

View File

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

View File

@ -205,28 +205,4 @@ public class JmxProperties {
*/ */
public static final Logger MISC_LOGGER = public static final Logger MISC_LOGGER =
Logger.getLogger(MISC_LOGGER_NAME); 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

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

View File

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

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,12 +1,10 @@
/* /*
* Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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 * under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this * published by the Free Software Foundation.
* 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 * This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
@ -23,27 +21,21 @@
* questions. * questions.
*/ */
#define PACKAGE_NAME "openjdk" /*
#define PACKAGE_TARNAME "openjdk" * @test
#define PACKAGE_VERSION "version-0.1" * @bug 4354680
#define PACKAGE_STRING "openjdk version-0.1" * @summary runFinalization() should not clear or ignore interrupt bit
#define PACKAGE_BUGREPORT "build-infra-dev@openjdk.java.net" * @run main FinInterrupt
#define PACKAGE_URL "" */
#define STDC_HEADERS
#define HAVE_SYS_TYPES_H public class FinInterrupt {
#define HAVE_SYS_STAT_H public static void main(String[] args) throws Exception {
#define HAVE_STDLIB_H Thread.currentThread().interrupt();
#define HAVE_STRING_H System.runFinalization();
#define HAVE_MEMORY_H if (Thread.interrupted()) {
#define HAVE_STRINGS_H System.out.println("Passed: interrupt bit was still set.");
#define HAVE_INTTYPES_H } else {
#define HAVE_STDINT_H throw new AssertionError("interrupt bit was cleared");
#define HAVE_UNISTD_H }
#define SIZEOF_INT_P 8 }
#define HAVE_CUPS_CUPS_H }
#define HAVE_CUPS_PPD_H
#define HAVE_LIBJPEG
#define HAVE_LIBGIF
#define HAVE_LIBZ
#define HAVE_LIBM
#define HAVE_ALTZONE

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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * 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.atomic.AtomicInteger;
import java.util.concurrent.locks.LockSupport; import java.util.concurrent.locks.LockSupport;
import jdk.testlibrary.LockFreeLogManager;
/** /**
* ThreadStateController allows a thread to request this thread to transition * ThreadStateController allows a thread to request this thread to transition
* to a specific thread state. The {@linkplain #transitionTo request} is * 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; private static final int S_TERMINATE = 8;
// for debugging // for debugging
private AtomicInteger iterations = new AtomicInteger(); private final AtomicInteger iterations = new AtomicInteger();
private AtomicInteger interrupted = new AtomicInteger(); private final AtomicInteger interrupted = new AtomicInteger();
private final LockFreeLogManager logManager = new LockFreeLogManager();
@Override
public void run() { public void run() {
// this thread has started // this thread has started
while (!done) { while (!done) {
@ -119,13 +125,13 @@ public class ThreadStateController extends Thread {
break; break;
} }
case S_BLOCKED: { case S_BLOCKED: {
System.out.format("%d: %s is going to block (interations %d)%n", log("%d: %s is going to block (iterations %d)%n",
getId(), getName(), iterations.get()); getId(), getName(), iterations.get());
stateChange(nextState); stateChange(nextState);
// going to block on lock // going to block on lock
synchronized (lock) { synchronized (lock) {
System.out.format("%d: %s acquired the lock (interations %d)%n", log("%d: %s acquired the lock (iterations %d)%n",
getId(), getName(), iterations.get()); getId(), getName(), iterations.get());
try { try {
// this thread has escaped the BLOCKED state // this thread has escaped the BLOCKED state
// release the lock and a short wait before continue // release the lock and a short wait before continue
@ -139,13 +145,13 @@ public class ThreadStateController extends Thread {
} }
case S_WAITING: { case S_WAITING: {
synchronized (lock) { synchronized (lock) {
System.out.format("%d: %s is going to waiting (interations %d interrupted %d)%n", log("%d: %s is going to waiting (iterations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get()); getId(), getName(), iterations.get(), interrupted.get());
try { try {
stateChange(nextState); stateChange(nextState);
lock.wait(); lock.wait();
System.out.format("%d: %s wakes up from waiting (interations %d interrupted %d)%n", log("%d: %s wakes up from waiting (iterations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get()); getId(), getName(), iterations.get(), interrupted.get());
} catch (InterruptedException e) { } catch (InterruptedException e) {
// ignore // ignore
interrupted.incrementAndGet(); interrupted.incrementAndGet();
@ -155,13 +161,13 @@ public class ThreadStateController extends Thread {
} }
case S_TIMED_WAITING: { case S_TIMED_WAITING: {
synchronized (lock) { synchronized (lock) {
System.out.format("%d: %s is going to timed waiting (interations %d interrupted %d)%n", log("%d: %s is going to timed waiting (iterations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get()); getId(), getName(), iterations.get(), interrupted.get());
try { try {
stateChange(nextState); stateChange(nextState);
lock.wait(10000); lock.wait(10000);
System.out.format("%d: %s wakes up from timed waiting (interations %d interrupted %d)%n", log("%d: %s wakes up from timed waiting (iterations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get()); getId(), getName(), iterations.get(), interrupted.get());
} catch (InterruptedException e) { } catch (InterruptedException e) {
// ignore // ignore
interrupted.incrementAndGet(); interrupted.incrementAndGet();
@ -170,23 +176,23 @@ public class ThreadStateController extends Thread {
break; break;
} }
case S_PARKED: { case S_PARKED: {
System.out.format("%d: %s is going to park (interations %d)%n", log("%d: %s is going to park (iterations %d)%n",
getId(), getName(), iterations.get()); getId(), getName(), iterations.get());
stateChange(nextState); stateChange(nextState);
LockSupport.park(); LockSupport.park();
break; break;
} }
case S_TIMED_PARKED: { case S_TIMED_PARKED: {
System.out.format("%d: %s is going to timed park (interations %d)%n", log("%d: %s is going to timed park (iterations %d)%n",
getId(), getName(), iterations.get()); getId(), getName(), iterations.get());
long deadline = System.currentTimeMillis() + 10000*1000; long deadline = System.currentTimeMillis() + 10000*1000;
stateChange(nextState); stateChange(nextState);
LockSupport.parkUntil(deadline); LockSupport.parkUntil(deadline);
break; break;
} }
case S_SLEEPING: { case S_SLEEPING: {
System.out.format("%d: %s is going to sleep (interations %d interrupted %d)%n", log("%d: %s is going to sleep (iterations %d interrupted %d)%n",
getId(), getName(), iterations.get(), interrupted.get()); getId(), getName(), iterations.get(), interrupted.get());
try { try {
stateChange(nextState); stateChange(nextState);
Thread.sleep(1000000); Thread.sleep(1000000);
@ -219,8 +225,8 @@ public class ThreadStateController extends Thread {
if (newState == nextState) { if (newState == nextState) {
state = nextState; state = nextState;
phaser.arrive(); phaser.arrive();
System.out.format("%d: state change: %s %s%n", log("%d: state change: %s %s%n",
getId(), toStateName(nextState), phaserToString(phaser)); getId(), toStateName(nextState), phaserToString(phaser));
return; return;
} }
@ -270,12 +276,12 @@ public class ThreadStateController extends Thread {
private void nextState(int s) throws InterruptedException { private void nextState(int s) throws InterruptedException {
final long id = Thread.currentThread().getId(); final long id = Thread.currentThread().getId();
System.out.format("%d: wait until the thread transitions to %s %s%n", log("%d: wait until the thread transitions to %s %s%n",
id, toStateName(s), phaserToString(phaser)); id, toStateName(s), phaserToString(phaser));
this.newState = s; this.newState = s;
int phase = phaser.arrive(); int phase = phaser.arrive();
System.out.format("%d: awaiting party arrive %s %s%n", log("%d: awaiting party arrive %s %s%n",
id, toStateName(s), phaserToString(phaser)); id, toStateName(s), phaserToString(phaser));
for (;;) { for (;;) {
// when this thread has changed its state before it waits or parks // 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 // on a lock, a potential race might happen if it misses the notify
@ -301,20 +307,22 @@ public class ThreadStateController extends Thread {
} }
try { try {
phaser.awaitAdvanceInterruptibly(phase, 100, TimeUnit.MILLISECONDS); phaser.awaitAdvanceInterruptibly(phase, 100, TimeUnit.MILLISECONDS);
System.out.format("%d: arrived at %s %s%n", log("%d: arrived at %s %s%n",
id, toStateName(s), phaserToString(phaser)); id, toStateName(s), phaserToString(phaser));
return; return;
} catch (TimeoutException ex) { } catch (TimeoutException ex) {
// this thread hasn't arrived at this phase // 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) { private String phaserToString(Phaser p) {
return "[phase = " + p.getPhase() + return "[phase = " + p.getPhase() +
" parties = " + p.getRegisteredParties() + " parties = " + p.getRegisteredParties() +
" arrived = " + p.getArrivedParties() + "]"; " arrived = " + p.getArrivedParties() + "]";
} }
private String toStateName(int state) { private String toStateName(int state) {
switch (state) { switch (state) {
case S_RUNNABLE: case S_RUNNABLE:
@ -337,4 +345,20 @@ public class ThreadStateController extends Thread {
return "unknown " + state; 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(). * Thread.getState().
* *
* @author Mandy Chung * @author Mandy Chung
* @library /lib/testlibrary
* @build jdk.testlibrary.*
* @build ThreadStateTest ThreadStateController * @build ThreadStateTest ThreadStateController
* @run main/othervm -Xmixed ThreadStateTest * @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. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
@ -31,6 +31,8 @@
* @author Mandy Chung * @author Mandy Chung
* *
* @library ../../Thread * @library ../../Thread
* @library /lib/testlibrary
* @build jdk.testlibrary.*
* @build ThreadMXBeanStateTest ThreadStateController * @build ThreadMXBeanStateTest ThreadStateController
* @run main ThreadMXBeanStateTest * @run main ThreadMXBeanStateTest
*/ */
@ -44,15 +46,17 @@ public class ThreadMXBeanStateTest {
private static final ThreadMXBean tm = ManagementFactory.getThreadMXBean(); private static final ThreadMXBean tm = ManagementFactory.getThreadMXBean();
static class Lock { static class Lock {
private String name; private final String name;
Lock(String name) { Lock(String name) {
this.name = name; this.name = name;
} }
@Override
public String toString() { public String toString() {
return name; 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 { public static void main(String[] argv) throws Exception {
// Force thread state initialization now before the test // Force thread state initialization now before the test
@ -109,7 +113,7 @@ public class ThreadMXBeanStateTest {
thread.checkThreadState(TERMINATED); thread.checkThreadState(TERMINATED);
try { try {
thread.join(); System.out.println(thread.getLog());
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
System.out.println("TEST FAILED: Unexpected exception."); System.out.println("TEST FAILED: Unexpected exception.");

View File

@ -35,6 +35,7 @@ import java.sql.SQLPermission;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.PropertyPermission; import java.util.PropertyPermission;
import java.util.StringJoiner; import java.util.StringJoiner;
import java.util.logging.LoggingPermission;
/* /*
* Simple Policy class that supports the required Permissions to validate the * Simple Policy class that supports the required Permissions to validate the
@ -57,7 +58,8 @@ public class TestPolicy extends Policy {
* Policy used by the JDBC tests Possible values are: all (ALLPermissions), * Policy used by the JDBC tests Possible values are: all (ALLPermissions),
* setLog (SQLPemission("setLog"), deregisterDriver * setLog (SQLPemission("setLog"), deregisterDriver
* (SQLPermission("deregisterDriver") (SQLPermission("deregisterDriver"), * (SQLPermission("deregisterDriver") (SQLPermission("deregisterDriver"),
* and setSyncFactory(SQLPermission(setSyncFactory), * setSyncFactory(SQLPermission(setSyncFactory), and also
* LoggerPermission("control", null) when setting a Level
* *
* @param policy Permissions to set * @param policy Permissions to set
*/ */
@ -79,6 +81,11 @@ public class TestPolicy extends Policy {
setMinimalPermissions(); setMinimalPermissions();
permissions.add(new SQLPermission("setSyncFactory")); permissions.add(new SQLPermission("setSyncFactory"));
break; break;
case "setSyncFactoryLogger":
setMinimalPermissions();
permissions.add(new SQLPermission("setSyncFactory"));
permissions.add(new LoggingPermission("control", null));
break;
default: default:
setMinimalPermissions(); setMinimalPermissions();
} }

View File

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

View File

@ -0,0 +1,113 @@
/*
* 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.spi;
import java.sql.SQLException;
import javax.sql.rowset.spi.SyncFactoryException;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import util.BaseTest;
public class SyncFactoryExceptionTests extends BaseTest {
/*
* Create SyncFactoryException with no-arg constructor
*/
@Test
public void test01() {
SyncFactoryException ex = new SyncFactoryException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/*
* Create SyncFactoryException with message
*/
@Test
public void test02() {
SyncFactoryException ex = new SyncFactoryException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
/*
* Validate that the ordering of the returned Exceptions is correct using
* for-each loop
*/
@Test
public void test03() {
SyncFactoryException ex = new SyncFactoryException("Exception 1");
ex.initCause(t1);
SyncFactoryException ex1 = new SyncFactoryException("Exception 2");
SyncFactoryException ex2 = new SyncFactoryException("Exception 3");
ex2.initCause(t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/*
* Validate that the ordering of the returned Exceptions is correct using
* traditional while loop
*/
@Test
public void test04() {
SQLException ex = new SyncFactoryException("Exception 1");
ex.initCause(t1);
SyncFactoryException ex1 = new SyncFactoryException("Exception 2");
SyncFactoryException ex2 = new SyncFactoryException("Exception 3");
ex2.initCause(t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
while (ex != null) {
assertTrue(msgs[num++].equals(ex.getMessage()));
Throwable c = ex.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
ex = ex.getNextException();
}
}
/*
* Serialize a SyncFactoryException and make sure you can read it back properly
*/
@Test
public void test05() throws Exception {
SyncFactoryException e = new SyncFactoryException(reason);
SyncFactoryException ex1 = createSerializedException(e);
assertTrue(ex1.getMessage().equals(reason)
&& ex1.getSQLState() == null
&& ex1.getCause() == null
&& ex1.getErrorCode() == 0);
}
}

View File

@ -27,13 +27,13 @@ import java.security.Policy;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.naming.Context; import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.rowset.spi.SyncFactory; import javax.sql.rowset.spi.SyncFactory;
import javax.sql.rowset.spi.SyncFactoryException;
import org.testng.annotations.AfterClass; import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass; import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test; import org.testng.annotations.Test;
import util.BaseTest; import util.BaseTest;
import util.StubContext;
import util.TestPolicy; import util.TestPolicy;
public class SyncFactoryPermissionsTests extends BaseTest { public class SyncFactoryPermissionsTests extends BaseTest {
@ -41,6 +41,7 @@ public class SyncFactoryPermissionsTests extends BaseTest {
Context ctx; Context ctx;
private static Policy policy; private static Policy policy;
private static SecurityManager sm; private static SecurityManager sm;
private final Logger alogger = Logger.getLogger(this.getClass().getName());
/* /*
* Install a SeeurityManager along with a base Policy to allow testNG to run * Install a SeeurityManager along with a base Policy to allow testNG to run
@ -67,13 +68,7 @@ public class SyncFactoryPermissionsTests extends BaseTest {
public SyncFactoryPermissionsTests() { public SyncFactoryPermissionsTests() {
policy = Policy.getPolicy(); policy = Policy.getPolicy();
sm = System.getSecurityManager(); sm = System.getSecurityManager();
ctx = new StubContext();
try {
ctx = new InitialContext();
} catch (NamingException ex) {
Logger.getLogger(SyncFactoryPermissionsTests.class.getName()).
log(Level.SEVERE, null, ex);
}
} }
/* /*
@ -86,13 +81,21 @@ public class SyncFactoryPermissionsTests extends BaseTest {
SyncFactory.setJNDIContext(ctx); SyncFactory.setJNDIContext(ctx);
} }
/*
* Validate that a SyncFactoryException is thrown if the Logger is null
*/
@Test(expectedExceptions = SyncFactoryException.class)
public void test00() throws SyncFactoryException {
Logger l = SyncFactory.getLogger();
}
/* /*
* Validate that setJNDIContext succeeds if SQLPermission("setSyncFactory") * Validate that setJNDIContext succeeds if SQLPermission("setSyncFactory")
* has been granted * has been granted
*/ */
@Test @Test
public void test1() throws Exception { public void test01() throws Exception {
Policy.setPolicy(new TestPolicy("setSyncFactory")); setPolicy(new TestPolicy("setSyncFactory"));
SyncFactory.setJNDIContext(ctx); SyncFactory.setJNDIContext(ctx);
} }
@ -100,8 +103,77 @@ public class SyncFactoryPermissionsTests extends BaseTest {
* Validate that setJNDIContext succeeds if AllPermissions has been granted * Validate that setJNDIContext succeeds if AllPermissions has been granted
*/ */
@Test @Test
public void test2() throws Exception { public void test02() throws Exception {
setPolicy(new TestPolicy("all")); setPolicy(new TestPolicy("all"));
SyncFactory.setJNDIContext(ctx); SyncFactory.setJNDIContext(ctx);
} }
/*
* Validate that AccessControlException is thrown if
* SQLPermission("setSyncFactory") has not been granted
*/
@Test(expectedExceptions = AccessControlException.class)
public void test03() throws Exception {
setPolicy(new TestPolicy());
SyncFactory.setLogger(alogger);
}
/*
* Validate that setLogger succeeds if SQLPermission("setSyncFactory")
* has been granted
*/
@Test
public void test04() throws Exception {
setPolicy(new TestPolicy("setSyncFactory"));
SyncFactory.setLogger(alogger);
}
/*
* Validate that setLogger succeeds if AllPermissions has been granted
*/
@Test
public void test05() throws Exception {
setPolicy(new TestPolicy("all"));
SyncFactory.setLogger(alogger);
}
/*
* Validate that AccessControlException is thrown if
* SQLPermission("setSyncFactory") has not been granted
*/
@Test(expectedExceptions = AccessControlException.class)
public void test06() throws Exception {
setPolicy(new TestPolicy());
SyncFactory.setLogger(alogger, Level.INFO);
}
/*
* Validate that AccessControlException is thrown if
* SQLPermission("setSyncFactory") and LoggingPermission("control", null)
* have not been granted
*/
@Test(expectedExceptions = AccessControlException.class)
public void test07() throws Exception {
setPolicy(new TestPolicy("setSyncFactory"));
SyncFactory.setLogger(alogger, Level.INFO);
}
/*
* Validate that setLogger succeeds if SQLPermission("setSyncFactory")
* has been granted
*/
@Test
public void test08() throws Exception {
setPolicy(new TestPolicy("setSyncFactoryLogger"));
SyncFactory.setLogger(alogger, Level.INFO);
}
/*
* Validate that setLogger succeeds if AllPermissions has been granted
*/
@Test
public void test09() throws Exception {
setPolicy(new TestPolicy("all"));
SyncFactory.setLogger(alogger, Level.INFO);
}
} }

View File

@ -0,0 +1,220 @@
/*
* 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.spi;
import com.sun.rowset.providers.RIOptimisticProvider;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Enumeration;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.sql.rowset.spi.SyncFactory;
import javax.sql.rowset.spi.SyncFactoryException;
import javax.sql.rowset.spi.SyncProvider;
import static org.testng.Assert.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import util.PropertyStubProvider;
import util.StubSyncProvider;
import util.StubContext;
//com.sun.jndi.ldap.LdapCtxFactory
public class SyncFactoryTests {
private static String origFactory;
private final String stubProvider = "util.StubSyncProvider";
private final String propertyStubProvider = "util.PropertyStubProvider";
private final Logger alogger = Logger.getLogger(this.getClass().getName());
// Initial providers including those set via a property
List<String> initialProviders;
// All providers including those specifically registered
List<String> allProviders;
private Context ctx= null;
public SyncFactoryTests() {
// Add a provider via a property
System.setProperty("rowset.provider.classname", propertyStubProvider);
initialProviders = Arrays.asList(
"com.sun.rowset.providers.RIOptimisticProvider",
"com.sun.rowset.providers.RIXMLProvider",
propertyStubProvider);
allProviders = new ArrayList<>();
allProviders.addAll(initialProviders);
allProviders.add(stubProvider);
ctx = new StubContext();
}
@BeforeMethod
public void setUpMethod() throws Exception {
// Make sure the provider provider that is registered is removed
// before each run
SyncFactory.unregisterProvider(stubProvider);
}
/*
* Validate a non-null factory is returned
*/
@Test
public void test() throws SyncFactoryException {
SyncFactory syncFactory = SyncFactory.getSyncFactory();
assertTrue(syncFactory != null);
}
/*
* Check that the correct SyncProvider is returned for the specified
* providerID for the provider registered via a property
*/
@Test
public void test00() throws SyncFactoryException {
SyncProvider p = SyncFactory.getInstance(propertyStubProvider);
assertTrue(p instanceof PropertyStubProvider);
}
/*
* Check that the correct SyncProvider is returned for the specified
* providerID
*/
@Test
public void test01() throws SyncFactoryException {
SyncFactory.registerProvider(stubProvider);
SyncProvider p = SyncFactory.getInstance(stubProvider);
assertTrue(p instanceof StubSyncProvider);
}
/*
* Check that the Default SyncProvider is returned if an empty String is
* passed or if an invalid providerID is specified
*/
@Test
public void test02() throws SyncFactoryException {
SyncProvider p = SyncFactory.getInstance("");
assertTrue(p instanceof RIOptimisticProvider);
// Attempt to get an invalid provider and get the default provider
p = SyncFactory.getInstance("util.InvalidSyncProvider");
assertTrue(p instanceof RIOptimisticProvider);
}
/*
* Validate that a SyncFactoryException is thrown if the ProviderID is null
*/
@Test(expectedExceptions = SyncFactoryException.class)
public void test03() throws SyncFactoryException {
SyncProvider p = SyncFactory.getInstance(null);
}
/*
* Validate that a SyncFactoryException is thrown if the Logger is null
*/
@Test(expectedExceptions = SyncFactoryException.class,enabled=true)
public void test04() throws SyncFactoryException {
Logger l = SyncFactory.getLogger();
}
/*
* Validate that the correct logger is returned by getLogger
*/
@Test
public void test05() throws SyncFactoryException {
SyncFactory.setLogger(alogger);
Logger l = SyncFactory.getLogger();
assertTrue(l.equals(alogger));
}
/*
* Validate that the correct logger is returned by getLogger
*/
@Test
public void test06() throws SyncFactoryException {
SyncFactory.setLogger(alogger, Level.INFO);
Logger l = SyncFactory.getLogger();
assertTrue(l.equals(alogger));
}
/*
* Validate that a driver that is registered is returned by
* getRegisteredProviders and if it is unregistered, that it is
* not returned by getRegisteredProviders
*/
@Test
public void test07() throws SyncFactoryException {
// Validate that only the default providers and any specified via
// a System property are available
validateProviders(initialProviders);
// Register a provider and make sure it is avaiable
SyncFactory.registerProvider(stubProvider);
validateProviders(allProviders);
// Check that if a provider is unregistered, it does not show as
// registered
SyncFactory.unregisterProvider(stubProvider);
validateProviders(initialProviders);
}
/*
* Validate that setJNDIContext throws a SyncFactoryException if the
* context is null
*/
@Test(expectedExceptions = SyncFactoryException.class, enabled=true)
public void test08() throws Exception {
SyncFactory.setJNDIContext(null);
}
/*
* Validate that setJNDIContext succeeds
*/
@Test(enabled=true)
public void test09() throws Exception {
SyncFactory.setJNDIContext(ctx);
}
/*
* Utility method to validate the expected providers are regsitered
*/
private void validateProviders(List<String> expectedProviders)
throws SyncFactoryException {
List<String> results = new ArrayList<>();
Enumeration<SyncProvider> providers = SyncFactory.getRegisteredProviders();
while (providers.hasMoreElements()) {
SyncProvider p = providers.nextElement();
results.add(p.getProviderID());
}
assertTrue(expectedProviders.containsAll(results)
&& results.size() == expectedProviders.size());
}
/*
* Utility method to dump out SyncProvider info for a registered provider
*/
private void showImpl(SyncProvider impl) {
System.out.println("Provider implementation:"
+ "\nVendor: " + impl.getVendor()
+ "\nVersion: " + impl.getVersion()
+ "\nProviderID: " + impl.getProviderID());
}
}

View File

@ -0,0 +1,187 @@
/*
* 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.spi;
import com.sun.rowset.internal.SyncResolverImpl;
import java.sql.SQLException;
import javax.sql.rowset.spi.SyncProviderException;
import static org.testng.Assert.*;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import util.BaseTest;
import util.StubSyncResolver;
public class SyncProviderExceptionTests extends BaseTest {
@BeforeClass
public static void setUpClass() throws Exception {
System.out.println(System.getProperty("java.naming.factory.initial"));
}
@AfterClass
public static void tearDownClass() throws Exception {
}
/*
* Create SyncProviderException with no-arg constructor
*/
@Test
public void test() {
SyncProviderException ex = new SyncProviderException();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getSyncResolver() instanceof SyncResolverImpl);
}
/*
* Create SyncProviderException with no-arg constructor and
* call setSyncResolver to indicate the SyncResolver to use
*/
@Test
public void test01() {
SyncProviderException ex = new SyncProviderException();
ex.setSyncResolver(new StubSyncResolver());
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getSyncResolver() instanceof StubSyncResolver);
}
/*
* Create SyncProviderException with message
*/
@Test
public void test02() {
SyncProviderException ex = new SyncProviderException(reason);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getSyncResolver() instanceof SyncResolverImpl);
}
/*
* Create SyncProviderException with message and
* call setSyncResolver to indicate the SyncResolver to use
*/
@Test
public void test03() {
SyncProviderException ex = new SyncProviderException(reason);
ex.setSyncResolver(new StubSyncResolver());
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getSyncResolver() instanceof StubSyncResolver);
}
/*
* Create SyncProviderException with and specify the SyncResolver to use
*/
@Test
public void test04() {
SyncProviderException ex = new SyncProviderException(new StubSyncResolver());
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0
&& ex.getSyncResolver() instanceof StubSyncResolver);
}
/*
* Validate that the ordering of the returned Exceptions is correct using
* for-each loop
*/
@Test
public void test05() {
SyncProviderException ex = new SyncProviderException("Exception 1");
ex.initCause(t1);
SyncProviderException ex1 = new SyncProviderException("Exception 2");
SyncProviderException ex2 = new SyncProviderException("Exception 3");
ex2.initCause(t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
for (Throwable e : ex) {
assertTrue(msgs[num++].equals(e.getMessage()));
}
}
/*
* Validate that the ordering of the returned Exceptions is correct using
* traditional while loop
*/
@Test
public void test06() {
SQLException ex = new SyncProviderException("Exception 1");
ex.initCause(t1);
SyncProviderException ex1 = new SyncProviderException("Exception 2");
SyncProviderException ex2 = new SyncProviderException("Exception 3");
ex2.initCause(t2);
ex.setNextException(ex1);
ex.setNextException(ex2);
int num = 0;
while (ex != null) {
assertTrue(msgs[num++].equals(ex.getMessage()));
Throwable c = ex.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
ex = ex.getNextException();
}
}
/*
* Serialize a SyncProviderException and make sure you can read it back properly
*/
@Test
public void test07() throws Exception {
SyncProviderException e = new SyncProviderException(reason);
SyncProviderException ex1 = createSerializedException(e);
assertTrue(ex1.getMessage().equals(reason)
&& ex1.getSQLState() == null
&& ex1.getCause() == null
&& ex1.getErrorCode() == 0
&& ex1.getSyncResolver() instanceof SyncResolverImpl, ex1.getSyncResolver().getClass().getName());
}
/*
* Serialize a SyncProviderException and make sure you can read it back properly
*/
@Test
public void test08() throws Exception {
SyncProviderException e = new SyncProviderException(reason);
e.setSyncResolver(new StubSyncResolver());
SyncProviderException ex1 = createSerializedException(e);
assertTrue(ex1.getMessage().equals(reason)
&& ex1.getSQLState() == null
&& ex1.getCause() == null
&& ex1.getErrorCode() == 0
&& ex1.getSyncResolver() instanceof StubSyncResolver);
}
}

View File

@ -0,0 +1,27 @@
/*
* 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;
public class PropertyStubProvider extends StubSyncProvider {
}

View File

@ -0,0 +1,220 @@
/*
* 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.util.Hashtable;
import javax.naming.Binding;
import javax.naming.Context;
import javax.naming.Name;
import javax.naming.NameClassPair;
import javax.naming.NameParser;
import javax.naming.NamingEnumeration;
import javax.naming.NamingException;
@SuppressWarnings("unchecked")
public class StubContext implements Context {
@Override
public Object lookup(Name name) throws NamingException {
return null;
}
@Override
public Object lookup(String name) throws NamingException {
return null;
}
@Override
public void bind(Name name, Object obj) throws NamingException {
}
@Override
public void bind(String name, Object obj) throws NamingException {
}
@Override
public void rebind(Name name, Object obj) throws NamingException {
}
@Override
public void rebind(String name, Object obj) throws NamingException {
}
@Override
public void unbind(Name name) throws NamingException {
}
@Override
public void unbind(String name) throws NamingException {
}
@Override
public void rename(Name oldName, Name newName) throws NamingException {
}
@Override
public void rename(String oldName, String newName) throws NamingException {
}
@Override
public NamingEnumeration<NameClassPair> list(Name name) throws NamingException {
return new NamingEnumerationStub();
}
@Override
public NamingEnumeration<NameClassPair> list(String name) throws NamingException {
return new NamingEnumerationStub();
}
@Override
public NamingEnumeration<Binding> listBindings(Name name) throws NamingException {
return new NamingEnumerationStub();
}
@Override
public NamingEnumeration<Binding> listBindings(String name) throws NamingException {
return new NamingEnumerationStub();
}
@Override
public void destroySubcontext(Name name) throws NamingException {
}
@Override
public void destroySubcontext(String name) throws NamingException {
}
@Override
public Context createSubcontext(Name name) throws NamingException {
return null;
}
@Override
public Context createSubcontext(String name) throws NamingException {
return null;
}
@Override
public Object lookupLink(Name name) throws NamingException {
return null;
}
@Override
public Object lookupLink(String name) throws NamingException {
return null;
}
@Override
public NameParser getNameParser(Name name) throws NamingException {
return new NameParserStub();
}
@Override
public NameParser getNameParser(String name) throws NamingException {
return new NameParserStub();
}
@Override
public Name composeName(Name name, Name prefix) throws NamingException {
return null;
}
@Override
public String composeName(String name, String prefix) throws NamingException {
return null;
}
@Override
public Object addToEnvironment(String propName, Object propVal) throws NamingException {
return null;
}
@Override
public Object removeFromEnvironment(String propName) throws NamingException {
return null;
}
@Override
public Hashtable<?, ?> getEnvironment() throws NamingException {
return new Hashtable();
}
@Override
public void close() throws NamingException {
}
@Override
public String getNameInNamespace() throws NamingException {
return null;
}
class NamingEnumerationStub implements NamingEnumeration {
@Override
public Object next() throws NamingException {
return null;
}
@Override
public boolean hasMore() throws NamingException {
return false;
}
@Override
public void close() throws NamingException {
}
@Override
public boolean hasMoreElements() {
return false;
}
@Override
public Object nextElement() {
return null;
}
}
class NameParserStub implements NameParser {
@Override
public Name parse(String name) throws NamingException {
return null;
}
}
}

View File

@ -0,0 +1,92 @@
/*
* 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.RowSetReader;
import javax.sql.RowSetWriter;
import javax.sql.rowset.spi.SyncProvider;
import javax.sql.rowset.spi.SyncProviderException;
public class StubSyncProvider extends SyncProvider {
/**
* The unique provider identifier.
*/
private String providerID = "util.StubSyncProvider";
/**
* The vendor name of this SyncProvider implementation
*/
private String vendorName = "Oracle Corporation";
/**
* The version number of this SyncProvider implementation
*/
private String versionNumber = "1.0";
@Override
public String getProviderID() {
return providerID;
}
@Override
public RowSetReader getRowSetReader() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public RowSetWriter getRowSetWriter() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getProviderGrade() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setDataSourceLock(int datasource_lock) throws SyncProviderException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getDataSourceLock() throws SyncProviderException {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int supportsUpdatableView() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public String getVersion() {
return versionNumber;
}
@Override
public String getVendor() {
return vendorName;
}
}

File diff suppressed because it is too large Load Diff

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,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

@ -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 { void testOK(String input, String cmd) throws Exception {
try { 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); test(input, cmd);
} catch(Exception e) { } catch(Exception e) {
afterFail(input, cmd, "OK"); afterFail(input, cmd, "OK");
@ -245,6 +252,9 @@ public class KeyToolTest {
* Helper method, print some output after a test does not do as expected * Helper method, print some output after a test does not do as expected
*/ */
void afterFail(String input, String cmd, String should) { 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" + System.err.println("\nTest fails for the command ---\n" +
"keytool " + cmd + "\nOr its debug version ---\n" + "keytool " + cmd + "\nOr its debug version ---\n" +
"keytool -debug " + cmd); "keytool -debug " + cmd);
@ -799,7 +809,7 @@ public class KeyToolTest {
remove("x.jks.p1.cert"); remove("x.jks.p1.cert");
remove("csr1"); remove("csr1");
// PrivateKeyEntry can do certreq // 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 -alias mykey");
testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1"); testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1");
testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1 -sigalg SHA1withDSA"); testOK("", "-keystore x.jks -storepass changeit -certreq -file csr1 -sigalg SHA1withDSA");

View File

@ -118,13 +118,4 @@ echo | ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Dnss \
KeyToolTest KeyToolTest
status=$? status=$?
rm -f p11-nss.txt
rm -f cert8.db
rm -f key3.db
rm -f secmod.db
rm HumanInputStream*.class
rm KeyToolTest*.class
rm TestException.class
exit $status exit $status

View File

@ -62,9 +62,5 @@ ${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d . -XDigno
echo | ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Dfile KeyToolTest echo | ${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -Dfile KeyToolTest
status=$? status=$?
rm HumanInputStream*.class
rm KeyToolTest*.class
rm TestException.class
exit $status exit $status

View File

@ -1,4 +1,4 @@
# Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
# #
# This code is free software; you can redistribute it and/or modify it # This code is free software; you can redistribute it and/or modify it
@ -335,6 +335,14 @@ endif
################################################################# #################################################################
#
# Load custom Javadoc rules
#
$(eval $(call IncludeCustomExtension, , Javadoc.gmk))
#################################################################
# #
# Default target is same as docs target, create core api and all others it can # Default target is same as docs target, create core api and all others it can
# #

View File

@ -514,7 +514,7 @@ clean-docs: clean-docstemp
# If the output directory was created by configure and now becomes empty, remove it as well. # If the output directory was created by configure and now becomes empty, remove it as well.
dist-clean: clean dist-clean: clean
($(CD) $(OUTPUT_ROOT) && $(RM) -r *spec.gmk config.* configure-arguments \ ($(CD) $(OUTPUT_ROOT) && $(RM) -r *spec.gmk config.* configure-arguments \
Makefile compare.sh spec.sh tmp javacservers) Makefile compare.sh tmp javacservers)
$(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \ $(if $(filter $(CONF_NAME),$(notdir $(OUTPUT_ROOT))), \
if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \ if test "x`$(LS) $(OUTPUT_ROOT)`" != x; then \
$(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \ $(ECHO) "Warning: Not removing non-empty configuration directory for '$(CONF_NAME)'" ; \

View File

@ -791,18 +791,9 @@
<export> <export>
<name>javax.management.timer</name> <name>javax.management.timer</name>
</export> </export>
<export>
<name>com.sun.jmx.defaults</name>
<to>jdk.snmp</to>
</export>
<export>
<name>com.sun.jmx.mbeanserver</name>
<to>jdk.snmp</to>
</export>
<export> <export>
<name>sun.management</name> <name>sun.management</name>
<to>jdk.jconsole</to> <to>jdk.jconsole</to>
<to>jdk.snmp</to>
</export> </export>
</module> </module>
<module> <module>