Merge
This commit is contained in:
commit
c6e7f87632
2
.hgtags
2
.hgtags
@ -342,3 +342,5 @@ f242d4332f563648426a1b0fa02d8741beba19ef jdk9-b92
|
||||
4edcff1b9a8875eb6380a2165dfec599e8e3f7c0 jdk-9+97
|
||||
d00ad2d9049ac60815f70bff445e95df85648bd2 jdk-9+98
|
||||
f9bcdce2df26678c3fe468130b535c0342c69b89 jdk-9+99
|
||||
4379223f8806626852c46c52d4e7a27a584b406e jdk-9+100
|
||||
80f67512daa15cf37b4825c1c62a675d524d7c49 jdk-9+101
|
||||
|
@ -342,3 +342,5 @@ cf1dc4c035fb84693d4ae5ad818785cb4d1465d1 jdk9-b90
|
||||
75c3897541ecb52ee16d001ea605b12971df7303 jdk-9+97
|
||||
48987460c7d49a29013963ee44d090194396bb61 jdk-9+98
|
||||
7c0577bea4c65d69c5bef67023a89d2efa4fb2f7 jdk-9+99
|
||||
c1f30ac14db0eaff398429c04cd9fab92e1b4b2a jdk-9+100
|
||||
c4d72a1620835b5d657b7b6792c2879367d0154f jdk-9+101
|
||||
|
@ -23,6 +23,74 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Create a function/macro that takes a series of named arguments. The call is
|
||||
# similar to AC_DEFUN, but the setup of the function looks like this:
|
||||
# BASIC_DEFUN_NAMED([MYFUNC], [FOO *BAR], [$@], [
|
||||
# ... do something
|
||||
# AC_MSG_NOTICE([Value of BAR is ARG_BAR])
|
||||
# ])
|
||||
# A star (*) in front of a named argument means that it is required and it's
|
||||
# presence will be verified. To pass e.g. the first value as a normal indexed
|
||||
# argument, use [m4_shift($@)] as the third argument instead of [$@]. These
|
||||
# arguments are referenced in the function by their name prefixed by ARG_, e.g.
|
||||
# "ARG_FOO".
|
||||
#
|
||||
# The generated function can be called like this:
|
||||
# MYFUNC(FOO: [foo-val], BAR:
|
||||
# [
|
||||
# $ECHO hello world
|
||||
# ])
|
||||
#
|
||||
#
|
||||
# Argument 1: Name of the function to define
|
||||
# Argument 2: List of legal named arguments, with a * prefix for required arguments
|
||||
# Argument 3: Argument array to treat as named, typically $@
|
||||
# Argument 4: The main function body
|
||||
AC_DEFUN([BASIC_DEFUN_NAMED],
|
||||
[
|
||||
AC_DEFUN($1, [
|
||||
m4_foreach(arg, m4_split($2), [
|
||||
m4_if(m4_bregexp(arg, [^\*]), -1,
|
||||
[
|
||||
m4_set_add(legal_named_args, arg)
|
||||
],
|
||||
[
|
||||
m4_set_add(legal_named_args, m4_substr(arg, 1))
|
||||
m4_set_add(required_named_args, m4_substr(arg, 1))
|
||||
]
|
||||
)
|
||||
])
|
||||
|
||||
m4_foreach([arg], [$3], [
|
||||
m4_define(arg_name, m4_substr(arg, 0, m4_bregexp(arg, [: ])))
|
||||
m4_set_contains(legal_named_args, arg_name, [],[AC_MSG_ERROR([Internal error: arg_name is not a valid named argument to [$1]. Valid arguments are 'm4_set_contents(legal_named_args, [ ])'.])])
|
||||
m4_set_remove(required_named_args, arg_name)
|
||||
m4_set_remove(legal_named_args, arg_name)
|
||||
m4_pushdef([ARG_][]arg_name, m4_substr(arg, m4_incr(m4_incr(m4_bregexp(arg, [: ])))))
|
||||
m4_set_add(defined_args, arg_name)
|
||||
m4_undefine([arg_name])
|
||||
])
|
||||
m4_set_empty(required_named_args, [], [
|
||||
AC_MSG_ERROR([Internal error: Required named arguments are missing for [$1]. Missing arguments: 'm4_set_contents(required_named_args, [ ])'])
|
||||
])
|
||||
m4_foreach([arg], m4_indir([m4_dquote]m4_set_listc([legal_named_args])), [
|
||||
m4_pushdef([ARG_][]arg, [])
|
||||
m4_set_add(defined_args, arg)
|
||||
])
|
||||
m4_set_delete(legal_named_args)
|
||||
m4_set_delete(required_named_args)
|
||||
|
||||
# Execute function body
|
||||
$4
|
||||
|
||||
m4_foreach([arg], m4_indir([m4_dquote]m4_set_listc([defined_args])), [
|
||||
m4_popdef([ARG_][]arg)
|
||||
])
|
||||
|
||||
m4_set_delete(defined_args)
|
||||
])
|
||||
])
|
||||
|
||||
# Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
|
||||
# If so, then append $1 to $2 \
|
||||
# Also set JVM_ARG_OK to true/false depending on outcome.
|
||||
@ -1122,7 +1190,6 @@ AC_DEFUN_ONCE([BASIC_POST_CONFIG_OUTPUT],
|
||||
|
||||
# Move configure.log from current directory to the build output root
|
||||
if test -e ./configure.log; then
|
||||
echo found it
|
||||
$MV -f ./configure.log "$OUTPUT_ROOT/configure.log" 2> /dev/null
|
||||
fi
|
||||
|
||||
|
@ -251,6 +251,24 @@ AC_DEFUN([BPERF_SETUP_CCACHE_USAGE],
|
||||
fi
|
||||
])
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Runs icecc-create-env once and prints the error if it fails
|
||||
#
|
||||
# $1: arguments to icecc-create-env
|
||||
# $2: log file
|
||||
#
|
||||
AC_DEFUN([BPERF_RUN_ICECC_CREATE_ENV],
|
||||
[
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} $1 > $2 2>&1
|
||||
if test "$?" != "0"; then
|
||||
AC_MSG_NOTICE([icecc-create-env output:])
|
||||
cat $2
|
||||
AC_MSG_ERROR([Failed to create icecc compiler environment])
|
||||
fi
|
||||
])
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Optionally enable distributed compilation of native code using icecc/icecream
|
||||
@ -271,16 +289,18 @@ AC_DEFUN([BPERF_SETUP_ICECC],
|
||||
# be sent to the other hosts in the icecream cluster.
|
||||
icecc_create_env_log="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/icecc_create_env.log"
|
||||
${MKDIR} -p ${CONFIGURESUPPORT_OUTPUTDIR}/icecc
|
||||
AC_MSG_CHECKING([for icecc build environment for target compiler])
|
||||
# Older versions of icecc does not have the --gcc parameter
|
||||
if ${ICECC_CREATE_ENV} | $GREP -q -e --gcc; then
|
||||
icecc_gcc_arg="--gcc"
|
||||
fi
|
||||
if test "x${TOOLCHAIN_TYPE}" = "xgcc"; then
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} --gcc ${CC} ${CXX} > ${icecc_create_env_log}
|
||||
BPERF_RUN_ICECC_CREATE_ENV([${icecc_gcc_arg} ${CC} ${CXX}], \
|
||||
${icecc_create_env_log})
|
||||
elif test "x$TOOLCHAIN_TYPE" = "xclang"; then
|
||||
# For clang, the icecc compilerwrapper is needed. It usually resides next
|
||||
# to icecc-create-env.
|
||||
BASIC_REQUIRE_PROGS(ICECC_WRAPPER, compilerwrapper)
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} --clang ${CC} ${ICECC_WRAPPER} > ${icecc_create_env_log}
|
||||
BPERF_RUN_ICECC_CREATE_ENV([--clang ${CC} ${ICECC_WRAPPER}], ${icecc_create_env_log})
|
||||
else
|
||||
AC_MSG_ERROR([Can only create icecc compiler packages for toolchain types gcc and clang])
|
||||
fi
|
||||
@ -289,24 +309,31 @@ AC_DEFUN([BPERF_SETUP_ICECC],
|
||||
# to find it.
|
||||
ICECC_ENV_BUNDLE_BASENAME="`${SED} -n '/^creating/s/creating //p' ${icecc_create_env_log}`"
|
||||
ICECC_ENV_BUNDLE="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/${ICECC_ENV_BUNDLE_BASENAME}"
|
||||
if test ! -f ${ICECC_ENV_BUNDLE}; then
|
||||
AC_MSG_ERROR([icecc-create-env did not produce an environment ${ICECC_ENV_BUNDLE}])
|
||||
fi
|
||||
AC_MSG_CHECKING([for icecc build environment for target compiler])
|
||||
AC_MSG_RESULT([${ICECC_ENV_BUNDLE}])
|
||||
ICECC="ICECC_VERSION=${ICECC_ENV_BUNDLE} ICECC_CC=${CC} ICECC_CXX=${CXX} ${ICECC_CMD}"
|
||||
|
||||
if test "x${COMPILE_TYPE}" = "xcross"; then
|
||||
# If cross compiling, create a separate env package for the build compiler
|
||||
AC_MSG_CHECKING([for icecc build environment for build compiler])
|
||||
# Assume "gcc" or "cc" is gcc and "clang" is clang. Otherwise bail.
|
||||
icecc_create_env_log_build="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/icecc_create_env_build.log"
|
||||
if test "x${BUILD_CC##*/}" = "xgcc" || test "x${BUILD_CC##*/}" = "xcc"; then
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} --gcc ${BUILD_CC} ${BUILD_CXX} > ${icecc_create_env_log}
|
||||
BPERF_RUN_ICECC_CREATE_ENV([${icecc_gcc_arg} ${BUILD_CC} ${BUILD_CXX}], \
|
||||
${icecc_create_env_log_build})
|
||||
elif test "x${BUILD_CC##*/}" = "xclang"; then
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} --clang ${BUILD_CC} ${ICECC_WRAPPER} > ${icecc_create_env_log}
|
||||
BPERF_RUN_ICECC_CREATE_ENV([--clang ${BUILD_CC} ${ICECC_WRAPPER}], ${icecc_create_env_log_build})
|
||||
else
|
||||
AC_MSG_ERROR([Cannot create icecc compiler package for ${BUILD_CC}])
|
||||
fi
|
||||
ICECC_ENV_BUNDLE_BASENAME="`${SED} -n '/^creating/s/creating //p' ${icecc_create_env_log}`"
|
||||
ICECC_ENV_BUNDLE_BASENAME="`${SED} -n '/^creating/s/creating //p' ${icecc_create_env_log_build}`"
|
||||
ICECC_ENV_BUNDLE="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/${ICECC_ENV_BUNDLE_BASENAME}"
|
||||
if test ! -f ${ICECC_ENV_BUNDLE}; then
|
||||
AC_MSG_ERROR([icecc-create-env did not produce an environment ${ICECC_ENV_BUNDLE}])
|
||||
fi
|
||||
AC_MSG_CHECKING([for icecc build environment for build compiler])
|
||||
AC_MSG_RESULT([${ICECC_ENV_BUNDLE}])
|
||||
BUILD_ICECC="ICECC_VERSION=${ICECC_ENV_BUNDLE} ICECC_CC=${BUILD_CC} \
|
||||
ICECC_CXX=${BUILD_CXX} ${ICECC_CMD}"
|
||||
|
@ -128,6 +128,26 @@ AC_DEFUN_ONCE([FLAGS_SETUP_INIT_FLAGS],
|
||||
else
|
||||
COMPILER_TARGET_BITS_FLAG="-m"
|
||||
COMPILER_COMMAND_FILE_FLAG="@"
|
||||
|
||||
# The solstudio linker does not support @-files.
|
||||
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
||||
COMPILER_COMMAND_FILE_FLAG=
|
||||
fi
|
||||
|
||||
# Check if @file is supported by gcc
|
||||
if test "x$TOOLCHAIN_TYPE" = xgcc; then
|
||||
AC_MSG_CHECKING([if @file is supported by gcc])
|
||||
# Extra emtpy "" to prevent ECHO from interpreting '--version' as argument
|
||||
$ECHO "" "--version" > command.file
|
||||
if $CXX @command.file 2>&AS_MESSAGE_LOG_FD >&AS_MESSAGE_LOG_FD; then
|
||||
AC_MSG_RESULT(yes)
|
||||
COMPILER_COMMAND_FILE_FLAG="@"
|
||||
else
|
||||
AC_MSG_RESULT(no)
|
||||
COMPILER_COMMAND_FILE_FLAG=
|
||||
fi
|
||||
rm -rf command.file
|
||||
fi
|
||||
fi
|
||||
AC_SUBST(COMPILER_TARGET_BITS_FLAG)
|
||||
AC_SUBST(COMPILER_COMMAND_FILE_FLAG)
|
||||
@ -405,7 +425,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_OPTIMIZATION],
|
||||
# Add runtime stack smashing and undefined behavior checks.
|
||||
# Not all versions of gcc support -fstack-protector
|
||||
STACK_PROTECTOR_CFLAG="-fstack-protector-all"
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS([$STACK_PROTECTOR_CFLAG], [], [STACK_PROTECTOR_CFLAG=""])
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$STACK_PROTECTOR_CFLAG], IF_FALSE: [STACK_PROTECTOR_CFLAG=""])
|
||||
|
||||
CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
|
||||
CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
|
||||
@ -722,7 +742,7 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
|
||||
-I${JDK_TOPDIR}/src/java.base/share/native/include \
|
||||
-I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS/native/include \
|
||||
-I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/include \
|
||||
-I${JDK_TOPDIR}/src/java.base/share/native/libjava \
|
||||
-I${JDK_TOPDIR}/src/java.base/share/native/libjava \
|
||||
-I${JDK_TOPDIR}/src/java.base/$OPENJDK_TARGET_OS_TYPE/native/libjava"
|
||||
|
||||
# The shared libraries are compiled using the picflag.
|
||||
@ -876,17 +896,18 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_FOR_JDK],
|
||||
AC_SUBST(LDFLAGS_TESTEXE)
|
||||
])
|
||||
|
||||
# FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
|
||||
# [RUN-IF-FALSE])
|
||||
# FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
|
||||
# IF_FALSE: [RUN-IF-FALSE])
|
||||
# ------------------------------------------------------------
|
||||
# Check that the c and c++ compilers support an argument
|
||||
AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS],
|
||||
BASIC_DEFUN_NAMED([FLAGS_COMPILER_CHECK_ARGUMENTS],
|
||||
[*ARGUMENT IF_TRUE IF_FALSE], [$@],
|
||||
[
|
||||
AC_MSG_CHECKING([if compiler supports "$1"])
|
||||
AC_MSG_CHECKING([if compiler supports "ARG_ARGUMENT"])
|
||||
supports=yes
|
||||
|
||||
saved_cflags="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $1"
|
||||
CFLAGS="$CFLAGS ARG_ARGUMENT"
|
||||
AC_LANG_PUSH([C])
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
|
||||
[supports=no])
|
||||
@ -894,7 +915,7 @@ AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS],
|
||||
CFLAGS="$saved_cflags"
|
||||
|
||||
saved_cxxflags="$CXXFLAGS"
|
||||
CXXFLAGS="$CXXFLAG $1"
|
||||
CXXFLAGS="$CXXFLAG ARG_ARGUMENT"
|
||||
AC_LANG_PUSH([C++])
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[int i;]])], [],
|
||||
[supports=no])
|
||||
@ -903,23 +924,26 @@ AC_DEFUN([FLAGS_COMPILER_CHECK_ARGUMENTS],
|
||||
|
||||
AC_MSG_RESULT([$supports])
|
||||
if test "x$supports" = "xyes" ; then
|
||||
m4_ifval([$2], [$2], [:])
|
||||
:
|
||||
ARG_IF_TRUE
|
||||
else
|
||||
m4_ifval([$3], [$3], [:])
|
||||
:
|
||||
ARG_IF_FALSE
|
||||
fi
|
||||
])
|
||||
|
||||
# FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
|
||||
# [RUN-IF-FALSE])
|
||||
# FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
|
||||
# IF_FALSE: [RUN-IF-FALSE])
|
||||
# ------------------------------------------------------------
|
||||
# Check that the linker support an argument
|
||||
AC_DEFUN([FLAGS_LINKER_CHECK_ARGUMENTS],
|
||||
BASIC_DEFUN_NAMED([FLAGS_LINKER_CHECK_ARGUMENTS],
|
||||
[*ARGUMENT IF_TRUE IF_FALSE], [$@],
|
||||
[
|
||||
AC_MSG_CHECKING([if linker supports "$1"])
|
||||
AC_MSG_CHECKING([if linker supports "ARG_ARGUMENT"])
|
||||
supports=yes
|
||||
|
||||
saved_ldflags="$LDFLAGS"
|
||||
LDFLAGS="$LDFLAGS $1"
|
||||
LDFLAGS="$LDFLAGS ARG_ARGUMENT"
|
||||
AC_LANG_PUSH([C])
|
||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[]])],
|
||||
[], [supports=no])
|
||||
@ -928,9 +952,11 @@ AC_DEFUN([FLAGS_LINKER_CHECK_ARGUMENTS],
|
||||
|
||||
AC_MSG_RESULT([$supports])
|
||||
if test "x$supports" = "xyes" ; then
|
||||
m4_ifval([$2], [$2], [:])
|
||||
:
|
||||
ARG_IF_TRUE
|
||||
else
|
||||
m4_ifval([$3], [$3], [:])
|
||||
:
|
||||
ARG_IF_FALSE
|
||||
fi
|
||||
])
|
||||
|
||||
@ -945,14 +971,14 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
|
||||
*)
|
||||
ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
|
||||
esac
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS([$ZERO_ARCHFLAG], [], [ZERO_ARCHFLAG=""])
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$ZERO_ARCHFLAG], IF_FALSE: [ZERO_ARCHFLAG=""])
|
||||
AC_SUBST(ZERO_ARCHFLAG)
|
||||
|
||||
# Check that the compiler supports -mX (or -qX on AIX) flags
|
||||
# Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS([${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
|
||||
[COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
|
||||
[COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}],
|
||||
IF_TRUE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=true],
|
||||
IF_FALSE: [COMPILER_SUPPORTS_TARGET_BITS_FLAG=false])
|
||||
AC_SUBST(COMPILER_SUPPORTS_TARGET_BITS_FLAG)
|
||||
|
||||
AC_ARG_ENABLE([warnings-as-errors], [AS_HELP_STRING([--disable-warnings-as-errors],
|
||||
@ -993,9 +1019,9 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
|
||||
;;
|
||||
gcc)
|
||||
# Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS([-Wno-this-is-a-warning-that-do-not-exist],
|
||||
[GCC_CAN_DISABLE_WARNINGS=true],
|
||||
[GCC_CAN_DISABLE_WARNINGS=false]
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
|
||||
IF_TRUE: [GCC_CAN_DISABLE_WARNINGS=true],
|
||||
IF_FALSE: [GCC_CAN_DISABLE_WARNINGS=false]
|
||||
)
|
||||
if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then
|
||||
DISABLE_WARNING_PREFIX="-Wno-"
|
||||
@ -1006,9 +1032,9 @@ AC_DEFUN_ONCE([FLAGS_SETUP_COMPILER_FLAGS_MISC],
|
||||
# Repeate the check for the BUILD_CC
|
||||
CC_OLD="$CC"
|
||||
CC="$BUILD_CC"
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS([-Wno-this-is-a-warning-that-do-not-exist],
|
||||
[BUILD_CC_CAN_DISABLE_WARNINGS=true],
|
||||
[BUILD_CC_CAN_DISABLE_WARNINGS=false]
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [-Wno-this-is-a-warning-that-do-not-exist],
|
||||
IF_TRUE: [BUILD_CC_CAN_DISABLE_WARNINGS=true],
|
||||
IF_FALSE: [BUILD_CC_CAN_DISABLE_WARNINGS=false]
|
||||
)
|
||||
if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then
|
||||
BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
|
||||
|
@ -3451,6 +3451,31 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
|
||||
# questions.
|
||||
#
|
||||
|
||||
# Create a function/macro that takes a series of named arguments. The call is
|
||||
# similar to AC_DEFUN, but the setup of the function looks like this:
|
||||
# BASIC_DEFUN_NAMED([MYFUNC], [FOO *BAR], [$@], [
|
||||
# ... do something
|
||||
# AC_MSG_NOTICE([Value of BAR is ARG_BAR])
|
||||
# ])
|
||||
# A star (*) in front of a named argument means that it is required and it's
|
||||
# presence will be verified. To pass e.g. the first value as a normal indexed
|
||||
# argument, use [m4_shift($@)] as the third argument instead of [$@]. These
|
||||
# arguments are referenced in the function by their name prefixed by ARG_, e.g.
|
||||
# "ARG_FOO".
|
||||
#
|
||||
# The generated function can be called like this:
|
||||
# MYFUNC(FOO: [foo-val], BAR:
|
||||
# [
|
||||
# $ECHO hello world
|
||||
# ])
|
||||
#
|
||||
#
|
||||
# Argument 1: Name of the function to define
|
||||
# Argument 2: List of legal named arguments, with a * prefix for required arguments
|
||||
# Argument 3: Argument array to treat as named, typically $@
|
||||
# Argument 4: The main function body
|
||||
|
||||
|
||||
# Test if $1 is a valid argument to $3 (often is $JAVA passed as $3)
|
||||
# If so, then append $1 to $2 \
|
||||
# Also set JVM_ARG_OK to true/false depending on outcome.
|
||||
@ -3792,6 +3817,15 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
|
||||
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Runs icecc-create-env once and prints the error if it fails
|
||||
#
|
||||
# $1: arguments to icecc-create-env
|
||||
# $2: log file
|
||||
#
|
||||
|
||||
|
||||
################################################################################
|
||||
#
|
||||
# Optionally enable distributed compilation of native code using icecc/icecream
|
||||
@ -3877,20 +3911,24 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var.
|
||||
|
||||
|
||||
|
||||
# FLAGS_COMPILER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
|
||||
# [RUN-IF-FALSE])
|
||||
# FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
|
||||
# IF_FALSE: [RUN-IF-FALSE])
|
||||
# ------------------------------------------------------------
|
||||
# Check that the c and c++ compilers support an argument
|
||||
|
||||
|
||||
# FLAGS_LINKER_CHECK_ARGUMENTS([ARGUMENT], [RUN-IF-TRUE],
|
||||
# [RUN-IF-FALSE])
|
||||
|
||||
|
||||
# FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [ARGUMENT], IF_TRUE: [RUN-IF-TRUE],
|
||||
# IF_FALSE: [RUN-IF-FALSE])
|
||||
# ------------------------------------------------------------
|
||||
# Check that the linker support an argument
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
@ -4308,7 +4346,7 @@ pkgadd_help() {
|
||||
|
||||
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -4801,7 +4839,7 @@ VS_SDK_PLATFORM_NAME_2013=
|
||||
#CUSTOM_AUTOCONF_INCLUDE
|
||||
|
||||
# Do not change or remove the following line, it is needed for consistency checks:
|
||||
DATE_WHEN_GENERATED=1450400041
|
||||
DATE_WHEN_GENERATED=1452780299
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
@ -45349,6 +45387,54 @@ $as_echo "$as_me: Rewriting BUILD_AR to \"$new_complete\"" >&6;}
|
||||
# "-Og" suppported for GCC 4.8 and later
|
||||
CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Execute function body
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$CFLAG_OPTIMIZE_DEBUG_FLAG\"" >&5
|
||||
$as_echo_n "checking if compiler supports \"$CFLAG_OPTIMIZE_DEBUG_FLAG\"... " >&6; }
|
||||
supports=yes
|
||||
@ -45408,15 +45494,76 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
|
||||
$as_echo "$supports" >&6; }
|
||||
if test "x$supports" = "xyes" ; then
|
||||
:
|
||||
HAS_CFLAG_OPTIMIZE_DEBUG=true
|
||||
else
|
||||
:
|
||||
HAS_CFLAG_OPTIMIZE_DEBUG=false
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# "-z relro" supported in GNU binutils 2.17 and later
|
||||
LINKER_RELRO_FLAG="-Wl,-z,relro"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Execute function body
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports \"$LINKER_RELRO_FLAG\"" >&5
|
||||
$as_echo_n "checking if linker supports \"$LINKER_RELRO_FLAG\"... " >&6; }
|
||||
supports=yes
|
||||
@ -45458,15 +45605,76 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
|
||||
$as_echo "$supports" >&6; }
|
||||
if test "x$supports" = "xyes" ; then
|
||||
:
|
||||
HAS_LINKER_RELRO=true
|
||||
else
|
||||
:
|
||||
HAS_LINKER_RELRO=false
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# "-z now" supported in GNU binutils 2.11 and later
|
||||
LINKER_NOW_FLAG="-Wl,-z,now"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Execute function body
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if linker supports \"$LINKER_NOW_FLAG\"" >&5
|
||||
$as_echo_n "checking if linker supports \"$LINKER_NOW_FLAG\"... " >&6; }
|
||||
supports=yes
|
||||
@ -45508,11 +45716,24 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
|
||||
$as_echo "$supports" >&6; }
|
||||
if test "x$supports" = "xyes" ; then
|
||||
:
|
||||
HAS_LINKER_NOW=true
|
||||
else
|
||||
:
|
||||
HAS_LINKER_NOW=false
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
fi
|
||||
|
||||
# Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed
|
||||
@ -45930,6 +46151,29 @@ $as_echo "$tool_specified" >&6; }
|
||||
else
|
||||
COMPILER_TARGET_BITS_FLAG="-m"
|
||||
COMPILER_COMMAND_FILE_FLAG="@"
|
||||
|
||||
# The solstudio linker does not support @-files.
|
||||
if test "x$TOOLCHAIN_TYPE" = xsolstudio; then
|
||||
COMPILER_COMMAND_FILE_FLAG=
|
||||
fi
|
||||
|
||||
# Check if @file is supported by gcc
|
||||
if test "x$TOOLCHAIN_TYPE" = xgcc; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if @file is supported by gcc" >&5
|
||||
$as_echo_n "checking if @file is supported by gcc... " >&6; }
|
||||
# Extra emtpy "" to prevent ECHO from interpreting '--version' as argument
|
||||
$ECHO "" "--version" > command.file
|
||||
if $CXX @command.file 2>&5 >&5; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
$as_echo "yes" >&6; }
|
||||
COMPILER_COMMAND_FILE_FLAG="@"
|
||||
else
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
$as_echo "no" >&6; }
|
||||
COMPILER_COMMAND_FILE_FLAG=
|
||||
fi
|
||||
rm -rf command.file
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
@ -46810,6 +47054,49 @@ $as_echo "$ac_cv_c_bigendian" >&6; }
|
||||
# Not all versions of gcc support -fstack-protector
|
||||
STACK_PROTECTOR_CFLAG="-fstack-protector-all"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Execute function body
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$STACK_PROTECTOR_CFLAG\"" >&5
|
||||
$as_echo_n "checking if compiler supports \"$STACK_PROTECTOR_CFLAG\"... " >&6; }
|
||||
supports=yes
|
||||
@ -46870,11 +47157,24 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
$as_echo "$supports" >&6; }
|
||||
if test "x$supports" = "xyes" ; then
|
||||
:
|
||||
|
||||
else
|
||||
:
|
||||
STACK_PROTECTOR_CFLAG=""
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
CFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
|
||||
CXXFLAGS_DEBUG_OPTIONS="$STACK_PROTECTOR_CFLAG --param ssp-buffer-size=1"
|
||||
;;
|
||||
@ -47352,6 +47652,49 @@ $as_echo "$supports" >&6; }
|
||||
ZERO_ARCHFLAG="${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}"
|
||||
esac
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Execute function body
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"$ZERO_ARCHFLAG\"" >&5
|
||||
$as_echo_n "checking if compiler supports \"$ZERO_ARCHFLAG\"... " >&6; }
|
||||
supports=yes
|
||||
@ -47412,15 +47755,76 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
$as_echo "$supports" >&6; }
|
||||
if test "x$supports" = "xyes" ; then
|
||||
:
|
||||
|
||||
else
|
||||
:
|
||||
ZERO_ARCHFLAG=""
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Check that the compiler supports -mX (or -qX on AIX) flags
|
||||
# Set COMPILER_SUPPORTS_TARGET_BITS_FLAG to 'true' if it does
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Execute function body
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"" >&5
|
||||
$as_echo_n "checking if compiler supports \"${COMPILER_TARGET_BITS_FLAG}${OPENJDK_TARGET_CPU_BITS}\"... " >&6; }
|
||||
supports=yes
|
||||
@ -47480,13 +47884,26 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
|
||||
$as_echo "$supports" >&6; }
|
||||
if test "x$supports" = "xyes" ; then
|
||||
:
|
||||
COMPILER_SUPPORTS_TARGET_BITS_FLAG=true
|
||||
else
|
||||
:
|
||||
COMPILER_SUPPORTS_TARGET_BITS_FLAG=false
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Check whether --enable-warnings-as-errors was given.
|
||||
if test "${enable_warnings_as_errors+set}" = set; then :
|
||||
enableval=$enable_warnings_as_errors;
|
||||
@ -47533,6 +47950,54 @@ $as_echo "yes (default)" >&6; }
|
||||
gcc)
|
||||
# Prior to gcc 4.4, a -Wno-X where X is unknown for that version of gcc will cause an error
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Execute function body
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"-Wno-this-is-a-warning-that-do-not-exist\"" >&5
|
||||
$as_echo_n "checking if compiler supports \"-Wno-this-is-a-warning-that-do-not-exist\"... " >&6; }
|
||||
supports=yes
|
||||
@ -47592,12 +48057,25 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
|
||||
$as_echo "$supports" >&6; }
|
||||
if test "x$supports" = "xyes" ; then
|
||||
:
|
||||
GCC_CAN_DISABLE_WARNINGS=true
|
||||
else
|
||||
:
|
||||
GCC_CAN_DISABLE_WARNINGS=false
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if test "x$GCC_CAN_DISABLE_WARNINGS" = "xtrue"; then
|
||||
DISABLE_WARNING_PREFIX="-Wno-"
|
||||
else
|
||||
@ -47608,6 +48086,54 @@ $as_echo "$supports" >&6; }
|
||||
CC_OLD="$CC"
|
||||
CC="$BUILD_CC"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Execute function body
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if compiler supports \"-Wno-this-is-a-warning-that-do-not-exist\"" >&5
|
||||
$as_echo_n "checking if compiler supports \"-Wno-this-is-a-warning-that-do-not-exist\"... " >&6; }
|
||||
supports=yes
|
||||
@ -47667,12 +48193,25 @@ ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $supports" >&5
|
||||
$as_echo "$supports" >&6; }
|
||||
if test "x$supports" = "xyes" ; then
|
||||
:
|
||||
BUILD_CC_CAN_DISABLE_WARNINGS=true
|
||||
else
|
||||
:
|
||||
BUILD_CC_CAN_DISABLE_WARNINGS=false
|
||||
|
||||
fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
if test "x$BUILD_CC_CAN_DISABLE_WARNINGS" = "xtrue"; then
|
||||
BUILD_CC_DISABLE_WARNING_PREFIX="-Wno-"
|
||||
else
|
||||
@ -51750,12 +52289,28 @@ $as_echo "$as_me: WARNING: cups not used, so --with-cups[-*] is ignored" >&2;}
|
||||
fi
|
||||
|
||||
if test "x${with_cups}" != x; then
|
||||
CUPS_CFLAGS="-I${with_cups}/include"
|
||||
CUPS_FOUND=yes
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cups headers" >&5
|
||||
$as_echo_n "checking for cups headers... " >&6; }
|
||||
if test -s "${with_cups}/include/cups/cups.h"; then
|
||||
CUPS_CFLAGS="-I${with_cups}/include"
|
||||
CUPS_FOUND=yes
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_FOUND" >&5
|
||||
$as_echo "$CUPS_FOUND" >&6; }
|
||||
else
|
||||
as_fn_error $? "Can't find 'include/cups/cups.h' under ${with_cups} given with the --with-cups option." "$LINENO" 5
|
||||
fi
|
||||
fi
|
||||
if test "x${with_cups_include}" != x; then
|
||||
CUPS_CFLAGS="-I${with_cups_include}"
|
||||
CUPS_FOUND=yes
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for cups headers" >&5
|
||||
$as_echo_n "checking for cups headers... " >&6; }
|
||||
if test -s "${with_cups_include}/cups/cups.h"; then
|
||||
CUPS_CFLAGS="-I${with_cups_include}"
|
||||
CUPS_FOUND=yes
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CUPS_FOUND" >&5
|
||||
$as_echo "$CUPS_FOUND" >&6; }
|
||||
else
|
||||
as_fn_error $? "Can't find 'cups/cups.h' under ${with_cups_include} given with the --with-cups-include option." "$LINENO" 5
|
||||
fi
|
||||
fi
|
||||
if test "x$CUPS_FOUND" = xno; then
|
||||
# Are the cups headers installed in the default /usr/include location?
|
||||
@ -59551,11 +60106,23 @@ $as_echo "$tool_specified" >&6; }
|
||||
# be sent to the other hosts in the icecream cluster.
|
||||
icecc_create_env_log="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/icecc_create_env.log"
|
||||
${MKDIR} -p ${CONFIGURESUPPORT_OUTPUTDIR}/icecc
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for icecc build environment for target compiler" >&5
|
||||
$as_echo_n "checking for icecc build environment for target compiler... " >&6; }
|
||||
# Older versions of icecc does not have the --gcc parameter
|
||||
if ${ICECC_CREATE_ENV} | $GREP -q -e --gcc; then
|
||||
icecc_gcc_arg="--gcc"
|
||||
fi
|
||||
if test "x${TOOLCHAIN_TYPE}" = "xgcc"; then
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} --gcc ${CC} ${CXX} > ${icecc_create_env_log}
|
||||
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} ${icecc_gcc_arg} ${CC} ${CXX} > \
|
||||
${icecc_create_env_log} 2>&1
|
||||
if test "$?" != "0"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: icecc-create-env output:" >&5
|
||||
$as_echo "$as_me: icecc-create-env output:" >&6;}
|
||||
cat \
|
||||
${icecc_create_env_log}
|
||||
as_fn_error $? "Failed to create icecc compiler environment" "$LINENO" 5
|
||||
fi
|
||||
|
||||
elif test "x$TOOLCHAIN_TYPE" = "xclang"; then
|
||||
# For clang, the icecc compilerwrapper is needed. It usually resides next
|
||||
# to icecc-create-env.
|
||||
@ -59763,8 +60330,16 @@ $as_echo "$tool_specified" >&6; }
|
||||
fi
|
||||
|
||||
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} --clang ${CC} ${ICECC_WRAPPER} > ${icecc_create_env_log}
|
||||
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} --clang ${CC} ${ICECC_WRAPPER} > ${icecc_create_env_log} 2>&1
|
||||
if test "$?" != "0"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: icecc-create-env output:" >&5
|
||||
$as_echo "$as_me: icecc-create-env output:" >&6;}
|
||||
cat ${icecc_create_env_log}
|
||||
as_fn_error $? "Failed to create icecc compiler environment" "$LINENO" 5
|
||||
fi
|
||||
|
||||
else
|
||||
as_fn_error $? "Can only create icecc compiler packages for toolchain types gcc and clang" "$LINENO" 5
|
||||
fi
|
||||
@ -59773,26 +60348,53 @@ $as_echo "$tool_specified" >&6; }
|
||||
# to find it.
|
||||
ICECC_ENV_BUNDLE_BASENAME="`${SED} -n '/^creating/s/creating //p' ${icecc_create_env_log}`"
|
||||
ICECC_ENV_BUNDLE="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/${ICECC_ENV_BUNDLE_BASENAME}"
|
||||
if test ! -f ${ICECC_ENV_BUNDLE}; then
|
||||
as_fn_error $? "icecc-create-env did not produce an environment ${ICECC_ENV_BUNDLE}" "$LINENO" 5
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for icecc build environment for target compiler" >&5
|
||||
$as_echo_n "checking for icecc build environment for target compiler... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ICECC_ENV_BUNDLE}" >&5
|
||||
$as_echo "${ICECC_ENV_BUNDLE}" >&6; }
|
||||
ICECC="ICECC_VERSION=${ICECC_ENV_BUNDLE} ICECC_CC=${CC} ICECC_CXX=${CXX} ${ICECC_CMD}"
|
||||
|
||||
if test "x${COMPILE_TYPE}" = "xcross"; then
|
||||
# If cross compiling, create a separate env package for the build compiler
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for icecc build environment for build compiler" >&5
|
||||
$as_echo_n "checking for icecc build environment for build compiler... " >&6; }
|
||||
# Assume "gcc" or "cc" is gcc and "clang" is clang. Otherwise bail.
|
||||
icecc_create_env_log_build="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/icecc_create_env_build.log"
|
||||
if test "x${BUILD_CC##*/}" = "xgcc" || test "x${BUILD_CC##*/}" = "xcc"; then
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} --gcc ${BUILD_CC} ${BUILD_CXX} > ${icecc_create_env_log}
|
||||
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} ${icecc_gcc_arg} ${BUILD_CC} ${BUILD_CXX} > \
|
||||
${icecc_create_env_log_build} 2>&1
|
||||
if test "$?" != "0"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: icecc-create-env output:" >&5
|
||||
$as_echo "$as_me: icecc-create-env output:" >&6;}
|
||||
cat \
|
||||
${icecc_create_env_log_build}
|
||||
as_fn_error $? "Failed to create icecc compiler environment" "$LINENO" 5
|
||||
fi
|
||||
|
||||
elif test "x${BUILD_CC##*/}" = "xclang"; then
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} --clang ${BUILD_CC} ${ICECC_WRAPPER} > ${icecc_create_env_log}
|
||||
|
||||
cd ${CONFIGURESUPPORT_OUTPUTDIR}/icecc \
|
||||
&& ${ICECC_CREATE_ENV} --clang ${BUILD_CC} ${ICECC_WRAPPER} > ${icecc_create_env_log_build} 2>&1
|
||||
if test "$?" != "0"; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: icecc-create-env output:" >&5
|
||||
$as_echo "$as_me: icecc-create-env output:" >&6;}
|
||||
cat ${icecc_create_env_log_build}
|
||||
as_fn_error $? "Failed to create icecc compiler environment" "$LINENO" 5
|
||||
fi
|
||||
|
||||
else
|
||||
as_fn_error $? "Cannot create icecc compiler package for ${BUILD_CC}" "$LINENO" 5
|
||||
fi
|
||||
ICECC_ENV_BUNDLE_BASENAME="`${SED} -n '/^creating/s/creating //p' ${icecc_create_env_log}`"
|
||||
ICECC_ENV_BUNDLE_BASENAME="`${SED} -n '/^creating/s/creating //p' ${icecc_create_env_log_build}`"
|
||||
ICECC_ENV_BUNDLE="${CONFIGURESUPPORT_OUTPUTDIR}/icecc/${ICECC_ENV_BUNDLE_BASENAME}"
|
||||
if test ! -f ${ICECC_ENV_BUNDLE}; then
|
||||
as_fn_error $? "icecc-create-env did not produce an environment ${ICECC_ENV_BUNDLE}" "$LINENO" 5
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for icecc build environment for build compiler" >&5
|
||||
$as_echo_n "checking for icecc build environment for build compiler... " >&6; }
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: ${ICECC_ENV_BUNDLE}" >&5
|
||||
$as_echo "${ICECC_ENV_BUNDLE}" >&6; }
|
||||
BUILD_ICECC="ICECC_VERSION=${ICECC_ENV_BUNDLE} ICECC_CC=${BUILD_CC} \
|
||||
@ -61436,7 +62038,6 @@ fi
|
||||
|
||||
# Move configure.log from current directory to the build output root
|
||||
if test -e ./configure.log; then
|
||||
echo found it
|
||||
$MV -f ./configure.log "$OUTPUT_ROOT/configure.log" 2> /dev/null
|
||||
fi
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
@ -48,12 +48,24 @@ AC_DEFUN_ONCE([LIB_SETUP_CUPS],
|
||||
fi
|
||||
|
||||
if test "x${with_cups}" != x; then
|
||||
CUPS_CFLAGS="-I${with_cups}/include"
|
||||
CUPS_FOUND=yes
|
||||
AC_MSG_CHECKING([for cups headers])
|
||||
if test -s "${with_cups}/include/cups/cups.h"; then
|
||||
CUPS_CFLAGS="-I${with_cups}/include"
|
||||
CUPS_FOUND=yes
|
||||
AC_MSG_RESULT([$CUPS_FOUND])
|
||||
else
|
||||
AC_MSG_ERROR([Can't find 'include/cups/cups.h' under ${with_cups} given with the --with-cups option.])
|
||||
fi
|
||||
fi
|
||||
if test "x${with_cups_include}" != x; then
|
||||
CUPS_CFLAGS="-I${with_cups_include}"
|
||||
CUPS_FOUND=yes
|
||||
AC_MSG_CHECKING([for cups headers])
|
||||
if test -s "${with_cups_include}/cups/cups.h"; then
|
||||
CUPS_CFLAGS="-I${with_cups_include}"
|
||||
CUPS_FOUND=yes
|
||||
AC_MSG_RESULT([$CUPS_FOUND])
|
||||
else
|
||||
AC_MSG_ERROR([Can't find 'cups/cups.h' under ${with_cups_include} given with the --with-cups-include option.])
|
||||
fi
|
||||
fi
|
||||
if test "x$CUPS_FOUND" = xno; then
|
||||
# Are the cups headers installed in the default /usr/include location?
|
||||
|
@ -75,8 +75,8 @@ AC_DEFUN([TOOLCHAIN_SETUP_FILENAME_PATTERNS],
|
||||
# For full static builds, we're overloading the SHARED_LIBRARY
|
||||
# variables in order to limit the amount of changes required.
|
||||
# It would be better to remove SHARED and just use LIBRARY and
|
||||
# LIBRARY_SUFFIX for libraries that can be built either
|
||||
# shared or static and use STATIC_* for libraries that are
|
||||
# LIBRARY_SUFFIX for libraries that can be built either
|
||||
# shared or static and use STATIC_* for libraries that are
|
||||
# always built statically.
|
||||
if test "x$STATIC_BUILD" = xtrue; then
|
||||
SHARED_LIBRARY='lib[$]1.a'
|
||||
@ -824,21 +824,21 @@ AC_DEFUN_ONCE([TOOLCHAIN_MISC_CHECKS],
|
||||
|
||||
# "-Og" suppported for GCC 4.8 and later
|
||||
CFLAG_OPTIMIZE_DEBUG_FLAG="-Og"
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS([$CFLAG_OPTIMIZE_DEBUG_FLAG],
|
||||
[HAS_CFLAG_OPTIMIZE_DEBUG=true],
|
||||
[HAS_CFLAG_OPTIMIZE_DEBUG=false])
|
||||
FLAGS_COMPILER_CHECK_ARGUMENTS(ARGUMENT: [$CFLAG_OPTIMIZE_DEBUG_FLAG],
|
||||
IF_TRUE: [HAS_CFLAG_OPTIMIZE_DEBUG=true],
|
||||
IF_FALSE: [HAS_CFLAG_OPTIMIZE_DEBUG=false])
|
||||
|
||||
# "-z relro" supported in GNU binutils 2.17 and later
|
||||
LINKER_RELRO_FLAG="-Wl,-z,relro"
|
||||
FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_RELRO_FLAG],
|
||||
[HAS_LINKER_RELRO=true],
|
||||
[HAS_LINKER_RELRO=false])
|
||||
FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [$LINKER_RELRO_FLAG],
|
||||
IF_TRUE: [HAS_LINKER_RELRO=true],
|
||||
IF_FALSE: [HAS_LINKER_RELRO=false])
|
||||
|
||||
# "-z now" supported in GNU binutils 2.11 and later
|
||||
LINKER_NOW_FLAG="-Wl,-z,now"
|
||||
FLAGS_LINKER_CHECK_ARGUMENTS([$LINKER_NOW_FLAG],
|
||||
[HAS_LINKER_NOW=true],
|
||||
[HAS_LINKER_NOW=false])
|
||||
FLAGS_LINKER_CHECK_ARGUMENTS(ARGUMENT: [$LINKER_NOW_FLAG],
|
||||
IF_TRUE: [HAS_LINKER_NOW=true],
|
||||
IF_FALSE: [HAS_LINKER_NOW=false])
|
||||
fi
|
||||
|
||||
# Check for broken SuSE 'ld' for which 'Only anonymous version tag is allowed
|
||||
|
@ -342,3 +342,5 @@ feb1bd85d7990dcf5584ca9e53104269c01db006 jdk-9+96
|
||||
10a482b863582376d4ca229090334b23b05159fc jdk-9+97
|
||||
ea285530245cf4e0edf0479121a41347d3030eba jdk-9+98
|
||||
180212ee1d8710691ba9944593dfc1ff3e4f1532 jdk-9+99
|
||||
791d0d3ac0138faeb6110bd840a4545bc1950df2 jdk-9+100
|
||||
30dfb3bd3d06b4bb80a087babc0d1841edba187b jdk-9+101
|
||||
|
@ -502,3 +502,5 @@ a94bb7203596dd632486f1e3655fa5f70541dc08 jdk-9+96
|
||||
de592ea5f7ba0f8a8c5afc03bd169f7690c72b6f jdk-9+97
|
||||
e5b1a23be1e105417ba1c4c576ab373eb3fa2c2b jdk-9+98
|
||||
f008e8cc10d5b3212fb22d58c96fa01d38654f19 jdk-9+99
|
||||
bdb0acafc63c42e84d9d8195bf2e2b25ee9c3306 jdk-9+100
|
||||
9f45d3d57d6948cf526fbc2e2891a9a74ac6941a jdk-9+101
|
||||
|
@ -285,7 +285,7 @@ JVM_LEAF(jlong, JVM_NanoTime(JNIEnv *env, jclass ignored))
|
||||
return os::javaTimeNanos();
|
||||
JVM_END
|
||||
|
||||
// The function below is actually exposed by sun.misc.VM and not
|
||||
// The function below is actually exposed by jdk.internal.misc.VM and not
|
||||
// java.lang.System, but we choose to keep it here so that it stays next
|
||||
// to JVM_CurrentTimeMillis and JVM_NanoTime
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -124,7 +124,7 @@ static JNINativeMethod lookup_special_native_methods[] = {
|
||||
{ CC"Java_jdk_internal_misc_Unsafe_registerNatives", NULL, FN_PTR(JVM_RegisterUnsafeMethods) },
|
||||
{ CC"Java_sun_misc_Unsafe_registerNatives", NULL, FN_PTR(JVM_RegisterUnsafeMethods) },
|
||||
{ CC"Java_java_lang_invoke_MethodHandleNatives_registerNatives", NULL, FN_PTR(JVM_RegisterMethodHandleMethods) },
|
||||
{ CC"Java_sun_misc_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) },
|
||||
{ CC"Java_jdk_internal_perf_Perf_registerNatives", NULL, FN_PTR(JVM_RegisterPerfMethods) },
|
||||
{ CC"Java_sun_hotspot_WhiteBox_registerNatives", NULL, FN_PTR(JVM_RegisterWhiteBoxMethods) },
|
||||
#if INCLUDE_JVMCI
|
||||
{ CC"Java_jdk_vm_ci_runtime_JVMCI_initializeRuntime", NULL, FN_PTR(JVM_GetJVMCIRuntime) },
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,7 +34,7 @@
|
||||
#include "runtime/perfMemory.hpp"
|
||||
|
||||
/*
|
||||
* Implementation of class sun.misc.Perf
|
||||
* Implementation of class jdk.internal.perf.Perf
|
||||
*/
|
||||
|
||||
|
||||
|
@ -342,3 +342,5 @@ c8d0845877a811ab4350935892f826929359a3ff jdk-9+95
|
||||
9c107c050335d7ee63b2a8b38ca5d498f19713a2 jdk-9+97
|
||||
52b01339235f24c93b679bd6b8fb36a1072ad0ac jdk-9+98
|
||||
52774b544850c791f1d1c67db2601b33739b18c9 jdk-9+99
|
||||
d45bcd374f6057851e3c2dcd45607cd362afadfa jdk-9+100
|
||||
d3e834ff74e724a2b92a558e18e8cbf81c6dbc59 jdk-9+101
|
||||
|
@ -32,7 +32,6 @@ import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.NoSuchElementException;
|
||||
@ -43,6 +42,7 @@ import java.util.stream.StreamSupport;
|
||||
import static javax.xml.catalog.BaseEntry.CatalogEntryType;
|
||||
import static javax.xml.catalog.CatalogFeatures.DEFER_TRUE;
|
||||
import javax.xml.catalog.CatalogFeatures.Feature;
|
||||
import static javax.xml.catalog.CatalogMessages.formatMessage;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
@ -109,25 +109,20 @@ class CatalogImpl extends GroupEntry implements Catalog {
|
||||
*/
|
||||
public CatalogImpl(CatalogImpl parent, CatalogFeatures f, String... file) throws CatalogException {
|
||||
super(CatalogEntryType.CATALOG);
|
||||
this.parent = parent;
|
||||
if (parent == null) {
|
||||
level = 0;
|
||||
} else {
|
||||
level = parent.level + 1;
|
||||
}
|
||||
if (f == null) {
|
||||
this.features = CatalogFeatures.defaults();
|
||||
} else {
|
||||
this.features = f;
|
||||
throw new NullPointerException(
|
||||
formatMessage(CatalogMessages.ERR_NULL_ARGUMENT, new Object[]{"CatalogFeatures"}));
|
||||
}
|
||||
setPrefer(features.get(Feature.PREFER));
|
||||
setDeferred(features.get(Feature.DEFER));
|
||||
setResolve(features.get(Feature.RESOLVE));
|
||||
|
||||
if (file.length > 0) {
|
||||
CatalogMessages.reportNPEOnNull("The path to the catalog file", file[0]);
|
||||
}
|
||||
|
||||
init(parent, f);
|
||||
|
||||
//Path of catalog files
|
||||
String[] catalogFile = file;
|
||||
if (level == 0
|
||||
&& (file == null || (file.length == 0 || file[0] == null))) {
|
||||
if (level == 0 && file.length == 0) {
|
||||
String files = features.get(Feature.FILES);
|
||||
if (files != null) {
|
||||
catalogFile = files.split(";[ ]*");
|
||||
@ -166,6 +161,23 @@ class CatalogImpl extends GroupEntry implements Catalog {
|
||||
}
|
||||
}
|
||||
|
||||
private void init(CatalogImpl parent, CatalogFeatures f) {
|
||||
this.parent = parent;
|
||||
if (parent == null) {
|
||||
level = 0;
|
||||
} else {
|
||||
level = parent.level + 1;
|
||||
}
|
||||
if (f == null) {
|
||||
this.features = CatalogFeatures.defaults();
|
||||
} else {
|
||||
this.features = f;
|
||||
}
|
||||
setPrefer(features.get(Feature.PREFER));
|
||||
setDeferred(features.get(Feature.DEFER));
|
||||
setResolve(features.get(Feature.RESOLVE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the Catalog instance to its initial state.
|
||||
*/
|
||||
|
@ -38,33 +38,38 @@ public final class CatalogManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a Catalog object using the specified feature settings and path to
|
||||
* a catalog file. If the features is null, the default features will be used.
|
||||
* If the path is empty, System property {@code javax.xml.catalog.files} will
|
||||
* be read to locate the initial list of catalog files.
|
||||
* Creates a {@code Catalog} object using the specified feature settings and
|
||||
* path to one or more catalog files.
|
||||
* <p>
|
||||
* If more than one catalog files are specified through the path argument or
|
||||
* If {@code paths} is empty, system property {@code javax.xml.catalog.files}
|
||||
* will be read to locate the initial list of catalog files.
|
||||
* <p>
|
||||
* If more than one catalog files are specified through the paths argument or
|
||||
* {@code javax.xml.catalog.files} property, the first entry is considered
|
||||
* the main catalog, while others are treated as alternative catalogs after
|
||||
* those referenced by the {@code nextCatalog} elements in the main catalog.
|
||||
* <p>
|
||||
* As specified in
|
||||
* <a href="https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html#s.res.fail">
|
||||
* XML Catalogs, OASIS Standard V1.1</a>, invalid path entries will be ignored.
|
||||
* No error will be reported. In case all entries are invalid, the resolver
|
||||
* will return as no mapping is found.
|
||||
*
|
||||
* @param features the catalog features
|
||||
* @param path path(s) to one or more catalogs.
|
||||
* @param paths path(s) to one or more catalogs.
|
||||
*
|
||||
* @return a catalog instance
|
||||
* @throws CatalogException If no catalog can be found whether through the
|
||||
* specified path or the System property {@code javax.xml.catalog.files}, or
|
||||
* an error occurs while parsing the catalog
|
||||
* @return an instance of a {@code Catalog}
|
||||
* @throws CatalogException If an error occurs while parsing the catalog
|
||||
*/
|
||||
public static Catalog catalog(CatalogFeatures features, String... path) {
|
||||
return new CatalogImpl(features, path);
|
||||
public static Catalog catalog(CatalogFeatures features, String... paths) {
|
||||
return new CatalogImpl(features, paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of a CatalogResolver using the specified catalog.
|
||||
* Creates an instance of a {@code CatalogResolver} using the specified catalog.
|
||||
*
|
||||
* @param catalog the catalog instance
|
||||
* @return an instance of a CatalogResolver
|
||||
* @return an instance of a {@code CatalogResolver}
|
||||
*/
|
||||
public static CatalogResolver catalogResolver(Catalog catalog) {
|
||||
if (catalog == null) CatalogMessages.reportNPEOnNull("catalog", null);
|
||||
@ -72,10 +77,10 @@ public final class CatalogManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of a CatalogUriResolver using the specified catalog.
|
||||
* Creates an instance of a {@code CatalogUriResolver} using the specified catalog.
|
||||
*
|
||||
* @param catalog the catalog instance
|
||||
* @return an instance of a CatalogResolver
|
||||
* @return an instance of a {@code CatalogResolver}
|
||||
*/
|
||||
public static CatalogUriResolver catalogUriResolver(Catalog catalog) {
|
||||
if (catalog == null) CatalogMessages.reportNPEOnNull("catalog", null);
|
||||
@ -83,50 +88,60 @@ public final class CatalogManager {
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of a CatalogResolver using the specified feature settings
|
||||
* and path to a catalog file. If the features is null, the default features will
|
||||
* be used. If the path is empty, System property {@code javax.xml.catalog.files}
|
||||
* Creates an instance of a {@code CatalogResolver} using the specified feature
|
||||
* settings and path to one or more catalog files.
|
||||
* <p>
|
||||
* If {@code paths} is empty, system property {@code javax.xml.catalog.files}
|
||||
* will be read to locate the initial list of catalog files.
|
||||
* <p>
|
||||
* If more than one catalog files are specified through the path argument or
|
||||
* If more than one catalog files are specified through the paths argument or
|
||||
* {@code javax.xml.catalog.files} property, the first entry is considered
|
||||
* the main catalog, while others are treated as alternative catalogs after
|
||||
* those referenced by the {@code nextCatalog} elements in the main catalog.
|
||||
* <p>
|
||||
* As specified in
|
||||
* <a href="https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html#s.res.fail">
|
||||
* XML Catalogs, OASIS Standard V1.1</a>, invalid path entries will be ignored.
|
||||
* No error will be reported. In case all entries are invalid, the resolver
|
||||
* will return as no mapping is found.
|
||||
*
|
||||
* @param features the catalog features
|
||||
* @param path the path(s) to one or more catalogs
|
||||
* @param paths the path(s) to one or more catalogs
|
||||
*
|
||||
* @return an instance of a CatalogResolver
|
||||
* @throws CatalogException If no catalog can be found whether through the
|
||||
* specified path or the System property {@code javax.xml.catalog.files}, or
|
||||
* an error occurs while parsing the catalog
|
||||
* @return an instance of a {@code CatalogResolver}
|
||||
* @throws CatalogException If an error occurs while parsing the catalog
|
||||
*/
|
||||
public static CatalogResolver catalogResolver(CatalogFeatures features, String... path) {
|
||||
Catalog catalog = catalog(features, path);
|
||||
public static CatalogResolver catalogResolver(CatalogFeatures features, String... paths) {
|
||||
Catalog catalog = catalog(features, paths);
|
||||
return new CatalogResolverImpl(catalog);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an instance of a CatalogUriResolver using the specified feature settings
|
||||
* and path to a catalog file. If the features is null, the default features will
|
||||
* be used. If the path is empty, System property {@code javax.xml.catalog.files}
|
||||
* Creates an instance of a {@code CatalogUriResolver} using the specified
|
||||
* feature settings and path to one or more catalog files.
|
||||
* <p>
|
||||
* If {@code paths} is empty, system property {@code javax.xml.catalog.files}
|
||||
* will be read to locate the initial list of catalog files.
|
||||
* <p>
|
||||
* If more than one catalog files are specified through the path argument or
|
||||
* If more than one catalog files are specified through the paths argument or
|
||||
* {@code javax.xml.catalog.files} property, the first entry is considered
|
||||
* the main catalog, while others are treated as alternative catalogs after
|
||||
* those referenced by the {@code nextCatalog} elements in the main catalog.
|
||||
* <p>
|
||||
* As specified in
|
||||
* <a href="https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html#s.res.fail">
|
||||
* XML Catalogs, OASIS Standard V1.1</a>, invalid path entries will be ignored.
|
||||
* No error will be reported. In case all entries are invalid, the resolver
|
||||
* will return as no mapping is found.
|
||||
*
|
||||
* @param features the catalog features
|
||||
* @param path the path(s) to one or more catalogs
|
||||
* @param paths the path(s) to one or more catalogs
|
||||
*
|
||||
* @return an instance of a CatalogResolver
|
||||
* @throws CatalogException If no catalog can be found whether through the
|
||||
* specified path or the System property {@code javax.xml.catalog.files}, or
|
||||
* an error occurs while parsing the catalog
|
||||
* @return an instance of a {@code CatalogUriResolver}
|
||||
* @throws CatalogException If an error occurs while parsing the catalog
|
||||
*/
|
||||
public static CatalogUriResolver catalogUriResolver(CatalogFeatures features, String... path) {
|
||||
Catalog catalog = catalog(features, path);
|
||||
public static CatalogUriResolver catalogUriResolver(CatalogFeatures features, String... paths) {
|
||||
Catalog catalog = catalog(features, paths);
|
||||
return new CatalogUriResolverImpl(catalog);
|
||||
}
|
||||
}
|
||||
|
@ -43,9 +43,9 @@ public interface CatalogUriResolver extends URIResolver {
|
||||
* absolute if the absolute URI is required
|
||||
*
|
||||
* @return a {@link javax.xml.transform.Source} object if a mapping is found.
|
||||
* If no mapping is found, returns a {@link javax.xml.transform.Source} object
|
||||
* containing an empty {@link java.io.Reader} if the
|
||||
* {@code javax.xml.catalog.resolve} property is set to {@code ignore};
|
||||
* If no mapping is found, returns an empty {@link javax.xml.transform.Source}
|
||||
* object if the {@code javax.xml.catalog.resolve} property is set to
|
||||
* {@code ignore};
|
||||
* returns a {@link javax.xml.transform.Source} object with the original URI
|
||||
* (href, or href resolved with base if base is not null) if the
|
||||
* {@code javax.xml.catalog.resolve} property is set to {@code continue}.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -72,6 +72,7 @@ final class RewriteSystem extends BaseEntry {
|
||||
public String getSystemIdStartString () {
|
||||
return systemIdStartString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rewritePrefix attribute.
|
||||
* @return The rewritePrefix attribute value.
|
||||
@ -80,7 +81,6 @@ final class RewriteSystem extends BaseEntry {
|
||||
return rewritePrefix;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Try to match the specified systemId with the entry. Return the match if it
|
||||
* is successful and the length of the systemIdStartString is longer than the
|
||||
@ -91,14 +91,20 @@ final class RewriteSystem extends BaseEntry {
|
||||
* @return The replacement URI if the match is successful, null if not.
|
||||
*/
|
||||
public String match(String systemId, int currentMatch) {
|
||||
if (systemIdStartString.length() <= systemId.length() &&
|
||||
if (systemIdStartString.length() < systemId.length() &&
|
||||
systemIdStartString.equals(systemId.substring(0, systemIdStartString.length()))) {
|
||||
if (currentMatch < systemIdStartString.length()) {
|
||||
String prefix = rewritePrefix.toExternalForm();
|
||||
if (!prefix.endsWith(SLASH) && !systemId.startsWith(SLASH)) {
|
||||
return prefix + SLASH + systemId.substring(systemIdStartString.length());
|
||||
String sysId;
|
||||
if (systemIdStartString.endsWith(SLASH)) {
|
||||
sysId = systemId.substring(systemIdStartString.length());
|
||||
} else {
|
||||
return prefix + systemId.substring(systemIdStartString.length());
|
||||
sysId = systemId.substring(systemIdStartString.length() + 1);
|
||||
}
|
||||
if (prefix.endsWith(SLASH)) {
|
||||
return prefix + sysId;
|
||||
} else {
|
||||
return prefix + SLASH + sysId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -72,6 +72,7 @@ final class RewriteUri extends BaseEntry {
|
||||
public String getURIStartString () {
|
||||
return uriStartString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the rewritePrefix attribute.
|
||||
* @return The rewritePrefix attribute value.
|
||||
@ -91,14 +92,20 @@ final class RewriteUri extends BaseEntry {
|
||||
*/
|
||||
@Override
|
||||
public String match(String systemId, int currentMatch) {
|
||||
if (uriStartString.length() <= systemId.length() &&
|
||||
if (uriStartString.length() < systemId.length() &&
|
||||
uriStartString.equals(systemId.substring(0, uriStartString.length()))) {
|
||||
if (currentMatch < uriStartString.length()) {
|
||||
String prefix = rewritePrefix.toExternalForm();
|
||||
if (!prefix.endsWith(SLASH) && !systemId.startsWith(SLASH)) {
|
||||
return prefix + SLASH + systemId.substring(uriStartString.length());
|
||||
String sysId;
|
||||
if (uriStartString.endsWith(SLASH)) {
|
||||
sysId = systemId.substring(uriStartString.length());
|
||||
} else {
|
||||
return prefix + systemId.substring(uriStartString.length());
|
||||
sysId = systemId.substring(uriStartString.length() + 1);
|
||||
}
|
||||
if (prefix.endsWith(SLASH)) {
|
||||
return prefix + sysId;
|
||||
} else {
|
||||
return prefix + SLASH + sysId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -52,4 +52,17 @@ public interface Source {
|
||||
* if setSystemId was not called.
|
||||
*/
|
||||
public String getSystemId();
|
||||
|
||||
/**
|
||||
* Indicates whether the {@code Source} object is empty. Empty means
|
||||
* that there is no input available from this Source.
|
||||
*
|
||||
* @implSpec The default implementation of this method throws
|
||||
* {@link UnsupportedOperationException}.
|
||||
*
|
||||
* @return true if the {@code Source} object is empty, false otherwise
|
||||
*/
|
||||
default boolean isEmpty() {
|
||||
throw new UnsupportedOperationException("The isEmpty method is not supported.");
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -122,6 +122,7 @@ public class DOMSource implements Source {
|
||||
*
|
||||
* @param systemID Base URL for this DOM tree.
|
||||
*/
|
||||
@Override
|
||||
public void setSystemId(String systemID) {
|
||||
this.systemID = systemID;
|
||||
}
|
||||
@ -132,7 +133,25 @@ public class DOMSource implements Source {
|
||||
*
|
||||
* @return Base URL for this DOM tree.
|
||||
*/
|
||||
@Override
|
||||
public String getSystemId() {
|
||||
return this.systemID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the {@code DOMSource} object is empty. Empty is
|
||||
* defined as follows:
|
||||
* <ul>
|
||||
* <li>if the system identifier and node are {@code null};
|
||||
* </li>
|
||||
* <li>if the system identifier is null, and the {@code node} has no child nodes.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @return true if the {@code DOMSource} object is empty, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return systemID == null && (node == null || !node.hasChildNodes());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -147,6 +147,7 @@ public class SAXSource implements Source {
|
||||
*
|
||||
* @param systemId The system identifier as a URI string.
|
||||
*/
|
||||
@Override
|
||||
public void setSystemId(String systemId) {
|
||||
|
||||
if (null == inputSource) {
|
||||
@ -162,6 +163,7 @@ public class SAXSource implements Source {
|
||||
*
|
||||
* @return Base URL for the <code>Source</code>, or <code>null</code>.
|
||||
*/
|
||||
@Override
|
||||
public String getSystemId() {
|
||||
|
||||
if (inputSource == null) {
|
||||
@ -207,4 +209,22 @@ public class SAXSource implements Source {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the {@code SAXSource} object is empty. Empty is
|
||||
* defined as follows:
|
||||
* <ul>
|
||||
* <li>if the system identifier and {@code InputSource} are {@code null};
|
||||
* </li>
|
||||
* <li>if the system identifier is {@code null}, and the {@code InputSource}
|
||||
* is empty.
|
||||
* </li>
|
||||
* </ul>
|
||||
*
|
||||
* @return true if the {@code SAXSource} object is empty, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return getSystemId() == null && (inputSource == null || inputSource.isEmpty());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -209,6 +209,7 @@ public class StAXSource implements Source {
|
||||
* @throws UnsupportedOperationException Is <strong>always</strong>
|
||||
* thrown by this method.
|
||||
*/
|
||||
@Override
|
||||
public void setSystemId(final String systemId) {
|
||||
|
||||
throw new UnsupportedOperationException(
|
||||
@ -229,8 +230,21 @@ public class StAXSource implements Source {
|
||||
*
|
||||
* @return System identifier used by this <code>StAXSource</code>.
|
||||
*/
|
||||
@Override
|
||||
public String getSystemId() {
|
||||
|
||||
return systemId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the {@code StAXSource} object is empty. Since a
|
||||
* {@code StAXSource} object can never be empty, this method always returns
|
||||
* false.
|
||||
*
|
||||
* @return unconditionally false
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,8 +26,10 @@
|
||||
package javax.xml.transform.stream;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Reader;
|
||||
import javax.xml.transform.Result;
|
||||
|
||||
import javax.xml.transform.Source;
|
||||
|
||||
@ -233,6 +235,7 @@ public class StreamSource implements Source {
|
||||
*
|
||||
* @param systemId The system identifier as a URL string.
|
||||
*/
|
||||
@Override
|
||||
public void setSystemId(String systemId) {
|
||||
this.systemId = systemId;
|
||||
}
|
||||
@ -243,6 +246,7 @@ public class StreamSource implements Source {
|
||||
* @return The system identifier that was set with setSystemId, or null
|
||||
* if setSystemId was not called.
|
||||
*/
|
||||
@Override
|
||||
public String getSystemId() {
|
||||
return systemId;
|
||||
}
|
||||
@ -259,6 +263,59 @@ public class StreamSource implements Source {
|
||||
this.systemId = f.toURI().toASCIIString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the {@code StreamSource} object is empty. Empty is
|
||||
* defined as follows:
|
||||
* <ul>
|
||||
* <li>All of the input sources, including the public identifier, system
|
||||
* identifier, byte stream, and character stream, are {@code null}.
|
||||
* </li>
|
||||
* <li>The public identifier and system identifier are {@code null}, and
|
||||
* byte and character stream are either {@code null} or contain no byte or
|
||||
* character.
|
||||
* <p>
|
||||
* Note that this method will reset the byte stream if it is provided, or
|
||||
* the character stream if the byte stream is not provided.
|
||||
* </li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* In case of error while checking the byte or character stream, the method
|
||||
* will return false to allow the XML processor to handle the error.
|
||||
*
|
||||
* @return true if the {@code StreamSource} object is empty, false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return (publicId == null && systemId == null && isStreamEmpty());
|
||||
}
|
||||
|
||||
private boolean isStreamEmpty() {
|
||||
boolean empty = true;
|
||||
try {
|
||||
if (inputStream != null) {
|
||||
inputStream.reset();
|
||||
int bytesRead = inputStream.available();
|
||||
if (bytesRead > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (reader != null) {
|
||||
reader.reset();
|
||||
int c = reader.read();
|
||||
reader.reset();
|
||||
if (c != -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
//in case of error, return false
|
||||
return false;
|
||||
}
|
||||
|
||||
return empty;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Internal state.
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,6 +30,7 @@
|
||||
|
||||
package org.xml.sax;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.io.InputStream;
|
||||
|
||||
@ -343,8 +344,57 @@ public class InputSource {
|
||||
return characterStream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the {@code InputSource} object is empty. Empty is
|
||||
* defined as follows:
|
||||
* <ul>
|
||||
* <li>All of the input sources, including the public identifier, system
|
||||
* identifier, byte stream, and character stream, are {@code null}.
|
||||
* </li>
|
||||
* <li>The public identifier and system identifier are {@code null}, and
|
||||
* byte and character stream are either {@code null} or contain no byte
|
||||
* or character.
|
||||
* <p>
|
||||
* Note that this method will reset the byte stream if it is provided, or
|
||||
* the character stream if the byte stream is not provided.
|
||||
* </li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* In case of error while checking the byte or character stream, the method
|
||||
* will return false to allow the XML processor to handle the error.
|
||||
*
|
||||
* @return true if the {@code InputSource} object is empty, false otherwise
|
||||
*/
|
||||
public boolean isEmpty() {
|
||||
return (publicId == null && systemId == null && isStreamEmpty());
|
||||
}
|
||||
|
||||
private boolean isStreamEmpty() {
|
||||
boolean empty = true;
|
||||
try {
|
||||
if (byteStream != null) {
|
||||
byteStream.reset();
|
||||
int bytesRead = byteStream.available();
|
||||
if (bytesRead > 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (characterStream != null) {
|
||||
characterStream.reset();
|
||||
int c = characterStream.read();
|
||||
characterStream.reset();
|
||||
if (c != -1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
//in case of error, return false
|
||||
return false;
|
||||
}
|
||||
|
||||
return empty;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// Internal state.
|
||||
////////////////////////////////////////////////////////////////////
|
||||
|
@ -56,23 +56,14 @@ public class DeferFeatureTest {
|
||||
|
||||
@DataProvider(name = "catalog-countOfLoadedCatalogFile")
|
||||
private Object[][] data() {
|
||||
return new Object[][] {
|
||||
// This catalog specifies null catalog explicitly,
|
||||
// and the count of loaded catalogs should be 0.
|
||||
{ createCatalog(null), 0 },
|
||||
|
||||
// This catalog specifies null catalog implicitly,
|
||||
// and the count of loaded catalogs should be 0.
|
||||
{ createCatalog(CatalogFeatures.defaults()), 0 },
|
||||
|
||||
// This catalog loads null catalog with true DEFER,
|
||||
// and the count of loaded catalogs should be 0.
|
||||
{ createCatalog(createDeferFeature(DEFER_TRUE)), 0 },
|
||||
|
||||
// This catalog loads null catalog with false DEFER.
|
||||
// It should load all of none-current catalogs and the
|
||||
// count of loaded catalogs should be 3.
|
||||
{ createCatalog(createDeferFeature(DEFER_FALSE)), 3 } };
|
||||
return new Object[][]{
|
||||
// By default, alternative catalogs are not loaded.
|
||||
{createCatalog(CatalogFeatures.defaults()), 0},
|
||||
// Alternative catalogs are not loaded when DEFER is set to true.
|
||||
{createCatalog(createDeferFeature(DEFER_TRUE)), 0},
|
||||
// The 3 alternative catalogs are not pre-loaded
|
||||
//when DEFER is set to false.
|
||||
{createCatalog(createDeferFeature(DEFER_FALSE)), 3}};
|
||||
}
|
||||
|
||||
private CatalogFeatures createDeferFeature(String defer) {
|
||||
|
@ -83,7 +83,7 @@ final class CatalogTestUtils {
|
||||
* Creates CatalogResolver with a set of catalogs.
|
||||
*/
|
||||
static CatalogResolver catalogResolver(String... catalogName) {
|
||||
return catalogResolver(null, catalogName);
|
||||
return catalogResolver(CatalogFeatures.defaults(), catalogName);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -91,15 +91,16 @@ final class CatalogTestUtils {
|
||||
*/
|
||||
static CatalogResolver catalogResolver(CatalogFeatures features,
|
||||
String... catalogName) {
|
||||
return CatalogManager.catalogResolver(features,
|
||||
getCatalogPaths(catalogName));
|
||||
return (catalogName == null) ?
|
||||
CatalogManager.catalogResolver(features) :
|
||||
CatalogManager.catalogResolver(features, getCatalogPaths(catalogName));
|
||||
}
|
||||
|
||||
/*
|
||||
* Creates catalogUriResolver with a set of catalogs.
|
||||
*/
|
||||
static CatalogUriResolver catalogUriResolver(String... catalogName) {
|
||||
return catalogUriResolver(null, catalogName);
|
||||
return catalogUriResolver(CatalogFeatures.defaults(), catalogName);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -107,8 +108,9 @@ final class CatalogTestUtils {
|
||||
*/
|
||||
static CatalogUriResolver catalogUriResolver(
|
||||
CatalogFeatures features, String... catalogName) {
|
||||
return CatalogManager.catalogUriResolver(features,
|
||||
getCatalogPaths(catalogName));
|
||||
return (catalogName == null) ?
|
||||
CatalogManager.catalogUriResolver(features) :
|
||||
CatalogManager.catalogUriResolver(features, getCatalogPaths(catalogName));
|
||||
}
|
||||
|
||||
// Gets the paths of the specified catalogs.
|
||||
|
@ -89,7 +89,7 @@ public class JAXPTestUtilities {
|
||||
/**
|
||||
* BOM table for storing BOM header.
|
||||
*/
|
||||
private final static Map<String, byte[]> bom = new HashMap();
|
||||
private final static Map<String, byte[]> bom = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Initialize all BOM headers.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,14 +27,13 @@ import javax.xml.catalog.CatalogFeatures;
|
||||
import javax.xml.catalog.CatalogFeatures.Feature;
|
||||
import javax.xml.catalog.CatalogManager;
|
||||
import javax.xml.catalog.CatalogResolver;
|
||||
import javax.xml.catalog.CatalogUriResolver;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import static jaxp.library.JAXPTestUtilities.getPathByClassName;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import org.w3c.dom.Element;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.ErrorHandler;
|
||||
import org.xml.sax.SAXException;
|
||||
@ -42,11 +41,65 @@ import org.xml.sax.XMLReader;
|
||||
import org.xml.sax.ext.DefaultHandler2;
|
||||
|
||||
/*
|
||||
* @bug 8081248
|
||||
* @bug 8081248, 8144966, 8146606
|
||||
* @summary Tests basic Catalog functions.
|
||||
*/
|
||||
|
||||
public class CatalogTest {
|
||||
/*
|
||||
@bug 8146606
|
||||
Verifies that the resulting systemId does not contain duplicate slashes
|
||||
*/
|
||||
public void testRewriteSystem() {
|
||||
String catalog = getClass().getResource("rewriteCatalog.xml").getFile();
|
||||
|
||||
try {
|
||||
CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog);
|
||||
String actualSystemId = resolver.resolveEntity(null, "http://remote.com/dtd/book.dtd").getSystemId();
|
||||
Assert.assertTrue(!actualSystemId.contains("//"), "result contains duplicate slashes");
|
||||
} catch (Exception e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@bug 8146606
|
||||
Verifies that the resulting systemId does not contain duplicate slashes
|
||||
*/
|
||||
public void testRewriteUri() {
|
||||
String catalog = getClass().getResource("rewriteCatalog.xml").getFile();
|
||||
|
||||
try {
|
||||
|
||||
CatalogUriResolver resolver = CatalogManager.catalogUriResolver(CatalogFeatures.defaults(), catalog);
|
||||
String actualSystemId = resolver.resolve("http://remote.com/import/import.xsl", null).getSystemId();
|
||||
Assert.assertTrue(!actualSystemId.contains("//"), "result contains duplicate slashes");
|
||||
} catch (Exception e) {
|
||||
Assert.fail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@bug 8144966
|
||||
Verifies that passing null as CatalogFeatures will result in a NPE.
|
||||
*/
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testFeatureNull() {
|
||||
CatalogResolver resolver = CatalogManager.catalogResolver(null, "");
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@bug 8144966
|
||||
Verifies that passing null as the path will result in a NPE.
|
||||
*/
|
||||
@Test(expectedExceptions = NullPointerException.class)
|
||||
public void testPathNull() {
|
||||
String path = null;
|
||||
CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), path);
|
||||
}
|
||||
|
||||
/*
|
||||
Tests basic catalog feature by using a CatalogResolver instance to
|
||||
resolve a DTD reference to a locally specified DTD file. If the resolution
|
||||
@ -61,7 +114,7 @@ public class CatalogTest {
|
||||
}
|
||||
String url = getClass().getResource(xml).getFile();
|
||||
try {
|
||||
CatalogResolver cr = CatalogManager.catalogResolver(null, catalog);
|
||||
CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog);
|
||||
XMLReader reader = saxParser.getXMLReader();
|
||||
reader.setEntityResolver(cr);
|
||||
MyHandler handler = new MyHandler(saxParser);
|
||||
@ -84,7 +137,7 @@ public class CatalogTest {
|
||||
|
||||
String test = "testInvalidCatalog";
|
||||
try {
|
||||
CatalogResolver resolver = CatalogManager.catalogResolver(null, catalog);
|
||||
CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog);
|
||||
String actualSystemId = resolver.resolveEntity(null, "http://remote/xml/dtd/sys/alice/docAlice.dtd").getSystemId();
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
|
11
jaxp/test/javax/xml/jaxp/unittest/catalog/rewriteCatalog.xml
Normal file
11
jaxp/test/javax/xml/jaxp/unittest/catalog/rewriteCatalog.xml
Normal file
@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<catalog
|
||||
xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
|
||||
|
||||
<rewriteSystem systemIdStartString="http://remote.com/dtd"
|
||||
rewritePrefix="file:///share/docbook/docbook/pass"/>
|
||||
|
||||
<rewriteURI uriStartString="http://remote.com/import" rewritePrefix="file:///local/import" />
|
||||
|
||||
</catalog>
|
||||
|
202
jaxp/test/javax/xml/jaxp/unittest/common/Sources.java
Normal file
202
jaxp/test/javax/xml/jaxp/unittest/common/Sources.java
Normal file
@ -0,0 +1,202 @@
|
||||
/*
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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 common;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.StringReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URISyntaxException;
|
||||
import javax.xml.parsers.DocumentBuilderFactory;
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import javax.xml.stream.XMLEventReader;
|
||||
import javax.xml.stream.XMLInputFactory;
|
||||
import javax.xml.stream.XMLStreamException;
|
||||
import javax.xml.stream.XMLStreamReader;
|
||||
import javax.xml.transform.Source;
|
||||
import javax.xml.transform.dom.DOMSource;
|
||||
import javax.xml.transform.sax.SAXSource;
|
||||
import javax.xml.transform.stax.StAXSource;
|
||||
import javax.xml.transform.stream.StreamSource;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.DataProvider;
|
||||
import org.testng.annotations.Test;
|
||||
import org.w3c.dom.Document;
|
||||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.XMLReader;
|
||||
|
||||
/*
|
||||
* @bug 8144967
|
||||
* @summary Tests related to the javax.xml.transform.Source
|
||||
* and org.xml.sax.InputSource
|
||||
*/
|
||||
public class Sources {
|
||||
|
||||
/**
|
||||
* @bug 8144967
|
||||
* Tests whether a Source object is empty
|
||||
* @param source the Source object
|
||||
*/
|
||||
@Test(dataProvider = "emptySources")
|
||||
public void testIsEmpty(Source source) {
|
||||
Assert.assertTrue(source.isEmpty(), "The source is not empty");
|
||||
}
|
||||
|
||||
/**
|
||||
* @bug 8144967
|
||||
* Tests that the source is not empty
|
||||
* @param source the Source object
|
||||
*/
|
||||
@Test(dataProvider = "nonEmptySources")
|
||||
public void testIsNotEmpty(Source source) {
|
||||
Assert.assertTrue(!source.isEmpty(), "The source is empty");
|
||||
}
|
||||
|
||||
/**
|
||||
* @bug 8144967
|
||||
* Tests whether an InputSource object is empty
|
||||
* @param source the InputSource object
|
||||
*/
|
||||
@Test(dataProvider = "emptyInputSource")
|
||||
public void testISIsEmpty(InputSource source) {
|
||||
Assert.assertTrue(source.isEmpty(), "The source is not empty");
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider: sources that are empty
|
||||
*/
|
||||
@DataProvider(name = "emptySources")
|
||||
Object[][] getSources() throws URISyntaxException {
|
||||
|
||||
return new Object[][]{
|
||||
{new DOMSource()},
|
||||
{new DOMSource(getDocument())},
|
||||
{new SAXSource()},
|
||||
{new SAXSource(new InputSource(new StringReader("")))},
|
||||
{new SAXSource(getXMLReader(), new InputSource(new StringReader("")))},
|
||||
{new StreamSource()},
|
||||
{new StreamSource(new ByteArrayInputStream("".getBytes()))},
|
||||
{new StreamSource(new StringReader(""))},
|
||||
{new StreamSource(new StringReader(""), null)},
|
||||
{new StreamSource((String) null)}
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider: sources that are not empty
|
||||
*/
|
||||
@DataProvider(name = "nonEmptySources")
|
||||
Object[][] getSourcesEx() throws URISyntaxException {
|
||||
StAXSource ss = null;
|
||||
try {
|
||||
ss = new StAXSource(getXMLEventReader());
|
||||
} catch (XMLStreamException ex) {}
|
||||
|
||||
return new Object[][]{
|
||||
//This will set a non-null systemId on the resulting StreamSource
|
||||
{new StreamSource(new File(""))},
|
||||
//Can't tell because XMLStreamReader is a pull parser, cursor advancement
|
||||
//would have been required in order to examine the reader.
|
||||
{new StAXSource(getXMLStreamReader())},
|
||||
{ss}
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* DataProvider: sources that are empty
|
||||
*/
|
||||
@DataProvider(name = "emptyInputSource")
|
||||
Object[][] getInputSources() throws URISyntaxException {
|
||||
byte[] utf8Bytes = null;
|
||||
try {
|
||||
utf8Bytes = "".getBytes("UTF8");
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new RuntimeException(ex.getMessage());
|
||||
}
|
||||
return new Object[][]{
|
||||
{new InputSource()},
|
||||
{new InputSource(new ByteArrayInputStream(utf8Bytes))},
|
||||
{new InputSource(new StringReader(""))},
|
||||
{new InputSource((String) null)}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of Document.
|
||||
*
|
||||
* @return an instance of Document.
|
||||
*/
|
||||
private Document getDocument() {
|
||||
Document doc = null;
|
||||
try {
|
||||
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||
doc = dbf.newDocumentBuilder().newDocument();
|
||||
} catch (ParserConfigurationException ex) {}
|
||||
return doc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of XMLReader.
|
||||
*
|
||||
* @return an instance of XMLReader.
|
||||
*/
|
||||
private XMLReader getXMLReader() {
|
||||
XMLReader reader = null;
|
||||
try {
|
||||
reader = SAXParserFactory.newInstance().newSAXParser().getXMLReader();
|
||||
} catch (ParserConfigurationException | SAXException ex) {}
|
||||
return reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of XMLStreamReader.
|
||||
*
|
||||
* @return an instance of XMLStreamReader.
|
||||
*/
|
||||
private XMLStreamReader getXMLStreamReader() {
|
||||
XMLStreamReader r = null;
|
||||
try {
|
||||
XMLInputFactory xif = XMLInputFactory.newInstance();
|
||||
r = xif.createXMLStreamReader(new ByteArrayInputStream("".getBytes()));
|
||||
} catch (XMLStreamException ex) {}
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an instance of XMLEventReader.
|
||||
*
|
||||
* @return an instance of XMLEventReader.
|
||||
*/
|
||||
private XMLEventReader getXMLEventReader() {
|
||||
XMLEventReader r = null;
|
||||
try {
|
||||
r = XMLInputFactory.newInstance().createXMLEventReader(
|
||||
new ByteArrayInputStream("".getBytes()));
|
||||
} catch (XMLStreamException ex) {}
|
||||
|
||||
return r;
|
||||
}
|
||||
}
|
@ -345,3 +345,5 @@ b55cebc47555293cf9c2aefb3bf63c56e847ab19 jdk-9+96
|
||||
7293db4716ee25b814e14f738b9acfb85700e3fa jdk-9+97
|
||||
67c84077edc3db6b24998b35970b37c01aae985e jdk-9+98
|
||||
97b31ca0dd77483cf20ff99a033a455673639578 jdk-9+99
|
||||
d0a97e57d2336238edf6a4cd60aafe67deb7258d jdk-9+100
|
||||
3e99318616da903e0dc8f07f9f9203dc1bd49921 jdk-9+101
|
||||
|
@ -342,3 +342,5 @@ c021b855f51e572e63982654b17742cb1f814fb4 jdk-9+96
|
||||
fdd84b2265ddce7f50e084b7c8635189bba6f012 jdk-9+97
|
||||
f86ee68d1107dad41a27efc34306e0e56244a12e jdk-9+98
|
||||
e1a789be1535741274c9779f4d4ca3495196b5c3 jdk-9+99
|
||||
3d452840f48299a36842760d17c0c8402f0e1266 jdk-9+100
|
||||
5e8370fb3ed925335164afe340d1e54beab2d4d5 jdk-9+101
|
||||
|
@ -48,7 +48,6 @@ BREAK_ITERATOR_CLASSES := $(BUILDTOOLS_OUTPUTDIR)/break_iterator_classes
|
||||
$(eval $(call SetupJavaCompilation,BUILD_BREAKITERATOR, \
|
||||
SETUP := GENERATE_OLDBYTECODE, \
|
||||
SRC := $(TEXT_SRCDIR), \
|
||||
INCLUDES := $(TEXT_PKG), \
|
||||
INCLUDE_FILES := $(TEXT_SOURCES), \
|
||||
BIN := $(BREAK_ITERATOR_CLASSES)))
|
||||
|
||||
|
@ -58,7 +58,10 @@ endif
|
||||
ifeq ($(OPENJDK_TARGET_OS), aix)
|
||||
BUILD_LIBNIO_MAPFILE:=$(JDK_TOPDIR)/make/mapfiles/libnio/mapfile-$(OPENJDK_TARGET_OS)
|
||||
BUILD_LIBNIO_EXFILES += \
|
||||
NativeThread.c
|
||||
/NativeThread.c
|
||||
# Notice: we really need the leading slash here because otherwise every
|
||||
# FILE_NAME in EXCLUDE_FILES will actually match any file ending in FILE_NAME
|
||||
# (e.g. 'NativeThread.c' will also exclude 'AixNativeThread.c').
|
||||
endif
|
||||
|
||||
$(eval $(call SetupNativeCompilation,BUILD_LIBNIO, \
|
||||
|
@ -216,6 +216,7 @@ SUNWprivate_1.1 {
|
||||
Java_java_lang_SecurityManager_getClassContext;
|
||||
Java_java_lang_Shutdown_halt0;
|
||||
Java_java_lang_String_intern;
|
||||
Java_java_lang_StringCoding_err;
|
||||
Java_java_lang_StringUTF16_isBigEndian;
|
||||
Java_java_lang_System_identityHashCode;
|
||||
Java_java_lang_System_initProperties;
|
||||
@ -243,8 +244,6 @@ SUNWprivate_1.1 {
|
||||
Java_java_util_TimeZone_getSystemTimeZoneID;
|
||||
Java_java_util_TimeZone_getSystemGMTOffsetID;
|
||||
Java_java_util_concurrent_atomic_AtomicLong_VMSupportsCS8;
|
||||
Java_sun_misc_MessageUtils_toStderr;
|
||||
Java_sun_misc_MessageUtils_toStdout;
|
||||
Java_sun_misc_NativeSignalHandler_handle0;
|
||||
Java_sun_misc_Signal_findSignal;
|
||||
Java_sun_misc_Signal_handle0;
|
||||
@ -274,12 +273,12 @@ SUNWprivate_1.1 {
|
||||
Java_sun_reflect_Reflection_getClassAccessFlags;
|
||||
Java_sun_misc_Version_getJdkVersionInfo;
|
||||
Java_sun_misc_Version_getJvmVersionInfo;
|
||||
Java_sun_misc_VM_latestUserDefinedLoader;
|
||||
Java_sun_misc_VM_getuid;
|
||||
Java_sun_misc_VM_geteuid;
|
||||
Java_sun_misc_VM_getgid;
|
||||
Java_sun_misc_VM_getegid;
|
||||
Java_sun_misc_VM_initialize;
|
||||
Java_jdk_internal_misc_VM_latestUserDefinedLoader;
|
||||
Java_jdk_internal_misc_VM_getuid;
|
||||
Java_jdk_internal_misc_VM_geteuid;
|
||||
Java_jdk_internal_misc_VM_getgid;
|
||||
Java_jdk_internal_misc_VM_getegid;
|
||||
Java_jdk_internal_misc_VM_initialize;
|
||||
Java_sun_misc_VMSupport_initAgentProperties;
|
||||
Java_sun_misc_VMSupport_getVMTemporaryDirectory;
|
||||
|
||||
|
@ -35,8 +35,6 @@ import java.util.Hashtable;
|
||||
import java.util.BitSet;
|
||||
import java.text.MessageFormat;
|
||||
|
||||
import sun.misc.MessageUtils;
|
||||
|
||||
/**
|
||||
* A parser for DTDs. This parser roughly corresponds to the
|
||||
* rules specified in "The SGML Handbook" by Charles F. Goldfarb.
|
||||
|
@ -2135,7 +2135,7 @@ public class ObjectInputStream
|
||||
* corresponding modifications to the above class.
|
||||
*/
|
||||
private static ClassLoader latestUserDefinedLoader() {
|
||||
return sun.misc.VM.latestUserDefinedLoader();
|
||||
return jdk.internal.misc.VM.latestUserDefinedLoader();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -56,6 +56,7 @@ import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.StringJoiner;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.ConstantPool;
|
||||
@ -360,9 +361,9 @@ public final class Class<T> implements java.io.Serializable,
|
||||
// Reflective call to get caller class is only needed if a security manager
|
||||
// is present. Avoid the overhead of making this call otherwise.
|
||||
caller = Reflection.getCallerClass();
|
||||
if (sun.misc.VM.isSystemDomainLoader(loader)) {
|
||||
if (VM.isSystemDomainLoader(loader)) {
|
||||
ClassLoader ccl = ClassLoader.getClassLoader(caller);
|
||||
if (!sun.misc.VM.isSystemDomainLoader(ccl)) {
|
||||
if (!VM.isSystemDomainLoader(ccl)) {
|
||||
sm.checkPermission(
|
||||
SecurityConstants.GET_CLASSLOADER_PERMISSION);
|
||||
}
|
||||
|
@ -50,6 +50,8 @@ import java.util.Vector;
|
||||
import java.util.Hashtable;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import jdk.internal.perf.PerfCounter;
|
||||
import sun.misc.Resource;
|
||||
import sun.misc.URLClassPath;
|
||||
import sun.reflect.CallerSensitive;
|
||||
@ -423,9 +425,9 @@ public abstract class ClassLoader {
|
||||
c = findClass(name);
|
||||
|
||||
// this is the defining class loader; record the stats
|
||||
sun.misc.PerfCounter.getParentDelegationTime().addTime(t1 - t0);
|
||||
sun.misc.PerfCounter.getFindClassTime().addElapsedTimeFrom(t1);
|
||||
sun.misc.PerfCounter.getFindClasses().increment();
|
||||
PerfCounter.getParentDelegationTime().addTime(t1 - t0);
|
||||
PerfCounter.getFindClassTime().addElapsedTimeFrom(t1);
|
||||
PerfCounter.getFindClasses().increment();
|
||||
}
|
||||
}
|
||||
if (resolve) {
|
||||
|
@ -28,6 +28,7 @@ package java.lang;
|
||||
import java.lang.annotation.Native;
|
||||
import java.util.Objects;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
import static java.lang.String.COMPACT_STRINGS;
|
||||
import static java.lang.String.LATIN1;
|
||||
@ -1018,7 +1019,7 @@ public final class Integer extends Number implements Comparable<Integer> {
|
||||
* may be controlled by the {@code -XX:AutoBoxCacheMax=<size>} option.
|
||||
* During VM initialization, java.lang.Integer.IntegerCache.high property
|
||||
* may be set and saved in the private system properties in the
|
||||
* sun.misc.VM class.
|
||||
* jdk.internal.misc.VM class.
|
||||
*/
|
||||
|
||||
private static class IntegerCache {
|
||||
@ -1030,7 +1031,7 @@ public final class Integer extends Number implements Comparable<Integer> {
|
||||
// high value may be configured by property
|
||||
int h = 127;
|
||||
String integerCacheHighPropValue =
|
||||
sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
|
||||
VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
|
||||
if (integerCacheHighPropValue != null) {
|
||||
try {
|
||||
int i = parseInt(integerCacheHighPropValue);
|
||||
|
@ -61,6 +61,9 @@ interface LiveStackFrame extends StackFrame {
|
||||
* local variable array is an {@link PrimitiveValue} object;
|
||||
* otherwise, the element is an {@code Object}.
|
||||
*
|
||||
* <p>The returned array may contain null entries if a local variable is not
|
||||
* live.
|
||||
*
|
||||
* @return the local variable array of this stack frame.
|
||||
*/
|
||||
public Object[] getLocals();
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
package java.lang;
|
||||
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.lang.StackWalker.Option;
|
||||
|
@ -39,7 +39,6 @@ import java.nio.charset.IllegalCharsetNameException;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.Arrays;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import sun.misc.MessageUtils;
|
||||
import sun.nio.cs.HistoricallyNamedCharset;
|
||||
import sun.nio.cs.ArrayDecoder;
|
||||
import sun.nio.cs.ArrayEncoder;
|
||||
@ -106,11 +105,11 @@ class StringCoding {
|
||||
|
||||
private static void warnUnsupportedCharset(String csn) {
|
||||
if (warnUnsupportedCharset) {
|
||||
// Use sun.misc.MessageUtils rather than the Logging API or
|
||||
// System.err since this method may be called during VM
|
||||
// initialization before either is available.
|
||||
MessageUtils.err("WARNING: Default charset " + csn +
|
||||
" not supported, using ISO-8859-1 instead");
|
||||
// Use err(String) rather than the Logging API or System.err
|
||||
// since this method may be called during VM initialization
|
||||
// before either is available.
|
||||
err("WARNING: Default charset " + csn +
|
||||
" not supported, using ISO-8859-1 instead\n");
|
||||
warnUnsupportedCharset = false;
|
||||
}
|
||||
}
|
||||
@ -341,10 +340,9 @@ class StringCoding {
|
||||
try {
|
||||
return decode("ISO-8859-1", ba, off, len);
|
||||
} catch (UnsupportedEncodingException x) {
|
||||
// If this code is hit during VM initialization, MessageUtils is
|
||||
// If this code is hit during VM initialization, err(String) is
|
||||
// the only way we will be able to get any kind of error message.
|
||||
MessageUtils.err("ISO-8859-1 charset not available: "
|
||||
+ x.toString());
|
||||
err("ISO-8859-1 charset not available: " + x.toString() + "\n");
|
||||
// If we can not find ISO-8859-1 (a required encoding) then things
|
||||
// are seriously wrong with the installation.
|
||||
System.exit(1);
|
||||
@ -653,14 +651,20 @@ class StringCoding {
|
||||
try {
|
||||
return encode("ISO-8859-1", coder, val);
|
||||
} catch (UnsupportedEncodingException x) {
|
||||
// If this code is hit during VM initialization, MessageUtils is
|
||||
// If this code is hit during VM initialization, err(String) is
|
||||
// the only way we will be able to get any kind of error message.
|
||||
MessageUtils.err("ISO-8859-1 charset not available: "
|
||||
+ x.toString());
|
||||
err("ISO-8859-1 charset not available: " + x.toString() + "\n");
|
||||
// If we can not find ISO-8859-1 (a required encoding) then things
|
||||
// are seriously wrong with the installation.
|
||||
System.exit(1);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a message directly to stderr, bypassing all character conversion
|
||||
* methods.
|
||||
* @param msg message to print
|
||||
*/
|
||||
private static native void err(String msg);
|
||||
}
|
||||
|
@ -46,6 +46,7 @@ import sun.reflect.annotation.AnnotationType;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.JavaLangAccess;;
|
||||
import jdk.internal.misc.SharedSecrets;;
|
||||
import jdk.internal.misc.VM;
|
||||
import jdk.internal.logger.LoggerFinderLoader;
|
||||
import jdk.internal.logger.LazyLoggers;
|
||||
import jdk.internal.logger.LocalizedLoggerWrapper;
|
||||
@ -1534,6 +1535,8 @@ public final class System {
|
||||
* @return an instance of {@link Logger} that can be used by the calling
|
||||
* class.
|
||||
* @throws NullPointerException if {@code name} is {@code null}.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
@CallerSensitive
|
||||
public static Logger getLogger(String name) {
|
||||
@ -1571,6 +1574,8 @@ public final class System {
|
||||
* resource bundle for message localization.
|
||||
* @throws NullPointerException if {@code name} is {@code null} or
|
||||
* {@code bundle} is {@code null}.
|
||||
*
|
||||
* @since 9
|
||||
*/
|
||||
@CallerSensitive
|
||||
public static Logger getLogger(String name, ResourceBundle bundle) {
|
||||
@ -1817,12 +1822,12 @@ public final class System {
|
||||
// removed from the system properties.
|
||||
//
|
||||
// See java.lang.Integer.IntegerCache and the
|
||||
// sun.misc.VM.saveAndRemoveProperties method for example.
|
||||
// VM.saveAndRemoveProperties method for example.
|
||||
//
|
||||
// Save a private copy of the system properties object that
|
||||
// can only be accessed by the internal implementation. Remove
|
||||
// certain system properties that are not intended for public access.
|
||||
sun.misc.VM.saveAndRemoveProperties(props);
|
||||
VM.saveAndRemoveProperties(props);
|
||||
|
||||
|
||||
lineSeparator = props.getProperty("line.separator");
|
||||
@ -1846,7 +1851,7 @@ public final class System {
|
||||
// set for the class libraries. Currently this is no-op everywhere except
|
||||
// for Windows where the process-wide error mode is set before the java.io
|
||||
// classes are used.
|
||||
sun.misc.VM.initializeOSEnvironment();
|
||||
VM.initializeOSEnvironment();
|
||||
|
||||
// The main thread is not added to its thread group in the same
|
||||
// way as other threads; we must do it ourselves here.
|
||||
@ -1857,10 +1862,10 @@ public final class System {
|
||||
setJavaLangAccess();
|
||||
|
||||
// Subsystems that are invoked during initialization can invoke
|
||||
// sun.misc.VM.isBooted() in order to avoid doing things that should
|
||||
// VM.isBooted() in order to avoid doing things that should
|
||||
// wait until the application class loader has been set up.
|
||||
// IMPORTANT: Ensure that this remains the last initialization action!
|
||||
sun.misc.VM.booted();
|
||||
VM.booted();
|
||||
}
|
||||
|
||||
private static void setJavaLangAccess() {
|
||||
|
@ -1869,7 +1869,7 @@ class Thread implements Runnable {
|
||||
*/
|
||||
public State getState() {
|
||||
// get current thread state
|
||||
return sun.misc.VM.toThreadState(threadStatus);
|
||||
return jdk.internal.misc.VM.toThreadState(threadStatus);
|
||||
}
|
||||
|
||||
// Added in JSR-166
|
||||
|
@ -27,7 +27,7 @@ package java.lang;
|
||||
|
||||
import java.io.PrintStream;
|
||||
import java.util.Arrays;
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
/**
|
||||
* A thread group represents a set of threads. In addition, a thread
|
||||
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
package java.lang;
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1836,7 +1836,7 @@ return mh1;
|
||||
return false;
|
||||
}
|
||||
ClassLoader loader = defc.getClassLoader();
|
||||
if (!sun.misc.VM.isSystemDomainLoader(loader)) {
|
||||
if (!jdk.internal.misc.VM.isSystemDomainLoader(loader)) {
|
||||
ClassLoader sysl = ClassLoader.getSystemClassLoader();
|
||||
boolean found = false;
|
||||
while (sysl != null) {
|
||||
@ -3120,6 +3120,8 @@ assertEquals("boojum", (String) catTrace.invokeExact("boo", "jum"));
|
||||
MethodHandle handler) {
|
||||
MethodType ttype = target.type();
|
||||
MethodType htype = handler.type();
|
||||
if (!Throwable.class.isAssignableFrom(exType))
|
||||
throw new ClassCastException(exType.getName());
|
||||
if (htype.parameterCount() < 1 ||
|
||||
!htype.parameterType(0).isAssignableFrom(exType))
|
||||
throw newIllegalArgumentException("handler does not accept exception type "+exType);
|
||||
|
@ -28,7 +28,7 @@ package java.lang.ref;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import jdk.internal.misc.CleanerImpl;
|
||||
import jdk.internal.ref.CleanerImpl;
|
||||
|
||||
/**
|
||||
* {@code Cleaner} manages a set of object references and corresponding cleaning actions.
|
||||
|
@ -29,7 +29,7 @@ import java.security.PrivilegedAction;
|
||||
import java.security.AccessController;
|
||||
import jdk.internal.misc.JavaLangAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
final class Finalizer extends FinalReference<Object> { /* Package-private; must be in
|
||||
same package as the Reference
|
||||
|
@ -26,6 +26,7 @@
|
||||
package java.lang.ref;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
/**
|
||||
* Reference queues, to which registered reference objects are appended by the
|
||||
@ -73,7 +74,7 @@ public class ReferenceQueue<T> {
|
||||
// Volatiles ensure ordering.
|
||||
r.queue = ENQUEUED;
|
||||
if (r instanceof FinalReference) {
|
||||
sun.misc.VM.addFinalRefCount(1);
|
||||
VM.addFinalRefCount(1);
|
||||
}
|
||||
lock.notifyAll();
|
||||
return true;
|
||||
@ -93,7 +94,7 @@ public class ReferenceQueue<T> {
|
||||
r.next = r;
|
||||
queueLength--;
|
||||
if (r instanceof FinalReference) {
|
||||
sun.misc.VM.addFinalRefCount(-1);
|
||||
VM.addFinalRefCount(-1);
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.function.BiFunction;
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.Reflection;
|
||||
import sun.reflect.misc.ReflectUtil;
|
||||
|
@ -376,19 +376,23 @@ public abstract class SocketImpl implements SocketOptions {
|
||||
* @since 1.9
|
||||
*/
|
||||
protected <T> void setOption(SocketOption<T> name, T value) throws IOException {
|
||||
if (name == StandardSocketOptions.SO_KEEPALIVE) {
|
||||
if (name == StandardSocketOptions.SO_KEEPALIVE &&
|
||||
(getSocket() != null)) {
|
||||
setOption(SocketOptions.SO_KEEPALIVE, value);
|
||||
} else if (name == StandardSocketOptions.SO_SNDBUF) {
|
||||
} else if (name == StandardSocketOptions.SO_SNDBUF &&
|
||||
(getSocket() != null)) {
|
||||
setOption(SocketOptions.SO_SNDBUF, value);
|
||||
} else if (name == StandardSocketOptions.SO_RCVBUF) {
|
||||
setOption(SocketOptions.SO_RCVBUF, value);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEADDR) {
|
||||
setOption(SocketOptions.SO_REUSEADDR, value);
|
||||
} else if (name == StandardSocketOptions.SO_LINGER) {
|
||||
} else if (name == StandardSocketOptions.SO_LINGER &&
|
||||
(getSocket() != null)) {
|
||||
setOption(SocketOptions.SO_LINGER, value);
|
||||
} else if (name == StandardSocketOptions.IP_TOS) {
|
||||
setOption(SocketOptions.IP_TOS, value);
|
||||
} else if (name == StandardSocketOptions.TCP_NODELAY) {
|
||||
} else if (name == StandardSocketOptions.TCP_NODELAY &&
|
||||
(getSocket() != null)) {
|
||||
setOption(SocketOptions.TCP_NODELAY, value);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
@ -412,19 +416,23 @@ public abstract class SocketImpl implements SocketOptions {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> T getOption(SocketOption<T> name) throws IOException {
|
||||
if (name == StandardSocketOptions.SO_KEEPALIVE) {
|
||||
if (name == StandardSocketOptions.SO_KEEPALIVE &&
|
||||
(getSocket() != null)) {
|
||||
return (T)getOption(SocketOptions.SO_KEEPALIVE);
|
||||
} else if (name == StandardSocketOptions.SO_SNDBUF) {
|
||||
} else if (name == StandardSocketOptions.SO_SNDBUF &&
|
||||
(getSocket() != null)) {
|
||||
return (T)getOption(SocketOptions.SO_SNDBUF);
|
||||
} else if (name == StandardSocketOptions.SO_RCVBUF) {
|
||||
return (T)getOption(SocketOptions.SO_RCVBUF);
|
||||
} else if (name == StandardSocketOptions.SO_REUSEADDR) {
|
||||
return (T)getOption(SocketOptions.SO_REUSEADDR);
|
||||
} else if (name == StandardSocketOptions.SO_LINGER) {
|
||||
} else if (name == StandardSocketOptions.SO_LINGER &&
|
||||
(getSocket() != null)) {
|
||||
return (T)getOption(SocketOptions.SO_LINGER);
|
||||
} else if (name == StandardSocketOptions.IP_TOS) {
|
||||
return (T)getOption(SocketOptions.IP_TOS);
|
||||
} else if (name == StandardSocketOptions.TCP_NODELAY) {
|
||||
} else if (name == StandardSocketOptions.TCP_NODELAY &&
|
||||
(getSocket() != null)) {
|
||||
return (T)getOption(SocketOptions.TCP_NODELAY);
|
||||
} else {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
|
@ -1146,13 +1146,30 @@ public final class URI
|
||||
if (part != null) {
|
||||
return part;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
appendSchemeSpecificPart(sb, null, getAuthority(), getUserInfo(),
|
||||
|
||||
String s = string;
|
||||
if (s != null) {
|
||||
// if string is defined, components will have been parsed
|
||||
int start = 0;
|
||||
int end = s.length();
|
||||
if (scheme != null) {
|
||||
start = scheme.length() + 1;
|
||||
}
|
||||
if (fragment != null) {
|
||||
end -= fragment.length() + 1;
|
||||
}
|
||||
if (path != null && path.length() == end - start) {
|
||||
part = path;
|
||||
} else {
|
||||
part = s.substring(start, end);
|
||||
}
|
||||
} else {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
appendSchemeSpecificPart(sb, null, getAuthority(), getUserInfo(),
|
||||
host, port, getPath(), getQuery());
|
||||
if (sb.length() == 0) {
|
||||
return null;
|
||||
part = sb.toString();
|
||||
}
|
||||
return schemeSpecificPart = sb.toString();
|
||||
return schemeSpecificPart = part;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2059,7 +2076,7 @@ public final class URI
|
||||
|
||||
// 5.2 (2): Reference to current document (lone fragment)
|
||||
if ((child.scheme == null) && (child.authority == null)
|
||||
&& child.path.equals("") && (child.fragment != null)
|
||||
&& child.path.isEmpty() && (child.fragment != null)
|
||||
&& (child.query == null)) {
|
||||
if ((base.fragment != null)
|
||||
&& child.fragment.equals(base.fragment)) {
|
||||
@ -2647,13 +2664,6 @@ public final class URI
|
||||
private static final long L_SCHEME = L_ALPHA | L_DIGIT | lowMask("+-.");
|
||||
private static final long H_SCHEME = H_ALPHA | H_DIGIT | highMask("+-.");
|
||||
|
||||
// uric_no_slash = unreserved | escaped | ";" | "?" | ":" | "@" |
|
||||
// "&" | "=" | "+" | "$" | ","
|
||||
private static final long L_URIC_NO_SLASH
|
||||
= L_UNRESERVED | L_ESCAPED | lowMask(";?:@&=+$,");
|
||||
private static final long H_URIC_NO_SLASH
|
||||
= H_UNRESERVED | H_ESCAPED | highMask(";?:@&=+$,");
|
||||
|
||||
// scope_id = alpha | digit | "_" | "."
|
||||
private static final long L_SCOPE_ID
|
||||
= L_ALPHANUM | lowMask("_.");
|
||||
@ -2884,23 +2894,10 @@ public final class URI
|
||||
|
||||
// -- Simple access to the input string --
|
||||
|
||||
// Return a substring of the input string
|
||||
//
|
||||
private String substring(int start, int end) {
|
||||
return input.substring(start, end);
|
||||
}
|
||||
|
||||
// Return the char at position p,
|
||||
// assuming that p < input.length()
|
||||
//
|
||||
private char charAt(int p) {
|
||||
return input.charAt(p);
|
||||
}
|
||||
|
||||
// Tells whether start < end and, if so, whether charAt(start) == c
|
||||
//
|
||||
private boolean at(int start, int end, char c) {
|
||||
return (start < end) && (charAt(start) == c);
|
||||
return (start < end) && (input.charAt(start) == c);
|
||||
}
|
||||
|
||||
// Tells whether start + s.length() < end and, if so,
|
||||
@ -2913,7 +2910,7 @@ public final class URI
|
||||
return false;
|
||||
int i = 0;
|
||||
while (i < sn) {
|
||||
if (charAt(p++) != s.charAt(i)) {
|
||||
if (input.charAt(p++) != s.charAt(i)) {
|
||||
break;
|
||||
}
|
||||
i++;
|
||||
@ -2953,7 +2950,7 @@ public final class URI
|
||||
// start position.
|
||||
//
|
||||
private int scan(int start, int end, char c) {
|
||||
if ((start < end) && (charAt(start) == c))
|
||||
if ((start < end) && (input.charAt(start) == c))
|
||||
return start + 1;
|
||||
return start;
|
||||
}
|
||||
@ -2968,7 +2965,7 @@ public final class URI
|
||||
private int scan(int start, int end, String err, String stop) {
|
||||
int p = start;
|
||||
while (p < end) {
|
||||
char c = charAt(p);
|
||||
char c = input.charAt(p);
|
||||
if (err.indexOf(c) >= 0)
|
||||
return -1;
|
||||
if (stop.indexOf(c) >= 0)
|
||||
@ -2978,6 +2975,23 @@ public final class URI
|
||||
return p;
|
||||
}
|
||||
|
||||
// Scan forward from the given start position. Stop at the first char
|
||||
// in the stop string (in which case the index of the preceding char is
|
||||
// returned), or the end of the input string (in which case the length
|
||||
// of the input string is returned). May return the start position if
|
||||
// nothing matches.
|
||||
//
|
||||
private int scan(int start, int end, String stop) {
|
||||
int p = start;
|
||||
while (p < end) {
|
||||
char c = input.charAt(p);
|
||||
if (stop.indexOf(c) >= 0)
|
||||
break;
|
||||
p++;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
// Scan a potential escape sequence, starting at the given position,
|
||||
// with the given first char (i.e., charAt(start) == c).
|
||||
//
|
||||
@ -2992,8 +3006,8 @@ public final class URI
|
||||
if (c == '%') {
|
||||
// Process escape pair
|
||||
if ((p + 3 <= n)
|
||||
&& match(charAt(p + 1), L_HEX, H_HEX)
|
||||
&& match(charAt(p + 2), L_HEX, H_HEX)) {
|
||||
&& match(input.charAt(p + 1), L_HEX, H_HEX)
|
||||
&& match(input.charAt(p + 2), L_HEX, H_HEX)) {
|
||||
return p + 3;
|
||||
}
|
||||
fail("Malformed escape pair", p);
|
||||
@ -3013,7 +3027,7 @@ public final class URI
|
||||
{
|
||||
int p = start;
|
||||
while (p < n) {
|
||||
char c = charAt(p);
|
||||
char c = input.charAt(p);
|
||||
if (match(c, lowMask, highMask)) {
|
||||
p++;
|
||||
continue;
|
||||
@ -3059,7 +3073,6 @@ public final class URI
|
||||
//
|
||||
void parse(boolean rsa) throws URISyntaxException {
|
||||
requireServerAuthority = rsa;
|
||||
int ssp; // Start of scheme-specific part
|
||||
int n = input.length();
|
||||
int p = scan(0, n, "/?#", ":");
|
||||
if ((p >= 0) && at(p, n, ':')) {
|
||||
@ -3067,26 +3080,25 @@ public final class URI
|
||||
failExpecting("scheme name", 0);
|
||||
checkChar(0, L_ALPHA, H_ALPHA, "scheme name");
|
||||
checkChars(1, p, L_SCHEME, H_SCHEME, "scheme name");
|
||||
scheme = substring(0, p);
|
||||
scheme = input.substring(0, p);
|
||||
p++; // Skip ':'
|
||||
ssp = p;
|
||||
if (at(p, n, '/')) {
|
||||
p = parseHierarchical(p, n);
|
||||
} else {
|
||||
int q = scan(p, n, "", "#");
|
||||
// opaque; need to create the schemeSpecificPart
|
||||
int q = scan(p, n, "#");
|
||||
if (q <= p)
|
||||
failExpecting("scheme-specific part", p);
|
||||
checkChars(p, q, L_URIC, H_URIC, "opaque part");
|
||||
schemeSpecificPart = input.substring(p, q);
|
||||
p = q;
|
||||
}
|
||||
} else {
|
||||
ssp = 0;
|
||||
p = parseHierarchical(0, n);
|
||||
}
|
||||
schemeSpecificPart = substring(ssp, p);
|
||||
if (at(p, n, '#')) {
|
||||
checkChars(p + 1, n, L_URIC, H_URIC, "fragment");
|
||||
fragment = substring(p + 1, n);
|
||||
fragment = input.substring(p + 1, n);
|
||||
p = n;
|
||||
}
|
||||
if (p < n)
|
||||
@ -3113,7 +3125,7 @@ public final class URI
|
||||
int p = start;
|
||||
if (at(p, n, '/') && at(p + 1, n, '/')) {
|
||||
p += 2;
|
||||
int q = scan(p, n, "", "/?#");
|
||||
int q = scan(p, n, "/?#");
|
||||
if (q > p) {
|
||||
p = parseAuthority(p, q);
|
||||
} else if (q < n) {
|
||||
@ -3122,15 +3134,15 @@ public final class URI
|
||||
} else
|
||||
failExpecting("authority", p);
|
||||
}
|
||||
int q = scan(p, n, "", "?#"); // DEVIATION: May be empty
|
||||
int q = scan(p, n, "?#"); // DEVIATION: May be empty
|
||||
checkChars(p, q, L_PATH, H_PATH, "path");
|
||||
path = substring(p, q);
|
||||
path = input.substring(p, q);
|
||||
p = q;
|
||||
if (at(p, n, '?')) {
|
||||
p++;
|
||||
q = scan(p, n, "", "#");
|
||||
q = scan(p, n, "#");
|
||||
checkChars(p, q, L_URIC, H_URIC, "query");
|
||||
query = substring(p, q);
|
||||
query = input.substring(p, q);
|
||||
p = q;
|
||||
}
|
||||
return p;
|
||||
@ -3154,7 +3166,7 @@ public final class URI
|
||||
boolean serverChars;
|
||||
boolean regChars;
|
||||
|
||||
if (scan(p, n, "", "]") > p) {
|
||||
if (scan(p, n, "]") > p) {
|
||||
// contains a literal IPv6 address, therefore % is allowed
|
||||
serverChars = (scan(p, n, L_SERVER_PERCENT, H_SERVER_PERCENT) == n);
|
||||
} else {
|
||||
@ -3164,7 +3176,7 @@ public final class URI
|
||||
|
||||
if (regChars && !serverChars) {
|
||||
// Must be a registry-based authority
|
||||
authority = substring(p, n);
|
||||
authority = input.substring(p, n);
|
||||
return n;
|
||||
}
|
||||
|
||||
@ -3176,7 +3188,7 @@ public final class URI
|
||||
q = parseServer(p, n);
|
||||
if (q < n)
|
||||
failExpecting("end of authority", q);
|
||||
authority = substring(p, n);
|
||||
authority = input.substring(p, n);
|
||||
} catch (URISyntaxException x) {
|
||||
// Undo results of failed parse
|
||||
userInfo = null;
|
||||
@ -3198,7 +3210,7 @@ public final class URI
|
||||
if (q < n) {
|
||||
if (regChars) {
|
||||
// Registry-based authority
|
||||
authority = substring(p, n);
|
||||
authority = input.substring(p, n);
|
||||
} else if (ex != null) {
|
||||
// Re-throw exception; it was probably due to
|
||||
// a malformed IPv6 address
|
||||
@ -3224,7 +3236,7 @@ public final class URI
|
||||
q = scan(p, n, "/?#", "@");
|
||||
if ((q >= p) && at(q, n, '@')) {
|
||||
checkChars(p, q, L_USERINFO, H_USERINFO, "user info");
|
||||
userInfo = substring(p, q);
|
||||
userInfo = input.substring(p, q);
|
||||
p = q + 1; // Skip '@'
|
||||
}
|
||||
|
||||
@ -3235,7 +3247,7 @@ public final class URI
|
||||
q = scan(p, n, "/?#", "]");
|
||||
if ((q > p) && at(q, n, ']')) {
|
||||
// look for a "%" scope id
|
||||
int r = scan (p, q, "", "%");
|
||||
int r = scan (p, q, "%");
|
||||
if (r > p) {
|
||||
parseIPv6Reference(p, r);
|
||||
if (r+1 == q) {
|
||||
@ -3246,7 +3258,7 @@ public final class URI
|
||||
} else {
|
||||
parseIPv6Reference(p, q);
|
||||
}
|
||||
host = substring(p-1, q+1);
|
||||
host = input.substring(p-1, q+1);
|
||||
p = q + 1;
|
||||
} else {
|
||||
failExpecting("closing bracket for IPv6 address", q);
|
||||
@ -3261,7 +3273,7 @@ public final class URI
|
||||
// port
|
||||
if (at(p, n, ':')) {
|
||||
p++;
|
||||
q = scan(p, n, "", "/");
|
||||
q = scan(p, n, "/");
|
||||
if (q > p) {
|
||||
checkChars(p, q, L_DIGIT, H_DIGIT, "port number");
|
||||
try {
|
||||
@ -3361,13 +3373,13 @@ public final class URI
|
||||
// IPv4 address is followed by something - check that
|
||||
// it's a ":" as this is the only valid character to
|
||||
// follow an address.
|
||||
if (charAt(p) != ':') {
|
||||
if (input.charAt(p) != ':') {
|
||||
p = -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (p > start)
|
||||
host = substring(start, p);
|
||||
host = input.substring(start, p);
|
||||
|
||||
return p;
|
||||
}
|
||||
@ -3393,7 +3405,7 @@ public final class URI
|
||||
p = q;
|
||||
q = scan(p, n, L_ALPHANUM | L_DASH, H_ALPHANUM | H_DASH);
|
||||
if (q > p) {
|
||||
if (charAt(q - 1) == '-')
|
||||
if (input.charAt(q - 1) == '-')
|
||||
fail("Illegal character in hostname", q - 1);
|
||||
p = q;
|
||||
}
|
||||
@ -3412,11 +3424,11 @@ public final class URI
|
||||
|
||||
// for a fully qualified hostname check that the rightmost
|
||||
// label starts with an alpha character.
|
||||
if (l > start && !match(charAt(l), L_ALPHA, H_ALPHA)) {
|
||||
if (l > start && !match(input.charAt(l), L_ALPHA, H_ALPHA)) {
|
||||
fail("Illegal character in hostname", l);
|
||||
}
|
||||
|
||||
host = substring(start, p);
|
||||
host = input.substring(start, p);
|
||||
return p;
|
||||
}
|
||||
|
||||
|
@ -1242,7 +1242,7 @@ public final class URL implements java.io.Serializable {
|
||||
private static ThreadLocal<Object> gate = new ThreadLocal<>();
|
||||
|
||||
private static URLStreamHandler lookupViaProviders(final String protocol) {
|
||||
if (!sun.misc.VM.isBooted())
|
||||
if (!jdk.internal.misc.VM.isBooted())
|
||||
return null;
|
||||
|
||||
if (gate.get() != null)
|
||||
|
@ -52,6 +52,7 @@ import java.util.jar.Manifest;
|
||||
|
||||
import jdk.internal.misc.JavaNetAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.perf.PerfCounter;
|
||||
import sun.misc.Resource;
|
||||
import sun.misc.URLClassPath;
|
||||
import sun.net.www.ParseUtil;
|
||||
@ -459,14 +460,14 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
||||
// Use (direct) ByteBuffer:
|
||||
CodeSigner[] signers = res.getCodeSigners();
|
||||
CodeSource cs = new CodeSource(url, signers);
|
||||
sun.misc.PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0);
|
||||
PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0);
|
||||
return defineClass(name, bb, cs);
|
||||
} else {
|
||||
byte[] b = res.getBytes();
|
||||
// must read certificates AFTER reading bytes.
|
||||
CodeSigner[] signers = res.getCodeSigners();
|
||||
CodeSource cs = new CodeSource(url, signers);
|
||||
sun.misc.PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0);
|
||||
PerfCounter.getReadClassBytesTime().addElapsedTimeFrom(t0);
|
||||
return defineClass(name, b, 0, b.length, cs);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1567,6 +1567,11 @@ public abstract class URLConnection {
|
||||
}
|
||||
}
|
||||
|
||||
if ((c1 == 0x49 && c2 == 0x49 && c3 == 0x2a && c4 == 0x00)
|
||||
|| (c1 == 0x4d && c2 == 0x4d && c3 == 0x00 && c4 == 0x2a)) {
|
||||
return "image/tiff";
|
||||
}
|
||||
|
||||
if (c1 == 0xD0 && c2 == 0xCF && c3 == 0x11 && c4 == 0xE0 &&
|
||||
c5 == 0xA1 && c6 == 0xB1 && c7 == 0x1A && c8 == 0xE1) {
|
||||
|
||||
|
@ -31,7 +31,7 @@ import jdk.internal.misc.JavaNioAccess;
|
||||
import jdk.internal.misc.JavaLangRefAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
/**
|
||||
* Access to bits, native and otherwise.
|
||||
|
@ -30,7 +30,7 @@ package java.nio;
|
||||
import java.io.FileDescriptor;
|
||||
import sun.misc.Cleaner;
|
||||
import jdk.internal.misc.Unsafe;
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
import sun.nio.ch.DirectBuffer;
|
||||
|
||||
|
||||
|
@ -43,6 +43,7 @@ import java.util.ServiceLoader;
|
||||
import java.util.ServiceConfigurationError;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
import jdk.internal.misc.VM;
|
||||
import sun.misc.ASCIICaseInsensitiveComparator;
|
||||
import sun.nio.cs.StandardCharsets;
|
||||
import sun.nio.cs.ThreadLocalCoders;
|
||||
@ -281,7 +282,7 @@ public abstract class Charset
|
||||
static boolean atBugLevel(String bl) { // package-private
|
||||
String level = bugLevel;
|
||||
if (level == null) {
|
||||
if (!sun.misc.VM.isBooted())
|
||||
if (!VM.isBooted())
|
||||
return false;
|
||||
bugLevel = level = AccessController.doPrivileged(
|
||||
new GetPropertyAction("sun.nio.cs.bugLevel", ""));
|
||||
@ -394,7 +395,7 @@ public abstract class Charset
|
||||
// that loader to be prematurely initialized with incomplete
|
||||
// information.
|
||||
//
|
||||
if (!sun.misc.VM.isBooted())
|
||||
if (!VM.isBooted())
|
||||
return null;
|
||||
|
||||
if (gate.get() != null)
|
||||
@ -445,7 +446,7 @@ public abstract class Charset
|
||||
}
|
||||
|
||||
private static Charset lookupExtendedCharset(String charsetName) {
|
||||
if (!sun.misc.VM.isBooted()) // see lookupViaProviders()
|
||||
if (!VM.isBooted()) // see lookupViaProviders()
|
||||
return null;
|
||||
CharsetProvider[] ecps = ExtendedProviderHolder.extendedProviders;
|
||||
for (CharsetProvider cp : ecps) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,12 +27,12 @@ package java.security;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import jdk.internal.misc.JavaSecurityAccess;
|
||||
import jdk.internal.misc.JavaSecurityProtectionDomainAccess;
|
||||
@ -472,11 +472,15 @@ public class ProtectionDomain {
|
||||
*
|
||||
* This class stores ProtectionDomains as weak keys in a ConcurrentHashMap
|
||||
* with additional support for checking and removing weak keys that are no
|
||||
* longer in use.
|
||||
* longer in use. There can be cases where the permission collection may
|
||||
* have a chain of strong references back to the ProtectionDomain, which
|
||||
* ordinarily would prevent the entry from being removed from the map. To
|
||||
* address that, we wrap the permission collection in a SoftReference so
|
||||
* that it can be reclaimed by the garbage collector due to memory demand.
|
||||
*/
|
||||
private static class PDCache implements ProtectionDomainCache {
|
||||
private final ConcurrentHashMap<WeakProtectionDomainKey,
|
||||
PermissionCollection>
|
||||
SoftReference<PermissionCollection>>
|
||||
pdMap = new ConcurrentHashMap<>();
|
||||
private final ReferenceQueue<Key> queue = new ReferenceQueue<>();
|
||||
|
||||
@ -485,15 +489,15 @@ public class ProtectionDomain {
|
||||
processQueue(queue, pdMap);
|
||||
WeakProtectionDomainKey weakPd =
|
||||
new WeakProtectionDomainKey(pd, queue);
|
||||
pdMap.putIfAbsent(weakPd, pc);
|
||||
pdMap.put(weakPd, new SoftReference<>(pc));
|
||||
}
|
||||
|
||||
@Override
|
||||
public PermissionCollection get(ProtectionDomain pd) {
|
||||
processQueue(queue, pdMap);
|
||||
WeakProtectionDomainKey weakPd =
|
||||
new WeakProtectionDomainKey(pd, queue);
|
||||
return pdMap.get(weakPd);
|
||||
WeakProtectionDomainKey weakPd = new WeakProtectionDomainKey(pd);
|
||||
SoftReference<PermissionCollection> sr = pdMap.get(weakPd);
|
||||
return (sr == null) ? null : sr.get();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -533,11 +537,20 @@ public class ProtectionDomain {
|
||||
this((pd == null ? NULL_KEY : pd.key), rq);
|
||||
}
|
||||
|
||||
WeakProtectionDomainKey(ProtectionDomain pd) {
|
||||
this(pd == null ? NULL_KEY : pd.key);
|
||||
}
|
||||
|
||||
private WeakProtectionDomainKey(Key key, ReferenceQueue<Key> rq) {
|
||||
super(key, rq);
|
||||
hash = key.hashCode();
|
||||
}
|
||||
|
||||
private WeakProtectionDomainKey(Key key) {
|
||||
super(key);
|
||||
hash = key.hashCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the identity hash code of the original referent.
|
||||
*/
|
||||
|
@ -69,7 +69,7 @@ import static java.time.LocalTime.NANOS_PER_MILLI;
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.TimeZone;
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
/**
|
||||
* A clock providing access to the current instant, date and time using a time-zone.
|
||||
|
@ -1194,6 +1194,7 @@ public final class Duration
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @return the whole seconds part of the length of the duration, positive or negative
|
||||
* @since 9
|
||||
*/
|
||||
public long toSeconds() {
|
||||
return seconds;
|
||||
@ -1243,6 +1244,7 @@ public final class Duration
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @return the number of days in the duration, may be negative
|
||||
* @since 9
|
||||
*/
|
||||
public long toDaysPart(){
|
||||
return seconds / SECONDS_PER_DAY;
|
||||
@ -1258,6 +1260,7 @@ public final class Duration
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @return the number of hours part in the duration, may be negative
|
||||
* @since 9
|
||||
*/
|
||||
public int toHoursPart(){
|
||||
return (int) (toHours() % 24);
|
||||
@ -1273,7 +1276,7 @@ public final class Duration
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @return the number of minutes parts in the duration, may be negative
|
||||
* may be negative
|
||||
* @since 9
|
||||
*/
|
||||
public int toMinutesPart(){
|
||||
return (int) (toMinutes() % MINUTES_PER_HOUR);
|
||||
@ -1289,6 +1292,7 @@ public final class Duration
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @return the number of seconds parts in the duration, may be negative
|
||||
* @since 9
|
||||
*/
|
||||
public int toSecondsPart(){
|
||||
return (int) (seconds % SECONDS_PER_MINUTE);
|
||||
@ -1306,6 +1310,7 @@ public final class Duration
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @return the number of milliseconds part of the duration.
|
||||
* @since 9
|
||||
*/
|
||||
public int toMillisPart(){
|
||||
return nanos / 1000_000;
|
||||
@ -1322,6 +1327,7 @@ public final class Duration
|
||||
* This instance is immutable and unaffected by this method call.
|
||||
*
|
||||
* @return the nanoseconds within the second part of the length of the duration, from 0 to 999,999,999
|
||||
* @since 9
|
||||
*/
|
||||
public int toNanosPart(){
|
||||
return nanos;
|
||||
@ -1385,7 +1391,7 @@ public final class Duration
|
||||
* <p>
|
||||
* The format of the returned string will be {@code PTnHnMnS}, where n is
|
||||
* the relevant hours, minutes or seconds part of the duration.
|
||||
* Any fractional seconds are placed after a decimal point i the seconds section.
|
||||
* Any fractional seconds are placed after a decimal point in the seconds section.
|
||||
* If a section has a zero value, it is omitted.
|
||||
* The hours, minutes and seconds will all have the same sign.
|
||||
* <p>
|
||||
@ -1406,9 +1412,13 @@ public final class Duration
|
||||
if (this == ZERO) {
|
||||
return "PT0S";
|
||||
}
|
||||
long hours = seconds / SECONDS_PER_HOUR;
|
||||
int minutes = (int) ((seconds % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE);
|
||||
int secs = (int) (seconds % SECONDS_PER_MINUTE);
|
||||
long effectiveTotalSecs = seconds;
|
||||
if (seconds < 0 && nanos > 0) {
|
||||
effectiveTotalSecs++;
|
||||
}
|
||||
long hours = effectiveTotalSecs / SECONDS_PER_HOUR;
|
||||
int minutes = (int) ((effectiveTotalSecs % SECONDS_PER_HOUR) / SECONDS_PER_MINUTE);
|
||||
int secs = (int) (effectiveTotalSecs % SECONDS_PER_MINUTE);
|
||||
StringBuilder buf = new StringBuilder(24);
|
||||
buf.append("PT");
|
||||
if (hours != 0) {
|
||||
@ -1420,18 +1430,18 @@ public final class Duration
|
||||
if (secs == 0 && nanos == 0 && buf.length() > 2) {
|
||||
return buf.toString();
|
||||
}
|
||||
if (secs < 0 && nanos > 0) {
|
||||
if (secs == -1) {
|
||||
if (seconds < 0 && nanos > 0) {
|
||||
if (secs == 0) {
|
||||
buf.append("-0");
|
||||
} else {
|
||||
buf.append(secs + 1);
|
||||
buf.append(secs);
|
||||
}
|
||||
} else {
|
||||
buf.append(secs);
|
||||
}
|
||||
if (nanos > 0) {
|
||||
int pos = buf.length();
|
||||
if (secs < 0) {
|
||||
if (seconds < 0) {
|
||||
buf.append(2 * NANOS_PER_SECOND - nanos);
|
||||
} else {
|
||||
buf.append(nanos + NANOS_PER_SECOND);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1369,6 +1369,23 @@ public final class LocalDate
|
||||
if (daysToAdd == 0) {
|
||||
return this;
|
||||
}
|
||||
long dom = day + daysToAdd;
|
||||
if (dom > 0) {
|
||||
if (dom <= 28) {
|
||||
return new LocalDate(year, month, (int) dom);
|
||||
} else if (dom <= 59) { // 59th Jan is 28th Feb, 59th Feb is 31st Mar
|
||||
long monthLen = lengthOfMonth();
|
||||
if (dom <= monthLen) {
|
||||
return new LocalDate(year, month, (int) dom);
|
||||
} else if (month < 12) {
|
||||
return new LocalDate(year, month + 1, (int) (dom - monthLen));
|
||||
} else {
|
||||
YEAR.checkValidValue(year + 1);
|
||||
return new LocalDate(year + 1, 1, (int) (dom - monthLen));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
long mjDay = Math.addExact(toEpochDay(), daysToAdd);
|
||||
return LocalDate.ofEpochDay(mjDay);
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -2085,8 +2085,10 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
|
||||
|
||||
String calendarType = getCalendarType();
|
||||
int fieldValue = get(field);
|
||||
// the standalone and narrow styles are supported only through CalendarDataProviders.
|
||||
if (isStandaloneStyle(style) || isNarrowFormatStyle(style)) {
|
||||
// the standalone/narrow styles and short era are supported only through
|
||||
// CalendarNameProviders.
|
||||
if (isStandaloneStyle(style) || isNarrowFormatStyle(style) ||
|
||||
field == ERA && (style & SHORT) == SHORT) {
|
||||
String val = CalendarDataUtility.retrieveFieldValueName(calendarType,
|
||||
field, fieldValue,
|
||||
style, locale);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -1037,14 +1037,16 @@ class JapaneseImperialCalendar extends Calendar {
|
||||
}
|
||||
if (size < eras.length) {
|
||||
int baseStyle = getBaseStyle(style);
|
||||
for (int i = size; i < eras.length; i++) {
|
||||
Era era = eras[i];
|
||||
if (baseStyle == ALL_STYLES || baseStyle == SHORT
|
||||
|| baseStyle == NARROW_FORMAT) {
|
||||
names.put(era.getAbbreviation(), i);
|
||||
}
|
||||
if (baseStyle == ALL_STYLES || baseStyle == LONG) {
|
||||
names.put(era.getName(), i);
|
||||
for (int i = 0; i < eras.length; i++) {
|
||||
if (!names.values().contains(i)) {
|
||||
Era era = eras[i];
|
||||
if (baseStyle == ALL_STYLES || baseStyle == SHORT
|
||||
|| baseStyle == NARROW_FORMAT) {
|
||||
names.put(era.getAbbreviation(), i);
|
||||
}
|
||||
if (baseStyle == ALL_STYLES || baseStyle == LONG) {
|
||||
names.put(era.getName(), i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3144,6 +3144,18 @@ public final class Locale implements Cloneable, Serializable {
|
||||
&& range.equals(other.range)
|
||||
&& weight == other.weight;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an informative string representation of this {@code LanguageRange}
|
||||
* object, consisting of language range and weight if the range is
|
||||
* weighted and the weight is less than the max weight.
|
||||
*
|
||||
* @return a string representation of this {@code LanguageRange} object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return (weight == MAX_WEIGHT) ? range : range + ";q=" + weight;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -54,6 +54,7 @@ import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
import jdk.internal.misc.JavaUtilZipFileAccess;
|
||||
import jdk.internal.misc.SharedSecrets;
|
||||
import jdk.internal.perf.PerfCounter;
|
||||
|
||||
import static java.util.zip.ZipConstants.*;
|
||||
import static java.util.zip.ZipConstants64.*;
|
||||
@ -210,8 +211,8 @@ class ZipFile implements ZipConstants, Closeable {
|
||||
this.name = name;
|
||||
long t0 = System.nanoTime();
|
||||
this.zsrc = Source.get(file, (mode & OPEN_DELETE) != 0);
|
||||
sun.misc.PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0);
|
||||
sun.misc.PerfCounter.getZipFileCount().increment();
|
||||
PerfCounter.getZipFileOpenTime().addElapsedTimeFrom(t0);
|
||||
PerfCounter.getZipFileCount().increment();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1251,7 +1252,7 @@ class ZipFile implements ZipConstants, Closeable {
|
||||
idx = getEntryNext(idx);
|
||||
}
|
||||
/* If not addSlash, or slash is already there, we are done */
|
||||
if (!addSlash || name[name.length - 1] == '/') {
|
||||
if (!addSlash || name.length == 0 || name[name.length - 1] == '/') {
|
||||
return -1;
|
||||
}
|
||||
/* Add slash and try once more */
|
||||
|
@ -1,80 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
|
||||
/**
|
||||
* Indicates whether or not a JDK specific type or package is an
|
||||
* exported part of the JDK suitable for use outside of the JDK
|
||||
* implementation itself.
|
||||
*
|
||||
* This annotation should only be applied to types and packages
|
||||
* <em>outside</em> of the Java SE namespaces of {@code java.*} and
|
||||
* {@code javax.*} packages. For example, certain portions of {@code
|
||||
* com.sun.*} are official parts of the JDK meant to be generally
|
||||
* usable while other portions of {@code com.sun.*} are not. This
|
||||
* annotation type allows those portions to be easily and
|
||||
* programmatically distinguished.
|
||||
*
|
||||
* <p>If in one release a type or package is
|
||||
* <code>@Exported(true)</code>, in a subsequent major release such a
|
||||
* type or package can transition to <code>@Exported(false)</code>.
|
||||
*
|
||||
* <p>If a type or package is <code>@Exported(false)</code> in a
|
||||
* release, it may be removed in a subsequent major release.
|
||||
*
|
||||
* <p>If a top-level type has an <code>@Exported</code> annotation,
|
||||
* any nested member types with the top-level type should have an
|
||||
* <code>@Exported</code> annotation with the same value.
|
||||
*
|
||||
* (In exceptional cases, if a nested type is going to be removed
|
||||
* before its enclosing type, the nested type's could be
|
||||
* <code>@Exported(false)</code> while its enclosing type was
|
||||
* <code>@Exported(true)</code>.)
|
||||
*
|
||||
* Likewise, if a package has an <code>@Exported</code> annotation,
|
||||
* top-level types within that package should also have an
|
||||
* <code>@Exported</code> annotation.
|
||||
*
|
||||
* Sometimes a top-level type may have a different
|
||||
* <code>@Exported</code> value than its package.
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.TYPE, ElementType.PACKAGE})
|
||||
@Exported
|
||||
public @interface Exported {
|
||||
/**
|
||||
* Whether or not the annotated type or package is an exported
|
||||
* part of the JDK.
|
||||
* @return whether or not the annotated type or package is an exported
|
||||
* part of the JDK
|
||||
*/
|
||||
boolean value() default true;
|
||||
}
|
@ -48,7 +48,7 @@ import java.util.concurrent.ThreadFactory;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import sun.misc.InnocuousThread;
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
import jdk.internal.logger.LazyLoggers.LazyLoggerAccessor;
|
||||
|
||||
|
@ -32,7 +32,7 @@ import java.lang.System.LoggerFinder;
|
||||
import java.lang.System.Logger;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Objects;
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
/**
|
||||
|
@ -1,788 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.internal.misc;
|
||||
|
||||
import java.lang.ref.Cleaner;
|
||||
import java.lang.ref.Cleaner.Cleanable;
|
||||
import java.lang.ref.PhantomReference;
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.function.Function;
|
||||
|
||||
import sun.misc.InnocuousThread;
|
||||
|
||||
/**
|
||||
* CleanerImpl manages a set of object references and corresponding cleaning actions.
|
||||
* CleanerImpl provides the functionality of {@link java.lang.ref.Cleaner}.
|
||||
*/
|
||||
public final class CleanerImpl implements Runnable {
|
||||
|
||||
/**
|
||||
* An object to access the CleanerImpl from a Cleaner; set by Cleaner init.
|
||||
*/
|
||||
private static Function<Cleaner, CleanerImpl> cleanerImplAccess = null;
|
||||
|
||||
/**
|
||||
* Heads of a CleanableList for each reference type.
|
||||
*/
|
||||
final PhantomCleanable<?> phantomCleanableList;
|
||||
|
||||
final WeakCleanable<?> weakCleanableList;
|
||||
|
||||
final SoftCleanable<?> softCleanableList;
|
||||
|
||||
// The ReferenceQueue of pending cleaning actions
|
||||
final ReferenceQueue<Object> queue;
|
||||
|
||||
/**
|
||||
* Called by Cleaner static initialization to provide the function
|
||||
* to map from Cleaner to CleanerImpl.
|
||||
* @param access a function to map from Cleaner to CleanerImpl
|
||||
*/
|
||||
public static void setCleanerImplAccess(Function<Cleaner, CleanerImpl> access) {
|
||||
if (cleanerImplAccess == null) {
|
||||
cleanerImplAccess = access;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to get the CleanerImpl for a Cleaner.
|
||||
* @param cleaner the cleaner
|
||||
* @return the corresponding CleanerImpl
|
||||
*/
|
||||
private static CleanerImpl getCleanerImpl(Cleaner cleaner) {
|
||||
return cleanerImplAccess.apply(cleaner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for CleanerImpl.
|
||||
*/
|
||||
public CleanerImpl() {
|
||||
queue = new ReferenceQueue<>();
|
||||
phantomCleanableList = new PhantomCleanableRef(this);
|
||||
weakCleanableList = new WeakCleanableRef(this);
|
||||
softCleanableList = new SoftCleanableRef(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Cleaner implementation.
|
||||
* When started waits for Cleanables to be queued.
|
||||
* @param service the cleaner
|
||||
* @param threadFactory the thread factory
|
||||
*/
|
||||
public void start(Cleaner service, ThreadFactory threadFactory) {
|
||||
// schedule a nop cleaning action for the service, so the associated thread
|
||||
// will continue to run at least until the service is reclaimable.
|
||||
new PhantomCleanableRef(service, service, () -> {});
|
||||
|
||||
if (threadFactory == null) {
|
||||
threadFactory = CleanerImpl.InnocuousThreadFactory.factory();
|
||||
}
|
||||
|
||||
// now that there's at least one cleaning action, for the service,
|
||||
// we can start the associated thread, which runs until
|
||||
// all cleaning actions have been run.
|
||||
Thread thread = threadFactory.newThread(this);
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process queued Cleanables as long as the cleanable lists are not empty.
|
||||
* A Cleanable is in one of the lists for each Object and for the Cleaner
|
||||
* itself.
|
||||
* Terminates when the Cleaner is no longer reachable and
|
||||
* has been cleaned and there are no more Cleanable instances
|
||||
* for which the object is reachable.
|
||||
* <p>
|
||||
* If the thread is a ManagedLocalsThread, the threadlocals
|
||||
* are erased before each cleanup
|
||||
*/
|
||||
public void run() {
|
||||
Thread t = Thread.currentThread();
|
||||
InnocuousThread mlThread = (t instanceof InnocuousThread)
|
||||
? (InnocuousThread) t
|
||||
: null;
|
||||
while (!phantomCleanableList.isListEmpty() ||
|
||||
!weakCleanableList.isListEmpty() ||
|
||||
!softCleanableList.isListEmpty()) {
|
||||
if (mlThread != null) {
|
||||
// Clear the thread locals
|
||||
mlThread.eraseThreadLocals();
|
||||
}
|
||||
try {
|
||||
// Wait for a Ref, with a timeout to avoid getting hung
|
||||
// due to a race with clear/clean
|
||||
Cleanable ref = (Cleanable) queue.remove(60 * 1000L);
|
||||
if (ref != null) {
|
||||
ref.clean();
|
||||
}
|
||||
} catch (InterruptedException i) {
|
||||
continue; // ignore the interruption
|
||||
} catch (Throwable e) {
|
||||
// ignore exceptions from the cleanup action
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* PhantomCleanable subclasses efficiently encapsulate cleanup state and
|
||||
* the cleaning action.
|
||||
* Subclasses implement the abstract {@link #performCleanup()} method
|
||||
* to provide the cleaning action.
|
||||
* When constructed, the object reference and the {@link Cleanable Cleanable}
|
||||
* are registered with the {@link Cleaner}.
|
||||
* The Cleaner invokes {@link Cleaner.Cleanable#clean() clean} after the
|
||||
* referent becomes phantom reachable.
|
||||
*/
|
||||
public static abstract class PhantomCleanable<T> extends PhantomReference<T>
|
||||
implements Cleaner.Cleanable {
|
||||
|
||||
/**
|
||||
* Links to previous and next in a doubly-linked list.
|
||||
*/
|
||||
PhantomCleanable<?> prev = this, next = this;
|
||||
|
||||
/**
|
||||
* The CleanerImpl for this Cleanable.
|
||||
*/
|
||||
private final CleanerImpl cleanerImpl;
|
||||
|
||||
/**
|
||||
* Constructs new {@code PhantomCleanable} with
|
||||
* {@code non-null referent} and {@code non-null cleaner}.
|
||||
* The {@code cleaner} is not retained; it is only used to
|
||||
* register the newly constructed {@link Cleaner.Cleanable Cleanable}.
|
||||
*
|
||||
* @param referent the referent to track
|
||||
* @param cleaner the {@code Cleaner} to register with
|
||||
*/
|
||||
public PhantomCleanable(T referent, Cleaner cleaner) {
|
||||
super(Objects.requireNonNull(referent), getCleanerImpl(cleaner).queue);
|
||||
this.cleanerImpl = getCleanerImpl(cleaner);
|
||||
insert();
|
||||
|
||||
// TODO: Replace getClass() with ReachabilityFence when it is available
|
||||
cleaner.getClass();
|
||||
referent.getClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new root of the list; not inserted.
|
||||
*/
|
||||
PhantomCleanable(CleanerImpl cleanerImpl) {
|
||||
super(null, null);
|
||||
this.cleanerImpl = cleanerImpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert this PhantomCleanable after the list head.
|
||||
*/
|
||||
private void insert() {
|
||||
final PhantomCleanable<?> list = cleanerImpl.phantomCleanableList;
|
||||
synchronized (list) {
|
||||
prev = list;
|
||||
next = list.next;
|
||||
next.prev = this;
|
||||
list.next = this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this PhantomCleanable from the list.
|
||||
*
|
||||
* @return true if Cleanable was removed or false if not because
|
||||
* it had already been removed before
|
||||
*/
|
||||
private boolean remove() {
|
||||
PhantomCleanable<?> list = cleanerImpl.phantomCleanableList;
|
||||
synchronized (list) {
|
||||
if (next != this) {
|
||||
next.prev = prev;
|
||||
prev.next = next;
|
||||
prev = this;
|
||||
next = this;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the list's next reference refers to itself.
|
||||
*
|
||||
* @return true if the list is empty
|
||||
*/
|
||||
boolean isListEmpty() {
|
||||
PhantomCleanable<?> list = cleanerImpl.phantomCleanableList;
|
||||
synchronized (list) {
|
||||
return list == list.next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this PhantomCleanable and invoke {@link #performCleanup()},
|
||||
* ensuring at-most-once semantics.
|
||||
*/
|
||||
@Override
|
||||
public final void clean() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
performCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this PhantomCleanable and clear the reference.
|
||||
* Due to inherent concurrency, {@link #performCleanup()} may still be invoked.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@code performCleanup} abstract method is overridden
|
||||
* to implement the cleaning logic.
|
||||
* The {@code performCleanup} method should not be called except
|
||||
* by the {@link #clean} method which ensures at most once semantics.
|
||||
*/
|
||||
protected abstract void performCleanup();
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean isEnqueued() {
|
||||
throw new UnsupportedOperationException("isEnqueued");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean enqueue() {
|
||||
throw new UnsupportedOperationException("enqueue");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* WeakCleanable subclasses efficiently encapsulate cleanup state and
|
||||
* the cleaning action.
|
||||
* Subclasses implement the abstract {@link #performCleanup()} method
|
||||
* to provide the cleaning action.
|
||||
* When constructed, the object reference and the {@link Cleanable Cleanable}
|
||||
* are registered with the {@link Cleaner}.
|
||||
* The Cleaner invokes {@link Cleaner.Cleanable#clean() clean} after the
|
||||
* referent becomes weakly reachable.
|
||||
*/
|
||||
public static abstract class WeakCleanable<T> extends WeakReference<T>
|
||||
implements Cleaner.Cleanable {
|
||||
|
||||
/**
|
||||
* Links to previous and next in a doubly-linked list.
|
||||
*/
|
||||
WeakCleanable<?> prev = this, next = this;
|
||||
|
||||
/**
|
||||
* The CleanerImpl for this Cleanable.
|
||||
*/
|
||||
private final CleanerImpl cleanerImpl;
|
||||
|
||||
/**
|
||||
* Constructs new {@code WeakCleanableReference} with
|
||||
* {@code non-null referent} and {@code non-null cleaner}.
|
||||
* The {@code cleaner} is not retained by this reference; it is only used
|
||||
* to register the newly constructed {@link Cleaner.Cleanable Cleanable}.
|
||||
*
|
||||
* @param referent the referent to track
|
||||
* @param cleaner the {@code Cleaner} to register new reference with
|
||||
*/
|
||||
public WeakCleanable(T referent, Cleaner cleaner) {
|
||||
super(Objects.requireNonNull(referent), getCleanerImpl(cleaner).queue);
|
||||
cleanerImpl = getCleanerImpl(cleaner);
|
||||
insert();
|
||||
|
||||
// TODO: Replace getClass() with ReachabilityFence when it is available
|
||||
cleaner.getClass();
|
||||
referent.getClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new root of the list; not inserted.
|
||||
*/
|
||||
WeakCleanable(CleanerImpl cleanerImpl) {
|
||||
super(null, null);
|
||||
this.cleanerImpl = cleanerImpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert this WeakCleanableReference after the list head.
|
||||
*/
|
||||
private void insert() {
|
||||
final WeakCleanable<?> list = cleanerImpl.weakCleanableList;
|
||||
synchronized (list) {
|
||||
prev = list;
|
||||
next = list.next;
|
||||
next.prev = this;
|
||||
list.next = this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this WeakCleanableReference from the list.
|
||||
*
|
||||
* @return true if Cleanable was removed or false if not because
|
||||
* it had already been removed before
|
||||
*/
|
||||
private boolean remove() {
|
||||
WeakCleanable<?> list = cleanerImpl.weakCleanableList;
|
||||
synchronized (list) {
|
||||
if (next != this) {
|
||||
next.prev = prev;
|
||||
prev.next = next;
|
||||
prev = this;
|
||||
next = this;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the list's next reference refers to itself.
|
||||
*
|
||||
* @return true if the list is empty
|
||||
*/
|
||||
boolean isListEmpty() {
|
||||
WeakCleanable<?> list = cleanerImpl.weakCleanableList;
|
||||
synchronized (list) {
|
||||
return list == list.next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this WeakCleanable reference and invoke {@link #performCleanup()},
|
||||
* ensuring at-most-once semantics.
|
||||
*/
|
||||
@Override
|
||||
public final void clean() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
performCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this WeakCleanable and clear the reference.
|
||||
* Due to inherent concurrency, {@link #performCleanup()} may still be invoked.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@code performCleanup} abstract method is overridden
|
||||
* to implement the cleaning logic.
|
||||
* The {@code performCleanup} method should not be called except
|
||||
* by the {@link #clean} method which ensures at most once semantics.
|
||||
*/
|
||||
protected abstract void performCleanup();
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link java.lang.ref.Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean isEnqueued() {
|
||||
throw new UnsupportedOperationException("isEnqueued");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link java.lang.ref.Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean enqueue() {
|
||||
throw new UnsupportedOperationException("enqueue");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* SoftCleanable subclasses efficiently encapsulate cleanup state and
|
||||
* the cleaning action.
|
||||
* Subclasses implement the abstract {@link #performCleanup()} method
|
||||
* to provide the cleaning action.
|
||||
* When constructed, the object reference and the {@link Cleanable Cleanable}
|
||||
* are registered with the {@link Cleaner}.
|
||||
* The Cleaner invokes {@link Cleaner.Cleanable#clean() clean} after the
|
||||
* referent becomes softly reachable.
|
||||
*/
|
||||
public static abstract class SoftCleanable<T> extends SoftReference<T>
|
||||
implements Cleaner.Cleanable {
|
||||
|
||||
/**
|
||||
* Links to previous and next in a doubly-linked list.
|
||||
*/
|
||||
SoftCleanable<?> prev = this, next = this;
|
||||
|
||||
/**
|
||||
* The CleanerImpl for this Cleanable.
|
||||
*/
|
||||
private final CleanerImpl cleanerImpl;
|
||||
|
||||
/**
|
||||
* Constructs new {@code SoftCleanableReference} with
|
||||
* {@code non-null referent} and {@code non-null cleaner}.
|
||||
* The {@code cleaner} is not retained by this reference; it is only used
|
||||
* to register the newly constructed {@link Cleaner.Cleanable Cleanable}.
|
||||
*
|
||||
* @param referent the referent to track
|
||||
* @param cleaner the {@code Cleaner} to register with
|
||||
*/
|
||||
public SoftCleanable(T referent, Cleaner cleaner) {
|
||||
super(Objects.requireNonNull(referent), getCleanerImpl(cleaner).queue);
|
||||
cleanerImpl = getCleanerImpl(cleaner);
|
||||
insert();
|
||||
|
||||
// TODO: Replace getClass() with ReachabilityFence when it is available
|
||||
cleaner.getClass();
|
||||
referent.getClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new root of the list; not inserted.
|
||||
*/
|
||||
SoftCleanable(CleanerImpl cleanerImpl) {
|
||||
super(null, null);
|
||||
this.cleanerImpl = cleanerImpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert this SoftCleanableReference after the list head.
|
||||
*/
|
||||
private void insert() {
|
||||
final SoftCleanable<?> list = cleanerImpl.softCleanableList;
|
||||
synchronized (list) {
|
||||
prev = list;
|
||||
next = list.next;
|
||||
next.prev = this;
|
||||
list.next = this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this SoftCleanableReference from the list.
|
||||
*
|
||||
* @return true if Cleanable was removed or false if not because
|
||||
* it had already been removed before
|
||||
*/
|
||||
private boolean remove() {
|
||||
SoftCleanable<?> list = cleanerImpl.softCleanableList;
|
||||
synchronized (list) {
|
||||
if (next != this) {
|
||||
next.prev = prev;
|
||||
prev.next = next;
|
||||
prev = this;
|
||||
next = this;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the list's next reference refers to itself.
|
||||
*
|
||||
* @return true if the list is empty
|
||||
*/
|
||||
boolean isListEmpty() {
|
||||
SoftCleanable<?> list = cleanerImpl.softCleanableList;
|
||||
synchronized (list) {
|
||||
return list == list.next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this SoftCleanable reference and invoke {@link #performCleanup()},
|
||||
* ensuring at-most-once semantics.
|
||||
*/
|
||||
@Override
|
||||
public final void clean() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
performCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this SoftCleanable and clear the reference.
|
||||
* Due to inherent concurrency, {@link #performCleanup()} may still be invoked.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@code performCleanup} abstract method is overridden
|
||||
* to implement the cleaning logic.
|
||||
* The {@code performCleanup} method should not be called except
|
||||
* by the {@link #clean} method which ensures at most once semantics.
|
||||
*/
|
||||
protected abstract void performCleanup();
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean isEnqueued() {
|
||||
throw new UnsupportedOperationException("isEnqueued");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean enqueue() {
|
||||
throw new UnsupportedOperationException("enqueue");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform cleaning on an unreachable PhantomReference.
|
||||
*/
|
||||
public static final class PhantomCleanableRef extends PhantomCleanable<Object> {
|
||||
private final Runnable action;
|
||||
|
||||
/**
|
||||
* Constructor for a phantom cleanable reference.
|
||||
* @param obj the object to monitor
|
||||
* @param cleaner the cleaner
|
||||
* @param action the action Runnable
|
||||
*/
|
||||
public PhantomCleanableRef(Object obj, Cleaner cleaner, Runnable action) {
|
||||
super(obj, cleaner);
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used only for root of phantom cleanable list.
|
||||
* @param cleanerImpl the cleanerImpl
|
||||
*/
|
||||
PhantomCleanableRef(CleanerImpl cleanerImpl) {
|
||||
super(cleanerImpl);
|
||||
this.action = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performCleanup() {
|
||||
action.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent access to referent even when it is still alive.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public Object get() {
|
||||
throw new UnsupportedOperationException("get");
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct clearing of the referent is not supported.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("clear");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform cleaning on an unreachable WeakReference.
|
||||
*/
|
||||
public static final class WeakCleanableRef extends WeakCleanable<Object> {
|
||||
private final Runnable action;
|
||||
|
||||
/**
|
||||
* Constructor for a weak cleanable reference.
|
||||
* @param obj the object to monitor
|
||||
* @param cleaner the cleaner
|
||||
* @param action the action Runnable
|
||||
*/
|
||||
WeakCleanableRef(Object obj, Cleaner cleaner, Runnable action) {
|
||||
super(obj, cleaner);
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used only for root of weak cleanable list.
|
||||
* @param cleanerImpl the cleanerImpl
|
||||
*/
|
||||
WeakCleanableRef(CleanerImpl cleanerImpl) {
|
||||
super(cleanerImpl);
|
||||
this.action = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performCleanup() {
|
||||
action.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent access to referent even when it is still alive.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public Object get() {
|
||||
throw new UnsupportedOperationException("get");
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct clearing of the referent is not supported.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("clear");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform cleaning on an unreachable SoftReference.
|
||||
*/
|
||||
public static final class SoftCleanableRef extends SoftCleanable<Object> {
|
||||
private final Runnable action;
|
||||
|
||||
/**
|
||||
* Constructor for a soft cleanable reference.
|
||||
* @param obj the object to monitor
|
||||
* @param cleaner the cleaner
|
||||
* @param action the action Runnable
|
||||
*/
|
||||
SoftCleanableRef(Object obj, Cleaner cleaner, Runnable action) {
|
||||
super(obj, cleaner);
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used only for root of soft cleanable list.
|
||||
* @param cleanerImpl the cleanerImpl
|
||||
*/
|
||||
SoftCleanableRef(CleanerImpl cleanerImpl) {
|
||||
super(cleanerImpl);
|
||||
this.action = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performCleanup() {
|
||||
action.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent access to referent even when it is still alive.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public Object get() {
|
||||
throw new UnsupportedOperationException("get");
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct clearing of the referent is not supported.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("clear");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A ThreadFactory for InnocuousThreads.
|
||||
* The factory is a singleton.
|
||||
*/
|
||||
static final class InnocuousThreadFactory implements ThreadFactory {
|
||||
final static ThreadFactory factory = new InnocuousThreadFactory();
|
||||
|
||||
static ThreadFactory factory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public Thread newThread(Runnable r) {
|
||||
return AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
|
||||
Thread t = new InnocuousThread(r);
|
||||
t.setPriority(Thread.MAX_PRIORITY - 2);
|
||||
t.setName("Cleaner-" + t.getId());
|
||||
return t;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -30,7 +30,7 @@ import java.security.ProtectionDomain;
|
||||
|
||||
import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.Reflection;
|
||||
import sun.misc.VM;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
import static java.lang.Thread.State.*;
|
||||
import java.util.Properties;
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.misc;
|
||||
|
||||
/** @deprecated */
|
||||
@Deprecated
|
@ -22,13 +22,14 @@
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.misc;
|
||||
package jdk.internal.perf;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.Permission;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import jdk.internal.ref.CleanerFactory;
|
||||
|
||||
/**
|
||||
* The Perf class provides the ability to attach to an instrumentation
|
||||
@ -46,7 +47,7 @@ import java.io.UnsupportedEncodingException;
|
||||
* @author Brian Doherty
|
||||
* @since 1.4.2
|
||||
* @see #getPerf
|
||||
* @see sun.misc.Perf$GetPerfAction
|
||||
* @see jdk.internal.perf.Perf.GetPerfAction
|
||||
* @see java.nio.ByteBuffer
|
||||
*/
|
||||
public final class Perf {
|
||||
@ -123,10 +124,10 @@ public final class Perf {
|
||||
* Please note that the <em>"sun.misc.Perf.getPerf"</em> permission
|
||||
* is not a JDK specified permission.
|
||||
*
|
||||
* @return A reference to the singleton Perf instance.
|
||||
* @throws AccessControlException if a security manager exists and
|
||||
* its <code>checkPermission</code> method doesn't allow
|
||||
* access to the <em>"sun.misc.Perf.getPerf"</em> target.
|
||||
* @return A reference to the singleton Perf instance.
|
||||
* @throws SecurityException if a security manager exists and its
|
||||
* <code>checkPermission</code> method doesn't allow access
|
||||
* to the <em>"jdk.internal.perf.Perf.getPerf""</em> target.
|
||||
* @see java.lang.RuntimePermission
|
||||
* @see #attach
|
||||
*/
|
||||
@ -134,7 +135,7 @@ public final class Perf {
|
||||
{
|
||||
SecurityManager security = System.getSecurityManager();
|
||||
if (security != null) {
|
||||
Permission perm = new RuntimePermission("sun.misc.Perf.getPerf");
|
||||
Permission perm = new RuntimePermission("jdk.internal.perf.Perf.getPerf");
|
||||
security.checkPermission(perm);
|
||||
}
|
||||
|
||||
@ -277,27 +278,35 @@ public final class Perf {
|
||||
// This is an instrumentation buffer for another Java virtual
|
||||
// machine with native resources that need to be managed. We
|
||||
// create a duplicate of the native ByteBuffer and manage it
|
||||
// with a Cleaner object (PhantomReference). When the duplicate
|
||||
// becomes only phantomly reachable, the native resources will
|
||||
// be released.
|
||||
// with a Cleaner. When the duplicate becomes phantom reachable,
|
||||
// the native resources will be released.
|
||||
|
||||
final ByteBuffer dup = b.duplicate();
|
||||
Cleaner.create(dup, new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
instance.detach(b);
|
||||
}
|
||||
catch (Throwable th) {
|
||||
// avoid crashing the reference handler thread,
|
||||
// but provide for some diagnosability
|
||||
assert false : th.toString();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
CleanerFactory.cleaner()
|
||||
.register(dup, new CleanerAction(instance, b));
|
||||
return dup;
|
||||
}
|
||||
}
|
||||
|
||||
private static class CleanerAction implements Runnable {
|
||||
private final ByteBuffer bb;
|
||||
private final Perf perf;
|
||||
CleanerAction(Perf perf, ByteBuffer bb) {
|
||||
this.perf = perf;
|
||||
this.bb = bb;
|
||||
}
|
||||
public void run() {
|
||||
try {
|
||||
perf.detach(bb);
|
||||
} catch (Throwable th) {
|
||||
// avoid crashing the reference handler thread,
|
||||
// but provide for some diagnosability
|
||||
assert false : th.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Native method to perform the implementation specific attach mechanism.
|
||||
* <p>
|
||||
@ -341,7 +350,7 @@ public final class Perf {
|
||||
* machine running this method (lvmid=0, for example), then the detach
|
||||
* request is silently ignored.
|
||||
*
|
||||
* @param ByteBuffer A direct allocated byte buffer created by the
|
||||
* @param bb A direct allocated byte buffer created by the
|
||||
* <code>attach</code> method.
|
||||
* @see java.nio.ByteBuffer
|
||||
* @see #attach
|
@ -23,7 +23,7 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
package jdk.internal.perf;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -23,16 +23,26 @@
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.internal.dynalink.beans.test;
|
||||
package jdk.internal.ref;
|
||||
|
||||
import jdk.dynalink.beans.BeansLinker;
|
||||
import jdk.nashorn.test.models.ClassLoaderAware;
|
||||
import org.testng.annotations.Test;
|
||||
import java.lang.ref.Cleaner;
|
||||
|
||||
@SuppressWarnings("javadoc")
|
||||
public class CallerSensitiveTest {
|
||||
@Test
|
||||
public void testCallerSensitive() {
|
||||
BeansLinker.getLinkerForClass(ClassLoaderAware.class);
|
||||
/**
|
||||
* CleanerFactory provides a Cleaner for use within OpenJDK modules.
|
||||
* The cleaner is created on the first reference to the CleanerFactory.
|
||||
*/
|
||||
public final class CleanerFactory {
|
||||
|
||||
/* The common Cleaner. */
|
||||
private final static Cleaner commonCleaner = Cleaner.create();
|
||||
|
||||
/**
|
||||
* Cleaner for use within OpenJDK modules.
|
||||
*
|
||||
* @return a Cleaner for use within OpenJDK modules
|
||||
*/
|
||||
public static Cleaner cleaner() {
|
||||
return commonCleaner;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,333 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.internal.ref;
|
||||
|
||||
import java.lang.ref.Cleaner;
|
||||
import java.lang.ref.Cleaner.Cleanable;
|
||||
import java.lang.ref.ReferenceQueue;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
import java.util.function.Function;
|
||||
|
||||
import sun.misc.InnocuousThread;
|
||||
|
||||
/**
|
||||
* CleanerImpl manages a set of object references and corresponding cleaning actions.
|
||||
* CleanerImpl provides the functionality of {@link java.lang.ref.Cleaner}.
|
||||
*/
|
||||
public final class CleanerImpl {
|
||||
|
||||
/**
|
||||
* An object to access the CleanerImpl from a Cleaner; set by Cleaner init.
|
||||
*/
|
||||
private static Function<Cleaner, CleanerImpl> cleanerImplAccess = null;
|
||||
|
||||
/**
|
||||
* Heads of a CleanableList for each reference type.
|
||||
*/
|
||||
final PhantomCleanable<?> phantomCleanableList;
|
||||
|
||||
final WeakCleanable<?> weakCleanableList;
|
||||
|
||||
final SoftCleanable<?> softCleanableList;
|
||||
|
||||
// The ReferenceQueue of pending cleaning actions
|
||||
final ReferenceQueue<Object> queue;
|
||||
|
||||
/**
|
||||
* Called by Cleaner static initialization to provide the function
|
||||
* to map from Cleaner to CleanerImpl.
|
||||
* @param access a function to map from Cleaner to CleanerImpl
|
||||
*/
|
||||
public static void setCleanerImplAccess(Function<Cleaner, CleanerImpl> access) {
|
||||
if (cleanerImplAccess == null) {
|
||||
cleanerImplAccess = access;
|
||||
} else {
|
||||
throw new InternalError("cleanerImplAccess");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to get the CleanerImpl for a Cleaner.
|
||||
* @param cleaner the cleaner
|
||||
* @return the corresponding CleanerImpl
|
||||
*/
|
||||
static CleanerImpl getCleanerImpl(Cleaner cleaner) {
|
||||
return cleanerImplAccess.apply(cleaner);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor for CleanerImpl.
|
||||
*/
|
||||
public CleanerImpl() {
|
||||
queue = new ReferenceQueue<>();
|
||||
phantomCleanableList = new PhantomCleanableRef();
|
||||
weakCleanableList = new WeakCleanableRef();
|
||||
softCleanableList = new SoftCleanableRef();
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the Cleaner implementation.
|
||||
* Ensure this is the CleanerImpl for the Cleaner.
|
||||
* When started waits for Cleanables to be queued.
|
||||
* @param cleaner the cleaner
|
||||
* @param threadFactory the thread factory
|
||||
*/
|
||||
public void start(Cleaner cleaner, ThreadFactory threadFactory) {
|
||||
if (getCleanerImpl(cleaner) != this) {
|
||||
throw new AssertionError("wrong cleaner");
|
||||
}
|
||||
// schedule a nop cleaning action for the cleaner, so the associated thread
|
||||
// will continue to run at least until the cleaner is reclaimable.
|
||||
new PhantomCleanableRef(cleaner, cleaner, () -> {});
|
||||
|
||||
if (threadFactory == null) {
|
||||
threadFactory = CleanerImpl.InnocuousThreadFactory.factory();
|
||||
}
|
||||
|
||||
// now that there's at least one cleaning action, for the cleaner,
|
||||
// we can start the associated thread, which runs until
|
||||
// all cleaning actions have been run.
|
||||
Thread thread = threadFactory.newThread(this::run);
|
||||
thread.setDaemon(true);
|
||||
thread.start();
|
||||
}
|
||||
|
||||
/**
|
||||
* Process queued Cleanables as long as the cleanable lists are not empty.
|
||||
* A Cleanable is in one of the lists for each Object and for the Cleaner
|
||||
* itself.
|
||||
* Terminates when the Cleaner is no longer reachable and
|
||||
* has been cleaned and there are no more Cleanable instances
|
||||
* for which the object is reachable.
|
||||
* <p>
|
||||
* If the thread is a ManagedLocalsThread, the threadlocals
|
||||
* are erased before each cleanup
|
||||
*/
|
||||
private void run() {
|
||||
Thread t = Thread.currentThread();
|
||||
InnocuousThread mlThread = (t instanceof InnocuousThread)
|
||||
? (InnocuousThread) t
|
||||
: null;
|
||||
while (!phantomCleanableList.isListEmpty() ||
|
||||
!weakCleanableList.isListEmpty() ||
|
||||
!softCleanableList.isListEmpty()) {
|
||||
if (mlThread != null) {
|
||||
// Clear the thread locals
|
||||
mlThread.eraseThreadLocals();
|
||||
}
|
||||
try {
|
||||
// Wait for a Ref, with a timeout to avoid getting hung
|
||||
// due to a race with clear/clean
|
||||
Cleanable ref = (Cleanable) queue.remove(60 * 1000L);
|
||||
if (ref != null) {
|
||||
ref.clean();
|
||||
}
|
||||
} catch (InterruptedException i) {
|
||||
continue; // ignore the interruption
|
||||
} catch (Throwable e) {
|
||||
// ignore exceptions from the cleanup action
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform cleaning on an unreachable PhantomReference.
|
||||
*/
|
||||
public static final class PhantomCleanableRef extends PhantomCleanable<Object> {
|
||||
private final Runnable action;
|
||||
|
||||
/**
|
||||
* Constructor for a phantom cleanable reference.
|
||||
* @param obj the object to monitor
|
||||
* @param cleaner the cleaner
|
||||
* @param action the action Runnable
|
||||
*/
|
||||
public PhantomCleanableRef(Object obj, Cleaner cleaner, Runnable action) {
|
||||
super(obj, cleaner);
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used only for root of phantom cleanable list.
|
||||
*/
|
||||
PhantomCleanableRef() {
|
||||
super();
|
||||
this.action = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performCleanup() {
|
||||
action.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent access to referent even when it is still alive.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public Object get() {
|
||||
throw new UnsupportedOperationException("get");
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct clearing of the referent is not supported.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("clear");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform cleaning on an unreachable WeakReference.
|
||||
*/
|
||||
public static final class WeakCleanableRef extends WeakCleanable<Object> {
|
||||
private final Runnable action;
|
||||
|
||||
/**
|
||||
* Constructor for a weak cleanable reference.
|
||||
* @param obj the object to monitor
|
||||
* @param cleaner the cleaner
|
||||
* @param action the action Runnable
|
||||
*/
|
||||
WeakCleanableRef(Object obj, Cleaner cleaner, Runnable action) {
|
||||
super(obj, cleaner);
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used only for root of weak cleanable list.
|
||||
*/
|
||||
WeakCleanableRef() {
|
||||
super();
|
||||
this.action = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performCleanup() {
|
||||
action.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent access to referent even when it is still alive.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public Object get() {
|
||||
throw new UnsupportedOperationException("get");
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct clearing of the referent is not supported.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("clear");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform cleaning on an unreachable SoftReference.
|
||||
*/
|
||||
public static final class SoftCleanableRef extends SoftCleanable<Object> {
|
||||
private final Runnable action;
|
||||
|
||||
/**
|
||||
* Constructor for a soft cleanable reference.
|
||||
* @param obj the object to monitor
|
||||
* @param cleaner the cleaner
|
||||
* @param action the action Runnable
|
||||
*/
|
||||
SoftCleanableRef(Object obj, Cleaner cleaner, Runnable action) {
|
||||
super(obj, cleaner);
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor used only for root of soft cleanable list.
|
||||
*/
|
||||
SoftCleanableRef() {
|
||||
super();
|
||||
this.action = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void performCleanup() {
|
||||
action.run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Prevent access to referent even when it is still alive.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public Object get() {
|
||||
throw new UnsupportedOperationException("get");
|
||||
}
|
||||
|
||||
/**
|
||||
* Direct clearing of the referent is not supported.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("clear");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* A ThreadFactory for InnocuousThreads.
|
||||
* The factory is a singleton.
|
||||
*/
|
||||
static final class InnocuousThreadFactory implements ThreadFactory {
|
||||
final static ThreadFactory factory = new InnocuousThreadFactory();
|
||||
|
||||
static ThreadFactory factory() {
|
||||
return factory;
|
||||
}
|
||||
|
||||
public Thread newThread(Runnable r) {
|
||||
return AccessController.doPrivileged((PrivilegedAction<Thread>) () -> {
|
||||
Thread t = new InnocuousThread(r);
|
||||
t.setPriority(Thread.MAX_PRIORITY - 2);
|
||||
t.setName("Cleaner-" + t.getId());
|
||||
return t;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.internal.ref;
|
||||
|
||||
import java.lang.ref.Cleaner;
|
||||
import java.lang.ref.PhantomReference;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* PhantomCleanable subclasses efficiently encapsulate cleanup state and
|
||||
* the cleaning action.
|
||||
* Subclasses implement the abstract {@link #performCleanup()} method
|
||||
* to provide the cleaning action.
|
||||
* When constructed, the object reference and the {@link Cleaner.Cleanable Cleanable}
|
||||
* are registered with the {@link Cleaner}.
|
||||
* The Cleaner invokes {@link Cleaner.Cleanable#clean() clean} after the
|
||||
* referent becomes phantom reachable.
|
||||
*/
|
||||
public abstract class PhantomCleanable<T> extends PhantomReference<T>
|
||||
implements Cleaner.Cleanable {
|
||||
|
||||
/**
|
||||
* Links to previous and next in a doubly-linked list.
|
||||
*/
|
||||
PhantomCleanable<?> prev = this, next = this;
|
||||
|
||||
/**
|
||||
* The list of PhantomCleanable; synchronizes insert and remove.
|
||||
*/
|
||||
private final PhantomCleanable<?> list;
|
||||
|
||||
/**
|
||||
* Constructs new {@code PhantomCleanable} with
|
||||
* {@code non-null referent} and {@code non-null cleaner}.
|
||||
* The {@code cleaner} is not retained; it is only used to
|
||||
* register the newly constructed {@link Cleaner.Cleanable Cleanable}.
|
||||
*
|
||||
* @param referent the referent to track
|
||||
* @param cleaner the {@code Cleaner} to register with
|
||||
*/
|
||||
public PhantomCleanable(T referent, Cleaner cleaner) {
|
||||
super(Objects.requireNonNull(referent), CleanerImpl.getCleanerImpl(cleaner).queue);
|
||||
this.list = CleanerImpl.getCleanerImpl(cleaner).phantomCleanableList;
|
||||
insert();
|
||||
|
||||
// TODO: Replace getClass() with ReachabilityFence when it is available
|
||||
cleaner.getClass();
|
||||
referent.getClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new root of the list; not inserted.
|
||||
*/
|
||||
PhantomCleanable() {
|
||||
super(null, null);
|
||||
this.list = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert this PhantomCleanable after the list head.
|
||||
*/
|
||||
private void insert() {
|
||||
synchronized (list) {
|
||||
prev = list;
|
||||
next = list.next;
|
||||
next.prev = this;
|
||||
list.next = this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this PhantomCleanable from the list.
|
||||
*
|
||||
* @return true if Cleanable was removed or false if not because
|
||||
* it had already been removed before
|
||||
*/
|
||||
private boolean remove() {
|
||||
synchronized (list) {
|
||||
if (next != this) {
|
||||
next.prev = prev;
|
||||
prev.next = next;
|
||||
prev = this;
|
||||
next = this;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the list's next reference refers to itself.
|
||||
*
|
||||
* @return true if the list is empty
|
||||
*/
|
||||
boolean isListEmpty() {
|
||||
synchronized (list) {
|
||||
return list == list.next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this PhantomCleanable and invoke {@link #performCleanup()},
|
||||
* ensuring at-most-once semantics.
|
||||
*/
|
||||
@Override
|
||||
public final void clean() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
performCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this PhantomCleanable and clear the reference.
|
||||
* Due to inherent concurrency, {@link #performCleanup()} may still be invoked.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@code performCleanup} abstract method is overridden
|
||||
* to implement the cleaning logic.
|
||||
* The {@code performCleanup} method should not be called except
|
||||
* by the {@link #clean} method which ensures at most once semantics.
|
||||
*/
|
||||
protected abstract void performCleanup();
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean isEnqueued() {
|
||||
throw new UnsupportedOperationException("isEnqueued");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean enqueue() {
|
||||
throw new UnsupportedOperationException("enqueue");
|
||||
}
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package jdk.internal.ref;
|
||||
|
||||
import java.lang.ref.Cleaner;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* SoftCleanable subclasses efficiently encapsulate cleanup state and
|
||||
* the cleaning action.
|
||||
* Subclasses implement the abstract {@link #performCleanup()} method
|
||||
* to provide the cleaning action.
|
||||
* When constructed, the object reference and the {@link Cleaner.Cleanable Cleanable}
|
||||
* are registered with the {@link Cleaner}.
|
||||
* The Cleaner invokes {@link Cleaner.Cleanable#clean() clean} after the
|
||||
* referent becomes softly reachable.
|
||||
*/
|
||||
public abstract class SoftCleanable<T> extends SoftReference<T>
|
||||
implements Cleaner.Cleanable {
|
||||
|
||||
/**
|
||||
* Links to previous and next in a doubly-linked list.
|
||||
*/
|
||||
SoftCleanable<?> prev = this, next = this;
|
||||
|
||||
/**
|
||||
* The list of SoftCleanable; synchronizes insert and remove.
|
||||
*/
|
||||
private final SoftCleanable<?> list;
|
||||
|
||||
/**
|
||||
* Constructs new {@code SoftCleanableReference} with
|
||||
* {@code non-null referent} and {@code non-null cleaner}.
|
||||
* The {@code cleaner} is not retained by this reference; it is only used
|
||||
* to register the newly constructed {@link Cleaner.Cleanable Cleanable}.
|
||||
*
|
||||
* @param referent the referent to track
|
||||
* @param cleaner the {@code Cleaner} to register with
|
||||
*/
|
||||
public SoftCleanable(T referent, Cleaner cleaner) {
|
||||
super(Objects.requireNonNull(referent), CleanerImpl.getCleanerImpl(cleaner).queue);
|
||||
list = CleanerImpl.getCleanerImpl(cleaner).softCleanableList;
|
||||
insert();
|
||||
|
||||
// TODO: Replace getClass() with ReachabilityFence when it is available
|
||||
cleaner.getClass();
|
||||
referent.getClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new root of the list; not inserted.
|
||||
*/
|
||||
SoftCleanable() {
|
||||
super(null, null);
|
||||
this.list = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert this SoftCleanableReference after the list head.
|
||||
*/
|
||||
private void insert() {
|
||||
synchronized (list) {
|
||||
prev = list;
|
||||
next = list.next;
|
||||
next.prev = this;
|
||||
list.next = this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this SoftCleanableReference from the list.
|
||||
*
|
||||
* @return true if Cleanable was removed or false if not because
|
||||
* it had already been removed before
|
||||
*/
|
||||
private boolean remove() {
|
||||
synchronized (list) {
|
||||
if (next != this) {
|
||||
next.prev = prev;
|
||||
prev.next = next;
|
||||
prev = this;
|
||||
next = this;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the list's next reference refers to itself.
|
||||
*
|
||||
* @return true if the list is empty
|
||||
*/
|
||||
boolean isListEmpty() {
|
||||
synchronized (list) {
|
||||
return list == list.next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this SoftCleanable reference and invoke {@link #performCleanup()},
|
||||
* ensuring at-most-once semantics.
|
||||
*/
|
||||
@Override
|
||||
public final void clean() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
performCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this SoftCleanable and clear the reference.
|
||||
* Due to inherent concurrency, {@link #performCleanup()} may still be invoked.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@code performCleanup} abstract method is overridden
|
||||
* to implement the cleaning logic.
|
||||
* The {@code performCleanup} method should not be called except
|
||||
* by the {@link #clean} method which ensures at most once semantics.
|
||||
*/
|
||||
protected abstract void performCleanup();
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean isEnqueued() {
|
||||
throw new UnsupportedOperationException("isEnqueued");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean enqueue() {
|
||||
throw new UnsupportedOperationException("enqueue");
|
||||
}
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
package jdk.internal.ref;
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import java.lang.ref.Cleaner;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* WeakCleanable subclasses efficiently encapsulate cleanup state and
|
||||
* the cleaning action.
|
||||
* Subclasses implement the abstract {@link #performCleanup()} method
|
||||
* to provide the cleaning action.
|
||||
* When constructed, the object reference and the {@link Cleaner.Cleanable Cleanable}
|
||||
* are registered with the {@link Cleaner}.
|
||||
* The Cleaner invokes {@link Cleaner.Cleanable#clean() clean} after the
|
||||
* referent becomes weakly reachable.
|
||||
*/
|
||||
public abstract class WeakCleanable<T> extends WeakReference<T>
|
||||
implements Cleaner.Cleanable {
|
||||
|
||||
/**
|
||||
* Links to previous and next in a doubly-linked list.
|
||||
*/
|
||||
WeakCleanable<?> prev = this, next = this;
|
||||
|
||||
/**
|
||||
* The list of WeakCleanable; synchronizes insert and remove.
|
||||
*/
|
||||
private final WeakCleanable<?> list;
|
||||
|
||||
/**
|
||||
* Constructs new {@code WeakCleanableReference} with
|
||||
* {@code non-null referent} and {@code non-null cleaner}.
|
||||
* The {@code cleaner} is not retained by this reference; it is only used
|
||||
* to register the newly constructed {@link Cleaner.Cleanable Cleanable}.
|
||||
*
|
||||
* @param referent the referent to track
|
||||
* @param cleaner the {@code Cleaner} to register new reference with
|
||||
*/
|
||||
public WeakCleanable(T referent, Cleaner cleaner) {
|
||||
super(Objects.requireNonNull(referent), CleanerImpl.getCleanerImpl(cleaner).queue);
|
||||
list = CleanerImpl.getCleanerImpl(cleaner).weakCleanableList;
|
||||
insert();
|
||||
|
||||
// TODO: Replace getClass() with ReachabilityFence when it is available
|
||||
cleaner.getClass();
|
||||
referent.getClass();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a new root of the list; not inserted.
|
||||
*/
|
||||
WeakCleanable() {
|
||||
super(null, null);
|
||||
this.list = this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert this WeakCleanableReference after the list head.
|
||||
*/
|
||||
private void insert() {
|
||||
synchronized (list) {
|
||||
prev = list;
|
||||
next = list.next;
|
||||
next.prev = this;
|
||||
list.next = this;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove this WeakCleanableReference from the list.
|
||||
*
|
||||
* @return true if Cleanable was removed or false if not because
|
||||
* it had already been removed before
|
||||
*/
|
||||
private boolean remove() {
|
||||
synchronized (list) {
|
||||
if (next != this) {
|
||||
next.prev = prev;
|
||||
prev.next = next;
|
||||
prev = this;
|
||||
next = this;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the list's next reference refers to itself.
|
||||
*
|
||||
* @return true if the list is empty
|
||||
*/
|
||||
boolean isListEmpty() {
|
||||
synchronized (list) {
|
||||
return list == list.next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this WeakCleanable reference and invoke {@link #performCleanup()},
|
||||
* ensuring at-most-once semantics.
|
||||
*/
|
||||
@Override
|
||||
public final void clean() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
performCleanup();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregister this WeakCleanable and clear the reference.
|
||||
* Due to inherent concurrency, {@link #performCleanup()} may still be invoked.
|
||||
*/
|
||||
@Override
|
||||
public void clear() {
|
||||
if (remove()) {
|
||||
super.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@code performCleanup} abstract method is overridden
|
||||
* to implement the cleaning logic.
|
||||
* The {@code performCleanup} method should not be called except
|
||||
* by the {@link #clean} method which ensures at most once semantics.
|
||||
*/
|
||||
protected abstract void performCleanup();
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean isEnqueued() {
|
||||
throw new UnsupportedOperationException("isEnqueued");
|
||||
}
|
||||
|
||||
/**
|
||||
* This method always throws {@link UnsupportedOperationException}.
|
||||
* Enqueuing details of {@link Cleaner.Cleanable}
|
||||
* are a private implementation detail.
|
||||
*
|
||||
* @throws UnsupportedOperationException always
|
||||
*/
|
||||
@Override
|
||||
public final boolean enqueue() {
|
||||
throw new UnsupportedOperationException("enqueue");
|
||||
}
|
||||
}
|
@ -34,7 +34,6 @@ import java.net.SocketOption;
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
@jdk.Exported
|
||||
public final class ExtendedSocketOptions {
|
||||
|
||||
private static class ExtSocketOption<T> implements SocketOption<T> {
|
||||
|
@ -61,7 +61,6 @@ import java.security.BasicPermission;
|
||||
* @since 1.8
|
||||
*/
|
||||
|
||||
@jdk.Exported
|
||||
public final class NetworkPermission extends BasicPermission {
|
||||
|
||||
private static final long serialVersionUID = -2012939586906722291L;
|
||||
|
@ -45,7 +45,6 @@ import java.lang.annotation.Native;
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
@jdk.Exported
|
||||
public class SocketFlow {
|
||||
|
||||
private static final int UNSET = -1;
|
||||
@ -68,7 +67,6 @@ public class SocketFlow {
|
||||
*
|
||||
* @since 1.8
|
||||
*/
|
||||
@jdk.Exported
|
||||
public enum Status {
|
||||
/**
|
||||
* Set or get socket option has not been called yet. Status
|
||||
|
@ -55,7 +55,6 @@ import sun.net.ExtendedOptionsImpl;
|
||||
*
|
||||
* @see java.nio.channels.NetworkChannel
|
||||
*/
|
||||
@jdk.Exported
|
||||
public class Sockets {
|
||||
|
||||
private static final HashMap<Class<?>,Set<SocketOption<?>>>
|
||||
|
@ -30,5 +30,4 @@
|
||||
* @since 1.8
|
||||
*/
|
||||
|
||||
@jdk.Exported
|
||||
package jdk.net;
|
||||
|
@ -66,6 +66,7 @@ import java.util.TreeSet;
|
||||
import java.util.jar.Attributes;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.jar.Manifest;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
public enum LauncherHelper {
|
||||
INSTANCE;
|
||||
@ -86,9 +87,9 @@ public enum LauncherHelper {
|
||||
private static final String PROP_SETTINGS = "Property settings:";
|
||||
private static final String LOCALE_SETTINGS = "Locale settings:";
|
||||
|
||||
// sync with java.c and sun.misc.VM
|
||||
// sync with java.c and jdk.internal.misc.VM
|
||||
private static final String diagprop = "sun.java.launcher.diag";
|
||||
static final boolean trace = sun.misc.VM.getSavedProperty(diagprop) != null;
|
||||
static final boolean trace = VM.getSavedProperty(diagprop) != null;
|
||||
|
||||
private static final String defaultBundleName =
|
||||
"sun.launcher.resources.launcher";
|
||||
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 1995, 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.misc;
|
||||
|
||||
/**
|
||||
* MessageUtils: miscellaneous utilities for handling error and status
|
||||
* properties and messages.
|
||||
*
|
||||
* @author Herb Jellinek
|
||||
*/
|
||||
|
||||
public class MessageUtils {
|
||||
// can instantiate it for to allow less verbose use - via instance
|
||||
// instead of classname
|
||||
|
||||
public MessageUtils() { }
|
||||
|
||||
public static String subst(String patt, String arg) {
|
||||
String args[] = { arg };
|
||||
return subst(patt, args);
|
||||
}
|
||||
|
||||
public static String subst(String patt, String arg1, String arg2) {
|
||||
String args[] = { arg1, arg2 };
|
||||
return subst(patt, args);
|
||||
}
|
||||
|
||||
public static String subst(String patt, String arg1, String arg2,
|
||||
String arg3) {
|
||||
String args[] = { arg1, arg2, arg3 };
|
||||
return subst(patt, args);
|
||||
}
|
||||
|
||||
public static String subst(String patt, String args[]) {
|
||||
StringBuilder result = new StringBuilder();
|
||||
int len = patt.length();
|
||||
for (int i = 0; i >= 0 && i < len; i++) {
|
||||
char ch = patt.charAt(i);
|
||||
if (ch == '%') {
|
||||
if (i != len) {
|
||||
int index = Character.digit(patt.charAt(i + 1), 10);
|
||||
if (index == -1) {
|
||||
result.append(patt.charAt(i + 1));
|
||||
i++;
|
||||
} else if (index < args.length) {
|
||||
result.append(args[index]);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
result.append(ch);
|
||||
}
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
public static String substProp(String propName, String arg) {
|
||||
return subst(System.getProperty(propName), arg);
|
||||
}
|
||||
|
||||
public static String substProp(String propName, String arg1, String arg2) {
|
||||
return subst(System.getProperty(propName), arg1, arg2);
|
||||
}
|
||||
|
||||
public static String substProp(String propName, String arg1, String arg2,
|
||||
String arg3) {
|
||||
return subst(System.getProperty(propName), arg1, arg2, arg3);
|
||||
}
|
||||
|
||||
/**
|
||||
* Print a message directly to stderr, bypassing all the
|
||||
* character conversion methods.
|
||||
* @param msg message to print
|
||||
*/
|
||||
public static native void toStderr(String msg);
|
||||
|
||||
/**
|
||||
* Print a message directly to stdout, bypassing all the
|
||||
* character conversion methods.
|
||||
* @param msg message to print
|
||||
*/
|
||||
public static native void toStdout(String msg);
|
||||
|
||||
|
||||
// Short forms of the above
|
||||
|
||||
public static void err(String s) {
|
||||
toStderr(s + "\n");
|
||||
}
|
||||
|
||||
public static void out(String s) {
|
||||
toStdout(s + "\n");
|
||||
}
|
||||
|
||||
// Print a stack trace to stderr
|
||||
//
|
||||
public static void where() {
|
||||
Throwable t = new Throwable();
|
||||
StackTraceElement[] es = t.getStackTrace();
|
||||
for (int i = 1; i < es.length; i++)
|
||||
toStderr("\t" + es[i].toString() + "\n");
|
||||
}
|
||||
|
||||
}
|
@ -32,6 +32,7 @@ import sun.reflect.CallerSensitive;
|
||||
import sun.reflect.Reflection;
|
||||
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -967,12 +967,6 @@ public class HttpClient extends NetworkClient {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
// This should do nothing. The stream finalizer will
|
||||
// close the fd.
|
||||
}
|
||||
|
||||
public void setDoNotRetry(boolean value) {
|
||||
// failedOnce is used to determine if a request should be retried.
|
||||
failedOnce = value;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -108,13 +108,6 @@ public class URLJarFile extends JarFile {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* close the jar file.
|
||||
*/
|
||||
protected void finalize() throws IOException {
|
||||
close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the <code>ZipEntry</code> for the given entry name or
|
||||
* <code>null</code> if not found.
|
||||
|
@ -389,7 +389,7 @@ public class Util {
|
||||
|
||||
static boolean atBugLevel(String bl) { // package-private
|
||||
if (bugLevel == null) {
|
||||
if (!sun.misc.VM.isBooted())
|
||||
if (!jdk.internal.misc.VM.isBooted())
|
||||
return false;
|
||||
String value = AccessController.doPrivileged(
|
||||
new GetPropertyAction("sun.nio.ch.bugLevel"));
|
||||
|
@ -156,12 +156,12 @@ public class StandardCharsets extends CharsetProvider {
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
/* provider the sun.nio.cs.map property fir sjis/ms932 mapping hack
|
||||
/* provider the sun.nio.cs.map property fir sjis/ms932 mapping hack
|
||||
*/
|
||||
private void init() {
|
||||
if (initialized)
|
||||
return;
|
||||
if (!sun.misc.VM.isBooted())
|
||||
if (!jdk.internal.misc.VM.isBooted())
|
||||
return;
|
||||
initialized = true;
|
||||
|
||||
|
@ -29,6 +29,7 @@ import java.lang.reflect.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import jdk.internal.HotSpotIntrinsicCandidate;
|
||||
import jdk.internal.misc.VM;
|
||||
|
||||
/** Common utility routines used by both java.lang and
|
||||
java.lang.reflect */
|
||||
@ -335,7 +336,7 @@ public class Reflection {
|
||||
*/
|
||||
public static boolean isCallerSensitive(Method m) {
|
||||
final ClassLoader loader = m.getDeclaringClass().getClassLoader();
|
||||
if (sun.misc.VM.isSystemDomainLoader(loader) || isExtClassLoader(loader)) {
|
||||
if (VM.isSystemDomainLoader(loader) || isExtClassLoader(loader)) {
|
||||
return m.isAnnotationPresent(CallerSensitive.class);
|
||||
}
|
||||
return false;
|
||||
|
@ -2211,7 +2211,7 @@ public final class SSLEngineImpl extends SSLEngine {
|
||||
|
||||
@Override
|
||||
public synchronized String getHandshakeApplicationProtocol() {
|
||||
if ((handshaker != null) && !handshaker.started()) {
|
||||
if ((handshaker != null) && handshaker.started()) {
|
||||
return handshaker.getHandshakeApplicationProtocol();
|
||||
}
|
||||
return null;
|
||||
|
@ -2598,7 +2598,7 @@ public final class SSLSocketImpl extends BaseSSLSocketImpl {
|
||||
|
||||
@Override
|
||||
public synchronized String getHandshakeApplicationProtocol() {
|
||||
if ((handshaker != null) && !handshaker.started()) {
|
||||
if ((handshaker != null) && handshaker.started()) {
|
||||
return handshaker.getHandshakeApplicationProtocol();
|
||||
}
|
||||
return null;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -153,13 +153,11 @@ final class SignatureAndHashAlgorithm {
|
||||
getSupportedAlgorithms(AlgorithmConstraints constraints) {
|
||||
|
||||
Collection<SignatureAndHashAlgorithm> supported = new ArrayList<>();
|
||||
synchronized (priorityMap) {
|
||||
for (SignatureAndHashAlgorithm sigAlg : priorityMap.values()) {
|
||||
if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM &&
|
||||
constraints.permits(SIGNATURE_PRIMITIVE_SET,
|
||||
sigAlg.algorithm, null)) {
|
||||
supported.add(sigAlg);
|
||||
}
|
||||
for (SignatureAndHashAlgorithm sigAlg : priorityMap.values()) {
|
||||
if (sigAlg.priority <= SUPPORTED_ALG_PRIORITY_MAX_NUM &&
|
||||
constraints.permits(SIGNATURE_PRIMITIVE_SET,
|
||||
sigAlg.algorithm, null)) {
|
||||
supported.add(sigAlg);
|
||||
}
|
||||
}
|
||||
|
||||
@ -417,14 +415,12 @@ final class SignatureAndHashAlgorithm {
|
||||
supports(HashAlgorithm.SHA1, SignatureAlgorithm.ECDSA,
|
||||
"SHA1withECDSA", --p);
|
||||
|
||||
if (Security.getProvider("SunMSCAPI") == null) {
|
||||
supports(HashAlgorithm.SHA224, SignatureAlgorithm.DSA,
|
||||
"SHA224withDSA", --p);
|
||||
supports(HashAlgorithm.SHA224, SignatureAlgorithm.RSA,
|
||||
"SHA224withRSA", --p);
|
||||
supports(HashAlgorithm.SHA224, SignatureAlgorithm.ECDSA,
|
||||
"SHA224withECDSA", --p);
|
||||
}
|
||||
|
||||
supports(HashAlgorithm.SHA256, SignatureAlgorithm.DSA,
|
||||
"SHA256withDSA", --p);
|
||||
|
@ -98,17 +98,6 @@ grant codeBase "jrt:/java.activation" {
|
||||
// default permissions granted to all domains
|
||||
|
||||
grant {
|
||||
// Allows any thread to stop itself using the java.lang.Thread.stop()
|
||||
// method that takes no argument.
|
||||
// Note that this permission is granted by default only to remain
|
||||
// backwards compatible.
|
||||
// It is strongly recommended that you either remove this permission
|
||||
// from this policy file or further restrict it to code sources
|
||||
// that you specify, because Thread.stop() is potentially unsafe.
|
||||
// See the API specification of java.lang.Thread.stop() for more
|
||||
// information.
|
||||
permission java.lang.RuntimePermission "stopThread";
|
||||
|
||||
// allows anyone to listen on dynamic ports
|
||||
permission java.net.SocketPermission "localhost:0", "listen";
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user