Merge
This commit is contained in:
commit
5bb28e9381
.hgtags.hgtags-top-repo
common/autoconf
corba
hotspot
jaxp
.hgtags
src/java.xml/share/classes
javax/xml
catalog
transform
org/xml/sax
test/javax/xml/jaxp
functional/catalog
libs
unittest
jaxws
jdk
make
CompileDemos.gmkCompileTools.gmkCopySamples.gmkImport.gmkTools.gmk
copy
gendata
gensrc
Gensrc-jdk.charsets.gmkGensrc-jdk.jdi.gmkGensrcBuffer.gmkGensrcCharacterData.gmkGensrcCharsetMapping.gmkGensrcExceptions.gmkGensrcIcons.gmkGensrcLocaleData.gmkGensrcMisc.gmkGensrcProperties.gmkGensrcSwing.gmkGensrcX11Wrappers.gmk
launcher
lib
src/java.base
share/classes/java
unix/classes/java/net
test
TEST.groups
java
net/SocketOption
nio/channels/ServerSocketChannel
util
javax
net/ssl/SSLSession
security/auth/SubjectDomainCombiner
xml/ws/publish
langtools
.hgtags
src
jdk.compiler/share/classes/com/sun/tools
javac
sjavac
jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/util
jdk.jshell/share/classes/jdk
internal/jshell
jshell
test
1
.hgtags
1
.hgtags
@ -343,3 +343,4 @@ f242d4332f563648426a1b0fa02d8741beba19ef jdk9-b92
|
||||
d00ad2d9049ac60815f70bff445e95df85648bd2 jdk-9+98
|
||||
f9bcdce2df26678c3fe468130b535c0342c69b89 jdk-9+99
|
||||
4379223f8806626852c46c52d4e7a27a584b406e jdk-9+100
|
||||
80f67512daa15cf37b4825c1c62a675d524d7c49 jdk-9+101
|
||||
|
@ -343,3 +343,4 @@ cf1dc4c035fb84693d4ae5ad818785cb4d1465d1 jdk9-b90
|
||||
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
|
||||
|
||||
|
@ -425,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"
|
||||
@ -742,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.
|
||||
@ -896,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])
|
||||
@ -914,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])
|
||||
@ -923,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])
|
||||
@ -948,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
|
||||
])
|
||||
|
||||
@ -965,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],
|
||||
@ -1013,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-"
|
||||
@ -1026,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.
|
||||
@ -3886,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.
|
||||
@ -4810,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=1452261921
|
||||
DATE_WHEN_GENERATED=1452780299
|
||||
|
||||
###############################################################################
|
||||
#
|
||||
@ -45358,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
|
||||
@ -45417,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
|
||||
@ -45467,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
|
||||
@ -45517,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
|
||||
@ -46842,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
|
||||
@ -46902,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"
|
||||
;;
|
||||
@ -47384,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
|
||||
@ -47444,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
|
||||
@ -47512,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;
|
||||
@ -47565,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
|
||||
@ -47624,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
|
||||
@ -47640,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
|
||||
@ -47699,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
|
||||
@ -61523,7 +62030,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
|
||||
|
||||
|
@ -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
|
||||
|
@ -343,3 +343,4 @@ feb1bd85d7990dcf5584ca9e53104269c01db006 jdk-9+96
|
||||
ea285530245cf4e0edf0479121a41347d3030eba jdk-9+98
|
||||
180212ee1d8710691ba9944593dfc1ff3e4f1532 jdk-9+99
|
||||
791d0d3ac0138faeb6110bd840a4545bc1950df2 jdk-9+100
|
||||
30dfb3bd3d06b4bb80a087babc0d1841edba187b jdk-9+101
|
||||
|
@ -503,3 +503,4 @@ de592ea5f7ba0f8a8c5afc03bd169f7690c72b6f jdk-9+97
|
||||
e5b1a23be1e105417ba1c4c576ab373eb3fa2c2b jdk-9+98
|
||||
f008e8cc10d5b3212fb22d58c96fa01d38654f19 jdk-9+99
|
||||
bdb0acafc63c42e84d9d8195bf2e2b25ee9c3306 jdk-9+100
|
||||
9f45d3d57d6948cf526fbc2e2891a9a74ac6941a jdk-9+101
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
|
||||
|
@ -343,3 +343,4 @@ c8d0845877a811ab4350935892f826929359a3ff jdk-9+95
|
||||
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;
|
||||
}
|
||||
}
|
@ -346,3 +346,4 @@ b55cebc47555293cf9c2aefb3bf63c56e847ab19 jdk-9+96
|
||||
67c84077edc3db6b24998b35970b37c01aae985e jdk-9+98
|
||||
97b31ca0dd77483cf20ff99a033a455673639578 jdk-9+99
|
||||
d0a97e57d2336238edf6a4cd60aafe67deb7258d jdk-9+100
|
||||
3e99318616da903e0dc8f07f9f9203dc1bd49921 jdk-9+101
|
||||
|
@ -38,7 +38,8 @@ include TextFileProcessing.gmk
|
||||
include ZipArchive.gmk
|
||||
|
||||
# Prepare the find cache.
|
||||
$(eval $(call FillCacheFind, $(JDK_TOPDIR)/src))
|
||||
$(eval $(call FillCacheFind, $(wildcard $(JDK_TOPDIR)/src/demo \
|
||||
$(JDK_TOPDIR)/src/*/demo)))
|
||||
|
||||
# Append demo goals to this variable.
|
||||
TARGETS =
|
||||
|
83
jdk/make/CompileTools.gmk
Normal file
83
jdk/make/CompileTools.gmk
Normal file
@ -0,0 +1,83 @@
|
||||
#
|
||||
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
#
|
||||
# This code is free software; you can redistribute it and/or modify it
|
||||
# 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.
|
||||
#
|
||||
|
||||
default: all
|
||||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
include JavaCompilation.gmk
|
||||
include SetupJavaCompilers.gmk
|
||||
|
||||
################################################################################
|
||||
|
||||
JIMAGE_PKGS := \
|
||||
jdk/internal/jimage \
|
||||
jdk/internal/jrtfs \
|
||||
#
|
||||
|
||||
$(eval $(call SetupJavaCompilation,BUILD_INTERIM_JIMAGE, \
|
||||
SETUP := GENERATE_OLDBYTECODE, \
|
||||
SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \
|
||||
INCLUDES := $(JIMAGE_PKGS), \
|
||||
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes))
|
||||
|
||||
TARGETS += $(BUILD_INTERIM_JIMAGE)
|
||||
|
||||
# Because of the explicit INCLUDES in the compilation setup above, the service provider
|
||||
# file will not be copied unless META-INF/services would also be added to the INCLUDES.
|
||||
# Adding META-INF/services would include all files in that directory when only the one
|
||||
# is needed, which is why this explicit copy is defined instead.
|
||||
$(eval $(call SetupCopyFiles,COPY_JIMAGE_SERVICE_PROVIDER, \
|
||||
SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \
|
||||
DEST := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes, \
|
||||
FILES := META-INF/services/java.nio.file.spi.FileSystemProvider))
|
||||
|
||||
TARGETS += $(COPY_JIMAGE_SERVICE_PROVIDER)
|
||||
|
||||
################################################################################
|
||||
|
||||
$(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \
|
||||
SETUP := GENERATE_OLDBYTECODE, \
|
||||
ADD_JAVAC_FLAGS := -Xbootclasspath/p:$(call PathList, \
|
||||
$(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes \
|
||||
$(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes), \
|
||||
SRC := $(JDK_TOPDIR)/make/src/classes $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes, \
|
||||
BIN := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
|
||||
COPY := boot.modules ext.modules))
|
||||
|
||||
$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE) $(COPY_JIMAGE_SERVICE_PROVIDER)
|
||||
|
||||
TARGETS += $(BUILD_TOOLS_JDK)
|
||||
|
||||
$(eval $(call SetupCopyFiles,COPY_NIMBUS_TEMPLATES, \
|
||||
SRC := $(JDK_TOPDIR)/src/java.desktop/share/classes/javax/swing/plaf/nimbus, \
|
||||
DEST := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes/build/tools/generatenimbus/resources, \
|
||||
FILES := $(wildcard $(JDK_TOPDIR)/src/java.desktop/share/classes/javax/swing/plaf/nimbus/*.template)))
|
||||
|
||||
TARGETS += $(COPY_NIMBUS_TEMPLATES)
|
||||
|
||||
################################################################################
|
||||
|
||||
all: $(TARGETS)
|
@ -28,41 +28,38 @@ default: all
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
|
||||
################################################################################
|
||||
|
||||
SAMPLE_TARGET_DIR := $(SUPPORT_OUTPUTDIR)/sample/image
|
||||
SAMPLE_SOURCE_DIR := $(JDK_TOPDIR)/src/sample/share
|
||||
SAMPLE_CLOSED_SOURCE_DIR := $(JDK_TOPDIR)/src/closed/sample/share
|
||||
SAMPLE_SOLARIS_SOURCE_DIR := $(JDK_TOPDIR)/src/sample/solaris
|
||||
|
||||
# Exclude the vm directory
|
||||
SAMPLE_FIND_FILTER := -name vm -prune -o
|
||||
$(eval $(call SetupCopyFiles, COPY_SHARE_SAMPLES, \
|
||||
SRC := $(SAMPLE_SOURCE_DIR), \
|
||||
DEST := $(SAMPLE_TARGET_DIR), \
|
||||
FILES := $(filter-out $(SAMPLE_SOURCE_DIR)/vm/%, \
|
||||
$(call CacheFind, $(SAMPLE_SOURCE_DIR))), \
|
||||
))
|
||||
|
||||
SAMPLE_SOURCE := $(shell $(FIND) $(SAMPLE_SOURCE_DIR) $(SAMPLE_FIND_FILTER) -type f -print)
|
||||
SAMPLE_TARGET := $(subst $(SAMPLE_SOURCE_DIR),$(SAMPLE_TARGET_DIR),$(SAMPLE_SOURCE))
|
||||
|
||||
ifndef OPENJDK
|
||||
# Exclude Main.java in EbayClient dir
|
||||
SAMPLE_CLOSED_SOURCE := $(shell $(FIND) $(SAMPLE_CLOSED_SOURCE_DIR) -type f -print | $(GREP) -v EbayClient/Main.java)
|
||||
SAMPLE_CLOSED_TARGET := $(subst $(SAMPLE_CLOSED_SOURCE_DIR),$(SAMPLE_TARGET_DIR),$(SAMPLE_CLOSED_SOURCE))
|
||||
SAMPLE_TARGET += $(SAMPLE_CLOSED_TARGET)
|
||||
endif
|
||||
TARGETS += $(COPY_SHARE_SAMPLES)
|
||||
|
||||
ifneq (, $(filter $(OPENJDK_TARGET_OS), solaris macosx))
|
||||
SAMPLE_SOLARIS_SOURCE := $(shell $(FIND) $(SAMPLE_SOLARIS_SOURCE_DIR) -type f -print)
|
||||
SAMPLE_SOLARIS_TARGET := $(subst $(SAMPLE_SOLARIS_SOURCE_DIR),$(SAMPLE_TARGET_DIR),$(SAMPLE_SOLARIS_SOURCE))
|
||||
SAMPLE_TARGET += $(SAMPLE_SOLARIS_TARGET)
|
||||
$(eval $(call SetupCopyFiles, COPY_SOLARIS_SAMPLES, \
|
||||
SRC := $(SAMPLE_SOLARIS_SOURCE_DIR), \
|
||||
DEST := $(SAMPLE_TARGET_DIR), \
|
||||
FILES := $(call CacheFind, $(SAMPLE_SOLARIS_SOURCE_DIR)), \
|
||||
))
|
||||
|
||||
TARGETS += $(COPY_SOLARIS_SAMPLES)
|
||||
endif
|
||||
|
||||
$(SAMPLE_TARGET_DIR)/dtrace/%: $(SAMPLE_SOLARIS_SOURCE_DIR)/dtrace/%
|
||||
$(call install-file)
|
||||
################################################################################
|
||||
|
||||
$(SAMPLE_TARGET_DIR)/webservices/%: $(SAMPLE_CLOSED_SOURCE_DIR)/webservices/%
|
||||
$(call install-file)
|
||||
$(eval $(call IncludeCustomExtension, jdk, CopySamples.gmk))
|
||||
|
||||
$(SAMPLE_TARGET_DIR)/%: $(SAMPLE_SOURCE_DIR)/%
|
||||
$(call install-file)
|
||||
################################################################################
|
||||
|
||||
COPY_FILES += $(SAMPLE_TARGET)
|
||||
all: $(TARGETS)
|
||||
|
||||
all: $(COPY_FILES)
|
||||
|
||||
.PHONY: all
|
||||
.PHONY: all default
|
||||
|
@ -48,7 +48,7 @@ endif
|
||||
ifneq ($(STATIC_BUILD), true)
|
||||
JSIG_IMPORT = jsig.*
|
||||
else
|
||||
JSIG_IMPORT =
|
||||
JSIG_IMPORT =
|
||||
endif
|
||||
|
||||
HOTSPOT_BASE_IMPORT_FILES := \
|
||||
|
@ -26,31 +26,14 @@
|
||||
ifndef _TOOLS_GMK
|
||||
_TOOLS_GMK := 1
|
||||
|
||||
default: all
|
||||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
include JavaCompilation.gmk
|
||||
include NativeCompilation.gmk
|
||||
include SetupJavaCompilers.gmk
|
||||
|
||||
################################################################################
|
||||
|
||||
$(eval $(call SetupJavaCompilation,BUILD_TOOLS_JDK, \
|
||||
SETUP := GENERATE_OLDBYTECODE, \
|
||||
ADD_JAVAC_FLAGS := -Xbootclasspath/p:$(call PathList, \
|
||||
$(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes \
|
||||
$(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes), \
|
||||
SRC := $(JDK_TOPDIR)/make/src/classes $(BUILDTOOLS_OUTPUTDIR)/interim_cldrconverter_classes, \
|
||||
BIN := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes, \
|
||||
COPY := boot.modules ext.modules))
|
||||
|
||||
$(eval $(call SetupCopyFiles,COPY_NIMBUS_TEMPLATES, \
|
||||
SRC := $(JDK_TOPDIR)/src/java.desktop/share/classes/javax/swing/plaf/nimbus, \
|
||||
DEST := $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes/build/tools/generatenimbus/resources, \
|
||||
FILES := $(wildcard $(JDK_TOPDIR)/src/java.desktop/share/classes/javax/swing/plaf/nimbus/*.template)))
|
||||
|
||||
BUILD_TOOLS_JDK += $(COPY_NIMBUS_TEMPLATES)
|
||||
# To avoid reevaluating the compilation setup for the tools each time this file
|
||||
# is included, the actual compilation is handled by CompileTools.gmk. The
|
||||
# following trick is used to be able to declare a dependency on the built tools.
|
||||
BUILD_TOOLS_JDK := $(call SetupJavaCompilationCompileTarget, \
|
||||
BUILD_TOOLS_JDK, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes)
|
||||
|
||||
################################################################################
|
||||
|
||||
@ -135,34 +118,4 @@ TOOL_IMAGEBUILDER = $(JAVA_SMALL) -Xbootclasspath/p:$(BUILDTOOLS_OUTPUTDIR)/inte
|
||||
-cp $(call PathList, $(BUILDTOOLS_OUTPUTDIR)/jdk_tools_classes $(JDK_OUTPUTDIR)) \
|
||||
build.tools.module.ImageBuilder
|
||||
|
||||
##########################################################################################
|
||||
|
||||
JIMAGE_PKGS := \
|
||||
jdk/internal/jimage \
|
||||
jdk/internal/jrtfs \
|
||||
#
|
||||
|
||||
$(eval $(call SetupJavaCompilation,BUILD_INTERIM_JIMAGE, \
|
||||
SETUP := GENERATE_OLDBYTECODE, \
|
||||
SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \
|
||||
INCLUDES := $(JIMAGE_PKGS), \
|
||||
BIN := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes))
|
||||
|
||||
# Because of the explicit INCLUDES in the compilation setup above, the service provider
|
||||
# file will not be copied unless META-INF/services would also be added to the INCLUDES.
|
||||
# Adding META-INF/services would include all files in that directory when only the one
|
||||
# is needed, which is why this explicit copy is defined instead.
|
||||
$(eval $(call SetupCopyFiles,COPY_JIMAGE_SERVICE_PROVIDER, \
|
||||
SRC := $(JDK_TOPDIR)/src/java.base/share/classes, \
|
||||
DEST := $(BUILDTOOLS_OUTPUTDIR)/interim_jimage_classes, \
|
||||
FILES := META-INF/services/java.nio.file.spi.FileSystemProvider))
|
||||
|
||||
##########################################################################################
|
||||
|
||||
$(BUILD_TOOLS_JDK): $(BUILD_INTERIM_JIMAGE) $(COPY_JIMAGE_SERVICE_PROVIDER)
|
||||
|
||||
java-tools: $(BUILD_TOOLS_JDK)
|
||||
|
||||
all: java-tools
|
||||
|
||||
endif # _TOOLS_GMK
|
||||
|
@ -187,27 +187,31 @@ TARGETS += $(POLICY_DST)
|
||||
ifeq ($(CACERTS_FILE), )
|
||||
CACERTS_FILE := $(JDK_TOPDIR)/src/java.base/share/conf/security/cacerts
|
||||
endif
|
||||
|
||||
CACERTS_DST := $(LIB_DST_DIR)/security/cacerts
|
||||
|
||||
$(CACERTS_DST): $(CACERTS_FILE)
|
||||
$(call LogInfo, Copying $(patsubst $(OUTPUT_ROOT)/%, %, $@))
|
||||
$(call install-file)
|
||||
|
||||
TARGETS += $(CACERTS_DST)
|
||||
|
||||
################################################################################
|
||||
|
||||
$(CONF_DST_DIR)/net.properties: $(JDK_TOPDIR)/src/java.base/share/conf/net.properties
|
||||
$(ECHO) $(LOG_INFO) Copying $(@F)
|
||||
$(call install-file)
|
||||
$(eval $(call SetupCopyFiles, COPY_NET_PROPERTIES, \
|
||||
FILES := $(JDK_TOPDIR)/src/java.base/share/conf/net.properties, \
|
||||
DEST := $(CONF_DST_DIR), \
|
||||
))
|
||||
|
||||
TARGETS += $(CONF_DST_DIR)/net.properties
|
||||
TARGETS += $(COPY_NET_PROPERTIES)
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_OS), solaris)
|
||||
$(CONF_DST_DIR)/sdp/sdp.conf.template: $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template
|
||||
$(ECHO) $(LOG_INFO) Copying $(@F)
|
||||
$(call install-file)
|
||||
$(eval $(call SetupCopyFiles, COPY_SDP_CONF, \
|
||||
FILES := $(JDK_TOPDIR)/src/java.base/$(OPENJDK_TARGET_OS_TYPE)/conf/sdp/sdp.conf.template, \
|
||||
DEST := $(CONF_DST_DIR)/sdp, \
|
||||
))
|
||||
|
||||
TARGETS += $(CONF_DST_DIR)/sdp/sdp.conf.template
|
||||
TARGETS += $(COPY_SDP_CONF)
|
||||
endif
|
||||
|
||||
################################################################################
|
||||
|
@ -68,8 +68,8 @@ BIFILES_TH := $(LD_DATA_PKG_DIR)/th/WordBreakIteratorData_th \
|
||||
$(BIFILES): $(BASE_DATA_PKG_DIR)/_the.bifiles
|
||||
$(BASE_DATA_PKG_DIR)/_the.bifiles: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES)
|
||||
$(BASE_DATA_PKG_DIR)/_the.bifiles: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKITERATOR)
|
||||
$(ECHO) $(LOG_INFO) "Generating BreakIteratorData"
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call LogInfo, Generating BreakIteratorData)
|
||||
$(call MakeDir, $(@D))
|
||||
$(RM) $(BIFILES)
|
||||
$(TOOL_GENERATEBREAKITERATORDATA) \
|
||||
-o $(@D) \
|
||||
@ -79,8 +79,8 @@ $(BASE_DATA_PKG_DIR)/_the.bifiles: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKIT
|
||||
$(BIFILES_TH): $(LD_DATA_PKG_DIR)/_the.bifiles_th
|
||||
$(LD_DATA_PKG_DIR)/_the.bifiles_th: JAVA_FLAGS += -Xbootclasspath/p:$(BREAK_ITERATOR_CLASSES)
|
||||
$(LD_DATA_PKG_DIR)/_the.bifiles_th: $(BUILD_TOOLS) $(UNICODEDATA) $(BUILD_BREAKITERATOR)
|
||||
$(ECHO) $(LOG_INFO) "Generating BreakIteratorData_th"
|
||||
$(MKDIR) -p $(@D)/th
|
||||
$(call LogInfo, Generating BreakIteratorData_th)
|
||||
$(call MakeDir, $(@D)/th)
|
||||
$(RM) $(BIFILES_TH)
|
||||
$(TOOL_GENERATEBREAKITERATORDATA) \
|
||||
-o $(@D) \
|
||||
|
@ -27,7 +27,7 @@ GENDATA_HTML32DTD :=
|
||||
|
||||
HTML32DTD = $(JDK_OUTPUTDIR)/modules/java.desktop/javax/swing/text/html/parser/html32.bdtd
|
||||
$(HTML32DTD): $(BUILD_TOOLS_JDK)
|
||||
$(ECHO) "Generating HTML DTD file"
|
||||
$(call LogInfo, Generating HTML DTD file)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(RM) $@
|
||||
($(TOOL_DTDBUILDER) $(LOG_INFO) html32 > $@) || exit 1
|
||||
|
@ -87,8 +87,7 @@ $(eval $(call SetupJarArchive, BUILD_US_EXPORT_POLICY_JAR, \
|
||||
|
||||
$(US_EXPORT_POLICY_JAR_LIMITED): \
|
||||
$(US_EXPORT_POLICY_JAR_UNLIMITED)
|
||||
$(ECHO) $(LOG_INFO) \
|
||||
Copying unlimited $(patsubst $(OUTPUT_ROOT)/%,%,$@)
|
||||
$(call LogInfo, Copying unlimited $(patsubst $(OUTPUT_ROOT)/%,%,$@))
|
||||
$(install-file)
|
||||
|
||||
TARGETS += $(US_EXPORT_POLICY_JAR_LIMITED) $(US_EXPORT_POLICY_JAR_UNLIMITED)
|
||||
@ -99,7 +98,7 @@ ifeq ($(UNLIMITED_CRYPTO), true)
|
||||
else
|
||||
$(US_EXPORT_POLICY_JAR_DST): $(US_EXPORT_POLICY_JAR_LIMITED)
|
||||
$(install-file)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef OPENJDK
|
||||
ifneq ($(UNLIMITED_CRYPTO), true)
|
||||
|
@ -46,30 +46,34 @@ $(CHARSET_DONE_CS)-extcs: $(CHARSET_DATA_DIR)/charsets \
|
||||
$(wildcard $(CHARSET_DATA_DIR)/$(CHARSET_STANDARD_OS)) \
|
||||
$(CHARSET_TEMPLATES) $(CHARSET_EXTENDED_JAVA_TEMPLATES) \
|
||||
$(BUILD_TOOLS_JDK)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call LogInfo, Generating jdk.charsets extcs)
|
||||
$(call MakeDir, $(@D))
|
||||
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_CS) \
|
||||
extcs charsets $(CHARSET_STANDARD_OS) \
|
||||
$(CHARSET_EXTENDED_JAVA_TEMPLATES) \
|
||||
$(CHARSET_EXTENDED_JAVA_DIR) \
|
||||
$(CHARSET_COPYRIGHT_HEADER) \
|
||||
$(LOG_INFO)
|
||||
$(LOG_DEBUG)
|
||||
$(TOUCH) '$@'
|
||||
|
||||
$(CHARSET_DONE_CS)-hkscs: $(CHARSET_COPYRIGHT_HEADER)/HKSCS.java \
|
||||
$(BUILD_TOOLS_JDK)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call LogInfo, Generating jdk.charsets hkscs)
|
||||
$(call MakeDir, $(@D))
|
||||
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_CS) hkscs '$<'
|
||||
$(TOUCH) '$@'
|
||||
|
||||
$(CHARSET_DONE_CS)-euctw: $(CHARSET_COPYRIGHT_HEADER)/EUC_TW.java \
|
||||
$(BUILD_TOOLS_JDK)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call LogInfo, Generating jdk.charsets euctw)
|
||||
$(call MakeDir, $(@D))
|
||||
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_CS) euctw '$<'
|
||||
$(TOUCH) '$@'
|
||||
|
||||
$(CHARSET_GENSRC_JAVA_DIR_CS)/sjis0213.dat: $(CHARSET_DATA_DIR)/sjis0213.map \
|
||||
$(BUILD_TOOLS_JDK)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%, %, $@))
|
||||
$(call MakeDir, $(@D))
|
||||
$(TOOL_CHARSETMAPPING) '$<' '$@' sjis0213
|
||||
|
||||
GENSRC_JDK_CHARSETS += \
|
||||
@ -86,4 +90,3 @@ jdk.charsets: $(GENSRC_JDK_CHARSETS)
|
||||
all: jdk.charsets
|
||||
|
||||
.PHONY: all jdk.charsets
|
||||
|
||||
|
@ -40,19 +40,18 @@ $(HEADER_FILE): $(JDWP_SPEC_FILE) $(BUILD_TOOLS_JDK)
|
||||
|
||||
# Touch the target of this rule at the end to avoid triggering false rebuilds
|
||||
$(JAVA_FILE): $(JDWP_SPEC_FILE) $(BUILD_TOOLS_JDK) $(HEADER_FILE)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(MKDIR) -p $(SUPPORT_OUTPUTDIR)/headers/jdk.jdwp.agent
|
||||
$(call LogInfo, Creating JDWP.java and JDWPCommands.h from jdwp.spec)
|
||||
$(call MakeDir, $(@D) $(SUPPORT_OUTPUTDIR)/headers/jdk.jdwp.agent)
|
||||
$(RM) $@ $(SUPPORT_OUTPUTDIR)/headers/jdk.jdwp.agent/JDWPCommands.h
|
||||
$(ECHO) $(LOG_INFO) Creating JDWP.java and JDWPCommands.h from jdwp.spec
|
||||
$(TOOL_JDWPGEN) $< -jdi $@ -include \
|
||||
$(SUPPORT_OUTPUTDIR)/headers/jdk.jdwp.agent/JDWPCommands.h
|
||||
$(TOUCH) $@
|
||||
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/jdwp-protocol.html: $(JDWP_SPEC_FILE) \
|
||||
$(BUILD_TOOLS_JDK)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call LogInfo, Creating $(@F) from jdwp.spec)
|
||||
$(call MakeDir, $(@D))
|
||||
$(RM) $@
|
||||
$(ECHO) $(LOG_INFO) Creating $(@F) from jdwp.spec
|
||||
$(TOOL_JDWPGEN) $< -doc $@
|
||||
|
||||
GENSRC_JDWP := $(SUPPORT_OUTPUTDIR)/gensrc/jdk.jdi/com/sun/tools/jdi/JDWP.java \
|
||||
@ -63,7 +62,7 @@ GENSRC_JDK_JDI += $(GENSRC_JDWP)
|
||||
################################################################################
|
||||
|
||||
define process-provider
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call MakeDir, $(@D))
|
||||
$(CAT) $^ | $(SED) -e "s/^#\[$(OPENJDK_TARGET_OS)\]//" > $@
|
||||
endef
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
GENSRC_BUFFER :=
|
||||
GENSRC_BUFFER :=
|
||||
|
||||
GENSRC_BUFFER_DST := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/nio
|
||||
|
||||
@ -31,9 +31,9 @@ GENSRC_BUFFER_SRC := $(JDK_TOPDIR)/src/java.base/share/classes/java/nio
|
||||
|
||||
###
|
||||
|
||||
$(GENSRC_BUFFER_DST)/_the.buffer.dir:
|
||||
$(ECHO) "Generating buffer classes"
|
||||
$(MKDIR) -p $(@D)
|
||||
$(GENSRC_BUFFER_DST)/_the.buffer.dir:
|
||||
$(call LogInfo, Generating buffer classes)
|
||||
$(call MakeDir, $(@D))
|
||||
$(TOUCH) $@
|
||||
|
||||
define fixRw
|
||||
|
@ -35,8 +35,8 @@ UNICODEDATA = $(JDK_TOPDIR)/make/data/unicodedata
|
||||
define SetupCharacterData
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/$1.java: \
|
||||
$(CHARACTERDATA)/$1.java.template
|
||||
$(MKDIR) -p $$(@D)
|
||||
$(ECHO) $(LOG_INFO) Generating $1.java
|
||||
$$(call LogInfo, Generating $1.java)
|
||||
$$(call MakeDir, $$(@D))
|
||||
$(TOOL_GENERATECHARACTER) $2 \
|
||||
-template $(CHARACTERDATA)/$1.java.template \
|
||||
-spec $(UNICODEDATA)/UnicodeData.txt \
|
||||
@ -56,7 +56,7 @@ $(eval $(call SetupCharacterData,CharacterData0E, -plane 14, 11 4 1))
|
||||
|
||||
# Copy two Java files that need no preprocessing.
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/%.java: $(CHARACTERDATA)/%.java.template
|
||||
$(ECHO) $(LOG_INFO) Generating $(@F)
|
||||
$(call LogInfo, Generating $(@F))
|
||||
$(call install-file)
|
||||
|
||||
GENSRC_CHARACTERDATA += $(SUPPORT_OUTPUTDIR)/gensrc/java.base/java/lang/CharacterDataUndefined.java \
|
||||
|
@ -44,13 +44,13 @@ $(CHARSET_DONE_BASE)-stdcs: $(CHARSET_DATA_DIR)/charsets \
|
||||
$(wildcard $(CHARSET_DATA_DIR)/$(CHARSET_STANDARD_OS)) \
|
||||
$(CHARSET_TEMPLATES) $(CHARSET_STANDARD_JAVA_TEMPLATES) \
|
||||
$(BUILD_TOOLS_JDK)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call LogInfo, Generating java.base charset mapping)
|
||||
$(call MakeDir, $(@D))
|
||||
$(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR_BASE) \
|
||||
stdcs charsets $(CHARSET_STANDARD_OS) \
|
||||
$(CHARSET_STANDARD_JAVA_TEMPLATES) $(CHARSET_EXTSRC_DIR) \
|
||||
$(CHARSET_COPYRIGHT_HEADER) \
|
||||
$(LOG_INFO)
|
||||
$(LOG_DEBUG)
|
||||
$(TOUCH) '$@'
|
||||
|
||||
GENSRC_JAVA_BASE += $(CHARSET_DONE_BASE)-stdcs
|
||||
|
||||
|
@ -32,21 +32,12 @@ GENSRC_EXCEPTIONS_CMD := $(JDK_TOPDIR)/make/scripts/genExceptions.sh
|
||||
|
||||
GENSRC_EXCEPTIONS_SRC_DIRS := . charset channels
|
||||
|
||||
###
|
||||
|
||||
$(GENSRC_EXCEPTIONS_DST)/_the.exceptions.dir:
|
||||
$(ECHO) "Generating exceptions classes"
|
||||
$(MKDIR) -p $(@D)
|
||||
$(TOUCH) $@
|
||||
|
||||
|
||||
###
|
||||
|
||||
$(GENSRC_EXCEPTIONS_DST)/_the.%.marker: $(GENSRC_EXCEPTIONS_SRC)/%/exceptions \
|
||||
$(GENSRC_EXCEPTIONS_CMD) \
|
||||
$(GENSRC_EXCEPTIONS_DST)/_the.exceptions.dir
|
||||
$(MKDIR) -p $(@D)/$*
|
||||
SCRIPTS="$(JDK_TOPDIR)/make/scripts" NAWK="$(NAWK)" SH="$(SH)" $(SH) $(GENSRC_EXCEPTIONS_CMD) $< $(@D)/$* $(LOG_INFO)
|
||||
$(GENSRC_EXCEPTIONS_CMD)
|
||||
$(call LogInfo, Generating exceptions java.nio $*)
|
||||
$(call MakeDir, $(@D)/$*)
|
||||
SCRIPTS="$(JDK_TOPDIR)/make/scripts" NAWK="$(NAWK)" SH="$(SH)" $(SH) \
|
||||
$(GENSRC_EXCEPTIONS_CMD) $< $(@D)/$* $(LOG_DEBUG)
|
||||
$(TOUCH) $@
|
||||
|
||||
GENSRC_EXCEPTIONS += $(foreach D,$(GENSRC_EXCEPTIONS_SRC_DIRS),$(GENSRC_EXCEPTIONS_DST)/_the.$(D).marker)
|
||||
|
@ -65,8 +65,8 @@ GENSRC_AWT_ICONS_DST_NAME = AWTIcon$(2)_$(subst .,_,$(subst -,_,$(1)))
|
||||
################################################################################
|
||||
|
||||
$(GENSRC_AWT_ICONS_TMP)/_the.icons.dir:
|
||||
$(ECHO) Generating icon classes
|
||||
$(MKDIR) -p $(GENSRC_AWT_ICONS_DST)
|
||||
$(call LogInfo, Generating icon classes)
|
||||
$(call MakeDir, $(GENSRC_AWT_ICONS_DST))
|
||||
$(TOUCH) $@
|
||||
|
||||
################################################################################
|
||||
@ -121,8 +121,9 @@ ifeq ($(OPENJDK_TARGET_OS), macosx)
|
||||
endif
|
||||
|
||||
$(GENSRC_OSX_ICONS): $(GENSRC_OSX_ICONS_SRC) $(BUILD_TOOLS_JDK)
|
||||
$(call LogInfo, Generating $(patsubst $(OUTPUT_ROOT)/%, %, $@))
|
||||
$(call MakeDir, $(@D))
|
||||
$(RM) $@ $@.tmp
|
||||
$(MKDIR) -p $(dir $@)
|
||||
$(ECHO) "static unsigned char sAWTIconData[] = { " >> $@.tmp
|
||||
$(CAT) $< | $(TOOL_OSX_TOBIN) >> $@.tmp
|
||||
$(ECHO) "};" >> $@.tmp
|
||||
|
@ -28,8 +28,9 @@
|
||||
# into LocaleDataMetaInfo.java
|
||||
|
||||
# First go look for all locale files
|
||||
LOCALE_FILES := $(shell $(FIND) $(JDK_TOPDIR)/src/java.base/share/classes \
|
||||
$(JDK_TOPDIR)/src/jdk.localedata/share/classes \
|
||||
LOCALE_FILES := $(shell $(FIND) \
|
||||
$(JDK_TOPDIR)/src/$(MODULE)/share/classes/sun/text/resources \
|
||||
$(JDK_TOPDIR)/src/$(MODULE)/share/classes/sun/util/resources \
|
||||
-name "FormatData_*.java" -o -name "FormatData_*.properties" -o \
|
||||
-name "CollationData_*.java" -o -name "CollationData_*.properties" -o \
|
||||
-name "TimeZoneNames_*.java" -o -name "TimeZoneNames_*.properties" -o \
|
||||
@ -42,17 +43,21 @@ LOCALE_FILES := $(shell $(FIND) $(JDK_TOPDIR)/src/java.base/share/classes \
|
||||
LOCALE_RESOURCES := $(sort $(subst .properties,,$(subst .java,,$(notdir $(LOCALE_FILES)))))
|
||||
|
||||
# Include the list of resources found during the previous compile.
|
||||
-include $(SUPPORT_OUTPUTDIR)/gensrc/_the.locale_resources
|
||||
-include $(SUPPORT_OUTPUTDIR)/gensrc/$(MODULE)/_the.locale_resources
|
||||
|
||||
MISSING_RESOURCES := $(filter-out $(LOCALE_RESOURCES), $(PREV_LOCALE_RESOURCES))
|
||||
NEW_RESOURCES := $(filter-out $(PREV_LOCALE_RESOURCES), $(LOCALE_RESOURCES))
|
||||
|
||||
ifneq (, $(MISSING_RESOURCES)$(NEW_RESOURCES))
|
||||
# There is a difference in the number of supported resources. Trigger a regeneration.
|
||||
$(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/locale/provider/BaseLocaleDataMetaInfo.java \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/provider/NonBaseLocaleDataMetaInfo.java \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/cldr/CLDRBaseLocaleDataMetaInfo.java \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/cldr/provider/CLDRLocaleDataMetaInfo_jdk_localedata.java)
|
||||
ifeq ($(MODULE), java.base)
|
||||
$(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/locale/provider/BaseLocaleDataMetaInfo.java \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/cldr/CLDRBaseLocaleDataMetaInfo.java)
|
||||
endif
|
||||
ifeq ($(MODULE), jdk.localedata)
|
||||
$(shell $(RM) $(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/provider/NonBaseLocaleDataMetaInfo.java \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/cldr/provider/CLDRLocaleDataMetaInfo_jdk_localedata.java)
|
||||
endif
|
||||
endif
|
||||
|
||||
# The base locales
|
||||
@ -121,18 +126,18 @@ SED_NONBASEARGS += -e 's/$(HASH)AvailableLocales_Locales$(HASH)/$(sort $(ALL_NON
|
||||
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/locale/provider/BaseLocaleDataMetaInfo.java: \
|
||||
$(JDK_TOPDIR)/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template
|
||||
$(call LogInfo, Creating sun/util/locale/provider/BaseLocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(ECHO) Creating sun/util/locale/provider/BaseLocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources.
|
||||
$(PRINTF) "PREV_LOCALE_RESOURCES:=$(LOCALE_RESOURCES)" \
|
||||
> $(SUPPORT_OUTPUTDIR)/gensrc/_the.locale_resources
|
||||
> $(SUPPORT_OUTPUTDIR)/gensrc/java.base/_the.locale_resources
|
||||
$(SED) $(SED_BASEARGS) $< > $@
|
||||
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/sun/util/resources/provider/NonBaseLocaleDataMetaInfo.java: \
|
||||
$(JDK_TOPDIR)/src/java.base/share/classes/sun/util/locale/provider/LocaleDataMetaInfo-XLocales.java.template
|
||||
$(call LogInfo, Creating sun/util/resources/provider/NonBaseLocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(ECHO) Creating sun/util/resources/provider/NonBaseLocaleDataMetaInfo.java from $(words $(LOCALE_RESOURCES)) found resources.
|
||||
$(PRINTF) "PREV_LOCALE_RESOURCES:=$(LOCALE_RESOURCES)" \
|
||||
> $(SUPPORT_OUTPUTDIR)/gensrc/_the.locale_resources
|
||||
> $(SUPPORT_OUTPUTDIR)/gensrc/jdk.localedata/_the.locale_resources
|
||||
$(SED) $(SED_NONBASEARGS) $< > $@
|
||||
|
||||
GENSRC_BASELOCALEDATA := $(SUPPORT_OUTPUTDIR)/gensrc/java.base/sun/util/locale/provider/BaseLocaleDataMetaInfo.java
|
||||
|
@ -50,7 +50,7 @@ GENSRC_SOR_BIN := $(BUILDTOOLS_OUTPUTDIR)/native/genSocketOptionRegistry
|
||||
SOR_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_SOR_SRC)/$(GENSRC_SOR_SRC_FILE) | \
|
||||
$(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }')
|
||||
|
||||
$(eval $(call SetupNativeCompilation,BUILD_GENSRC_SOR_EXE, \
|
||||
$(eval $(call SetupNativeCompilation, BUILD_GENSRC_SOR_EXE, \
|
||||
SRC := $(GENSRC_SOR_SRC), \
|
||||
INCLUDE_FILES := $(GENSRC_SOR_SRC_FILE), \
|
||||
TOOLCHAIN := TOOLCHAIN_BUILD, \
|
||||
@ -86,7 +86,7 @@ ifneq ($(OPENJDK_TARGET_OS), windows)
|
||||
UC_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_UC_SRC)/$(GENSRC_UC_SRC_FILE) | \
|
||||
$(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }')
|
||||
|
||||
$(eval $(call SetupNativeCompilation,BUILD_GENSRC_UC_EXE, \
|
||||
$(eval $(call SetupNativeCompilation, BUILD_GENSRC_UC_EXE, \
|
||||
SRC := $(GENSRC_UC_SRC), \
|
||||
INCLUDE_FILES := $(GENSRC_UC_SRC_FILE), \
|
||||
TOOLCHAIN := TOOLCHAIN_BUILD, \
|
||||
@ -124,7 +124,7 @@ ifeq ($(OPENJDK_TARGET_OS), solaris)
|
||||
SOL_COPYRIGHT_YEARS = $(shell $(CAT) $(GENSRC_SOL_SRC)/$(GENSRC_SOL_SRC_FILE) | \
|
||||
$(NAWK) '/^.*Copyright.*Oracle/ { printf "%s %s",$$4,$$5 }')
|
||||
|
||||
$(eval $(call SetupNativeCompilation,BUILD_GENSRC_SOL_EXE, \
|
||||
$(eval $(call SetupNativeCompilation, BUILD_GENSRC_SOL_EXE, \
|
||||
SRC := $(GENSRC_SOL_SRC), \
|
||||
INCLUDE_FILES := $(GENSRC_SOL_SRC_FILE), \
|
||||
TOOLCHAIN := TOOLCHAIN_BUILD, \
|
||||
|
@ -75,7 +75,7 @@ define SetupCompilePropertiesBody
|
||||
|
||||
# Convert .../src/<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN.properties
|
||||
# to .../support/gensrc/<module>/com/sun/tools/javac/resources/javac_zh_CN.java
|
||||
# Strip away prefix and suffix, leaving for example only:
|
||||
# Strip away prefix and suffix, leaving for example only:
|
||||
# "<module>/share/classes/com/sun/tools/javac/resources/javac_zh_CN"
|
||||
$1_JAVAS := $$(patsubst $$($1_MODULE_PATH_ROOT)/%, \
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/%, \
|
||||
|
@ -31,12 +31,11 @@ NIMBUS_GENSRC_DIR = $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/javax/swing/plaf/ni
|
||||
NIMBUS_SKIN_FILE = $(JDK_TOPDIR)/src/java.desktop/share/classes/javax/swing/plaf/nimbus/skin.laf
|
||||
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/_the.generated_nimbus: $(NIMBUS_SKIN_FILE) $(BUILD_TOOLS_JDK)
|
||||
$(call LogInfo, Generating Nimbus source files)
|
||||
$(MKDIR) -p $(@D)
|
||||
$(ECHO) "Generating Nimbus source files"
|
||||
$(TOOL_GENERATENIMBUS) $(LOG_INFO) \
|
||||
$(TOOL_GENERATENIMBUS) $(LOG_DEBUG) \
|
||||
-skinFile $(NIMBUS_SKIN_FILE) -buildDir $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop \
|
||||
-packagePrefix $(NIMBUS_PACKAGE).nimbus -lafName Nimbus
|
||||
$(ECHO) $(LOG_INFO) "Finished generating Nimbus source files"
|
||||
$(TOUCH) $@
|
||||
|
||||
GENSRC_SWING_NIMBUS := $(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/_the.generated_nimbus
|
||||
|
@ -63,14 +63,14 @@ GENSRC_X11_SIZES_USED := $(addprefix $(GENSRC_X11WRAPPERS_TMP)/sizes., $(GENSRC_
|
||||
# Copy only the sizes.* files that are actually needed. WrapperGenerator picks up any it finds from the
|
||||
# file prefix it is given so those not needed need to be hidden.
|
||||
$(GENSRC_X11WRAPPERS_TMP)/sizes.%: $(GENSRC_SIZER_DIR)/sizes.%
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call MakeDir, $(@D))
|
||||
$(RM) '$@'
|
||||
$(SORT) $< > $@
|
||||
|
||||
# Run the tool on the offset files copied from the source repository to generate several Java classes
|
||||
# used in awt.
|
||||
$(SUPPORT_OUTPUTDIR)/gensrc/java.desktop/_the.generated.x11: $(GENSRC_X11_SIZES_USED) $(BUILD_TOOLS_JDK)
|
||||
$(MKDIR) -p $(GENSRC_X11WRAPPERS_DST)
|
||||
$(call MakeDir, $(GENSRC_X11WRAPPERS_DST))
|
||||
$(TOOL_WRAPPERGENERATOR) $(GENSRC_X11WRAPPERS_DST) $(GENSRC_SIZER_DIR)/xlibtypes.txt "gen" $(GENSRC_X11WRAPPERS_TMP)/sizes
|
||||
$(TOUCH) $@
|
||||
|
||||
@ -82,8 +82,8 @@ ifneq ($(COMPILE_TYPE), cross)
|
||||
|
||||
# Generate the C code for the program that will output the offset file.
|
||||
$(GENSRC_X11WRAPPERS_TMP)/sizer.%.c: $(GENSRC_SIZER_DIR)/xlibtypes.txt $(BUILD_TOOLS_JDK)
|
||||
$(ECHO) "Generating X11 wrapper ($*-bit version)"
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call LogInfo, Generating X11 wrapper ($*-bit version))
|
||||
$(call MakeDir, $(@D))
|
||||
$(TOOL_WRAPPERGENERATOR) $(@D) $(GENSRC_SIZER_DIR)/xlibtypes.txt "sizer" $*
|
||||
|
||||
# use -m32/-m64 only if the compiler supports it
|
||||
@ -103,7 +103,7 @@ ifneq ($(COMPILE_TYPE), cross)
|
||||
|
||||
# Compile the C code into an executable.
|
||||
$(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe: $(GENSRC_X11WRAPPERS_TMP)/sizer.%.c
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call MakeDir, $(@D))
|
||||
(cd $(@D) && $(CC) $(MEMORY_MODEL_FLAG) -o $@ $< \
|
||||
$(X_CFLAGS) \
|
||||
$(X_LIBS) \
|
||||
@ -114,9 +114,9 @@ ifneq ($(COMPILE_TYPE), cross)
|
||||
# Run the executable create the offset file and check that it is identical
|
||||
# to the offset file in the source code repository.
|
||||
$(GENSRC_X11WRAPPERS_TMP)/sizes.%.verification: $(GENSRC_X11WRAPPERS_TMP)/sizer.%.exe
|
||||
$(MKDIR) -p $(@D)
|
||||
$(call LogInfo, Verifying X11 wrapper sizes)
|
||||
$(call MakeDir, $(@D))
|
||||
$(GENSRC_X11WRAPPERS_TMP)/sizer.$*.exe | $(SORT) > $@.tmp
|
||||
$(ECHO) Verifying $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp to $(GENSRC_X11WRAPPERS_TMP)/sizes.$*
|
||||
$(DIFF) $(GENSRC_X11WRAPPERS_TMP)/sizes.$*.verification.tmp $(GENSRC_X11WRAPPERS_TMP)/sizes.$*
|
||||
mv $@.tmp $@
|
||||
|
||||
|
@ -31,9 +31,6 @@ ifeq ($(OPENJDK_TARGET_OS), macosx)
|
||||
ENABLE_DEBUG_SYMBOLS := false
|
||||
endif
|
||||
|
||||
# Prepare the find cache.
|
||||
$(eval $(call FillCacheFind, $(JDK_TOPDIR)/src/java.base/share/native/launcher))
|
||||
|
||||
ifeq ($(OPENJDK_TARGET_OS), macosx)
|
||||
ORIGIN_ARG := $(call SET_EXECUTABLE_ORIGIN)
|
||||
else
|
||||
@ -124,7 +121,7 @@ define SetupBuildLauncherBody
|
||||
$1_LDFLAGS += -exported_symbols_list \
|
||||
$(SUPPORT_OUTPUTDIR)/build-static/exported.symbols
|
||||
$1_LIBS += \
|
||||
$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/java.base -name "*.a") \
|
||||
$$(shell $(FIND) $(SUPPORT_OUTPUTDIR)/modules_libs/java.base -name "*.a") \
|
||||
$(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libdt_socket.a \
|
||||
$(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/libjdwp.a \
|
||||
$(SUPPORT_OUTPUTDIR)/native/java.base/$(LIBRARY_PREFIX)fdlibm$(STATIC_LIBRARY_SUFFIX) \
|
||||
@ -174,8 +171,7 @@ define SetupBuildLauncherBody
|
||||
endif
|
||||
|
||||
$$(eval $$(call SetupNativeCompilation, BUILD_LAUNCHER_$1, \
|
||||
SRC := $(LAUNCHER_SRC), \
|
||||
INCLUDE_FILES := main.c, \
|
||||
EXTRA_FILES := $(LAUNCHER_SRC)/main.c, \
|
||||
OPTIMIZATION := $$($1_OPTIMIZATION), \
|
||||
CFLAGS := $$($1_CFLAGS) \
|
||||
$(LAUNCHER_CFLAGS) \
|
||||
|
@ -750,7 +750,8 @@ ifeq ($(OPENJDK_TARGET_OS), windows)
|
||||
$(BUILD_LIBJAWT): $(BUILD_LIBAWT)
|
||||
|
||||
$(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX): $(BUILD_LIBJAWT)
|
||||
$(ECHO) Copying $(@F)
|
||||
$(call LogInfo, Copying $(patsubst $(OUTPUT_ROOT)/%, %, $@))
|
||||
$(call MakeDir, $(@D))
|
||||
$(CP) $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjawt/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX) $@
|
||||
|
||||
TARGETS += $(JDK_OUTPUTDIR)/lib/$(LIBRARY_PREFIX)jawt$(STATIC_LIBRARY_SUFFIX)
|
||||
|
@ -49,7 +49,7 @@ ifeq ($(STATIC_BUILD), true)
|
||||
JAVA_BASE_EXPORT_SYMBOL_FILE := $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/java.base.symbols
|
||||
|
||||
$(JAVA_BASE_EXPORT_SYMBOL_FILE): $(JAVA_BASE_EXPORT_SYMBOLS_SRC)
|
||||
$(ECHO) $(LOG_INFO) "Generating java.base.symbols file"
|
||||
$(call LogInfo, Generating java.base.symbols file)
|
||||
$(CAT) $^ > $@
|
||||
|
||||
# The individual symbol files is generated when the respective lib is built
|
||||
|
@ -111,7 +111,7 @@ ifeq ($(STATIC_BUILD), true)
|
||||
JDK_JDWP_AGENT_EXPORT_SYMBOL_FILE := $(SUPPORT_OUTPUTDIR)/modules_libs/jdk.jdwp.agent/jdk.jdwp.agent.symbols
|
||||
|
||||
$(JDK_JDWP_AGENT_EXPORT_SYMBOL_FILE): $(JDK_JDWP_AGENT_EXPORT_SYMBOLS_SRC)
|
||||
$(ECHO) $(LOG_INFO) "Generating jdk.jdwp.agent symbols file"
|
||||
$(call LogInfo, Generating jdk.jdwp.agent symbols file)
|
||||
$(CAT) $^ > $@
|
||||
|
||||
# The individual symbol files is generated when the respective lib is built
|
||||
|
@ -23,8 +23,6 @@
|
||||
# questions.
|
||||
#
|
||||
|
||||
include $(SPEC)
|
||||
include MakeBase.gmk
|
||||
include NativeCompilation.gmk
|
||||
|
||||
# Hook to include the corresponding custom file, if present.
|
||||
@ -92,3 +90,5 @@ ifeq ($(USE_EXTERNAL_LIBZ), true)
|
||||
else
|
||||
ZLIB_CPPFLAGS := -I$(JDK_TOPDIR)/src/java.base/share/native/libzip/zlib-1.2.8
|
||||
endif
|
||||
|
||||
###############################################################################
|
||||
|
@ -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");
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -47,6 +47,9 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
|
||||
if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
|
||||
super.setOption(name, value);
|
||||
} else {
|
||||
if (!flowSupported()) {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
if (isClosed()) {
|
||||
throw new SocketException("Socket closed");
|
||||
}
|
||||
@ -61,6 +64,9 @@ class PlainDatagramSocketImpl extends AbstractPlainDatagramSocketImpl
|
||||
if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
|
||||
return super.getOption(name);
|
||||
}
|
||||
if (!flowSupported()) {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
if (isClosed()) {
|
||||
throw new SocketException("Socket closed");
|
||||
}
|
||||
|
@ -61,6 +61,9 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
|
||||
if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
|
||||
super.setOption(name, value);
|
||||
} else {
|
||||
if (getSocket() == null || !flowSupported()) {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
if (isClosedOrPending()) {
|
||||
throw new SocketException("Socket closed");
|
||||
}
|
||||
@ -75,6 +78,9 @@ class PlainSocketImpl extends AbstractPlainSocketImpl
|
||||
if (!name.equals(ExtendedSocketOptions.SO_FLOW_SLA)) {
|
||||
return super.getOption(name);
|
||||
}
|
||||
if (getSocket() == null || !flowSupported()) {
|
||||
throw new UnsupportedOperationException("unsupported option");
|
||||
}
|
||||
if (isClosedOrPending()) {
|
||||
throw new SocketException("Socket closed");
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
# Copyright (c) 2013, 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
|
||||
@ -31,7 +31,8 @@ tier1 = \
|
||||
-java/util/zip/TestLocalTime.java \
|
||||
:jdk_util \
|
||||
-java/util/WeakHashMap/GCDuringIteration.java \
|
||||
-java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java
|
||||
-java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \
|
||||
-java/util/concurrent/forkjoin/FJExceptionTableLeak.java \
|
||||
sun/nio/cs/ISO8859x.java \
|
||||
java/nio/Buffer \
|
||||
com/sun/crypto/provider/Cipher \
|
||||
@ -42,6 +43,7 @@ tier2 = \
|
||||
java/util/zip/TestLocalTime.java \
|
||||
java/util/WeakHashMap/GCDuringIteration.java \
|
||||
java/util/concurrent/ThreadPoolExecutor/ConfigChanges.java \
|
||||
java/util/concurrent/forkjoin/FJExceptionTableLeak.java \
|
||||
:jdk_io \
|
||||
:jdk_nio \
|
||||
-sun/nio/cs/ISO8859x.java \
|
||||
|
141
jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java
Normal file
141
jdk/test/java/net/SocketOption/UnsupportedOptionsTest.java
Normal file
@ -0,0 +1,141 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
import jdk.net.ExtendedSocketOptions;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.*;
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8143554
|
||||
* @run main UnsupportedOptionsTest
|
||||
* @summary Test checks that UnsupportedOperationException for unsupported
|
||||
* SOCKET_OPTIONS is thrown by both getOption() and setOption() methods.
|
||||
*/
|
||||
public class UnsupportedOptionsTest {
|
||||
|
||||
private static final SocketOption[] SOCKET_OPTIONS = {
|
||||
StandardSocketOptions.IP_MULTICAST_IF,
|
||||
StandardSocketOptions.IP_MULTICAST_LOOP,
|
||||
StandardSocketOptions.IP_MULTICAST_TTL,
|
||||
StandardSocketOptions.IP_TOS,
|
||||
StandardSocketOptions.SO_BROADCAST,
|
||||
StandardSocketOptions.SO_KEEPALIVE,
|
||||
StandardSocketOptions.SO_LINGER,
|
||||
StandardSocketOptions.SO_RCVBUF,
|
||||
StandardSocketOptions.SO_REUSEADDR,
|
||||
StandardSocketOptions.SO_SNDBUF,
|
||||
StandardSocketOptions.TCP_NODELAY,
|
||||
ExtendedSocketOptions.SO_FLOW_SLA
|
||||
};
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
Socket s = new Socket();
|
||||
ServerSocket ss = new ServerSocket();
|
||||
DatagramSocket ds = new DatagramSocket();
|
||||
MulticastSocket ms = new MulticastSocket();
|
||||
|
||||
for (SocketOption option : SOCKET_OPTIONS) {
|
||||
if (!s.supportedOptions().contains(option)) {
|
||||
testUnsupportedSocketOption(s, option);
|
||||
}
|
||||
|
||||
if (!ss.supportedOptions().contains(option)) {
|
||||
testUnsupportedSocketOption(ss, option);
|
||||
}
|
||||
|
||||
if (!ms.supportedOptions().contains(option)) {
|
||||
testUnsupportedSocketOption(ms, option);
|
||||
}
|
||||
|
||||
if (!ds.supportedOptions().contains(option)) {
|
||||
testUnsupportedSocketOption(ds, option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check that UnsupportedOperationException for unsupported option is
|
||||
* thrown from both getOption() and setOption() methods.
|
||||
*/
|
||||
private static void testUnsupportedSocketOption(Object socket,
|
||||
SocketOption option) {
|
||||
testSet(socket, option);
|
||||
testGet(socket, option);
|
||||
}
|
||||
|
||||
private static void testSet(Object socket, SocketOption option) {
|
||||
try {
|
||||
setOption(socket, option);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
System.out.println("UnsupportedOperationException was throw " +
|
||||
"as expected. Socket: " + socket + " Option: " + option);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("FAIL. Unexpected exception.", e);
|
||||
}
|
||||
throw new RuntimeException("FAIL. UnsupportedOperationException " +
|
||||
"hasn't been thrown. Socket: " + socket + " Option: " + option);
|
||||
}
|
||||
|
||||
private static void testGet(Object socket, SocketOption option) {
|
||||
try {
|
||||
getOption(socket, option);
|
||||
} catch (UnsupportedOperationException e) {
|
||||
System.out.println("UnsupportedOperationException was throw " +
|
||||
"as expected. Socket: " + socket + " Option: " + option);
|
||||
return;
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("FAIL. Unexpected exception.", e);
|
||||
}
|
||||
throw new RuntimeException("FAIL. UnsupportedOperationException " +
|
||||
"hasn't been thrown. Socket: " + socket + " Option: " + option);
|
||||
}
|
||||
|
||||
private static void getOption(Object socket,
|
||||
SocketOption option) throws IOException {
|
||||
if (socket instanceof Socket) {
|
||||
((Socket) socket).getOption(option);
|
||||
} else if (socket instanceof ServerSocket) {
|
||||
((ServerSocket) socket).getOption(option);
|
||||
} else if (socket instanceof DatagramSocket) {
|
||||
((DatagramSocket) socket).getOption(option);
|
||||
} else {
|
||||
throw new RuntimeException("Unsupported socket type");
|
||||
}
|
||||
}
|
||||
|
||||
private static void setOption(Object socket,
|
||||
SocketOption option) throws IOException {
|
||||
if (socket instanceof Socket) {
|
||||
((Socket) socket).setOption(option, null);
|
||||
} else if (socket instanceof ServerSocket) {
|
||||
((ServerSocket) socket).setOption(option, null);
|
||||
} else if (socket instanceof DatagramSocket) {
|
||||
((DatagramSocket) socket).setOption(option, null);
|
||||
} else {
|
||||
throw new RuntimeException("Unsupported socket type");
|
||||
}
|
||||
}
|
||||
}
|
@ -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
|
||||
@ -22,8 +22,8 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4286936 8146213
|
||||
* @summary Unit test for server-socket-channel adaptors
|
||||
* @key intermittent
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
@ -77,6 +77,9 @@ public class AdaptServerSocket {
|
||||
static void test(int clientDally, int timeout, boolean shouldTimeout)
|
||||
throws Exception
|
||||
{
|
||||
boolean needClient = !shouldTimeout;
|
||||
client = null;
|
||||
clientException = null;
|
||||
clientStarted = false;
|
||||
out.println();
|
||||
|
||||
@ -90,9 +93,11 @@ public class AdaptServerSocket {
|
||||
sso.bind(null);
|
||||
out.println("bound: " + ssc);
|
||||
out.println(" " + sso);
|
||||
startClient(sso.getLocalPort(), clientDally);
|
||||
while (!clientStarted) {
|
||||
Thread.sleep(20);
|
||||
if (needClient) {
|
||||
startClient(sso.getLocalPort(), clientDally);
|
||||
while (!clientStarted) {
|
||||
Thread.sleep(20);
|
||||
}
|
||||
}
|
||||
Socket so = null;
|
||||
try {
|
||||
@ -115,10 +120,12 @@ public class AdaptServerSocket {
|
||||
out.println("server: read " + b);
|
||||
}
|
||||
}
|
||||
client.interrupt();
|
||||
client.join();
|
||||
if (clientException != null)
|
||||
throw clientException;
|
||||
if (needClient) {
|
||||
client.interrupt();
|
||||
client.join();
|
||||
if (clientException != null)
|
||||
throw clientException;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2001, 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
|
||||
@ -22,6 +22,7 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4286936 8143100
|
||||
* @summary Unit test for server-socket channels
|
||||
* @library ..
|
||||
*/
|
||||
@ -130,7 +131,7 @@ public class Basic {
|
||||
Client client = new Client(port, block);
|
||||
server.start();
|
||||
client.start();
|
||||
if ((server.finish(2000) & client.finish(100)) == 0)
|
||||
if ((server.finish(0) & client.finish(0)) == 0)
|
||||
throw new Exception("Failure");
|
||||
log.println();
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2004, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 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
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 4801882 5046333
|
||||
* @bug 4801882 5046333 8141595
|
||||
* @summary test ServerSocketAdaptor.accept on nonblocking channel
|
||||
* @library ..
|
||||
* @build TestUtil
|
||||
@ -57,8 +57,17 @@ public class NonBlockingAccept {
|
||||
SocketChannel sc = SocketChannel.open();
|
||||
sc.configureBlocking(false);
|
||||
sc.connect(isa);
|
||||
Thread.sleep(100);
|
||||
ss.accept();
|
||||
|
||||
// loop until accepted
|
||||
while (true) {
|
||||
try {
|
||||
ss.accept();
|
||||
break;
|
||||
} catch (IllegalBlockingModeException ex) {
|
||||
System.out.println(ex + ", sleeping ...");
|
||||
Thread.sleep(100);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
45
jdk/test/java/util/Locale/Bug8026766.java
Normal file
45
jdk/test/java/util/Locale/Bug8026766.java
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8026766
|
||||
* @summary Confirm that LanguageRange.toString() returns an expected result.
|
||||
* @run main Bug8026766
|
||||
*/
|
||||
|
||||
import java.util.Locale.LanguageRange;
|
||||
|
||||
public class Bug8026766 {
|
||||
|
||||
public static void main(String[] args) {
|
||||
LanguageRange lr1 = new LanguageRange("ja", 1.0);
|
||||
LanguageRange lr2 = new LanguageRange("fr", 0.0);
|
||||
|
||||
if (!lr1.toString().equals("ja") ||
|
||||
!lr2.toString().equals("fr;q=0.0")) {
|
||||
throw new RuntimeException("LanguageRange.toString() returned an unexpected result.");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -37,6 +37,7 @@
|
||||
* @bug 8004138
|
||||
* @summary Check if ForkJoinPool table leaks thrown exceptions.
|
||||
* @run main/othervm -Xmx2200k FJExceptionTableLeak
|
||||
* @key intermittent
|
||||
*/
|
||||
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
|
@ -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
|
||||
@ -35,6 +35,7 @@ import java.io.*;
|
||||
import java.net.*;
|
||||
import javax.net.ssl.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.security.KeyStore;
|
||||
|
||||
public class SSLCtxAccessToSessCtx {
|
||||
@ -63,7 +64,7 @@ public class SSLCtxAccessToSessCtx {
|
||||
/*
|
||||
* Is the server ready to serve?
|
||||
*/
|
||||
volatile static boolean serverReady = false;
|
||||
AtomicInteger serverReady = new AtomicInteger(1); // only one port now
|
||||
|
||||
/*
|
||||
* Turn on SSL debugging?
|
||||
@ -89,12 +90,13 @@ public class SSLCtxAccessToSessCtx {
|
||||
|
||||
SSLServerSocket sslServerSocket =
|
||||
(SSLServerSocket) sslssf.createServerSocket(serverPort);
|
||||
serverPorts[createdPorts++] = sslServerSocket.getLocalPort();
|
||||
int slot = createdPorts.getAndIncrement();
|
||||
serverPorts[slot] = sslServerSocket.getLocalPort();
|
||||
|
||||
/*
|
||||
* Signal Client, we're ready for his connect.
|
||||
*/
|
||||
serverReady = true;
|
||||
serverReady.getAndDecrement();
|
||||
int read = 0;
|
||||
SSLSocket sslSocket = (SSLSocket) sslServerSocket.accept();
|
||||
InputStream sslIS = sslSocket.getInputStream();
|
||||
@ -121,7 +123,7 @@ public class SSLCtxAccessToSessCtx {
|
||||
/*
|
||||
* Wait for server to get started.
|
||||
*/
|
||||
while (!serverReady) {
|
||||
while (serverReady.get() > 0) {
|
||||
Thread.sleep(50);
|
||||
}
|
||||
/*
|
||||
@ -151,8 +153,8 @@ public class SSLCtxAccessToSessCtx {
|
||||
* The remainder is just support stuff
|
||||
*/
|
||||
|
||||
volatile int serverPorts[] = new int[]{0};
|
||||
volatile int createdPorts = 0;
|
||||
int serverPorts[] = new int[]{0}; // only one port at present
|
||||
AtomicInteger createdPorts = new AtomicInteger(0);
|
||||
static SSLServerSocketFactory sslssf;
|
||||
static SSLSocketFactory sslsf;
|
||||
static SSLContext sslctx;
|
||||
@ -255,14 +257,20 @@ public class SSLCtxAccessToSessCtx {
|
||||
*/
|
||||
System.err.println("Server died...");
|
||||
e.printStackTrace();
|
||||
serverReady = true;
|
||||
serverReady.set(0);
|
||||
serverException = e;
|
||||
}
|
||||
}
|
||||
};
|
||||
serverThread.start();
|
||||
} else {
|
||||
doServerSide(port);
|
||||
try {
|
||||
doServerSide(port);
|
||||
} catch (Exception e) {
|
||||
serverException = e;
|
||||
} finally {
|
||||
serverReady.set(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,7 +292,11 @@ public class SSLCtxAccessToSessCtx {
|
||||
};
|
||||
clientThread.start();
|
||||
} else {
|
||||
doClientSide();
|
||||
try {
|
||||
doClientSide();
|
||||
} catch (Exception e) {
|
||||
clientException = e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 2015, 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
|
||||
@ -112,7 +112,8 @@ public class SessionTimeOutTests {
|
||||
|
||||
SSLServerSocket sslServerSocket =
|
||||
(SSLServerSocket) sslssf.createServerSocket(serverPort);
|
||||
serverPorts[createdPorts++] = sslServerSocket.getLocalPort();
|
||||
int slot = createdPorts.getAndIncrement();
|
||||
serverPorts[slot] = sslServerSocket.getLocalPort();
|
||||
|
||||
/*
|
||||
* Signal Client, we're ready for his connect.
|
||||
@ -288,8 +289,8 @@ public class SessionTimeOutTests {
|
||||
* The remainder is just support stuff
|
||||
*/
|
||||
|
||||
volatile int serverPorts[] = new int[PORTS];
|
||||
volatile int createdPorts = 0;
|
||||
int serverPorts[] = new int[PORTS];
|
||||
AtomicInteger createdPorts = new AtomicInteger(0);
|
||||
static SSLServerSocketFactory sslssf;
|
||||
static SSLSocketFactory sslsf;
|
||||
static SSLContext sslctx;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -37,13 +37,16 @@ public class Optimize {
|
||||
|
||||
ProtectionDomain pd1 = new ProtectionDomain(
|
||||
new CodeSource(null, (java.security.cert.Certificate[]) null),
|
||||
new Permissions());
|
||||
new Permissions(),
|
||||
null, null);
|
||||
ProtectionDomain pd2 = new ProtectionDomain(
|
||||
new CodeSource(null, (java.security.cert.Certificate[]) null),
|
||||
new Permissions());
|
||||
new Permissions(),
|
||||
null, null);
|
||||
ProtectionDomain pd3 = new ProtectionDomain(
|
||||
new CodeSource(null, (java.security.cert.Certificate[]) null),
|
||||
new Permissions());
|
||||
new Permissions(),
|
||||
null, null);
|
||||
|
||||
ProtectionDomain[] current = new ProtectionDomain[] {pd1, pd2};
|
||||
ProtectionDomain[] assigned = new ProtectionDomain[] {pd3, pd2};
|
||||
|
86
jdk/test/javax/xml/ws/publish/WSTest.java
Normal file
86
jdk/test/javax/xml/ws/publish/WSTest.java
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8146086
|
||||
* @summary Publishing two webservices on same port fails with "java.net.BindException: Address already in use"
|
||||
* @run main/othervm WSTest
|
||||
*/
|
||||
import javax.jws.WebMethod;
|
||||
import javax.jws.WebService;
|
||||
import javax.xml.ws.Endpoint;
|
||||
import java.net.ServerSocket;
|
||||
|
||||
public class WSTest {
|
||||
|
||||
@WebService(targetNamespace = "test")
|
||||
public static class Method1 {
|
||||
@WebMethod
|
||||
public String getMethod1Value() {
|
||||
return "from Method1";
|
||||
}
|
||||
}
|
||||
|
||||
@WebService(targetNamespace = "test")
|
||||
public static class Method2 {
|
||||
@WebMethod
|
||||
public String getMethod2Value() {
|
||||
return "from Method2";
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
// find a free port
|
||||
ServerSocket ss = new ServerSocket(0);
|
||||
int port = ss.getLocalPort();
|
||||
ss.close();
|
||||
|
||||
Endpoint endPoint1 = null;
|
||||
Endpoint endPoint2 = null;
|
||||
try {
|
||||
endPoint1 = Endpoint.publish("http://0.0.0.0:" + port + "/method1",
|
||||
new Method1());
|
||||
endPoint2 = Endpoint.publish("http://0.0.0.0:" + port + "/method2",
|
||||
new Method2());
|
||||
|
||||
System.out.println("Sleep 3 secs...");
|
||||
|
||||
Thread.sleep(3000);
|
||||
} finally {
|
||||
stop(endPoint2);
|
||||
stop(endPoint1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void stop(Endpoint endPoint) {
|
||||
if (endPoint == null) return;
|
||||
|
||||
try {
|
||||
endPoint.stop();
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -343,3 +343,4 @@ ae8cdc734bab4f19ef8babd2434dcf024672ad38 jdk-9+97
|
||||
345520da2ec17100cb512a53d541a307a195305e jdk-9+98
|
||||
cb73b474703e2de266542b505cffd658bcc052da jdk-9+99
|
||||
51136404ee5e6cd5868b60d66ebd55a02170b508 jdk-9+100
|
||||
3b3bea483542bc08278af529fb25f2e5930da945 jdk-9+101
|
||||
|
@ -1146,14 +1146,21 @@ public class Types {
|
||||
if (!visit(supertype(t), supertype(s)))
|
||||
return false;
|
||||
|
||||
HashSet<UniqueType> set = new HashSet<>();
|
||||
for (Type x : interfaces(t))
|
||||
set.add(new UniqueType(x, Types.this));
|
||||
for (Type x : interfaces(s)) {
|
||||
if (!set.remove(new UniqueType(x, Types.this)))
|
||||
Map<Symbol,Type> tMap = new HashMap<>();
|
||||
for (Type ti : interfaces(t)) {
|
||||
if (tMap.containsKey(ti)) {
|
||||
throw new AssertionError("Malformed intersection");
|
||||
}
|
||||
tMap.put(ti.tsym, ti);
|
||||
}
|
||||
for (Type si : interfaces(s)) {
|
||||
if (!tMap.containsKey(si.tsym))
|
||||
return false;
|
||||
Type ti = tMap.remove(si.tsym);
|
||||
if (!visit(ti, si))
|
||||
return false;
|
||||
}
|
||||
return (set.isEmpty());
|
||||
return tMap.isEmpty();
|
||||
}
|
||||
return t.tsym == s.tsym
|
||||
&& visit(t.getEnclosingType(), s.getEnclosingType())
|
||||
|
@ -1137,7 +1137,56 @@ public class Resolve {
|
||||
|
||||
/** Parameters {@code t} and {@code s} are unrelated functional interface types. */
|
||||
private boolean functionalInterfaceMostSpecific(Type t, Type s, JCTree tree) {
|
||||
FunctionalInterfaceMostSpecificChecker msc = new FunctionalInterfaceMostSpecificChecker(t, s);
|
||||
Type tDesc = types.findDescriptorType(t);
|
||||
Type sDesc = types.findDescriptorType(s);
|
||||
|
||||
// compare type parameters -- can't use Types.hasSameBounds because bounds may have ivars
|
||||
final List<Type> tTypeParams = tDesc.getTypeArguments();
|
||||
final List<Type> sTypeParams = sDesc.getTypeArguments();
|
||||
List<Type> tIter = tTypeParams;
|
||||
List<Type> sIter = sTypeParams;
|
||||
while (tIter.nonEmpty() && sIter.nonEmpty()) {
|
||||
Type tBound = tIter.head.getUpperBound();
|
||||
Type sBound = types.subst(sIter.head.getUpperBound(), sTypeParams, tTypeParams);
|
||||
if (tBound.containsAny(tTypeParams) && inferenceContext().free(sBound)) {
|
||||
return false;
|
||||
}
|
||||
if (!types.isSameType(tBound, inferenceContext().asUndetVar(sBound))) {
|
||||
return false;
|
||||
}
|
||||
tIter = tIter.tail;
|
||||
sIter = sIter.tail;
|
||||
}
|
||||
if (!tIter.isEmpty() || !sIter.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// compare parameters
|
||||
List<Type> tParams = tDesc.getParameterTypes();
|
||||
List<Type> sParams = sDesc.getParameterTypes();
|
||||
while (tParams.nonEmpty() && sParams.nonEmpty()) {
|
||||
Type tParam = tParams.head;
|
||||
Type sParam = types.subst(sParams.head, sTypeParams, tTypeParams);
|
||||
if (tParam.containsAny(tTypeParams) && inferenceContext().free(sParam)) {
|
||||
return false;
|
||||
}
|
||||
if (!types.isSameType(tParam, inferenceContext().asUndetVar(sParam))) {
|
||||
return false;
|
||||
}
|
||||
tParams = tParams.tail;
|
||||
sParams = sParams.tail;
|
||||
}
|
||||
if (!tParams.isEmpty() || !sParams.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// compare returns
|
||||
Type tRet = tDesc.getReturnType();
|
||||
Type sRet = types.subst(sDesc.getReturnType(), sTypeParams, tTypeParams);
|
||||
if (tRet.containsAny(tTypeParams) && inferenceContext().free(sRet)) {
|
||||
return false;
|
||||
}
|
||||
MostSpecificFunctionReturnChecker msc = new MostSpecificFunctionReturnChecker(tRet, sRet);
|
||||
msc.scan(tree);
|
||||
return msc.result;
|
||||
}
|
||||
@ -1146,16 +1195,16 @@ public class Resolve {
|
||||
* Tests whether one functional interface type can be considered more specific
|
||||
* than another unrelated functional interface type for the scanned expression.
|
||||
*/
|
||||
class FunctionalInterfaceMostSpecificChecker extends DeferredAttr.PolyScanner {
|
||||
class MostSpecificFunctionReturnChecker extends DeferredAttr.PolyScanner {
|
||||
|
||||
final Type t;
|
||||
final Type s;
|
||||
final Type tRet;
|
||||
final Type sRet;
|
||||
boolean result;
|
||||
|
||||
/** Parameters {@code t} and {@code s} are unrelated functional interface types. */
|
||||
FunctionalInterfaceMostSpecificChecker(Type t, Type s) {
|
||||
this.t = t;
|
||||
this.s = s;
|
||||
MostSpecificFunctionReturnChecker(Type tRet, Type sRet) {
|
||||
this.tRet = tRet;
|
||||
this.sRet = sRet;
|
||||
result = true;
|
||||
}
|
||||
|
||||
@ -1172,29 +1221,18 @@ public class Resolve {
|
||||
|
||||
@Override
|
||||
public void visitReference(JCMemberReference tree) {
|
||||
Type desc_t = types.findDescriptorType(t);
|
||||
Type desc_s = types.findDescriptorType(s);
|
||||
// use inference variables here for more-specific inference (18.5.4)
|
||||
if (!types.isSameTypes(desc_t.getParameterTypes(),
|
||||
inferenceContext().asUndetVars(desc_s.getParameterTypes()))) {
|
||||
if (sRet.hasTag(VOID)) {
|
||||
result &= true;
|
||||
} else if (tRet.hasTag(VOID)) {
|
||||
result &= false;
|
||||
} else if (tRet.isPrimitive() != sRet.isPrimitive()) {
|
||||
boolean retValIsPrimitive =
|
||||
tree.refPolyKind == PolyKind.STANDALONE &&
|
||||
tree.sym.type.getReturnType().isPrimitive();
|
||||
result &= (retValIsPrimitive == tRet.isPrimitive()) &&
|
||||
(retValIsPrimitive != sRet.isPrimitive());
|
||||
} else {
|
||||
// compare return types
|
||||
Type ret_t = desc_t.getReturnType();
|
||||
Type ret_s = desc_s.getReturnType();
|
||||
if (ret_s.hasTag(VOID)) {
|
||||
result &= true;
|
||||
} else if (ret_t.hasTag(VOID)) {
|
||||
result &= false;
|
||||
} else if (ret_t.isPrimitive() != ret_s.isPrimitive()) {
|
||||
boolean retValIsPrimitive =
|
||||
tree.refPolyKind == PolyKind.STANDALONE &&
|
||||
tree.sym.type.getReturnType().isPrimitive();
|
||||
result &= (retValIsPrimitive == ret_t.isPrimitive()) &&
|
||||
(retValIsPrimitive != ret_s.isPrimitive());
|
||||
} else {
|
||||
result &= compatibleBySubtyping(ret_t, ret_s);
|
||||
}
|
||||
result &= compatibleBySubtyping(tRet, sRet);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1205,32 +1243,24 @@ public class Resolve {
|
||||
|
||||
@Override
|
||||
public void visitLambda(JCLambda tree) {
|
||||
Type desc_t = types.findDescriptorType(t);
|
||||
Type desc_s = types.findDescriptorType(s);
|
||||
// use inference variables here for more-specific inference (18.5.4)
|
||||
if (!types.isSameTypes(desc_t.getParameterTypes(),
|
||||
inferenceContext().asUndetVars(desc_s.getParameterTypes()))) {
|
||||
if (sRet.hasTag(VOID)) {
|
||||
result &= true;
|
||||
} else if (tRet.hasTag(VOID)) {
|
||||
result &= false;
|
||||
} else {
|
||||
// compare return types
|
||||
Type ret_t = desc_t.getReturnType();
|
||||
Type ret_s = desc_s.getReturnType();
|
||||
if (ret_s.hasTag(VOID)) {
|
||||
result &= true;
|
||||
} else if (ret_t.hasTag(VOID)) {
|
||||
result &= false;
|
||||
} else if (unrelatedFunctionalInterfaces(ret_t, ret_s)) {
|
||||
for (JCExpression expr : lambdaResults(tree)) {
|
||||
result &= functionalInterfaceMostSpecific(ret_t, ret_s, expr);
|
||||
List<JCExpression> lambdaResults = lambdaResults(tree);
|
||||
if (!lambdaResults.isEmpty() && unrelatedFunctionalInterfaces(tRet, sRet)) {
|
||||
for (JCExpression expr : lambdaResults) {
|
||||
result &= functionalInterfaceMostSpecific(tRet, sRet, expr);
|
||||
}
|
||||
} else if (ret_t.isPrimitive() != ret_s.isPrimitive()) {
|
||||
for (JCExpression expr : lambdaResults(tree)) {
|
||||
} else if (!lambdaResults.isEmpty() && tRet.isPrimitive() != sRet.isPrimitive()) {
|
||||
for (JCExpression expr : lambdaResults) {
|
||||
boolean retValIsPrimitive = expr.isStandalone() && expr.type.isPrimitive();
|
||||
result &= (retValIsPrimitive == ret_t.isPrimitive()) &&
|
||||
(retValIsPrimitive != ret_s.isPrimitive());
|
||||
result &= (retValIsPrimitive == tRet.isPrimitive()) &&
|
||||
(retValIsPrimitive != sRet.isPrimitive());
|
||||
}
|
||||
} else {
|
||||
result &= compatibleBySubtyping(ret_t, ret_s);
|
||||
result &= compatibleBySubtyping(tRet, sRet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 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
|
||||
@ -301,15 +301,16 @@ public class JavaTokenizer {
|
||||
}
|
||||
|
||||
/** Read a number.
|
||||
* @param radix The radix of the number; one of 2, j8, 10, 16.
|
||||
* @param radix The radix of the number; one of 2, 8, 10, 16.
|
||||
*/
|
||||
private void scanNumber(int pos, int radix) {
|
||||
// for octal, allow base-10 digit in case it's a float literal
|
||||
this.radix = radix;
|
||||
int digitRadix = (radix == 8 ? 10 : radix);
|
||||
boolean seendigit = false;
|
||||
if (reader.digit(pos, digitRadix) >= 0) {
|
||||
seendigit = true;
|
||||
int firstDigit = reader.digit(pos, Math.max(10, digitRadix));
|
||||
boolean seendigit = firstDigit >= 0;
|
||||
boolean seenValidDigit = firstDigit >= 0 && firstDigit < digitRadix;
|
||||
if (seendigit) {
|
||||
scanDigits(pos, digitRadix);
|
||||
}
|
||||
if (radix == 16 && reader.ch == '.') {
|
||||
@ -325,6 +326,16 @@ public class JavaTokenizer {
|
||||
reader.ch == 'd' || reader.ch == 'D')) {
|
||||
scanFractionAndSuffix(pos);
|
||||
} else {
|
||||
if (!seenValidDigit) {
|
||||
switch (radix) {
|
||||
case 2:
|
||||
lexError(pos, "invalid.binary.number");
|
||||
break;
|
||||
case 16:
|
||||
lexError(pos, "invalid.hex.number");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (reader.ch == 'l' || reader.ch == 'L') {
|
||||
reader.scanChar();
|
||||
tk = TokenKind.LONGLITERAL;
|
||||
@ -491,13 +502,7 @@ public class JavaTokenizer {
|
||||
if (reader.ch == 'x' || reader.ch == 'X') {
|
||||
reader.scanChar();
|
||||
skipIllegalUnderscores();
|
||||
if (reader.ch == '.') {
|
||||
scanHexFractionAndSuffix(pos, false);
|
||||
} else if (reader.digit(pos, 16) < 0) {
|
||||
lexError(pos, "invalid.hex.number");
|
||||
} else {
|
||||
scanNumber(pos, 16);
|
||||
}
|
||||
scanNumber(pos, 16);
|
||||
} else if (reader.ch == 'b' || reader.ch == 'B') {
|
||||
if (!allowBinaryLiterals) {
|
||||
lexError(pos, "unsupported.binary.lit", source.name);
|
||||
@ -505,11 +510,7 @@ public class JavaTokenizer {
|
||||
}
|
||||
reader.scanChar();
|
||||
skipIllegalUnderscores();
|
||||
if (reader.digit(pos, 2) < 0) {
|
||||
lexError(pos, "invalid.binary.number");
|
||||
} else {
|
||||
scanNumber(pos, 2);
|
||||
}
|
||||
scanNumber(pos, 2);
|
||||
} else {
|
||||
reader.putChar('0');
|
||||
if (reader.ch == '_') {
|
||||
|
@ -26,11 +26,20 @@
|
||||
package com.sun.tools.sjavac;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.FileSystem;
|
||||
import java.nio.file.FileVisitResult;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.PathMatcher;
|
||||
import java.nio.file.SimpleFileVisitor;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Set;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Map;
|
||||
import java.util.regex.PatternSyntaxException;
|
||||
|
||||
/** A Source object maintains information about a source file.
|
||||
* For example which package it belongs to and kind of source it is.
|
||||
@ -56,8 +65,6 @@ public class Source implements Comparable<Source> {
|
||||
private long lastModified;
|
||||
// The source File.
|
||||
private File file;
|
||||
// The source root under which file resides.
|
||||
private File root;
|
||||
// If the source is generated.
|
||||
private boolean isGenerated;
|
||||
// If the source is only linked to, not compiled.
|
||||
@ -78,7 +85,7 @@ public class Source implements Comparable<Source> {
|
||||
return name.hashCode();
|
||||
}
|
||||
|
||||
public Source(Module m, String n, File f, File r) {
|
||||
public Source(Module m, String n, File f) {
|
||||
name = n;
|
||||
int dp = n.lastIndexOf(".");
|
||||
if (dp != -1) {
|
||||
@ -87,7 +94,6 @@ public class Source implements Comparable<Source> {
|
||||
suffix = "";
|
||||
}
|
||||
file = f;
|
||||
root = r;
|
||||
lastModified = f.lastModified();
|
||||
linkedOnly = false;
|
||||
}
|
||||
@ -102,7 +108,6 @@ public class Source implements Comparable<Source> {
|
||||
suffix = "";
|
||||
}
|
||||
file = null;
|
||||
root = null;
|
||||
lastModified = lm;
|
||||
linkedOnly = false;
|
||||
int ls = n.lastIndexOf('/');
|
||||
@ -112,7 +117,6 @@ public class Source implements Comparable<Source> {
|
||||
public String suffix() { return suffix; }
|
||||
public Package pkg() { return pkg; }
|
||||
public File file() { return file; }
|
||||
public File root() { return root; }
|
||||
public long lastModified() {
|
||||
return lastModified;
|
||||
}
|
||||
@ -183,225 +187,122 @@ public class Source implements Comparable<Source> {
|
||||
*/
|
||||
static public void scanRoot(File root,
|
||||
Set<String> suffixes,
|
||||
List<String> excludes, List<String> includes,
|
||||
List<String> excludeFiles, List<String> includeFiles,
|
||||
List<String> excludes,
|
||||
List<String> includes,
|
||||
Map<String,Source> foundFiles,
|
||||
Map<String,Module> foundModules,
|
||||
Module currentModule,
|
||||
final Module currentModule,
|
||||
boolean permitSourcesWithoutPackage,
|
||||
boolean inGensrc,
|
||||
boolean inLinksrc)
|
||||
throws ProblemException {
|
||||
throws IOException, ProblemException {
|
||||
|
||||
if (root == null) return;
|
||||
int root_prefix = root.getPath().length()+1;
|
||||
// This is the root source directory, it must not contain any Java sources files
|
||||
// because we do not allow Java source files without a package.
|
||||
// (Unless of course --permit-sources-without-package has been specified.)
|
||||
// It might contain other source files however, (for -tr and -copy) these will
|
||||
// always be included, since no package pattern can match the root directory.
|
||||
currentModule = addFilesInDir(root, root_prefix, root, suffixes, permitSourcesWithoutPackage,
|
||||
excludeFiles, includeFiles,
|
||||
foundFiles, foundModules, currentModule,
|
||||
inGensrc, inLinksrc);
|
||||
if (root == null)
|
||||
return;
|
||||
|
||||
File[] dirfiles = root.listFiles();
|
||||
for (File d : dirfiles) {
|
||||
if (d.isDirectory()) {
|
||||
// Descend into the directory structure.
|
||||
scanDirectory(d, root_prefix, root, suffixes,
|
||||
excludes, includes, excludeFiles, includeFiles,
|
||||
foundFiles, foundModules, currentModule, inGensrc, inLinksrc);
|
||||
}
|
||||
FileSystem fs = root.toPath().getFileSystem();
|
||||
|
||||
if (includes.isEmpty()) {
|
||||
includes = Collections.singletonList("**");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if a path matches any of the patterns given.
|
||||
* The pattern foo/bar matches only foo/bar
|
||||
* The pattern foo/* matches foo/bar and foo/bar/zoo etc
|
||||
*/
|
||||
static private boolean hasMatch(String path, List<String> patterns) {
|
||||
List<PathMatcher> includeMatchers = createPathMatchers(fs, includes);
|
||||
List<PathMatcher> excludeMatchers = createPathMatchers(fs, excludes);
|
||||
|
||||
// Convert Windows '\' to '/' for the sake of comparing with the patterns
|
||||
path = path.replace(File.separatorChar, '/');
|
||||
Files.walkFileTree(root.toPath(), new SimpleFileVisitor<Path>() {
|
||||
@Override
|
||||
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
|
||||
|
||||
for (String p : patterns) {
|
||||
// Exact match
|
||||
if (p.equals(path))
|
||||
return true;
|
||||
Path relToRoot = root.toPath().relativize(file);
|
||||
|
||||
// Single dot the end matches this package and all its subpackages.
|
||||
if (p.endsWith("/*")) {
|
||||
// Remove the wildcard
|
||||
String patprefix = p.substring(0,p.length()-2);
|
||||
// Does the path start with the pattern prefix?
|
||||
if (path.startsWith(patprefix)) {
|
||||
// If the path has the same length as the pattern prefix, then it is a match.
|
||||
// If the path is longer, then make sure that
|
||||
// the next part of the path starts with a dot (.) to prevent
|
||||
// wildcard matching in the middle of a package name.
|
||||
if (path.length()==patprefix.length() || path.charAt(patprefix.length())=='/') {
|
||||
return true;
|
||||
if (includeMatchers.stream().anyMatch(im -> im.matches(relToRoot))
|
||||
&& excludeMatchers.stream().noneMatch(em -> em.matches(relToRoot))
|
||||
&& suffixes.contains(Util.fileSuffix(file))) {
|
||||
|
||||
// TODO: Test this.
|
||||
Source existing = foundFiles.get(file);
|
||||
if (existing != null) {
|
||||
throw new IOException("You have already added the file "+file+" from "+existing.file().getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
existing = currentModule.lookupSource(file.toString());
|
||||
if (existing != null) {
|
||||
|
||||
/**
|
||||
* Matches patterns with the asterisk first. */
|
||||
// The pattern foo/bar.java only matches foo/bar.java
|
||||
// The pattern */bar.java matches foo/bar.java and zoo/bar.java etc
|
||||
static private boolean hasFileMatch(String path, List<String> patterns) {
|
||||
// Convert Windows '\' to '/' for the sake of comparing with the patterns
|
||||
path = path.replace(File.separatorChar, '/');
|
||||
// Oups, the source is already added, could be ok, could be not, lets check.
|
||||
if (inLinksrc) {
|
||||
// So we are collecting sources for linking only.
|
||||
if (existing.isLinkedOnly()) {
|
||||
// Ouch, this one is also for linking only. Bad.
|
||||
throw new IOException("You have already added the link only file " + file + " from " + existing.file().getPath());
|
||||
}
|
||||
// Ok, the existing source is to be compiled. Thus this link only is redundant
|
||||
// since all compiled are also linked to. Continue to the next source.
|
||||
// But we need to add the source, so that it will be visible to linking,
|
||||
// if not the multi core compile will fail because a JavaCompiler cannot
|
||||
// find the necessary dependencies for its part of the source.
|
||||
foundFiles.put(file.toString(), existing);
|
||||
} else {
|
||||
// We are looking for sources to compile, if we find an existing to be compiled
|
||||
// source with the same name, it is an internal error, since we must
|
||||
// find the sources to be compiled before we find the sources to be linked to.
|
||||
throw new IOException("Internal error: Double add of file " + file + " from " + existing.file().getPath());
|
||||
}
|
||||
|
||||
path = Util.normalizeDriveLetter(path);
|
||||
for (String p : patterns) {
|
||||
// Exact match
|
||||
if (p.equals(path)) {
|
||||
return true;
|
||||
}
|
||||
// Single dot the end matches this package and all its subpackages.
|
||||
if (p.startsWith("*")) {
|
||||
// Remove the wildcard
|
||||
String patsuffix = p.substring(1);
|
||||
// Does the path start with the pattern prefix?
|
||||
if (path.endsWith(patsuffix)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the files in the directory, assuming that the file has not been excluded.
|
||||
* Returns a fresh Module object, if this was a dir with a module-info.java file.
|
||||
*/
|
||||
static private Module addFilesInDir(File dir, int rootPrefix, File root,
|
||||
Set<String> suffixes, boolean allow_javas,
|
||||
List<String> excludeFiles, List<String> includeFiles,
|
||||
Map<String,Source> foundFiles,
|
||||
Map<String,Module> foundModules,
|
||||
Module currentModule,
|
||||
boolean inGensrc,
|
||||
boolean inLinksrc)
|
||||
throws ProblemException
|
||||
{
|
||||
for (File f : dir.listFiles()) {
|
||||
|
||||
if (!f.isFile())
|
||||
continue;
|
||||
|
||||
boolean should_add =
|
||||
(excludeFiles == null || excludeFiles.isEmpty() || !hasFileMatch(f.getPath(), excludeFiles))
|
||||
&& (includeFiles == null || includeFiles.isEmpty() || hasFileMatch(f.getPath(), includeFiles));
|
||||
|
||||
if (!should_add)
|
||||
continue;
|
||||
|
||||
if (!allow_javas && f.getName().endsWith(".java")) {
|
||||
throw new ProblemException("No .java files are allowed in the source root "+dir.getPath()+
|
||||
", please remove "+f.getName());
|
||||
}
|
||||
// Extract the file name relative the root.
|
||||
String fn = f.getPath().substring(rootPrefix);
|
||||
// Extract the package name.
|
||||
int sp = fn.lastIndexOf(File.separatorChar);
|
||||
String pkg = "";
|
||||
if (sp != -1) {
|
||||
pkg = fn.substring(0,sp).replace(File.separatorChar,'.');
|
||||
}
|
||||
// Is this a module-info.java file?
|
||||
if (fn.endsWith("module-info.java")) {
|
||||
// Aha! We have recursed into a module!
|
||||
if (!currentModule.name().equals("")) {
|
||||
throw new ProblemException("You have an extra module-info.java inside a module! Please remove "+fn);
|
||||
}
|
||||
String module_name = fn.substring(0,fn.length()-16);
|
||||
currentModule = new Module(module_name, f.getPath());
|
||||
foundModules.put(module_name, currentModule);
|
||||
}
|
||||
// Extract the suffix.
|
||||
int dp = fn.lastIndexOf(".");
|
||||
String suffix = "";
|
||||
if (dp > 0) {
|
||||
suffix = fn.substring(dp);
|
||||
}
|
||||
// Should the file be added?
|
||||
if (suffixes.contains(suffix)) {
|
||||
Source of = foundFiles.get(f.getPath());
|
||||
if (of != null) {
|
||||
throw new ProblemException("You have already added the file "+fn+" from "+of.file().getPath());
|
||||
}
|
||||
of = currentModule.lookupSource(f.getPath());
|
||||
if (of != null) {
|
||||
// Oups, the source is already added, could be ok, could be not, lets check.
|
||||
if (inLinksrc) {
|
||||
// So we are collecting sources for linking only.
|
||||
if (of.isLinkedOnly()) {
|
||||
// Ouch, this one is also for linking only. Bad.
|
||||
throw new ProblemException("You have already added the link only file "+fn+" from "+of.file().getPath());
|
||||
}
|
||||
// Ok, the existing source is to be compiled. Thus this link only is redundant
|
||||
// since all compiled are also linked to. Continue to the next source.
|
||||
// But we need to add the source, so that it will be visible to linking,
|
||||
// if not the multi core compile will fail because a JavaCompiler cannot
|
||||
// find the necessary dependencies for its part of the source.
|
||||
foundFiles.put(f.getPath(), of);
|
||||
continue;
|
||||
} else {
|
||||
// We are looking for sources to compile, if we find an existing to be compiled
|
||||
// source with the same name, it is an internal error, since we must
|
||||
// find the sources to be compiled before we find the sources to be linked to.
|
||||
throw new ProblemException("Internal error: Double add of file "+fn+" from "+of.file().getPath());
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
// Add source
|
||||
Source s = new Source(currentModule, file.toString(), file.toFile());
|
||||
if (inGensrc) {
|
||||
s.markAsGenerated();
|
||||
}
|
||||
if (inLinksrc) {
|
||||
s.markAsLinkedOnly();
|
||||
}
|
||||
String pkg = packageOfJavaFile(root.toPath(), file);
|
||||
pkg = currentModule.name() + ":" + pkg;
|
||||
foundFiles.put(file.toString(), s);
|
||||
currentModule.addSource(pkg, s);
|
||||
//////////////////////////////////////////////////////////////
|
||||
}
|
||||
}
|
||||
Source s = new Source(currentModule, f.getPath(), f, root);
|
||||
if (inGensrc) s.markAsGenerated();
|
||||
if (inLinksrc) {
|
||||
s.markAsLinkedOnly();
|
||||
}
|
||||
pkg = currentModule.name()+":"+pkg;
|
||||
foundFiles.put(f.getPath(), s);
|
||||
currentModule.addSource(pkg, s);
|
||||
|
||||
return FileVisitResult.CONTINUE;
|
||||
}
|
||||
}
|
||||
return currentModule;
|
||||
});
|
||||
}
|
||||
|
||||
static private void scanDirectory(File dir, int rootPrefix, File root,
|
||||
Set<String> suffixes,
|
||||
List<String> excludes, List<String> includes,
|
||||
List<String> excludeFiles, List<String> includeFiles,
|
||||
Map<String,Source> foundFiles,
|
||||
Map<String,Module> foundModules,
|
||||
Module currentModule, boolean inGensrc, boolean inLinksrc)
|
||||
throws ProblemException {
|
||||
|
||||
String path = "";
|
||||
// Remove the root prefix from the dir path
|
||||
if (dir.getPath().length() > rootPrefix) {
|
||||
path = dir.getPath().substring(rootPrefix);
|
||||
}
|
||||
// Should this package directory be included and not excluded?
|
||||
if ((includes==null || includes.isEmpty() || hasMatch(path, includes)) &&
|
||||
(excludes==null || excludes.isEmpty() || !hasMatch(path, excludes))) {
|
||||
// Add the source files.
|
||||
currentModule = addFilesInDir(dir, rootPrefix, root, suffixes, true, excludeFiles, includeFiles,
|
||||
foundFiles, foundModules, currentModule, inGensrc, inLinksrc);
|
||||
}
|
||||
|
||||
for (File d : dir.listFiles()) {
|
||||
if (d.isDirectory()) {
|
||||
// Descend into the directory structure.
|
||||
scanDirectory(d, rootPrefix, root, suffixes,
|
||||
excludes, includes, excludeFiles, includeFiles,
|
||||
foundFiles, foundModules, currentModule, inGensrc, inLinksrc);
|
||||
private static List<PathMatcher> createPathMatchers(FileSystem fs, List<String> patterns) {
|
||||
List<PathMatcher> matchers = new ArrayList<>();
|
||||
for (String pattern : patterns) {
|
||||
try {
|
||||
matchers.add(fs.getPathMatcher("glob:" + pattern));
|
||||
} catch (PatternSyntaxException e) {
|
||||
Log.error("Invalid pattern: " + pattern);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
return matchers;
|
||||
}
|
||||
|
||||
private static String packageOfJavaFile(Path sourceRoot, Path javaFile) {
|
||||
Path javaFileDir = javaFile.getParent();
|
||||
Path packageDir = sourceRoot.relativize(javaFileDir);
|
||||
List<String> separateDirs = new ArrayList<>();
|
||||
for (Path pathElement : packageDir) {
|
||||
separateDirs.add(pathElement.getFileName().toString());
|
||||
}
|
||||
return String.join(".", separateDirs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s[pkg: %s, name: %s, suffix: %s, file: %s, isGenerated: %b, linkedOnly: %b]",
|
||||
getClass().getSimpleName(),
|
||||
pkg,
|
||||
name,
|
||||
suffix,
|
||||
file,
|
||||
isGenerated,
|
||||
linkedOnly);
|
||||
}
|
||||
}
|
||||
|
@ -230,4 +230,10 @@ public class Util {
|
||||
Function<? super T, ? extends I> indexFunction) {
|
||||
return c.stream().collect(Collectors.<T, I, T>toMap(indexFunction, o -> o));
|
||||
}
|
||||
|
||||
public static String fileSuffix(Path file) {
|
||||
String fileNameStr = file.getFileName().toString();
|
||||
int dotIndex = fileNameStr.indexOf('.');
|
||||
return dotIndex == -1 ? "" : fileNameStr.substring(dotIndex);
|
||||
}
|
||||
}
|
||||
|
@ -144,77 +144,77 @@ public class SjavacImpl implements Sjavac {
|
||||
Module current_module = new Module("", "");
|
||||
modules.put("", current_module);
|
||||
|
||||
// Find all sources, use the suffix rules to know which files are sources.
|
||||
Map<String,Source> sources = new HashMap<>();
|
||||
|
||||
// Find the files, this will automatically populate the found modules
|
||||
// with found packages where the sources are found!
|
||||
findSourceFiles(options.getSources(),
|
||||
suffixRules.keySet(),
|
||||
sources,
|
||||
modules,
|
||||
current_module,
|
||||
options.isDefaultPackagePermitted(),
|
||||
false);
|
||||
|
||||
if (sources.isEmpty()) {
|
||||
Log.error("Found nothing to compile!");
|
||||
return RC_FATAL;
|
||||
}
|
||||
|
||||
|
||||
// Create a map of all source files that are available for linking. Both -src and
|
||||
// -sourcepath point to such files. It is possible to specify multiple
|
||||
// -sourcepath options to enable different filtering rules. If the
|
||||
// filters are the same for multiple sourcepaths, they may be concatenated
|
||||
// using :(;). Before sending the list of sourcepaths to javac, they are
|
||||
// all concatenated. The list created here is used by the SmartFileWrapper to
|
||||
// make sure only the correct sources are actually available.
|
||||
// We might find more modules here as well.
|
||||
Map<String,Source> sources_to_link_to = new HashMap<>();
|
||||
|
||||
List<SourceLocation> sourceResolutionLocations = new ArrayList<>();
|
||||
sourceResolutionLocations.addAll(options.getSources());
|
||||
sourceResolutionLocations.addAll(options.getSourceSearchPaths());
|
||||
findSourceFiles(sourceResolutionLocations,
|
||||
Collections.singleton(".java"),
|
||||
sources_to_link_to,
|
||||
modules,
|
||||
current_module,
|
||||
options.isDefaultPackagePermitted(),
|
||||
true);
|
||||
|
||||
// Add the set of sources to the build database.
|
||||
javac_state.now().flattenPackagesSourcesAndArtifacts(modules);
|
||||
javac_state.now().checkInternalState("checking sources", false, sources);
|
||||
javac_state.now().checkInternalState("checking linked sources", true, sources_to_link_to);
|
||||
javac_state.setVisibleSources(sources_to_link_to);
|
||||
|
||||
int round = 0;
|
||||
printRound(round);
|
||||
|
||||
// If there is any change in the source files, taint packages
|
||||
// and mark the database in need of saving.
|
||||
javac_state.checkSourceStatus(false);
|
||||
|
||||
// Find all existing artifacts. Their timestamp will match the last modified timestamps stored
|
||||
// in javac_state, simply because loading of the JavacState will clean out all artifacts
|
||||
// that do not match the javac_state database.
|
||||
javac_state.findAllArtifacts();
|
||||
|
||||
// Remove unidentified artifacts from the bin, gensrc and header dirs.
|
||||
// (Unless we allow them to be there.)
|
||||
// I.e. artifacts that are not known according to the build database (javac_state).
|
||||
// For examples, files that have been manually copied into these dirs.
|
||||
// Artifacts with bad timestamps (ie the on disk timestamp does not match the timestamp
|
||||
// in javac_state) have already been removed when the javac_state was loaded.
|
||||
if (!options.areUnidentifiedArtifactsPermitted()) {
|
||||
javac_state.removeUnidentifiedArtifacts();
|
||||
}
|
||||
// Go through all sources and taint all packages that miss artifacts.
|
||||
javac_state.taintPackagesThatMissArtifacts();
|
||||
|
||||
try {
|
||||
// Find all sources, use the suffix rules to know which files are sources.
|
||||
Map<String,Source> sources = new HashMap<>();
|
||||
|
||||
// Find the files, this will automatically populate the found modules
|
||||
// with found packages where the sources are found!
|
||||
findSourceFiles(options.getSources(),
|
||||
suffixRules.keySet(),
|
||||
sources,
|
||||
modules,
|
||||
current_module,
|
||||
options.isDefaultPackagePermitted(),
|
||||
false);
|
||||
|
||||
if (sources.isEmpty()) {
|
||||
Log.error("Found nothing to compile!");
|
||||
return RC_FATAL;
|
||||
}
|
||||
|
||||
|
||||
// Create a map of all source files that are available for linking. Both -src and
|
||||
// -sourcepath point to such files. It is possible to specify multiple
|
||||
// -sourcepath options to enable different filtering rules. If the
|
||||
// filters are the same for multiple sourcepaths, they may be concatenated
|
||||
// using :(;). Before sending the list of sourcepaths to javac, they are
|
||||
// all concatenated. The list created here is used by the SmartFileWrapper to
|
||||
// make sure only the correct sources are actually available.
|
||||
// We might find more modules here as well.
|
||||
Map<String,Source> sources_to_link_to = new HashMap<>();
|
||||
|
||||
List<SourceLocation> sourceResolutionLocations = new ArrayList<>();
|
||||
sourceResolutionLocations.addAll(options.getSources());
|
||||
sourceResolutionLocations.addAll(options.getSourceSearchPaths());
|
||||
findSourceFiles(sourceResolutionLocations,
|
||||
Collections.singleton(".java"),
|
||||
sources_to_link_to,
|
||||
modules,
|
||||
current_module,
|
||||
options.isDefaultPackagePermitted(),
|
||||
true);
|
||||
|
||||
// Add the set of sources to the build database.
|
||||
javac_state.now().flattenPackagesSourcesAndArtifacts(modules);
|
||||
javac_state.now().checkInternalState("checking sources", false, sources);
|
||||
javac_state.now().checkInternalState("checking linked sources", true, sources_to_link_to);
|
||||
javac_state.setVisibleSources(sources_to_link_to);
|
||||
|
||||
int round = 0;
|
||||
printRound(round);
|
||||
|
||||
// If there is any change in the source files, taint packages
|
||||
// and mark the database in need of saving.
|
||||
javac_state.checkSourceStatus(false);
|
||||
|
||||
// Find all existing artifacts. Their timestamp will match the last modified timestamps stored
|
||||
// in javac_state, simply because loading of the JavacState will clean out all artifacts
|
||||
// that do not match the javac_state database.
|
||||
javac_state.findAllArtifacts();
|
||||
|
||||
// Remove unidentified artifacts from the bin, gensrc and header dirs.
|
||||
// (Unless we allow them to be there.)
|
||||
// I.e. artifacts that are not known according to the build database (javac_state).
|
||||
// For examples, files that have been manually copied into these dirs.
|
||||
// Artifacts with bad timestamps (ie the on disk timestamp does not match the timestamp
|
||||
// in javac_state) have already been removed when the javac_state was loaded.
|
||||
if (!options.areUnidentifiedArtifactsPermitted()) {
|
||||
javac_state.removeUnidentifiedArtifacts();
|
||||
}
|
||||
// Go through all sources and taint all packages that miss artifacts.
|
||||
javac_state.taintPackagesThatMissArtifacts();
|
||||
|
||||
// Check recorded classpath public apis. Taint packages that depend on
|
||||
// classpath classes whose public apis have changed.
|
||||
javac_state.taintPackagesDependingOnChangedClasspathPackages();
|
||||
@ -229,8 +229,16 @@ public class SjavacImpl implements Sjavac {
|
||||
// (Generated sources must always have a package.)
|
||||
Map<String,Source> generated_sources = new HashMap<>();
|
||||
|
||||
Source.scanRoot(Util.pathToFile(options.getGenSrcDir()), Util.set(".java"), null, null, null, null,
|
||||
generated_sources, modules, current_module, false, true, false);
|
||||
Source.scanRoot(Util.pathToFile(options.getGenSrcDir()),
|
||||
Util.set(".java"),
|
||||
Collections.emptyList(),
|
||||
Collections.emptyList(),
|
||||
generated_sources,
|
||||
modules,
|
||||
current_module,
|
||||
false,
|
||||
true,
|
||||
false);
|
||||
javac_state.now().flattenPackagesSourcesAndArtifacts(modules);
|
||||
// Recheck the the source files and their timestamps again.
|
||||
javac_state.checkSourceStatus(true);
|
||||
@ -254,7 +262,10 @@ public class SjavacImpl implements Sjavac {
|
||||
printRound(round);
|
||||
// Clean out artifacts in tainted packages.
|
||||
javac_state.deleteClassArtifactsInTaintedPackages();
|
||||
again = javac_state.performJavaCompilations(compilationService, options, recently_compiled, rc);
|
||||
again = javac_state.performJavaCompilations(compilationService,
|
||||
options,
|
||||
recently_compiled,
|
||||
rc);
|
||||
if (!rc[0]) {
|
||||
Log.debug("Compilation failed.");
|
||||
break;
|
||||
@ -344,7 +355,8 @@ public class SjavacImpl implements Sjavac {
|
||||
Map<String, Module> foundModules,
|
||||
Module currentModule,
|
||||
boolean permitSourcesInDefaultPackage,
|
||||
boolean inLinksrc) {
|
||||
boolean inLinksrc)
|
||||
throws IOException {
|
||||
|
||||
for (SourceLocation source : sourceLocations) {
|
||||
source.findSourceFiles(sourceTypes,
|
||||
|
@ -93,7 +93,7 @@ public enum Option {
|
||||
CLASSPATH.processMatching(iter, helper);
|
||||
}
|
||||
},
|
||||
X("-x", "Exclude directory from the subsequent source directory") {
|
||||
X("-x", "Exclude files matching the given pattern") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
String pattern = getFilePatternArg(iter, helper);
|
||||
@ -101,7 +101,7 @@ public enum Option {
|
||||
helper.exclude(pattern);
|
||||
}
|
||||
},
|
||||
I("-i", "Include only the given directory from the subsequent source directory") {
|
||||
I("-i", "Include only files matching the given pattern") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
String pattern = getFilePatternArg(iter, helper);
|
||||
@ -109,22 +109,6 @@ public enum Option {
|
||||
helper.include(pattern);
|
||||
}
|
||||
},
|
||||
XF("-xf", "Exclude a given file") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
String pattern = getFilePatternArg(iter, helper);
|
||||
if (pattern != null)
|
||||
helper.excludeFile(pattern);
|
||||
}
|
||||
},
|
||||
IF("-if", "Include only the given file") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
String pattern = getFilePatternArg(iter, helper);
|
||||
if (pattern != null)
|
||||
helper.includeFile(pattern);
|
||||
}
|
||||
},
|
||||
TR("-tr", "Translate resources") {
|
||||
@Override
|
||||
protected void processMatching(ArgumentIterator iter, OptionHelper helper) {
|
||||
@ -338,7 +322,7 @@ public enum Option {
|
||||
String getFilePatternArg(ArgumentIterator iter, OptionHelper helper) {
|
||||
|
||||
if (!iter.hasNext()) {
|
||||
helper.reportError(arg + " must be followed by a file or directory pattern.");
|
||||
helper.reportError(arg + " must be followed by a glob pattern.");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -53,12 +53,6 @@ public abstract class OptionHelper {
|
||||
/** Record a package inclusion pattern */
|
||||
public abstract void include(String incl);
|
||||
|
||||
/** Record a file exclusion */
|
||||
public abstract void excludeFile(String exclFile);
|
||||
|
||||
/** Record a file inclusion */
|
||||
public abstract void includeFile(String inclFile);
|
||||
|
||||
/** Record a root of sources to be compiled */
|
||||
public abstract void sourceRoots(List<Path> path);
|
||||
|
||||
|
@ -220,8 +220,6 @@ public class Options {
|
||||
for (SourceLocation sl : locs) {
|
||||
for (String pkg : sl.includes) addArg(Option.I, pkg);
|
||||
for (String pkg : sl.excludes) addArg(Option.X, pkg);
|
||||
for (String f : sl.excludedFiles) addArg(Option.XF, f);
|
||||
for (String f : sl.includedFiles) addArg(Option.IF, f);
|
||||
addArg(opt, sl.getPath());
|
||||
}
|
||||
}
|
||||
@ -379,18 +377,6 @@ public class Options {
|
||||
includes.add(inclPattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void excludeFile(String exclFilePattern) {
|
||||
exclFilePattern = Util.normalizeDriveLetter(exclFilePattern);
|
||||
excludeFiles.add(exclFilePattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void includeFile(String inclFilePattern) {
|
||||
inclFilePattern = Util.normalizeDriveLetter(inclFilePattern);
|
||||
includeFiles.add(inclFilePattern);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTransformer(String suffix, Transformer tr) {
|
||||
if (trRules.containsKey(suffix)) {
|
||||
@ -519,9 +505,7 @@ public class Options {
|
||||
result.add(new SourceLocation(
|
||||
path,
|
||||
includes,
|
||||
excludes,
|
||||
includeFiles,
|
||||
excludeFiles));
|
||||
excludes));
|
||||
}
|
||||
resetFilters();
|
||||
return result;
|
||||
|
@ -25,11 +25,13 @@
|
||||
|
||||
package com.sun.tools.sjavac.options;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import com.sun.tools.sjavac.Log;
|
||||
import com.sun.tools.sjavac.Module;
|
||||
import com.sun.tools.sjavac.ProblemException;
|
||||
import com.sun.tools.sjavac.Source;
|
||||
@ -49,18 +51,14 @@ public class SourceLocation {
|
||||
private Path path;
|
||||
|
||||
// Package include / exclude patterns and file includes / excludes.
|
||||
List<String> includes, excludes, includedFiles, excludedFiles;
|
||||
List<String> includes, excludes;
|
||||
|
||||
public SourceLocation(Path path,
|
||||
List<String> includes,
|
||||
List<String> excludes,
|
||||
List<String> includedFiles,
|
||||
List<String> excludedFiles) {
|
||||
List<String> excludes) {
|
||||
this.path = path;
|
||||
this.includes = includes;
|
||||
this.excludes = excludes;
|
||||
this.includedFiles = includedFiles;
|
||||
this.excludedFiles = excludedFiles;
|
||||
}
|
||||
|
||||
|
||||
@ -81,17 +79,23 @@ public class SourceLocation {
|
||||
Map<String, Module> foundModules,
|
||||
Module currentModule,
|
||||
boolean permitSourcesInDefaultPackage,
|
||||
boolean inLinksrc) {
|
||||
boolean inLinksrc)
|
||||
throws IOException {
|
||||
try {
|
||||
Source.scanRoot(path.toFile(), suffixes, excludes, includes,
|
||||
excludedFiles, includedFiles, foundFiles, foundModules,
|
||||
currentModule, permitSourcesInDefaultPackage, false,
|
||||
inLinksrc);
|
||||
Source.scanRoot(path.toFile(),
|
||||
suffixes,
|
||||
excludes,
|
||||
includes,
|
||||
foundFiles,
|
||||
foundModules,
|
||||
currentModule,
|
||||
permitSourcesInDefaultPackage,
|
||||
false,
|
||||
inLinksrc);
|
||||
} catch (ProblemException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/** Get the root directory of this source location */
|
||||
public Path getPath() {
|
||||
return path;
|
||||
@ -107,14 +111,9 @@ public class SourceLocation {
|
||||
return excludes;
|
||||
}
|
||||
|
||||
/** Get the file include patterns */
|
||||
public List<String> getIncludedFiles() {
|
||||
return includedFiles;
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s[\"%s\", includes: %s, excludes: %s]",
|
||||
getClass().getSimpleName(), path, includes, excludes);
|
||||
}
|
||||
|
||||
/** Get the file exclude patterns */
|
||||
public List<String> getExcludedFiles() {
|
||||
return excludedFiles;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
@ -174,11 +174,20 @@ public class PortFile {
|
||||
/**
|
||||
* Delete the port file.
|
||||
*/
|
||||
public void delete() throws IOException {
|
||||
public void delete() throws IOException, InterruptedException {
|
||||
// Access to file must be closed before deleting.
|
||||
rwfile.close();
|
||||
// Now delete.
|
||||
|
||||
file.delete();
|
||||
|
||||
// Wait until file has been deleted (deletes are asynchronous on Windows!) otherwise we
|
||||
// might shutdown the server and prevent another one from starting.
|
||||
for (int i = 0; i < 10 && file.exists(); i++) {
|
||||
Thread.sleep(1000);
|
||||
}
|
||||
if (file.exists()) {
|
||||
throw new IOException("Failed to delete file.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
@ -279,7 +279,7 @@ public class SjavacServer implements Terminable {
|
||||
// failed connection attempts
|
||||
try {
|
||||
portFile.delete();
|
||||
} catch (IOException e) {
|
||||
} catch (IOException | InterruptedException e) {
|
||||
e.printStackTrace(theLog);
|
||||
}
|
||||
try {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 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
|
||||
@ -248,7 +248,7 @@ public class VisibleMemberMap {
|
||||
for (ProgramElementDoc element : list) {
|
||||
Object key = getMemberKey(element);
|
||||
Map<ProgramElementDoc, String> memberLevelMap = memberNameMap.get(key);
|
||||
if (level.equals(memberLevelMap.get(element)))
|
||||
if (memberLevelMap != null && level.equals(memberLevelMap.get(element)))
|
||||
memberLevelMap.remove(element);
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,9 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -35,7 +38,9 @@ import java.net.Socket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static jdk.internal.jshell.remote.RemoteCodes.*;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@ -59,7 +64,10 @@ class RemoteAgent {
|
||||
void commandLoop(Socket socket) throws IOException {
|
||||
// in before out -- so we don't hang the controlling process
|
||||
ObjectInputStream in = new ObjectInputStream(socket.getInputStream());
|
||||
ObjectOutputStream out = new ObjectOutputStream(socket.getOutputStream());
|
||||
OutputStream socketOut = socket.getOutputStream();
|
||||
System.setOut(new PrintStream(new MultiplexingOutputStream("out", socketOut), true));
|
||||
System.setErr(new PrintStream(new MultiplexingOutputStream("err", socketOut), true));
|
||||
ObjectOutputStream out = new ObjectOutputStream(new MultiplexingOutputStream("command", socketOut));
|
||||
while (true) {
|
||||
int cmd = in.readInt();
|
||||
switch (cmd) {
|
||||
@ -260,4 +268,64 @@ class RemoteAgent {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static final class MultiplexingOutputStream extends OutputStream {
|
||||
|
||||
private static final int PACKET_SIZE = 127;
|
||||
|
||||
private final byte[] name;
|
||||
private final OutputStream delegate;
|
||||
|
||||
public MultiplexingOutputStream(String name, OutputStream delegate) {
|
||||
try {
|
||||
this.name = name.getBytes("UTF-8");
|
||||
this.delegate = delegate;
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
throw new IllegalStateException(ex); //should not happen
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
synchronized (delegate) {
|
||||
delegate.write(name.length); //assuming the len is small enough to fit into byte
|
||||
delegate.write(name);
|
||||
delegate.write(1);
|
||||
delegate.write(b);
|
||||
delegate.flush();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
synchronized (delegate) {
|
||||
int i = 0;
|
||||
while (len > 0) {
|
||||
int size = Math.min(PACKET_SIZE, len);
|
||||
|
||||
delegate.write(name.length); //assuming the len is small enough to fit into byte
|
||||
delegate.write(name);
|
||||
delegate.write(size);
|
||||
delegate.write(b, off + i, size);
|
||||
i += size;
|
||||
len -= size;
|
||||
}
|
||||
|
||||
delegate.flush();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush() throws IOException {
|
||||
super.flush();
|
||||
delegate.flush();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
super.close();
|
||||
delegate.close();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
@ -90,8 +91,10 @@ import java.util.MissingResourceException;
|
||||
import java.util.Optional;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Spliterators;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
import static java.util.stream.Collectors.toList;
|
||||
import static jdk.jshell.Snippet.SubKind.VAR_VALUE_SUBKIND;
|
||||
|
||||
/**
|
||||
* Command line REPL tool for Java using the JShell API.
|
||||
@ -102,6 +105,7 @@ public class JShellTool {
|
||||
private static final Pattern LINEBREAK = Pattern.compile("\\R");
|
||||
private static final Pattern HISTORY_ALL_START_FILENAME = Pattern.compile(
|
||||
"((?<cmd>(all|history|start))(\\z|\\p{javaWhitespace}+))?(?<filename>.*)");
|
||||
private static final String RECORD_SEPARATOR = "\u241E";
|
||||
|
||||
final InputStream cmdin;
|
||||
final PrintStream cmdout;
|
||||
@ -150,9 +154,14 @@ public class JShellTool {
|
||||
private String cmdlineStartup = null;
|
||||
private String editor = null;
|
||||
|
||||
static final Preferences PREFS = Preferences.userRoot().node("tool/REPL");
|
||||
// Commands and snippets which should be replayed
|
||||
private List<String> replayableHistory;
|
||||
private List<String> replayableHistoryPrevious;
|
||||
|
||||
static final Preferences PREFS = Preferences.userRoot().node("tool/JShell");
|
||||
|
||||
static final String STARTUP_KEY = "STARTUP";
|
||||
static final String REPLAY_RESTORE_KEY = "REPLAY_RESTORE";
|
||||
|
||||
static final String DEFAULT_STARTUP =
|
||||
"\n" +
|
||||
@ -165,11 +174,14 @@ public class JShellTool {
|
||||
"import java.util.regex.*;\n" +
|
||||
"void printf(String format, Object... args) { System.out.printf(format, args); }\n";
|
||||
|
||||
// Tool id (tid) mapping
|
||||
// Tool id (tid) mapping: the three name spaces
|
||||
NameSpace mainNamespace;
|
||||
NameSpace startNamespace;
|
||||
NameSpace errorNamespace;
|
||||
|
||||
// Tool id (tid) mapping: the current name spaces
|
||||
NameSpace currentNameSpace;
|
||||
|
||||
Map<Snippet,SnippetInfo> mapSnippet;
|
||||
|
||||
void debug(String format, Object... args) {
|
||||
@ -252,6 +264,12 @@ public class JShellTool {
|
||||
private void start(IOContext in, List<String> loadList) {
|
||||
resetState(); // Initialize
|
||||
|
||||
// Read replay history from last jshell session into previous history
|
||||
String prevReplay = PREFS.get(REPLAY_RESTORE_KEY, null);
|
||||
if (prevReplay != null) {
|
||||
replayableHistoryPrevious = Arrays.asList(prevReplay.split(RECORD_SEPARATOR));
|
||||
}
|
||||
|
||||
for (String loadFile : loadList) {
|
||||
cmdOpen(loadFile);
|
||||
}
|
||||
@ -370,6 +388,10 @@ public class JShellTool {
|
||||
mapSnippet = new LinkedHashMap<>();
|
||||
currentNameSpace = startNamespace;
|
||||
|
||||
// Reset the replayable history, saving the old for restore
|
||||
replayableHistoryPrevious = replayableHistory;
|
||||
replayableHistory = new ArrayList<>();
|
||||
|
||||
state = JShell.builder()
|
||||
.in(userin)
|
||||
.out(userout)
|
||||
@ -382,7 +404,8 @@ public class JShellTool {
|
||||
analysis = state.sourceCodeAnalysis();
|
||||
shutdownSubscription = state.onShutdown((JShell deadState) -> {
|
||||
if (deadState == state) {
|
||||
hard("State engine terminated. See /history");
|
||||
hard("State engine terminated.");
|
||||
hard("Restore definitions with: /reload restore");
|
||||
live = false;
|
||||
}
|
||||
});
|
||||
@ -392,7 +415,6 @@ public class JShellTool {
|
||||
state.addToClasspath(cmdlineClasspath);
|
||||
}
|
||||
|
||||
|
||||
String start;
|
||||
if (cmdlineStartup == null) {
|
||||
start = PREFS.get(STARTUP_KEY, "<nada>");
|
||||
@ -431,7 +453,7 @@ public class JShellTool {
|
||||
String incomplete = "";
|
||||
while (live) {
|
||||
String prompt;
|
||||
if (in.interactiveOutput() && displayPrompt) {
|
||||
if (displayPrompt) {
|
||||
prompt = testPrompt
|
||||
? incomplete.isEmpty()
|
||||
? "\u0005" //ENQ
|
||||
@ -480,6 +502,12 @@ public class JShellTool {
|
||||
}
|
||||
}
|
||||
|
||||
private void addToReplayHistory(String s) {
|
||||
if (currentNameSpace == mainNamespace) {
|
||||
replayableHistory.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
private String processSourceCatchingReset(String src) {
|
||||
try {
|
||||
input.beforeUserCode();
|
||||
@ -516,7 +544,12 @@ public class JShellTool {
|
||||
fluff("Type /help for help.");
|
||||
}
|
||||
} else if (candidates.length == 1) {
|
||||
candidates[0].run.accept(arg);
|
||||
Command command = candidates[0];
|
||||
|
||||
// If comand was successful and is of a replayable kind, add it the replayable history
|
||||
if (command.run.apply(arg) && command.kind == CommandKind.REPLAY) {
|
||||
addToReplayHistory((command.command + " " + arg).trim());
|
||||
}
|
||||
} else {
|
||||
hard("Command: %s is ambiguous: %s", cmd, Arrays.stream(candidates).map(c -> c.command).collect(Collectors.joining(", ")));
|
||||
fluff("Type /help for help.");
|
||||
@ -546,15 +579,15 @@ public class JShellTool {
|
||||
public final String command;
|
||||
public final String params;
|
||||
public final String description;
|
||||
public final Consumer<String> run;
|
||||
public final Function<String,Boolean> run;
|
||||
public final CompletionProvider completions;
|
||||
public final CommandKind kind;
|
||||
|
||||
public Command(String command, String params, String description, Consumer<String> run, CompletionProvider completions) {
|
||||
public Command(String command, String params, String description, Function<String,Boolean> run, CompletionProvider completions) {
|
||||
this(command, params, description, run, completions, CommandKind.NORMAL);
|
||||
}
|
||||
|
||||
public Command(String command, String params, String description, Consumer<String> run, CompletionProvider completions, CommandKind kind) {
|
||||
public Command(String command, String params, String description, Function<String,Boolean> run, CompletionProvider completions, CommandKind kind) {
|
||||
this.command = command;
|
||||
this.params = params;
|
||||
this.description = description;
|
||||
@ -571,6 +604,7 @@ public class JShellTool {
|
||||
|
||||
enum CommandKind {
|
||||
NORMAL,
|
||||
REPLAY,
|
||||
HIDDEN,
|
||||
HELP_ONLY;
|
||||
}
|
||||
@ -602,6 +636,7 @@ public class JShellTool {
|
||||
|
||||
private static final CompletionProvider EMPTY_COMPLETION_PROVIDER = new FixedCompletionProvider();
|
||||
private static final CompletionProvider KEYWORD_COMPLETION_PROVIDER = new FixedCompletionProvider("all ", "start ", "history ");
|
||||
private static final CompletionProvider RELOAD_OPTIONS_COMPLETION_PROVIDER = new FixedCompletionProvider("restore", "quiet");
|
||||
private static final CompletionProvider FILE_COMPLETION_PROVIDER = fileCompletions(p -> true);
|
||||
private final Map<String, Command> commands = new LinkedHashMap<>();
|
||||
private void registerCommand(Command cmd) {
|
||||
@ -674,6 +709,16 @@ public class JShellTool {
|
||||
};
|
||||
}
|
||||
|
||||
private static CompletionProvider reloadCompletion() {
|
||||
return (code, cursor, anchor) -> {
|
||||
List<Suggestion> result = new ArrayList<>();
|
||||
int pastSpace = code.indexOf(' ') + 1; // zero if no space
|
||||
result.addAll(RELOAD_OPTIONS_COMPLETION_PROVIDER.completionSuggestions(code.substring(pastSpace), cursor - pastSpace, anchor));
|
||||
anchor[0] += pastSpace;
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
// Table of commands -- with command forms, argument kinds, help message, implementation, ...
|
||||
|
||||
{
|
||||
@ -688,7 +733,8 @@ public class JShellTool {
|
||||
editCompletion()));
|
||||
registerCommand(new Command("/drop", "<name or id>", "delete a source entry referenced by name or id",
|
||||
arg -> cmdDrop(arg),
|
||||
editCompletion()));
|
||||
editCompletion(),
|
||||
CommandKind.REPLAY));
|
||||
registerCommand(new Command("/save", "[all|history|start] <file>", "save: <none> - current source;\n" +
|
||||
" all - source including overwritten, failed, and start-up code;\n" +
|
||||
" history - editing history;\n" +
|
||||
@ -716,6 +762,9 @@ public class JShellTool {
|
||||
registerCommand(new Command("/reset", null, "reset everything in the REPL",
|
||||
arg -> cmdReset(),
|
||||
EMPTY_COMPLETION_PROVIDER));
|
||||
registerCommand(new Command("/reload", "[restore] [quiet]", "reset and replay relevant history -- current or previous (restore)",
|
||||
arg -> cmdReload(arg),
|
||||
reloadCompletion()));
|
||||
registerCommand(new Command("/feedback", "<level>", "feedback information: off, concise, normal, verbose, default, or ?",
|
||||
arg -> cmdFeedback(arg),
|
||||
new FixedCompletionProvider("off", "concise", "normal", "verbose", "default", "?")));
|
||||
@ -724,7 +773,8 @@ public class JShellTool {
|
||||
EMPTY_COMPLETION_PROVIDER));
|
||||
registerCommand(new Command("/classpath", "<path>", "add a path to the classpath",
|
||||
arg -> cmdClasspath(arg),
|
||||
classPathCompletion()));
|
||||
classPathCompletion(),
|
||||
CommandKind.REPLAY));
|
||||
registerCommand(new Command("/history", null, "history of what you have typed",
|
||||
arg -> cmdHistory(),
|
||||
EMPTY_COMPLETION_PROVIDER));
|
||||
@ -801,25 +851,29 @@ public class JShellTool {
|
||||
|
||||
// --- Command implementations ---
|
||||
|
||||
void cmdSetEditor(String arg) {
|
||||
boolean cmdSetEditor(String arg) {
|
||||
if (arg.isEmpty()) {
|
||||
hard("/seteditor requires a path argument");
|
||||
return false;
|
||||
} else {
|
||||
editor = arg;
|
||||
fluff("Editor set to: %s", arg);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void cmdClasspath(String arg) {
|
||||
boolean cmdClasspath(String arg) {
|
||||
if (arg.isEmpty()) {
|
||||
hard("/classpath requires a path argument");
|
||||
return false;
|
||||
} else {
|
||||
state.addToClasspath(toPathResolvingUserHome(arg).toString());
|
||||
fluff("Path %s added to classpath", arg);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
void cmdDebug(String arg) {
|
||||
boolean cmdDebug(String arg) {
|
||||
if (arg.isEmpty()) {
|
||||
debug = !debug;
|
||||
InternalDebugControl.setDebugFlags(state, debug ? InternalDebugControl.DBG_GEN : 0);
|
||||
@ -860,20 +914,26 @@ public class JShellTool {
|
||||
default:
|
||||
hard("Unknown debugging option: %c", ch);
|
||||
fluff("Use: 0 r g f c d");
|
||||
break;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
InternalDebugControl.setDebugFlags(state, flags);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdExit() {
|
||||
private boolean cmdExit() {
|
||||
regenerateOnDeath = false;
|
||||
live = false;
|
||||
if (!replayableHistory.isEmpty()) {
|
||||
PREFS.put(REPLAY_RESTORE_KEY, replayableHistory.stream().reduce(
|
||||
(a, b) -> a + RECORD_SEPARATOR + b).get());
|
||||
}
|
||||
fluff("Goodbye\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdFeedback(String arg) {
|
||||
private boolean cmdFeedback(String arg) {
|
||||
switch (arg) {
|
||||
case "":
|
||||
case "d":
|
||||
@ -905,12 +965,13 @@ public class JShellTool {
|
||||
hard(" default");
|
||||
hard("You may also use just the first letter, for example: /f c");
|
||||
hard("In interactive mode 'default' is the same as 'normal', from a file it is the same as 'off'");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
fluff("Feedback mode: %s", feedback.name().toLowerCase());
|
||||
return true;
|
||||
}
|
||||
|
||||
void cmdHelp() {
|
||||
boolean cmdHelp() {
|
||||
int synopsisLen = 0;
|
||||
Map<String, String> synopsis2Description = new LinkedHashMap<>();
|
||||
for (Command cmd : new LinkedHashSet<>(commands.values())) {
|
||||
@ -936,14 +997,16 @@ public class JShellTool {
|
||||
cmdout.println("Supported shortcuts include:");
|
||||
cmdout.println("<tab> -- show possible completions for the current text");
|
||||
cmdout.println("Shift-<tab> -- for current method or constructor invocation, show a synopsis of the method/constructor");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdHistory() {
|
||||
private boolean cmdHistory() {
|
||||
cmdout.println();
|
||||
for (String s : input.currentSessionHistory()) {
|
||||
// No number prefix, confusing with snippet ids
|
||||
cmdout.printf("%s\n", s);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1010,23 +1073,23 @@ public class JShellTool {
|
||||
}
|
||||
}
|
||||
|
||||
private void cmdDrop(String arg) {
|
||||
private boolean cmdDrop(String arg) {
|
||||
if (arg.isEmpty()) {
|
||||
hard("In the /drop argument, please specify an import, variable, method, or class to drop.");
|
||||
hard("Specify by id or name. Use /list to see ids. Use /reset to reset all state.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
Stream<Snippet> stream = argToSnippets(arg, false);
|
||||
if (stream == null) {
|
||||
hard("No definition or id named %s found. See /classes, /methods, /vars, or /list", arg);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
List<Snippet> snippets = stream
|
||||
.filter(sn -> state.status(sn).isActive && sn instanceof PersistentSnippet)
|
||||
.collect(toList());
|
||||
if (snippets.isEmpty()) {
|
||||
hard("The argument did not specify an active import, variable, method, or class to drop.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
if (snippets.size() > 1) {
|
||||
hard("The argument references more than one import, variable, method, or class.");
|
||||
@ -1034,17 +1097,18 @@ public class JShellTool {
|
||||
for (Snippet sn : snippets) {
|
||||
cmdout.printf("%4s : %s\n", sn.id(), sn.source().replace("\n", "\n "));
|
||||
}
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
PersistentSnippet psn = (PersistentSnippet) snippets.get(0);
|
||||
state.drop(psn).forEach(this::handleEvent);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdEdit(String arg) {
|
||||
private boolean cmdEdit(String arg) {
|
||||
Stream<Snippet> stream = argToSnippets(arg, true);
|
||||
if (stream == null) {
|
||||
hard("No definition or id named %s found. See /classes, /methods, /vars, or /list", arg);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
Set<String> srcSet = new LinkedHashSet<>();
|
||||
stream.forEachOrdered(sn -> {
|
||||
@ -1078,6 +1142,7 @@ public class JShellTool {
|
||||
} else {
|
||||
ExternalEditor.edit(editor, errorHandler, src, saveHandler, input);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
//where
|
||||
// receives editor requests to save
|
||||
@ -1135,10 +1200,9 @@ public class JShellTool {
|
||||
}
|
||||
}
|
||||
|
||||
private void cmdList(String arg) {
|
||||
private boolean cmdList(String arg) {
|
||||
if (arg.equals("history")) {
|
||||
cmdHistory();
|
||||
return;
|
||||
return cmdHistory();
|
||||
}
|
||||
Stream<Snippet> stream = argToSnippets(arg, true);
|
||||
if (stream == null) {
|
||||
@ -1148,7 +1212,7 @@ public class JShellTool {
|
||||
} else {
|
||||
hard("No definition or id named %s found. There are no active definitions.", arg);
|
||||
}
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
// prevent double newline on empty list
|
||||
@ -1160,38 +1224,72 @@ public class JShellTool {
|
||||
}
|
||||
cmdout.printf("%4s : %s\n", sn.id(), sn.source().replace("\n", "\n "));
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdOpen(String filename) {
|
||||
private boolean cmdOpen(String filename) {
|
||||
if (filename.isEmpty()) {
|
||||
hard("The /open command requires a filename argument.");
|
||||
return false;
|
||||
} else {
|
||||
try {
|
||||
run(new FileScannerIOContext(toPathResolvingUserHome(filename).toString()));
|
||||
} catch (FileNotFoundException e) {
|
||||
hard("File '%s' is not found: %s", filename, e.getMessage());
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
hard("Exception while reading file: %s", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdPrompt() {
|
||||
private boolean cmdPrompt() {
|
||||
displayPrompt = !displayPrompt;
|
||||
fluff("Prompt will %sdisplay. Use /prompt to toggle.", displayPrompt ? "" : "NOT ");
|
||||
concise("Prompt: %s", displayPrompt ? "on" : "off");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdReset() {
|
||||
private boolean cmdReset() {
|
||||
live = false;
|
||||
fluff("Resetting state.");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdSave(String arg_filename) {
|
||||
private boolean cmdReload(String arg) {
|
||||
Iterable<String> history = replayableHistory;
|
||||
boolean echo = true;
|
||||
if (arg.length() > 0) {
|
||||
if ("restore".startsWith(arg)) {
|
||||
if (replayableHistoryPrevious == null) {
|
||||
hard("No previous history to restore\n", arg);
|
||||
return false;
|
||||
}
|
||||
history = replayableHistoryPrevious;
|
||||
} else if ("quiet".startsWith(arg)) {
|
||||
echo = false;
|
||||
} else {
|
||||
hard("Invalid argument to reload command: %s\nUse 'restore', 'quiet', or no argument\n", arg);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
fluff("Restarting and restoring %s.",
|
||||
history == replayableHistoryPrevious
|
||||
? "from previous state"
|
||||
: "state");
|
||||
resetState();
|
||||
run(new ReloadIOContext(history,
|
||||
echo? cmdout : null));
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean cmdSave(String arg_filename) {
|
||||
Matcher mat = HISTORY_ALL_START_FILENAME.matcher(arg_filename);
|
||||
if (!mat.find()) {
|
||||
hard("Malformed argument to the /save command: %s", arg_filename);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
boolean useHistory = false;
|
||||
String saveAll = "";
|
||||
@ -1211,7 +1309,7 @@ public class JShellTool {
|
||||
String filename = mat.group("filename");
|
||||
if (filename == null ||filename.isEmpty()) {
|
||||
hard("The /save command requires a filename argument.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(toPathResolvingUserHome(filename),
|
||||
Charset.defaultCharset(),
|
||||
@ -1234,12 +1332,15 @@ public class JShellTool {
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
hard("File '%s' for save is not accessible: %s", filename, e.getMessage());
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
hard("Exception while saving: %s", e);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdSetStart(String filename) {
|
||||
private boolean cmdSetStart(String filename) {
|
||||
if (filename.isEmpty()) {
|
||||
hard("The /setstart command requires a filename argument.");
|
||||
} else {
|
||||
@ -1249,30 +1350,36 @@ public class JShellTool {
|
||||
PREFS.put(STARTUP_KEY, init);
|
||||
} catch (AccessDeniedException e) {
|
||||
hard("File '%s' for /setstart is not accessible.", filename);
|
||||
return false;
|
||||
} catch (NoSuchFileException e) {
|
||||
hard("File '%s' for /setstart is not found.", filename);
|
||||
return false;
|
||||
} catch (Exception e) {
|
||||
hard("Exception while reading start set file: %s", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdVars() {
|
||||
private boolean cmdVars() {
|
||||
for (VarSnippet vk : state.variables()) {
|
||||
String val = state.status(vk) == Status.VALID
|
||||
? state.varValue(vk)
|
||||
: "(not-active)";
|
||||
hard(" %s %s = %s", vk.typeName(), vk.name(), val);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdMethods() {
|
||||
private boolean cmdMethods() {
|
||||
for (MethodSnippet mk : state.methods()) {
|
||||
hard(" %s %s", mk.name(), mk.signature());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdClasses() {
|
||||
private boolean cmdClasses() {
|
||||
for (TypeDeclSnippet ck : state.types()) {
|
||||
String kind;
|
||||
switch (ck.subKind()) {
|
||||
@ -1295,15 +1402,17 @@ public class JShellTool {
|
||||
}
|
||||
hard(" %s %s", kind, ck.name());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdImports() {
|
||||
private boolean cmdImports() {
|
||||
state.imports().forEach(ik -> {
|
||||
hard(" import %s%s", ik.isStatic() ? "static " : "", ik.fullname());
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
private void cmdUseHistoryEntry(int index) {
|
||||
private boolean cmdUseHistoryEntry(int index) {
|
||||
List<Snippet> keys = state.snippets();
|
||||
if (index < 0)
|
||||
index += keys.size();
|
||||
@ -1313,7 +1422,9 @@ public class JShellTool {
|
||||
rerunSnippet(keys.get(index));
|
||||
} else {
|
||||
hard("Cannot find snippet %d", index + 1);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean rerunHistoryEntryById(String id) {
|
||||
@ -1357,7 +1468,7 @@ public class JShellTool {
|
||||
}
|
||||
}
|
||||
|
||||
for (String line : diag.getMessage(null).split("\\r?\\n")) {
|
||||
for (String line : diag.getMessage(null).split("\\r?\\n")) { // TODO: Internationalize
|
||||
if (!line.trim().startsWith("location:")) {
|
||||
hard("%s%s", padding, line);
|
||||
}
|
||||
@ -1425,10 +1536,24 @@ public class JShellTool {
|
||||
private boolean processCompleteSource(String source) throws IllegalStateException {
|
||||
debug("Compiling: %s", source);
|
||||
boolean failed = false;
|
||||
boolean isActive = false;
|
||||
List<SnippetEvent> events = state.eval(source);
|
||||
for (SnippetEvent e : events) {
|
||||
// Report the event, recording failure
|
||||
failed |= handleEvent(e);
|
||||
|
||||
// If any main snippet is active, this should be replayable
|
||||
// also ignore var value queries
|
||||
isActive |= e.causeSnippet() == null &&
|
||||
e.status().isActive &&
|
||||
e.snippet().subKind() != VAR_VALUE_SUBKIND;
|
||||
}
|
||||
// If this is an active snippet and it didn't cause the backend to die,
|
||||
// add it to the replayable history
|
||||
if (isActive && live) {
|
||||
addToReplayHistory(source);
|
||||
}
|
||||
|
||||
return failed;
|
||||
}
|
||||
|
||||
@ -1784,31 +1909,11 @@ public class JShellTool {
|
||||
}
|
||||
}
|
||||
|
||||
class ScannerIOContext extends IOContext {
|
||||
|
||||
private final Scanner scannerIn;
|
||||
private final PrintStream pStream;
|
||||
|
||||
public ScannerIOContext(Scanner scannerIn, PrintStream pStream) {
|
||||
this.scannerIn = scannerIn;
|
||||
this.pStream = pStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readLine(String prompt, String prefix) {
|
||||
if (pStream != null && prompt != null) {
|
||||
pStream.print(prompt);
|
||||
}
|
||||
if (scannerIn.hasNextLine()) {
|
||||
return scannerIn.nextLine();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
abstract class NonInteractiveIOContext extends IOContext {
|
||||
|
||||
@Override
|
||||
public boolean interactiveOutput() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1816,11 +1921,6 @@ class ScannerIOContext extends IOContext {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
scannerIn.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean terminalEditorRunning() {
|
||||
return false;
|
||||
@ -1847,19 +1947,62 @@ class ScannerIOContext extends IOContext {
|
||||
}
|
||||
}
|
||||
|
||||
class FileScannerIOContext extends ScannerIOContext {
|
||||
class ScannerIOContext extends NonInteractiveIOContext {
|
||||
private final Scanner scannerIn;
|
||||
|
||||
public FileScannerIOContext(String fn) throws FileNotFoundException {
|
||||
this(new FileReader(fn));
|
||||
}
|
||||
|
||||
public FileScannerIOContext(Reader rdr) throws FileNotFoundException {
|
||||
super(new Scanner(rdr), null);
|
||||
ScannerIOContext(Scanner scannerIn) {
|
||||
this.scannerIn = scannerIn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean interactiveOutput() {
|
||||
return false;
|
||||
public String readLine(String prompt, String prefix) {
|
||||
if (scannerIn.hasNextLine()) {
|
||||
return scannerIn.nextLine();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
scannerIn.close();
|
||||
}
|
||||
}
|
||||
|
||||
class FileScannerIOContext extends ScannerIOContext {
|
||||
|
||||
FileScannerIOContext(String fn) throws FileNotFoundException {
|
||||
this(new FileReader(fn));
|
||||
}
|
||||
|
||||
FileScannerIOContext(Reader rdr) throws FileNotFoundException {
|
||||
super(new Scanner(rdr));
|
||||
}
|
||||
}
|
||||
|
||||
class ReloadIOContext extends NonInteractiveIOContext {
|
||||
private final Iterator<String> it;
|
||||
private final PrintStream echoStream;
|
||||
|
||||
ReloadIOContext(Iterable<String> history, PrintStream echoStream) {
|
||||
this.it = history.iterator();
|
||||
this.echoStream = echoStream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String readLine(String prompt, String prefix) {
|
||||
String s = it.hasNext()
|
||||
? it.next()
|
||||
: null;
|
||||
if (echoStream != null && s != null) {
|
||||
String p = "-: ";
|
||||
String p2 = "\n ";
|
||||
echoStream.printf("%s%s\n", p, s.replace("\n", p2));
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
}
|
||||
}
|
||||
|
@ -26,9 +26,12 @@
|
||||
package jdk.jshell;
|
||||
|
||||
import static jdk.internal.jshell.remote.RemoteCodes.*;
|
||||
import java.io.DataInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import com.sun.jdi.*;
|
||||
@ -69,7 +72,9 @@ class ExecutionControl {
|
||||
socket = listener.accept();
|
||||
// out before in -- match remote creation so we don't hang
|
||||
out = new ObjectOutputStream(socket.getOutputStream());
|
||||
in = new ObjectInputStream(socket.getInputStream());
|
||||
PipeInputStream commandIn = new PipeInputStream();
|
||||
new DemultiplexInput(socket.getInputStream(), commandIn, proc.out, proc.err).start();
|
||||
in = new ObjectInputStream(commandIn);
|
||||
}
|
||||
}
|
||||
|
||||
@ -117,11 +122,13 @@ class ExecutionControl {
|
||||
String result = in.readUTF();
|
||||
return result;
|
||||
}
|
||||
} catch (EOFException ex) {
|
||||
env.shutdown();
|
||||
} catch (IOException | ClassNotFoundException ex) {
|
||||
proc.debug(DBG_GEN, "Exception on remote invoke: %s\n", ex);
|
||||
return "Execution failure: " + ex.getMessage();
|
||||
if (!env.connection().isRunning()) {
|
||||
env.shutdown();
|
||||
} else {
|
||||
proc.debug(DBG_GEN, "Exception on remote invoke: %s\n", ex);
|
||||
return "Execution failure: " + ex.getMessage();
|
||||
}
|
||||
} finally {
|
||||
synchronized (STOP_LOCK) {
|
||||
userCodeRunning = false;
|
||||
@ -310,4 +317,112 @@ class ExecutionControl {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class DemultiplexInput extends Thread {
|
||||
|
||||
private final DataInputStream delegate;
|
||||
private final PipeInputStream command;
|
||||
private final PrintStream out;
|
||||
private final PrintStream err;
|
||||
|
||||
public DemultiplexInput(InputStream input,
|
||||
PipeInputStream command,
|
||||
PrintStream out,
|
||||
PrintStream err) {
|
||||
super("output reader");
|
||||
this.delegate = new DataInputStream(input);
|
||||
this.command = command;
|
||||
this.out = out;
|
||||
this.err = err;
|
||||
}
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
while (true) {
|
||||
int nameLen = delegate.read();
|
||||
if (nameLen == (-1))
|
||||
break;
|
||||
byte[] name = new byte[nameLen];
|
||||
DemultiplexInput.this.delegate.readFully(name);
|
||||
int dataLen = delegate.read();
|
||||
byte[] data = new byte[dataLen];
|
||||
DemultiplexInput.this.delegate.readFully(data);
|
||||
switch (new String(name, "UTF-8")) {
|
||||
case "err":
|
||||
err.write(data);
|
||||
break;
|
||||
case "out":
|
||||
out.write(data);
|
||||
break;
|
||||
case "command":
|
||||
for (byte b : data) {
|
||||
command.write(Byte.toUnsignedInt(b));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
proc.debug(ex, "Failed reading output");
|
||||
} finally {
|
||||
command.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static final class PipeInputStream extends InputStream {
|
||||
public static final int INITIAL_SIZE = 128;
|
||||
|
||||
private int[] buffer = new int[INITIAL_SIZE];
|
||||
private int start;
|
||||
private int end;
|
||||
private boolean closed;
|
||||
|
||||
@Override
|
||||
public synchronized int read() {
|
||||
while (start == end) {
|
||||
if (closed) {
|
||||
return -1;
|
||||
}
|
||||
try {
|
||||
wait();
|
||||
} catch (InterruptedException ex) {
|
||||
//ignore
|
||||
}
|
||||
}
|
||||
try {
|
||||
return buffer[start];
|
||||
} finally {
|
||||
start = (start + 1) % buffer.length;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void write(int b) {
|
||||
if (closed)
|
||||
throw new IllegalStateException("Already closed.");
|
||||
int newEnd = (end + 1) % buffer.length;
|
||||
if (newEnd == start) {
|
||||
//overflow:
|
||||
int[] newBuffer = new int[buffer.length * 2];
|
||||
int rightPart = (end > start ? end : buffer.length) - start;
|
||||
int leftPart = end > start ? 0 : start - 1;
|
||||
System.arraycopy(buffer, start, newBuffer, 0, rightPart);
|
||||
System.arraycopy(buffer, 0, newBuffer, rightPart, leftPart);
|
||||
buffer = newBuffer;
|
||||
start = 0;
|
||||
end = rightPart + leftPart;
|
||||
newEnd = end + 1;
|
||||
}
|
||||
buffer[end] = b;
|
||||
end = newEnd;
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
closed = true;
|
||||
notifyAll();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -133,7 +133,7 @@ class JDIConnection {
|
||||
return vm;
|
||||
}
|
||||
|
||||
boolean setConnectorArg(String name, String value) {
|
||||
synchronized boolean setConnectorArg(String name, String value) {
|
||||
/*
|
||||
* Too late if the connection already made
|
||||
*/
|
||||
@ -165,7 +165,7 @@ class JDIConnection {
|
||||
}
|
||||
}
|
||||
|
||||
boolean isOpen() {
|
||||
synchronized boolean isOpen() {
|
||||
return (vm != null);
|
||||
}
|
||||
|
||||
@ -173,13 +173,17 @@ class JDIConnection {
|
||||
return (connector instanceof LaunchingConnector);
|
||||
}
|
||||
|
||||
public void disposeVM() {
|
||||
synchronized boolean isRunning() {
|
||||
return process != null && process.isAlive();
|
||||
}
|
||||
|
||||
public synchronized void disposeVM() {
|
||||
try {
|
||||
if (vm != null) {
|
||||
vm.dispose(); // This could NPE, so it is caught below
|
||||
vm = null;
|
||||
}
|
||||
} catch (VMDisconnectedException | NullPointerException ex) {
|
||||
} catch (VMDisconnectedException ex) {
|
||||
// Ignore if already closed
|
||||
} finally {
|
||||
if (process != null) {
|
||||
|
@ -182,9 +182,9 @@ final class OuterWrap implements GeneralWrap {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WrappedDiagnostic(" + getMessage(null) + ":" + getPosition() + ")";
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
return "WrappedDiagnostic(" + getMessage(null) + ":" + getPosition() + ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,6 @@ import com.sun.tools.javac.api.JavacTool;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import javax.tools.Diagnostic;
|
||||
import javax.tools.DiagnosticCollector;
|
||||
@ -395,7 +394,7 @@ class TaskFactory {
|
||||
LinkedHashMap<String, Diag> diagMap = new LinkedHashMap<>();
|
||||
for (Diagnostic<? extends JavaFileObject> in : diagnostics.getDiagnostics()) {
|
||||
Diag d = diag(in);
|
||||
String uniqueKey = d.getCode() + ":" + d.getPosition() + ":" + d.getMessage(null);
|
||||
String uniqueKey = d.getCode() + ":" + d.getPosition() + ":" + d.getMessage(PARSED_LOCALE);
|
||||
diagMap.put(uniqueKey, d);
|
||||
}
|
||||
diags = new DiagList(diagMap.values());
|
||||
@ -410,7 +409,7 @@ class TaskFactory {
|
||||
String shortErrorMessage() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Diag diag : getDiagnostics()) {
|
||||
for (String line : diag.getMessage(null).split("\\r?\\n")) {
|
||||
for (String line : diag.getMessage(PARSED_LOCALE).split("\\r?\\n")) {
|
||||
if (!line.trim().startsWith("location:")) {
|
||||
sb.append(line);
|
||||
}
|
||||
@ -422,7 +421,7 @@ class TaskFactory {
|
||||
void debugPrintDiagnostics(String src) {
|
||||
for (Diag diag : getDiagnostics()) {
|
||||
state.debug(DBG_GEN, "ERROR --\n");
|
||||
for (String line : diag.getMessage(null).split("\\r?\\n")) {
|
||||
for (String line : diag.getMessage(PARSED_LOCALE).split("\\r?\\n")) {
|
||||
if (!line.trim().startsWith("location:")) {
|
||||
state.debug(DBG_GEN, "%s\n", line);
|
||||
}
|
||||
|
@ -50,6 +50,7 @@ import static jdk.jshell.Snippet.Status.RECOVERABLE_DEFINED;
|
||||
import static jdk.jshell.Snippet.Status.RECOVERABLE_NOT_DEFINED;
|
||||
import static jdk.jshell.Snippet.Status.REJECTED;
|
||||
import static jdk.jshell.Snippet.Status.VALID;
|
||||
import static jdk.jshell.Util.PARSED_LOCALE;
|
||||
import static jdk.jshell.Util.expunge;
|
||||
|
||||
/**
|
||||
@ -456,7 +457,7 @@ final class Unit {
|
||||
for (Diag diag : diags) {
|
||||
if (diag.isError()) {
|
||||
if (diag.isResolutionError()) {
|
||||
String m = diag.getMessage(null);
|
||||
String m = diag.getMessage(PARSED_LOCALE);
|
||||
int symPos = m.indexOf(RESOLVE_ERROR_SYMBOL);
|
||||
if (symPos >= 0) {
|
||||
m = m.substring(symPos + RESOLVE_ERROR_SYMBOL.length());
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
package jdk.jshell;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.stream.Stream;
|
||||
import java.util.stream.StreamSupport;
|
||||
import javax.lang.model.element.Name;
|
||||
@ -40,6 +41,8 @@ class Util {
|
||||
static final String REPL_CLASS_PREFIX = "$REPL";
|
||||
static final String REPL_DOESNOTMATTER_CLASS_NAME = REPL_CLASS_PREFIX+"00DOESNOTMATTER";
|
||||
|
||||
static final Locale PARSED_LOCALE = Locale.ROOT;
|
||||
|
||||
static boolean isDoIt(Name name) {
|
||||
return isDoIt(name.toString());
|
||||
}
|
||||
|
@ -152,13 +152,13 @@ public class ReplToolTesting {
|
||||
}
|
||||
|
||||
public String getCommandOutput() {
|
||||
String s = cmdout.toString();
|
||||
String s = normalizeLineEndings(cmdout.toString());
|
||||
cmdout.reset();
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getCommandErrorOutput() {
|
||||
String s = cmderr.toString();
|
||||
String s = normalizeLineEndings(cmderr.toString());
|
||||
cmderr.reset();
|
||||
return s;
|
||||
}
|
||||
@ -168,13 +168,13 @@ public class ReplToolTesting {
|
||||
}
|
||||
|
||||
public String getUserOutput() {
|
||||
String s = userout.toString();
|
||||
String s = normalizeLineEndings(userout.toString());
|
||||
userout.reset();
|
||||
return s;
|
||||
}
|
||||
|
||||
public String getUserErrorOutput() {
|
||||
String s = usererr.toString();
|
||||
String s = normalizeLineEndings(usererr.toString());
|
||||
usererr.reset();
|
||||
return s;
|
||||
}
|
||||
@ -461,6 +461,10 @@ public class ReplToolTesting {
|
||||
}
|
||||
}
|
||||
|
||||
private String normalizeLineEndings(String text) {
|
||||
return text.replace(System.getProperty("line.separator"), "\n");
|
||||
}
|
||||
|
||||
public static abstract class MemberInfo {
|
||||
public final String source;
|
||||
public final String type;
|
||||
|
42
langtools/test/jdk/jshell/T8146368/JShellTest8146368.java
Normal file
42
langtools/test/jdk/jshell/T8146368/JShellTest8146368.java
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8146368
|
||||
* @summary Test Smashing Error when user language is Japanese
|
||||
* @library /tools/lib /jdk/jshell
|
||||
* @build KullaTesting
|
||||
* @run testng/othervm -Duser.language=ja JShellTest8146368
|
||||
*/
|
||||
|
||||
import static jdk.jshell.Snippet.Status.RECOVERABLE_NOT_DEFINED;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test
|
||||
public class JShellTest8146368 extends KullaTesting {
|
||||
public void test() {
|
||||
assertEval("class A extends B {}", added(RECOVERABLE_NOT_DEFINED));
|
||||
assertEval("und m() { return new und(); }", added(RECOVERABLE_NOT_DEFINED));
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8146368
|
||||
* @summary Test Smashing Error when user language is Japanese
|
||||
* @library /tools/lib /jdk/jshell
|
||||
* @build ReplToolTesting
|
||||
* @run testng/othervm -Duser.language=ja JShellToolTest8146368
|
||||
*/
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@Test
|
||||
public class JShellToolTest8146368 extends ReplToolTesting {
|
||||
public void test() {
|
||||
test(
|
||||
a -> assertCommand(a, "class A extends B {}", "| Added class A, however, it cannot be referenced until class B is declared\n"),
|
||||
a -> assertCommand(a, "und m() { return new und(); }", "| Added method m(), however, it cannot be referenced until class und is declared\n")
|
||||
);
|
||||
}
|
||||
}
|
@ -23,14 +23,16 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8143037 8142447 8144095 8140265
|
||||
* @bug 8143037 8142447 8144095 8140265 8144906
|
||||
* @requires os.family != "solaris"
|
||||
* @summary Tests for Basic tests for REPL tool
|
||||
* @library /tools/lib
|
||||
* @ignore 8139873
|
||||
* @build KullaTesting TestingInputStream ToolBox Compiler
|
||||
* @run testng ToolBasicTest
|
||||
* @run testng/timeout=600 ToolBasicTest
|
||||
*/
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
@ -460,8 +462,7 @@ public class ToolBasicTest extends ReplToolTesting {
|
||||
Path unknown = compiler.getPath("UNKNOWN.jar");
|
||||
test(true, new String[]{unknown.toString()},
|
||||
"| File '" + unknown
|
||||
+ "' is not found: " + unknown
|
||||
+ " (No such file or directory)\n");
|
||||
+ "' is not found: " + unresolvableMessage(unknown) + "\n");
|
||||
}
|
||||
|
||||
public void testReset() {
|
||||
@ -514,8 +515,7 @@ public class ToolBasicTest extends ReplToolTesting {
|
||||
test(
|
||||
(a) -> assertCommand(a, s + " " + unknown,
|
||||
"| File '" + unknown
|
||||
+ "' is not found: " + unknown
|
||||
+ " (No such file or directory)\n")
|
||||
+ "' is not found: " + unresolvableMessage(unknown) + "\n")
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -874,6 +874,15 @@ public class ToolBasicTest extends ReplToolTesting {
|
||||
);
|
||||
}
|
||||
|
||||
private String unresolvableMessage(Path p) {
|
||||
try {
|
||||
new FileInputStream(p.toFile());
|
||||
throw new AssertionError("Expected exception did not occur.");
|
||||
} catch (IOException ex) {
|
||||
return ex.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
public void testCommandPrefix() {
|
||||
test(a -> assertCommandCheckOutput(a, "/s",
|
||||
assertStartsWith("| Command: /s is ambiguous: /seteditor, /save, /setstart")),
|
||||
|
197
langtools/test/jdk/jshell/ToolReloadTest.java
Normal file
197
langtools/test/jdk/jshell/ToolReloadTest.java
Normal file
@ -0,0 +1,197 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8081845
|
||||
* @summary Tests for /reload in JShell tool
|
||||
* @library /tools/lib
|
||||
* @build KullaTesting TestingInputStream ToolBox Compiler
|
||||
* @run testng ToolReloadTest
|
||||
*/
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
|
||||
@Test
|
||||
public class ToolReloadTest extends ReplToolTesting {
|
||||
|
||||
public void testReloadSnippets() {
|
||||
test(
|
||||
(a) -> assertVariable(a, "int", "x", "5", "5"),
|
||||
(a) -> assertMethod(a, "int m(int z) { return z * z; }",
|
||||
"(int)int", "m"),
|
||||
(a) -> evaluateExpression(a, "int", "m(x)", "25"),
|
||||
(a) -> assertCommand(a, "/reload",
|
||||
"| Restarting and restoring state.\n" +
|
||||
"-: int x = 5;\n" +
|
||||
"-: int m(int z) { return z * z; }\n" +
|
||||
"-: m(x)\n"),
|
||||
(a) -> evaluateExpression(a, "int", "m(x)", "25"),
|
||||
(a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
|
||||
(a) -> assertCommandCheckOutput(a, "/methods", assertMethods())
|
||||
);
|
||||
}
|
||||
|
||||
public void testReloadClasspath() {
|
||||
Function<String,String> prog = (s) -> String.format(
|
||||
"package pkg; public class A { public String toString() { return \"%s\"; } }\n", s);
|
||||
Compiler compiler = new Compiler();
|
||||
Path outDir = Paths.get("testClasspathDirectory");
|
||||
compiler.compile(outDir, prog.apply("A"));
|
||||
Path classpath = compiler.getPath(outDir);
|
||||
test(
|
||||
(a) -> assertCommand(a, "/classpath " + classpath,
|
||||
String.format("| Path %s added to classpath\n", classpath)),
|
||||
(a) -> assertMethod(a, "String foo() { return (new pkg.A()).toString(); }",
|
||||
"()String", "foo"),
|
||||
(a) -> assertVariable(a, "String", "v", "foo()", "\"A\""),
|
||||
(a) -> {
|
||||
if (!a) compiler.compile(outDir, prog.apply("Aprime"));
|
||||
assertCommand(a, "/reload",
|
||||
"| Restarting and restoring state.\n" +
|
||||
"-: /classpath " + classpath + "\n" +
|
||||
"-: String foo() { return (new pkg.A()).toString(); }\n" +
|
||||
"-: String v = foo();\n");
|
||||
},
|
||||
(a) -> assertCommand(a, "v", "| Variable v of type String has value \"Aprime\"\n"),
|
||||
(a) -> evaluateExpression(a, "String", "foo()", "\"Aprime\""),
|
||||
(a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "\"Aprime\"")
|
||||
);
|
||||
}
|
||||
|
||||
public void testReloadDrop() {
|
||||
test(false, new String[]{"-nostartup"},
|
||||
a -> assertVariable(a, "int", "a"),
|
||||
a -> dropVariable(a, "/dr 1", "int a = 0"),
|
||||
a -> assertMethod(a, "int b() { return 0; }", "()I", "b"),
|
||||
a -> dropMethod(a, "/drop b", "b ()I"),
|
||||
a -> assertClass(a, "class A {}", "class", "A"),
|
||||
a -> dropClass(a, "/dr A", "class A"),
|
||||
a -> assertCommand(a, "/reload",
|
||||
"| Restarting and restoring state.\n" +
|
||||
"-: int a;\n" +
|
||||
"-: /drop 1\n" +
|
||||
"-: int b() { return 0; }\n" +
|
||||
"-: /drop b\n" +
|
||||
"-: class A {}\n" +
|
||||
"-: /drop A\n"),
|
||||
a -> assertCommandCheckOutput(a, "/vars", assertVariables()),
|
||||
a -> assertCommandCheckOutput(a, "/methods", assertMethods()),
|
||||
a -> assertCommandCheckOutput(a, "/classes", assertClasses()),
|
||||
a -> assertCommandCheckOutput(a, "/imports", assertImports())
|
||||
);
|
||||
}
|
||||
|
||||
public void testReloadRepeat() {
|
||||
test(false, new String[]{"-nostartup"},
|
||||
(a) -> assertVariable(a, "int", "c", "7", "7"),
|
||||
(a) -> assertCommand(a, "++c", null),
|
||||
(a) -> assertCommand(a, "/!", null),
|
||||
(a) -> assertCommand(a, "/2", null),
|
||||
(a) -> assertCommand(a, "/-1", null),
|
||||
(a) -> assertCommand(a, "/reload",
|
||||
"| Restarting and restoring state.\n" +
|
||||
"-: int c = 7;\n" +
|
||||
"-: ++c\n" +
|
||||
"-: ++c\n" +
|
||||
"-: ++c\n" +
|
||||
"-: ++c\n"
|
||||
),
|
||||
(a) -> assertCommand(a, "c", "| Variable c of type int has value 11\n"),
|
||||
(a) -> assertCommand(a, "$4", "| Variable $4 of type int has value 10\n")
|
||||
);
|
||||
}
|
||||
|
||||
public void testReloadIgnore() {
|
||||
test(false, new String[]{"-nostartup"},
|
||||
(a) -> assertCommand(a, "(-)", null),
|
||||
(a) -> assertCommand(a, "/list", null),
|
||||
(a) -> assertCommand(a, "/history", null),
|
||||
(a) -> assertCommand(a, "/help", null),
|
||||
(a) -> assertCommand(a, "/vars", null),
|
||||
(a) -> assertCommand(a, "/save abcd", null),
|
||||
(a) -> assertCommand(a, "/reload",
|
||||
"| Restarting and restoring state.\n")
|
||||
);
|
||||
}
|
||||
|
||||
public void testReloadResetRestore() {
|
||||
test(
|
||||
(a) -> assertVariable(a, "int", "x", "5", "5"),
|
||||
(a) -> assertMethod(a, "int m(int z) { return z * z; }",
|
||||
"(int)int", "m"),
|
||||
(a) -> evaluateExpression(a, "int", "m(x)", "25"),
|
||||
(a) -> assertCommand(a, "/reset", "| Resetting state.\n"),
|
||||
(a) -> assertCommand(a, "/reload restore",
|
||||
"| Restarting and restoring from previous state.\n" +
|
||||
"-: int x = 5;\n" +
|
||||
"-: int m(int z) { return z * z; }\n" +
|
||||
"-: m(x)\n"),
|
||||
(a) -> evaluateExpression(a, "int", "m(x)", "25"),
|
||||
(a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
|
||||
(a) -> assertCommandCheckOutput(a, "/methods", assertMethods())
|
||||
);
|
||||
}
|
||||
|
||||
public void testReloadCrashRestore() {
|
||||
test(
|
||||
(a) -> assertVariable(a, "int", "x", "5", "5"),
|
||||
(a) -> assertMethod(a, "int m(int z) { return z * z; }",
|
||||
"(int)int", "m"),
|
||||
(a) -> evaluateExpression(a, "int", "m(x)", "25"),
|
||||
(a) -> assertCommand(a, "System.exit(1);",
|
||||
"| State engine terminated.\n" +
|
||||
"| Restore definitions with: /reload restore\n"),
|
||||
(a) -> assertCommand(a, "/reload restore",
|
||||
"| Restarting and restoring from previous state.\n" +
|
||||
"-: int x = 5;\n" +
|
||||
"-: int m(int z) { return z * z; }\n" +
|
||||
"-: m(x)\n"),
|
||||
(a) -> evaluateExpression(a, "int", "m(x)", "25"),
|
||||
(a) -> assertCommandCheckOutput(a, "/vars", assertVariables()),
|
||||
(a) -> assertCommandCheckOutput(a, "/methods", assertMethods())
|
||||
);
|
||||
}
|
||||
|
||||
public void testReloadExitRestore() {
|
||||
test(false, new String[]{"-nostartup"},
|
||||
(a) -> assertVariable(a, "int", "x", "5", "5"),
|
||||
(a) -> assertMethod(a, "int m(int z) { return z * z; }",
|
||||
"(int)int", "m"),
|
||||
(a) -> evaluateExpression(a, "int", "m(x)", "25")
|
||||
);
|
||||
test(false, new String[]{"-nostartup"},
|
||||
(a) -> assertCommand(a, "/reload restore",
|
||||
"| Restarting and restoring from previous state.\n" +
|
||||
"-: int x = 5;\n" +
|
||||
"-: int m(int z) { return z * z; }\n" +
|
||||
"-: m(x)\n"),
|
||||
(a) -> evaluateExpression(a, "int", "m(x)", "25")
|
||||
);
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* @test /nodynamiccopyright/
|
||||
* @bug 4049982
|
||||
* @bug 4049982 8056897
|
||||
* @summary Compiler permitted invalid hex literal.
|
||||
* @author turnidge
|
||||
*
|
||||
|
@ -1,3 +1,2 @@
|
||||
BadHexConstant.java:12:14: compiler.err.invalid.hex.number
|
||||
BadHexConstant.java:12:17: compiler.err.expected: token.identifier
|
||||
2 errors
|
||||
1 error
|
||||
|
@ -1,259 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 6430241
|
||||
* @summary Hard to disable symbol file feature through API
|
||||
* @library /tools/lib
|
||||
* @modules jdk.compiler/com.sun.tools.javac.api
|
||||
* jdk.compiler/com.sun.tools.javac.file
|
||||
* jdk.compiler/com.sun.tools.javac.main
|
||||
* jdk.compiler/com.sun.tools.javac.util
|
||||
* @build ToolBox
|
||||
* @run main T6430241
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.tools.*;
|
||||
|
||||
import com.sun.source.util.JavacTask;
|
||||
import com.sun.tools.javac.api.JavacTool;
|
||||
import com.sun.tools.javac.file.JavacFileManager;
|
||||
import com.sun.tools.javac.util.Context;
|
||||
|
||||
public class T6430241 {
|
||||
public static void main(String... args) throws Exception {
|
||||
new T6430241().run();
|
||||
}
|
||||
|
||||
void run() throws Exception {
|
||||
setup();
|
||||
testCommandLine();
|
||||
testSimpleAPI();
|
||||
testTaskAPI();
|
||||
|
||||
if (errors > 0)
|
||||
throw new Exception(errors + " errors found");
|
||||
}
|
||||
|
||||
void setup() throws Exception {
|
||||
classesDir = new File("classes");
|
||||
classesDir.mkdirs();
|
||||
|
||||
emptyDir = new File("empty");
|
||||
emptyDir.mkdirs();
|
||||
|
||||
bootClassPath = createJar().getPath();
|
||||
|
||||
File srcDir = new File("src");
|
||||
String test = "import sun.misc.Unsafe; class Test { }";
|
||||
testFile = writeFile(srcDir, "Test.java", test);
|
||||
}
|
||||
|
||||
//----- tests for command line invocation
|
||||
|
||||
void testCommandLine() throws Exception {
|
||||
testCommandLine(true);
|
||||
testCommandLine(false, "-Xbootclasspath/p:" + emptyDir);
|
||||
testCommandLine(false, "-Xbootclasspath:" + bootClassPath);
|
||||
testCommandLine(false, "-Xbootclasspath/a:" + emptyDir);
|
||||
testCommandLine(false, "-XDignore.symbol.file");
|
||||
System.err.println();
|
||||
}
|
||||
|
||||
void testCommandLine(boolean expectWarnings, String... opts) throws Exception {
|
||||
System.err.println("test command line: " + Arrays.asList(opts));
|
||||
|
||||
String[] args = initArgs(opts);
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
int rc = com.sun.tools.javac.Main.compile(args, pw);
|
||||
String out = showOutput(sw.toString());
|
||||
|
||||
checkCompilationOK(rc);
|
||||
checkOutput(out, expectWarnings);
|
||||
}
|
||||
|
||||
//----- tests for simple API invocation
|
||||
|
||||
void testSimpleAPI() {
|
||||
testSimpleAPI(true);
|
||||
testSimpleAPI(false, "-Xbootclasspath/p:" + emptyDir);
|
||||
testSimpleAPI(false, "-Xbootclasspath:" + bootClassPath);
|
||||
testSimpleAPI(false, "-Xbootclasspath/a:" + emptyDir);
|
||||
testSimpleAPI(false, "-XDignore.symbol.file");
|
||||
System.err.println();
|
||||
}
|
||||
|
||||
void testSimpleAPI(boolean expectWarnings, String... opts) {
|
||||
System.err.println("test simple API: " + Arrays.asList(opts));
|
||||
|
||||
String[] args = initArgs(opts);
|
||||
|
||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||
PrintStream ps = new PrintStream(baos);
|
||||
|
||||
JavacTool tool = JavacTool.create();
|
||||
int rc = tool.run(null, null, ps, args);
|
||||
|
||||
String out = showOutput(baos.toString());
|
||||
|
||||
checkCompilationOK(rc);
|
||||
checkOutput(out, expectWarnings);
|
||||
}
|
||||
|
||||
//----- tests for CompilationTask API invocation
|
||||
|
||||
void testTaskAPI() throws Exception {
|
||||
List<File> bcp = new ArrayList<File>();
|
||||
for (String f: bootClassPath.split(File.pathSeparator)) {
|
||||
if (!f.isEmpty())
|
||||
bcp.add(new File(f));
|
||||
}
|
||||
|
||||
testTaskAPI(true, null);
|
||||
testTaskAPI(false, bcp);
|
||||
System.err.println();
|
||||
}
|
||||
|
||||
void testTaskAPI(boolean expectWarnings, Iterable<? extends File> pcp) throws Exception {
|
||||
System.err.println("test task API: " + pcp);
|
||||
|
||||
JavacTool tool = JavacTool.create();
|
||||
try (StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null)) {
|
||||
|
||||
if (pcp != null)
|
||||
fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, pcp);
|
||||
|
||||
Iterable<? extends JavaFileObject> files = fm.getJavaFileObjects(testFile);
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
JavacTask task = tool.getTask(pw, fm, null, null, null, files);
|
||||
boolean ok = task.call();
|
||||
String out = showOutput(sw.toString());
|
||||
|
||||
checkCompilationOK(ok);
|
||||
checkOutput(out, expectWarnings);
|
||||
}
|
||||
}
|
||||
|
||||
//----- utility methods
|
||||
|
||||
File createJar() throws IOException {
|
||||
File f = new File("test.jar");
|
||||
try (JavaFileManager fm = new JavacFileManager(new Context(), false, null)) {
|
||||
ToolBox tb = new ToolBox();
|
||||
tb.new JarTask(f.getPath())
|
||||
.files(fm, StandardLocation.PLATFORM_CLASS_PATH, "java.lang.*", "sun.misc.*")
|
||||
.run();
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a file with given content.
|
||||
*/
|
||||
File writeFile(File dir, String path, String content) throws IOException {
|
||||
File f = new File(dir, path);
|
||||
f.getParentFile().mkdirs();
|
||||
FileWriter out = new FileWriter(f);
|
||||
try {
|
||||
out.write(content);
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
return f;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize args for compilation with given opts.
|
||||
* @return opts -d classesDir testFile
|
||||
*/
|
||||
String[] initArgs(String[] opts) {
|
||||
List<String> args = new ArrayList<String>();
|
||||
args.addAll(Arrays.asList(opts));
|
||||
args.add("-d");
|
||||
args.add(classesDir.getPath());
|
||||
args.add(testFile.getPath());
|
||||
return args.toArray(new String[args.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show output from compilation if non empty.
|
||||
*/
|
||||
String showOutput(String out) {
|
||||
if (!out.isEmpty())
|
||||
System.err.println(out);
|
||||
return out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify compilation succeeded.
|
||||
*/
|
||||
void checkCompilationOK(boolean ok) {
|
||||
if (!ok)
|
||||
error("compilation failed");
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify compilation succeeded.
|
||||
*/
|
||||
void checkCompilationOK(int rc) {
|
||||
if (rc != 0)
|
||||
error("compilation failed, rc: " + rc);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether output contains warnings if and only if warnings
|
||||
* are expected.
|
||||
*/
|
||||
void checkOutput(String out, boolean expectWarnings) {
|
||||
boolean foundWarnings = out.contains("warning");
|
||||
if (foundWarnings) {
|
||||
if (!expectWarnings)
|
||||
error("unexpected warnings found");
|
||||
} else {
|
||||
if (expectWarnings)
|
||||
error("expected warnings not found");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Report an error.
|
||||
*/
|
||||
void error(String msg) {
|
||||
System.err.println("error: " + msg);
|
||||
errors++;
|
||||
}
|
||||
|
||||
String bootClassPath;
|
||||
File classesDir;
|
||||
File emptyDir;
|
||||
File testFile;
|
||||
int errors;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user