# HG changeset patch # User chegar # Date 1512469725 0 # Node ID 64298b1e890babfc848e074afaa98c0b553c1df5 # Parent 10b34c929b4f9c3913284e4ba5e6f8e1d6e548ef# Parent f14a1972f35de5a721c1bd6eb789c462d4f4b60a http-client-branch: merge with default diff -r 10b34c929b4f -r 64298b1e890b .hgtags --- a/.hgtags Tue Dec 05 10:21:41 2017 +0000 +++ b/.hgtags Tue Dec 05 10:28:45 2017 +0000 @@ -458,3 +458,4 @@ e6278add9ff28fab70fe1cc4c1d65f7363dc9445 jdk-10+31 a2008587c13fa05fa2dbfcb09fe987576fbedfd1 jdk-10+32 bbd692ad4fa300ecca7939ffbe3b1d5e52a28cc6 jdk-10+33 +89deac44e51517841491ba86ff44aa82a5ca96b3 jdk-10+34 diff -r 10b34c929b4f -r 64298b1e890b doc/testing.html --- a/doc/testing.html Tue Dec 05 10:21:41 2017 +0000 +++ b/doc/testing.html Tue Dec 05 10:28:45 2017 +0000 @@ -57,6 +57,7 @@
Since the Hotspot Gtest suite is so quick, the default is to run all tests. This is specified by just gtest
, or as a fully qualified test descriptor gtest:all
.
If you want, you can single out an individual test or a group of tests, for instance gtest:LogDecorations
or gtest:LogDecorations.level_test_vm
. This can be particularly useful if you want to run a shaky test repeatedly.
For Gtest, there is a separate test suite for each JVM variant. The JVM variant is defined by adding /<variant>
to the test descriptor, e.g. gtest:Log/client
. If you specify no variant, gtest will run once for each JVM variant present (e.g. server, client). So if you only have the server JVM present, then gtest:all
will be equivalent to gtest:all/server
.
At the end of the test run, a summary of all tests run will be presented. This will have a consistent look, regardless of what test suites were used. This is a sample summary:
==============================
diff -r 10b34c929b4f -r 64298b1e890b doc/testing.md
--- a/doc/testing.md Tue Dec 05 10:21:41 2017 +0000
+++ b/doc/testing.md Tue Dec 05 10:28:45 2017 +0000
@@ -81,6 +81,12 @@
instance `gtest:LogDecorations` or `gtest:LogDecorations.level_test_vm`. This
can be particularly useful if you want to run a shaky test repeatedly.
+For Gtest, there is a separate test suite for each JVM variant. The JVM variant
+is defined by adding `/` to the test descriptor, e.g.
+`gtest:Log/client`. If you specify no variant, gtest will run once for each JVM
+variant present (e.g. server, client). So if you only have the server JVM
+present, then `gtest:all` will be equivalent to `gtest:all/server`.
+
## Test results and summary
At the end of the test run, a summary of all tests run will be presented. This
diff -r 10b34c929b4f -r 64298b1e890b make/CompileJavaModules.gmk
--- a/make/CompileJavaModules.gmk Tue Dec 05 10:21:41 2017 +0000
+++ b/make/CompileJavaModules.gmk Tue Dec 05 10:28:45 2017 +0000
@@ -300,7 +300,9 @@
################################################################################
-java.xml_SETUP := GENERATE_JDKBYTECODE_NOWARNINGS
+java.xml_ADD_JAVAC_FLAGS += -Xdoclint:all/protected \
+ '-Xdoclint/package:$(call CommaList, javax.xml.catalog javax.xml.datatype \
+ javax.xml.transform javax.xml.validation javax.xml.xpath)'
java.xml_CLEAN += .properties
################################################################################
diff -r 10b34c929b4f -r 64298b1e890b make/InitSupport.gmk
--- a/make/InitSupport.gmk Tue Dec 05 10:21:41 2017 +0000
+++ b/make/InitSupport.gmk Tue Dec 05 10:28:45 2017 +0000
@@ -279,7 +279,9 @@
# generated files.
ifeq ($$(MAKE_RESTARTS),)
ifeq ($$(words $$(matching_confs)), 1)
- $$(info Building configuration '$$(matching_confs)' (matching CONF=$$(CONF)))
+ ifneq ($$(findstring $$(LOG_LEVEL), info debug trace),)
+ $$(info Building configuration '$$(matching_confs)' (matching CONF=$$(CONF)))
+ endif
else
$$(info Building these configurations (matching CONF=$$(CONF)):)
$$(foreach var, $$(matching_confs), $$(info * $$(var)))
diff -r 10b34c929b4f -r 64298b1e890b make/RunTests.gmk
--- a/make/RunTests.gmk Tue Dec 05 10:21:41 2017 +0000
+++ b/make/RunTests.gmk Tue Dec 05 10:28:45 2017 +0000
@@ -68,6 +68,7 @@
TEST_RESULTS_DIR := $(OUTPUTDIR)/test-results
TEST_SUPPORT_DIR := $(OUTPUTDIR)/test-support
TEST_SUMMARY := $(TEST_RESULTS_DIR)/test-summary.txt
+TEST_LAST_IDS := $(TEST_SUPPORT_DIR)/test-last-ids.txt
ifeq ($(CUSTOM_ROOT), )
JTREG_TOPDIR := $(TOPDIR)
@@ -87,6 +88,9 @@
-timeoutHandlerTimeout:0
endif
+GTEST_LAUNCHER_DIRS := $(patsubst %/gtestLauncher, %, $(wildcard $(TEST_IMAGE_DIR)/hotspot/gtest/*/gtestLauncher))
+GTEST_VARIANTS := $(strip $(patsubst $(TEST_IMAGE_DIR)/hotspot/gtest/%, %, $(GTEST_LAUNCHER_DIRS)))
+
################################################################################
# Parse control variables
################################################################################
@@ -165,16 +169,23 @@
# Helper function to determine if a test specification is a Gtest test
#
# It is a Gtest test if it is either "gtest", or "gtest:" followed by an optional
-# test filter string.
+# test filter string, and an optional "/" to select a specific JVM
+# variant. If no variant is specified, all found variants are tested.
define ParseGtestTestSelection
$(if $(filter gtest%, $1), \
$(if $(filter gtest, $1), \
- gtest:all \
+ $(addprefix gtest:all/, $(GTEST_VARIANTS)) \
, \
- $(if $(filter gtest:, $1), \
- gtest:all \
+ $(if $(strip $(or $(filter gtest/%, $1) $(filter gtest:/%, $1))), \
+ $(patsubst gtest:/%, gtest:all/%, $(patsubst gtest/%, gtest:/%, $1)) \
, \
- $1 \
+ $(if $(filter gtest:%, $1), \
+ $(if $(findstring /, $1), \
+ $1 \
+ , \
+ $(addprefix $1/, $(GTEST_VARIANTS)) \
+ ) \
+ ) \
) \
) \
)
@@ -228,7 +239,8 @@
$(if $(findstring :, $(TEST_NAME)), \
$(if $(filter :%, $(TEST_NAME)), \
$(eval TEST_GROUP := $(patsubst :%, %, $(TEST_NAME))) \
- $(eval TEST_ROOTS := $(JTREG_TESTROOTS)) \
+ $(eval TEST_ROOTS := $(foreach test_root, $(JTREG_TESTROOTS), \
+ $(call CleanupJtregPath, $(test_root)))) \
, \
$(eval TEST_PATH := $(word 1, $(subst :, $(SPACE), $(TEST_NAME)))) \
$(eval TEST_GROUP := $(word 2, $(subst :, $(SPACE), $(TEST_NAME)))) \
@@ -251,6 +263,15 @@
)
endef
+# Helper function to determine if a test specification is a special test
+#
+# It is a special test if it is "special:" followed by a test name.
+define ParseSpecialTestSelection
+ $(if $(filter special:%, $1), \
+ $1 \
+ )
+endef
+
ifeq ($(TEST), )
$(info No test selection given in TEST!)
$(info Please use e.g. 'run-test TEST=tier1' or 'run-test-tier1')
@@ -270,6 +291,9 @@
$(eval PARSED_TESTS += $(call ParseJtregTestSelection, $(test))) \
) \
$(if $(strip $(PARSED_TESTS)), , \
+ $(eval PARSED_TESTS += $(call ParseSpecialTestSelection, $(test))) \
+ ) \
+ $(if $(strip $(PARSED_TESTS)), , \
$(eval UNKNOWN_TEST := $(test)) \
) \
$(eval TESTS_TO_RUN += $(PARSED_TESTS)) \
@@ -316,8 +340,14 @@
define SetupRunGtestTestBody
$1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
$1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1
+ $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt
- $1_TEST_NAME := $$(strip $$(patsubst gtest:%, %, $$($1_TEST)))
+ $1_VARIANT := $$(lastword $$(subst /, , $$($1_TEST)))
+ ifeq ($$(filter $$($1_VARIANT), $$(GTEST_VARIANTS)), )
+ $$(error Invalid gtest variant '$$($1_VARIANT)'. Valid variants: $$(GTEST_VARIANTS))
+ endif
+ $1_TEST_NAME := $$(strip $$(patsubst %/$$($1_VARIANT), %, \
+ $$(patsubst gtest:%, %, $$($1_TEST))))
ifneq ($$($1_TEST_NAME), all)
$1_GTEST_FILTER := --gtest_filter=$$($1_TEST_NAME)*
endif
@@ -331,11 +361,14 @@
$$(call LogWarn, Running test '$$($1_TEST)')
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
$$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/gtest, \
- $$(FIXPATH) $$(TEST_IMAGE_DIR)/hotspot/gtest/server/gtestLauncher \
- -jdk $(JDK_IMAGE_DIR) $$($1_GTEST_FILTER) \
- --gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \
- $$($1_GTEST_REPEAT) $$(GTEST_OPTIONS) $$(GTEST_VM_OPTIONS) \
- > >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) || true )
+ $$(FIXPATH) $$(TEST_IMAGE_DIR)/hotspot/gtest/$$($1_VARIANT)/gtestLauncher \
+ -jdk $(JDK_IMAGE_DIR) $$($1_GTEST_FILTER) \
+ --gtest_output=xml:$$($1_TEST_RESULTS_DIR)/gtest.xml \
+ $$($1_GTEST_REPEAT) $$(GTEST_OPTIONS) $$(GTEST_VM_OPTIONS) \
+ > >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) \
+ && $$(ECHO) $$$$? > $$($1_EXITCODE) \
+ || $$(ECHO) $$$$? > $$($1_EXITCODE) \
+ )
$1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt
@@ -343,7 +376,7 @@
$$(call LogWarn, Finished running test '$$($1_TEST)')
$$(call LogWarn, Test report is stored in $$(strip \
$$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
- $$(if $$(wildcard $$($1_RESULT_FILE)), \
+ $$(if $$(wildcard $$($1_RESULT_FILE)), \
$$(eval $1_TOTAL := $$(shell $$(AWK) '/==========.* tests? from .* \
test cases? ran/ { print $$$$2 }' $$($1_RESULT_FILE))) \
$$(if $$($1_TOTAL), , $$(eval $1_TOTAL := 0)) \
@@ -398,6 +431,7 @@
define SetupRunJtregTestBody
$1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
$1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1
+ $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt
$1_TEST_NAME := $$(strip $$(patsubst jtreg:%, %, $$($1_TEST)))
@@ -505,7 +539,10 @@
-workDir:$$($1_TEST_SUPPORT_DIR) \
$$(JTREG_OPTIONS) \
$$(JTREG_FAILURE_HANDLER_OPTIONS) \
- $$($1_TEST_NAME) || true )
+ $$($1_TEST_NAME) \
+ && $$(ECHO) $$$$? > $$($1_EXITCODE) \
+ || $$(ECHO) $$$$? > $$($1_EXITCODE) \
+ )
$1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/text/stats.txt
@@ -513,7 +550,7 @@
$$(call LogWarn, Finished running test '$$($1_TEST)')
$$(call LogWarn, Test report is stored in $$(strip \
$$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
- $$(if $$(wildcard $$($1_RESULT_FILE)), \
+ $$(if $$(wildcard $$($1_RESULT_FILE)), \
$$(eval $1_PASSED := $$(shell $$(AWK) '{ gsub(/[,;]/, ""); \
for (i=1; i<=NF; i++) { if ($$$$i == "passed:") \
print $$$$(i+1) } }' $$($1_RESULT_FILE))) \
@@ -540,6 +577,69 @@
TARGETS += $1
endef
+################################################################################
+
+### Rules for special tests
+
+SetupRunSpecialTest = $(NamedParamsMacroTemplate)
+define SetupRunSpecialTestBody
+ $1_TEST_RESULTS_DIR := $$(TEST_RESULTS_DIR)/$1
+ $1_TEST_SUPPORT_DIR := $$(TEST_SUPPORT_DIR)/$1
+ $1_EXITCODE := $$($1_TEST_RESULTS_DIR)/exitcode.txt
+
+ $1_FULL_TEST_NAME := $$(strip $$(patsubst special:%, %, $$($1_TEST)))
+ ifneq ($$(findstring :, $$($1_FULL_TEST_NAME)), )
+ $1_TEST_NAME := $$(firstword $$(subst :, ,$$($1_FULL_TEST_NAME)))
+ $1_TEST_ARGS := $$(strip $$(patsubst special:$$($1_TEST_NAME):%, %, $$($1_TEST)))
+ else
+ $1_TEST_NAME := $$($1_FULL_TEST_NAME)
+ $1_TEST_ARGS :=
+ endif
+
+ ifeq ($$($1_TEST_NAME), hotspot-internal)
+ $1_TEST_COMMAND_LINE := \
+ $$(JDK_IMAGE_DIR)/bin/java -XX:+ExecuteInternalVMTests \
+ -XX:+ShowMessageBoxOnError -version
+ else ifeq ($$($1_TEST_NAME), failure-handler)
+ $1_TEST_COMMAND_LINE := \
+ ($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f \
+ BuildFailureHandler.gmk test)
+ else ifeq ($$($1_TEST_NAME), make)
+ $1_TEST_COMMAND_LINE := \
+ ($(CD) $(TOPDIR)/test/make && $(MAKE) $(MAKE_ARGS) -f \
+ TestMake.gmk $$($1_TEST_ARGS))
+ else
+ $$(error Invalid special test specification: $$($1_TEST_NAME))
+ endif
+
+ run-test-$1:
+ $$(call LogWarn)
+ $$(call LogWarn, Running test '$$($1_TEST)')
+ $$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
+ $$(call ExecuteWithLog, $$($1_TEST_SUPPORT_DIR)/test-execution, \
+ $$($1_TEST_COMMAND_LINE) \
+ > >($(TEE) $$($1_TEST_RESULTS_DIR)/test-output.txt) \
+ && $$(ECHO) $$$$? > $$($1_EXITCODE) \
+ || $$(ECHO) $$$$? > $$($1_EXITCODE) \
+ )
+
+ $1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/gtest.txt
+
+ # We can not parse the various "special" tests.
+ parse-test-$1: run-test-$1
+ $$(call LogWarn, Finished running test '$$($1_TEST)')
+ $$(call LogWarn, Test report is stored in $$(strip \
+ $$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
+ $$(call LogWarn, Warning: Special test results are not properly parsed!)
+ $$(eval $1_PASSED := 0)
+ $$(eval $1_FAILED := 0)
+ $$(eval $1_ERROR := 0)
+ $$(eval $1_TOTAL := 0)
+
+ $1: run-test-$1 parse-test-$1
+
+ TARGETS += $1
+endef
################################################################################
# Setup and execute make rules for all selected tests
@@ -552,10 +652,13 @@
UseJtregTestHandler = \
$(if $(filter jtreg:%, $1), true)
+UseSpecialTestHandler = \
+ $(if $(filter special:%, $1), true)
+
# Now process each test to run and setup a proper make rule
$(foreach test, $(TESTS_TO_RUN), \
$(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \
- $(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \
+ $(TR) -cs '[a-z][A-Z][0-9]\n' '[_*1000]')) \
$(eval ALL_TEST_IDS += $(TEST_ID)) \
$(if $(call UseCustomTestHandler, $(test)), \
$(eval $(call SetupRunCustomTest, $(TEST_ID), \
@@ -572,6 +675,11 @@
TEST := $(test), \
)) \
) \
+ $(if $(call UseSpecialTestHandler, $(test)), \
+ $(eval $(call SetupRunSpecialTest, $(TEST_ID), \
+ TEST := $(test), \
+ )) \
+ ) \
)
# Sort also removes duplicates, so if there is any we'll get fewer words.
@@ -592,6 +700,8 @@
# Create and print a table of the result of all tests run
$(RM) $(TEST_SUMMARY).old 2> /dev/null
$(MV) $(TEST_SUMMARY) $(TEST_SUMMARY).old 2> /dev/null || true
+ $(RM) $(TEST_LAST_IDS).old 2> /dev/null
+ $(MV) $(TEST_LAST_IDS) $(TEST_LAST_IDS).old 2> /dev/null || true
$(ECHO) >> $(TEST_SUMMARY) ==============================
$(ECHO) >> $(TEST_SUMMARY) Test summary
$(ECHO) >> $(TEST_SUMMARY) ==============================
@@ -599,8 +709,9 @@
TEST TOTAL PASS FAIL ERROR " "
$(foreach test, $(TESTS_TO_RUN), \
$(eval TEST_ID := $(shell $(ECHO) $(strip $(test)) | \
- $(TR) -cs '[a-z][A-Z][0-9]\n' '_')) \
- $(eval NAME_PATTERN := $(shell $(ECHO) $(test) | $(TR) -c \\n _)) \
+ $(TR) -cs '[a-z][A-Z][0-9]\n' '[_*1000]')) \
+ $(ECHO) >> $(TEST_LAST_IDS) $(TEST_ID) $(NEWLINE) \
+ $(eval NAME_PATTERN := $(shell $(ECHO) $(test) | $(TR) -c '\n' '[_*1000]')) \
$(if $(filter __________________________________________________%, $(NAME_PATTERN)), \
$(eval TEST_NAME := ) \
$(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s\n" " " "$(test)" $(NEWLINE) \
diff -r 10b34c929b4f -r 64298b1e890b make/autoconf/basics.m4
--- a/make/autoconf/basics.m4 Tue Dec 05 10:21:41 2017 +0000
+++ b/make/autoconf/basics.m4 Tue Dec 05 10:28:45 2017 +0000
@@ -1092,10 +1092,6 @@
# We can build without it.
LDD="true"
fi
- BASIC_PATH_PROGS(OTOOL, otool)
- if test "x$OTOOL" = "x"; then
- OTOOL="true"
- fi
BASIC_PATH_PROGS(READELF, [greadelf readelf])
BASIC_PATH_PROGS(DOT, dot)
BASIC_PATH_PROGS(HG, hg)
diff -r 10b34c929b4f -r 64298b1e890b make/autoconf/generated-configure.sh
--- a/make/autoconf/generated-configure.sh Tue Dec 05 10:21:41 2017 +0000
+++ b/make/autoconf/generated-configure.sh Tue Dec 05 10:28:45 2017 +0000
@@ -818,6 +818,8 @@
DUMPBIN
RC
MT
+INSTALL_NAME_TOOL
+OTOOL
LIPO
ac_ct_AR
AR
@@ -932,7 +934,6 @@
HG
DOT
READELF
-OTOOL
LDD
ZIPEXE
UNZIP
@@ -1277,7 +1278,6 @@
UNZIP
ZIPEXE
LDD
-OTOOL
READELF
DOT
HG
@@ -1310,6 +1310,8 @@
AS
AR
LIPO
+OTOOL
+INSTALL_NAME_TOOL
STRIP
NM
GNM
@@ -2226,7 +2228,6 @@
UNZIP Override default value for UNZIP
ZIPEXE Override default value for ZIPEXE
LDD Override default value for LDD
- OTOOL Override default value for OTOOL
READELF Override default value for READELF
DOT Override default value for DOT
HG Override default value for HG
@@ -2260,6 +2261,9 @@
AS Override default value for AS
AR Override default value for AR
LIPO Override default value for LIPO
+ OTOOL Override default value for OTOOL
+ INSTALL_NAME_TOOL
+ Override default value for INSTALL_NAME_TOOL
STRIP Override default value for STRIP
NM Override default value for NM
GNM Override default value for GNM
@@ -5155,7 +5159,7 @@
#CUSTOM_AUTOCONF_INCLUDE
# Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1511359342
+DATE_WHEN_GENERATED=1512410983
###############################################################################
#
@@ -22126,206 +22130,6 @@
# Publish this variable in the help.
- if [ -z "${OTOOL+x}" ]; then
- # The variable is not set by user, try to locate tool using the code snippet
- for ac_prog in otool
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_OTOOL+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- case $OTOOL in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_OTOOL="$OTOOL" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_OTOOL="$as_dir/$ac_word$ac_exec_ext"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-fi
-OTOOL=$ac_cv_path_OTOOL
-if test -n "$OTOOL"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
-$as_echo "$OTOOL" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$OTOOL" && break
-done
-
- else
- # The variable is set, but is it from the command line or the environment?
-
- # Try to remove the string !OTOOL! from our list.
- try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!OTOOL!/}
- if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
- # If it failed, the variable was not from the command line. Ignore it,
- # but warn the user (except for BASH, which is always set by the calling BASH).
- if test "xOTOOL" != xBASH; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of OTOOL from the environment. Use command line variables instead." >&5
-$as_echo "$as_me: WARNING: Ignoring value of OTOOL from the environment. Use command line variables instead." >&2;}
- fi
- # Try to locate tool using the code snippet
- for ac_prog in otool
-do
- # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_OTOOL+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- case $OTOOL in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_OTOOL="$OTOOL" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_OTOOL="$as_dir/$ac_word$ac_exec_ext"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-fi
-OTOOL=$ac_cv_path_OTOOL
-if test -n "$OTOOL"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
-$as_echo "$OTOOL" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- test -n "$OTOOL" && break
-done
-
- else
- # If it succeeded, then it was overridden by the user. We will use it
- # for the tool.
-
- # First remove it from the list of overridden variables, so we can test
- # for unknown variables in the end.
- CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
-
- # Check if we try to supply an empty value
- if test "x$OTOOL" = x; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool OTOOL= (no value)" >&5
-$as_echo "$as_me: Setting user supplied tool OTOOL= (no value)" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OTOOL" >&5
-$as_echo_n "checking for OTOOL... " >&6; }
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
-$as_echo "disabled" >&6; }
- else
- # Check if the provided tool contains a complete path.
- tool_specified="$OTOOL"
- tool_basename="${tool_specified##*/}"
- if test "x$tool_basename" = "x$tool_specified"; then
- # A command without a complete path is provided, search $PATH.
- { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool OTOOL=$tool_basename" >&5
-$as_echo "$as_me: Will search for user supplied tool OTOOL=$tool_basename" >&6;}
- # Extract the first word of "$tool_basename", so it can be a program name with args.
-set dummy $tool_basename; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_OTOOL+:} false; then :
- $as_echo_n "(cached) " >&6
-else
- case $OTOOL in
- [\\/]* | ?:[\\/]*)
- ac_cv_path_OTOOL="$OTOOL" # Let the user override the test with a path.
- ;;
- *)
- as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
- IFS=$as_save_IFS
- test -z "$as_dir" && as_dir=.
- for ac_exec_ext in '' $ac_executable_extensions; do
- if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
- ac_cv_path_OTOOL="$as_dir/$ac_word$ac_exec_ext"
- $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
- break 2
- fi
-done
- done
-IFS=$as_save_IFS
-
- ;;
-esac
-fi
-OTOOL=$ac_cv_path_OTOOL
-if test -n "$OTOOL"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
-$as_echo "$OTOOL" >&6; }
-else
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
- if test "x$OTOOL" = x; then
- as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
- fi
- else
- # Otherwise we believe it is a complete path. Use it as it is.
- { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool OTOOL=$tool_specified" >&5
-$as_echo "$as_me: Will use user supplied tool OTOOL=$tool_specified" >&6;}
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OTOOL" >&5
-$as_echo_n "checking for OTOOL... " >&6; }
- if test ! -x "$tool_specified"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
-$as_echo "not found" >&6; }
- as_fn_error $? "User supplied tool OTOOL=$tool_specified does not exist or is not executable" "$LINENO" 5
- fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
-$as_echo "$tool_specified" >&6; }
- fi
- fi
- fi
-
- fi
-
-
- if test "x$OTOOL" = "x"; then
- OTOOL="true"
- fi
-
-
- # Publish this variable in the help.
-
-
if [ -z "${READELF+x}" ]; then
# The variable is not set by user, try to locate tool using the code snippet
for ac_prog in greadelf readelf
@@ -39588,6 +39392,986 @@
fi
fi
+
+
+
+ # Publish this variable in the help.
+
+
+ if [ -z "${OTOOL+x}" ]; then
+ # The variable is not set by user, try to locate tool using the code snippet
+ for ac_prog in otool
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $OTOOL in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_OTOOL="$OTOOL" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_OTOOL="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+OTOOL=$ac_cv_path_OTOOL
+if test -n "$OTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$OTOOL" && break
+done
+
+ else
+ # The variable is set, but is it from the command line or the environment?
+
+ # Try to remove the string !OTOOL! from our list.
+ try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!OTOOL!/}
+ if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
+ # If it failed, the variable was not from the command line. Ignore it,
+ # but warn the user (except for BASH, which is always set by the calling BASH).
+ if test "xOTOOL" != xBASH; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of OTOOL from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of OTOOL from the environment. Use command line variables instead." >&2;}
+ fi
+ # Try to locate tool using the code snippet
+ for ac_prog in otool
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $OTOOL in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_OTOOL="$OTOOL" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_OTOOL="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+OTOOL=$ac_cv_path_OTOOL
+if test -n "$OTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$OTOOL" && break
+done
+
+ else
+ # If it succeeded, then it was overridden by the user. We will use it
+ # for the tool.
+
+ # First remove it from the list of overridden variables, so we can test
+ # for unknown variables in the end.
+ CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
+
+ # Check if we try to supply an empty value
+ if test "x$OTOOL" = x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool OTOOL= (no value)" >&5
+$as_echo "$as_me: Setting user supplied tool OTOOL= (no value)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OTOOL" >&5
+$as_echo_n "checking for OTOOL... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
+$as_echo "disabled" >&6; }
+ else
+ # Check if the provided tool contains a complete path.
+ tool_specified="$OTOOL"
+ tool_basename="${tool_specified##*/}"
+ if test "x$tool_basename" = "x$tool_specified"; then
+ # A command without a complete path is provided, search $PATH.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool OTOOL=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool OTOOL=$tool_basename" >&6;}
+ # Extract the first word of "$tool_basename", so it can be a program name with args.
+set dummy $tool_basename; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_OTOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $OTOOL in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_OTOOL="$OTOOL" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_OTOOL="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+OTOOL=$ac_cv_path_OTOOL
+if test -n "$OTOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ if test "x$OTOOL" = x; then
+ as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
+ fi
+ else
+ # Otherwise we believe it is a complete path. Use it as it is.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool OTOOL=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool OTOOL=$tool_specified" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for OTOOL" >&5
+$as_echo_n "checking for OTOOL... " >&6; }
+ if test ! -x "$tool_specified"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+ as_fn_error $? "User supplied tool OTOOL=$tool_specified does not exist or is not executable" "$LINENO" 5
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
+$as_echo "$tool_specified" >&6; }
+ fi
+ fi
+ fi
+
+ fi
+
+
+
+ if test "x$OTOOL" = x; then
+ as_fn_error $? "Could not find required tool for OTOOL" "$LINENO" 5
+ fi
+
+
+
+ # Only process if variable expands to non-empty
+
+ if test "x$OTOOL" != x; then
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+ # First separate the path from the arguments. This will split at the first
+ # space.
+ complete="$OTOOL"
+ path="${complete%% *}"
+ tmp="$complete EOL"
+ arguments="${tmp#* }"
+
+ # Input might be given as Windows format, start by converting to
+ # unix format.
+ new_path=`$CYGPATH -u "$path"`
+
+ # Now try to locate executable using which
+ new_path=`$WHICH "$new_path" 2> /dev/null`
+ # bat and cmd files are not always considered executable in cygwin causing which
+ # to not find them
+ if test "x$new_path" = x \
+ && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
+ && test "x`$LS \"$path\" 2>/dev/null`" != x; then
+ new_path=`$CYGPATH -u "$path"`
+ fi
+ if test "x$new_path" = x; then
+ # Oops. Which didn't find the executable.
+ # The splitting of arguments from the executable at a space might have been incorrect,
+ # since paths with space are more likely in Windows. Give it another try with the whole
+ # argument.
+ path="$complete"
+ arguments="EOL"
+ new_path=`$CYGPATH -u "$path"`
+ new_path=`$WHICH "$new_path" 2> /dev/null`
+ # bat and cmd files are not always considered executable in cygwin causing which
+ # to not find them
+ if test "x$new_path" = x \
+ && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
+ && test "x`$LS \"$path\" 2>/dev/null`" != x; then
+ new_path=`$CYGPATH -u "$path"`
+ fi
+ if test "x$new_path" = x; then
+ # It's still not found. Now this is an unrecoverable error.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OTOOL, which resolves as \"$complete\", is not found." >&5
+$as_echo "$as_me: The path of OTOOL, which resolves as \"$complete\", is not found." >&6;}
+ has_space=`$ECHO "$complete" | $GREP " "`
+ if test "x$has_space" != x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5
+$as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;}
+ fi
+ as_fn_error $? "Cannot locate the the path of OTOOL" "$LINENO" 5
+ fi
+ fi
+
+ # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+ # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+ # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+ # "foo.exe" is OK but "foo" is an error.
+ #
+ # This test is therefore slightly more accurate than "test -f" to check for file presence.
+ # It is also a way to make sure we got the proper file name for the real test later on.
+ test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+ if test "x$test_shortpath" = x; then
+ # Short path failed, file does not exist as specified.
+ # Try adding .exe or .cmd
+ if test -f "${new_path}.exe"; then
+ input_to_shortpath="${new_path}.exe"
+ elif test -f "${new_path}.cmd"; then
+ input_to_shortpath="${new_path}.cmd"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OTOOL, which resolves as \"$new_path\", is invalid." >&5
+$as_echo "$as_me: The path of OTOOL, which resolves as \"$new_path\", is invalid." >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5
+$as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;}
+ as_fn_error $? "Cannot locate the the path of OTOOL" "$LINENO" 5
+ fi
+ else
+ input_to_shortpath="$new_path"
+ fi
+
+ # Call helper function which possibly converts this using DOS-style short mode.
+ # If so, the updated path is stored in $new_path.
+ new_path="$input_to_shortpath"
+
+ input_path="$input_to_shortpath"
+ # Check if we need to convert this using DOS-style short mode. If the path
+ # contains just simple characters, use it. Otherwise (spaces, weird characters),
+ # take no chances and rewrite it.
+ # Note: m4 eats our [], so we need to use [ and ] instead.
+ has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+ if test "x$has_forbidden_chars" != x; then
+ # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+ shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+ path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+ if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+ # Going to short mode and back again did indeed matter. Since short mode is
+ # case insensitive, let's make it lowercase to improve readability.
+ shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ # Now convert it back to Unix-style (cygpath)
+ input_path=`$CYGPATH -u "$shortmode_path"`
+ new_path="$input_path"
+ fi
+ fi
+
+ test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+ if test "x$test_cygdrive_prefix" = x; then
+ # As a simple fix, exclude /usr/bin since it's not a real path.
+ if test "x`$ECHO $input_to_shortpath | $GREP ^/usr/bin/`" = x; then
+ # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+ # a path prefixed by /cygdrive for fixpath to work.
+ new_path="$CYGWIN_ROOT_PATH$input_path"
+ fi
+ fi
+
+ # remove trailing .exe if any
+ new_path="${new_path/%.exe/}"
+
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+ # First separate the path from the arguments. This will split at the first
+ # space.
+ complete="$OTOOL"
+ path="${complete%% *}"
+ tmp="$complete EOL"
+ arguments="${tmp#* }"
+
+ # Input might be given as Windows format, start by converting to
+ # unix format.
+ new_path="$path"
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+
+ # Now try to locate executable using which
+ new_path=`$WHICH "$new_path" 2> /dev/null`
+
+ if test "x$new_path" = x; then
+ # Oops. Which didn't find the executable.
+ # The splitting of arguments from the executable at a space might have been incorrect,
+ # since paths with space are more likely in Windows. Give it another try with the whole
+ # argument.
+ path="$complete"
+ arguments="EOL"
+ new_path="$path"
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+
+ new_path=`$WHICH "$new_path" 2> /dev/null`
+ # bat and cmd files are not always considered executable in MSYS causing which
+ # to not find them
+ if test "x$new_path" = x \
+ && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
+ && test "x`$LS \"$path\" 2>/dev/null`" != x; then
+ new_path="$path"
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+ fi
+
+ if test "x$new_path" = x; then
+ # It's still not found. Now this is an unrecoverable error.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OTOOL, which resolves as \"$complete\", is not found." >&5
+$as_echo "$as_me: The path of OTOOL, which resolves as \"$complete\", is not found." >&6;}
+ has_space=`$ECHO "$complete" | $GREP " "`
+ if test "x$has_space" != x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5
+$as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;}
+ fi
+ as_fn_error $? "Cannot locate the the path of OTOOL" "$LINENO" 5
+ fi
+ fi
+
+ # Now new_path has a complete unix path to the binary
+ if test "x`$ECHO $new_path | $GREP ^/bin/`" != x; then
+ # Keep paths in /bin as-is, but remove trailing .exe if any
+ new_path="${new_path/%.exe/}"
+ # Do not save /bin paths to all_fixpath_prefixes!
+ else
+ # Not in mixed or Windows style, start by that.
+ new_path=`cmd //c echo $new_path`
+
+ input_path="$new_path"
+ # Check if we need to convert this using DOS-style short mode. If the path
+ # contains just simple characters, use it. Otherwise (spaces, weird characters),
+ # take no chances and rewrite it.
+ # Note: m4 eats our [], so we need to use [ and ] instead.
+ has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+ if test "x$has_forbidden_chars" != x; then
+ # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+ new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ fi
+
+ # Output is in $new_path
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+ # remove trailing .exe if any
+ new_path="${new_path/%.exe/}"
+
+ # Save the first 10 bytes of this path to the storage, so fixpath can work.
+ all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+ fi
+
+ else
+ # We're on a unix platform. Hooray! :)
+ # First separate the path from the arguments. This will split at the first
+ # space.
+ complete="$OTOOL"
+ path="${complete%% *}"
+ tmp="$complete EOL"
+ arguments="${tmp#* }"
+
+ # Cannot rely on the command "which" here since it doesn't always work.
+ is_absolute_path=`$ECHO "$path" | $GREP ^/`
+ if test -z "$is_absolute_path"; then
+ # Path to executable is not absolute. Find it.
+ IFS_save="$IFS"
+ IFS=:
+ for p in $PATH; do
+ if test -f "$p/$path" && test -x "$p/$path"; then
+ new_path="$p/$path"
+ break
+ fi
+ done
+ IFS="$IFS_save"
+ else
+ # This is an absolute path, we can use it without further modifications.
+ new_path="$path"
+ fi
+
+ if test "x$new_path" = x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of OTOOL, which resolves as \"$complete\", is not found." >&5
+$as_echo "$as_me: The path of OTOOL, which resolves as \"$complete\", is not found." >&6;}
+ has_space=`$ECHO "$complete" | $GREP " "`
+ if test "x$has_space" != x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5
+$as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;}
+ fi
+ as_fn_error $? "Cannot locate the the path of OTOOL" "$LINENO" 5
+ fi
+ fi
+
+ # Now join together the path and the arguments once again
+ if test "x$arguments" != xEOL; then
+ new_complete="$new_path ${arguments% *}"
+ else
+ new_complete="$new_path"
+ fi
+
+ if test "x$complete" != "x$new_complete"; then
+ OTOOL="$new_complete"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting OTOOL to \"$new_complete\"" >&5
+$as_echo "$as_me: Rewriting OTOOL to \"$new_complete\"" >&6;}
+ fi
+ fi
+
+
+
+
+ # Publish this variable in the help.
+
+
+ if [ -z "${INSTALL_NAME_TOOL+x}" ]; then
+ # The variable is not set by user, try to locate tool using the code snippet
+ for ac_prog in install_name_tool
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_INSTALL_NAME_TOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $INSTALL_NAME_TOOL in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_INSTALL_NAME_TOOL="$INSTALL_NAME_TOOL" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_INSTALL_NAME_TOOL="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+INSTALL_NAME_TOOL=$ac_cv_path_INSTALL_NAME_TOOL
+if test -n "$INSTALL_NAME_TOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL_NAME_TOOL" >&5
+$as_echo "$INSTALL_NAME_TOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$INSTALL_NAME_TOOL" && break
+done
+
+ else
+ # The variable is set, but is it from the command line or the environment?
+
+ # Try to remove the string !INSTALL_NAME_TOOL! from our list.
+ try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!INSTALL_NAME_TOOL!/}
+ if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then
+ # If it failed, the variable was not from the command line. Ignore it,
+ # but warn the user (except for BASH, which is always set by the calling BASH).
+ if test "xINSTALL_NAME_TOOL" != xBASH; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of INSTALL_NAME_TOOL from the environment. Use command line variables instead." >&5
+$as_echo "$as_me: WARNING: Ignoring value of INSTALL_NAME_TOOL from the environment. Use command line variables instead." >&2;}
+ fi
+ # Try to locate tool using the code snippet
+ for ac_prog in install_name_tool
+do
+ # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_INSTALL_NAME_TOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $INSTALL_NAME_TOOL in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_INSTALL_NAME_TOOL="$INSTALL_NAME_TOOL" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_INSTALL_NAME_TOOL="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+INSTALL_NAME_TOOL=$ac_cv_path_INSTALL_NAME_TOOL
+if test -n "$INSTALL_NAME_TOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL_NAME_TOOL" >&5
+$as_echo "$INSTALL_NAME_TOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ test -n "$INSTALL_NAME_TOOL" && break
+done
+
+ else
+ # If it succeeded, then it was overridden by the user. We will use it
+ # for the tool.
+
+ # First remove it from the list of overridden variables, so we can test
+ # for unknown variables in the end.
+ CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var"
+
+ # Check if we try to supply an empty value
+ if test "x$INSTALL_NAME_TOOL" = x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Setting user supplied tool INSTALL_NAME_TOOL= (no value)" >&5
+$as_echo "$as_me: Setting user supplied tool INSTALL_NAME_TOOL= (no value)" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for INSTALL_NAME_TOOL" >&5
+$as_echo_n "checking for INSTALL_NAME_TOOL... " >&6; }
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: disabled" >&5
+$as_echo "disabled" >&6; }
+ else
+ # Check if the provided tool contains a complete path.
+ tool_specified="$INSTALL_NAME_TOOL"
+ tool_basename="${tool_specified##*/}"
+ if test "x$tool_basename" = "x$tool_specified"; then
+ # A command without a complete path is provided, search $PATH.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool INSTALL_NAME_TOOL=$tool_basename" >&5
+$as_echo "$as_me: Will search for user supplied tool INSTALL_NAME_TOOL=$tool_basename" >&6;}
+ # Extract the first word of "$tool_basename", so it can be a program name with args.
+set dummy $tool_basename; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_INSTALL_NAME_TOOL+:} false; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $INSTALL_NAME_TOOL in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_INSTALL_NAME_TOOL="$INSTALL_NAME_TOOL" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+ ac_cv_path_INSTALL_NAME_TOOL="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+INSTALL_NAME_TOOL=$ac_cv_path_INSTALL_NAME_TOOL
+if test -n "$INSTALL_NAME_TOOL"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL_NAME_TOOL" >&5
+$as_echo "$INSTALL_NAME_TOOL" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+ if test "x$INSTALL_NAME_TOOL" = x; then
+ as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5
+ fi
+ else
+ # Otherwise we believe it is a complete path. Use it as it is.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool INSTALL_NAME_TOOL=$tool_specified" >&5
+$as_echo "$as_me: Will use user supplied tool INSTALL_NAME_TOOL=$tool_specified" >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for INSTALL_NAME_TOOL" >&5
+$as_echo_n "checking for INSTALL_NAME_TOOL... " >&6; }
+ if test ! -x "$tool_specified"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
+$as_echo "not found" >&6; }
+ as_fn_error $? "User supplied tool INSTALL_NAME_TOOL=$tool_specified does not exist or is not executable" "$LINENO" 5
+ fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5
+$as_echo "$tool_specified" >&6; }
+ fi
+ fi
+ fi
+
+ fi
+
+
+
+ if test "x$INSTALL_NAME_TOOL" = x; then
+ as_fn_error $? "Could not find required tool for INSTALL_NAME_TOOL" "$LINENO" 5
+ fi
+
+
+
+ # Only process if variable expands to non-empty
+
+ if test "x$INSTALL_NAME_TOOL" != x; then
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+ # First separate the path from the arguments. This will split at the first
+ # space.
+ complete="$INSTALL_NAME_TOOL"
+ path="${complete%% *}"
+ tmp="$complete EOL"
+ arguments="${tmp#* }"
+
+ # Input might be given as Windows format, start by converting to
+ # unix format.
+ new_path=`$CYGPATH -u "$path"`
+
+ # Now try to locate executable using which
+ new_path=`$WHICH "$new_path" 2> /dev/null`
+ # bat and cmd files are not always considered executable in cygwin causing which
+ # to not find them
+ if test "x$new_path" = x \
+ && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
+ && test "x`$LS \"$path\" 2>/dev/null`" != x; then
+ new_path=`$CYGPATH -u "$path"`
+ fi
+ if test "x$new_path" = x; then
+ # Oops. Which didn't find the executable.
+ # The splitting of arguments from the executable at a space might have been incorrect,
+ # since paths with space are more likely in Windows. Give it another try with the whole
+ # argument.
+ path="$complete"
+ arguments="EOL"
+ new_path=`$CYGPATH -u "$path"`
+ new_path=`$WHICH "$new_path" 2> /dev/null`
+ # bat and cmd files are not always considered executable in cygwin causing which
+ # to not find them
+ if test "x$new_path" = x \
+ && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
+ && test "x`$LS \"$path\" 2>/dev/null`" != x; then
+ new_path=`$CYGPATH -u "$path"`
+ fi
+ if test "x$new_path" = x; then
+ # It's still not found. Now this is an unrecoverable error.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of INSTALL_NAME_TOOL, which resolves as \"$complete\", is not found." >&5
+$as_echo "$as_me: The path of INSTALL_NAME_TOOL, which resolves as \"$complete\", is not found." >&6;}
+ has_space=`$ECHO "$complete" | $GREP " "`
+ if test "x$has_space" != x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5
+$as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;}
+ fi
+ as_fn_error $? "Cannot locate the the path of INSTALL_NAME_TOOL" "$LINENO" 5
+ fi
+ fi
+
+ # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+ # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+ # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+ # "foo.exe" is OK but "foo" is an error.
+ #
+ # This test is therefore slightly more accurate than "test -f" to check for file presence.
+ # It is also a way to make sure we got the proper file name for the real test later on.
+ test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+ if test "x$test_shortpath" = x; then
+ # Short path failed, file does not exist as specified.
+ # Try adding .exe or .cmd
+ if test -f "${new_path}.exe"; then
+ input_to_shortpath="${new_path}.exe"
+ elif test -f "${new_path}.cmd"; then
+ input_to_shortpath="${new_path}.cmd"
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of INSTALL_NAME_TOOL, which resolves as \"$new_path\", is invalid." >&5
+$as_echo "$as_me: The path of INSTALL_NAME_TOOL, which resolves as \"$new_path\", is invalid." >&6;}
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&5
+$as_echo "$as_me: Neither \"$new_path\" nor \"$new_path.exe/cmd\" can be found" >&6;}
+ as_fn_error $? "Cannot locate the the path of INSTALL_NAME_TOOL" "$LINENO" 5
+ fi
+ else
+ input_to_shortpath="$new_path"
+ fi
+
+ # Call helper function which possibly converts this using DOS-style short mode.
+ # If so, the updated path is stored in $new_path.
+ new_path="$input_to_shortpath"
+
+ input_path="$input_to_shortpath"
+ # Check if we need to convert this using DOS-style short mode. If the path
+ # contains just simple characters, use it. Otherwise (spaces, weird characters),
+ # take no chances and rewrite it.
+ # Note: m4 eats our [], so we need to use [ and ] instead.
+ has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+ if test "x$has_forbidden_chars" != x; then
+ # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+ shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+ path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+ if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+ # Going to short mode and back again did indeed matter. Since short mode is
+ # case insensitive, let's make it lowercase to improve readability.
+ shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ # Now convert it back to Unix-style (cygpath)
+ input_path=`$CYGPATH -u "$shortmode_path"`
+ new_path="$input_path"
+ fi
+ fi
+
+ test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+ if test "x$test_cygdrive_prefix" = x; then
+ # As a simple fix, exclude /usr/bin since it's not a real path.
+ if test "x`$ECHO $input_to_shortpath | $GREP ^/usr/bin/`" = x; then
+ # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+ # a path prefixed by /cygdrive for fixpath to work.
+ new_path="$CYGWIN_ROOT_PATH$input_path"
+ fi
+ fi
+
+ # remove trailing .exe if any
+ new_path="${new_path/%.exe/}"
+
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+ # First separate the path from the arguments. This will split at the first
+ # space.
+ complete="$INSTALL_NAME_TOOL"
+ path="${complete%% *}"
+ tmp="$complete EOL"
+ arguments="${tmp#* }"
+
+ # Input might be given as Windows format, start by converting to
+ # unix format.
+ new_path="$path"
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+
+ # Now try to locate executable using which
+ new_path=`$WHICH "$new_path" 2> /dev/null`
+
+ if test "x$new_path" = x; then
+ # Oops. Which didn't find the executable.
+ # The splitting of arguments from the executable at a space might have been incorrect,
+ # since paths with space are more likely in Windows. Give it another try with the whole
+ # argument.
+ path="$complete"
+ arguments="EOL"
+ new_path="$path"
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+
+ new_path=`$WHICH "$new_path" 2> /dev/null`
+ # bat and cmd files are not always considered executable in MSYS causing which
+ # to not find them
+ if test "x$new_path" = x \
+ && test "x`$ECHO \"$path\" | $GREP -i -e \"\\.bat$\" -e \"\\.cmd$\"`" != x \
+ && test "x`$LS \"$path\" 2>/dev/null`" != x; then
+ new_path="$path"
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+ fi
+
+ if test "x$new_path" = x; then
+ # It's still not found. Now this is an unrecoverable error.
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of INSTALL_NAME_TOOL, which resolves as \"$complete\", is not found." >&5
+$as_echo "$as_me: The path of INSTALL_NAME_TOOL, which resolves as \"$complete\", is not found." >&6;}
+ has_space=`$ECHO "$complete" | $GREP " "`
+ if test "x$has_space" != x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: You might be mixing spaces in the path and extra arguments, which is not allowed." >&5
+$as_echo "$as_me: You might be mixing spaces in the path and extra arguments, which is not allowed." >&6;}
+ fi
+ as_fn_error $? "Cannot locate the the path of INSTALL_NAME_TOOL" "$LINENO" 5
+ fi
+ fi
+
+ # Now new_path has a complete unix path to the binary
+ if test "x`$ECHO $new_path | $GREP ^/bin/`" != x; then
+ # Keep paths in /bin as-is, but remove trailing .exe if any
+ new_path="${new_path/%.exe/}"
+ # Do not save /bin paths to all_fixpath_prefixes!
+ else
+ # Not in mixed or Windows style, start by that.
+ new_path=`cmd //c echo $new_path`
+
+ input_path="$new_path"
+ # Check if we need to convert this using DOS-style short mode. If the path
+ # contains just simple characters, use it. Otherwise (spaces, weird characters),
+ # take no chances and rewrite it.
+ # Note: m4 eats our [], so we need to use [ and ] instead.
+ has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+ if test "x$has_forbidden_chars" != x; then
+ # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+ new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ fi
+
+ # Output is in $new_path
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+ # remove trailing .exe if any
+ new_path="${new_path/%.exe/}"
+
+ # Save the first 10 bytes of this path to the storage, so fixpath can work.
+ all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+ fi
+
+ else
+ # We're on a unix platform. Hooray! :)
+ # First separate the path from the arguments. This will split at the first
+ # space.
+ complete="$INSTALL_NAME_TOOL"
+ path="${complete%% *}"
+ tmp="$complete EOL"
+ arguments="${tmp#* }"
+
+ # Cannot rely on the command "which" here since it doesn't always work.
+ is_absolute_path=`$ECHO "$path" | $GREP ^/`
+ if test -z "$is_absolute_path"; then
+ # Path to executable is not absolute. Find it.
+ IFS_save="$IFS"
+ IFS=:
+ for p in $PATH; do
+ if test -f "$p/$path" && test -x "$p/$path"; then
+ new_path="$p/$path"
+ break
+ fi
+ done
+ IFS="$IFS_save"
+ else
+ # This is an absolute path, we can use it without further modifications.
+ new_path="$path"
+ fi
+
+ if test "x$new_path" = x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of INSTALL_NAME_TOOL, which resolves as \"$complete\", is not found." >&5
+$as_echo "$as_me: The path of INSTALL_NAME_TOOL, which resolves as \"$complete\", is not found." >&6;}
+ has_space=`$ECHO "$complete" | $GREP " "`
+ if test "x$has_space" != x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: This might be caused by spaces in the path, which is not allowed." >&5
+$as_echo "$as_me: This might be caused by spaces in the path, which is not allowed." >&6;}
+ fi
+ as_fn_error $? "Cannot locate the the path of INSTALL_NAME_TOOL" "$LINENO" 5
+ fi
+ fi
+
+ # Now join together the path and the arguments once again
+ if test "x$arguments" != xEOL; then
+ new_complete="$new_path ${arguments% *}"
+ else
+ new_complete="$new_path"
+ fi
+
+ if test "x$complete" != "x$new_complete"; then
+ INSTALL_NAME_TOOL="$new_complete"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting INSTALL_NAME_TOOL to \"$new_complete\"" >&5
+$as_echo "$as_me: Rewriting INSTALL_NAME_TOOL to \"$new_complete\"" >&6;}
+ fi
+ fi
+
fi
if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
@@ -64486,17 +65270,18 @@
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $BUNDLE_FREETYPE" >&5
$as_echo "$BUNDLE_FREETYPE" >&6; }
- fi # end freetype needed
-
- FREETYPE_LICENSE=""
- if test "x$with_freetype_license" = "xyes"; then
- as_fn_error $? "--with-freetype-license must have a value" "$LINENO" 5
- elif test "x$with_freetype_license" != "x"; then
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype license" >&5
+ if test "x$BUNDLE_FREETYPE" = xyes; then
+ FREETYPE_LICENSE=""
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for freetype license" >&5
$as_echo_n "checking for freetype license... " >&6; }
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_freetype_license" >&5
+ if test "x$with_freetype_license" = "xyes"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ as_fn_error $? "--with-freetype-license must have a value" "$LINENO" 5
+ elif test "x$with_freetype_license" != "x"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_freetype_license" >&5
$as_echo "$with_freetype_license" >&6; }
- FREETYPE_LICENSE="$with_freetype_license"
+ FREETYPE_LICENSE="$with_freetype_license"
# Only process if variable expands to non-empty
@@ -64629,10 +65414,154 @@
fi
fi
- if test ! -f "$FREETYPE_LICENSE"; then
- as_fn_error $? "$FREETYPE_LICENSE cannot be found" "$LINENO" 5
- fi
- fi
+ if test ! -f "$FREETYPE_LICENSE"; then
+ as_fn_error $? "$FREETYPE_LICENSE cannot be found" "$LINENO" 5
+ fi
+ else
+ if test "x$with_freetype" != "x" && test -f $with_freetype/freetype.md; then
+ FREETYPE_LICENSE="$with_freetype/freetype.md"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FREETYPE_LICENSE" >&5
+$as_echo "$FREETYPE_LICENSE" >&6; }
+
+ # Only process if variable expands to non-empty
+
+ if test "x$FREETYPE_LICENSE" != x; then
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+
+ # Input might be given as Windows format, start by converting to
+ # unix format.
+ path="$FREETYPE_LICENSE"
+ new_path=`$CYGPATH -u "$path"`
+
+ # Cygwin tries to hide some aspects of the Windows file system, such that binaries are
+ # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered
+ # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then
+ # "foo.exe" is OK but "foo" is an error.
+ #
+ # This test is therefore slightly more accurate than "test -f" to check for file precense.
+ # It is also a way to make sure we got the proper file name for the real test later on.
+ test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null`
+ if test "x$test_shortpath" = x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&6;}
+ as_fn_error $? "Cannot locate the the path of FREETYPE_LICENSE" "$LINENO" 5
+ fi
+
+ # Call helper function which possibly converts this using DOS-style short mode.
+ # If so, the updated path is stored in $new_path.
+
+ input_path="$new_path"
+ # Check if we need to convert this using DOS-style short mode. If the path
+ # contains just simple characters, use it. Otherwise (spaces, weird characters),
+ # take no chances and rewrite it.
+ # Note: m4 eats our [], so we need to use [ and ] instead.
+ has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]`
+ if test "x$has_forbidden_chars" != x; then
+ # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+ shortmode_path=`$CYGPATH -s -m -a "$input_path"`
+ path_after_shortmode=`$CYGPATH -u "$shortmode_path"`
+ if test "x$path_after_shortmode" != "x$input_to_shortpath"; then
+ # Going to short mode and back again did indeed matter. Since short mode is
+ # case insensitive, let's make it lowercase to improve readability.
+ shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ # Now convert it back to Unix-style (cygpath)
+ input_path=`$CYGPATH -u "$shortmode_path"`
+ new_path="$input_path"
+ fi
+ fi
+
+ test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/`
+ if test "x$test_cygdrive_prefix" = x; then
+ # As a simple fix, exclude /usr/bin since it's not a real path.
+ if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then
+ # The path is in a Cygwin special directory (e.g. /home). We need this converted to
+ # a path prefixed by /cygdrive for fixpath to work.
+ new_path="$CYGWIN_ROOT_PATH$input_path"
+ fi
+ fi
+
+
+ if test "x$path" != "x$new_path"; then
+ FREETYPE_LICENSE="$new_path"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&6;}
+ fi
+
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+
+ path="$FREETYPE_LICENSE"
+ has_colon=`$ECHO $path | $GREP ^.:`
+ new_path="$path"
+ if test "x$has_colon" = x; then
+ # Not in mixed or Windows style, start by that.
+ new_path=`cmd //c echo $path`
+ fi
+
+
+ input_path="$new_path"
+ # Check if we need to convert this using DOS-style short mode. If the path
+ # contains just simple characters, use it. Otherwise (spaces, weird characters),
+ # take no chances and rewrite it.
+ # Note: m4 eats our [], so we need to use [ and ] instead.
+ has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]`
+ if test "x$has_forbidden_chars" != x; then
+ # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \)
+ new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+ fi
+
+
+ windows_path="$new_path"
+ if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
+ unix_path=`$CYGPATH -u "$windows_path"`
+ new_path="$unix_path"
+ elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then
+ unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'`
+ new_path="$unix_path"
+ fi
+
+ if test "x$path" != "x$new_path"; then
+ FREETYPE_LICENSE="$new_path"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&5
+$as_echo "$as_me: Rewriting FREETYPE_LICENSE to \"$new_path\"" >&6;}
+ fi
+
+ # Save the first 10 bytes of this path to the storage, so fixpath can work.
+ all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}")
+
+ else
+ # We're on a unix platform. Hooray! :)
+ path="$FREETYPE_LICENSE"
+ has_space=`$ECHO "$path" | $GREP " "`
+ if test "x$has_space" != x; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&5
+$as_echo "$as_me: The path of FREETYPE_LICENSE, which resolves as \"$path\", is invalid." >&6;}
+ as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5
+ fi
+
+ # Use eval to expand a potential ~
+ eval path="$path"
+ if test ! -f "$path" && test ! -d "$path"; then
+ as_fn_error $? "The path of FREETYPE_LICENSE, which resolves as \"$path\", is not found." "$LINENO" 5
+ fi
+
+ if test -d "$path"; then
+ FREETYPE_LICENSE="`cd "$path"; $THEPWDCMD -L`"
+ else
+ dir="`$DIRNAME "$path"`"
+ base="`$BASENAME "$path"`"
+ FREETYPE_LICENSE="`cd "$dir"; $THEPWDCMD -L`/$base"
+ fi
+ fi
+ fi
+
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ fi
+ fi
+ fi
+
+ fi # end freetype needed
@@ -65334,23 +66263,6 @@
fi
- { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which libpng to use" >&5
-$as_echo_n "checking for which libpng to use... " >&6; }
-
- # default is bundled
- DEFAULT_LIBPNG=bundled
- # if user didn't specify, use DEFAULT_LIBPNG
- if test "x${with_libpng}" = "x"; then
- with_libpng=${DEFAULT_LIBPNG}
- fi
-
- if test "x${with_libpng}" = "xbundled"; then
- USE_EXTERNAL_LIBPNG=false
- PNG_CFLAGS=""
- PNG_LIBS=""
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: bundled" >&5
-$as_echo "bundled" >&6; }
- elif test "x${with_libpng}" = "xsystem"; then
pkg_failed=no
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PNG" >&5
@@ -65418,6 +66330,23 @@
$as_echo "yes" >&6; }
LIBPNG_FOUND=yes
fi
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for which libpng to use" >&5
+$as_echo_n "checking for which libpng to use... " >&6; }
+
+ # default is bundled
+ DEFAULT_LIBPNG=bundled
+ # if user didn't specify, use DEFAULT_LIBPNG
+ if test "x${with_libpng}" = "x"; then
+ with_libpng=${DEFAULT_LIBPNG}
+ fi
+
+ if test "x${with_libpng}" = "xbundled"; then
+ USE_EXTERNAL_LIBPNG=false
+ PNG_CFLAGS=""
+ PNG_LIBS=""
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: bundled" >&5
+$as_echo "bundled" >&6; }
+ elif test "x${with_libpng}" = "xsystem"; then
if test "x${LIBPNG_FOUND}" = "xyes"; then
# PKG_CHECK_MODULES will set PNG_CFLAGS and PNG_LIBS
USE_EXTERNAL_LIBPNG=true
@@ -65515,6 +66444,40 @@
USE_EXTERNAL_LIBZ=true
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: system" >&5
$as_echo "system" >&6; }
+
+ if test "x$USE_EXTERNAL_LIBPNG" != "xtrue"; then
+ # If we use bundled libpng, we must verify that we have a proper zlib.
+ # For instance zlib-ng has had issues with inflateValidate().
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking for system zlib functionality" >&5
+$as_echo_n "checking for system zlib functionality... " >&6; }
+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h. */
+#include "zlib.h"
+int
+main ()
+{
+
+ #if ZLIB_VERNUM >= 0x1281
+ inflateValidate(NULL, 0);
+ #endif
+
+ ;
+ return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+else
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: not ok" >&5
+$as_echo "not ok" >&6; }
+ as_fn_error $? "System zlib not working correctly" "$LINENO" 5
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ fi
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: system not found" >&5
$as_echo "system not found" >&6; }
diff -r 10b34c929b4f -r 64298b1e890b make/autoconf/lib-bundled.m4
--- a/make/autoconf/lib-bundled.m4 Tue Dec 05 10:21:41 2017 +0000
+++ b/make/autoconf/lib-bundled.m4 Tue Dec 05 10:28:45 2017 +0000
@@ -113,6 +113,7 @@
AC_ARG_WITH(libpng, [AS_HELP_STRING([--with-libpng],
[use libpng from build system or OpenJDK source (system, bundled) @<:@bundled@:>@])])
+ PKG_CHECK_MODULES(PNG, libpng, [LIBPNG_FOUND=yes], [LIBPNG_FOUND=no])
AC_MSG_CHECKING([for which libpng to use])
# default is bundled
@@ -128,7 +129,6 @@
PNG_LIBS=""
AC_MSG_RESULT([bundled])
elif test "x${with_libpng}" = "xsystem"; then
- PKG_CHECK_MODULES(PNG, libpng, [LIBPNG_FOUND=yes], [LIBPNG_FOUND=no])
if test "x${LIBPNG_FOUND}" = "xyes"; then
# PKG_CHECK_MODULES will set PNG_CFLAGS and PNG_LIBS
USE_EXTERNAL_LIBPNG=true
@@ -183,6 +183,24 @@
if test "x${ZLIB_FOUND}" = "xyes"; then
USE_EXTERNAL_LIBZ=true
AC_MSG_RESULT([system])
+
+ if test "x$USE_EXTERNAL_LIBPNG" != "xtrue"; then
+ # If we use bundled libpng, we must verify that we have a proper zlib.
+ # For instance zlib-ng has had issues with inflateValidate().
+ AC_MSG_CHECKING([for system zlib functionality])
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([#include "zlib.h"], [
+ #if ZLIB_VERNUM >= 0x1281
+ inflateValidate(NULL, 0);
+ #endif
+ ])],
+ [AC_MSG_RESULT([ok])],
+ [
+ AC_MSG_RESULT([not ok])
+ AC_MSG_ERROR([System zlib not working correctly])
+ ]
+ )
+ fi
else
AC_MSG_RESULT([system not found])
AC_MSG_ERROR([--with-zlib=system specified, but no zlib found!])
diff -r 10b34c929b4f -r 64298b1e890b make/autoconf/lib-freetype.m4
--- a/make/autoconf/lib-freetype.m4 Tue Dec 05 10:21:41 2017 +0000
+++ b/make/autoconf/lib-freetype.m4 Tue Dec 05 10:28:45 2017 +0000
@@ -443,20 +443,31 @@
fi
AC_MSG_RESULT([$BUNDLE_FREETYPE])
- fi # end freetype needed
+ if test "x$BUNDLE_FREETYPE" = xyes; then
+ FREETYPE_LICENSE=""
+ AC_MSG_CHECKING([for freetype license])
+ if test "x$with_freetype_license" = "xyes"; then
+ AC_MSG_RESULT([no])
+ AC_MSG_ERROR([--with-freetype-license must have a value])
+ elif test "x$with_freetype_license" != "x"; then
+ AC_MSG_RESULT([$with_freetype_license])
+ FREETYPE_LICENSE="$with_freetype_license"
+ BASIC_FIXUP_PATH(FREETYPE_LICENSE)
+ if test ! -f "$FREETYPE_LICENSE"; then
+ AC_MSG_ERROR([$FREETYPE_LICENSE cannot be found])
+ fi
+ else
+ if test "x$with_freetype" != "x" && test -f $with_freetype/freetype.md; then
+ FREETYPE_LICENSE="$with_freetype/freetype.md"
+ AC_MSG_RESULT([$FREETYPE_LICENSE])
+ BASIC_FIXUP_PATH(FREETYPE_LICENSE)
+ else
+ AC_MSG_RESULT([no])
+ fi
+ fi
+ fi
- FREETYPE_LICENSE=""
- if test "x$with_freetype_license" = "xyes"; then
- AC_MSG_ERROR([--with-freetype-license must have a value])
- elif test "x$with_freetype_license" != "x"; then
- AC_MSG_CHECKING([for freetype license])
- AC_MSG_RESULT([$with_freetype_license])
- FREETYPE_LICENSE="$with_freetype_license"
- BASIC_FIXUP_PATH(FREETYPE_LICENSE)
- if test ! -f "$FREETYPE_LICENSE"; then
- AC_MSG_ERROR([$FREETYPE_LICENSE cannot be found])
- fi
- fi
+ fi # end freetype needed
AC_SUBST(FREETYPE_BUNDLE_LIB_PATH)
AC_SUBST(FREETYPE_CFLAGS)
diff -r 10b34c929b4f -r 64298b1e890b make/autoconf/spec.gmk.in
--- a/make/autoconf/spec.gmk.in Tue Dec 05 10:21:41 2017 +0000
+++ b/make/autoconf/spec.gmk.in Tue Dec 05 10:28:45 2017 +0000
@@ -293,6 +293,7 @@
FREETYPE_CFLAGS:=@FREETYPE_CFLAGS@
FREETYPE_BUNDLE_LIB_PATH=@FREETYPE_BUNDLE_LIB_PATH@
FREETYPE_LICENSE=@FREETYPE_LICENSE@
+FONTCONFIG_CFLAGS:=@FONTCONFIG_CFLAGS@
CUPS_CFLAGS:=@CUPS_CFLAGS@
ALSA_LIBS:=@ALSA_LIBS@
ALSA_CFLAGS:=@ALSA_CFLAGS@
@@ -471,6 +472,7 @@
STRIP:=@STRIP@
LIPO:=@LIPO@
+INSTALL_NAME_TOOL:=@INSTALL_NAME_TOOL@
# Options to linker to specify a mapfile.
# (Note absence of := assignment, because we do not want to evaluate the macro body here)
diff -r 10b34c929b4f -r 64298b1e890b make/autoconf/toolchain.m4
--- a/make/autoconf/toolchain.m4 Tue Dec 05 10:21:41 2017 +0000
+++ b/make/autoconf/toolchain.m4 Tue Dec 05 10:28:45 2017 +0000
@@ -628,6 +628,10 @@
if test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
BASIC_PATH_PROGS(LIPO, lipo)
BASIC_FIXUP_EXECUTABLE(LIPO)
+ BASIC_REQUIRE_PROGS(OTOOL, otool)
+ BASIC_FIXUP_EXECUTABLE(OTOOL)
+ BASIC_REQUIRE_PROGS(INSTALL_NAME_TOOL, install_name_tool)
+ BASIC_FIXUP_EXECUTABLE(INSTALL_NAME_TOOL)
fi
if test "x$TOOLCHAIN_TYPE" = xmicrosoft; then
diff -r 10b34c929b4f -r 64298b1e890b make/conf/jib-profiles.js
--- a/make/conf/jib-profiles.js Tue Dec 05 10:21:41 2017 +0000
+++ b/make/conf/jib-profiles.js Tue Dec 05 10:28:45 2017 +0000
@@ -429,7 +429,7 @@
"macosx-x64": {
target_os: "macosx",
target_cpu: "x64",
- dependencies: ["devkit"],
+ dependencies: ["devkit", "freetype"],
configure_args: concat(common.configure_args_64bit, "--with-zlib=system",
"--with-macosx-version-max=10.7.0"),
},
@@ -662,21 +662,6 @@
}
});
- // The windows ri profile needs to add the freetype license file
- profilesRiFreetype = {
- "windows-x86-ri": {
- configure_args: "--with-freetype-license="
- + input.get("freetype", "install_path")
- + "/freetype-2.7.1-v120-x86/freetype.md"
- },
- "windows-x64-ri": {
- configure_args: "--with-freetype-license="
- + input.get("freetype", "install_path")
- + "/freetype-2.7.1-v120-x64/freetype.md"
- }
- };
- profiles = concatObjects(profiles, profilesRiFreetype);
-
// Profiles used to run tests. Used in JPRT and Mach 5.
var testOnlyProfiles = {
"run-test-jprt": {
@@ -788,6 +773,12 @@
var boot_jdk_platform = (input.build_os == "macosx" ? "osx" : input.build_os)
+ "-" + input.build_cpu;
+ var freetype_version = {
+ windows_x64: "2.7.1-v120+1.1",
+ windows_x86: "2.7.1-v120+1.1",
+ macosx_x64: "2.7.1-Xcode6.3-MacOSX10.9+1.0"
+ }[input.target_platform];
+
var dependencies = {
boot_jdk: {
@@ -852,7 +843,7 @@
freetype: {
organization: common.organization,
ext: "tar.gz",
- revision: "2.7.1-v120+1.0",
+ revision: freetype_version,
module: "freetype-" + input.target_platform
},
diff -r 10b34c929b4f -r 64298b1e890b make/copy/Copy-java.desktop.gmk
--- a/make/copy/Copy-java.desktop.gmk Tue Dec 05 10:21:41 2017 +0000
+++ b/make/copy/Copy-java.desktop.gmk Tue Dec 05 10:28:45 2017 +0000
@@ -44,7 +44,8 @@
################################################################################
ifneq ($(FREETYPE_BUNDLE_LIB_PATH), )
- # We need to bundle the freetype library, so it will be available at runtime as well as link time.
+ # We need to bundle the freetype library, so it will be available at runtime
+ # as well as link time.
#
# NB: Default freetype build system uses -h linker option and
# result .so contains hardcoded library name that is later
@@ -61,10 +62,10 @@
#
#TODO: rework this to avoid hardcoding library name in the makefile
#
- ifeq ($(OPENJDK_TARGET_OS), windows)
+ ifneq ($(filter $(OPENJDK_TARGET_OS), linux solaris), )
+ FREETYPE_TARGET_LIB := $(LIB_DST_DIR)/$(call SHARED_LIBRARY,freetype).6
+ else
FREETYPE_TARGET_LIB := $(LIB_DST_DIR)/$(call SHARED_LIBRARY,freetype)
- else
- FREETYPE_TARGET_LIB := $(LIB_DST_DIR)/$(call SHARED_LIBRARY,freetype).6
endif
# We can't use $(install-file) in this rule because it preserves symbolic links and
diff -r 10b34c929b4f -r 64298b1e890b make/data/charsetmapping/charsets
--- a/make/data/charsetmapping/charsets Tue Dec 05 10:21:41 2017 +0000
+++ b/make/data/charsetmapping/charsets Tue Dec 05 10:28:45 2017 +0000
@@ -492,7 +492,7 @@
charset x-MS950-HKSCS MS950_HKSCS
package sun.nio.cs.ext
- type source
+ type template
hisname MS950_HKSCS
ascii true
alias MS950_HKSCS # JDK historical;
diff -r 10b34c929b4f -r 64298b1e890b make/data/charsetmapping/stdcs-windows
--- a/make/data/charsetmapping/stdcs-windows Tue Dec 05 10:21:41 2017 +0000
+++ b/make/data/charsetmapping/stdcs-windows Tue Dec 05 10:28:45 2017 +0000
@@ -13,4 +13,5 @@
MS936
MS949
MS950
+MS950_HKSCS
MS950_HKSCS_XP
diff -r 10b34c929b4f -r 64298b1e890b make/hotspot/symbols/symbols-unix
--- a/make/hotspot/symbols/symbols-unix Tue Dec 05 10:21:41 2017 +0000
+++ b/make/hotspot/symbols/symbols-unix Tue Dec 05 10:28:45 2017 +0000
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved.
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
#
# This code is free software; you can redistribute it and/or modify it
@@ -25,8 +25,6 @@
JVM_ArrayCopy
JVM_AssertionStatusDirectives
JVM_CallStackWalk
-JVM_ClassDepth
-JVM_ClassLoaderDepth
JVM_Clone
JVM_ConstantPoolGetClassAt
JVM_ConstantPoolGetClassAtIfLoaded
@@ -47,8 +45,6 @@
JVM_ConstantPoolGetTagAt
JVM_ConstantPoolGetUTF8At
JVM_CountStackFrames
-JVM_CurrentClassLoader
-JVM_CurrentLoadedClass
JVM_CurrentThread
JVM_CurrentTimeMillis
JVM_DefineClass
diff -r 10b34c929b4f -r 64298b1e890b make/jdk/src/classes/build/tools/charsetmapping/Main.java
--- a/make/jdk/src/classes/build/tools/charsetmapping/Main.java Tue Dec 05 10:21:41 2017 +0000
+++ b/make/jdk/src/classes/build/tools/charsetmapping/Main.java Tue Dec 05 10:28:45 2017 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -54,6 +54,7 @@
new File(args[SRC_DIR], args[CHARSETS]));
String[] osStdcs = getOSStdCSList(new File(args[SRC_DIR], args[OS]));
boolean hasBig5_HKSCS = false;
+ boolean hasMS950_HKSCS = false;
boolean hasMS950_HKSCS_XP = false;
boolean hasEUC_TW = false;
for (String name : osStdcs) {
@@ -63,6 +64,8 @@
}
if (name.equals("Big5_HKSCS")) {
hasBig5_HKSCS = true;
+ } else if (name.equals("MS950_HKSCS")) {
+ hasMS950_HKSCS = true;
} else if (name.equals("MS950_HKSCS_XP")) {
hasMS950_HKSCS_XP = true;
} else if (name.equals("EUC_TW")) {
@@ -98,12 +101,15 @@
args[TEMPLATE],
args[OS].endsWith("windows") ? "windows" : "unix");
- // HKSCSMapping2008/XP.java goes together with Big5/MS950XP_HKSCS
- if (isStandard && hasBig5_HKSCS || isExtended && !hasBig5_HKSCS) {
+ // HKSCSMapping(2008).java goes std if one of Big5_HKSCS MS950_HKSCS
+ // is in std
+ if (isStandard && (hasBig5_HKSCS || hasMS950_HKSCS) ||
+ isExtended && !(hasBig5_HKSCS || hasMS950_HKSCS)) {
HKSCS.genClass2008(args[SRC_DIR], args[DST_DIR],
isStandard ? "sun.nio.cs" : "sun.nio.cs.ext",
new File(args[COPYRIGHT_SRC], "HKSCS.java"));
}
+ // HKSCS_XPMapping.java goes together with MS950XP_HKSCS
if (isStandard && hasMS950_HKSCS_XP || isExtended && !hasMS950_HKSCS_XP) {
HKSCS.genClassXP(args[SRC_DIR], args[DST_DIR],
isStandard ? "sun.nio.cs" : "sun.nio.cs.ext",
diff -r 10b34c929b4f -r 64298b1e890b make/lib/Awt2dLibraries.gmk
--- a/make/lib/Awt2dLibraries.gmk Tue Dec 05 10:21:41 2017 +0000
+++ b/make/lib/Awt2dLibraries.gmk Tue Dec 05 10:28:45 2017 +0000
@@ -658,7 +658,7 @@
$(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
LIBRARY := fontmanager, \
- OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
+ OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfontmanager, \
SRC := $(LIBFONTMANAGER_SRC), \
EXCLUDE_FILES := $(LIBFONTMANAGER_EXCLUDE_FILES) \
AccelGlyphCache.c, \
@@ -702,6 +702,21 @@
OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libfontmanager, \
))
+$(INSTALL_LIBRARIES_HERE)/$(call SHARED_LIBRARY,fontmanager): $(BUILD_LIBFONTMANAGER_TARGET)
+ $(install-file)
+ ifneq ($(FREETYPE_BUNDLE_LIB_PATH), )
+ ifeq ($(OPENJDK_TARGET_OS), macosx)
+ # If bundling freetype on macosx, we need to rewrite the rpath location
+ # in the libfontmanager library to point to the bundled location
+ $(INSTALL_NAME_TOOL) -change \
+ `$(OTOOL) -D $(FREETYPE_BUNDLE_LIB_PATH)/$(call SHARED_LIBRARY,freetype) | $(TAIL) -n1` \
+ '@rpath/$(call SHARED_LIBRARY,freetype)' \
+ $@
+ endif
+ endif
+
+BUILD_LIBFONTMANAGER += $(INSTALL_LIBRARIES_HERE)/$(call SHARED_LIBRARY,fontmanager)
+
$(BUILD_LIBFONTMANAGER): $(BUILD_LIBAWT)
ifneq (, $(findstring $(OPENJDK_TARGET_OS), solaris aix))
diff -r 10b34c929b4f -r 64298b1e890b make/mapfiles/libjava/mapfile-vers
--- a/make/mapfiles/libjava/mapfile-vers Tue Dec 05 10:21:41 2017 +0000
+++ b/make/mapfiles/libjava/mapfile-vers Tue Dec 05 10:28:45 2017 +0000
@@ -205,10 +205,6 @@
Java_java_lang_Runtime_runFinalization0;
Java_java_lang_Runtime_totalMemory;
Java_java_lang_Runtime_availableProcessors;
- Java_java_lang_SecurityManager_classDepth;
- Java_java_lang_SecurityManager_classLoaderDepth0;
- Java_java_lang_SecurityManager_currentClassLoader0;
- Java_java_lang_SecurityManager_currentLoadedClass0;
Java_java_lang_SecurityManager_getClassContext;
Java_java_lang_Shutdown_halt0;
Java_java_lang_StackTraceElement_initStackTraceElement;
diff -r 10b34c929b4f -r 64298b1e890b src/hotspot/cpu/aarch64/vm_version_aarch64.cpp
--- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp Tue Dec 05 10:21:41 2017 +0000
+++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp Tue Dec 05 10:28:45 2017 +0000
@@ -148,6 +148,16 @@
PrefetchCopyIntervalInBytes = 32760;
}
+ if (AllocatePrefetchDistance !=-1 && (AllocatePrefetchDistance & 7)) {
+ warning("AllocatePrefetchDistance must be multiple of 8");
+ AllocatePrefetchDistance &= ~7;
+ }
+
+ if (AllocatePrefetchStepSize & 7) {
+ warning("AllocatePrefetchStepSize must be multiple of 8");
+ AllocatePrefetchStepSize &= ~7;
+ }
+
if (SoftwarePrefetchHintDistance != -1 &&
(SoftwarePrefetchHintDistance & 7)) {
warning("SoftwarePrefetchHintDistance must be -1, or a multiple of 8");
diff -r 10b34c929b4f -r 64298b1e890b src/hotspot/share/prims/jvm.cpp
--- a/src/hotspot/share/prims/jvm.cpp Tue Dec 05 10:21:41 2017 +0000
+++ b/src/hotspot/share/prims/jvm.cpp Tue Dec 05 10:28:45 2017 +0000
@@ -3137,64 +3137,6 @@
// java.lang.SecurityManager ///////////////////////////////////////////////////////////////////////
-static bool is_trusted_frame(JavaThread* jthread, vframeStream* vfst) {
- assert(jthread->is_Java_thread(), "must be a Java thread");
- if (jthread->privileged_stack_top() == NULL) return false;
- if (jthread->privileged_stack_top()->frame_id() == vfst->frame_id()) {
- oop loader = jthread->privileged_stack_top()->class_loader();
- if (loader == NULL) return true;
- bool trusted = java_lang_ClassLoader::is_trusted_loader(loader);
- if (trusted) return true;
- }
- return false;
-}
-
-JVM_ENTRY(jclass, JVM_CurrentLoadedClass(JNIEnv *env))
- JVMWrapper("JVM_CurrentLoadedClass");
- ResourceMark rm(THREAD);
-
- for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) {
- // if a method in a class in a trusted loader is in a doPrivileged, return NULL
- bool trusted = is_trusted_frame(thread, &vfst);
- if (trusted) return NULL;
-
- Method* m = vfst.method();
- if (!m->is_native()) {
- InstanceKlass* holder = m->method_holder();
- oop loader = holder->class_loader();
- if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) {
- return (jclass) JNIHandles::make_local(env, holder->java_mirror());
- }
- }
- }
- return NULL;
-JVM_END
-
-
-JVM_ENTRY(jobject, JVM_CurrentClassLoader(JNIEnv *env))
- JVMWrapper("JVM_CurrentClassLoader");
- ResourceMark rm(THREAD);
-
- for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) {
-
- // if a method in a class in a trusted loader is in a doPrivileged, return NULL
- bool trusted = is_trusted_frame(thread, &vfst);
- if (trusted) return NULL;
-
- Method* m = vfst.method();
- if (!m->is_native()) {
- InstanceKlass* holder = m->method_holder();
- assert(holder->is_klass(), "just checking");
- oop loader = holder->class_loader();
- if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) {
- return JNIHandles::make_local(env, loader);
- }
- }
- }
- return NULL;
-JVM_END
-
-
JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))
JVMWrapper("JVM_GetClassContext");
ResourceMark rm(THREAD);
@@ -3234,58 +3176,6 @@
JVM_END
-JVM_ENTRY(jint, JVM_ClassDepth(JNIEnv *env, jstring name))
- JVMWrapper("JVM_ClassDepth");
- ResourceMark rm(THREAD);
- Handle h_name (THREAD, JNIHandles::resolve_non_null(name));
- Handle class_name_str = java_lang_String::internalize_classname(h_name, CHECK_0);
-
- const char* str = java_lang_String::as_utf8_string(class_name_str());
- TempNewSymbol class_name_sym = SymbolTable::probe(str, (int)strlen(str));
- if (class_name_sym == NULL) {
- return -1;
- }
-
- int depth = 0;
-
- for(vframeStream vfst(thread); !vfst.at_end(); vfst.next()) {
- if (!vfst.method()->is_native()) {
- InstanceKlass* holder = vfst.method()->method_holder();
- assert(holder->is_klass(), "just checking");
- if (holder->name() == class_name_sym) {
- return depth;
- }
- depth++;
- }
- }
- return -1;
-JVM_END
-
-
-JVM_ENTRY(jint, JVM_ClassLoaderDepth(JNIEnv *env))
- JVMWrapper("JVM_ClassLoaderDepth");
- ResourceMark rm(THREAD);
- int depth = 0;
- for (vframeStream vfst(thread); !vfst.at_end(); vfst.next()) {
- // if a method in a class in a trusted loader is in a doPrivileged, return -1
- bool trusted = is_trusted_frame(thread, &vfst);
- if (trusted) return -1;
-
- Method* m = vfst.method();
- if (!m->is_native()) {
- InstanceKlass* holder = m->method_holder();
- assert(holder->is_klass(), "just checking");
- oop loader = holder->class_loader();
- if (loader != NULL && !java_lang_ClassLoader::is_trusted_loader(loader)) {
- return depth;
- }
- depth++;
- }
- }
- return -1;
-JVM_END
-
-
// java.lang.Package ////////////////////////////////////////////////////////////////
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/lang/Class.java
--- a/src/java.base/share/classes/java/lang/Class.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/lang/Class.java Tue Dec 05 10:28:45 2017 +0000
@@ -53,12 +53,11 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
-import java.util.Set;
import java.util.StringJoiner;
import jdk.internal.HotSpotIntrinsicCandidate;
@@ -1771,7 +1770,7 @@
if (sm != null) {
checkMemberAccess(sm, Member.PUBLIC, Reflection.getCallerClass(), true);
}
- return copyFields(privateGetPublicFields(null));
+ return copyFields(privateGetPublicFields());
}
@@ -3026,7 +3025,7 @@
// Returns an array of "root" fields. These Field objects must NOT
// be propagated to the outside world, but must instead be copied
// via ReflectionFactory.copyField.
- private Field[] privateGetPublicFields(Set> traversedInterfaces) {
+ private Field[] privateGetPublicFields() {
Field[] res;
ReflectionData rd = reflectionData();
if (rd != null) {
@@ -3034,35 +3033,25 @@
if (res != null) return res;
}
- // No cached value available; compute value recursively.
- // Traverse in correct order for getField().
- List fields = new ArrayList<>();
- if (traversedInterfaces == null) {
- traversedInterfaces = new HashSet<>();
- }
+ // Use a linked hash set to ensure order is preserved and
+ // fields from common super interfaces are not duplicated
+ LinkedHashSet fields = new LinkedHashSet<>();
// Local fields
- Field[] tmp = privateGetDeclaredFields(true);
- addAll(fields, tmp);
+ addAll(fields, privateGetDeclaredFields(true));
// Direct superinterfaces, recursively
- for (Class> c : getInterfaces()) {
- if (!traversedInterfaces.contains(c)) {
- traversedInterfaces.add(c);
- addAll(fields, c.privateGetPublicFields(traversedInterfaces));
- }
+ for (Class> si : getInterfaces()) {
+ addAll(fields, si.privateGetPublicFields());
}
// Direct superclass, recursively
- if (!isInterface()) {
- Class> c = getSuperclass();
- if (c != null) {
- addAll(fields, c.privateGetPublicFields(traversedInterfaces));
- }
+ Class> sc = getSuperclass();
+ if (sc != null) {
+ addAll(fields, sc.privateGetPublicFields());
}
- res = new Field[fields.size()];
- fields.toArray(res);
+ res = fields.toArray(new Field[0]);
if (rd != null) {
rd.publicFields = res;
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/lang/SecurityManager.java
--- a/src/java.base/share/classes/java/lang/SecurityManager.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/lang/SecurityManager.java Tue Dec 05 10:28:45 2017 +0000
@@ -101,7 +101,7 @@
* checkPermission
returns quietly. If denied, a
* SecurityException
is thrown.
*
- * As of Java 2 SDK v1.2, the default implementation of each of the other
+ * The default implementation of each of the other
* check
methods in SecurityManager
is to
* call the SecurityManager checkPermission
method
* to determine if the calling thread has permission to perform the requested
@@ -197,10 +197,10 @@
* See {@extLink security_guide_permissions
* Permissions in the Java Development Kit (JDK)}
* for permission-related information.
- * This document includes, for example, a table listing the various SecurityManager
+ * This document includes a table listing the various SecurityManager
* check
methods and the permission(s) the default
* implementation of each such method requires.
- * It also contains a table of all the version 1.2 methods
+ * It also contains a table of the methods
* that require permissions, and for each such method tells
* which permission it requires.
*
@@ -228,20 +228,7 @@
*
* @since 1.0
*/
-public
-class SecurityManager {
-
- /**
- * This field is true
if there is a security check in
- * progress; false
otherwise.
- *
- * @deprecated This type of security checking is not recommended.
- * It is recommended that the checkPermission
- * call be used instead. This field is subject to removal in a
- * future version of Java SE.
- */
- @Deprecated(since="1.2", forRemoval=true)
- protected boolean inCheck;
+public class SecurityManager {
/*
* Have we been initialized. Effective against finalizer attacks.
@@ -262,24 +249,6 @@
}
/**
- * Tests if there is a security check in progress.
- *
- * @return the value of the inCheck
field. This field
- * should contain true
if a security check is
- * in progress,
- * false
otherwise.
- * @see java.lang.SecurityManager#inCheck
- * @deprecated This type of security checking is not recommended.
- * It is recommended that the checkPermission
- * call be used instead. This method is subject to removal in a
- * future version of Java SE.
- */
- @Deprecated(since="1.2", forRemoval=true)
- public boolean getInCheck() {
- return inCheck;
- }
-
- /**
* Constructs a new SecurityManager
.
*
*
If there is a security manager already installed, this method first
@@ -322,198 +291,6 @@
protected native Class>[] getClassContext();
/**
- * Returns the class loader of the most recently executing method from
- * a class defined using a non-system class loader. A non-system
- * class loader is defined as being a class loader that is not equal to
- * the system class loader (as returned
- * by {@link ClassLoader#getSystemClassLoader}) or one of its ancestors.
- *
- * This method will return
- * null
in the following three cases:
- *
- * - All methods on the execution stack are from classes
- * defined using the system class loader or one of its ancestors.
- *
- *
- All methods on the execution stack up to the first
- * "privileged" caller
- * (see {@link java.security.AccessController#doPrivileged})
- * are from classes
- * defined using the system class loader or one of its ancestors.
- *
- *
- A call to
checkPermission
with
- * java.security.AllPermission
does not
- * result in a SecurityException.
- *
- *
- *
- * @return the class loader of the most recent occurrence on the stack
- * of a method from a class defined using a non-system class
- * loader.
- *
- * @deprecated This type of security checking is not recommended.
- * It is recommended that the checkPermission
- * call be used instead. This method is subject to removal in a
- * future version of Java SE.
- *
- * @see java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
- * @see #checkPermission(java.security.Permission) checkPermission
- */
- @Deprecated(since="1.2", forRemoval=true)
- protected ClassLoader currentClassLoader() {
- ClassLoader cl = currentClassLoader0();
- if ((cl != null) && hasAllPermission())
- cl = null;
- return cl;
- }
-
- private native ClassLoader currentClassLoader0();
-
- /**
- * Returns the class of the most recently executing method from
- * a class defined using a non-system class loader. A non-system
- * class loader is defined as being a class loader that is not equal to
- * the system class loader (as returned
- * by {@link ClassLoader#getSystemClassLoader}) or one of its ancestors.
- *
- * This method will return
- * null
in the following three cases:
- *
- * - All methods on the execution stack are from classes
- * defined using the system class loader or one of its ancestors.
- *
- *
- All methods on the execution stack up to the first
- * "privileged" caller
- * (see {@link java.security.AccessController#doPrivileged})
- * are from classes
- * defined using the system class loader or one of its ancestors.
- *
- *
- A call to
checkPermission
with
- * java.security.AllPermission
does not
- * result in a SecurityException.
- *
- *
- *
- * @return the class of the most recent occurrence on the stack
- * of a method from a class defined using a non-system class
- * loader.
- *
- * @deprecated This type of security checking is not recommended.
- * It is recommended that the checkPermission
- * call be used instead. This method is subject to removal in a
- * future version of Java SE.
- *
- * @see java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
- * @see #checkPermission(java.security.Permission) checkPermission
- */
- @Deprecated(since="1.2", forRemoval=true)
- protected Class> currentLoadedClass() {
- Class> c = currentLoadedClass0();
- if ((c != null) && hasAllPermission())
- c = null;
- return c;
- }
-
- /**
- * Returns the stack depth of the specified class.
- *
- * @param name the fully qualified name of the class to search for.
- * @return the depth on the stack frame of the first occurrence of a
- * method from a class with the specified name;
- * -1
if such a frame cannot be found.
- * @deprecated This type of security checking is not recommended.
- * It is recommended that the checkPermission
- * call be used instead. This method is subject to removal in a
- * future version of Java SE.
- */
- @Deprecated(since="1.2", forRemoval=true)
- protected native int classDepth(String name);
-
- /**
- * Returns the stack depth of the most recently executing method
- * from a class defined using a non-system class loader. A non-system
- * class loader is defined as being a class loader that is not equal to
- * the system class loader (as returned
- * by {@link ClassLoader#getSystemClassLoader}) or one of its ancestors.
- *
- * This method will return
- * -1 in the following three cases:
- *
- * - All methods on the execution stack are from classes
- * defined using the system class loader or one of its ancestors.
- *
- *
- All methods on the execution stack up to the first
- * "privileged" caller
- * (see {@link java.security.AccessController#doPrivileged})
- * are from classes
- * defined using the system class loader or one of its ancestors.
- *
- *
- A call to
checkPermission
with
- * java.security.AllPermission
does not
- * result in a SecurityException.
- *
- *
- *
- * @return the depth on the stack frame of the most recent occurrence of
- * a method from a class defined using a non-system class loader.
- *
- * @deprecated This type of security checking is not recommended.
- * It is recommended that the checkPermission
- * call be used instead. This method is subject to removal in a
- * future version of Java SE.
- *
- * @see java.lang.ClassLoader#getSystemClassLoader() getSystemClassLoader
- * @see #checkPermission(java.security.Permission) checkPermission
- */
- @Deprecated(since="1.2", forRemoval=true)
- protected int classLoaderDepth() {
- int depth = classLoaderDepth0();
- if (depth != -1) {
- if (hasAllPermission())
- depth = -1;
- else
- depth--; // make sure we don't include ourself
- }
- return depth;
- }
-
- private native int classLoaderDepth0();
-
- /**
- * Tests if a method from a class with the specified
- * name is on the execution stack.
- *
- * @param name the fully qualified name of the class.
- * @return true
if a method from a class with the specified
- * name is on the execution stack; false
otherwise.
- * @deprecated This type of security checking is not recommended.
- * It is recommended that the checkPermission
- * call be used instead. This method is subject to removal in a
- * future version of Java SE.
- */
- @Deprecated(since="1.2", forRemoval=true)
- protected boolean inClass(String name) {
- return classDepth(name) >= 0;
- }
-
- /**
- * Basically, tests if a method from a class defined using a
- * class loader is on the execution stack.
- *
- * @return true
if a call to currentClassLoader
- * has a non-null return value.
- *
- * @deprecated This type of security checking is not recommended.
- * It is recommended that the checkPermission
- * call be used instead. This method is subject to removal in a
- * future version of Java SE.
- * @see #currentClassLoader() currentClassLoader
- */
- @Deprecated(since="1.2", forRemoval=true)
- protected boolean inClassLoader() {
- return currentClassLoader() != null;
- }
-
- /**
* Creates an object that encapsulates the current execution
* environment. The result of this method is used, for example, by the
* three-argument checkConnect
method and by the
@@ -1698,64 +1475,32 @@
}
/**
- * Throws a SecurityException
if the
- * calling thread is not allowed to access members.
- *
- * The default policy is to allow access to PUBLIC members, as well
- * as access to classes that have the same class loader as the caller.
- * In all other cases, this method calls checkPermission
- * with the RuntimePermission("accessDeclaredMembers")
- *
permission.
- *
- * If this method is overridden, then a call to
- * super.checkMemberAccess
cannot be made,
- * as the default implementation of checkMemberAccess
- * relies on the code being checked being at a stack depth of
- * 4.
+ * Throws a {@code SecurityException} if the calling thread does
+ * not have {@code AllPermission}.
*
* @param clazz the class that reflection is to be performed on.
- *
* @param which type of access, PUBLIC or DECLARED.
- *
- * @exception SecurityException if the caller does not have
- * permission to access members.
- * @exception NullPointerException if the clazz
argument is
- * null
.
- *
- * @deprecated This method relies on the caller being at a stack depth
- * of 4 which is error-prone and cannot be enforced by the runtime.
- * Users of this method should instead invoke {@link #checkPermission}
- * directly.
- * This method is subject to removal in a future version of Java SE.
- *
- * @see java.lang.reflect.Member
+ * @throws SecurityException if the caller does not have
+ * {@code AllPermission}
+ * @throws NullPointerException if the {@code clazz} argument is
+ * {@code null}
+ * @deprecated This method was originally used to check if the calling
+ * thread was allowed to access members. It relied on the
+ * caller being at a stack depth of 4 which is error-prone and
+ * cannot be enforced by the runtime. The method has been
+ * obsoleted and code should instead use
+ * {@link #checkPermission} to check
+ * {@code RuntimePermission("accessDeclaredMembers")}. This
+ * method is subject to removal in a future version of Java SE.
* @since 1.1
* @see #checkPermission(java.security.Permission) checkPermission
*/
@Deprecated(since="1.8", forRemoval=true)
- @CallerSensitive
public void checkMemberAccess(Class> clazz, int which) {
if (clazz == null) {
throw new NullPointerException("class can't be null");
}
- if (which != Member.PUBLIC) {
- Class> stack[] = getClassContext();
- /*
- * stack depth of 4 should be the caller of one of the
- * methods in java.lang.Class that invoke checkMember
- * access. The stack should look like:
- *
- * someCaller [3]
- * java.lang.Class.someReflectionAPI [2]
- * java.lang.Class.checkMemberAccess [1]
- * SecurityManager.checkMemberAccess [0]
- *
- */
- if ((stack.length<4) ||
- (stack[3].getClassLoader() != clazz.getClassLoader())) {
- checkPermission(SecurityConstants.CHECK_MEMBER_ACCESS_PERMISSION);
- }
- }
+ checkPermission(SecurityConstants.ALL_PERMISSION);
}
/**
@@ -1792,8 +1537,6 @@
checkPermission(new SecurityPermission(target));
}
- private native Class> currentLoadedClass0();
-
/**
* Returns the thread group into which to instantiate any new
* thread being created at the time this is being called.
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/lang/System.java
--- a/src/java.base/share/classes/java/lang/System.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/lang/System.java Tue Dec 05 10:28:45 2017 +0000
@@ -63,8 +63,8 @@
import jdk.internal.reflect.CallerSensitive;
import jdk.internal.reflect.Reflection;
import jdk.internal.HotSpotIntrinsicCandidate;
-import jdk.internal.misc.JavaLangAccess;;
-import jdk.internal.misc.SharedSecrets;;
+import jdk.internal.misc.JavaLangAccess;
+import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.VM;
import jdk.internal.logger.LoggerFinderLoader;
import jdk.internal.logger.LazyLoggers;
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/util/Collection.java
--- a/src/java.base/share/classes/java/util/Collection.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/util/Collection.java Tue Dec 05 10:28:45 2017 +0000
@@ -54,19 +54,15 @@
* constructors) but all of the general-purpose {@code Collection}
* implementations in the Java platform libraries comply.
*
- *
The "destructive" methods contained in this interface, that is, the
- * methods that modify the collection on which they operate, are specified to
- * throw {@code UnsupportedOperationException} if this collection does not
- * support the operation. If this is the case, these methods may, but are not
- * required to, throw an {@code UnsupportedOperationException} if the
- * invocation would have no effect on the collection. For example, invoking
- * the {@link #addAll(Collection)} method on an unmodifiable collection may,
- * but is not required to, throw the exception if the collection to be added
- * is empty.
+ *
Certain methods are specified to be
+ * optional. If a collection implementation doesn't implement a
+ * particular operation, it should define the corresponding method to throw
+ * {@code UnsupportedOperationException}. Such methods are marked "optional
+ * operation" in method specifications of the collections interfaces.
*
- *
- * Some collection implementations have restrictions on the elements that
- * they may contain. For example, some implementations prohibit null elements,
+ *
Some collection implementations
+ * have restrictions on the elements that they may contain.
+ * For example, some implementations prohibit null elements,
* and some have restrictions on the types of their elements. Attempting to
* add an ineligible element throws an unchecked exception, typically
* {@code NullPointerException} or {@code ClassCastException}. Attempting
@@ -111,6 +107,86 @@
* methods. Implementations may optionally handle the self-referential scenario,
* however most current implementations do not do so.
*
+ *
View Collections
+ *
+ * Most collections manage storage for elements they contain. By contrast, view
+ * collections themselves do not store elements, but instead they rely on a
+ * backing collection to store the actual elements. Operations that are not handled
+ * by the view collection itself are delegated to the backing collection. Examples of
+ * view collections include the wrapper collections returned by methods such as
+ * {@link Collections#checkedCollection Collections.checkedCollection},
+ * {@link Collections#synchronizedCollection Collections.synchronizedCollection}, and
+ * {@link Collections#unmodifiableCollection Collections.unmodifiableCollection}.
+ * Other examples of view collections include collections that provide a
+ * different representation of the same elements, for example, as
+ * provided by {@link List#subList List.subList},
+ * {@link NavigableSet#subSet NavigableSet.subSet}, or
+ * {@link Map#entrySet Map.entrySet}.
+ * Any changes made to the backing collection are visible in the view collection.
+ * Correspondingly, any changes made to the view collection — if changes
+ * are permitted — are written through to the backing collection.
+ * Although they technically aren't collections, instances of
+ * {@link Iterator} and {@link ListIterator} can also allow modifications
+ * to be written through to the backing collection, and in some cases,
+ * modifications to the backing collection will be visible to the Iterator
+ * during iteration.
+ *
+ *
Unmodifiable Collections
+ *
+ * Certain methods of this interface are considered "destructive" and are called
+ * "mutator" methods in that they modify the group of objects contained within
+ * the collection on which they operate. They can be specified to throw
+ * {@code UnsupportedOperationException} if this collection implementation
+ * does not support the operation. Such methods should (but are not required
+ * to) throw an {@code UnsupportedOperationException} if the invocation would
+ * have no effect on the collection. For example, consider a collection that
+ * does not support the {@link #add add} operation. What will happen if the
+ * {@link #addAll addAll} method is invoked on this collection, with an empty
+ * collection as the argument? The addition of zero elements has no effect,
+ * so it is permissible for this collection simply to do nothing and not to throw
+ * an exception. However, it is recommended that such cases throw an exception
+ * unconditionally, as throwing only in certain cases can lead to
+ * programming errors.
+ *
+ *
An unmodifiable collection is a collection, all of whose
+ * mutator methods (as defined above) are specified to throw
+ * {@code UnsupportedOperationException}. Such a collection thus cannot be
+ * modified by calling any methods on it. For a collection to be properly
+ * unmodifiable, any view collections derived from it must also be unmodifiable.
+ * For example, if a List is unmodifiable, the List returned by
+ * {@link List#subList List.subList} is also unmodifiable.
+ *
+ *
An unmodifiable collection is not necessarily immutable. If the
+ * contained elements are mutable, the entire collection is clearly
+ * mutable, even though it might be unmodifiable. For example, consider
+ * two unmodifiable lists containing mutable elements. The result of calling
+ * {@code list1.equals(list2)} might differ from one call to the next if
+ * the elements had been mutated, even though both lists are unmodifiable.
+ * However, if an unmodifiable collection contains all immutable elements,
+ * it can be considered effectively immutable.
+ *
+ *
Unmodifiable View Collections
+ *
+ * An unmodifiable view collection is a collection that is unmodifiable
+ * and that is also a view onto a backing collection. Its mutator methods throw
+ * {@code UnsupportedOperationException}, as described above, while
+ * reading and querying methods are delegated to the backing collection.
+ * The effect is to provide read-only access to the backing collection.
+ * This is useful for a component to provide users with read access to
+ * an internal collection, while preventing them from modifying such
+ * collections unexpectedly. Examples of unmodifiable view collections
+ * are those returned by the
+ * {@link Collections#unmodifiableCollection Collections.unmodifiableCollection},
+ * {@link Collections#unmodifiableList Collections.unmodifiableList}, and
+ * related methods.
+ *
+ *
Note that changes to the backing collection might still be possible,
+ * and if they occur, they are visible through the unmodifiable view. Thus,
+ * an unmodifiable view collection is not necessarily immutable. However,
+ * if the backing collection of an unmodifiable view is effectively immutable,
+ * or if the only reference to the backing collection is through an
+ * unmodifiable view, the view can be considered effectively immutable.
+ *
*
This interface is a member of the
*
* Java Collections Framework.
@@ -192,7 +268,8 @@
* Returns an array containing all of the elements in this collection.
* If this collection makes any guarantees as to what order its elements
* are returned by its iterator, this method must return the elements in
- * the same order.
+ * the same order. The returned array's {@linkplain Class#getComponentType
+ * runtime component type} is {@code Object}.
*
*
The returned array will be "safe" in that no references to it are
* maintained by this collection. (In other words, this method must
@@ -202,7 +279,8 @@
*
This method acts as bridge between array-based and collection-based
* APIs.
*
- * @return an array containing all of the elements in this collection
+ * @return an array, whose {@linkplain Class#getComponentType runtime component
+ * type} is {@code Object}, containing all of the elements in this collection
*/
Object[] toArray();
@@ -239,14 +317,14 @@
* Note that {@code toArray(new Object[0])} is identical in function to
* {@code toArray()}.
*
- * @param the runtime type of the array to contain the collection
+ * @param the component type of the array to contain the collection
* @param a the array into which the elements of this collection are to be
* stored, if it is big enough; otherwise, a new array of the same
* runtime type is allocated for this purpose.
* @return an array containing all of the elements in this collection
- * @throws ArrayStoreException if the runtime type of the specified array
- * is not a supertype of the runtime type of every element in
- * this collection
+ * @throws ArrayStoreException if the runtime type of any element in this
+ * collection is not assignable to the {@linkplain Class#getComponentType
+ * runtime component type} of the specified array
* @throws NullPointerException if the specified array is null
*/
T[] toArray(T[] a);
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/util/Collections.java
--- a/src/java.base/share/classes/java/util/Collections.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/util/Collections.java Tue Dec 05 10:28:45 2017 +0000
@@ -989,9 +989,8 @@
// Unmodifiable Wrappers
/**
- * Returns an unmodifiable view of the specified collection. This method
- * allows modules to provide users with "read-only" access to internal
- * collections. Query operations on the returned collection "read through"
+ * Returns an unmodifiable view of the
+ * specified collection. Query operations on the returned collection "read through"
* to the specified collection, and attempts to modify the returned
* collection, whether direct or via its iterator, result in an
* {@code UnsupportedOperationException}.
@@ -1102,9 +1101,8 @@
}
/**
- * Returns an unmodifiable view of the specified set. This method allows
- * modules to provide users with "read-only" access to internal sets.
- * Query operations on the returned set "read through" to the specified
+ * Returns an unmodifiable view of the
+ * specified set. Query operations on the returned set "read through" to the specified
* set, and attempts to modify the returned set, whether direct or via its
* iterator, result in an {@code UnsupportedOperationException}.
*
@@ -1132,9 +1130,8 @@
}
/**
- * Returns an unmodifiable view of the specified sorted set. This method
- * allows modules to provide users with "read-only" access to internal
- * sorted sets. Query operations on the returned sorted set "read
+ * Returns an unmodifiable view of the
+ * specified sorted set. Query operations on the returned sorted set "read
* through" to the specified sorted set. Attempts to modify the returned
* sorted set, whether direct, via its iterator, or via its
* {@code subSet}, {@code headSet}, or {@code tailSet} views, result in
@@ -1180,9 +1177,8 @@
}
/**
- * Returns an unmodifiable view of the specified navigable set. This method
- * allows modules to provide users with "read-only" access to internal
- * navigable sets. Query operations on the returned navigable set "read
+ * Returns an unmodifiable view of the
+ * specified navigable set. Query operations on the returned navigable set "read
* through" to the specified navigable set. Attempts to modify the returned
* navigable set, whether direct, via its iterator, or via its
* {@code subSet}, {@code headSet}, or {@code tailSet} views, result in
@@ -1269,9 +1265,8 @@
}
/**
- * Returns an unmodifiable view of the specified list. This method allows
- * modules to provide users with "read-only" access to internal
- * lists. Query operations on the returned list "read through" to the
+ * Returns an unmodifiable view of the
+ * specified list. Query operations on the returned list "read through" to the
* specified list, and attempts to modify the returned list, whether
* direct or via its iterator, result in an
* {@code UnsupportedOperationException}.
@@ -1415,9 +1410,8 @@
}
/**
- * Returns an unmodifiable view of the specified map. This method
- * allows modules to provide users with "read-only" access to internal
- * maps. Query operations on the returned map "read through"
+ * Returns an unmodifiable view of the
+ * specified map. Query operations on the returned map "read through"
* to the specified map, and attempts to modify the returned
* map, whether direct or via its collection views, result in an
* {@code UnsupportedOperationException}.
@@ -1765,9 +1759,8 @@
}
/**
- * Returns an unmodifiable view of the specified sorted map. This method
- * allows modules to provide users with "read-only" access to internal
- * sorted maps. Query operations on the returned sorted map "read through"
+ * Returns an unmodifiable view of the
+ * specified sorted map. Query operations on the returned sorted map "read through"
* to the specified sorted map. Attempts to modify the returned
* sorted map, whether direct, via its collection views, or via its
* {@code subMap}, {@code headMap}, or {@code tailMap} views, result in
@@ -1809,9 +1802,8 @@
}
/**
- * Returns an unmodifiable view of the specified navigable map. This method
- * allows modules to provide users with "read-only" access to internal
- * navigable maps. Query operations on the returned navigable map "read
+ * Returns an unmodifiable view of the
+ * specified navigable map. Query operations on the returned navigable map "read
* through" to the specified navigable map. Attempts to modify the returned
* navigable map, whether direct, via its collection views, or via its
* {@code subMap}, {@code headMap}, or {@code tailMap} views, result in
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/util/List.java
--- a/src/java.base/share/classes/java/util/List.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/util/List.java Tue Dec 05 10:28:45 2017 +0000
@@ -87,15 +87,16 @@
* Such exceptions are marked as "optional" in the specification for this
* interface.
*
- *
Immutable List Static Factory Methods
- * The {@link List#of(Object...) List.of()} static factory methods
- * provide a convenient way to create immutable lists. The {@code List}
+ *
Unmodifiable Lists
+ * The {@link List#of(Object...) List.of} and
+ * {@link List#copyOf List.copyOf} static factory methods
+ * provide a convenient way to create unmodifiable lists. The {@code List}
* instances created by these methods have the following characteristics:
*
*
- * - They are structurally immutable. Elements cannot be added, removed,
- * or replaced. Calling any mutator method will always cause
- * {@code UnsupportedOperationException} to be thrown.
+ *
- They are unmodifiable. Elements cannot
+ * be added, removed, or replaced. Calling any mutator method on the List
+ * will always cause {@code UnsupportedOperationException} to be thrown.
* However, if the contained elements are themselves mutable,
* this may cause the List's contents to appear to change.
*
- They disallow {@code null} elements. Attempts to create them with
@@ -777,9 +778,9 @@
}
/**
- * Returns an immutable list containing zero elements.
+ * Returns an unmodifiable list containing zero elements.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param
the {@code List}'s element type
* @return an empty {@code List}
@@ -791,9 +792,9 @@
}
/**
- * Returns an immutable list containing one element.
+ * Returns an unmodifiable list containing one element.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param the {@code List}'s element type
* @param e1 the single element
@@ -807,9 +808,9 @@
}
/**
- * Returns an immutable list containing two elements.
+ * Returns an unmodifiable list containing two elements.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param the {@code List}'s element type
* @param e1 the first element
@@ -824,9 +825,9 @@
}
/**
- * Returns an immutable list containing three elements.
+ * Returns an unmodifiable list containing three elements.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param the {@code List}'s element type
* @param e1 the first element
@@ -842,9 +843,9 @@
}
/**
- * Returns an immutable list containing four elements.
+ * Returns an unmodifiable list containing four elements.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param the {@code List}'s element type
* @param e1 the first element
@@ -861,9 +862,9 @@
}
/**
- * Returns an immutable list containing five elements.
+ * Returns an unmodifiable list containing five elements.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param the {@code List}'s element type
* @param e1 the first element
@@ -881,9 +882,9 @@
}
/**
- * Returns an immutable list containing six elements.
+ * Returns an unmodifiable list containing six elements.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param the {@code List}'s element type
* @param e1 the first element
@@ -903,9 +904,9 @@
}
/**
- * Returns an immutable list containing seven elements.
+ * Returns an unmodifiable list containing seven elements.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param the {@code List}'s element type
* @param e1 the first element
@@ -926,9 +927,9 @@
}
/**
- * Returns an immutable list containing eight elements.
+ * Returns an unmodifiable list containing eight elements.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param the {@code List}'s element type
* @param e1 the first element
@@ -950,9 +951,9 @@
}
/**
- * Returns an immutable list containing nine elements.
+ * Returns an unmodifiable list containing nine elements.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param the {@code List}'s element type
* @param e1 the first element
@@ -975,9 +976,9 @@
}
/**
- * Returns an immutable list containing ten elements.
+ * Returns an unmodifiable list containing ten elements.
*
- * See Immutable List Static Factory Methods for details.
+ * See Unmodifiable Lists for details.
*
* @param the {@code List}'s element type
* @param e1 the first element
@@ -1001,8 +1002,8 @@
}
/**
- * Returns an immutable list containing an arbitrary number of elements.
- * See Immutable List Static Factory Methods for details.
+ * Returns an unmodifiable list containing an arbitrary number of elements.
+ * See Unmodifiable Lists for details.
*
* @apiNote
* This method also accepts a single array as an argument. The element type of
@@ -1039,4 +1040,29 @@
return new ImmutableCollections.ListN<>(elements);
}
}
+
+ /**
+ * Returns an unmodifiable List containing the elements of
+ * the given Collection, in its iteration order. The given Collection must not be null,
+ * and it must not contain any null elements. If the given Collection is subsequently
+ * modified, the returned List will not reflect such modifications.
+ *
+ * @implNote
+ * If the given Collection is an unmodifiable List,
+ * calling copyOf will generally not create a copy.
+ *
+ * @param the {@code List}'s element type
+ * @param coll a {@code Collection} from which elements are drawn, must be non-null
+ * @return a {@code List} containing the elements of the given {@code Collection}
+ * @throws NullPointerException if coll is null, or if it contains any nulls
+ * @since 10
+ */
+ @SuppressWarnings("unchecked")
+ static List copyOf(Collection extends E> coll) {
+ if (coll instanceof ImmutableCollections.AbstractImmutableList) {
+ return (List)coll;
+ } else {
+ return (List)List.of(coll.toArray());
+ }
+ }
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/util/Map.java
--- a/src/java.base/share/classes/java/util/Map.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/util/Map.java Tue Dec 05 10:28:45 2017 +0000
@@ -110,17 +110,18 @@
* Implementations may optionally handle the self-referential scenario, however
* most current implementations do not do so.
*
- * Immutable Map Static Factory Methods
- * The {@link Map#of() Map.of()} and
- * {@link Map#ofEntries(Map.Entry...) Map.ofEntries()}
- * static factory methods provide a convenient way to create immutable maps.
+ *
Unmodifiable Maps
+ * The {@link Map#of() Map.of},
+ * {@link Map#ofEntries(Map.Entry...) Map.ofEntries}, and
+ * {@link Map#copyOf Map.copyOf}
+ * static factory methods provide a convenient way to create unmodifiable maps.
* The {@code Map}
* instances created by these methods have the following characteristics:
*
*
- * - They are structurally immutable. Keys and values cannot be added,
- * removed, or updated. Calling any mutator method will always cause
- * {@code UnsupportedOperationException} to be thrown.
+ *
- They are unmodifiable. Keys and values
+ * cannot be added, removed, or updated. Calling any mutator method on the Map
+ * will always cause {@code UnsupportedOperationException} to be thrown.
* However, if the contained keys or values are themselves mutable, this may cause the
* Map to behave inconsistently or its contents to appear to change.
*
- They disallow {@code null} keys and values. Attempts to create them with
@@ -1276,8 +1277,8 @@
}
/**
- * Returns an immutable map containing zero mappings.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing zero mappings.
+ * See Unmodifiable Maps for details.
*
* @param
the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1290,8 +1291,8 @@
}
/**
- * Returns an immutable map containing a single mapping.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing a single mapping.
+ * See Unmodifiable Maps for details.
*
* @param the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1307,8 +1308,8 @@
}
/**
- * Returns an immutable map containing two mappings.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing two mappings.
+ * See Unmodifiable Maps for details.
*
* @param the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1327,8 +1328,8 @@
}
/**
- * Returns an immutable map containing three mappings.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing three mappings.
+ * See Unmodifiable Maps for details.
*
* @param the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1349,8 +1350,8 @@
}
/**
- * Returns an immutable map containing four mappings.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing four mappings.
+ * See Unmodifiable Maps for details.
*
* @param the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1373,8 +1374,8 @@
}
/**
- * Returns an immutable map containing five mappings.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing five mappings.
+ * See Unmodifiable Maps for details.
*
* @param the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1399,8 +1400,8 @@
}
/**
- * Returns an immutable map containing six mappings.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing six mappings.
+ * See Unmodifiable Maps for details.
*
* @param the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1429,8 +1430,8 @@
}
/**
- * Returns an immutable map containing seven mappings.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing seven mappings.
+ * See Unmodifiable Maps for details.
*
* @param the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1461,8 +1462,8 @@
}
/**
- * Returns an immutable map containing eight mappings.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing eight mappings.
+ * See Unmodifiable Maps for details.
*
* @param the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1495,8 +1496,8 @@
}
/**
- * Returns an immutable map containing nine mappings.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing nine mappings.
+ * See Unmodifiable Maps for details.
*
* @param the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1531,8 +1532,8 @@
}
/**
- * Returns an immutable map containing ten mappings.
- * See Immutable Map Static Factory Methods for details.
+ * Returns an unmodifiable map containing ten mappings.
+ * See Unmodifiable Maps for details.
*
* @param the {@code Map}'s key type
* @param the {@code Map}'s value type
@@ -1569,9 +1570,9 @@
}
/**
- * Returns an immutable map containing keys and values extracted from the given entries.
+ * Returns an unmodifiable map containing keys and values extracted from the given entries.
* The entries themselves are not stored in the map.
- * See Immutable Map Static Factory Methods for details.
+ * See Unmodifiable Maps for details.
*
* @apiNote
* It is convenient to create the map entries using the {@link Map#entry Map.entry()} method.
@@ -1602,15 +1603,17 @@
@SafeVarargs
@SuppressWarnings("varargs")
static Map ofEntries(Entry extends K, ? extends V>... entries) {
- if (entries.length == 0) { // implicit null check of entries
+ if (entries.length == 0) { // implicit null check of entries array
return ImmutableCollections.Map0.instance();
} else if (entries.length == 1) {
+ // implicit null check of the array slot
return new ImmutableCollections.Map1<>(entries[0].getKey(),
entries[0].getValue());
} else {
Object[] kva = new Object[entries.length << 1];
int a = 0;
for (Entry extends K, ? extends V> entry : entries) {
+ // implicit null checks of each array slot
kva[a++] = entry.getKey();
kva[a++] = entry.getValue();
}
@@ -1619,7 +1622,7 @@
}
/**
- * Returns an immutable {@link Entry} containing the given key and value.
+ * Returns an unmodifiable {@link Entry} containing the given key and value.
* These entries are suitable for populating {@code Map} instances using the
* {@link Map#ofEntries Map.ofEntries()} method.
* The {@code Entry} instances created by this method have the following characteristics:
@@ -1627,7 +1630,7 @@
*
* - They disallow {@code null} keys and values. Attempts to create them using a {@code null}
* key or value result in {@code NullPointerException}.
- *
- They are immutable. Calls to {@link Entry#setValue Entry.setValue()}
+ *
- They are unmodifiable. Calls to {@link Entry#setValue Entry.setValue()}
* on a returned {@code Entry} result in {@code UnsupportedOperationException}.
*
- They are not serializable.
*
- They are value-based.
@@ -1655,4 +1658,30 @@
// KeyValueHolder checks for nulls
return new KeyValueHolder<>(k, v);
}
+
+ /**
+ * Returns an unmodifiable Map containing the entries
+ * of the given Map. The given Map must not be null, and it must not contain any
+ * null keys or values. If the given Map is subsequently modified, the returned
+ * Map will not reflect such modifications.
+ *
+ * @implNote
+ * If the given Map is an unmodifiable Map,
+ * calling copyOf will generally not create a copy.
+ *
+ * @param
the {@code Map}'s key type
+ * @param the {@code Map}'s value type
+ * @param map a {@code Map} from which entries are drawn, must be non-null
+ * @return a {@code Map} containing the entries of the given {@code Map}
+ * @throws NullPointerException if map is null, or if it contains any null keys or values
+ * @since 10
+ */
+ @SuppressWarnings({"rawtypes","unchecked"})
+ static Map copyOf(Map extends K, ? extends V> map) {
+ if (map instanceof ImmutableCollections.AbstractImmutableMap) {
+ return (Map)map;
+ } else {
+ return (Map)Map.ofEntries(map.entrySet().toArray(new Entry[0]));
+ }
+ }
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/util/Set.java
--- a/src/java.base/share/classes/java/util/Set.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/util/Set.java Tue Dec 05 10:28:45 2017 +0000
@@ -63,15 +63,16 @@
* Such exceptions are marked as "optional" in the specification for this
* interface.
*
- * Immutable Set Static Factory Methods
- * The {@link Set#of(Object...) Set.of()} static factory methods
- * provide a convenient way to create immutable sets. The {@code Set}
+ *
Unmodifiable Sets
+ * The {@link Set#of(Object...) Set.of} and
+ * {@link Set#copyOf Set.copyOf} static factory methods
+ * provide a convenient way to create unmodifiable sets. The {@code Set}
* instances created by these methods have the following characteristics:
*
*
- * - They are structurally immutable. Elements cannot be added or
- * removed. Calling any mutator method will always cause
- * {@code UnsupportedOperationException} to be thrown.
+ *
- They are unmodifiable. Elements cannot
+ * be added or removed. Calling any mutator method on the Set
+ * will always cause {@code UnsupportedOperationException} to be thrown.
* However, if the contained elements are themselves mutable, this may cause the
* Set to behave inconsistently or its contents to appear to change.
*
- They disallow {@code null} elements. Attempts to create them with
@@ -439,8 +440,8 @@
}
/**
- * Returns an immutable set containing zero elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing zero elements.
+ * See Unmodifiable Sets for details.
*
* @param
the {@code Set}'s element type
* @return an empty {@code Set}
@@ -452,8 +453,8 @@
}
/**
- * Returns an immutable set containing one element.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing one element.
+ * See Unmodifiable Sets for details.
*
* @param the {@code Set}'s element type
* @param e1 the single element
@@ -467,8 +468,8 @@
}
/**
- * Returns an immutable set containing two elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing two elements.
+ * See Unmodifiable Sets for details.
*
* @param the {@code Set}'s element type
* @param e1 the first element
@@ -484,8 +485,8 @@
}
/**
- * Returns an immutable set containing three elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing three elements.
+ * See Unmodifiable Sets for details.
*
* @param the {@code Set}'s element type
* @param e1 the first element
@@ -502,8 +503,8 @@
}
/**
- * Returns an immutable set containing four elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing four elements.
+ * See Unmodifiable Sets for details.
*
* @param the {@code Set}'s element type
* @param e1 the first element
@@ -521,8 +522,8 @@
}
/**
- * Returns an immutable set containing five elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing five elements.
+ * See Unmodifiable Sets for details.
*
* @param the {@code Set}'s element type
* @param e1 the first element
@@ -541,8 +542,8 @@
}
/**
- * Returns an immutable set containing six elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing six elements.
+ * See Unmodifiable Sets for details.
*
* @param the {@code Set}'s element type
* @param e1 the first element
@@ -563,8 +564,8 @@
}
/**
- * Returns an immutable set containing seven elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing seven elements.
+ * See Unmodifiable Sets for details.
*
* @param the {@code Set}'s element type
* @param e1 the first element
@@ -586,8 +587,8 @@
}
/**
- * Returns an immutable set containing eight elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing eight elements.
+ * See Unmodifiable Sets for details.
*
* @param the {@code Set}'s element type
* @param e1 the first element
@@ -610,8 +611,8 @@
}
/**
- * Returns an immutable set containing nine elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing nine elements.
+ * See Unmodifiable Sets for details.
*
* @param the {@code Set}'s element type
* @param e1 the first element
@@ -635,8 +636,8 @@
}
/**
- * Returns an immutable set containing ten elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing ten elements.
+ * See Unmodifiable Sets for details.
*
* @param the {@code Set}'s element type
* @param e1 the first element
@@ -661,8 +662,8 @@
}
/**
- * Returns an immutable set containing an arbitrary number of elements.
- * See Immutable Set Static Factory Methods for details.
+ * Returns an unmodifiable set containing an arbitrary number of elements.
+ * See Unmodifiable Sets for details.
*
* @apiNote
* This method also accepts a single array as an argument. The element type of
@@ -700,4 +701,30 @@
return new ImmutableCollections.SetN<>(elements);
}
}
+
+ /**
+ * Returns an unmodifiable Set containing the elements
+ * of the given Collection. The given Collection must not be null, and it must not
+ * contain any null elements. If the given Collection contains duplicate elements,
+ * an arbitrary element of the duplicates is preserved. If the given Collection is
+ * subsequently modified, the returned Set will not reflect such modifications.
+ *
+ * @implNote
+ * If the given Collection is an unmodifiable Set,
+ * calling copyOf will generally not create a copy.
+ *
+ * @param the {@code Set}'s element type
+ * @param coll a {@code Collection} from which elements are drawn, must be non-null
+ * @return a {@code Set} containing the elements of the given {@code Collection}
+ * @throws NullPointerException if coll is null, or if it contains any nulls
+ * @since 10
+ */
+ @SuppressWarnings("unchecked")
+ static Set copyOf(Collection extends E> coll) {
+ if (coll instanceof ImmutableCollections.AbstractImmutableSet) {
+ return (Set)coll;
+ } else {
+ return (Set)Set.of(new HashSet<>(coll).toArray());
+ }
+ }
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java
--- a/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java Tue Dec 05 10:28:45 2017 +0000
@@ -38,11 +38,15 @@
import java.lang.invoke.MethodHandles;
import java.lang.invoke.VarHandle;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import java.util.concurrent.locks.LockSupport;
import java.util.function.BiConsumer;
import java.util.function.BiPredicate;
import java.util.function.Consumer;
+import static java.util.concurrent.Flow.Publisher;
+import static java.util.concurrent.Flow.Subscriber;
+import static java.util.concurrent.Flow.Subscription;
/**
* A {@link Flow.Publisher} that asynchronously issues submitted
@@ -74,6 +78,14 @@
* Flow#defaultBufferSize()} may provide a useful starting point for
* choosing a capacity based on expected rates, resources, and usages.
*
+ * A single SubmissionPublisher may be shared among multiple
+ * sources. Actions in a source thread prior to publishing an item or
+ * issuing a signal
+ * happen-before actions subsequent to the corresponding
+ * access by each subscriber. But reported estimates of lag and demand
+ * are designed for use in monitoring, not for synchronization
+ * control, and may reflect stale or inaccurate views of progress.
+ *
*
Publication methods support different policies about what to do
* when buffers are saturated. Method {@link #submit(Object) submit}
* blocks until resources are available. This is simplest, but least
@@ -158,19 +170,27 @@
* @author Doug Lea
* @since 9
*/
-public class SubmissionPublisher implements Flow.Publisher,
+public class SubmissionPublisher implements Publisher,
AutoCloseable {
/*
* Most mechanics are handled by BufferedSubscription. This class
* mainly tracks subscribers and ensures sequentiality, by using
- * built-in synchronization locks across public methods. (Using
+ * built-in synchronization locks across public methods. Using
* built-in locks works well in the most typical case in which
- * only one thread submits items).
+ * only one thread submits items. We extend this idea in
+ * submission methods by detecting single-ownership to reduce
+ * producer-consumer synchronization strength.
*/
/** The largest possible power of two array size. */
static final int BUFFER_CAPACITY_LIMIT = 1 << 30;
+ /**
+ * Initial buffer capacity used when maxBufferCapacity is
+ * greater. Must be a power of two.
+ */
+ static final int INITIAL_CAPACITY = 32;
+
/** Round capacity to power of 2, at most limit. */
static final int roundCapacity(int cap) {
int n = cap - 1;
@@ -206,7 +226,7 @@
* but we expect that subscribing is much less common than
* publishing. Unsubscribing occurs only during traversal loops,
* when BufferedSubscription methods return negative values
- * signifying that they have been disabled. To reduce
+ * signifying that they have been closed. To reduce
* head-of-line blocking, submit and offer methods first call
* BufferedSubscription.offer on each subscriber, and place
* saturated ones in retries list (using nextRetry field), and
@@ -216,12 +236,16 @@
/** Run status, updated only within locks */
volatile boolean closed;
+ /** Set true on first call to subscribe, to initialize possible owner */
+ boolean subscribed;
+ /** The first caller thread to subscribe, or null if thread ever changed */
+ Thread owner;
/** If non-null, the exception in closeExceptionally */
volatile Throwable closedException;
// Parameters for constructing BufferedSubscriptions
final Executor executor;
- final BiConsumer super Flow.Subscriber super T>, ? super Throwable> onNextHandler;
+ final BiConsumer super Subscriber super T>, ? super Throwable> onNextHandler;
final int maxBufferCapacity;
/**
@@ -245,7 +269,7 @@
* positive
*/
public SubmissionPublisher(Executor executor, int maxBufferCapacity,
- BiConsumer super Flow.Subscriber super T>, ? super Throwable> handler) {
+ BiConsumer super Subscriber super T>, ? super Throwable> handler) {
if (executor == null)
throw new NullPointerException();
if (maxBufferCapacity <= 0)
@@ -311,12 +335,19 @@
* @param subscriber the subscriber
* @throws NullPointerException if subscriber is null
*/
- public void subscribe(Flow.Subscriber super T> subscriber) {
+ public void subscribe(Subscriber super T> subscriber) {
if (subscriber == null) throw new NullPointerException();
+ int max = maxBufferCapacity; // allocate initial array
+ Object[] array = new Object[max < INITIAL_CAPACITY ?
+ max : INITIAL_CAPACITY];
BufferedSubscription subscription =
- new BufferedSubscription(subscriber, executor,
- onNextHandler, maxBufferCapacity);
+ new BufferedSubscription(subscriber, executor, onNextHandler,
+ array, max);
synchronized (this) {
+ if (!subscribed) {
+ subscribed = true;
+ owner = Thread.currentThread();
+ }
for (BufferedSubscription b = clients, pred = null;;) {
if (b == null) {
Throwable ex;
@@ -332,7 +363,7 @@
break;
}
BufferedSubscription next = b.next;
- if (b.isDisabled()) { // remove
+ if (b.isClosed()) { // remove
b.next = null; // detach
if (pred == null)
clients = next;
@@ -351,6 +382,107 @@
}
/**
+ * Common implementation for all three forms of submit and offer.
+ * Acts as submit if nanos == Long.MAX_VALUE, else offer.
+ */
+ private int doOffer(T item, long nanos,
+ BiPredicate, ? super T> onDrop) {
+ if (item == null) throw new NullPointerException();
+ int lag = 0;
+ boolean complete, unowned;
+ synchronized (this) {
+ Thread t = Thread.currentThread(), o;
+ BufferedSubscription b = clients;
+ if ((unowned = ((o = owner) != t)) && o != null)
+ owner = null; // disable bias
+ if (b == null)
+ complete = closed;
+ else {
+ complete = false;
+ boolean cleanMe = false;
+ BufferedSubscription retries = null, rtail = null, next;
+ do {
+ next = b.next;
+ int stat = b.offer(item, unowned);
+ if (stat == 0) { // saturated; add to retry list
+ b.nextRetry = null; // avoid garbage on exceptions
+ if (rtail == null)
+ retries = b;
+ else
+ rtail.nextRetry = b;
+ rtail = b;
+ }
+ else if (stat < 0) // closed
+ cleanMe = true; // remove later
+ else if (stat > lag)
+ lag = stat;
+ } while ((b = next) != null);
+
+ if (retries != null || cleanMe)
+ lag = retryOffer(item, nanos, onDrop, retries, lag, cleanMe);
+ }
+ }
+ if (complete)
+ throw new IllegalStateException("Closed");
+ else
+ return lag;
+ }
+
+ /**
+ * Helps, (timed) waits for, and/or drops buffers on list; returns
+ * lag or negative drops (for use in offer).
+ */
+ private int retryOffer(T item, long nanos,
+ BiPredicate, ? super T> onDrop,
+ BufferedSubscription retries, int lag,
+ boolean cleanMe) {
+ for (BufferedSubscription r = retries; r != null;) {
+ BufferedSubscription nextRetry = r.nextRetry;
+ r.nextRetry = null;
+ if (nanos > 0L)
+ r.awaitSpace(nanos);
+ int stat = r.retryOffer(item);
+ if (stat == 0 && onDrop != null && onDrop.test(r.subscriber, item))
+ stat = r.retryOffer(item);
+ if (stat == 0)
+ lag = (lag >= 0) ? -1 : lag - 1;
+ else if (stat < 0)
+ cleanMe = true;
+ else if (lag >= 0 && stat > lag)
+ lag = stat;
+ r = nextRetry;
+ }
+ if (cleanMe)
+ cleanAndCount();
+ return lag;
+ }
+
+ /**
+ * Returns current list count after removing closed subscribers.
+ * Call only while holding lock. Used mainly by retryOffer for
+ * cleanup.
+ */
+ private int cleanAndCount() {
+ int count = 0;
+ BufferedSubscription pred = null, next;
+ for (BufferedSubscription b = clients; b != null; b = next) {
+ next = b.next;
+ if (b.isClosed()) {
+ b.next = null;
+ if (pred == null)
+ clients = next;
+ else
+ pred.next = next;
+ }
+ else {
+ pred = b;
+ ++count;
+ }
+ }
+ return count;
+ }
+
+ /**
* Publishes the given item to each current subscriber by
* asynchronously invoking its {@link Flow.Subscriber#onNext(Object)
* onNext} method, blocking uninterruptibly while resources for any
@@ -373,55 +505,7 @@
* @throws RejectedExecutionException if thrown by Executor
*/
public int submit(T item) {
- if (item == null) throw new NullPointerException();
- int lag = 0;
- boolean complete;
- synchronized (this) {
- complete = closed;
- BufferedSubscription b = clients;
- if (!complete) {
- BufferedSubscription pred = null, r = null, rtail = null;
- while (b != null) {
- BufferedSubscription next = b.next;
- int stat = b.offer(item);
- if (stat < 0) { // disabled
- b.next = null;
- if (pred == null)
- clients = next;
- else
- pred.next = next;
- }
- else {
- if (stat > lag)
- lag = stat;
- else if (stat == 0) { // place on retry list
- b.nextRetry = null;
- if (rtail == null)
- r = b;
- else
- rtail.nextRetry = b;
- rtail = b;
- }
- pred = b;
- }
- b = next;
- }
- while (r != null) {
- BufferedSubscription nextRetry = r.nextRetry;
- r.nextRetry = null;
- int stat = r.submit(item);
- if (stat > lag)
- lag = stat;
- else if (stat < 0 && clients == r)
- clients = r.next; // postpone internal unsubscribes
- r = nextRetry;
- }
- }
- }
- if (complete)
- throw new IllegalStateException("Closed");
- else
- return lag;
+ return doOffer(item, Long.MAX_VALUE, null);
}
/**
@@ -462,8 +546,8 @@
* @throws RejectedExecutionException if thrown by Executor
*/
public int offer(T item,
- BiPredicate, ? super T> onDrop) {
- return doOffer(0L, item, onDrop);
+ BiPredicate, ? super T> onDrop) {
+ return doOffer(item, 0L, onDrop);
}
/**
@@ -510,71 +594,11 @@
* @throws RejectedExecutionException if thrown by Executor
*/
public int offer(T item, long timeout, TimeUnit unit,
- BiPredicate, ? super T> onDrop) {
- return doOffer(unit.toNanos(timeout), item, onDrop);
- }
-
- /** Common implementation for both forms of offer */
- final int doOffer(long nanos, T item,
- BiPredicate, ? super T> onDrop) {
- if (item == null) throw new NullPointerException();
- int lag = 0, drops = 0;
- boolean complete;
- synchronized (this) {
- complete = closed;
- BufferedSubscription b = clients;
- if (!complete) {
- BufferedSubscription pred = null, r = null, rtail = null;
- while (b != null) {
- BufferedSubscription next = b.next;
- int stat = b.offer(item);
- if (stat < 0) {
- b.next = null;
- if (pred == null)
- clients = next;
- else
- pred.next = next;
- }
- else {
- if (stat > lag)
- lag = stat;
- else if (stat == 0) {
- b.nextRetry = null;
- if (rtail == null)
- r = b;
- else
- rtail.nextRetry = b;
- rtail = b;
- }
- else if (stat > lag)
- lag = stat;
- pred = b;
- }
- b = next;
- }
- while (r != null) {
- BufferedSubscription nextRetry = r.nextRetry;
- r.nextRetry = null;
- int stat = (nanos > 0L)
- ? r.timedOffer(item, nanos)
- : r.offer(item);
- if (stat == 0 && onDrop != null &&
- onDrop.test(r.subscriber, item))
- stat = r.offer(item);
- if (stat == 0)
- ++drops;
- else if (stat > lag)
- lag = stat;
- else if (stat < 0 && clients == r)
- clients = r.next;
- r = nextRetry;
- }
- }
- }
- if (complete)
- throw new IllegalStateException("Closed");
- else
- return (drops > 0) ? -drops : lag;
+ BiPredicate, ? super T> onDrop) {
+ long nanos = unit.toNanos(timeout);
+ // distinguishes from untimed (only wrt interrupt policy)
+ if (nanos == Long.MAX_VALUE) --nanos;
+ return doOffer(item, nanos, onDrop);
}
/**
@@ -591,6 +615,7 @@
// no need to re-check closed here
b = clients;
clients = null;
+ owner = null;
closed = true;
}
while (b != null) {
@@ -621,8 +646,9 @@
synchronized (this) {
b = clients;
if (!closed) { // don't clobber racing close
+ closedException = error;
clients = null;
- closedException = error;
+ owner = null;
closed = true;
}
}
@@ -662,18 +688,16 @@
*/
public boolean hasSubscribers() {
boolean nonEmpty = false;
- if (!closed) {
- synchronized (this) {
- for (BufferedSubscription b = clients; b != null;) {
- BufferedSubscription next = b.next;
- if (b.isDisabled()) {
- b.next = null;
- b = clients = next;
- }
- else {
- nonEmpty = true;
- break;
- }
+ synchronized (this) {
+ for (BufferedSubscription b = clients; b != null;) {
+ BufferedSubscription next = b.next;
+ if (b.isClosed()) {
+ b.next = null;
+ b = clients = next;
+ }
+ else {
+ nonEmpty = true;
+ break;
}
}
}
@@ -686,27 +710,9 @@
* @return the number of current subscribers
*/
public int getNumberOfSubscribers() {
- int count = 0;
- if (!closed) {
- synchronized (this) {
- BufferedSubscription pred = null, next;
- for (BufferedSubscription b = clients; b != null; b = next) {
- next = b.next;
- if (b.isDisabled()) {
- b.next = null;
- if (pred == null)
- clients = next;
- else
- pred.next = next;
- }
- else {
- pred = b;
- ++count;
- }
- }
- }
+ synchronized (this) {
+ return cleanAndCount();
}
- return count;
}
/**
@@ -734,13 +740,13 @@
*
* @return list of current subscribers
*/
- public List> getSubscribers() {
- ArrayList> subs = new ArrayList<>();
+ public List> getSubscribers() {
+ ArrayList> subs = new ArrayList<>();
synchronized (this) {
BufferedSubscription pred = null, next;
for (BufferedSubscription b = clients; b != null; b = next) {
next = b.next;
- if (b.isDisabled()) {
+ if (b.isClosed()) {
b.next = null;
if (pred == null)
clients = next;
@@ -761,14 +767,14 @@
* @return true if currently subscribed
* @throws NullPointerException if subscriber is null
*/
- public boolean isSubscribed(Flow.Subscriber super T> subscriber) {
+ public boolean isSubscribed(Subscriber super T> subscriber) {
if (subscriber == null) throw new NullPointerException();
if (!closed) {
synchronized (this) {
BufferedSubscription pred = null, next;
for (BufferedSubscription b = clients; b != null; b = next) {
next = b.next;
- if (b.isDisabled()) {
+ if (b.isClosed()) {
b.next = null;
if (pred == null)
clients = next;
@@ -872,16 +878,15 @@
}
/** Subscriber for method consume */
- private static final class ConsumerSubscriber
- implements Flow.Subscriber {
+ static final class ConsumerSubscriber implements Subscriber {
final CompletableFuture status;
final Consumer super T> consumer;
- Flow.Subscription subscription;
+ Subscription subscription;
ConsumerSubscriber(CompletableFuture status,
Consumer super T> consumer) {
this.status = status; this.consumer = consumer;
}
- public final void onSubscribe(Flow.Subscription subscription) {
+ public final void onSubscribe(Subscription subscription) {
this.subscription = subscription;
status.whenComplete((v, e) -> subscription.cancel());
if (!status.isDone())
@@ -925,634 +930,534 @@
}
/**
- * A bounded (ring) buffer with integrated control to start a
- * consumer task whenever items are available. The buffer
- * algorithm is similar to one used inside ForkJoinPool (see its
- * internal documentation for details) specialized for the case of
- * at most one concurrent producer and consumer, and power of two
- * buffer sizes. This allows methods to operate without locks even
- * while supporting resizing, blocking, task-triggering, and
- * garbage-free buffers (nulling out elements when consumed),
- * although supporting these does impose a bit of overhead
- * compared to plain fixed-size ring buffers.
- *
- * The publisher guarantees a single producer via its lock. We
- * ensure in this class that there is at most one consumer. The
- * request and cancel methods must be fully thread-safe but are
- * coded to exploit the most common case in which they are only
- * called by consumers (usually within onNext).
+ * A resizable array-based ring buffer with integrated control to
+ * start a consumer task whenever items are available. The buffer
+ * algorithm is specialized for the case of at most one concurrent
+ * producer and consumer, and power of two buffer sizes. It relies
+ * primarily on atomic operations (CAS or getAndSet) at the next
+ * array slot to put or take an element, at the "tail" and "head"
+ * indices written only by the producer and consumer respectively.
*
- * Execution control is managed using the ACTIVE ctl bit. We
- * ensure that a task is active when consumable items (and
- * usually, SUBSCRIBE, ERROR or COMPLETE signals) are present and
- * there is demand (unfilled requests). This is complicated on
- * the creation side by the possibility of exceptions when trying
- * to execute tasks. These eventually force DISABLED state, but
- * sometimes not directly. On the task side, termination (clearing
- * ACTIVE) that would otherwise race with producers or request()
- * calls uses the CONSUME keep-alive bit to force a recheck.
+ * We ensure internally that there is at most one active consumer
+ * task at any given time. The publisher guarantees a single
+ * producer via its lock. Sync among producers and consumers
+ * relies on volatile fields "ctl", "demand", and "waiting" (along
+ * with element access). Other variables are accessed in plain
+ * mode, relying on outer ordering and exclusion, and/or enclosing
+ * them within other volatile accesses. Some atomic operations are
+ * avoided by tracking single threaded ownership by producers (in
+ * the style of biased locking).
*
- * The ctl field also manages run state. When DISABLED, no further
- * updates are possible. Disabling may be preceded by setting
- * ERROR or COMPLETE (or both -- ERROR has precedence), in which
- * case the associated Subscriber methods are invoked, possibly
- * synchronously if there is no active consumer task (including
- * cases where execute() failed). The cancel() method is supported
- * by treating as ERROR but suppressing onError signal.
+ * Execution control and protocol state are managed using field
+ * "ctl". Methods to subscribe, close, request, and cancel set
+ * ctl bits (mostly using atomic boolean method getAndBitwiseOr),
+ * and ensure that a task is running. (The corresponding consumer
+ * side actions are in method consume.) To avoid starting a new
+ * task on each action, ctl also includes a keep-alive bit
+ * (ACTIVE) that is refreshed if needed on producer actions.
+ * (Maintaining agreement about keep-alives requires most atomic
+ * updates to be full SC/Volatile strength, which is still much
+ * cheaper than using one task per item.) Error signals
+ * additionally null out items and/or fields to reduce termination
+ * latency. The cancel() method is supported by treating as ERROR
+ * but suppressing onError signal.
*
* Support for blocking also exploits the fact that there is only
* one possible waiter. ManagedBlocker-compatible control fields
* are placed in this class itself rather than in wait-nodes.
- * Blocking control relies on the "waiter" field. Producers set
- * the field before trying to block, but must then recheck (via
- * offer) before parking. Signalling then just unparks and clears
- * waiter field. If the producer and/or consumer are using a
- * ForkJoinPool, the producer attempts to help run consumer tasks
- * via ForkJoinPool.helpAsyncBlocker before blocking.
+ * Blocking control relies on the "waiting" and "waiter"
+ * fields. Producers set them before trying to block. Signalling
+ * unparks and clears fields. If the producer and/or consumer are
+ * using a ForkJoinPool, the producer attempts to help run
+ * consumer tasks via ForkJoinPool.helpAsyncBlocker before
+ * blocking.
*
- * This class uses @Contended and heuristic field declaration
- * ordering to reduce false-sharing-based memory contention among
- * instances of BufferedSubscription, but it does not currently
- * attempt to avoid memory contention among buffers. This field
- * and element packing can hurt performance especially when each
- * publisher has only one client operating at a high rate.
- * Addressing this may require allocating substantially more space
- * than users expect.
+ * Usages of this class may encounter any of several forms of
+ * memory contention. We try to ameliorate across them without
+ * unduly impacting footprints in low-contention usages where it
+ * isn't needed. Buffer arrays start out small and grow only as
+ * needed. The class uses @Contended and heuristic field
+ * declaration ordering to reduce false-sharing memory contention
+ * across instances of BufferedSubscription (as in, multiple
+ * subscribers per publisher). We additionally segregate some
+ * fields that would otherwise nearly always encounter cache line
+ * contention among producers and consumers. To reduce contention
+ * across time (vs space), consumers only periodically update
+ * other fields (see method takeItems), at the expense of possibly
+ * staler reporting of lags and demand (bounded at 12.5% == 1/8
+ * capacity) and possibly more atomic operations.
+ *
+ * Other forms of imbalance and slowdowns can occur during startup
+ * when producer and consumer methods are compiled and/or memory
+ * is allocated at different rates. This is ameliorated by
+ * artificially subdividing some consumer methods, including
+ * isolation of all subscriber callbacks. This code also includes
+ * typical power-of-two array screening idioms to avoid compilers
+ * generating traps, along with the usual SSA-based inline
+ * assignment coding style. Also, all methods and fields have
+ * default visibility to simplify usage by callers.
*/
@SuppressWarnings("serial")
@jdk.internal.vm.annotation.Contended
- private static final class BufferedSubscription
- implements Flow.Subscription, ForkJoinPool.ManagedBlocker {
- // Order-sensitive field declarations
- long timeout; // > 0 if timed wait
- volatile long demand; // # unfilled requests
- int maxCapacity; // reduced on OOME
- int putStat; // offer result for ManagedBlocker
+ static final class BufferedSubscription
+ implements Subscription, ForkJoinPool.ManagedBlocker {
+ long timeout; // Long.MAX_VALUE if untimed wait
+ int head; // next position to take
+ int tail; // next position to put
+ final int maxCapacity; // max buffer size
volatile int ctl; // atomic run state flags
- volatile int head; // next position to take
- int tail; // next position to put
- Object[] array; // buffer: null if disabled
- Flow.Subscriber super T> subscriber; // null if disabled
- Executor executor; // null if disabled
- BiConsumer super Flow.Subscriber super T>, ? super Throwable> onNextHandler;
- volatile Throwable pendingError; // holds until onError issued
- volatile Thread waiter; // blocked producer thread
- T putItem; // for offer within ManagedBlocker
+ Object[] array; // buffer
+ final Subscriber super T> subscriber;
+ final BiConsumer super Subscriber super T>, ? super Throwable> onNextHandler;
+ Executor executor; // null on error
+ Thread waiter; // blocked producer thread
+ Throwable pendingError; // holds until onError issued
BufferedSubscription next; // used only by publisher
BufferedSubscription nextRetry; // used only by publisher
- // ctl values
- static final int ACTIVE = 0x01; // consumer task active
- static final int CONSUME = 0x02; // keep-alive for consumer task
- static final int DISABLED = 0x04; // final state
- static final int ERROR = 0x08; // signal onError then disable
- static final int SUBSCRIBE = 0x10; // signal onSubscribe
- static final int COMPLETE = 0x20; // signal onComplete when done
+ @jdk.internal.vm.annotation.Contended("c") // segregate
+ volatile long demand; // # unfilled requests
+ @jdk.internal.vm.annotation.Contended("c")
+ volatile int waiting; // nonzero if producer blocked
+
+ // ctl bit values
+ static final int CLOSED = 0x01; // if set, other bits ignored
+ static final int ACTIVE = 0x02; // keep-alive for consumer task
+ static final int REQS = 0x04; // (possibly) nonzero demand
+ static final int ERROR = 0x08; // issues onError when noticed
+ static final int COMPLETE = 0x10; // issues onComplete when done
+ static final int RUN = 0x20; // task is or will be running
+ static final int OPEN = 0x40; // true after subscribe
static final long INTERRUPTED = -1L; // timeout vs interrupt sentinel
- /**
- * Initial buffer capacity used when maxBufferCapacity is
- * greater. Must be a power of two.
- */
- static final int DEFAULT_INITIAL_CAP = 32;
-
- BufferedSubscription(Flow.Subscriber super T> subscriber,
+ BufferedSubscription(Subscriber super T> subscriber,
Executor executor,
- BiConsumer super Flow.Subscriber super T>,
+ BiConsumer super Subscriber super T>,
? super Throwable> onNextHandler,
+ Object[] array,
int maxBufferCapacity) {
this.subscriber = subscriber;
this.executor = executor;
this.onNextHandler = onNextHandler;
+ this.array = array;
this.maxCapacity = maxBufferCapacity;
- this.array = new Object[maxBufferCapacity < DEFAULT_INITIAL_CAP ?
- (maxBufferCapacity < 2 ? // at least 2 slots
- 2 : maxBufferCapacity) :
- DEFAULT_INITIAL_CAP];
+ }
+
+ // Wrappers for some VarHandle methods
+
+ final boolean weakCasCtl(int cmp, int val) {
+ return CTL.weakCompareAndSet(this, cmp, val);
}
- final boolean isDisabled() {
- return ctl == DISABLED;
+ final int getAndBitwiseOrCtl(int bits) {
+ return (int)CTL.getAndBitwiseOr(this, bits);
}
+ final long subtractDemand(int k) {
+ long n = (long)(-k);
+ return n + (long)DEMAND.getAndAdd(this, n);
+ }
+
+ final boolean casDemand(long cmp, long val) {
+ return DEMAND.compareAndSet(this, cmp, val);
+ }
+
+ // Utilities used by SubmissionPublisher
+
/**
- * Returns estimated number of buffered items, or -1 if
- * disabled.
- */
- final int estimateLag() {
- int n;
- return (ctl == DISABLED) ? -1 : ((n = tail - head) > 0) ? n : 0;
- }
-
- /**
- * Tries to add item and start consumer task if necessary.
- * @return -1 if disabled, 0 if dropped, else estimated lag
+ * Returns true if closed (consumer task may still be running).
*/
- final int offer(T item) {
- int h = head, t = tail, cap, size, stat;
- Object[] a = array;
- if (a != null && (cap = a.length) > 0 && cap >= (size = t + 1 - h)) {
- a[(cap - 1) & t] = item; // relaxed writes OK
- tail = t + 1;
- stat = size;
- }
- else
- stat = growAndAdd(a, item);
- return (stat > 0 &&
- (ctl & (ACTIVE | CONSUME)) != (ACTIVE | CONSUME)) ?
- startOnOffer(stat) : stat;
+ final boolean isClosed() {
+ return (ctl & CLOSED) != 0;
}
/**
- * Tries to create or expand buffer, then adds item if possible.
+ * Returns estimated number of buffered items, or negative if
+ * closed.
+ */
+ final int estimateLag() {
+ int c = ctl, n = tail - head;
+ return ((c & CLOSED) != 0) ? -1 : (n < 0) ? 0 : n;
+ }
+
+ // Methods for submitting items
+
+ /**
+ * Tries to add item and start consumer task if necessary.
+ * @return negative if closed, 0 if saturated, else estimated lag
*/
- private int growAndAdd(Object[] a, T item) {
- boolean alloc;
- int cap, stat;
- if ((ctl & (ERROR | DISABLED)) != 0) {
- cap = 0;
- stat = -1;
- alloc = false;
- }
- else if (a == null || (cap = a.length) <= 0) {
- cap = 0;
- stat = 1;
- alloc = true;
- }
- else {
- VarHandle.fullFence(); // recheck
- int h = head, t = tail, size = t + 1 - h;
- if (cap >= size) {
- a[(cap - 1) & t] = item;
+ final int offer(T item, boolean unowned) {
+ Object[] a;
+ int stat = 0, cap = ((a = array) == null) ? 0 : a.length;
+ int t = tail, i = t & (cap - 1), n = t + 1 - head;
+ if (cap > 0) {
+ boolean added;
+ if (n >= cap && cap < maxCapacity) // resize
+ added = growAndoffer(item, a, t);
+ else if (n >= cap || unowned) // need volatile CAS
+ added = QA.compareAndSet(a, i, null, item);
+ else { // can use release mode
+ QA.setRelease(a, i, item);
+ added = true;
+ }
+ if (added) {
tail = t + 1;
- stat = size;
- alloc = false;
- }
- else if (cap >= maxCapacity) {
- stat = 0; // cannot grow
- alloc = false;
- }
- else {
- stat = cap + 1;
- alloc = true;
+ stat = n;
}
}
- if (alloc) {
- int newCap = (cap > 0) ? cap << 1 : 1;
- if (newCap <= cap)
- stat = 0;
- else {
- Object[] newArray = null;
- try {
- newArray = new Object[newCap];
- } catch (Throwable ex) { // try to cope with OOME
- }
- if (newArray == null) {
- if (cap > 0)
- maxCapacity = cap; // avoid continuous failure
- stat = 0;
- }
- else {
- array = newArray;
- int t = tail;
- int newMask = newCap - 1;
- if (a != null && cap > 0) {
- int mask = cap - 1;
- for (int j = head; j != t; ++j) {
- int k = j & mask;
- Object x = QA.getAcquire(a, k);
- if (x != null && // races with consumer
- QA.compareAndSet(a, k, x, null))
- newArray[j & newMask] = x;
- }
- }
- newArray[t & newMask] = item;
- tail = t + 1;
- }
+ return startOnOffer(stat);
+ }
+
+ /**
+ * Tries to expand buffer and add item, returning true on
+ * success. Currently fails only if out of memory.
+ */
+ final boolean growAndoffer(T item, Object[] a, int t) {
+ int cap = 0, newCap = 0;
+ Object[] newArray = null;
+ if (a != null && (cap = a.length) > 0 && (newCap = cap << 1) > 0) {
+ try {
+ newArray = new Object[newCap];
+ } catch (OutOfMemoryError ex) {
}
}
+ if (newArray == null)
+ return false;
+ else { // take and move items
+ int newMask = newCap - 1;
+ newArray[t-- & newMask] = item;
+ for (int mask = cap - 1, k = mask; k >= 0; --k) {
+ Object x = QA.getAndSet(a, t & mask, null);
+ if (x == null)
+ break; // already consumed
+ else
+ newArray[t-- & newMask] = x;
+ }
+ array = newArray;
+ VarHandle.releaseFence(); // release array and slots
+ return true;
+ }
+ }
+
+ /**
+ * Version of offer for retries (no resize or bias)
+ */
+ final int retryOffer(T item) {
+ Object[] a;
+ int stat = 0, t = tail, h = head, cap;
+ if ((a = array) != null && (cap = a.length) > 0 &&
+ QA.compareAndSet(a, (cap - 1) & t, null, item))
+ stat = (tail = t + 1) - h;
+ return startOnOffer(stat);
+ }
+
+ /**
+ * Tries to start consumer task after offer.
+ * @return negative if now closed, else argument
+ */
+ final int startOnOffer(int stat) {
+ int c; // start or keep alive if requests exist and not active
+ if (((c = ctl) & (REQS | ACTIVE)) == REQS &&
+ ((c = getAndBitwiseOrCtl(RUN | ACTIVE)) & (RUN | CLOSED)) == 0)
+ tryStart();
+ else if ((c & CLOSED) != 0)
+ stat = -1;
return stat;
}
/**
- * Spins/helps/blocks while offer returns 0. Called only if
- * initial offer return 0.
- */
- final int submit(T item) {
- int stat;
- if ((stat = offer(item)) == 0) {
- putItem = item;
- timeout = 0L;
- putStat = 0;
- ForkJoinPool.helpAsyncBlocker(executor, this);
- if ((stat = putStat) == 0) {
- try {
- ForkJoinPool.managedBlock(this);
- } catch (InterruptedException ie) {
- timeout = INTERRUPTED;
- }
- stat = putStat;
- }
- if (timeout < 0L)
- Thread.currentThread().interrupt();
- }
- return stat;
- }
-
- /**
- * Timeout version; similar to submit.
- */
- final int timedOffer(T item, long nanos) {
- int stat;
- if ((stat = offer(item)) == 0 && (timeout = nanos) > 0L) {
- putItem = item;
- putStat = 0;
- ForkJoinPool.helpAsyncBlocker(executor, this);
- if ((stat = putStat) == 0) {
- try {
- ForkJoinPool.managedBlock(this);
- } catch (InterruptedException ie) {
- timeout = INTERRUPTED;
- }
- stat = putStat;
- }
- if (timeout < 0L)
- Thread.currentThread().interrupt();
- }
- return stat;
- }
-
- /**
- * Tries to start consumer task after offer.
- * @return -1 if now disabled, else argument
+ * Tries to start consumer task. Sets error state on failure.
*/
- private int startOnOffer(int stat) {
- for (;;) {
- Executor e; int c;
- if ((c = ctl) == DISABLED || (e = executor) == null) {
- stat = -1;
- break;
- }
- else if ((c & ACTIVE) != 0) { // ensure keep-alive
- if ((c & CONSUME) != 0 ||
- CTL.compareAndSet(this, c, c | CONSUME))
- break;
- }
- else if (demand == 0L || tail == head)
- break;
- else if (CTL.compareAndSet(this, c, c | (ACTIVE | CONSUME))) {
- try {
- e.execute(new ConsumerTask(this));
- break;
- } catch (RuntimeException | Error ex) { // back out
- do {} while (((c = ctl) & DISABLED) == 0 &&
- (c & ACTIVE) != 0 &&
- !CTL.weakCompareAndSet
- (this, c, c & ~ACTIVE));
- throw ex;
- }
- }
- }
- return stat;
- }
-
- private void signalWaiter(Thread w) {
- waiter = null;
- LockSupport.unpark(w); // release producer
- }
-
- /**
- * Nulls out most fields, mainly to avoid garbage retention
- * until publisher unsubscribes, but also to help cleanly stop
- * upon error by nulling required components.
- */
- private void detach() {
- Thread w = waiter;
- executor = null;
- subscriber = null;
- pendingError = null;
- signalWaiter(w);
- }
-
- /**
- * Issues error signal, asynchronously if a task is running,
- * else synchronously.
- */
- final void onError(Throwable ex) {
- for (int c;;) {
- if (((c = ctl) & (ERROR | DISABLED)) != 0)
- break;
- else if ((c & ACTIVE) != 0) {
- pendingError = ex;
- if (CTL.compareAndSet(this, c, c | ERROR))
- break; // cause consumer task to exit
- }
- else if (CTL.compareAndSet(this, c, DISABLED)) {
- Flow.Subscriber super T> s = subscriber;
- if (s != null && ex != null) {
- try {
- s.onError(ex);
- } catch (Throwable ignore) {
- }
- }
- detach();
- break;
- }
+ final void tryStart() {
+ try {
+ Executor e;
+ ConsumerTask task = new ConsumerTask(this);
+ if ((e = executor) != null) // skip if disabled on error
+ e.execute(task);
+ } catch (RuntimeException | Error ex) {
+ getAndBitwiseOrCtl(ERROR | CLOSED);
+ throw ex;
}
}
+ // Signals to consumer tasks
+
/**
- * Tries to start consumer task upon a signal or request;
- * disables on failure.
+ * Sets the given control bits, starting task if not running or closed.
+ * @param bits state bits, assumed to include RUN but not CLOSED
*/
- private void startOrDisable() {
- Executor e;
- if ((e = executor) != null) { // skip if already disabled
- try {
- e.execute(new ConsumerTask(this));
- } catch (Throwable ex) { // back out and force signal
- for (int c;;) {
- if ((c = ctl) == DISABLED || (c & ACTIVE) == 0)
- break;
- if (CTL.compareAndSet(this, c, c & ~ACTIVE)) {
- onError(ex);
- break;
- }
- }
- }
- }
+ final void startOnSignal(int bits) {
+ if ((ctl & bits) != bits &&
+ (getAndBitwiseOrCtl(bits) & (RUN | CLOSED)) == 0)
+ tryStart();
+ }
+
+ final void onSubscribe() {
+ startOnSignal(RUN | ACTIVE);
}
final void onComplete() {
- for (int c;;) {
- if ((c = ctl) == DISABLED)
- break;
- if (CTL.compareAndSet(this, c,
- c | (ACTIVE | CONSUME | COMPLETE))) {
- if ((c & ACTIVE) == 0)
- startOrDisable();
- break;
- }
- }
+ startOnSignal(RUN | ACTIVE | COMPLETE);
}
- final void onSubscribe() {
- for (int c;;) {
- if ((c = ctl) == DISABLED)
- break;
- if (CTL.compareAndSet(this, c,
- c | (ACTIVE | CONSUME | SUBSCRIBE))) {
- if ((c & ACTIVE) == 0)
- startOrDisable();
- break;
- }
+ final void onError(Throwable ex) {
+ int c; Object[] a; // to null out buffer on async error
+ if (ex != null)
+ pendingError = ex; // races are OK
+ if (((c = getAndBitwiseOrCtl(ERROR | RUN | ACTIVE)) & CLOSED) == 0) {
+ if ((c & RUN) == 0)
+ tryStart();
+ else if ((a = array) != null)
+ Arrays.fill(a, null);
}
}
- /**
- * Causes consumer task to exit if active (without reporting
- * onError unless there is already a pending error), and
- * disables.
- */
- public void cancel() {
- for (int c;;) {
- if ((c = ctl) == DISABLED)
- break;
- else if ((c & ACTIVE) != 0) {
- if (CTL.compareAndSet(this, c,
- c | (CONSUME | ERROR)))
- break;
- }
- else if (CTL.compareAndSet(this, c, DISABLED)) {
- detach();
- break;
- }
- }
+ public final void cancel() {
+ onError(null);
}
- /**
- * Adds to demand and possibly starts task.
- */
- public void request(long n) {
+ public final void request(long n) {
if (n > 0L) {
for (;;) {
- long prev = demand, d;
- if ((d = prev + n) < prev) // saturate
- d = Long.MAX_VALUE;
- if (DEMAND.compareAndSet(this, prev, d)) {
- for (int c, h;;) {
- if ((c = ctl) == DISABLED)
- break;
- else if ((c & ACTIVE) != 0) {
- if ((c & CONSUME) != 0 ||
- CTL.compareAndSet(this, c, c | CONSUME))
- break;
- }
- else if ((h = head) != tail) {
- if (CTL.compareAndSet(this, c,
- c | (ACTIVE|CONSUME))) {
- startOrDisable();
- break;
- }
- }
- else if (head == h && tail == h)
- break; // else stale
- if (demand == 0L)
- break;
- }
+ long p = demand, d = p + n; // saturate
+ if (casDemand(p, d < p ? Long.MAX_VALUE : d))
break;
- }
}
+ startOnSignal(RUN | ACTIVE | REQS);
}
else
onError(new IllegalArgumentException(
"non-positive subscription request"));
}
- public final boolean isReleasable() { // for ManagedBlocker
- T item = putItem;
- if (item != null) {
- if ((putStat = offer(item)) == 0)
- return false;
- putItem = null;
- }
- return true;
- }
-
- public final boolean block() { // for ManagedBlocker
- T item = putItem;
- if (item != null) {
- putItem = null;
- long nanos = timeout;
- long deadline = (nanos > 0L) ? System.nanoTime() + nanos : 0L;
- while ((putStat = offer(item)) == 0) {
- if (Thread.interrupted()) {
- timeout = INTERRUPTED;
- if (nanos > 0L)
- break;
- }
- else if (nanos > 0L &&
- (nanos = deadline - System.nanoTime()) <= 0L)
- break;
- else if (waiter == null)
- waiter = Thread.currentThread();
- else {
- if (nanos > 0L)
- LockSupport.parkNanos(this, nanos);
- else
- LockSupport.park(this);
- waiter = null;
- }
- }
- }
- waiter = null;
- return true;
- }
+ // Consumer task actions
/**
- * Consumer loop, called from ConsumerTask, or indirectly
- * when helping during submit.
+ * Consumer loop, called from ConsumerTask, or indirectly when
+ * helping during submit.
*/
final void consume() {
- Flow.Subscriber super T> s;
- int h = head;
- if ((s = subscriber) != null) { // else disabled
- for (;;) {
- long d = demand;
- int c; Object[] a; int n, i; Object x; Thread w;
- if (((c = ctl) & (ERROR | SUBSCRIBE | DISABLED)) != 0) {
- if (!checkControl(s, c))
- break;
- }
- else if ((a = array) == null || h == tail ||
- (n = a.length) == 0 ||
- (x = QA.getAcquire(a, i = (n - 1) & h)) == null) {
- if (!checkEmpty(s, c))
- break;
+ Subscriber super T> s;
+ if ((s = subscriber) != null) { // hoist checks
+ subscribeOnOpen(s);
+ long d = demand;
+ for (int h = head, t = tail;;) {
+ int c, taken; boolean empty;
+ if (((c = ctl) & ERROR) != 0) {
+ closeOnError(s, null);
+ break;
}
- else if (d == 0L) {
- if (!checkDemand(c))
- break;
+ else if ((taken = takeItems(s, d, h)) > 0) {
+ head = h += taken;
+ d = subtractDemand(taken);
+ }
+ else if ((empty = (t == h)) && (c & COMPLETE) != 0) {
+ closeOnComplete(s); // end of stream
+ break;
}
- else if (((c & CONSUME) != 0 ||
- CTL.compareAndSet(this, c, c | CONSUME)) &&
- QA.compareAndSet(a, i, x, null)) {
- HEAD.setRelease(this, ++h);
- DEMAND.getAndAdd(this, -1L);
- if ((w = waiter) != null)
- signalWaiter(w);
- try {
- @SuppressWarnings("unchecked") T y = (T) x;
- s.onNext(y);
- } catch (Throwable ex) {
- handleOnNext(s, ex);
- }
+ else if ((d = demand) == 0L && (c & REQS) != 0)
+ weakCasCtl(c, c & ~REQS); // exhausted demand
+ else if (d != 0L && (c & REQS) == 0)
+ weakCasCtl(c, c | REQS); // new demand
+ else if (t == (t = tail) && (empty || d == 0L)) {
+ int bit = ((c & ACTIVE) != 0) ? ACTIVE : RUN;
+ if (weakCasCtl(c, c & ~bit) && bit == RUN)
+ break; // un-keep-alive or exit
}
}
}
}
/**
- * Responds to control events in consume().
+ * Consumes some items until unavailable or bound or error.
+ *
+ * @param s subscriber
+ * @param d current demand
+ * @param h current head
+ * @return number taken
*/
- private boolean checkControl(Flow.Subscriber super T> s, int c) {
- boolean stat = true;
- if ((c & SUBSCRIBE) != 0) {
- if (CTL.compareAndSet(this, c, c & ~SUBSCRIBE)) {
- try {
- if (s != null)
- s.onSubscribe(this);
- } catch (Throwable ex) {
- onError(ex);
- }
+ final int takeItems(Subscriber super T> s, long d, int h) {
+ Object[] a;
+ int k = 0, cap;
+ if ((a = array) != null && (cap = a.length) > 0) {
+ int m = cap - 1, b = (m >>> 3) + 1; // min(1, cap/8)
+ int n = (d < (long)b) ? (int)d : b;
+ for (; k < n; ++h, ++k) {
+ Object x = QA.getAndSet(a, h & m, null);
+ if (waiting != 0)
+ signalWaiter();
+ if (x == null)
+ break;
+ else if (!consumeNext(s, x))
+ break;
}
}
- else if ((c & ERROR) != 0) {
- Throwable ex = pendingError;
- ctl = DISABLED; // no need for CAS
- if (ex != null) { // null if errorless cancel
- try {
- if (s != null)
- s.onError(ex);
- } catch (Throwable ignore) {
- }
- }
- }
- else {
- detach();
- stat = false;
- }
- return stat;
+ return k;
}
- /**
- * Responds to apparent emptiness in consume().
- */
- private boolean checkEmpty(Flow.Subscriber super T> s, int c) {
- boolean stat = true;
- if (head == tail) {
- if ((c & CONSUME) != 0)
- CTL.compareAndSet(this, c, c & ~CONSUME);
- else if ((c & COMPLETE) != 0) {
- if (CTL.compareAndSet(this, c, DISABLED)) {
- try {
- if (s != null)
- s.onComplete();
- } catch (Throwable ignore) {
- }
- }
- }
- else if (CTL.compareAndSet(this, c, c & ~ACTIVE))
- stat = false;
+ final boolean consumeNext(Subscriber super T> s, Object x) {
+ try {
+ @SuppressWarnings("unchecked") T y = (T) x;
+ if (s != null)
+ s.onNext(y);
+ return true;
+ } catch (Throwable ex) {
+ handleOnNext(s, ex);
+ return false;
}
- return stat;
- }
-
- /**
- * Responds to apparent zero demand in consume().
- */
- private boolean checkDemand(int c) {
- boolean stat = true;
- if (demand == 0L) {
- if ((c & CONSUME) != 0)
- CTL.compareAndSet(this, c, c & ~CONSUME);
- else if (CTL.compareAndSet(this, c, c & ~ACTIVE))
- stat = false;
- }
- return stat;
}
/**
* Processes exception in Subscriber.onNext.
*/
- private void handleOnNext(Flow.Subscriber super T> s, Throwable ex) {
- BiConsumer super Flow.Subscriber super T>, ? super Throwable> h;
- if ((h = onNextHandler) != null) {
- try {
+ final void handleOnNext(Subscriber super T> s, Throwable ex) {
+ BiConsumer super Subscriber super T>, ? super Throwable> h;
+ try {
+ if ((h = onNextHandler) != null)
h.accept(s, ex);
- } catch (Throwable ignore) {
+ } catch (Throwable ignore) {
+ }
+ closeOnError(s, ex);
+ }
+
+ /**
+ * Issues subscriber.onSubscribe if this is first signal.
+ */
+ final void subscribeOnOpen(Subscriber super T> s) {
+ if ((ctl & OPEN) == 0 && (getAndBitwiseOrCtl(OPEN) & OPEN) == 0)
+ consumeSubscribe(s);
+ }
+
+ final void consumeSubscribe(Subscriber super T> s) {
+ try {
+ if (s != null) // ignore if disabled
+ s.onSubscribe(this);
+ } catch (Throwable ex) {
+ closeOnError(s, ex);
+ }
+ }
+
+ /**
+ * Issues subscriber.onComplete unless already closed.
+ */
+ final void closeOnComplete(Subscriber super T> s) {
+ if ((getAndBitwiseOrCtl(CLOSED) & CLOSED) == 0)
+ consumeComplete(s);
+ }
+
+ final void consumeComplete(Subscriber super T> s) {
+ try {
+ if (s != null)
+ s.onComplete();
+ } catch (Throwable ignore) {
+ }
+ }
+
+ /**
+ * Issues subscriber.onError, and unblocks producer if needed.
+ */
+ final void closeOnError(Subscriber super T> s, Throwable ex) {
+ if ((getAndBitwiseOrCtl(ERROR | CLOSED) & CLOSED) == 0) {
+ if (ex == null)
+ ex = pendingError;
+ pendingError = null; // detach
+ executor = null; // suppress racing start calls
+ signalWaiter();
+ consumeError(s, ex);
+ }
+ }
+
+ final void consumeError(Subscriber super T> s, Throwable ex) {
+ try {
+ if (ex != null && s != null)
+ s.onError(ex);
+ } catch (Throwable ignore) {
+ }
+ }
+
+ // Blocking support
+
+ /**
+ * Unblocks waiting producer.
+ */
+ final void signalWaiter() {
+ Thread w;
+ waiting = 0;
+ if ((w = waiter) != null)
+ LockSupport.unpark(w);
+ }
+
+ /**
+ * Returns true if closed or space available.
+ * For ManagedBlocker.
+ */
+ public final boolean isReleasable() {
+ Object[] a; int cap;
+ return ((ctl & CLOSED) != 0 ||
+ ((a = array) != null && (cap = a.length) > 0 &&
+ QA.getAcquire(a, (cap - 1) & tail) == null));
+ }
+
+ /**
+ * Helps or blocks until timeout, closed, or space available.
+ */
+ final void awaitSpace(long nanos) {
+ if (!isReleasable()) {
+ ForkJoinPool.helpAsyncBlocker(executor, this);
+ if (!isReleasable()) {
+ timeout = nanos;
+ try {
+ ForkJoinPool.managedBlock(this);
+ } catch (InterruptedException ie) {
+ timeout = INTERRUPTED;
+ }
+ if (timeout == INTERRUPTED)
+ Thread.currentThread().interrupt();
}
}
- onError(ex);
+ }
+
+ /**
+ * Blocks until closed, space available or timeout.
+ * For ManagedBlocker.
+ */
+ public final boolean block() {
+ long nanos = timeout;
+ boolean timed = (nanos < Long.MAX_VALUE);
+ long deadline = timed ? System.nanoTime() + nanos : 0L;
+ while (!isReleasable()) {
+ if (Thread.interrupted()) {
+ timeout = INTERRUPTED;
+ if (timed)
+ break;
+ }
+ else if (timed && (nanos = deadline - System.nanoTime()) <= 0L)
+ break;
+ else if (waiter == null)
+ waiter = Thread.currentThread();
+ else if (waiting == 0)
+ waiting = 1;
+ else if (timed)
+ LockSupport.parkNanos(this, nanos);
+ else
+ LockSupport.park(this);
+ }
+ waiter = null;
+ waiting = 0;
+ return true;
}
// VarHandle mechanics
- private static final VarHandle CTL;
- private static final VarHandle TAIL;
- private static final VarHandle HEAD;
- private static final VarHandle DEMAND;
- private static final VarHandle QA;
+ static final VarHandle CTL;
+ static final VarHandle DEMAND;
+ static final VarHandle QA;
static {
try {
MethodHandles.Lookup l = MethodHandles.lookup();
CTL = l.findVarHandle(BufferedSubscription.class, "ctl",
int.class);
- TAIL = l.findVarHandle(BufferedSubscription.class, "tail",
- int.class);
- HEAD = l.findVarHandle(BufferedSubscription.class, "head",
- int.class);
DEMAND = l.findVarHandle(BufferedSubscription.class, "demand",
long.class);
QA = MethodHandles.arrayElementVarHandle(Object[].class);
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java
--- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedLongSynchronizer.java Tue Dec 05 10:28:45 2017 +0000
@@ -422,8 +422,8 @@
* @return {@code true} if interrupted while waiting
*/
final boolean acquireQueued(final Node node, long arg) {
+ boolean interrupted = false;
try {
- boolean interrupted = false;
for (;;) {
final Node p = node.predecessor();
if (p == head && tryAcquire(arg)) {
@@ -431,12 +431,13 @@
p.next = null; // help GC
return interrupted;
}
- if (shouldParkAfterFailedAcquire(p, node) &&
- parkAndCheckInterrupt())
- interrupted = true;
+ if (shouldParkAfterFailedAcquire(p, node))
+ interrupted |= parkAndCheckInterrupt();
}
} catch (Throwable t) {
cancelAcquire(node);
+ if (interrupted)
+ selfInterrupt();
throw t;
}
}
@@ -510,8 +511,8 @@
*/
private void doAcquireShared(long arg) {
final Node node = addWaiter(Node.SHARED);
+ boolean interrupted = false;
try {
- boolean interrupted = false;
for (;;) {
final Node p = node.predecessor();
if (p == head) {
@@ -519,18 +520,18 @@
if (r >= 0) {
setHeadAndPropagate(node, r);
p.next = null; // help GC
- if (interrupted)
- selfInterrupt();
return;
}
}
- if (shouldParkAfterFailedAcquire(p, node) &&
- parkAndCheckInterrupt())
- interrupted = true;
+ if (shouldParkAfterFailedAcquire(p, node))
+ interrupted |= parkAndCheckInterrupt();
}
} catch (Throwable t) {
cancelAcquire(node);
throw t;
+ } finally {
+ if (interrupted)
+ selfInterrupt();
}
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java
--- a/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/util/concurrent/locks/AbstractQueuedSynchronizer.java Tue Dec 05 10:28:45 2017 +0000
@@ -505,7 +505,7 @@
*
* @return the predecessor of this node
*/
- final Node predecessor() throws NullPointerException {
+ final Node predecessor() {
Node p = prev;
if (p == null)
throw new NullPointerException();
@@ -902,8 +902,8 @@
* @return {@code true} if interrupted while waiting
*/
final boolean acquireQueued(final Node node, int arg) {
+ boolean interrupted = false;
try {
- boolean interrupted = false;
for (;;) {
final Node p = node.predecessor();
if (p == head && tryAcquire(arg)) {
@@ -911,12 +911,13 @@
p.next = null; // help GC
return interrupted;
}
- if (shouldParkAfterFailedAcquire(p, node) &&
- parkAndCheckInterrupt())
- interrupted = true;
+ if (shouldParkAfterFailedAcquire(p, node))
+ interrupted |= parkAndCheckInterrupt();
}
} catch (Throwable t) {
cancelAcquire(node);
+ if (interrupted)
+ selfInterrupt();
throw t;
}
}
@@ -990,8 +991,8 @@
*/
private void doAcquireShared(int arg) {
final Node node = addWaiter(Node.SHARED);
+ boolean interrupted = false;
try {
- boolean interrupted = false;
for (;;) {
final Node p = node.predecessor();
if (p == head) {
@@ -999,18 +1000,18 @@
if (r >= 0) {
setHeadAndPropagate(node, r);
p.next = null; // help GC
- if (interrupted)
- selfInterrupt();
return;
}
}
- if (shouldParkAfterFailedAcquire(p, node) &&
- parkAndCheckInterrupt())
- interrupted = true;
+ if (shouldParkAfterFailedAcquire(p, node))
+ interrupted |= parkAndCheckInterrupt();
}
} catch (Throwable t) {
cancelAcquire(node);
throw t;
+ } finally {
+ if (interrupted)
+ selfInterrupt();
}
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/java/util/stream/Collectors.java
--- a/src/java.base/share/classes/java/util/stream/Collectors.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/java/util/stream/Collectors.java Tue Dec 05 10:28:45 2017 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2017, 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
@@ -116,6 +116,8 @@
= Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED,
Collector.Characteristics.IDENTITY_FINISH));
static final Set CH_NOID = Collections.emptySet();
+ static final Set CH_UNORDERED_NOID
+ = Collections.unmodifiableSet(EnumSet.of(Collector.Characteristics.UNORDERED));
private Collectors() { }
@@ -279,6 +281,26 @@
}
/**
+ * Returns a {@code Collector} that accumulates the input elements into an
+ * unmodifiable List in encounter
+ * order. The returned Collector disallows null values and will throw
+ * {@code NullPointerException} if it is presented with a null value.
+ *
+ * @param the type of the input elements
+ * @return a {@code Collector} that accumulates the input elements into an
+ * unmodifiable List in encounter order
+ * @since 10
+ */
+ @SuppressWarnings("unchecked")
+ public static
+ Collector> toUnmodifiableList() {
+ return new CollectorImpl<>((Supplier>) ArrayList::new, List::add,
+ (left, right) -> { left.addAll(right); return left; },
+ list -> (List)List.of(list.toArray()),
+ CH_NOID);
+ }
+
+ /**
* Returns a {@code Collector} that accumulates the input elements into a
* new {@code Set}. There are no guarantees on the type, mutability,
* serializability, or thread-safety of the {@code Set} returned; if more
@@ -306,6 +328,36 @@
}
/**
+ * Returns a {@code Collector} that accumulates the input elements into an
+ * unmodifiable Set. The returned
+ * Collector disallows null values and will throw {@code NullPointerException}
+ * if it is presented with a null value. If the input contains duplicate elements,
+ * an arbitrary element of the duplicates is preserved.
+ *
+ * This is an {@link Collector.Characteristics#UNORDERED unordered}
+ * Collector.
+ *
+ * @param the type of the input elements
+ * @return a {@code Collector} that accumulates the input elements into an
+ * unmodifiable Set
+ * @since 10
+ */
+ @SuppressWarnings("unchecked")
+ public static
+ Collector> toUnmodifiableSet() {
+ return new CollectorImpl<>((Supplier>) HashSet::new, Set::add,
+ (left, right) -> {
+ if (left.size() < right.size()) {
+ right.addAll(left); return right;
+ } else {
+ left.addAll(right); return left;
+ }
+ },
+ set -> (Set)Set.of(set.toArray()),
+ CH_UNORDERED_NOID);
+ }
+
+ /**
* Returns a {@code Collector} that concatenates the input elements into a
* {@code String}, in encounter order.
*
@@ -1353,7 +1405,7 @@
* If the mapped keys contain duplicates (according to
* {@link Object#equals(Object)}), an {@code IllegalStateException} is
* thrown when the collection operation is performed. If the mapped keys
- * may have duplicates, use {@link #toMap(Function, Function, BinaryOperator)}
+ * might have duplicates, use {@link #toMap(Function, Function, BinaryOperator)}
* instead.
*
*
There are no guarantees on the type, mutability, serializability,
@@ -1411,6 +1463,45 @@
}
/**
+ * Returns a {@code Collector} that accumulates the input elements into an
+ * unmodifiable Map,
+ * whose keys and values are the result of applying the provided
+ * mapping functions to the input elements.
+ *
+ *
If the mapped keys contain duplicates (according to
+ * {@link Object#equals(Object)}), an {@code IllegalStateException} is
+ * thrown when the collection operation is performed. If the mapped keys
+ * might have duplicates, use {@link #toUnmodifiableMap(Function, Function, BinaryOperator)}
+ * to handle merging of the values.
+ *
+ *
The returned Collector disallows null keys and values. If either mapping function
+ * returns null, {@code NullPointerException} will be thrown.
+ *
+ * @param the type of the input elements
+ * @param the output type of the key mapping function
+ * @param the output type of the value mapping function
+ * @param keyMapper a mapping function to produce keys, must be non-null
+ * @param valueMapper a mapping function to produce values, must be non-null
+ * @return a {@code Collector} that accumulates the input elements into an
+ * unmodifiable Map, whose keys and values
+ * are the result of applying the provided mapping functions to the input elements
+ * @throws NullPointerException if either keyMapper or valueMapper is null
+ *
+ * @see #toUnmodifiableMap(Function, Function, BinaryOperator)
+ * @since 10
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static
+ Collector> toUnmodifiableMap(Function super T, ? extends K> keyMapper,
+ Function super T, ? extends U> valueMapper) {
+ Objects.requireNonNull(keyMapper, "keyMapper");
+ Objects.requireNonNull(valueMapper, "valueMapper");
+ return collectingAndThen(
+ toMap(keyMapper, valueMapper),
+ map -> (Map)Map.ofEntries(map.entrySet().toArray(new Map.Entry[0])));
+ }
+
+ /**
* Returns a {@code Collector} that accumulates elements into a
* {@code Map} whose keys and values are the result of applying the provided
* mapping functions to the input elements.
@@ -1473,6 +1564,51 @@
return toMap(keyMapper, valueMapper, mergeFunction, HashMap::new);
}
+
+ /**
+ * Returns a {@code Collector} that accumulates the input elements into an
+ * unmodifiable Map,
+ * whose keys and values are the result of applying the provided
+ * mapping functions to the input elements.
+ *
+ * If the mapped
+ * keys contain duplicates (according to {@link Object#equals(Object)}),
+ * the value mapping function is applied to each equal element, and the
+ * results are merged using the provided merging function.
+ *
+ *
The returned Collector disallows null keys and values. If either mapping function
+ * returns null, {@code NullPointerException} will be thrown.
+ *
+ * @param the type of the input elements
+ * @param the output type of the key mapping function
+ * @param the output type of the value mapping function
+ * @param keyMapper a mapping function to produce keys, must be non-null
+ * @param valueMapper a mapping function to produce values, must be non-null
+ * @param mergeFunction a merge function, used to resolve collisions between
+ * values associated with the same key, as supplied
+ * to {@link Map#merge(Object, Object, BiFunction)},
+ * must be non-null
+ * @return a {@code Collector} that accumulates the input elements into an
+ * unmodifiable Map, whose keys and values
+ * are the result of applying the provided mapping functions to the input elements
+ * @throws NullPointerException if the keyMapper, valueMapper, or mergeFunction is null
+ *
+ * @see #toUnmodifiableMap(Function, Function)
+ * @since 10
+ */
+ @SuppressWarnings({"rawtypes", "unchecked"})
+ public static
+ Collector> toUnmodifiableMap(Function super T, ? extends K> keyMapper,
+ Function super T, ? extends U> valueMapper,
+ BinaryOperator mergeFunction) {
+ Objects.requireNonNull(keyMapper, "keyMapper");
+ Objects.requireNonNull(valueMapper, "valueMapper");
+ Objects.requireNonNull(mergeFunction, "mergeFunction");
+ return collectingAndThen(
+ toMap(keyMapper, valueMapper, mergeFunction, HashMap::new),
+ map -> (Map)Map.ofEntries(map.entrySet().toArray(new Map.Entry[0])));
+ }
+
/**
* Returns a {@code Collector} that accumulates elements into a
* {@code Map} whose keys and values are the result of applying the provided
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java
--- a/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java Tue Dec 05 10:28:45 2017 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -33,7 +33,7 @@
import java.nio.channels.FileChannel;
import java.nio.channels.SeekableByteChannel;
import java.nio.file.*;
-import java.nio.file.DirectoryStream.Filter;;
+import java.nio.file.DirectoryStream.Filter;
import java.nio.file.attribute.BasicFileAttributes;
import java.nio.file.attribute.BasicFileAttributeView;
import java.nio.file.attribute.FileAttribute;
@@ -274,7 +274,7 @@
if (o.path.length() == 0) {
return this;
}
- StringBuilder sb = new StringBuilder(path.length() + o.path.length());
+ StringBuilder sb = new StringBuilder(path.length() + o.path.length() + 1);
sb.append(path);
if (path.charAt(path.length() - 1) != '/')
sb.append('/');
@@ -478,12 +478,15 @@
// Remove DotSlash(./) and resolve DotDot (..) components
private String getResolved() {
- if (path.length() == 0) {
+ int length = path.length();
+ if (length == 0 || (path.indexOf("./") == -1 && path.charAt(length - 1) != '.')) {
return path;
+ } else {
+ return resolvePath();
}
- if (path.indexOf('.') == -1) {
- return path;
- }
+ }
+
+ private String resolvePath() {
int length = path.length();
char[] to = new char[length];
int nc = getNameCount();
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/jdk/internal/util/jar/VersionedStream.java
--- a/src/java.base/share/classes/jdk/internal/util/jar/VersionedStream.java Tue Dec 05 10:21:41 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,85 +0,0 @@
-/*
- * 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. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package jdk.internal.util.jar;
-
-import java.util.Objects;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-import java.util.stream.Stream;
-
-public class VersionedStream {
- private static final String META_INF_VERSIONS = "META-INF/versions/";
-
- /**
- * Returns a stream of versioned entries, derived from the base names of
- * all entries in a multi-release {@code JarFile} that are present either in
- * the base directory or in any versioned directory with a version number
- * less than or equal to the {@code Runtime.Version::major} that the
- * {@code JarFile} was opened with. These versioned entries are aliases
- * for the real entries -- i.e. the names are base names and the content
- * may come from a versioned directory entry. If the {@code jarFile} is not
- * a multi-release jar, a stream of all entries is returned.
- *
- * @param jf the input JarFile
- * @return stream of entries
- * @since 9
- */
- public static Stream stream(JarFile jf) {
- if (jf.isMultiRelease()) {
- int version = jf.getVersion().major();
- return jf.stream()
- .map(je -> getBaseSuffix(je, version))
- .filter(Objects::nonNull)
- .distinct()
- .map(jf::getJarEntry);
- }
- return jf.stream();
- }
-
- private static String getBaseSuffix(JarEntry je, int version) {
- String name = je.getName();
- if (name.startsWith(META_INF_VERSIONS)) {
- int len = META_INF_VERSIONS.length();
- int index = name.indexOf('/', len);
- if (index == -1 || index == (name.length() - 1)) {
- // filter out META-INF/versions/* and META-INF/versions/*/
- return null;
- }
- try {
- if (Integer.parseInt(name, len, index, 10) > version) {
- // not an integer
- return null;
- }
- } catch (NumberFormatException x) {
- // silently remove malformed entries
- return null;
- }
- // We know name looks like META-INF/versions/*/*
- return name.substring(index + 1);
- }
- return name;
- }
-}
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/classes/sun/security/tools/keytool/Main.java
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java Tue Dec 05 10:28:45 2017 +0000
@@ -2746,12 +2746,12 @@
if (rfc) {
dumpCert(cert, out);
} else {
- out.println("Certificate #" + i++);
+ out.println("Certificate #" + i);
out.println("====================================");
printX509Cert((X509Certificate)cert, out);
out.println();
}
- checkWeak(oneInMany(rb.getString("the.certificate"), i, chain.size()), cert);
+ checkWeak(oneInMany(rb.getString("the.certificate"), i++, chain.size()), cert);
} catch (Exception e) {
if (debug) {
e.printStackTrace();
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/native/include/jvm.h
--- a/src/java.base/share/native/include/jvm.h Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/native/include/jvm.h Tue Dec 05 10:28:45 2017 +0000
@@ -262,21 +262,9 @@
/*
* java.lang.SecurityManager
*/
-JNIEXPORT jclass JNICALL
-JVM_CurrentLoadedClass(JNIEnv *env);
-
-JNIEXPORT jobject JNICALL
-JVM_CurrentClassLoader(JNIEnv *env);
-
JNIEXPORT jobjectArray JNICALL
JVM_GetClassContext(JNIEnv *env);
-JNIEXPORT jint JNICALL
-JVM_ClassDepth(JNIEnv *env, jstring name);
-
-JNIEXPORT jint JNICALL
-JVM_ClassLoaderDepth(JNIEnv *env);
-
/*
* java.lang.Package
*/
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/native/libjava/SecurityManager.c
--- a/src/java.base/share/native/libjava/SecurityManager.c Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/native/libjava/SecurityManager.c Tue Dec 05 10:28:45 2017 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -76,53 +76,3 @@
return JVM_GetClassContext(env);
}
-
-JNIEXPORT jclass JNICALL
-Java_java_lang_SecurityManager_currentLoadedClass0(JNIEnv *env, jobject this)
-{
- /* Make sure the security manager instance is initialized */
- if (!check(env, this)) {
- return NULL; /* exception */
- }
-
- return JVM_CurrentLoadedClass(env);
-}
-
-JNIEXPORT jobject JNICALL
-Java_java_lang_SecurityManager_currentClassLoader0(JNIEnv *env, jobject this)
-{
- /* Make sure the security manager instance is initialized */
- if (!check(env, this)) {
- return NULL; /* exception */
- }
-
- return JVM_CurrentClassLoader(env);
-}
-
-JNIEXPORT jint JNICALL
-Java_java_lang_SecurityManager_classDepth(JNIEnv *env, jobject this,
- jstring name)
-{
- /* Make sure the security manager instance is initialized */
- if (!check(env, this)) {
- return -1; /* exception */
- }
-
- if (name == NULL) {
- JNU_ThrowNullPointerException(env, 0);
- return -1;
- }
-
- return JVM_ClassDepth(env, name);
-}
-
-JNIEXPORT jint JNICALL
-Java_java_lang_SecurityManager_classLoaderDepth0(JNIEnv *env, jobject this)
-{
- /* Make sure the security manager instance is initialized */
- if (!check(env, this)) {
- return -1; /* exception */
- }
-
- return JVM_ClassLoaderDepth(env);
-}
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/native/libzip/Deflater.c
--- a/src/java.base/share/native/libzip/Deflater.c Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/native/libzip/Deflater.c Tue Dec 05 10:28:45 2017 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2017, 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
@@ -164,17 +164,14 @@
res = deflateParams(strm, level, strategy);
(*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0);
(*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
-
switch (res) {
case Z_OK:
(*env)->SetBooleanField(env, this, setParamsID, JNI_FALSE);
+ case Z_BUF_ERROR:
this_off += this_len - strm->avail_in;
(*env)->SetIntField(env, this, offID, this_off);
(*env)->SetIntField(env, this, lenID, strm->avail_in);
return (jint) (len - strm->avail_out);
- case Z_BUF_ERROR:
- (*env)->SetBooleanField(env, this, setParamsID, JNI_FALSE);
- return 0;
default:
JNU_ThrowInternalError(env, strm->msg);
return 0;
@@ -203,19 +200,17 @@
res = deflate(strm, finish ? Z_FINISH : flush);
(*env)->ReleasePrimitiveArrayCritical(env, b, out_buf, 0);
(*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0);
-
switch (res) {
case Z_STREAM_END:
(*env)->SetBooleanField(env, this, finishedID, JNI_TRUE);
/* fall through */
case Z_OK:
+ case Z_BUF_ERROR:
this_off += this_len - strm->avail_in;
(*env)->SetIntField(env, this, offID, this_off);
(*env)->SetIntField(env, this, lenID, strm->avail_in);
return len - strm->avail_out;
- case Z_BUF_ERROR:
- return 0;
- default:
+ default:
JNU_ThrowInternalError(env, strm->msg);
return 0;
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/native/libzip/zlib/deflate.c
--- a/src/java.base/share/native/libzip/zlib/deflate.c Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/native/libzip/zlib/deflate.c Tue Dec 05 10:28:45 2017 +0000
@@ -505,8 +505,6 @@
s->pending = 0;
s->pending_out = s->pending_buf;
- s->high_water = 0; /* reset to its inital value 0 */
-
if (s->wrap < 0) {
s->wrap = -s->wrap; /* was made negative by deflate(..., Z_FINISH); */
}
@@ -520,7 +518,7 @@
s->wrap == 2 ? crc32(0L, Z_NULL, 0) :
#endif
adler32(0L, Z_NULL, 0);
- s->last_flush = Z_NO_FLUSH;
+ s->last_flush = -2;
_tr_init(s);
@@ -613,7 +611,7 @@
func = configuration_table[s->level].func;
if ((strategy != s->strategy || func != configuration_table[level].func) &&
- s->high_water) {
+ s->last_flush != -2) {
/* Flush the last buffer: */
int err = deflate(strm, Z_BLOCK);
if (err == Z_STREAM_ERROR)
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/share/native/libzip/zlib/patches/ChangeLog_java
--- a/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/share/native/libzip/zlib/patches/ChangeLog_java Tue Dec 05 10:28:45 2017 +0000
@@ -93,4 +93,6 @@
s->status =
#ifdef GZIP
+(7) deflate.c undo (6), replaced withe the official zlib repo fix see#305/#f969409
+
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java
--- a/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/unix/classes/java/net/PlainDatagramSocketImpl.java Tue Dec 05 10:28:45 2017 +0000
@@ -45,41 +45,33 @@
ExtendedSocketOptions.getInstance();
protected void setOption(SocketOption name, T value) throws IOException {
- if (!extendedOptions.isOptionSupported(name)) {
- if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
- super.setOption(name, value);
+ if (isClosed()) {
+ throw new SocketException("Socket closed");
+ }
+ if (supportedOptions().contains(name)) {
+ if (extendedOptions.isOptionSupported(name)) {
+ extendedOptions.setOption(fd, name, value);
} else {
- if (supportedOptions().contains(name)) {
- super.setOption(name, value);
- } else {
- throw new UnsupportedOperationException("unsupported option");
- }
+ super.setOption(name, value);
}
} else {
- if (isClosed()) {
- throw new SocketException("Socket closed");
- }
- extendedOptions.setOption(fd, name, value);
+ throw new UnsupportedOperationException("unsupported option");
}
}
@SuppressWarnings("unchecked")
protected T getOption(SocketOption name) throws IOException {
- if (!extendedOptions.isOptionSupported(name)) {
- if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
- return super.getOption(name);
+ if (isClosed()) {
+ throw new SocketException("Socket closed");
+ }
+ if (supportedOptions().contains(name)) {
+ if (extendedOptions.isOptionSupported(name)) {
+ return (T) extendedOptions.getOption(fd, name);
} else {
- if (supportedOptions().contains(name)) {
- return super.getOption(name);
- } else {
- throw new UnsupportedOperationException("unsupported option");
- }
+ return super.getOption(name);
}
} else {
- if (isClosed()) {
- throw new SocketException("Socket closed");
- }
- return (T) extendedOptions.getOption(fd, name);
+ throw new UnsupportedOperationException("unsupported option");
}
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.base/unix/classes/java/net/PlainSocketImpl.java
--- a/src/java.base/unix/classes/java/net/PlainSocketImpl.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.base/unix/classes/java/net/PlainSocketImpl.java Tue Dec 05 10:28:45 2017 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -58,58 +58,57 @@
ExtendedSocketOptions.getInstance();
protected void setOption(SocketOption name, T value) throws IOException {
- if (!extendedOptions.isOptionSupported(name)) {
- if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
- super.setOption(name, value);
+ if (isClosedOrPending()) {
+ throw new SocketException("Socket closed");
+ }
+ if (supportedOptions().contains(name)) {
+ if (extendedOptions.isOptionSupported(name)) {
+ extendedOptions.setOption(fd, name, value);
} else {
- if (supportedOptions().contains(name)) {
- super.setOption(name, value);
- } else {
- throw new UnsupportedOperationException("unsupported option");
- }
+ super.setOption(name, value);
}
} else {
- if (getSocket() == null) {
- throw new UnsupportedOperationException("unsupported option");
- }
- if (isClosedOrPending()) {
- throw new SocketException("Socket closed");
- }
- extendedOptions.setOption(fd, name, value);
+ throw new UnsupportedOperationException("unsupported option");
}
}
@SuppressWarnings("unchecked")
protected T getOption(SocketOption name) throws IOException {
- if (!extendedOptions.isOptionSupported(name)) {
- if (!name.equals(StandardSocketOptions.SO_REUSEPORT)) {
- return super.getOption(name);
+ if (isClosedOrPending()) {
+ throw new SocketException("Socket closed");
+ }
+ if (supportedOptions().contains(name)) {
+ if (extendedOptions.isOptionSupported(name)) {
+ return (T) extendedOptions.getOption(fd, name);
} else {
- if (supportedOptions().contains(name)) {
- return super.getOption(name);
- } else {
- throw new UnsupportedOperationException("unsupported option");
- }
+ return super.getOption(name);
}
} else {
- if (getSocket() == null) {
- throw new UnsupportedOperationException("unsupported option");
- }
- if (isClosedOrPending()) {
- throw new SocketException("Socket closed");
- }
- return (T) extendedOptions.getOption(fd, name);
+ throw new UnsupportedOperationException("unsupported option");
}
}
protected Set> supportedOptions() {
HashSet> options = new HashSet<>(super.supportedOptions());
- if (getSocket() != null) {
- options.addAll(extendedOptions.options());
- }
+ addExtSocketOptions(extendedOptions.options(), options);
return options;
}
+ private void addExtSocketOptions(Set> extOptions,
+ Set> options) {
+ extOptions.forEach((option) -> {
+ if (option.name().equals("SO_FLOW_SLA")) {
+ // SO_FLOW_SLA is Solaris specific option which is not applicable
+ // for ServerSockets.
+ // getSocket() will always return null for server socket
+ if (getSocket() != null) {
+ options.add(option);
+ }
+ } else {
+ options.add(option);
+ }
+ });
+ }
protected void socketSetOption(int opt, boolean b, Object val) throws SocketException {
if (opt == SocketOptions.SO_REUSEPORT &&
!supportedOptions().contains(StandardSocketOptions.SO_REUSEPORT)) {
diff -r 10b34c929b4f -r 64298b1e890b src/java.desktop/share/classes/sun/applet/AppletSecurity.java
--- a/src/java.desktop/share/classes/sun/applet/AppletSecurity.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.desktop/share/classes/sun/applet/AppletSecurity.java Tue Dec 05 10:28:45 2017 +0000
@@ -48,6 +48,8 @@
import sun.awt.AWTPermissions;
import sun.security.util.SecurityConstants;
+import static java.lang.StackWalker.*;
+import static java.lang.StackWalker.Option.*;
/**
@@ -106,11 +108,90 @@
});
}
+ private static final StackWalker walker =
+ AccessController.doPrivileged(
+ (PrivilegedAction) () ->
+ StackWalker.getInstance(RETAIN_CLASS_REFERENCE));
+ /**
+ * Returns the class loader of the most recently executing method from
+ * a class defined using a non-system class loader. A non-system
+ * class loader is defined as being a class loader that is not equal to
+ * the system class loader (as returned
+ * by {@link ClassLoader#getSystemClassLoader}) or one of its ancestors.
+ *
+ * This method will return
+ * null
in the following three cases:
+ *
+ * - All methods on the execution stack are from classes
+ * defined using the system class loader or one of its ancestors.
+ *
+ *
- All methods on the execution stack up to the first
+ * "privileged" caller
+ * (see {@link java.security.AccessController#doPrivileged})
+ * are from classes
+ * defined using the system class loader or one of its ancestors.
+ *
+ *
- A call to
checkPermission
with
+ * java.security.AllPermission
does not
+ * result in a SecurityException.
+ *
+ *
+ * NOTE: This is an implementation of the SecurityManager.currentClassLoader
+ * method that uses StackWalker. SecurityManager.currentClassLoader
+ * has been removed from SE. This is a temporary workaround which is
+ * only needed while applets are still supported.
+ *
+ * @return the class loader of the most recent occurrence on the stack
+ * of a method from a class defined using a non-system class
+ * loader.
+ */
+ private static ClassLoader currentClassLoader() {
+ StackFrame f =
+ walker.walk(s -> s.takeWhile(AppletSecurity::isNonPrivileged)
+ .filter(AppletSecurity::isNonSystemFrame)
+ .findFirst())
+ .orElse(null);
+
+ SecurityManager sm = System.getSecurityManager();
+ if (f != null && sm != null) {
+ try {
+ sm.checkPermission(new AllPermission());
+ } catch (SecurityException se) {
+ return f.getDeclaringClass().getClassLoader();
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns true if the StackFrame is not AccessController.doPrivileged.
+ */
+ private static boolean isNonPrivileged(StackFrame f) {
+ // possibly other doPrivileged variants
+ Class> c = f.getDeclaringClass();
+ return c == AccessController.class &&
+ f.getMethodName().equals("doPrivileged");
+ }
+
+ /**
+ * Returns true if the StackFrame is not from a class defined by the
+ * system class loader or one of its ancestors.
+ */
+ private static boolean isNonSystemFrame(StackFrame f) {
+ ClassLoader loader = ClassLoader.getSystemClassLoader();
+ ClassLoader ld = f.getDeclaringClass().getClassLoader();
+ if (ld == null || ld == loader) return false;
+
+ while ((loader = loader.getParent()) != null) {
+ if (ld == loader)
+ return false;
+ }
+ return true;
+ }
+
/**
* get the current (first) instance of an AppletClassLoader on the stack.
*/
- @SuppressWarnings({"deprecation",
- "removal"}) // SecurityManager.currentClassLoader()
private AppletClassLoader currentAppletClassLoader()
{
// try currentClassLoader first
diff -r 10b34c929b4f -r 64298b1e890b src/java.desktop/share/classes/sun/awt/FontDescriptor.java
--- a/src/java.desktop/share/classes/sun/awt/FontDescriptor.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.desktop/share/classes/sun/awt/FontDescriptor.java Tue Dec 05 10:28:45 2017 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2017, 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,7 +26,7 @@
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
-import java.io.IOException;;
+import java.io.IOException;
import java.nio.charset.Charset;
import java.nio.charset.CharsetEncoder;
import java.nio.charset.StandardCharsets;
diff -r 10b34c929b4f -r 64298b1e890b src/java.security.jgss/share/native/libj2gss/GSSLibStub.c
--- a/src/java.security.jgss/share/native/libj2gss/GSSLibStub.c Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.security.jgss/share/native/libj2gss/GSSLibStub.c Tue Dec 05 10:28:45 2017 +0000
@@ -1410,7 +1410,6 @@
checkStatus(env, jobj, GSS_S_CONTEXT_EXPIRED, 0, "[GSSLibStub_getMic]");
return NULL;
}
- contextHdl = (gss_ctx_id_t) jlong_to_ptr(pContext);
qop = (gss_qop_t) jqop;
initGSSBuffer(env, jmsg, &msg);
if ((*env)->ExceptionCheck(env)) {
diff -r 10b34c929b4f -r 64298b1e890b src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java
--- a/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.xml.ws/share/classes/com/sun/xml/internal/messaging/saaj/util/stax/SaajStaxWriter.java Tue Dec 05 10:28:45 2017 +0000
@@ -505,7 +505,7 @@
}
// add namespace declarations
for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
- target.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
+ newElement.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
}
// add attribute declarations
for (AttributeDeclaration attribute : this.attributeDeclarations) {
diff -r 10b34c929b4f -r 64298b1e890b src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java
--- a/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/message/saaj/SaajStaxWriter.java Tue Dec 05 10:28:45 2017 +0000
@@ -499,7 +499,7 @@
}
// add namespace declarations
for (NamespaceDeclaration namespace : this.namespaceDeclarations) {
- target.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
+ newElement.addNamespaceDeclaration(namespace.prefix, namespace.namespaceUri);
}
// add attribute declarations
for (AttributeDeclaration attribute : this.attributeDeclarations) {
diff -r 10b34c929b4f -r 64298b1e890b src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantDouble.java Tue Dec 05 10:28:45 2017 +0000
@@ -32,6 +32,7 @@
*
* @version $Id: ConstantDouble.java 1747278 2016-06-07 17:28:43Z britter $
* @see Constant
+ * @LastModified: Nov 2017
*/
public final class ConstantDouble extends Constant implements ConstantObject {
@@ -121,6 +122,6 @@
*/
@Override
public Object getConstantValue( final ConstantPool cp ) {
- return new Double(bytes);
+ return bytes;
}
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/classfile/ConstantFloat.java Tue Dec 05 10:28:45 2017 +0000
@@ -32,6 +32,7 @@
*
* @version $Id: ConstantFloat.java 1747278 2016-06-07 17:28:43Z britter $
* @see Constant
+ * @LastModified: Nov 2017
*/
public final class ConstantFloat extends Constant implements ConstantObject {
@@ -122,6 +123,6 @@
*/
@Override
public Object getConstantValue( final ConstantPool cp ) {
- return new Float(bytes);
+ return bytes;
}
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCONST.java
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCONST.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/DCONST.java Tue Dec 05 10:28:45 2017 +0000
@@ -26,6 +26,7 @@
* Stack: ... -> ...,
*
* @version $Id: DCONST.java 1747278 2016-06-07 17:28:43Z britter $
+ * @LastModified: Nov 2017
*/
public class DCONST extends Instruction implements ConstantPushInstruction {
@@ -55,7 +56,7 @@
@Override
public Number getValue() {
- return new Double(value);
+ return value;
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCONST.java
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCONST.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/FCONST.java Tue Dec 05 10:28:45 2017 +0000
@@ -26,6 +26,7 @@
* Stack: ... -> ...,
*
* @version $Id: FCONST.java 1747278 2016-06-07 17:28:43Z britter $
+ * @LastModified: Nov 2017
*/
public class FCONST extends Instruction implements ConstantPushInstruction {
@@ -57,7 +58,7 @@
@Override
public Number getValue() {
- return new Float(value);
+ return value;
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/INVOKEDYNAMIC.java Tue Dec 05 10:28:45 2017 +0000
@@ -1,6 +1,5 @@
/*
- * reserved comment block
- * DO NOT REMOVE OR ALTER!
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
*/
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
@@ -41,6 +40,7 @@
*
* The invokedynamic instruction in The Java Virtual Machine Specification
* @since 6.0
+ * @LastModified: Nov 2017
*/
public class INVOKEDYNAMIC extends InvokeInstruction {
@@ -124,8 +124,14 @@
/**
* Override the parent method because our classname is held elsewhere.
+ *
+ * @param cpg the ConstantPool generator
+ * @deprecated in FieldOrMethod
+ *
+ * @return name of the referenced class/interface
*/
@Override
+ @Deprecated
public String getClassName( final ConstantPoolGen cpg ) {
final ConstantPool cp = cpg.getConstantPool();
final ConstantInvokeDynamic cid = (ConstantInvokeDynamic) cp.getConstant(super.getIndex(), Const.CONSTANT_InvokeDynamic);
diff -r 10b34c929b4f -r 64298b1e890b src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/InstructionFactory.java Tue Dec 05 10:28:45 2017 +0000
@@ -32,6 +32,7 @@
* @version $Id: InstructionFactory.java 1749603 2016-06-21 20:50:19Z ggregory $
* @see Const
* @see InstructionConst
+ * @LastModified: Nov 2017
*/
public class InstructionFactory {
@@ -573,7 +574,7 @@
+ short_names[dest - Const.T_CHAR];
Instruction i = null;
try {
- i = (Instruction) java.lang.Class.forName(name).newInstance();
+ i = (Instruction) java.lang.Class.forName(name).getDeclaredConstructor().newInstance();
} catch (final Exception e) {
throw new RuntimeException("Could not find instruction: " + name, e);
}
diff -r 10b34c929b4f -r 64298b1e890b src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC.java Tue Dec 05 10:28:45 2017 +0000
@@ -32,6 +32,7 @@
* Stack: ... -> ..., item
*
* @version $Id: LDC.java 1749603 2016-06-21 20:50:19Z ggregory $
+ * @LastModified: Nov 2017
*/
public class LDC extends CPInstruction implements PushInstruction, ExceptionThrower {
@@ -104,9 +105,9 @@
c = cpg.getConstantPool().getConstant(i);
return ((com.sun.org.apache.bcel.internal.classfile.ConstantUtf8) c).getBytes();
case com.sun.org.apache.bcel.internal.Const.CONSTANT_Float:
- return new Float(((com.sun.org.apache.bcel.internal.classfile.ConstantFloat) c).getBytes());
+ return ((com.sun.org.apache.bcel.internal.classfile.ConstantFloat) c).getBytes();
case com.sun.org.apache.bcel.internal.Const.CONSTANT_Integer:
- return Integer.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantInteger) c).getBytes());
+ return ((com.sun.org.apache.bcel.internal.classfile.ConstantInteger) c).getBytes();
case com.sun.org.apache.bcel.internal.Const.CONSTANT_Class:
final int nameIndex = ((com.sun.org.apache.bcel.internal.classfile.ConstantClass) c).getNameIndex();
c = cpg.getConstantPool().getConstant(nameIndex);
diff -r 10b34c929b4f -r 64298b1e890b src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java
--- a/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/java.xml/share/classes/com/sun/org/apache/bcel/internal/generic/LDC2_W.java Tue Dec 05 10:28:45 2017 +0000
@@ -26,6 +26,7 @@
* Stack: ... -> ..., item.word1, item.word2
*
* @version $Id: LDC2_W.java 1749603 2016-06-21 20:50:19Z ggregory $
+ * @LastModified: Nov 2017
*/
public class LDC2_W extends CPInstruction implements PushInstruction {
@@ -59,9 +60,9 @@
final com.sun.org.apache.bcel.internal.classfile.Constant c = cpg.getConstantPool().getConstant(super.getIndex());
switch (c.getTag()) {
case com.sun.org.apache.bcel.internal.Const.CONSTANT_Long:
- return Long.valueOf(((com.sun.org.apache.bcel.internal.classfile.ConstantLong) c).getBytes());
+ return ((com.sun.org.apache.bcel.internal.classfile.ConstantLong) c).getBytes();
case com.sun.org.apache.bcel.internal.Const.CONSTANT_Double:
- return new Double(((com.sun.org.apache.bcel.internal.classfile.ConstantDouble) c).getBytes());
+ return ((com.sun.org.apache.bcel.internal.classfile.ConstantDouble) c).getBytes();
default: // Never reached
throw new RuntimeException("Unknown or invalid constant type at " + super.getIndex());
}
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_HKSCS.java.template
--- a/src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_HKSCS.java.template Tue Dec 05 10:21:41 2017 +0000
+++ b/src/jdk.charsets/share/classes/sun/nio/cs/ext/Big5_HKSCS.java.template Tue Dec 05 10:28:45 2017 +0000
@@ -31,6 +31,7 @@
import sun.nio.cs.DoubleByte;
import sun.nio.cs.HKSCS;
import sun.nio.cs.HistoricallyNamedCharset;
+import sun.nio.cs.*;
import static sun.nio.cs.CharsetMapping.*;
public class Big5_HKSCS extends Charset implements HistoricallyNamedCharset
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.charsets/share/classes/sun/nio/cs/ext/MS950_HKSCS.java
--- a/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS950_HKSCS.java Tue Dec 05 10:21:41 2017 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,90 +0,0 @@
-/*
- * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation. Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package sun.nio.cs.ext;
-
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-import sun.nio.cs.HistoricallyNamedCharset;
-import sun.nio.cs.*;
-import static sun.nio.cs.CharsetMapping.*;
-
-public class MS950_HKSCS extends Charset implements HistoricallyNamedCharset
-{
- public MS950_HKSCS() {
- super("x-MS950-HKSCS", ExtendedCharsets.aliasesFor("x-MS950-HKSCS"));
- }
-
- public String historicalName() {
- return "MS950_HKSCS";
- }
-
- public boolean contains(Charset cs) {
- return ((cs.name().equals("US-ASCII"))
- || (cs instanceof MS950)
- || (cs instanceof MS950_HKSCS));
- }
-
- public CharsetDecoder newDecoder() {
- return new Decoder(this);
- }
-
- public CharsetEncoder newEncoder() {
- return new Encoder(this);
- }
-
- static class Decoder extends HKSCS.Decoder {
- private static DoubleByte.Decoder ms950 =
- (DoubleByte.Decoder)new MS950().newDecoder();
-
- private static char[][] b2cBmp = new char[0x100][];
- private static char[][] b2cSupp = new char[0x100][];
- static {
- initb2c(b2cBmp, HKSCSMapping.b2cBmpStr);
- initb2c(b2cSupp, HKSCSMapping.b2cSuppStr);
- }
-
- private Decoder(Charset cs) {
- super(cs, ms950, b2cBmp, b2cSupp);
- }
- }
-
- private static class Encoder extends HKSCS.Encoder {
- private static DoubleByte.Encoder ms950 =
- (DoubleByte.Encoder)new MS950().newEncoder();
-
- static char[][] c2bBmp = new char[0x100][];
- static char[][] c2bSupp = new char[0x100][];
- static {
- initc2b(c2bBmp, HKSCSMapping.b2cBmpStr, HKSCSMapping.pua);
- initc2b(c2bSupp, HKSCSMapping.b2cSuppStr, null);
- }
-
- private Encoder(Charset cs) {
- super(cs, ms950, c2bBmp, c2bSupp);
- }
- }
-}
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.charsets/share/classes/sun/nio/cs/ext/MS950_HKSCS.java.template
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.charsets/share/classes/sun/nio/cs/ext/MS950_HKSCS.java.template Tue Dec 05 10:28:45 2017 +0000
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package $PACKAGE$;
+
+import java.nio.charset.Charset;
+import java.nio.charset.CharsetDecoder;
+import java.nio.charset.CharsetEncoder;
+import sun.nio.cs.HistoricallyNamedCharset;
+import sun.nio.cs.*;
+import static sun.nio.cs.CharsetMapping.*;
+
+public class MS950_HKSCS extends Charset implements HistoricallyNamedCharset
+{
+ public MS950_HKSCS() {
+ super("x-MS950-HKSCS", $ALIASES$);
+ }
+
+ public String historicalName() {
+ return "MS950_HKSCS";
+ }
+
+ public boolean contains(Charset cs) {
+ return ((cs.name().equals("US-ASCII"))
+ || (cs instanceof MS950)
+ || (cs instanceof MS950_HKSCS));
+ }
+
+ public CharsetDecoder newDecoder() {
+ return new Decoder(this);
+ }
+
+ public CharsetEncoder newEncoder() {
+ return new Encoder(this);
+ }
+
+ static class Decoder extends HKSCS.Decoder {
+ private static DoubleByte.Decoder ms950 =
+ (DoubleByte.Decoder)new MS950().newDecoder();
+
+ private static char[][] b2cBmp = new char[0x100][];
+ private static char[][] b2cSupp = new char[0x100][];
+ static {
+ initb2c(b2cBmp, HKSCSMapping.b2cBmpStr);
+ initb2c(b2cSupp, HKSCSMapping.b2cSuppStr);
+ }
+
+ private Decoder(Charset cs) {
+ super(cs, ms950, b2cBmp, b2cSupp);
+ }
+ }
+
+ private static class Encoder extends HKSCS.Encoder {
+ private static DoubleByte.Encoder ms950 =
+ (DoubleByte.Encoder)new MS950().newEncoder();
+
+ static char[][] c2bBmp = new char[0x100][];
+ static char[][] c2bSupp = new char[0x100][];
+ static {
+ initc2b(c2bBmp, HKSCSMapping.b2cBmpStr, HKSCSMapping.pua);
+ initc2b(c2bSupp, HKSCSMapping.b2cSuppStr, null);
+ }
+
+ private Encoder(Charset cs) {
+ super(cs, ms950, c2bBmp, c2bSupp);
+ }
+ }
+}
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.compiler/share/classes/com/sun/source/doctree/DocCommentTree.java
--- a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocCommentTree.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocCommentTree.java Tue Dec 05 10:28:45 2017 +0000
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, 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,6 +26,7 @@
package com.sun.source.doctree;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
/**
@@ -69,4 +70,39 @@
* @return the block tags of a documentation comment
*/
List extends DocTree> getBlockTags();
+
+ /**
+ * Returns a list of trees containing the content (if any) preceding
+ * the content of the documentation comment.
+ * When the {@code DocCommentTree} has been read from a documentation
+ * comment in a Java source file, the list will be empty.
+ * When the {@code DocCommentTree} has been read from an HTML file, this
+ * represents the content from the beginning of the file up to and
+ * including the {@code } tag.
+ *
+ * @implSpec This implementation returns an empty list.
+ *
+ * @return the list of trees
+ * @since 10
+ */
+ default List extends DocTree> getPreamble() {
+ return Collections.emptyList();
+ }
+
+ /**
+ * Returns a list of trees containing the content (if any) following the
+ * content of the documentation comment.
+ * When the {@code DocCommentTree} has been read from a documentation
+ * comment in a Java source file, the list will be empty.
+ * When {@code DocCommentTree} has been read from an HTML file, this
+ * represents the content from the {@code } tag to the end of file.
+ *
+ * @implSpec This implementation returns an empty list.
+ *
+ * @return the list of trees
+ * @since 10
+ */
+ default List extends DocTree> getPostamble() {
+ return Collections.emptyList();
+ }
}
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java
--- a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTree.java Tue Dec 05 10:28:45 2017 +0000
@@ -78,6 +78,12 @@
DOC_ROOT("docRoot"),
/**
+ * Used for instances of {@link DocTypeTree}
+ * representing an HTML DocType declaration.
+ */
+ DOC_TYPE,
+
+ /**
* Used for instances of {@link EndElementTree}
* representing the end of an HTML element.
*/
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java
--- a/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTreeVisitor.java Tue Dec 05 10:28:45 2017 +0000
@@ -105,6 +105,21 @@
R visitDocRoot(DocRootTree node, P p);
/**
+ * Visits a DocTypeTree node.
+ *
+ * @implSpec Visits a {@code DocTypeTree} node
+ * by calling {@code visitOther(node, p)}.
+ *
+ * @param node the node being visited
+ * @param p a parameter value
+ * @return a result value
+ * @since 10
+ */
+ default R visitDocType(DocTypeTree node, P p) {
+ return visitOther(node, p);
+ }
+
+ /**
* Visits an EndElementTree node.
* @param node the node being visited
* @param p a parameter value
@@ -130,11 +145,19 @@
/**
* Visits a HiddenTree node.
+ *
+ * @implSpec Visits a {@code HiddenTree} node
+ * by calling {@code visitOther(node, p)}.
+ *
* @param node the node being visited
* @param p a parameter value
* @return a result value
+ *
+ * @since 9
*/
- R visitHidden(HiddenTree node, P p);
+ default R visitHidden(HiddenTree node, P p) {
+ return visitOther(node, p);
+ }
/**
* Visits an IdentifierTree node.
@@ -146,11 +169,19 @@
/**
* Visits an IndexTree node.
+ *
+ * @implSpec Visits an {@code IndexTree} node
+ * by calling {@code visitOther(node, p)}.
+ *
* @param node the node being visited
* @param p a parameter value
* @return a result value
+ *
+ * @since 9
*/
- R visitIndex(IndexTree node, P p);
+ default R visitIndex(IndexTree node, P p) {
+ return visitOther(node, p);
+ }
/**
* Visits an InheritDocTree node.
@@ -186,11 +217,19 @@
/**
* Visits a ProvidesTree node.
+ *
+ * @implSpec Visits a {@code ProvidesTree} node
+ * by calling {@code visitOther(node, p)}.
+ *
* @param node the node being visited
* @param p a parameter value
* @return a result value
+ *
+ * @since 9
*/
- R visitProvides(ProvidesTree node, P p);
+ default R visitProvides(ProvidesTree node, P p) {
+ return visitOther(node, p);
+ }
/**
* Visits a ReferenceTree node.
@@ -267,7 +306,9 @@
* @return a result value
* @since 10
*/
- default R visitSummary(SummaryTree node, P p) { return visitOther(node, p);}
+ default R visitSummary(SummaryTree node, P p) {
+ return visitOther(node, p);
+ }
/**
* Visits a TextTree node.
@@ -303,11 +344,19 @@
/**
* Visits a UsesTree node.
+ *
+ * @implSpec Visits a {@code UsesTree} node
+ * by calling {@code visitOther(node, p)}.
+ *
* @param node the node being visited
* @param p a parameter value
* @return a result value
+ *
+ * @since 9
*/
- R visitUses(UsesTree node, P p);
+ default R visitUses(UsesTree node, P p) {
+ return visitOther(node, p);
+ }
/**
* Visits a ValueTree node.
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.compiler/share/classes/com/sun/source/doctree/DocTypeTree.java
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/doctree/DocTypeTree.java Tue Dec 05 10:28:45 2017 +0000
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.source.doctree;
+
+/**
+ * A tree node for a {@code doctype} declaration.
+ *
+ *
+ * <!doctype text>
+ *
+ * @since 10
+ */
+public interface DocTypeTree extends DocTree {
+ /**
+ * Returns the text of the doctype declaration.
+ * @return text
+ */
+ String getText();
+}
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeFactory.java Tue Dec 05 10:28:45 2017 +0000
@@ -39,6 +39,7 @@
import com.sun.source.doctree.DocCommentTree;
import com.sun.source.doctree.DocRootTree;
import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.DocTypeTree;
import com.sun.source.doctree.EndElementTree;
import com.sun.source.doctree.EntityTree;
import com.sun.source.doctree.ErroneousTree;
@@ -121,6 +122,20 @@
*/
DocCommentTree newDocCommentTree(List extends DocTree> fullBody, List extends DocTree> tags);
+
+ /**
+ * Create a new {@code DocCommentTree} object, to represent the enitire doc comment.
+ * @param fullBody the entire body of the doc comment
+ * @param tags the block tags in the doc comment
+ * @param preamble the meta content of an html file including the body tag
+ * @param postamble the meta content of an html including the closing body tag
+ * @return a {@code DocCommentTree} object
+ * @since 10
+ */
+ DocCommentTree newDocCommentTree(List extends DocTree> fullBody,
+ List extends DocTree> tags,
+ List extends DocTree> preamble,
+ List extends DocTree> postamble);
/**
* Create a new {@code DocRootTree} object, to represent an {@code {@docroot} } tag.
* @return a {@code DocRootTree} object
@@ -128,6 +143,14 @@
DocRootTree newDocRootTree();
/**
+ * Create a new {@code DocTypeTree}, to represent a {@code DOCTYPE} HTML declaration.
+ * @param text the content of the declaration
+ * @return a {@code CommentTree} object
+ * @since 10
+ */
+ DocTypeTree newDocTypeTree(String text);
+
+ /**
* Create a new {@code EndElement} object, to represent the end of an HTML element.
* @param name the name of the HTML element
* @return an {@code EndElementTree} object
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTreeScanner.java Tue Dec 05 10:28:45 2017 +0000
@@ -206,6 +206,18 @@
* @return the result of scanning
*/
@Override
+ public R visitDocType(DocTypeTree node, P p) {
+ return null;
+ }
+
+ /**
+ * {@inheritDoc} This implementation returns {@code null}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of scanning
+ */
+ @Override
public R visitEndElement(EndElementTree node, P p) {
return null;
}
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java
--- a/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/DocTrees.java Tue Dec 05 10:28:45 2017 +0000
@@ -98,13 +98,12 @@
/**
* Returns the doc comment tree of the given file. The file must be
* an HTML file, in which case the doc comment tree represents the
- * contents of the <body> tag, and any enclosing tags are ignored.
+ * entire contents of the file.
* Returns {@code null} if no doc comment was found.
* Future releases may support additional file types.
*
* @param fileObject the content container
* @return the doc comment tree
- *
* @since 9
*/
public abstract DocCommentTree getDocCommentTree(FileObject fileObject);
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java
--- a/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/source/util/SimpleDocTreeVisitor.java Tue Dec 05 10:28:45 2017 +0000
@@ -168,6 +168,19 @@
}
/**
+ * {@inheritDoc}
+ *
+ * @implSpec This implementation calls {@code defaultAction}.
+ *
+ * @param node {@inheritDoc}
+ * @param p {@inheritDoc}
+ * @return the result of {@code defaultAction}
+ * @since 10
+ */
+ @Override
+ public R visitDocType(DocTypeTree node, P p) { return defaultAction(node, p); }
+
+ /**
* {@inheritDoc} This implementation calls {@code defaultAction}.
*
* @param node {@inheritDoc}
@@ -175,9 +188,7 @@
* @return the result of {@code defaultAction}
*/
@Override
- public R visitEndElement(EndElementTree node, P p) {
- return defaultAction(node, p);
- }
+ public R visitEndElement(EndElementTree node, P p) { return defaultAction(node, p);}
/**
* {@inheritDoc} This implementation calls {@code defaultAction}.
@@ -209,6 +220,8 @@
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
+ *
+ * @since 9
*/
@Override
public R visitHidden(HiddenTree node, P p) {
@@ -233,6 +246,8 @@
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
+ *
+ * @since 9
*/
@Override
public R visitIndex(IndexTree node, P p) {
@@ -293,6 +308,8 @@
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
+ *
+ * @since 9
*/
@Override
public R visitProvides(ProvidesTree node, P p) {
@@ -462,6 +479,8 @@
* @param node {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
+ *
+ * @since 9
*/
@Override
public R visitUses(UsesTree node, P p) {
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/api/JavacTrees.java Tue Dec 05 10:28:45 2017 +0000
@@ -28,9 +28,8 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.BreakIterator;
-import java.util.HashMap;
+import java.util.Collections;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -59,6 +58,8 @@
import com.sun.source.doctree.DocCommentTree;
import com.sun.source.doctree.DocTree;
+import com.sun.source.doctree.EndElementTree;
+import com.sun.source.doctree.StartElementTree;
import com.sun.source.tree.CatchTree;
import com.sun.source.tree.CompilationUnitTree;
import com.sun.source.tree.Scope;
@@ -68,6 +69,7 @@
import com.sun.source.util.DocTreeScanner;
import com.sun.source.util.DocTrees;
import com.sun.source.util.JavacTask;
+import com.sun.source.util.SimpleDocTreeVisitor;
import com.sun.source.util.TreePath;
import com.sun.tools.javac.code.Flags;
import com.sun.tools.javac.code.Scope.NamedImportScope;
@@ -1006,16 +1008,7 @@
public String getText() {
try {
CharSequence rawDoc = fileObject.getCharContent(true);
- Pattern bodyPat =
- Pattern.compile("(?is).*?
]*>(.*)= 0) {
+ if (source.compareTo(Source.JDK9) >= 0) {
values.add(LintCategory.DEP_ANN);
}
values.add(LintCategory.REQUIRES_TRANSITIVE_AUTOMATIC);
diff -r 10b34c929b4f -r 64298b1e890b src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java Tue Dec 05 10:21:41 2017 +0000
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java Tue Dec 05 10:28:45 2017 +0000
@@ -31,7 +31,12 @@
import static javax.lang.model.SourceVersion.*;
import com.sun.tools.javac.jvm.Target;
+import com.sun.tools.javac.resources.CompilerProperties.Errors;
+import com.sun.tools.javac.resources.CompilerProperties.Fragments;
import com.sun.tools.javac.util.*;
+import com.sun.tools.javac.util.JCDiagnostic.Error;
+import com.sun.tools.javac.util.JCDiagnostic.Fragment;
+
import static com.sun.tools.javac.main.Option.*;
/** The source language version accepted.
@@ -59,22 +64,22 @@
/** 1.5 introduced generics, attributes, foreach, boxing, static import,
* covariant return, enums, varargs, et al. */
- JDK1_5("1.5"),
+ JDK5("5"),
/** 1.6 reports encoding problems as errors instead of warnings. */
- JDK1_6("1.6"),
+ JDK6("6"),
/** 1.7 introduced try-with-resources, multi-catch, string switch, etc. */
- JDK1_7("1.7"),
+ JDK7("7"),
/** 1.8 lambda expressions and default methods. */
- JDK1_8("1.8"),
+ JDK8("8"),
/** 1.9 modularity. */
- JDK1_9("1.9"),
+ JDK9("9"),
/** 1.10 covers the to be determined language features that will be added in JDK 10. */
- JDK1_10("1.10");
+ JDK10("10");
private static final Context.Key