This commit is contained in:
Jesper Wilhelmsson 2017-12-02 06:51:10 +01:00
commit 48d81c1e0c
286 changed files with 10129 additions and 2688 deletions

View File

@ -458,3 +458,4 @@ a6e591e12f122768f675428e1e5a838fd0e9c7ec jdk-10+29
e6278add9ff28fab70fe1cc4c1d65f7363dc9445 jdk-10+31
a2008587c13fa05fa2dbfcb09fe987576fbedfd1 jdk-10+32
bbd692ad4fa300ecca7939ffbe3b1d5e52a28cc6 jdk-10+33
89deac44e51517841491ba86ff44aa82a5ca96b3 jdk-10+34

View File

@ -177,7 +177,7 @@ ifneq ($(filter product-bundles, $(MAKECMDGOALS)), )
# Create special filter rules when dealing with unzipped .dSYM directories on
# macosx
ifeq ($(OPENJDK_TARGET_OS), macosx)
ifeq ($(ZIP_DEBUGINFO_FILES), false)
ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
JDK_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \
$(call containing, .dSYM/, $(patsubst $(JDK_IMAGE_DIR)/%, %, $(ALL_JDK_FILES))))
endif
@ -212,7 +212,7 @@ ifneq ($(filter product-bundles, $(MAKECMDGOALS)), )
# Create special filter rules when dealing with unzipped .dSYM directories on
# macosx
ifeq ($(OPENJDK_TARGET_OS), macosx)
ifeq ($(ZIP_DEBUGINFO_FILES), false)
ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), false)
JRE_SYMBOLS_EXCLUDE_PATTERN := $(addprefix %, \
$(call containing, .dSYM/, $(patsubst $(JRE_IMAGE_DIR)/%, %, $(ALL_JRE_FILES))))
endif

View File

@ -300,7 +300,9 @@ java.corba_EXCLUDE_FILES += \
################################################################################
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
################################################################################

View File

@ -47,7 +47,7 @@ ifeq ($(HAS_SPEC),)
# Make control variables, handled by Init.gmk
INIT_CONTROL_VARIABLES += LOG CONF CONF_NAME SPEC JOBS TEST_JOBS CONF_CHECK \
COMPARE_BUILD JTREG GTEST
COMPARE_BUILD JTREG GTEST TEST_OPTS TEST_VM_OPTS
# All known make control variables
MAKE_CONTROL_VARIABLES := $(INIT_CONTROL_VARIABLES) TEST JDK_FILTER

View File

@ -480,8 +480,7 @@ ALL_TARGETS += $(ALL_TEST_TARGETS) $(ALL_EXPLODED_TEST_TARGETS)
#
prepare-test-image:
$(MKDIR) -p $(TEST_IMAGE_DIR)
$(ECHO) > $(TEST_IMAGE_DIR)/Readme.txt 'JDK test image'
+($(CD) $(TOPDIR)/make && $(MAKE) $(MAKE_ARGS) -f TestImage.gmk prepare-test-image)
build-test-hotspot-jtreg-native:
+($(CD) $(TOPDIR)/make/test && $(MAKE) $(MAKE_ARGS) -f JtregNativeHotspot.gmk \
@ -1049,7 +1048,7 @@ ALL_TARGETS += default jdk images docs bundles all
# file.
CLEAN_DIRS += hotspot jdk bootcycle-build test buildtools support \
images make-support test-make bundles buildjdk
images make-support test-make bundles buildjdk test-results test-support
CLEAN_DIR_TARGETS := $(addprefix clean-, $(CLEAN_DIRS))
CLEAN_SUPPORT_DIRS += demos
CLEAN_SUPPORT_DIR_TARGETS := $(addprefix clean-, $(CLEAN_SUPPORT_DIRS))
@ -1094,6 +1093,8 @@ $(CLEAN_MODULE_PHASE_TARGETS):
# while classes and touch files end up in jdk.
clean-support: clean-jdk
clean-test: clean-test-results clean-test-support
# Remove everything, including configure configuration. If the output
# directory was created by configure and now becomes empty, remove it as well.
dist-clean: clean

View File

@ -32,17 +32,77 @@ include FindTests.gmk
# We will always run multiple tests serially
.NOTPARALLEL:
################################################################################
# Parse global control variables
################################################################################
ifneq ($(TEST_VM_OPTS), )
ifneq ($(TEST_OPTS), )
TEST_OPTS := $(TEST_OPTS);VM_OPTIONS=$(TEST_VM_OPTS)
else
TEST_OPTS := VM_OPTIONS=$(TEST_VM_OPTS)
endif
endif
$(eval $(call ParseKeywordVariable, TEST_OPTS, \
KEYWORDS := JOBS TIMEOUT, \
STRING_KEYWORDS := VM_OPTIONS, \
))
# Helper function to propagate TEST_OPTS values.
#
# Note: No spaces are allowed around the arguments.
# Arg $1 The variable in TEST_OPTS to propagate
# Arg $2 The control variable to propagate it to
define SetTestOpt
ifneq ($$(TEST_OPTS_$1), )
$2_$1 := $$(TEST_OPTS_$1)
endif
endef
################################################################################
# Hook to include the corresponding custom file, if present.
$(eval $(call IncludeCustomExtension, RunTests.gmk))
################################################################################
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)
else
JTREG_TOPDIR := $(CUSTOM_ROOT)
endif
JTREG_FAILURE_HANDLER_DIR := $(TEST_IMAGE_DIR)/failure_handler
JTREG_FAILURE_HANDLER := $(JTREG_FAILURE_HANDLER_DIR)/jtregFailureHandler.jar
ifneq ($(wildcard $(JTREG_FAILURE_HANDLER)), )
JTREG_FAILURE_HANDLER_OPTIONS := \
-timeoutHandlerDir:$(JTREG_FAILURE_HANDLER) \
-observerDir:$(JTREG_FAILURE_HANDLER) \
-timeoutHandler:jdk.test.failurehandler.jtreg.GatherProcessInfoTimeoutHandler \
-observer:jdk.test.failurehandler.jtreg.GatherDiagnosticInfoObserver \
-timeoutHandlerTimeout:0
endif
################################################################################
# Parse control variables
################################################################################
ifneq ($(TEST_OPTS), )
# Inform the user
$(info Running tests using TEST_OPTS control variable '$(TEST_OPTS)')
$(eval $(call SetTestOpt,VM_OPTIONS,JTREG))
$(eval $(call SetTestOpt,VM_OPTIONS,GTEST))
$(eval $(call SetTestOpt,JOBS,JTREG))
$(eval $(call SetTestOpt,TIMEOUT,JTREG))
endif
$(eval $(call ParseKeywordVariable, JTREG, \
KEYWORDS := JOBS TIMEOUT TEST_MODE ASSERT VERBOSE RETAIN MAX_MEM, \
STRING_KEYWORDS := OPTIONS JAVA_OPTIONS VM_OPTIONS, \
@ -55,7 +115,7 @@ endif
$(eval $(call ParseKeywordVariable, GTEST, \
KEYWORDS := REPEAT, \
STRING_KEYWORDS := OPTIONS, \
STRING_KEYWORDS := OPTIONS VM_OPTIONS, \
))
ifneq ($(GTEST), )
@ -84,6 +144,11 @@ hotspot_JTREG_ASSERT := false
hotspot_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/hotspot/jtreg/native
jdk_JTREG_NATIVEPATH := $(TEST_IMAGE_DIR)/jdk/jtreg/native
jdk_JTREG_PROBLEM_LIST += $(TOPDIR)/test/jdk/ProblemList.txt
jaxp_JTREG_PROBLEM_LIST += $(TOPDIR)/test/jaxp/ProblemList.txt
langtools_JTREG_PROBLEM_LIST += $(TOPDIR)/test/langtools/ProblemList.txt
nashorn_JTREG_PROBLEM_LIST += $(TOPDIR)/test/nashorn/ProblemList.txt
hotspot_JTREG_PROBLEM_LIST += $(TOPDIR)/test/hotspot/jtreg/ProblemList.txt
################################################################################
# Parse test selection
@ -116,17 +181,23 @@ define ParseGtestTestSelection
)
endef
# Helper function that removes the TOPDIR part
CleanupJtregPath = \
$(strip $(patsubst %/, %, $(subst $(JTREG_TOPDIR)/,, $1)))
# Take a partial Jtreg root path and return a full, absolute path to that Jtreg
# root. Also support having "hotspot" as an alias for "hotspot/jtreg".
ExpandJtregRoot = \
$(strip $(wildcard $(patsubst %/, %, \
$(call CleanupJtregPath, $(wildcard \
$(if $(filter /%, $1), \
$1 \
$(if $(wildcard $(strip $1)/TEST.ROOT), \
$1 \
) \
, \
$(filter $(addprefix %, $1), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \
$(filter $(addprefix %, $(strip $1)/jtreg), $(JTREG_TESTROOTS) $(addsuffix /, $(JTREG_TESTROOTS))) \
) \
)))
))
# Take a partial Jtreg test path and return a full, absolute path to that Jtreg
# test. Also support having "hotspot" as an alias for "hotspot/jtreg".
@ -134,14 +205,14 @@ ExpandJtregPath = \
$(if $(call ExpandJtregRoot, $1), \
$(call ExpandJtregRoot, $1) \
, \
$(strip $(wildcard $(patsubst %/, %, \
$(call CleanupJtregPath, $(wildcard \
$(if $(filter /%, $1), \
$1 \
, \
$(addsuffix /$(strip $1), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \
$(addsuffix $(strip $(patsubst hotspot/%, /hotspot/jtreg/%, $1)), $(JTREG_TESTROOTS) $(TEST_BASEDIRS)) \
) \
))) \
)) \
)
# Helper function to determine if a test specification is a Jtreg test
@ -158,27 +229,26 @@ define ParseJtregTestSelection
$(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)))) \
$(eval TEST_ROOTS := $(call ExpandJtregRoot, $(TEST_PATH))) \
) \
$(foreach test_root, $(TEST_ROOTS), \
$(if $(filter $(TEST_GROUP), $($(test_root)_JTREG_TEST_GROUPS)), \
$(if $(filter /%, $(test_root)), \
jtreg:$(test_root):$(TEST_GROUP) \
, \
$(if $(filter $(TEST_GROUP), $($(JTREG_TOPDIR)/$(test_root)_JTREG_TEST_GROUPS)), \
jtreg:$(test_root):$(TEST_GROUP) \
) \
) \
) \
, \
$(if $(filter /%, $(TEST_NAME)), \
$(if $(wildcard $(TEST_NAME)), \
jtreg:$(TEST_NAME) \
) \
, \
$(eval TEST_PATHS := $(call ExpandJtregPath, $(TEST_NAME))) \
$(foreach test_path, $(TEST_PATHS), \
jtreg:$(test_path) \
) \
$(eval TEST_PATHS := $(call ExpandJtregPath, $(TEST_NAME))) \
$(foreach test_path, $(TEST_PATHS), \
jtreg:$(test_path) \
) \
)
endef
@ -248,6 +318,7 @@ SetupRunGtestTest = $(NamedParamsMacroTemplate)
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)))
ifneq ($$($1_TEST_NAME), all)
@ -264,10 +335,13 @@ define SetupRunGtestTestBody
$$(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) \
> >($(TEE) $$($1_TEST_RESULTS_DIR)/gtest.txt) || true )
-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
@ -275,15 +349,24 @@ define SetupRunGtestTestBody
$$(call LogWarn, Finished running test '$$($1_TEST)')
$$(call LogWarn, Test report is stored in $$(strip \
$$(subst $$(TOPDIR)/, , $$($1_TEST_RESULTS_DIR))))
$$(eval $1_TOTAL := $$(shell $$(AWK) '/==========.* tests? from .* \
test cases? ran/ { print $$$$2 }' $$($1_RESULT_FILE)))
$$(eval $1_PASSED := $$(shell $$(AWK) '/\[ PASSED \] .* tests?./ \
{ print $$$$4 }' $$($1_RESULT_FILE)))
$$(eval $1_FAILED := $$(shell $$(AWK) '/\[ FAILED \] .* tests?, \
listed below/ { print $$$$4 }' $$($1_RESULT_FILE)))
$$(if $$($1_FAILED), , $$(eval $1_FAILED := 0))
$$(eval $1_ERROR := $$(shell \
$$(EXPR) $$($1_TOTAL) - $$($1_PASSED) - $$($1_FAILED)))
$$(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)) \
$$(eval $1_PASSED := $$(shell $$(AWK) '/\[ PASSED \] .* tests?./ \
{ print $$$$4 }' $$($1_RESULT_FILE))) \
$$(if $$($1_PASSED), , $$(eval $1_PASSED := 0)) \
$$(eval $1_FAILED := $$(shell $$(AWK) '/\[ FAILED \] .* tests?, \
listed below/ { print $$$$4 }' $$($1_RESULT_FILE))) \
$$(if $$($1_FAILED), , $$(eval $1_FAILED := 0)) \
$$(eval $1_ERROR := $$(shell \
$$(EXPR) $$($1_TOTAL) - $$($1_PASSED) - $$($1_FAILED))) \
, \
$$(eval $1_PASSED := 0) \
$$(eval $1_FAILED := 0) \
$$(eval $1_ERROR := 1) \
$$(eval $1_TOTAL := 1) \
)
$1: run-test-$1 parse-test-$1
@ -321,12 +404,13 @@ SetupRunJtregTest = $(NamedParamsMacroTemplate)
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)))
$1_COMPONENT := \
$$(strip $$(foreach root, $$(JTREG_TESTROOTS), \
$$(if $$(filter $$(root)%, $$($1_TEST_NAME)), \
$$(if $$(filter $$(root)%, $$(JTREG_TOPDIR)/$$($1_TEST_NAME)), \
$$(lastword $$(subst /, $$(SPACE), $$(root))) \
) \
))
@ -350,6 +434,7 @@ define SetupRunJtregTestBody
$$(eval $$(call SetJtregValue,$1,JTREG_MAX_MEM,512m))
$$(eval $$(call SetJtregValue,$1,JTREG_NATIVEPATH))
$$(eval $$(call SetJtregValue,$1,JTREG_BASIC_OPTIONS))
$$(eval $$(call SetJtregValue,$1,JTREG_PROBLEM_LIST))
ifneq ($(TEST_JOBS), 0)
# User has specified TEST_JOBS, use that as fallback default
@ -359,11 +444,6 @@ define SetupRunJtregTestBody
$$(eval $$(call SetJtregValue,$1,JTREG_JOBS,$$(JOBS)))
endif
ifeq ($$(shell $$(EXPR) $$($1_JTREG_JOBS) \> 50), 1)
# Until CODETOOLS-7901892 is fixed, JTreg cannot handle more than 50 jobs
$1_JTREG_JOBS := 50
endif
# Make sure MaxRAMPercentage is high enough to not cause OOM or swapping since
# we may end up with a lot of JVM's
$1_JTREG_MAX_RAM_PERCENTAGE := $$(shell $$(EXPR) 25 / $$($1_JTREG_JOBS))
@ -403,11 +483,22 @@ define SetupRunJtregTestBody
$1_JTREG_BASIC_OPTIONS += -nativepath:$$($1_JTREG_NATIVEPATH)
endif
ifneq ($$($1_JTREG_PROBLEM_LIST), )
$1_JTREG_BASIC_OPTIONS += $$(addprefix -exclude:, $$($1_JTREG_PROBLEM_LIST))
endif
ifneq ($$(JIB_JAR), )
$1_JTREG_BASIC_OPTIONS += -cpa:$$(JIB_JAR)
endif
run-test-$1:
ifneq ($$(JTREG_FAILURE_HANDLER_OPTIONS), )
$1_JTREG_LAUNCHER_OPTIONS += -Djava.library.path="$(JTREG_FAILURE_HANDLER_DIR)"
endif
clean-workdir-$1:
$$(RM) -r $$($1_TEST_SUPPORT_DIR)
run-test-$1: clean-workdir-$1
$$(call LogWarn)
$$(call LogWarn, Running test '$$($1_TEST)')
$$(call MakeDir, $$($1_TEST_RESULTS_DIR) $$($1_TEST_SUPPORT_DIR))
@ -416,11 +507,15 @@ define SetupRunJtregTestBody
-Dprogram=jtreg -jar $$(JT_HOME)/lib/jtreg.jar \
$$($1_JTREG_BASIC_OPTIONS) \
-testjdk:$$(JDK_IMAGE_DIR) \
-dir:$$(TOPDIR) \
-dir:$$(JTREG_TOPDIR) \
-reportDir:$$($1_TEST_RESULTS_DIR) \
-workDir:$$($1_TEST_SUPPORT_DIR) \
$$(JTREG_OPTIONS) \
$$($1_TEST_NAME) || true )
$$(JTREG_FAILURE_HANDLER_OPTIONS) \
$$($1_TEST_NAME) \
&& $$(ECHO) $$$$? > $$($1_EXITCODE) \
|| $$(ECHO) $$$$? > $$($1_EXITCODE) \
)
$1_RESULT_FILE := $$($1_TEST_RESULTS_DIR)/text/stats.txt
@ -428,7 +523,7 @@ define SetupRunJtregTestBody
$$(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))) \
@ -470,7 +565,7 @@ UseJtregTestHandler = \
# 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), \
@ -504,35 +599,49 @@ endif
TEST_FAILURE := false
run-test: $(TARGETS)
# Print a table of the result of all tests run and their result
$(ECHO)
$(ECHO) ==============================
$(ECHO) Test summary
$(ECHO) ==============================
$(PRINTF) "%2s %-49s %5s %5s %5s %5s %2s\n" " " TEST \
TOTAL PASS FAIL ERROR " "
# 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) ==============================
$(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s %5s %5s %5s %5s %2s\n" " " \
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' '_')) \
$(if $(filter $($(TEST_ID)_PASSED), $($(TEST_ID)_TOTAL)), \
$(PRINTF) "%2s %-49s %5d %5d %5d %5d %2s\n" " " "$(test)" \
$($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) $($(TEST_ID)_FAILED) \
$($(TEST_ID)_ERROR) " " $(NEWLINE) \
$(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) \
, \
$(PRINTF) "%2s %-49s %5d %5d %5d %5d %2s\n" ">>" "$(test)" \
$($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) $($(TEST_ID)_FAILED) \
$($(TEST_ID)_ERROR) "<<" $(NEWLINE) \
$(eval TEST_NAME := $(test)) \
) \
$(if $(filter $($(TEST_ID)_PASSED), $($(TEST_ID)_TOTAL)), \
$(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s %5d %5d %5d %5d %2s\n" \
" " "$(TEST_NAME)" $($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) \
$($(TEST_ID)_FAILED) $($(TEST_ID)_ERROR) " " $(NEWLINE) \
, \
$(PRINTF) >> $(TEST_SUMMARY) "%2s %-49s %5d %5d %5d %5d %2s\n" \
">>" "$(TEST_NAME)" $($(TEST_ID)_TOTAL) $($(TEST_ID)_PASSED) \
$($(TEST_ID)_FAILED) $($(TEST_ID)_ERROR) "<<" $(NEWLINE) \
$(eval TEST_FAILURE := true) \
) \
)
$(ECHO) ==============================
$(ECHO) >> $(TEST_SUMMARY) ==============================
$(if $(filter true, $(TEST_FAILURE)), \
$(ECHO) TEST FAILURE $(NEWLINE) \
$(ECHO) >> $(TEST_SUMMARY) TEST FAILURE $(NEWLINE) \
$(MKDIR) -p $(MAKESUPPORT_OUTPUTDIR) $(NEWLINE) \
$(TOUCH) $(MAKESUPPORT_OUTPUTDIR)/exit-with-error \
, \
$(ECHO) TEST SUCCESS \
$(ECHO) >> $(TEST_SUMMARY) TEST SUCCESS \
)
$(ECHO)
$(CAT) $(TEST_SUMMARY)
$(ECHO)
################################################################################

46
make/TestImage.gmk Normal file
View File

@ -0,0 +1,46 @@
#
# 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.
#
default: all
include $(SPEC)
include MakeBase.gmk
############################################################################
ifeq ($(OPENJDK_TARGET_OS), windows)
FIXPATH_COPY := $(TEST_IMAGE_DIR)/bin/fixpath.exe
$(FIXPATH_COPY): $(firstword $(FIXPATH))
$(call install-file)
endif
prepare-test-image: $(FIXPATH_COPY)
$(call MakeDir, $(TEST_IMAGE_DIR))
$(ECHO) > $(TEST_IMAGE_DIR)/Readme.txt 'JDK test image'
all: prepare-test-image
.PHONY: default all prepare-test-image

View File

@ -1092,10 +1092,6 @@ AC_DEFUN_ONCE([BASIC_SETUP_COMPLEX_TOOLS],
# 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)

File diff suppressed because it is too large Load Diff

View File

@ -296,13 +296,13 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_DEBUG_SYMBOLS],
],
[
if test "x$OPENJDK_TARGET_OS" = xaix; then
# AIX doesn't support 'zipped' so use 'internal' as default
# AIX doesn't support 'external' so use 'internal' as default
with_native_debug_symbols="internal"
else
if test "x$STATIC_BUILD" = xtrue; then
with_native_debug_symbols="none"
else
with_native_debug_symbols="zipped"
with_native_debug_symbols="external"
fi
fi
])

View File

@ -443,20 +443,31 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE],
fi
AC_MSG_RESULT([$BUNDLE_FREETYPE])
fi # end freetype needed
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])
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
fi
fi # end freetype needed
AC_SUBST(FREETYPE_BUNDLE_LIB_PATH)
AC_SUBST(FREETYPE_CFLAGS)

View File

@ -471,6 +471,7 @@ GNM:=@GNM@
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)
@ -565,12 +566,10 @@ BUILD_JAVA_FLAGS := @BOOTCYCLE_JVM_ARGS_BIG@
BUILD_JAVA=@FIXPATH@ $(BUILD_JDK)/bin/java $(BUILD_JAVA_FLAGS)
# Interim langtools and rmic modules and arguments
INTERIM_LANGTOOLS_BASE_MODULES := java.compiler jdk.compiler jdk.jdeps jdk.javadoc
INTERIM_LANGTOOLS_BASE_MODULES := java.compiler jdk.compiler jdk.javadoc
INTERIM_LANGTOOLS_MODULES := $(addsuffix .interim, $(INTERIM_LANGTOOLS_BASE_MODULES))
INTERIM_LANGTOOLS_ADD_EXPORTS := \
--add-exports java.base/sun.reflect.annotation=jdk.compiler.interim \
--add-exports java.base/jdk.internal.util.jar=jdk.jdeps.interim \
--add-exports java.base/jdk.internal.misc=jdk.jdeps.interim \
#
INTERIM_LANGTOOLS_MODULES_COMMA := $(strip $(subst $(SPACE),$(COMMA),$(strip \
$(INTERIM_LANGTOOLS_MODULES))))

View File

@ -628,6 +628,10 @@ AC_DEFUN_ONCE([TOOLCHAIN_DETECT_TOOLCHAIN_EXTRA],
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

View File

@ -429,7 +429,7 @@ var getJibProfilesProfiles = function (input, common, data) {
"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 @@ var getJibProfilesProfiles = function (input, common, data) {
}
});
// 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 getJibProfilesDependencies = function (input, common) {
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 @@ var getJibProfilesDependencies = function (input, common) {
freetype: {
organization: common.organization,
ext: "tar.gz",
revision: "2.7.1-v120+1.0",
revision: freetype_version,
module: "freetype-" + input.target_platform
},

View File

@ -44,7 +44,8 @@ $(INCLUDE_DST_OS_DIR)/%.h: \
################################################################################
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 @@ ifneq ($(FREETYPE_BUNDLE_LIB_PATH), )
#
#TODO: rework this to avoid hardcoding library name in the makefile
#
ifeq ($(OPENJDK_TARGET_OS), windows)
FREETYPE_TARGET_LIB := $(LIB_DST_DIR)/$(call SHARED_LIBRARY,freetype)
else
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)
endif
# We can't use $(install-file) in this rule because it preserves symbolic links and

View File

@ -492,7 +492,7 @@ charset x-MS950-HKSCS-XP MS950_HKSCS_XP
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;

View File

@ -13,4 +13,5 @@ SJIS # SJIS must go together with MS932 to support sun.nio.cs.map
MS936
MS949
MS950
MS950_HKSCS
MS950_HKSCS_XP

View File

@ -49,13 +49,13 @@ COMPILECREATESYMBOLS_ADD_EXPORTS := \
--add-exports jdk.compiler.interim/com.sun.tools.javac.code=ALL-UNNAMED \
--add-exports jdk.compiler.interim/com.sun.tools.javac.util=ALL-UNNAMED \
--add-exports jdk.compiler.interim/com.sun.tools.javac.jvm=ALL-UNNAMED \
--add-exports jdk.jdeps.interim/com.sun.tools.classfile=ALL-UNNAMED \
#
$(eval $(call SetupJavaCompilation, COMPILE_CREATE_SYMBOLS, \
SETUP := GENERATE_OLDBYTECODE, \
SRC := $(TOPDIR)/make/langtools/src/classes, \
INCLUDES := build/tools/symbolgenerator, \
SRC := $(TOPDIR)/make/langtools/src/classes \
$(TOPDIR)/src/jdk.jdeps/share/classes, \
INCLUDES := build/tools/symbolgenerator com/sun/tools/classfile, \
BIN := $(BUILDTOOLS_OUTPUTDIR)/create_symbols, \
ADD_JAVAC_FLAGS := $(INTERIM_LANGTOOLS_ARGS) \
$(COMPILECREATESYMBOLS_ADD_EXPORTS), \

View File

@ -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_ActiveProcessorCount
JVM_ArrayCopy
JVM_AssertionStatusDirectives
JVM_CallStackWalk
JVM_ClassDepth
JVM_ClassLoaderDepth
JVM_Clone
JVM_ConstantPoolGetClassAt
JVM_ConstantPoolGetClassAtIfLoaded
@ -47,8 +45,6 @@ JVM_ConstantPoolGetStringAt
JVM_ConstantPoolGetTagAt
JVM_ConstantPoolGetUTF8At
JVM_CountStackFrames
JVM_CurrentClassLoader
JVM_CurrentLoadedClass
JVM_CurrentThread
JVM_CurrentTimeMillis
JVM_DefineClass

View File

@ -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 @@ public class Main {
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 @@ public class Main {
}
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 @@ public class Main {
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",

View File

@ -658,7 +658,7 @@ endif
$(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 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBFONTMANAGER, \
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))

View File

@ -205,10 +205,6 @@ SUNWprivate_1.1 {
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;

View File

@ -115,11 +115,11 @@
</target>
<!-- check minimum ant version required to be 1.8.4 -->
<!-- check minimum ant version required to be 1.9.5 -->
<target name="check-ant-version">
<property name="ant.version.required" value="1.8.4"/>
<property name="ant.version.required" value="1.9.5"/>
<antversion property="ant.current.version" />
<fail message="The current ant version, ${ant.current.version}, is too old. Please use 1.8.4 or above.">
<fail message="The current ant version, ${ant.current.version}, is too old. Please use 1.9.5 or above.">
<condition>
<not>
<antversion atleast="${ant.version.required}"/>

View File

@ -3129,64 +3129,6 @@ JVM_END
// 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);
@ -3226,58 +3168,6 @@ JVM_ENTRY(jobjectArray, JVM_GetClassContext(JNIEnv *env))
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 ////////////////////////////////////////////////////////////////

View File

@ -1813,7 +1813,7 @@ public abstract class ClassLoader {
}
/**
* Returns the platform class loader for delegation. All
* Returns the platform class loader. All
* <a href="#builtinLoaders">platform classes</a> are visible to
* the platform class loader.
*
@ -1843,7 +1843,7 @@ public abstract class ClassLoader {
}
/**
* Returns the system class loader for delegation. This is the default
* Returns the system class loader. This is the default
* delegation parent for new {@code ClassLoader} instances, and is
* typically the class loader used to start the application.
*
@ -1884,7 +1884,7 @@ public abstract class ClassLoader {
* the application module path then the class path defaults to
* the current working directory.
*
* @return The system {@code ClassLoader} for delegation
* @return The system {@code ClassLoader}
*
* @throws SecurityException
* If a security manager is present, and the caller's class loader

View File

@ -101,7 +101,7 @@ import sun.security.util.SecurityConstants;
* <code>checkPermission</code> returns quietly. If denied, a
* <code>SecurityException</code> is thrown.
* <p>
* As of Java 2 SDK v1.2, the default implementation of each of the other
* The default implementation of each of the other
* <code>check</code> methods in <code>SecurityManager</code> is to
* call the <code>SecurityManager checkPermission</code> method
* to determine if the calling thread has permission to perform the requested
@ -197,10 +197,10 @@ import sun.security.util.SecurityConstants;
* 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
* <code>check</code> 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 @@ import sun.security.util.SecurityConstants;
*
* @since 1.0
*/
public
class SecurityManager {
/**
* This field is <code>true</code> if there is a security check in
* progress; <code>false</code> otherwise.
*
* @deprecated This type of security checking is not recommended.
* It is recommended that the <code>checkPermission</code>
* 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.
@ -261,24 +248,6 @@ class SecurityManager {
}
}
/**
* Tests if there is a security check in progress.
*
* @return the value of the <code>inCheck</code> field. This field
* should contain <code>true</code> if a security check is
* in progress,
* <code>false</code> otherwise.
* @see java.lang.SecurityManager#inCheck
* @deprecated This type of security checking is not recommended.
* It is recommended that the <code>checkPermission</code>
* 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 <code>SecurityManager</code>.
*
@ -321,198 +290,6 @@ class SecurityManager {
*/
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.
* <p>
* This method will return
* <code>null</code> in the following three cases:
* <ol>
* <li>All methods on the execution stack are from classes
* defined using the system class loader or one of its ancestors.
*
* <li>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.
*
* <li> A call to <code>checkPermission</code> with
* <code>java.security.AllPermission</code> does not
* result in a SecurityException.
*
* </ol>
*
* @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 <code>checkPermission</code>
* 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.
* <p>
* This method will return
* <code>null</code> in the following three cases:
* <ol>
* <li>All methods on the execution stack are from classes
* defined using the system class loader or one of its ancestors.
*
* <li>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.
*
* <li> A call to <code>checkPermission</code> with
* <code>java.security.AllPermission</code> does not
* result in a SecurityException.
*
* </ol>
*
* @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 <code>checkPermission</code>
* 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;
* <code>-1</code> if such a frame cannot be found.
* @deprecated This type of security checking is not recommended.
* It is recommended that the <code>checkPermission</code>
* 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.
* <p>
* This method will return
* -1 in the following three cases:
* <ol>
* <li>All methods on the execution stack are from classes
* defined using the system class loader or one of its ancestors.
*
* <li>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.
*
* <li> A call to <code>checkPermission</code> with
* <code>java.security.AllPermission</code> does not
* result in a SecurityException.
*
* </ol>
*
* @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 <code>checkPermission</code>
* 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 <code>true</code> if a method from a class with the specified
* name is on the execution stack; <code>false</code> otherwise.
* @deprecated This type of security checking is not recommended.
* It is recommended that the <code>checkPermission</code>
* 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 <code>true</code> if a call to <code>currentClassLoader</code>
* has a non-null return value.
*
* @deprecated This type of security checking is not recommended.
* It is recommended that the <code>checkPermission</code>
* 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
@ -1698,64 +1475,32 @@ class SecurityManager {
}
/**
* Throws a <code>SecurityException</code> if the
* calling thread is not allowed to access members.
* <p>
* 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 <code>checkPermission</code>
* with the <code>RuntimePermission("accessDeclaredMembers")
* </code> permission.
* <p>
* If this method is overridden, then a call to
* <code>super.checkMemberAccess</code> cannot be made,
* as the default implementation of <code>checkMemberAccess</code>
* 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 <code>clazz</code> argument is
* <code>null</code>.
*
* @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 @@ class SecurityManager {
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.

View File

@ -263,8 +263,12 @@ public final class LambdaMetafactory {
* methods from {@code Object}.
*
* @param caller Represents a lookup context with the accessibility
* privileges of the caller. When used with {@code invokedynamic},
* this is stacked automatically by the VM.
* privileges of the caller. Specifically, the lookup context
* must have
* <a href="MethodHandles.Lookup.html#privacc">private access</a>
* privileges.
* When used with {@code invokedynamic}, this is stacked
* automatically by the VM.
* @param invokedName The name of the method to implement. When used with
* {@code invokedynamic}, this is provided by the
* {@code NameAndType} of the {@code InvokeDynamic}
@ -294,7 +298,8 @@ public final class LambdaMetafactory {
* instances of the interface named by {@code invokedType}
* @throws LambdaConversionException If any of the linkage invariants
* described {@link LambdaMetafactory above}
* are violated
* are violated, or the lookup context
* does not have private access privileges.
*/
public static CallSite metafactory(MethodHandles.Lookup caller,
String invokedName,
@ -404,8 +409,12 @@ public final class LambdaMetafactory {
* </ul>
*
* @param caller Represents a lookup context with the accessibility
* privileges of the caller. When used with {@code invokedynamic},
* this is stacked automatically by the VM.
* privileges of the caller. Specifically, the lookup context
* must have
* <a href="MethodHandles.Lookup.html#privacc">private access</a>
* privileges.
* When used with {@code invokedynamic}, this is stacked
* automatically by the VM.
* @param invokedName The name of the method to implement. When used with
* {@code invokedynamic}, this is provided by the
* {@code NameAndType} of the {@code InvokeDynamic}
@ -429,7 +438,8 @@ public final class LambdaMetafactory {
* instances of the interface named by {@code invokedType}
* @throws LambdaConversionException If any of the linkage invariants
* described {@link LambdaMetafactory above}
* are violated
* are violated, or the lookup context
* does not have private access privileges.
*/
public static CallSite altMetafactory(MethodHandles.Lookup caller,
String invokedName,

View File

@ -385,9 +385,16 @@ public final class StringConcatFactory {
* invoked, it returns the result of String concatenation, taking all
* function arguments passed to the linkage method as inputs for
* concatenation. The target signature is given by {@code concatType}.
* The arguments are concatenated as per requirements stated in JLS 15.18.1
* "String Concatenation Operator +". Notably, the inputs are converted as
* per JLS 5.1.11 "String Conversion", and combined from left to right.
* For a target accepting:
* <ul>
* <li>zero inputs, concatenation results in an empty string;</li>
* <li>one input, concatenation results in the single
* input converted as per JLS 5.1.11 "String Conversion"; otherwise</li>
* <li>two or more inputs, the inputs are concatenated as per
* requirements stated in JLS 15.18.1 "String Concatenation Operator +".
* The inputs are converted as per JLS 5.1.11 "String Conversion",
* and combined from left to right.</li>
* </ul>
*
* <p>Assume the linkage arguments are as follows:
*
@ -404,8 +411,12 @@ public final class StringConcatFactory {
* </ul>
*
* @param lookup Represents a lookup context with the accessibility
* privileges of the caller. When used with {@code
* invokedynamic}, this is stacked automatically by the VM.
* privileges of the caller. Specifically, the lookup
* context must have
* <a href="MethodHandles.Lookup.html#privacc">private access</a>
* privileges.
* When used with {@code invokedynamic}, this is stacked
* automatically by the VM.
* @param name The name of the method to implement. This name is
* arbitrary, and has no meaning for this linkage method.
* When used with {@code invokedynamic}, this is provided by
@ -422,7 +433,8 @@ public final class StringConcatFactory {
* concatenation, with dynamic concatenation arguments described by the given
* {@code concatType}.
* @throws StringConcatException If any of the linkage invariants described
* here are violated.
* here are violated, or the lookup context
* does not have private access privileges.
* @throws NullPointerException If any of the incoming arguments is null.
* This will never happen when a bootstrap method
* is called with invokedynamic.
@ -452,10 +464,17 @@ public final class StringConcatFactory {
* invoked, it returns the result of String concatenation, taking all
* function arguments and constants passed to the linkage method as inputs for
* concatenation. The target signature is given by {@code concatType}, and
* does not include constants. The arguments are concatenated as per requirements
* stated in JLS 15.18.1 "String Concatenation Operator +". Notably, the inputs
* are converted as per JLS 5.1.11 "String Conversion", and combined from left
* to right.
* does not include constants.
* For a target accepting:
* <ul>
* <li>zero inputs, concatenation results in an empty string;</li>
* <li>one input, concatenation results in the single
* input converted as per JLS 5.1.11 "String Conversion"; otherwise</li>
* <li>two or more inputs, the inputs are concatenated as per
* requirements stated in JLS 15.18.1 "String Concatenation Operator +".
* The inputs are converted as per JLS 5.1.11 "String Conversion",
* and combined from left to right.</li>
* </ul>
*
* <p>The concatenation <em>recipe</em> is a String description for the way to
* construct a concatenated String from the arguments and constants. The
@ -502,9 +521,12 @@ public final class StringConcatFactory {
* </ul>
*
* @param lookup Represents a lookup context with the accessibility
* privileges of the caller. When used with {@code
* invokedynamic}, this is stacked automatically by the
* VM.
* privileges of the caller. Specifically, the lookup
* context must have
* <a href="MethodHandles.Lookup.html#privacc">private access</a>
* privileges.
* When used with {@code invokedynamic}, this is stacked
* automatically by the VM.
* @param name The name of the method to implement. This name is
* arbitrary, and has no meaning for this linkage method.
* When used with {@code invokedynamic}, this is provided
@ -524,7 +546,8 @@ public final class StringConcatFactory {
* concatenation, with dynamic concatenation arguments described by the given
* {@code concatType}.
* @throws StringConcatException If any of the linkage invariants described
* here are violated.
* here are violated, or the lookup context
* does not have private access privileges.
* @throws NullPointerException If any of the incoming arguments is null, or
* any constant in {@code recipe} is null.
* This will never happen when a bootstrap method

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, 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
@ -32,9 +32,12 @@ import java.security.*;
*
* <p>The {@code initialize} methods may each be called any number
* of times. If no {@code initialize} method is called on a
* DSAKeyPairGenerator, the default is to generate 1024-bit keys, using
* precomputed p, q and g parameters and an instance of SecureRandom as
* the random bit source.
* DSAKeyPairGenerator, each provider that implements this interface
* should supply (and document) a default initialization. Note that
* defaults may vary across different providers. Additionally, the default
* value for a provider may change in a future version. Therefore, it is
* recommended to explicitly initialize the DSAKeyPairGenerator instead
* of relying on provider-specific defaults.
*
* <p>Users wishing to indicate DSA-specific parameters, and to generate a key
* pair suitable for use with the DSA algorithm typically
@ -45,12 +48,13 @@ import java.security.*;
* KeyPairGenerator {@code getInstance} method with "DSA"
* as its argument.
*
* <li>Initialize the generator by casting the result to a DSAKeyPairGenerator
* and calling one of the
* {@code initialize} methods from this DSAKeyPairGenerator interface.
* <li>Check if the returned key pair generator is an instance of
* DSAKeyPairGenerator before casting the result to a DSAKeyPairGenerator
* and calling one of the {@code initialize} methods from this
* DSAKeyPairGenerator interface.
*
* <li>Generate a key pair by calling the {@code generateKeyPair}
* method from the KeyPairGenerator class.
* method of the KeyPairGenerator class.
*
* </ol>
*
@ -63,7 +67,7 @@ import java.security.*;
* parameters.
*
* <p>Note: Some earlier implementations of this interface may not support
* larger sizes of DSA parameters such as 2048 and 3072-bit.
* larger values of DSA parameters such as 3072-bit.
*
* @since 1.1
* @see java.security.KeyPairGenerator
@ -97,8 +101,7 @@ public interface DSAKeyPairGenerator {
* p, q and g parameters. If it is false, the method uses precomputed
* parameters for the modulus length requested. If there are no
* precomputed parameters for that modulus length, an exception will be
* thrown. It is guaranteed that there will always be
* default parameters for modulus lengths of 512 and 1024 bits.
* thrown.
*
* @param modlen the modulus length in bits. Valid values are any
* multiple of 64 between 512 and 1024, inclusive, 2048, and 3072.

View File

@ -294,28 +294,27 @@ public abstract class DateFormat extends Format {
private static final long serialVersionUID = 7218322306649953788L;
/**
* Overrides Format.
* Formats a time object into a time string. Examples of time objects
* are a time value expressed in milliseconds and a Date object.
* @param obj must be a Number or a Date.
* @param toAppendTo the string buffer for the returning time string.
* @return the string buffer passed in as toAppendTo, with formatted text appended.
* @param fieldPosition keeps track of the position of the field
* within the returned string.
* On input: an alignment field,
* if desired. On output: the offsets of the alignment field. For
* example, given a time text "1996.07.10 AD at 15:08:56 PDT",
* if the given fieldPosition is DateFormat.YEAR_FIELD, the
* begin index and end index of fieldPosition will be set to
* 0 and 4, respectively.
* Notice that if the same time field appears
* more than once in a pattern, the fieldPosition will be set for the first
* occurrence of that time field. For instance, formatting a Date to
* the time string "1 PM PDT (Pacific Daylight Time)" using the pattern
* "h a z (zzzz)" and the alignment field DateFormat.TIMEZONE_FIELD,
* the begin index and end index of fieldPosition will be set to
* 5 and 8, respectively, for the first occurrence of the timezone
* pattern character 'z'.
* Formats the given {@code Object} into a date-time string. The formatted
* string is appended to the given {@code StringBuffer}.
*
* @param obj Must be a {@code Date} or a {@code Number} representing a
* millisecond offset from the <a href="../util/Calendar.html#Epoch">Epoch</a>.
* @param toAppendTo The string buffer for the returning date-time string.
* @param fieldPosition keeps track on the position of the field within
* the returned string. For example, given a date-time text
* {@code "1996.07.10 AD at 15:08:56 PDT"}, if the given {@code fieldPosition}
* is {@link DateFormat#YEAR_FIELD}, the begin index and end index of
* {@code fieldPosition} will be set to 0 and 4, respectively.
* Notice that if the same date-time field appears more than once in a
* pattern, the {@code fieldPosition} will be set for the first occurrence
* of that date-time field. For instance, formatting a {@code Date} to the
* date-time string {@code "1 PM PDT (Pacific Daylight Time)"} using the
* pattern {@code "h a z (zzzz)"} and the alignment field
* {@link DateFormat#TIMEZONE_FIELD}, the begin index and end index of
* {@code fieldPosition} will be set to 5 and 8, respectively, for the
* first occurrence of the timezone pattern character {@code 'z'}.
* @return the string buffer passed in as {@code toAppendTo},
* with formatted text appended.
* @exception IllegalArgumentException if the {@code Format} cannot format
* the given {@code obj}.
* @see java.text.Format
@ -333,34 +332,35 @@ public abstract class DateFormat extends Format {
}
/**
* Formats a Date into a date/time string.
* @param date a Date to be formatted into a date/time string.
* @param toAppendTo the string buffer for the returning date/time string.
* @param fieldPosition keeps track of the position of the field
* within the returned string.
* On input: an alignment field,
* if desired. On output: the offsets of the alignment field. For
* example, given a time text "1996.07.10 AD at 15:08:56 PDT",
* if the given fieldPosition is DateFormat.YEAR_FIELD, the
* begin index and end index of fieldPosition will be set to
* 0 and 4, respectively.
* Notice that if the same time field appears
* more than once in a pattern, the fieldPosition will be set for the first
* occurrence of that time field. For instance, formatting a Date to
* the time string "1 PM PDT (Pacific Daylight Time)" using the pattern
* "h a z (zzzz)" and the alignment field DateFormat.TIMEZONE_FIELD,
* the begin index and end index of fieldPosition will be set to
* 5 and 8, respectively, for the first occurrence of the timezone
* pattern character 'z'.
* @return the string buffer passed in as toAppendTo, with formatted text appended.
* Formats a {@link Date} into a date-time string. The formatted
* string is appended to the given {@code StringBuffer}.
*
* @param date a Date to be formatted into a date-time string.
* @param toAppendTo the string buffer for the returning date-time string.
* @param fieldPosition keeps track on the position of the field within
* the returned string. For example, given a date-time text
* {@code "1996.07.10 AD at 15:08:56 PDT"}, if the given {@code fieldPosition}
* is {@link DateFormat#YEAR_FIELD}, the begin index and end index of
* {@code fieldPosition} will be set to 0 and 4, respectively.
* Notice that if the same date-time field appears more than once in a
* pattern, the {@code fieldPosition} will be set for the first occurrence
* of that date-time field. For instance, formatting a {@code Date} to the
* date-time string {@code "1 PM PDT (Pacific Daylight Time)"} using the
* pattern {@code "h a z (zzzz)"} and the alignment field
* {@link DateFormat#TIMEZONE_FIELD}, the begin index and end index of
* {@code fieldPosition} will be set to 5 and 8, respectively, for the
* first occurrence of the timezone pattern character {@code 'z'}.
* @return the string buffer passed in as {@code toAppendTo}, with formatted
* text appended.
*/
public abstract StringBuffer format(Date date, StringBuffer toAppendTo,
FieldPosition fieldPosition);
/**
* Formats a Date into a date/time string.
* @param date the time value to be formatted into a time string.
* @return the formatted time string.
* Formats a {@link Date} into a date-time string.
*
* @param date the time value to be formatted into a date-time string.
* @return the formatted date-time string.
*/
public final String format(Date date)
{

View File

@ -480,8 +480,14 @@ public class DecimalFormat extends NumberFormat {
* @param number the number to format
* @param toAppendTo the <code>StringBuffer</code> to which the formatted
* text is to be appended
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param pos keeps track on the position of the field within the
* returned string. For example, for formatting a number
* {@code 1234567.89} in {@code Locale.US} locale,
* if the given {@code fieldPosition} is
* {@link NumberFormat#INTEGER_FIELD}, the begin index
* and end index of {@code fieldPosition} will be set
* to 0 and 9, respectively for the output string
* {@code 1,234,567.89}.
* @return the value passed in as <code>toAppendTo</code>
* @exception IllegalArgumentException if <code>number</code> is
* null or not an instance of <code>Number</code>.
@ -517,8 +523,14 @@ public class DecimalFormat extends NumberFormat {
* Formats a double to produce a string.
* @param number The double to format
* @param result where the text is to be appended
* @param fieldPosition On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param fieldPosition keeps track on the position of the field within
* the returned string. For example, for formatting
* a number {@code 1234567.89} in {@code Locale.US}
* locale, if the given {@code fieldPosition} is
* {@link NumberFormat#INTEGER_FIELD}, the begin index
* and end index of {@code fieldPosition} will be set
* to 0 and 9, respectively for the output string
* {@code 1,234,567.89}.
* @exception NullPointerException if {@code result} or
* {@code fieldPosition} is {@code null}
* @exception ArithmeticException if rounding is needed with rounding
@ -637,8 +649,14 @@ public class DecimalFormat extends NumberFormat {
* Format a long to produce a string.
* @param number The long to format
* @param result where the text is to be appended
* @param fieldPosition On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param fieldPosition keeps track on the position of the field within
* the returned string. For example, for formatting
* a number {@code 123456789} in {@code Locale.US}
* locale, if the given {@code fieldPosition} is
* {@link NumberFormat#INTEGER_FIELD}, the begin index
* and end index of {@code fieldPosition} will be set
* to 0 and 11, respectively for the output string
* {@code 123,456,789}.
* @exception NullPointerException if {@code result} or
* {@code fieldPosition} is {@code null}
* @exception ArithmeticException if rounding is needed with rounding
@ -727,8 +745,14 @@ public class DecimalFormat extends NumberFormat {
* Formats a BigDecimal to produce a string.
* @param number The BigDecimal to format
* @param result where the text is to be appended
* @param fieldPosition On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param fieldPosition keeps track on the position of the field within
* the returned string. For example, for formatting
* a number {@code 1234567.89} in {@code Locale.US}
* locale, if the given {@code fieldPosition} is
* {@link NumberFormat#INTEGER_FIELD}, the begin index
* and end index of {@code fieldPosition} will be set
* to 0 and 9, respectively for the output string
* {@code 1,234,567.89}.
* @return The formatted number string
* @exception ArithmeticException if rounding is needed with rounding
* mode being set to RoundingMode.UNNECESSARY
@ -780,8 +804,14 @@ public class DecimalFormat extends NumberFormat {
* Format a BigInteger to produce a string.
* @param number The BigInteger to format
* @param result where the text is to be appended
* @param fieldPosition On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param fieldPosition keeps track on the position of the field within
* the returned string. For example, for formatting
* a number {@code 123456789} in {@code Locale.US}
* locale, if the given {@code fieldPosition} is
* {@link NumberFormat#INTEGER_FIELD}, the begin index
* and end index of {@code fieldPosition} will be set
* to 0 and 11, respectively for the output string
* {@code 123,456,789}.
* @return The formatted number string
* @exception ArithmeticException if rounding is needed with rounding
* mode being set to RoundingMode.UNNECESSARY

View File

@ -820,8 +820,8 @@ public class MessageFormat extends Format {
*
* @param arguments an array of objects to be formatted and substituted.
* @param result where text is appended.
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param pos keeps track on the position of the first replaced argument
in the output string.
* @return the string buffer passed in as {@code result}, with formatted
* text appended
* @exception IllegalArgumentException if an argument in the
@ -868,8 +868,8 @@ public class MessageFormat extends Format {
*
* @param arguments an array of objects to be formatted and substituted.
* @param result where text is appended.
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param pos keeps track on the position of the first replaced argument
* in the output string.
* @exception IllegalArgumentException if an argument in the
* <code>arguments</code> array is not of the type
* expected by the format element(s) that use it.
@ -1239,11 +1239,11 @@ public class MessageFormat extends Format {
private int maxOffset = -1;
/**
* Internal routine used by format. If <code>characterIterators</code> is
* non-null, AttributedCharacterIterator will be created from the
* subformats as necessary. If <code>characterIterators</code> is null
* and <code>fp</code> is non-null and identifies
* <code>Field.MESSAGE_ARGUMENT</code>, the location of
* Internal routine used by format. If {@code characterIterators} is
* {@code non-null}, AttributedCharacterIterator will be created from the
* subformats as necessary. If {@code characterIterators} is {@code null}
* and {@code fp} is {@code non-null} and identifies
* {@code Field.ARGUMENT} as the field attribute, the location of
* the first replaced argument will be set in it.
*
* @exception IllegalArgumentException if an argument in the

View File

@ -240,8 +240,14 @@ public abstract class NumberFormat extends Format {
* @param number the number to format
* @param toAppendTo the <code>StringBuffer</code> to which the formatted
* text is to be appended
* @param pos On input: an alignment field, if desired.
* On output: the offsets of the alignment field.
* @param pos keeps track on the position of the field within the
* returned string. For example, for formatting a number
* {@code 1234567.89} in {@code Locale.US} locale,
* if the given {@code fieldPosition} is
* {@link NumberFormat#INTEGER_FIELD}, the begin index
* and end index of {@code fieldPosition} will be set
* to 0 and 9, respectively for the output string
* {@code 1,234,567.89}.
* @return the value passed in as <code>toAppendTo</code>
* @exception IllegalArgumentException if <code>number</code> is
* null or not an instance of <code>Number</code>.
@ -342,7 +348,14 @@ public abstract class NumberFormat extends Format {
* @param number the double number to format
* @param toAppendTo the StringBuffer to which the formatted text is to be
* appended
* @param pos the field position
* @param pos keeps track on the position of the field within the
* returned string. For example, for formatting a number
* {@code 1234567.89} in {@code Locale.US} locale,
* if the given {@code fieldPosition} is
* {@link NumberFormat#INTEGER_FIELD}, the begin index
* and end index of {@code fieldPosition} will be set
* to 0 and 9, respectively for the output string
* {@code 1,234,567.89}.
* @return the formatted StringBuffer
* @exception ArithmeticException if rounding is needed with rounding
* mode being set to RoundingMode.UNNECESSARY
@ -358,7 +371,14 @@ public abstract class NumberFormat extends Format {
* @param number the long number to format
* @param toAppendTo the StringBuffer to which the formatted text is to be
* appended
* @param pos the field position
* @param pos keeps track on the position of the field within the
* returned string. For example, for formatting a number
* {@code 123456789} in {@code Locale.US} locale,
* if the given {@code fieldPosition} is
* {@link NumberFormat#INTEGER_FIELD}, the begin index
* and end index of {@code fieldPosition} will be set
* to 0 and 11, respectively for the output string
* {@code 123,456,789}.
* @return the formatted StringBuffer
* @exception ArithmeticException if rounding is needed with rounding
* mode being set to RoundingMode.UNNECESSARY

View File

@ -942,8 +942,19 @@ public class SimpleDateFormat extends DateFormat {
*
* @param date the date-time value to be formatted into a date-time string.
* @param toAppendTo where the new date-time text is to be appended.
* @param pos the formatting position. On input: an alignment field,
* if desired. On output: the offsets of the alignment field.
* @param pos keeps track on the position of the field within
* the returned string. For example, given a date-time text
* {@code "1996.07.10 AD at 15:08:56 PDT"}, if the given {@code fieldPosition}
* is {@link DateFormat#YEAR_FIELD}, the begin index and end index of
* {@code fieldPosition} will be set to 0 and 4, respectively.
* Notice that if the same date-time field appears more than once in a
* pattern, the {@code fieldPosition} will be set for the first occurrence
* of that date-time field. For instance, formatting a {@code Date} to the
* date-time string {@code "1 PM PDT (Pacific Daylight Time)"} using the
* pattern {@code "h a z (zzzz)"} and the alignment field
* {@link DateFormat#TIMEZONE_FIELD}, the begin index and end index of
* {@code fieldPosition} will be set to 5 and 8, respectively, for the
* first occurrence of the timezone pattern character {@code 'z'}.
* @return the formatted date-time string.
* @exception NullPointerException if any of the parameters is {@code null}.
*/

View File

@ -192,7 +192,8 @@ public interface Collection<E> extends Iterable<E> {
* 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}.
*
* <p>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 +203,8 @@ public interface Collection<E> extends Iterable<E> {
* <p>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 +241,14 @@ public interface Collection<E> extends Iterable<E> {
* Note that {@code toArray(new Object[0])} is identical in function to
* {@code toArray()}.
*
* @param <T> the runtime type of the array to contain the collection
* @param <T> 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> T[] toArray(T[] a);

View File

@ -128,4 +128,25 @@ class JarEntry extends ZipEntry {
public CodeSigner[] getCodeSigners() {
return signers == null ? null : signers.clone();
}
/**
* Returns the real name of this {@code JarEntry}.
*
* If this {@code JarEntry} is an entry of a
* <a href="JarFile.html#multirelease">multi-release jar file</a> and the
* {@code JarFile} is configured to be processed as such, the name returned
* by this method is the path name of the versioned entry that the
* {@code JarEntry} represents, rather than the path name of the base entry
* that {@link #getName()} returns. If the {@code JarEntry} does not represent
* a versioned entry of a multi-release {@code JarFile} or the {@code JarFile}
* is not configured for processing a multi-release jar file, this method
* returns the same name that {@link #getName()} returns.
*
* @return the real name of the JarEntry
*
* @since 10
*/
public String getRealName() {
return super.getName();
}
}

View File

@ -26,6 +26,7 @@
package java.util.jar;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaUtilZipFileAccess;
import sun.security.action.GetPropertyAction;
import sun.security.util.ManifestEntryVerifier;
import sun.security.util.SignatureFileVerifier;
@ -45,10 +46,12 @@ import java.util.Enumeration;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.NoSuchElementException;
import java.util.Objects;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Collector;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import java.util.zip.ZipEntry;
@ -163,9 +166,13 @@ class JarFile extends ZipFile {
// true if manifest checked for special attributes
private volatile boolean hasCheckedSpecialAttributes;
private static final JavaUtilZipFileAccess JUZFA;
static {
// Set up JavaUtilJarAccess in SharedSecrets
SharedSecrets.setJavaUtilJarAccess(new JavaUtilJarAccessImpl());
// Get JavaUtilZipFileAccess from SharedSecrets
JUZFA = jdk.internal.misc.SharedSecrets.getJavaUtilZipFileAccess();
// multi-release jar file versions >= 9
BASE_VERSION = Runtime.Version.parse(Integer.toString(8));
BASE_VERSION_MAJOR = BASE_VERSION.major();
@ -424,8 +431,7 @@ class JarFile extends ZipFile {
}
private String[] getMetaInfEntryNames() {
return jdk.internal.misc.SharedSecrets.getJavaUtilZipFileAccess()
.getMetaInfEntryNames((ZipFile)this);
return JUZFA.getMetaInfEntryNames((ZipFile)this);
}
/**
@ -497,47 +503,11 @@ class JarFile extends ZipFile {
* </div>
*/
public ZipEntry getEntry(String name) {
ZipEntry ze = super.getEntry(name);
if (ze != null) {
return new JarFileEntry(ze);
}
// no matching base entry, but maybe there is a versioned entry,
// like a new private class
JarFileEntry je = getEntry0(name);
if (isMultiRelease()) {
ze = new ZipEntry(name);
ZipEntry vze = getVersionedEntry(ze);
if (ze != vze) {
return new JarFileEntry(name, vze);
}
}
return null;
}
private class JarEntryIterator implements Enumeration<JarEntry>,
Iterator<JarEntry>
{
final Enumeration<? extends ZipEntry> e = JarFile.super.entries();
public boolean hasNext() {
return e.hasMoreElements();
}
public JarEntry next() {
ZipEntry ze = e.nextElement();
return new JarFileEntry(ze.getName(), ze);
}
public boolean hasMoreElements() {
return hasNext();
}
public JarEntry nextElement() {
return next();
}
public Iterator<JarEntry> asIterator() {
return this;
return getVersionedEntry(name, je);
}
return je;
}
/**
@ -548,7 +518,7 @@ class JarFile extends ZipFile {
* may be thrown if the jar file has been closed
*/
public Enumeration<JarEntry> entries() {
return new JarEntryIterator();
return JUZFA.entries(this, JarFileEntry::new);
}
/**
@ -561,68 +531,100 @@ class JarFile extends ZipFile {
* @since 1.8
*/
public Stream<JarEntry> stream() {
return StreamSupport.stream(Spliterators.spliterator(
new JarEntryIterator(), size(),
Spliterator.ORDERED | Spliterator.DISTINCT |
Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
}
private ZipEntry searchForVersionedEntry(final int version, String name) {
ZipEntry vze = null;
String sname = "/" + name;
int i = version;
while (i > BASE_VERSION_MAJOR) {
vze = super.getEntry(META_INF_VERSIONS + i + sname);
if (vze != null) break;
i--;
}
return vze;
}
private ZipEntry getVersionedEntry(ZipEntry ze) {
ZipEntry vze = null;
if (BASE_VERSION_MAJOR < versionMajor) {
String name = ze.getName();
if (!name.startsWith(META_INF)) {
vze = searchForVersionedEntry(versionMajor, name);
}
}
return vze == null ? ze : vze;
return JUZFA.stream(this, JarFileEntry::new);
}
/**
* Returns the real name of a {@code JarEntry}. If this {@code JarFile} is
* a multi-release jar file and is configured to be processed as such, the
* name returned by this method is the path name of the versioned entry
* that the {@code JarEntry} represents, rather than the path name of the
* base entry that {@link JarEntry#getName()} returns. If the
* {@code JarEntry} does not represent a versioned entry, or the
* jar file is not a multi-release jar file or {@code JarFile} is not
* configured for processing a multi-release jar file, this method returns
* the same name that {@link JarEntry#getName()} returns.
* Returns a {@code Stream} of the versioned jar file entries.
*
* @param entry the JarEntry
* @return the real name of the JarEntry
* @since 9
* <p>If this {@code JarFile} is a multi-release jar file and is configured to
* be processed as such, then an entry in the stream is the latest versioned entry
* associated with the corresponding base entry name. The maximum version of the
* latest versioned entry is the version returned by {@link #getVersion()}.
* The returned stream may include an entry that only exists as a versioned entry.
*
* If the jar file is not a multi-release jar file or the {@code JarFile} is not
* configured for processing a multi-release jar file, this method returns the
* same stream that {@link #stream()} returns.
*
* @return stream of versioned entries
* @since 10
*/
String getRealName(JarEntry entry) {
if (entry instanceof JarFileEntry) {
return ((JarFileEntry)entry).realName();
public Stream<JarEntry> versionedStream() {
if (isMultiRelease()) {
return JUZFA.entryNameStream(this).map(this::getBasename)
.filter(Objects::nonNull)
.distinct()
.map(this::getJarEntry);
}
return entry.getName();
return stream();
}
/*
* Invokes {@ZipFile}'s getEntry to Return a {@code JarFileEntry} for the
* given entry name or {@code null} if not found.
*/
private JarFileEntry getEntry0(String name) {
return (JarFileEntry)JUZFA.getEntry(this, name, JarFileEntry::new);
}
private String getBasename(String name) {
if (name.startsWith(META_INF_VERSIONS)) {
int off = META_INF_VERSIONS.length();
int index = name.indexOf('/', off);
try {
// filter out dir META-INF/versions/ and META-INF/versions/*/
// and any entry with version > 'version'
if (index == -1 || index == (name.length() - 1) ||
Integer.parseInt(name, off, index, 10) > versionMajor) {
return null;
}
} catch (NumberFormatException x) {
return null; // remove malformed entries silently
}
// map to its base name
return name.substring(index + 1);
}
return name;
}
private JarEntry getVersionedEntry(String name, JarEntry je) {
if (BASE_VERSION_MAJOR < versionMajor) {
if (!name.startsWith(META_INF)) {
// search for versioned entry
int v = versionMajor;
while (v > BASE_VERSION_MAJOR) {
JarFileEntry vje = getEntry0(META_INF_VERSIONS + v + "/" + name);
if (vje != null) {
return vje.withBasename(name);
}
v--;
}
}
}
return je;
}
// placeholder for now
String getRealName(JarEntry entry) {
return entry.getRealName();
}
private class JarFileEntry extends JarEntry {
final private String name;
private String basename;
JarFileEntry(ZipEntry ze) {
super(isMultiRelease() ? getVersionedEntry(ze) : ze);
this.name = ze.getName();
JarFileEntry(String name) {
super(name);
this.basename = name;
}
JarFileEntry(String name, ZipEntry vze) {
super(vze);
this.name = name;
this.basename = name;
}
@Override
public Attributes getAttributes() throws IOException {
Manifest man = JarFile.this.getManifest();
if (man != null) {
@ -631,6 +633,8 @@ class JarFile extends ZipFile {
return null;
}
}
@Override
public Certificate[] getCertificates() {
try {
maybeInstantiateVerifier();
@ -642,6 +646,8 @@ class JarFile extends ZipFile {
}
return certs == null ? null : certs.clone();
}
@Override
public CodeSigner[] getCodeSigners() {
try {
maybeInstantiateVerifier();
@ -653,20 +659,30 @@ class JarFile extends ZipFile {
}
return signers == null ? null : signers.clone();
}
JarFileEntry realEntry() {
if (isMultiRelease() && versionMajor != BASE_VERSION_MAJOR) {
String entryName = super.getName();
return entryName.equals(this.name) ? this : new JarFileEntry(entryName, this);
}
return this;
}
String realName() {
@Override
public String getRealName() {
return super.getName();
}
@Override
public String getName() {
return name;
return basename;
}
JarFileEntry realEntry() {
if (isMultiRelease() && versionMajor != BASE_VERSION_MAJOR) {
String entryName = super.getName();
return entryName == basename || entryName.equals(basename) ?
this : new JarFileEntry(entryName, this);
}
return this;
}
// changes the basename, returns "this"
JarFileEntry withBasename(String name) {
basename = name;
return this;
}
}
@ -704,7 +720,6 @@ class JarFile extends ZipFile {
}
}
/*
* Initializes the verifier object by reading all the manifest
* entries and passing them to the verifier.
@ -904,7 +919,7 @@ class JarFile extends ZipFile {
private JarEntry getManEntry() {
if (manEntry == null) {
// First look up manifest entry using standard name
ZipEntry manEntry = super.getEntry(MANIFEST_NAME);
JarEntry manEntry = getEntry0(MANIFEST_NAME);
if (manEntry == null) {
// If not found, then iterate through all the "META-INF/"
// entries to find a match.
@ -912,15 +927,13 @@ class JarFile extends ZipFile {
if (names != null) {
for (String name : names) {
if (MANIFEST_NAME.equals(name.toUpperCase(Locale.ENGLISH))) {
manEntry = super.getEntry(name);
manEntry = getEntry0(name);
break;
}
}
}
}
this.manEntry = (manEntry == null)
? null
: new JarFileEntry(manEntry.getName(), manEntry);
this.manEntry = manEntry;
}
return manEntry;
}
@ -1032,8 +1045,32 @@ class JarFile extends ZipFile {
}
}
JarEntry newEntry(ZipEntry ze) {
return new JarFileEntry(ze);
/*
* Returns a versioned {@code JarFileEntry} for the given entry,
* if there is one. Otherwise returns the original entry. This
* is invoked by the {@code entries2} for verifier.
*/
JarEntry newEntry(JarEntry je) {
if (isMultiRelease()) {
return getVersionedEntry(je.getName(), je);
}
return je;
}
/*
* Returns a versioned {@code JarFileEntry} for the given entry
* name, if there is one. Otherwise returns a {@code JarFileEntry}
* with the given name. It is invoked from JarVerifier's entries2
* for {@code singers}.
*/
JarEntry newEntry(String name) {
if (isMultiRelease()) {
JarEntry vje = getVersionedEntry(name, (JarEntry)null);
if (vje != null) {
return vje;
}
}
return new JarFileEntry(name);
}
Enumeration<String> entryNames(CodeSource[] cs) {
@ -1077,35 +1114,37 @@ class JarFile extends ZipFile {
Enumeration<JarEntry> entries2() {
ensureInitialization();
if (jv != null) {
return jv.entries2(this, super.entries());
return jv.entries2(this, JUZFA.entries(JarFile.this,
JarFileEntry::new));
}
// screen out entries which are never signed
final Enumeration<? extends ZipEntry> enum_ = super.entries();
final var unfilteredEntries = JUZFA.entries(JarFile.this, JarFileEntry::new);
return new Enumeration<>() {
ZipEntry entry;
JarEntry entry;
public boolean hasMoreElements() {
if (entry != null) {
return true;
}
while (enum_.hasMoreElements()) {
ZipEntry ze = enum_.nextElement();
if (JarVerifier.isSigningRelated(ze.getName())) {
while (unfilteredEntries.hasMoreElements()) {
JarEntry je = unfilteredEntries.nextElement();
if (JarVerifier.isSigningRelated(je.getName())) {
continue;
}
entry = ze;
entry = je;
return true;
}
return false;
}
public JarFileEntry nextElement() {
public JarEntry nextElement() {
if (hasMoreElements()) {
ZipEntry ze = entry;
JarEntry je = entry;
entry = null;
return new JarFileEntry(ze);
return newEntry(je);
}
throw new NoSuchElementException();
}

View File

@ -724,10 +724,10 @@ class JarVerifier {
* Like entries() but screens out internal JAR mechanism entries
* and includes signed entries with no ZIP data.
*/
public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration<? extends ZipEntry> e) {
public Enumeration<JarEntry> entries2(final JarFile jar, Enumeration<JarEntry> e) {
final Map<String, CodeSigner[]> map = new HashMap<>();
map.putAll(signerMap());
final Enumeration<? extends ZipEntry> enum_ = e;
final Enumeration<JarEntry> enum_ = e;
return new Enumeration<>() {
Enumeration<String> signers = null;
@ -738,11 +738,11 @@ class JarVerifier {
return true;
}
while (enum_.hasMoreElements()) {
ZipEntry ze = enum_.nextElement();
if (JarVerifier.isSigningRelated(ze.getName())) {
JarEntry je = enum_.nextElement();
if (JarVerifier.isSigningRelated(je.getName())) {
continue;
}
entry = jar.newEntry(ze);
entry = jar.newEntry(je);
return true;
}
if (signers == null) {
@ -750,7 +750,7 @@ class JarVerifier {
}
while (signers.hasMoreElements()) {
String name = signers.nextElement();
entry = jar.newEntry(new ZipEntry(name));
entry = jar.newEntry(name);
return true;
}

View File

@ -60,8 +60,4 @@ class JavaUtilJarAccessImpl implements JavaUtilJarAccess {
public List<Object> getManifestDigests(JarFile jar) {
return jar.getManifestDigests();
}
public String getRealName(JarFile jar, JarEntry entry) {
return jar.getRealName(entry);
}
}

View File

@ -1089,11 +1089,27 @@ public interface DoubleStream extends BaseStream<Double, DoubleStream> {
* streams is parallel. When the resulting stream is closed, the close
* handlers for both input streams are invoked.
*
* <p>This method operates on the two input streams and binds each stream
* to its source. As a result subsequent modifications to an input stream
* source may not be reflected in the concatenated stream result.
*
* @implNote
* Use caution when constructing streams from repeated concatenation.
* Accessing an element of a deeply concatenated stream can result in deep
* call chains, or even {@code StackOverflowError}.
*
* @apiNote
* To preserve optimization opportunities this method binds each stream to
* its source and accepts only two streams as parameters. For example, the
* exact size of the concatenated stream source can be computed if the exact
* size of each input stream source is known.
* To concatenate more streams without binding, or without nested calls to
* this method, try creating a stream of streams and flat-mapping with the
* identity function, for example:
* <pre>{@code
* DoubleStream concat = Stream.of(s1, s2, s3, s4).flatMapToDouble(s -> s);
* }</pre>
*
* @param a the first stream
* @param b the second stream
* @return the concatenation of the two input streams

View File

@ -1081,11 +1081,27 @@ public interface IntStream extends BaseStream<Integer, IntStream> {
* streams is parallel. When the resulting stream is closed, the close
* handlers for both input streams are invoked.
*
* <p>This method operates on the two input streams and binds each stream
* to its source. As a result subsequent modifications to an input stream
* source may not be reflected in the concatenated stream result.
*
* @implNote
* Use caution when constructing streams from repeated concatenation.
* Accessing an element of a deeply concatenated stream can result in deep
* call chains, or even {@code StackOverflowError}.
*
* @apiNote
* To preserve optimization opportunities this method binds each stream to
* its source and accepts only two streams as parameters. For example, the
* exact size of the concatenated stream source can be computed if the exact
* size of each input stream source is known.
* To concatenate more streams without binding, or without nested calls to
* this method, try creating a stream of streams and flat-mapping with the
* identity function, for example:
* <pre>{@code
* IntStream concat = Stream.of(s1, s2, s3, s4).flatMapToInt(s -> s);
* }</pre>
*
* @param a the first stream
* @param b the second stream
* @return the concatenation of the two input streams

View File

@ -1086,11 +1086,27 @@ public interface LongStream extends BaseStream<Long, LongStream> {
* streams is parallel. When the resulting stream is closed, the close
* handlers for both input streams are invoked.
*
* <p>This method operates on the two input streams and binds each stream
* to its source. As a result subsequent modifications to an input stream
* source may not be reflected in the concatenated stream result.
*
* @implNote
* Use caution when constructing streams from repeated concatenation.
* Accessing an element of a deeply concatenated stream can result in deep
* call chains, or even {@code StackOverflowError}.
*
* @apiNote
* To preserve optimization opportunities this method binds each stream to
* its source and accepts only two streams as parameters. For example, the
* exact size of the concatenated stream source can be computed if the exact
* size of each input stream source is known.
* To concatenate more streams without binding, or without nested calls to
* this method, try creating a stream of streams and flat-mapping with the
* identity function, for example:
* <pre>{@code
* LongStream concat = Stream.of(s1, s2, s3, s4).flatMapToLong(s -> s);
* }</pre>
*
* @param a the first stream
* @param b the second stream
* @return the concatenation of the two input streams

View File

@ -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
@ -1341,6 +1341,10 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
* streams is parallel. When the resulting stream is closed, the close
* handlers for both input streams are invoked.
*
* <p>This method operates on the two input streams and binds each stream
* to its source. As a result subsequent modifications to an input stream
* source may not be reflected in the concatenated stream result.
*
* @implNote
* Use caution when constructing streams from repeated concatenation.
* Accessing an element of a deeply concatenated stream can result in deep
@ -1349,6 +1353,18 @@ public interface Stream<T> extends BaseStream<T, Stream<T>> {
* <p>Subsequent changes to the sequential/parallel execution mode of the
* returned stream are not guaranteed to be propagated to the input streams.
*
* @apiNote
* To preserve optimization opportunities this method binds each stream to
* its source and accepts only two streams as parameters. For example, the
* exact size of the concatenated stream source can be computed if the exact
* size of each input stream source is known.
* To concatenate more streams without binding, or without nested calls to
* this method, try creating a stream of streams and flat-mapping with the
* identity function, for example:
* <pre>{@code
* Stream<T> concat = Stream.of(s1, s2, s3, s4).flatMap(s -> s);
* }</pre>
*
* @param <T> The type of stream elements
* @param a the first stream
* @param b the second stream

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2009, 2011, 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
@ -43,7 +43,34 @@ import sun.nio.cs.ArrayEncoder;
final class ZipCoder {
private static boolean isASCII(byte[] ba, int off, int len) {
for (int i = off; i < off + len; i++) {
if (ba[i] < 0)
return false;
}
return true;
}
private static boolean hasReplaceChar(byte[] ba) {
for (int i = 0; i < ba.length; i++) {
if (ba[i] == (byte)'?')
return true;
}
return false;
}
String toString(byte[] ba, int off, int length) {
// fastpath for UTF-8 cs and ascii only name, leverage the
// compact string impl to avoid the unnecessary char[] copy/
// paste. A temporary workaround before we have better approach,
// such as a String constructor that throws exception for
// malformed and/or unmappable characters, instead of silently
// replacing with repl char
if (isUTF8 && isASCII(ba, off, length)) {
return new String(ba, off, length, cs);
}
CharsetDecoder cd = decoder().reset();
int len = (int)(length * cd.maxCharsPerByte());
char[] ca = new char[len];
@ -78,6 +105,15 @@ final class ZipCoder {
}
byte[] getBytes(String s) {
if (isUTF8) {
// fastpath for UTF8. should only occur when the string
// has malformed surrogates. A postscan should still be
// faster and use less memory.
byte[] ba = s.getBytes(cs);
if (!hasReplaceChar(ba)) {
return ba;
}
}
CharsetEncoder ce = encoder().reset();
char[] ca = s.toCharArray();
int len = (int)(ca.length * ce.maxBytesPerChar());

View File

@ -50,11 +50,15 @@ import java.util.NoSuchElementException;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.WeakHashMap;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.IntFunction;
import java.util.jar.JarEntry;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;
import jdk.internal.misc.JavaUtilZipFileAccess;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.misc.JavaIORandomAccessFileAccess;
import jdk.internal.misc.VM;
import jdk.internal.perf.PerfCounter;
@ -296,13 +300,27 @@ class ZipFile implements ZipConstants, Closeable {
* @throws IllegalStateException if the zip file has been closed
*/
public ZipEntry getEntry(String name) {
return getEntry(name, ZipEntry::new);
}
/*
* Returns the zip file entry for the specified name, or null
* if not found.
*
* @param name the name of the entry
* @param func the function that creates the returned entry
*
* @return the zip file entry, or null if not found
* @throws IllegalStateException if the zip file has been closed
*/
private ZipEntry getEntry(String name, Function<String, ? extends ZipEntry> func) {
Objects.requireNonNull(name, "name");
synchronized (this) {
ensureOpen();
byte[] bname = zc.getBytes(name);
int pos = zsrc.getEntryPos(bname, true);
if (pos != -1) {
return getZipEntry(name, bname, pos);
return getZipEntry(name, bname, pos, func);
}
}
return null;
@ -374,12 +392,10 @@ class ZipFile implements ZipConstants, Closeable {
private class ZipFileInflaterInputStream extends InflaterInputStream {
private volatile boolean closeRequested;
private boolean eof = false;
private final ZipFileInputStream zfin;
ZipFileInflaterInputStream(ZipFileInputStream zfin, Inflater inf,
int size) {
super(zfin, inf, size);
this.zfin = zfin;
}
public void close() throws IOException {
@ -416,7 +432,7 @@ class ZipFile implements ZipConstants, Closeable {
public int available() throws IOException {
if (closeRequested)
return 0;
long avail = zfin.size() - inf.getBytesWritten();
long avail = ((ZipFileInputStream)in).size() - inf.getBytesWritten();
return (avail > (long) Integer.MAX_VALUE ?
Integer.MAX_VALUE : (int) avail);
}
@ -466,41 +482,48 @@ class ZipFile implements ZipConstants, Closeable {
return name;
}
private class ZipEntryIterator implements Enumeration<ZipEntry>, Iterator<ZipEntry> {
private class ZipEntryIterator<T extends ZipEntry>
implements Enumeration<T>, Iterator<T> {
private int i = 0;
private final int entryCount;
private final Function<String, T> gen;
public ZipEntryIterator() {
synchronized (ZipFile.this) {
ensureOpen();
this.entryCount = zsrc.total;
}
public ZipEntryIterator(int entryCount, Function<String, T> gen) {
this.entryCount = entryCount;
this.gen = gen;
}
@Override
public boolean hasMoreElements() {
return hasNext();
}
@Override
public boolean hasNext() {
return i < entryCount;
}
public ZipEntry nextElement() {
@Override
public T nextElement() {
return next();
}
public ZipEntry next() {
@Override
@SuppressWarnings("unchecked")
public T next() {
synchronized (ZipFile.this) {
ensureOpen();
if (!hasNext()) {
throw new NoSuchElementException();
}
// each "entry" has 3 ints in table entries
return getZipEntry(null, null, zsrc.getEntryPos(i++ * 3));
return (T)getZipEntry(null, null, zsrc.getEntryPos(i++ * 3), gen);
}
}
public Iterator<ZipEntry> asIterator() {
@Override
public Iterator<T> asIterator() {
return this;
}
}
@ -511,11 +534,51 @@ class ZipFile implements ZipConstants, Closeable {
* @throws IllegalStateException if the zip file has been closed
*/
public Enumeration<? extends ZipEntry> entries() {
return new ZipEntryIterator();
synchronized (this) {
ensureOpen();
return new ZipEntryIterator<ZipEntry>(zsrc.total, ZipEntry::new);
}
}
private Enumeration<JarEntry> entries(Function<String, JarEntry> func) {
synchronized (this) {
ensureOpen();
return new ZipEntryIterator<JarEntry>(zsrc.total, func);
}
}
private class EntrySpliterator<T> extends Spliterators.AbstractSpliterator<T> {
private int index;
private final int fence;
private final IntFunction<T> gen;
EntrySpliterator(int index, int fence, IntFunction<T> gen) {
super((long)fence,
Spliterator.ORDERED | Spliterator.DISTINCT | Spliterator.IMMUTABLE |
Spliterator.NONNULL);
this.index = index;
this.fence = fence;
this.gen = gen;
}
@Override
public boolean tryAdvance(Consumer<? super T> action) {
if (action == null)
throw new NullPointerException();
if (index >= 0 && index < fence) {
synchronized (ZipFile.this) {
ensureOpen();
action.accept(gen.apply(zsrc.getEntryPos(index++ * 3)));
}
return true;
}
return false;
}
}
/**
* Returns an ordered {@code Stream} over the ZIP file entries.
*
* Entries appear in the {@code Stream} in the order they appear in
* the central directory of the ZIP file.
*
@ -524,17 +587,68 @@ class ZipFile implements ZipConstants, Closeable {
* @since 1.8
*/
public Stream<? extends ZipEntry> stream() {
return StreamSupport.stream(Spliterators.spliterator(
new ZipEntryIterator(), size(),
Spliterator.ORDERED | Spliterator.DISTINCT |
Spliterator.IMMUTABLE | Spliterator.NONNULL), false);
synchronized (this) {
ensureOpen();
return StreamSupport.stream(new EntrySpliterator<>(0, zsrc.total,
pos -> getZipEntry(null, null, pos, ZipEntry::new)), false);
}
}
private String getEntryName(int pos) {
byte[] cen = zsrc.cen;
int nlen = CENNAM(cen, pos);
int clen = CENCOM(cen, pos);
int flag = CENFLG(cen, pos);
if (!zc.isUTF8() && (flag & EFS) != 0) {
return zc.toStringUTF8(cen, pos + CENHDR, nlen);
} else {
return zc.toString(cen, pos + CENHDR, nlen);
}
}
/*
* Returns an ordered {@code Stream} over the zip file entry names.
*
* Entry names appear in the {@code Stream} in the order they appear in
* the central directory of the ZIP file.
*
* @return an ordered {@code Stream} of entry names in this zip file
* @throws IllegalStateException if the zip file has been closed
* @since 10
*/
private Stream<String> entryNameStream() {
synchronized (this) {
ensureOpen();
return StreamSupport.stream(
new EntrySpliterator<>(0, zsrc.total, this::getEntryName), false);
}
}
/*
* Returns an ordered {@code Stream} over the zip file entries.
*
* Entries appear in the {@code Stream} in the order they appear in
* the central directory of the jar file.
*
* @param func the function that creates the returned entry
* @return an ordered {@code Stream} of entries in this zip file
* @throws IllegalStateException if the zip file has been closed
* @since 10
*/
private Stream<JarEntry> stream(Function<String, JarEntry> func) {
synchronized (this) {
ensureOpen();
return StreamSupport.stream(new EntrySpliterator<>(0, zsrc.total,
pos -> (JarEntry)getZipEntry(null, null, pos, func)), false);
}
}
private String lastEntryName;
private int lastEntryPos;
/* Checks ensureOpen() before invoke this method */
private ZipEntry getZipEntry(String name, byte[] bname, int pos) {
private ZipEntry getZipEntry(String name, byte[] bname, int pos,
Function<String, ? extends ZipEntry> func) {
byte[] cen = zsrc.cen;
int nlen = CENNAM(cen, pos);
int elen = CENEXT(cen, pos);
@ -551,7 +665,7 @@ class ZipFile implements ZipConstants, Closeable {
name = zc.toString(cen, pos + CENHDR, nlen);
}
}
ZipEntry e = new ZipEntry(name);
ZipEntry e = func.apply(name); //ZipEntry e = new ZipEntry(name);
e.flag = flag;
e.xdostime = CENTIM(cen, pos);
e.crc = CENCRC(cen, pos);
@ -791,7 +905,6 @@ class ZipFile implements ZipConstants, Closeable {
public long skip(long n) throws IOException {
synchronized (ZipFile.this) {
ensureOpenOrZipException();
initDataOffset();
if (n > rem) {
n = rem;
@ -857,12 +970,33 @@ class ZipFile implements ZipConstants, Closeable {
static {
SharedSecrets.setJavaUtilZipFileAccess(
new JavaUtilZipFileAccess() {
@Override
public boolean startsWithLocHeader(ZipFile zip) {
return zip.zsrc.startsWithLoc;
}
@Override
public String[] getMetaInfEntryNames(ZipFile zip) {
return zip.getMetaInfEntryNames();
}
@Override
public JarEntry getEntry(ZipFile zip, String name,
Function<String, JarEntry> func) {
return (JarEntry)zip.getEntry(name, func);
}
@Override
public Enumeration<JarEntry> entries(ZipFile zip,
Function<String, JarEntry> func) {
return zip.entries(func);
}
@Override
public Stream<JarEntry> stream(ZipFile zip,
Function<String, JarEntry> func) {
return zip.stream(func);
}
@Override
public Stream<String> entryNameStream(ZipFile zip) {
return zip.entryNameStream();
}
}
);
isWindows = VM.getSavedProperty("os.name").contains("Windows");

View File

@ -274,7 +274,7 @@ final class JrtPath implements Path {
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 @@ final class JrtPath implements Path {
// Remove DotSlash(./) and resolve DotDot (..) components
private String getResolved() {
if (path.length() == 0) {
return path;
}
if (path.indexOf('.') == -1) {
int length = path.length();
if (length == 0 || (path.indexOf("./") == -1 && path.charAt(length - 1) != '.')) {
return path;
} else {
return resolvePath();
}
}
private String resolvePath() {
int length = path.length();
char[] to = new char[length];
int nc = getNameCount();

View File

@ -834,7 +834,7 @@ public class URLClassPath {
try {
String nm;
if (jar.isMultiRelease()) {
nm = SharedSecrets.javaUtilJarAccess().getRealName(jar, entry);
nm = entry.getRealName();
} else {
nm = name;
}

View File

@ -41,5 +41,4 @@ public interface JavaUtilJarAccess {
public Enumeration<JarEntry> entries2(JarFile jar);
public void setEagerValidation(JarFile jar, boolean eager);
public List<Object> getManifestDigests(JarFile jar);
public String getRealName(JarFile jar, JarEntry entry);
}

View File

@ -25,10 +25,19 @@
package jdk.internal.misc;
import java.io.IOException;
import java.util.Enumeration;
import java.util.function.Function;
import java.util.jar.JarEntry;
import java.util.stream.Stream;
import java.util.zip.ZipFile;
public interface JavaUtilZipFileAccess {
public boolean startsWithLocHeader(ZipFile zip);
public String[] getMetaInfEntryNames(ZipFile zip);
public JarEntry getEntry(ZipFile zip, String name, Function<String, JarEntry> func);
public Enumeration<JarEntry> entries(ZipFile zip, Function<String, JarEntry> func);
public Stream<JarEntry> stream(ZipFile zip, Function<String, JarEntry> func);
public Stream<String> entryNameStream(ZipFile zip);
}

View File

@ -66,8 +66,6 @@ import java.util.zip.ZipFile;
import jdk.internal.jmod.JmodFile;
import jdk.internal.jmod.JmodFile.Section;
import jdk.internal.perf.PerfCounter;
import jdk.internal.util.jar.VersionedStream;
/**
* A {@code ModuleFinder} that locates modules on the file system by searching
@ -515,7 +513,7 @@ public class ModulePath implements ModuleFinder {
builder.version(vs);
// scan the names of the entries in the JAR file
Map<Boolean, Set<String>> map = VersionedStream.stream(jf)
Map<Boolean, Set<String>> map = jf.versionedStream()
.filter(e -> !e.isDirectory())
.map(JarEntry::getName)
.filter(e -> (e.endsWith(".class") ^ e.startsWith(SERVICES_PREFIX)))
@ -615,7 +613,7 @@ public class ModulePath implements ModuleFinder {
}
private Set<String> jarPackages(JarFile jf) {
return VersionedStream.stream(jf)
return jf.versionedStream()
.filter(e -> !e.isDirectory())
.map(JarEntry::getName)
.map(this::toPackageName)

View File

@ -50,9 +50,7 @@ import java.util.stream.Stream;
import java.util.zip.ZipFile;
import jdk.internal.jmod.JmodFile;
import jdk.internal.misc.SharedSecrets;
import jdk.internal.module.ModuleHashes.HashSupplier;
import jdk.internal.util.jar.VersionedStream;
import sun.net.www.ParseUtil;
@ -250,7 +248,7 @@ class ModuleReferences {
JarEntry je = getEntry(name);
if (je != null) {
if (jf.isMultiRelease())
name = SharedSecrets.javaUtilJarAccess().getRealName(jf, je);
name = je.getRealName();
if (je.isDirectory() && !name.endsWith("/"))
name += "/";
String encodedPath = ParseUtil.encodePath(name, false);
@ -274,7 +272,7 @@ class ModuleReferences {
@Override
Stream<String> implList() throws IOException {
// take snapshot to avoid async close
List<String> names = VersionedStream.stream(jf)
List<String> names = jf.versionedStream()
.map(JarEntry::getName)
.collect(Collectors.toList());
return names.stream();

View File

@ -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<JarEntry> 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;
}
}

View File

@ -210,9 +210,7 @@ module java.base {
jdk.internal.vm.ci,
jdk.incubator.httpclient;
exports jdk.internal.util.jar to
jdk.jartool,
jdk.jdeps,
jdk.jlink;
jdk.jartool;
exports sun.net to
jdk.incubator.httpclient;
exports sun.net.ext to

View File

@ -262,21 +262,9 @@ JVM_DumpThreads(JNIEnv *env, jclass threadClass, jobjectArray threads);
/*
* 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
*/

View File

@ -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 @@ Java_java_lang_SecurityManager_getClassContext(JNIEnv *env, jobject this)
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);
}

View File

@ -257,7 +257,7 @@ public class TypeKindVisitor6<R, P> extends SimpleTypeVisitor6<R, P> {
*
* @implSpec This implementation dispatches to the visit method for
* the specific {@linkplain TypeKind kind} of pseudo-type:
* {@code VOID}, {@code PACKAGE}, or {@code NONE}.
* {@code VOID}, {@code PACKAGE}, {@code MODULE}, or {@code NONE}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
@ -273,6 +273,9 @@ public class TypeKindVisitor6<R, P> extends SimpleTypeVisitor6<R, P> {
case PACKAGE:
return visitNoTypeAsPackage(t, p);
case MODULE:
return visitNoTypeAsModule(t, p);
case NONE:
return visitNoTypeAsNone(t, p);
@ -307,6 +310,21 @@ public class TypeKindVisitor6<R, P> extends SimpleTypeVisitor6<R, P> {
return defaultAction(t, p);
}
/**
* Visits a {@link TypeKind#MODULE MODULE} pseudo-type.
*
* @implSpec This implementation calls {@code visitUnknown}.
*
* @param t the type to visit
* @param p a visitor-specified parameter
* @return the result of {@code visitUnknown}
*
* @since 10
*/
public R visitNoTypeAsModule(NoType t, P p) {
return visitUnknown(t, p);
}
/**
* Visits a {@link TypeKind#NONE NONE} pseudo-type.
*

View File

@ -93,4 +93,20 @@ public class TypeKindVisitor9<R, P> extends TypeKindVisitor8<R, P> {
protected TypeKindVisitor9(R defaultValue) {
super(defaultValue);
}
/**
* {@inheritDoc}
*
* @implSpec This implementation calls {@code defaultAction}.
*
* @param t {@inheritDoc}
* @param p {@inheritDoc}
* @return the result of {@code defaultAction}
*
* @since 10
*/
@Override
public R visitNoTypeAsModule(NoType t, P p) {
return defaultAction(t, p);
}
}

View File

@ -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
@ -329,7 +329,7 @@ class AquaFileSystemModel extends AbstractTableModel implements PropertyChangeLi
}
}
private final void swap(final Vector<Object> a, final int i, final int j) {
private void swap(final Vector<Object> a, final int i, final int j) {
final Object T = a.elementAt(i);
a.setElementAt(a.elementAt(j), i);
a.setElementAt(T, j);

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2016, 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
@ -1448,7 +1448,7 @@ public abstract class LWComponentPeer<T extends Component, D extends JComponent>
*
* @return true during layout, false otherwise.
*/
private final boolean isLayouting() {
private boolean isLayouting() {
return isLayouting;
}
}

View File

@ -1359,14 +1359,18 @@ public class PNGImageReader extends ImageReader {
this.pixelStream = new DataInputStream(is);
/*
* NB: the PNG spec declares that valid range for width
* PNG spec declares that valid range for width
* and height is [1, 2^31-1], so here we may fail to allocate
* a buffer for destination image due to memory limitation.
*
* However, the recovery strategy for this case should be
* defined on the level of application, so we will not
* try to estimate the required amount of the memory and/or
* handle OOM in any way.
* If the read operation triggers OutOfMemoryError, the same
* will be wrapped in an IIOException at PNGImageReader.read
* method.
*
* The recovery strategy for this case should be defined at
* the level of application, so we will not try to estimate
* the required amount of the memory and/or handle OOM in
* any way.
*/
theImage = getDestination(param,
getImageTypes(0),
@ -1671,7 +1675,16 @@ public class PNGImageReader extends ImageReader {
throw new IndexOutOfBoundsException("imageIndex != 0!");
}
readImage(param);
try {
readImage(param);
} catch (IOException |
IllegalStateException |
IllegalArgumentException e)
{
throw e;
} catch (Throwable e) {
throw new IIOException("Caught exception during read: ", e);
}
return theImage;
}
@ -1685,5 +1698,6 @@ public class PNGImageReader extends ImageReader {
gotMetadata = false;
metadata = null;
pixelStream = null;
imageStartPosition = -1L;
}
}

View File

@ -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
@ -41,7 +41,7 @@ public final class RIFFReader extends InputStream {
private final String fourcc;
private String riff_type = null;
private final long ckSize;
private InputStream stream;
private final InputStream stream;
private long avail = 0xffffffffL; // MAX_UNSIGNED_INT
private RIFFReader lastiterator = null;
@ -338,8 +338,6 @@ public final class RIFFReader extends InputStream {
@Override
public void close() throws IOException {
finish();
if (this == root)
stream.close();
stream = null;
stream.close();
}
}

View File

@ -1135,9 +1135,18 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (graphicsConfig == gc) {
return false;
}
GraphicsConfiguration oldConfig = graphicsConfig;
graphicsConfig = gc;
/*
* If component is moved from one screen to another sceeen
* graphicsConfiguration property is fired to enable the component
* to recalculate any rendering data, if needed
*/
if (oldConfig != null && gc != null) {
firePropertyChange("graphicsConfiguration", oldConfig, gc);
}
ComponentPeer peer = this.peer;
if (peer != null) {
return peer.updateGraphicsData(gc);
@ -2030,14 +2039,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
* used by GlobalCursormanager to update cursor
*/
final Point getLocationOnScreen_NoTreeLock() {
ComponentPeer peer = this.peer;
if (peer != null && isShowing()) {
if (peer instanceof LightweightPeer) {
// lightweight component location needs to be translated
// relative to a native component.
Container host = getNativeContainer();
Point pt = host.peer.getLocationOnScreen();
for(Component c = this; c != host; c = c.getParent()) {
for(Component c = this; c != host; c = c.getContainer()) {
pt.x += c.x;
pt.y += c.y;
}
@ -10218,7 +10227,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
applyCompoundShape(getAppliedShape().getDifference(s));
}
private final void applyCurrentShapeBelowMe() {
private void applyCurrentShapeBelowMe() {
checkTreeLock();
Container parent = getContainer();
if (parent != null && parent.isShowing()) {

View File

@ -283,7 +283,7 @@ public class EventQueue {
* @param theEvent an instance of {@code java.awt.AWTEvent},
* or a subclass of it
*/
private final void postEventPrivate(AWTEvent theEvent) {
private void postEventPrivate(AWTEvent theEvent) {
theEvent.isPosted = true;
pushPopLock.lock();
try {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1995, 2016, 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
@ -410,7 +410,7 @@ public class MenuItem extends MenuComponent implements Accessible {
* Returns true if the item and all its ancestors are
* enabled, false otherwise
*/
private final boolean isItemEnabled() {
private boolean isItemEnabled() {
// Fix For 6185151: Menu shortcuts of all menuitems within a menu
// should be disabled when the menu itself is disabled
if (!isEnabled()) {

View File

@ -1354,7 +1354,7 @@ public class AffineTransform implements Cloneable, java.io.Serializable {
/* SH | SC => */ APPLY_SHEAR | APPLY_SCALE,
/* SH | SC | TR => */ APPLY_SHEAR | APPLY_SCALE | APPLY_TRANSLATE,
};
private final void rotate90() {
private void rotate90() {
double M0 = m00;
m00 = m01;
m01 = -M0;
@ -1370,7 +1370,7 @@ public class AffineTransform implements Cloneable, java.io.Serializable {
this.state = state;
type = TYPE_UNKNOWN;
}
private final void rotate180() {
private void rotate180() {
m00 = -m00;
m11 = -m11;
int state = this.state;
@ -1390,7 +1390,7 @@ public class AffineTransform implements Cloneable, java.io.Serializable {
}
type = TYPE_UNKNOWN;
}
private final void rotate270() {
private void rotate270() {
double M0 = m00;
m00 = -m01;
m01 = M0;

View File

@ -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
@ -397,7 +397,7 @@ public class BufferedImageFilter extends ImageFilter implements Cloneable {
consumer.imageComplete(status);
}
private final WritableRaster createDCMraster() {
private WritableRaster createDCMraster() {
WritableRaster wr;
DirectColorModel dcm = (DirectColorModel) model;
boolean hasAlpha = model.hasAlpha();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2013, 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
@ -295,7 +295,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp {
}
}
private final BufferedImage ICCBIFilter(BufferedImage src,
private BufferedImage ICCBIFilter(BufferedImage src,
ColorSpace srcColorSpace,
BufferedImage dest,
ColorSpace destColorSpace) {
@ -753,7 +753,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp {
return hints;
}
private final BufferedImage nonICCBIFilter(BufferedImage src,
private BufferedImage nonICCBIFilter(BufferedImage src,
ColorSpace srcColorSpace,
BufferedImage dst,
ColorSpace dstColorSpace) {
@ -947,7 +947,7 @@ public class ColorConvertOp implements BufferedImageOp, RasterOp {
/* color convert a Raster - handles byte, ushort, int, short, float,
or double transferTypes */
private final WritableRaster nonICCRasterFilter(Raster src,
private WritableRaster nonICCRasterFilter(Raster src,
WritableRaster dst) {
if (CSList.length != 2) {

View File

@ -755,7 +755,7 @@ public class IndexColorModel extends ColorModel {
* value is used to mask off the pixel parameters for methods such
* as getRed(), getGreen(), getBlue(), getAlpha(), and getRGB().
*/
private final void calculatePixelMask() {
private void calculatePixelMask() {
// Note that we adjust the mask so that our masking behavior here
// is consistent with that of our native rendering loops.
int maskbits = pixel_bits;

View File

@ -1,6 +1,6 @@
/*
* Copyright (c) 1997, 2016, 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
@ -472,7 +472,7 @@ public class LookupOp implements BufferedImageOp, RasterOp {
return hints;
}
private final void byteFilter(ByteLookupTable lookup, Raster src,
private void byteFilter(ByteLookupTable lookup, Raster src,
WritableRaster dst,
int width, int height, int numBands) {
int[] srcPix = null;
@ -519,7 +519,7 @@ public class LookupOp implements BufferedImageOp, RasterOp {
}
}
private final void shortFilter(ShortLookupTable lookup, Raster src,
private void shortFilter(ShortLookupTable lookup, Raster src,
WritableRaster dst,
int width, int height, int numBands) {
int band;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2000, 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
@ -43,7 +43,7 @@ package java.awt.image;
* @see ShortLookupTable
* @see LookupOp
*/
public abstract class LookupTable extends Object{
public abstract class LookupTable {
/**
* Constants

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, 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
@ -775,8 +775,7 @@ public abstract class JComponent extends Container implements Serializable,
* transform. If you need to do these operations you may find it
* easier to create a new <code>Graphics</code> from the passed in
* <code>Graphics</code> and manipulate it. Further, if you do not
* invoker super's implementation you must honor the opaque property,
* that is
* invoke super's implementation you must honor the opaque property, that is
* if this component is opaque, you must completely fill in the background
* in an opaque color. If you do not honor the opaque property you
* will likely see visual artifacts.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, 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
@ -102,7 +102,7 @@ public class EventListenerList implements Serializable {
/* A null array to be shared by all empty listener lists*/
private static final Object[] NULL_ARRAY = new Object[0];
/** The list of ListenerType - Listener pairs */
protected transient Object[] listenerList = NULL_ARRAY;
protected transient volatile Object[] listenerList = NULL_ARRAY;
/**
* Passes back the event listener list as an array

View File

@ -75,7 +75,8 @@ public class BasicButtonListener implements MouseListener, MouseMotionListener,
checkOpacity((AbstractButton) e.getSource() );
}
else if(prop == AbstractButton.TEXT_CHANGED_PROPERTY ||
"font" == prop || "foreground" == prop) {
"font" == prop || "foreground" == prop ||
"ancestor" == prop || "graphicsConfiguration" == prop) {
AbstractButton b = (AbstractButton) e.getSource();
BasicHTML.updateRenderer(b, b.getText());
}

View File

@ -472,7 +472,8 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener
public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
if (name == "text" || "font" == name || "foreground" == name) {
if (name == "text" || "font" == name || "foreground" == name ||
"ancestor" == name || "graphicsConfiguration" == name) {
// remove the old html view client property if one
// existed, and install a new one if the text installed
// into the JLabel is html source.

View File

@ -1106,7 +1106,8 @@ public class BasicMenuItemUI extends MenuItemUI
name == "accelerator") {
updateAcceleratorBinding();
} else if (name == "text" || "font" == name ||
"foreground" == name) {
"foreground" == name ||
"ancestor" == name || "graphicsConfiguration" == name) {
// remove the old html view client property if one
// existed, and install a new one if the text installed
// into the JLabel is html source.

View File

@ -226,8 +226,13 @@ public class BasicMenuUI extends BasicMenuItemUI
return (MenuKeyListener)getHandler();
}
public Dimension getMinimumSize(JComponent c) {
return (((JMenu)menuItem).isTopLevelMenu()) ?
c.getPreferredSize() : null;
}
public Dimension getMaximumSize(JComponent c) {
if (((JMenu)menuItem).isTopLevelMenu() == true) {
if (((JMenu)menuItem).isTopLevelMenu()) {
Dimension d = c.getPreferredSize();
return new Dimension(d.width, Short.MAX_VALUE);
}

View File

@ -261,7 +261,8 @@ public class BasicToolTipUI extends ToolTipUI
public void propertyChange(PropertyChangeEvent e) {
String name = e.getPropertyName();
if (name.equals("tiptext") || "font".equals(name) ||
"foreground".equals(name)) {
"foreground".equals(name) ||
"ancestor" == name || "graphicsConfiguration" == name) {
// remove the old html view client property if one
// existed, and install a new one if the text installed
// into the JLabel is html source.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, 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
@ -3490,7 +3490,7 @@ public class BasicTreeUI extends TreeUI
* the destination it is constructed with. It is assumed all the
* events are currently target at source.
*/
public class MouseInputHandler extends Object implements
public class MouseInputHandler implements
MouseInputListener
{
/** Source that events are coming from. */

View File

@ -227,7 +227,8 @@ public class SynthToolTipUI extends BasicToolTipUI
}
String name = e.getPropertyName();
if (name.equals("tiptext") || "font".equals(name) ||
"foreground".equals(name)) {
"foreground".equals(name) ||
"ancestor" == name || "graphicsConfiguration" == name) {
// remove the old html view client property if one
// existed, and install a new one if the text installed
// into the JLabel is html source.

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, 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
@ -83,7 +83,7 @@ import javax.swing.event.SwingPropertyChangeSupport;
* @see JTable#getCellEditor(int, int)
*/
@SuppressWarnings("serial") // Same-version serialization only
public class TableColumn extends Object implements Serializable {
public class TableColumn implements Serializable {
/**
* Obsolete as of Java 2 platform v1.3. Please use string literals to identify

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2016, 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
@ -1797,7 +1797,7 @@ public abstract class AbstractDocument implements Document, Serializable {
}
}
private final void indent(PrintWriter out, int n) {
private void indent(PrintWriter out, int n) {
for (int i = 0; i < n; i++) {
out.print(" ");
}
@ -2063,7 +2063,7 @@ public abstract class AbstractDocument implements Document, Serializable {
}
}
private final void checkForIllegalCast() {
private void checkForIllegalCast() {
Thread t = getCurrentWriter();
if ((t == null) || (t != Thread.currentThread())) {
throw new StateInvariantError("Illegal cast to MutableAttributeSet");

View File

@ -59,7 +59,8 @@ class GlyphPainter1 extends GlyphView.GlyphPainter {
sync(v);
Segment text = v.getText(p0, p1);
int[] justificationData = getJustificationData(v);
int width = Utilities.getTabbedTextWidth(v, text, metrics, (int) x, e, p0,
int width = Utilities.getTabbedTextWidth(v, text, metrics, (int)x, e, p0,
justificationData);
SegmentCache.releaseSharedSegment(text);
return width;
@ -222,10 +223,15 @@ class GlyphPainter1 extends GlyphView.GlyphPainter {
@SuppressWarnings("deprecation")
void sync(GlyphView v) {
Font f = v.getFont();
if ((metrics == null) || (! f.equals(metrics.getFont()))) {
FontMetrics fm = null;
Container c = v.getContainer();
if (c != null) {
fm = c.getFontMetrics(f);
}
if ((metrics == null) || (! f.equals(metrics.getFont()))
|| (! metrics.equals(fm))) {
// fetch a new FontMetrics
Container c = v.getContainer();
metrics = (c != null) ? c.getFontMetrics(f) :
metrics = (c != null) ? fm :
Toolkit.getDefaultToolkit().getFontMetrics(f);
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -2422,7 +2422,7 @@ class Parser implements DTDConstants {
private int currentPosition;
private final int readCh() throws IOException {
private int readCh() throws IOException {
if (pos >= len) {

View File

@ -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
@ -82,7 +82,7 @@ import java.beans.ConstructorProperties;
* @author Philip Milne
*/
@SuppressWarnings("serial") // Same-version serialization only
public class TreePath extends Object implements Serializable {
public class TreePath implements Serializable {
/** Path representing the parent, null if lastPathComponent represents
* the root. */
private TreePath parentPath;

View File

@ -48,6 +48,8 @@ import sun.awt.AppContext;
import sun.awt.AWTPermissions;
import sun.security.util.SecurityConstants;
import static java.lang.StackWalker.*;
import static java.lang.StackWalker.Option.*;
/**
@ -106,11 +108,90 @@ class AppletSecurity extends AWTSecurityManager {
});
}
private static final StackWalker walker =
AccessController.doPrivileged(
(PrivilegedAction<StackWalker>) () ->
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.
* <p>
* This method will return
* <code>null</code> in the following three cases:
* <ol>
* <li>All methods on the execution stack are from classes
* defined using the system class loader or one of its ancestors.
*
* <li>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.
*
* <li> A call to <code>checkPermission</code> with
* <code>java.security.AllPermission</code> does not
* result in a SecurityException.
* </ol>
*
* 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

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1999, 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
@ -89,7 +89,7 @@ public class PNGImageDecoder extends ImageDecoder
private void property(String key,float value) {
property(key, Float.valueOf(value));
}
private final void pngassert(boolean b) throws IOException {
private void pngassert(boolean b) throws IOException {
if(!b) {
PNGException e = new PNGException("Broken file");
e.printStackTrace();
@ -692,20 +692,20 @@ public class PNGImageDecoder extends ImageDecoder
fill();
return limit-pos>=n;
}
private final int getInt(int pos) {
private int getInt(int pos) {
return ((inbuf[pos ]&0xFF)<<24)
| ((inbuf[pos+1]&0xFF)<<16)
| ((inbuf[pos+2]&0xFF)<< 8)
| ((inbuf[pos+3]&0xFF) );
}
private final int getShort(int pos) {
private int getShort(int pos) {
return (short)(((inbuf[pos ]&0xFF)<<8)
| ((inbuf[pos+1]&0xFF) ));
}
private final int getByte(int pos) {
private int getByte(int pos) {
return inbuf[pos]&0xFF;
}
private final boolean getChunk() throws IOException {
private boolean getChunk() throws IOException {
chunkLength = 0;
if (!need(8)) return false;
chunkLength = getInt(pos);

View File

@ -40,6 +40,7 @@ import sun.java2d.SunGraphics2D;
import sun.java2d.SurfaceManagerFactory;
import sun.java2d.DestSurfaceProvider;
import sun.java2d.Surface;
import sun.java2d.pipe.Region;
import static sun.java2d.pipe.hw.AccelSurface.*;
/**
@ -245,8 +246,8 @@ public class SunVolatileImage extends VolatileImage
* or a backup surface with the given horizontal and vertical scale factors.
*/
public BufferedImage getBackupImage(double scaleX, double scaleY) {
int w = (int) Math.ceil(getWidth() * scaleX);
int h = (int) Math.ceil(getHeight() * scaleY);
int w = Region.clipRound(getWidth() * scaleX);
int h = Region.clipRound(getHeight() * scaleY);
return graphicsConfig.createCompatibleImage(w, h, getTransparency());
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -310,7 +310,7 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La
return new Rectangle2D.Float(l, t, r - l, b - t);
}
private final StandardGlyphVector getGV() {
private StandardGlyphVector getGV() {
if (gv == null) {
gv = createGV();
}
@ -543,7 +543,7 @@ class ExtendedTextSourceLabel extends ExtendedTextLabel implements Decoration.La
}
}
private final float[] getCharinfo() {
private float[] getCharinfo() {
if (charinfo == null) {
charinfo = createCharinfo();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -998,14 +998,14 @@ public class StandardGlyphVector extends GlyphVector {
}
// called by getGlyphsPixelBounds
private final void setDTX(AffineTransform tx) {
private void setDTX(AffineTransform tx) {
if (!equalNonTranslateTX(dtx, tx)) {
resetDTX(getNonTranslateTX(tx));
}
}
// called by most functions
private final void setFRCTX() {
private void setFRCTX() {
if (!equalNonTranslateTX(frctx, dtx)) {
resetDTX(getNonTranslateTX(frctx));
}
@ -1016,7 +1016,7 @@ public class StandardGlyphVector extends GlyphVector {
* must not contain translation.
* Called by setRenderTransform, setDTX, initFontData.
*/
private final void resetDTX(AffineTransform at) {
private void resetDTX(AffineTransform at) {
fsref = null;
dtx = at;
invdtx = null;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 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
@ -147,7 +147,7 @@ public class TextSourceLabel extends TextLabel {
return createLogicalBounds();
}
private final GlyphVector getGV() {
private GlyphVector getGV() {
if (gv == null) {
gv = createGV();
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -106,11 +106,11 @@ public class TrueTypeGlyphMapper extends CharToGlyphMapper {
cmap = CMap.theNullCmap;
}
private final char remapJAChar(char unicode) {
private char remapJAChar(char unicode) {
return (unicode == REVERSE_SOLIDUS) ? JA_YEN : unicode;
}
private final int remapJAIntChar(int unicode) {
private int remapJAIntChar(int unicode) {
return (unicode == REVERSE_SOLIDUS) ? JA_YEN : unicode;
}

View File

@ -3146,6 +3146,14 @@ public final class SunGraphics2D
double widthScale = ((double) rvWidth) / width;
double heightScale = ((double) rvHeight) / height;
if (resolutionVariant instanceof VolatileImage) {
SurfaceData sd = SurfaceManager
.getManager(resolutionVariant)
.getPrimarySurfaceData();
widthScale *= sd.getDefaultScaleX();
heightScale *= sd.getDefaultScaleY();
}
sx1 = Region.clipScale(sx1, widthScale);
sy1 = Region.clipScale(sy1, heightScale);
sx2 = Region.clipScale(sx2, widthScale);

View File

@ -227,7 +227,7 @@ public final class DMarlinRenderingEngine extends RenderingEngine
pc2d);
}
private final double userSpaceLineWidth(AffineTransform at, double lw) {
private double userSpaceLineWidth(AffineTransform at, double lw) {
double widthScale;

View File

@ -227,7 +227,7 @@ public final class MarlinRenderingEngine extends RenderingEngine
pc2d);
}
private final float userSpaceLineWidth(AffineTransform at, float lw) {
private float userSpaceLineWidth(AffineTransform at, float lw) {
float widthScale;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 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
@ -152,7 +152,7 @@ public abstract class AccumulativeRunnable<T> implements Runnable {
*
* @return accumulated arguments
*/
private final synchronized List<T> flush() {
private synchronized List<T> flush() {
List<T> list = arguments;
arguments = null;
return list;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2004, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 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
@ -24,9 +24,21 @@
*/
package sun.swing;
import java.awt.*;
import java.awt.image.*;
import java.util.*;
import sun.awt.image.SurfaceManager;
import sun.java2d.SurfaceData;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.Image;
import java.awt.geom.AffineTransform;
import java.awt.image.AbstractMultiResolutionImage;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.awt.image.VolatileImage;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
/**
* A base class used for icons or images that are expensive to paint.
@ -129,6 +141,22 @@ public abstract class CachedPainter {
}
if (image == null) {
// Recreate the image
if( config != null && (w != baseHeight || h != baseWidth)) {
AffineTransform tx = config.getDefaultTransform();
double sx = tx.getScaleX();
double sy = tx.getScaleY();
if ( Double.compare(sx, 1) != 0 ||
Double.compare(sy, 1) != 0) {
if (Math.abs(sx * baseWidth - w) < 1 &&
Math.abs(sy * baseHeight - h) < 1) {
w = baseWidth;
h = baseHeight;
} else {
w = (int)Math.ceil(w / sx);
h = (int)Math.ceil(w / sy);
}
}
}
image = createImage(c, w, h, config, args);
cache.setImage(key, config, w, h, args, image);
draw = true;
@ -139,10 +167,24 @@ public abstract class CachedPainter {
if (draw) {
// Render to the Image
Graphics2D g2 = (Graphics2D) image.getGraphics();
if (volatileImage == null && (w != baseWidth || h != baseHeight)) {
g2.scale((double) w / baseWidth, (double) h / baseHeight);
if (volatileImage == null) {
if ((w != baseWidth || h != baseHeight)) {
g2.scale((double) w / baseWidth,
(double) h / baseHeight);
}
paintToImage(c, image, g2, baseWidth, baseHeight, args);
} else {
SurfaceData sd = SurfaceManager.getManager(volatileImage)
.getPrimarySurfaceData();
double sx = sd.getDefaultScaleX();
double sy = sd.getDefaultScaleY();
if ( Double.compare(sx, 1) != 0 ||
Double.compare(sy, 1) != 0) {
g2.scale(1 / sx, 1 / sy);
}
paintToImage(c, image, g2, (int)Math.ceil(w * sx),
(int)Math.ceil(h * sy), args);
}
paintToImage(c, image, g2, baseWidth, baseHeight, args);
g2.dispose();
}
@ -288,4 +330,4 @@ public abstract class CachedPainter {
return Arrays.asList(getResolutionVariant(baseWidth, baseHeight));
}
}
}
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 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
@ -113,7 +113,7 @@ public class XBaseWindow {
// internal lock for synchronizing state changes and paint calls, initialized in preInit.
// the order with other locks: AWTLock -> stateLock
static class StateLock extends Object { }
static class StateLock { }
protected StateLock state_lock;
/**
@ -315,7 +315,7 @@ public class XBaseWindow {
* Creates window with parameters specified by {@code params}
* @see #init
*/
private final void create(XCreateWindowParams params) {
private void create(XCreateWindowParams params) {
XToolkit.awtLock();
try {
XSetWindowAttributes xattr = new XSetWindowAttributes();

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 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,7 +54,7 @@ public class X11Renderer implements
: new X11Renderer());
}
private final long validate(SunGraphics2D sg2d) {
private long validate(SunGraphics2D sg2d) {
// NOTE: getCompClip() will revalidateAll() if the
// surfaceData is invalid. This should ensure that
// the clip and pixel that we are validating against

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 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
@ -69,7 +69,7 @@ public class XRRenderer implements PixelDrawPipe, PixelFillPipe, ShapeDrawPipe {
* Common validate method, used by all XRRender functions to validate the
* destination context.
*/
private final void validateSurface(SunGraphics2D sg2d) {
private void validateSurface(SunGraphics2D sg2d) {
XRSurfaceData xrsd;
try {
xrsd = (XRSurfaceData) sg2d.surfaceData;

View File

@ -498,7 +498,7 @@ final class WInputMethod extends InputMethodAdapter
// set Clause and Reading Information
if (clauseBoundary!=null && clauseReading!=null &&
clauseReading.length!=0 && clauseBoundary.length==clauseReading.length+1 &&
clauseBoundary[0]==0 && clauseBoundary[clauseReading.length]==text.length() )
clauseBoundary[0]==0 && clauseBoundary[clauseReading.length]<=text.length() )
{
for (int i=0; i<clauseBoundary.length-1; i++) {
attrStr.addAttribute(Attribute.INPUT_METHOD_SEGMENT,

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