diff --git a/make/Images.gmk b/make/Images.gmk index acdc594b0097e..5f987a2f71a7d 100644 --- a/make/Images.gmk +++ b/make/Images.gmk @@ -281,27 +281,6 @@ else endif CMDS_TARGET_SUBDIR := bin -# Param 1 - dir to find debuginfo files in -FindDebuginfoFiles = \ - $(wildcard $(addprefix $1/*, $(DEBUGINFO_SUFFIXES)) \ - $(addprefix $1/*/*, $(DEBUGINFO_SUFFIXES)) \ - $(addprefix $1/*/*/*, $(DEBUGINFO_SUFFIXES))) - -# Pick the correct debug info files to copy, either zipped or not. -ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true) - DEBUGINFO_SUFFIXES += .diz -else - DEBUGINFO_SUFFIXES := .debuginfo .pdb .map - # On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM - # dirs. - ifeq ($(call isTargetOs, macosx), true) - $(call FillFindCache, \ - $(SUPPORT_OUTPUTDIR)/modules_libs $(SUPPORT_OUTPUTDIR)/modules_cmds) - FindDebuginfoFiles = \ - $(if $(wildcard $1), $(call containing, .dSYM/, $(call FindFiles, $1))) - endif -endif - # Param 1 - either JDK or JRE SetupCopyDebuginfo = \ $(foreach m, $(ALL_$1_MODULES), \ diff --git a/make/Main.gmk b/make/Main.gmk index 152dbf17cd3c9..ddcc0c7f67412 100644 --- a/make/Main.gmk +++ b/make/Main.gmk @@ -454,6 +454,18 @@ $(eval $(call SetupTarget, symbols-image, \ TARGET := symbols, \ )) +$(eval $(call SetupTarget, static-launcher, \ + MAKEFILE := StaticLibs, \ + TARGET := static-launcher, \ + DEPS := hotspot-static-libs static-libs, \ +)) + +$(eval $(call SetupTarget, static-jdk-image, \ + MAKEFILE := StaticLibs, \ + TARGET := static-jdk-image, \ + DEPS := static-exploded-image jdk-image, \ +)) + $(eval $(call SetupTarget, static-libs-image, \ MAKEFILE := StaticLibsImage, \ TARGET := static-libs-image, \ @@ -1086,9 +1098,9 @@ else symbols-image: $(LIBS_TARGETS) $(LAUNCHER_TARGETS) - static-libs-image: hotspot-static-libs $(STATIC_LIBS_TARGETS) + static-libs-image: hotspot-static-libs static-libs - static-libs-graal-image: $(STATIC_LIBS_TARGETS) + static-libs-graal-image: static-libs bootcycle-images: jdk-image @@ -1254,6 +1266,8 @@ ifeq ($(call isTargetOs, macosx), true) legacy-images: mac-legacy-jre-bundle endif +static-exploded-image: static-launcher exploded-image + # These targets build the various documentation images docs-jdk-image: docs-jdk docs-javase-image: docs-javase @@ -1296,7 +1310,7 @@ endif ################################################################################ # all-images builds all our deliverables as images. -all-images: product-images test-image all-docs-images +all-images: product-images static-jdk-image test-image all-docs-images # all-bundles packages all our deliverables as tar.gz bundles. all-bundles: product-bundles test-bundles docs-bundles static-libs-bundles @@ -1309,7 +1323,7 @@ ALL_TARGETS += buildtools hotspot hotspot-libs hotspot-static-libs \ create-buildjdk docs-jdk-api docs-javase-api docs-reference-api docs-jdk \ docs-javase docs-reference docs-javadoc mac-bundles product-images legacy-images \ docs-image docs-javase-image docs-reference-image all-docs-images \ - docs-bundles all-docs-bundles test-image all-images \ + docs-bundles all-docs-bundles test-image all-images static-exploded-image \ all-bundles ################################################################################ diff --git a/make/ModuleWrapper.gmk b/make/ModuleWrapper.gmk index 14298d25a5398..e99f34cdd716f 100644 --- a/make/ModuleWrapper.gmk +++ b/make/ModuleWrapper.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2014, 2024, 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 @@ -45,6 +45,23 @@ TARGETS := # Include the file being wrapped. include $(MAKEFILE_PREFIX).gmk +ifeq ($(MAKEFILE_PREFIX), Lib) + # We need to keep track of what libraries are generated/needed by this + # module. This information is required when doing static linking, to know + # which static library files to include. The variable $(MODULE)_INCLUDED_LIBS is + # added to for each call to SetupJdkLibrary. The file module-included-libs.txt is then + # read in StaticLibs.gmk. + ifneq ($($(MODULE)_JDK_LIBS), ) + LIBLIST := $(SUPPORT_OUTPUTDIR)/modules_static-libs/$(MODULE)/module-included-libs.txt + + $(LIBLIST): $(TARGETS) + $(call MakeDir, $(@D)) + $(ECHO) $($(MODULE)_INCLUDED_LIBS) > $@ + + TARGETS += $(LIBLIST) + endif +endif + # Setup copy rules from the modules directories to the jdk image directory. ifeq ($(call isTargetOs, windows), true) TO_BIN_FILTER := %$(SHARED_LIBRARY_SUFFIX) %.diz %.pdb %.map diff --git a/make/StaticLibs.gmk b/make/StaticLibs.gmk new file mode 100644 index 0000000000000..78918c456eed9 --- /dev/null +++ b/make/StaticLibs.gmk @@ -0,0 +1,191 @@ +# +# Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +default: all + +include $(SPEC) +include MakeBase.gmk + +include CopyFiles.gmk +include Modules.gmk +include modules/LauncherCommon.gmk + +################################################################################ +# +# Create the static java launcher +# +################################################################################ + +STATIC_JDK_IMAGE_DIR := $(IMAGES_OUTPUTDIR)/static-jdk +STATIC_LAUNCHER_OUTPUT_DIR := $(SUPPORT_OUTPUTDIR)/static-native/launcher +HOTSPOT_STATIC_LIB_PATH := $(HOTSPOT_OUTPUTDIR)/*/libjvm/objs/static + +ifneq ($(word 2, $(wildcard $(HOTSPOT_STATIC_LIB_PATH))), ) + $(error Cannot perform static linking when building more than one JVM library) +endif + +# Find all modules with static libraries +STATIC_LIB_MODULES := $(patsubst $(SUPPORT_OUTPUTDIR)/modules_static-libs/%, \ + %, $(wildcard $(SUPPORT_OUTPUTDIR)/modules_static-libs/*)) + +# Filter out known broken libraries. This is a temporary measure until +# proper support for these libraries can be provided. +ifeq ($(call isTargetOs, linux), true) + # libsplashscreen has a name conflict with libawt in the function + # BitmapToYXBandedRectangles, so we exclude it for now. + BROKEN_STATIC_LIBS += splashscreen +else ifeq ($(call isTargetOs, macosx), true) + # libosxsecurity has a name conflict with libosxapp in the function + # JavaStringToNSString, so we exclude it for now. + BROKEN_STATIC_LIBS += osxsecurity +else ifeq ($(call isTargetOs, windows), true) + # libsplashscreen has a name conflict with libawt in the function + # BitmapToYXBandedRectangles, so we exclude it for now. + BROKEN_STATIC_LIBS += splashscreen + # libsspi_bridge has name conflicts with sunmscapi + BROKEN_STATIC_LIBS += sspi_bridge + # These libs define DllMain which conflict with Hotspot + BROKEN_STATIC_LIBS += awt dt_shmem dt_socket + # These libs are dependent on any of the above disabled libs + BROKEN_STATIC_LIBS += fontmanager jawt lcms net nio +endif + +$(foreach module, $(STATIC_LIB_MODULES), \ + $(eval LIBS_$(module) := $(filter-out $(BROKEN_STATIC_LIBS), $(shell cat \ + $(SUPPORT_OUTPUTDIR)/modules_static-libs/$(module)/module-included-libs.txt))) \ +) + +STATIC_LIB_FILES := $(foreach module, $(STATIC_LIB_MODULES), \ + $(foreach lib, $(LIBS_$(module)), \ + $(SUPPORT_OUTPUTDIR)/native/$(module)/lib$(lib)/static/$(LIBRARY_PREFIX)$(lib)$(STATIC_LIBRARY_SUFFIX))) + +# Add Hotspot +STATIC_LIB_FILES += $(wildcard $(HOTSPOT_STATIC_LIB_PATH)/$(LIBRARY_PREFIX)jvm$(STATIC_LIBRARY_SUFFIX)) + +# Figure out what external libraries are required to link these static JDK +# libraries. +LIB_FLAGS_FILES := $(addsuffix .lib-flags.txt, $(STATIC_LIB_FILES)) + +# Gather the lib flags from all individual libraries. There are many duplicates, +# so sort and just keep unique instances. On macOS, a common pattern is +# "-framework FooFramework", so we must make sure we keep the two words together. +EXTERNAL_LIBS := $(strip $(shell $(CAT) $(LIB_FLAGS_FILES) | \ + $(SED) -e 's/-framework /-framework_/g' | $(TR) ' ' '\n' | $(SORT) -u | \ + $(SED) -e 's/-framework_/-framework /g')) + +ifeq ($(call isTargetOs, macosx), true) + STATIC_LIBS := $(addprefix -force_load$(SPACE), $(STATIC_LIB_FILES)) + STANDARD_LIBS += -lstdc++ +else ifeq ($(call isTargetOs, linux), true) + STATIC_LIBS := -Wl,--export-dynamic -Wl,--whole-archive $(STATIC_LIB_FILES) -Wl,--no-whole-archive + STANDARD_LIBS := -l:libstdc++.a +else ifeq ($(call isTargetOs, windows), true) + STATIC_LIBS := $(addprefix -wholearchive:, $(STATIC_LIB_FILES)) +else + $(error Unsupported platform) +endif + +$(eval $(call SetupBuildLauncher, java, \ + CFLAGS := -DEXPAND_CLASSPATH_WILDCARDS -DENABLE_ARG_FILES, \ + EXTRA_RCFLAGS := $(JAVA_RCFLAGS), \ + VERSION_INFO_RESOURCE := $(JAVA_VERSION_INFO_RESOURCE), \ + OPTIMIZATION := HIGH, \ + STATIC_LAUNCHER := true, \ + LDFLAGS := $(LDFLAGS_STATIC_JDK), \ + LIBS := $(STATIC_LIBS) $(EXTERNAL_LIBS) $(STANDARD_LIBS), \ + OUTPUT_DIR := $(STATIC_LAUNCHER_OUTPUT_DIR), \ + OBJECT_DIR := $(STATIC_LAUNCHER_OUTPUT_DIR), \ +)) + +$(java): $(STATIC_LIB_FILES) + +TARGETS += $(java) + +JAVA_LAUNCHER := $(BUILD_LAUNCHER_java_TARGET) + +static-launcher: $(java) + +################################################################################ +# +# Create the static-jdk image with the statically built java launcher +# +################################################################################ + +# Until we get proper support in jlink for generating an image with static +# builds, we need to create the image ourselves. We base it on a normal +# dynamically linked JDK image. + +# All these files/dirs should be copied as-is +JDK_IMAGE_COPY_FILES := $(addprefix $(JDK_IMAGE_DIR)/, conf demo include jmods \ + legal man/man1/java.1 release README) + +# We need to copy some files from lib, but not the dynamic libraries themselves +ALL_LIB_FILES := $(call FindFiles, $(JDK_IMAGE_DIR)/lib) + +# Remove all dynamic libraries from the list +JDK_IMAGE_COPY_LIB_FILES := $(filter-out %$(SHARED_LIBRARY_SUFFIX), $(ALL_LIB_FILES)) +# Remove all debug files from the list +ifeq ($(call isTargetOs, macosx), true) + JDK_IMAGE_COPY_LIB_FILES := $(call not-containing, .dSYM, $(JDK_IMAGE_COPY_LIB_FILES)) +else + JDK_IMAGE_COPY_LIB_FILES := $(filter-out %.debuginfo %.pdb %.map, $(JDK_IMAGE_COPY_LIB_FILES)) +endif + +static-jdk-info: + $(call LogWarn, Creating static-jdk image) + +$(eval $(call SetupCopyFiles, copy-from-jdk-image, \ + SRC := $(JDK_IMAGE_DIR), \ + DEST := $(STATIC_JDK_IMAGE_DIR), \ + FILES := $(call FindFiles, $(JDK_IMAGE_COPY_FILES)) \ + $(JDK_IMAGE_COPY_LIB_FILES), \ +)) + +TARGETS += $(copy-from-jdk-image) + +$(copy-from-jdk-image): | static-jdk-info + +$(eval $(call SetupCopyFiles, copy-static-launcher, \ + FILES := $(JAVA_LAUNCHER), \ + DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \ +)) + +TARGETS += $(copy-static-launcher) + +$(eval $(call SetupCopyFiles, copy-static-launcher-debuginfo, \ + SRC := $(STATIC_LAUNCHER_OUTPUT_DIR), \ + DEST := $(STATIC_JDK_IMAGE_DIR)/bin, \ + FILES := $(call FindDebuginfoFiles, $(STATIC_LAUNCHER_OUTPUT_DIR)), \ +)) + +TARGETS += $(copy-static-launcher-debuginfo) + +static-jdk-image: $(copy-from-jdk-image) $(copy-static-launcher) $(copy-static-launcher-debuginfo) + +TARGETS += static-jdk-image + +all: $(TARGETS) + +.PHONY: all static-launcher static-jdk-image diff --git a/make/autoconf/flags-ldflags.m4 b/make/autoconf/flags-ldflags.m4 index 851b3b7a0ef95..ffb1f0d6e1979 100644 --- a/make/autoconf/flags-ldflags.m4 +++ b/make/autoconf/flags-ldflags.m4 @@ -192,18 +192,23 @@ AC_DEFUN([FLAGS_SETUP_LDFLAGS_CPU_DEP], # Export variables according to old definitions, prefix with $2 if present. LDFLAGS_JDK_COMMON="$BASIC_LDFLAGS $BASIC_LDFLAGS_JDK_ONLY \ $OS_LDFLAGS $DEBUGLEVEL_LDFLAGS_JDK_ONLY ${$2EXTRA_LDFLAGS}" - $2LDFLAGS_JDKLIB="$LDFLAGS_JDK_COMMON $BASIC_LDFLAGS_JDK_LIB_ONLY \ + $2LDFLAGS_JDKLIB="$LDFLAGS_JDK_COMMON \ $SHARED_LIBRARY_FLAGS $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS" $2LDFLAGS_JDKEXE="$LDFLAGS_JDK_COMMON $EXECUTABLE_LDFLAGS \ ${$1_CPU_EXECUTABLE_LDFLAGS} $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS" + $2LDFLAGS_STATIC_JDK="$BASIC_LDFLAGS $BASIC_LDFLAGS_JVM_ONLY \ + $OS_LDFLAGS ${$2EXTRA_LDFLAGS} $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS" + $2JVM_LDFLAGS="$BASIC_LDFLAGS $BASIC_LDFLAGS_JVM_ONLY $OS_LDFLAGS $OS_LDFLAGS_JVM_ONLY \ - $DEBUGLEVEL_LDFLAGS $DEBUGLEVEL_LDFLAGS_JVM_ONLY $BASIC_LDFLAGS_ONLYCXX \ + $DEBUGLEVEL_LDFLAGS $DEBUGLEVEL_LDFLAGS_JVM_ONLY \ ${$1_CPU_LDFLAGS} ${$1_CPU_LDFLAGS_JVM_ONLY} ${$2EXTRA_LDFLAGS} \ $REPRODUCIBLE_LDFLAGS $FILE_MACRO_LDFLAGS" AC_SUBST($2LDFLAGS_JDKLIB) AC_SUBST($2LDFLAGS_JDKEXE) + AC_SUBST($2LDFLAGS_STATIC_JDK) + AC_SUBST($2JVM_LDFLAGS) ]) diff --git a/make/autoconf/jdk-options.m4 b/make/autoconf/jdk-options.m4 index cf8a856de96d2..61638ce5a2c7f 100644 --- a/make/autoconf/jdk-options.m4 +++ b/make/autoconf/jdk-options.m4 @@ -369,6 +369,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_CODE_COVERAGE], CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $GCOV_CFLAGS" LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $GCOV_LDFLAGS" LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $GCOV_LDFLAGS" + LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $GCOV_LDFLAGS" ]) AC_SUBST(GCOV_ENABLED) @@ -463,6 +464,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_ADDRESS_SANITIZER], CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $ASAN_CFLAGS" LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $ASAN_LDFLAGS" LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $ASAN_LDFLAGS" + LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $ASAN_LDFLAGS" ]) AC_SUBST(ASAN_ENABLED) ]) @@ -496,6 +498,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_LEAK_SANITIZER], CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $LSAN_CFLAGS" LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $LSAN_LDFLAGS" LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $LSAN_LDFLAGS" + LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $LSAN_LDFLAGS" ]) AC_SUBST(LSAN_ENABLED) ]) @@ -538,6 +541,7 @@ AC_DEFUN_ONCE([JDKOPT_SETUP_UNDEFINED_BEHAVIOR_SANITIZER], CXXFLAGS_JDKEXE="$CXXFLAGS_JDKEXE $UBSAN_CFLAGS" LDFLAGS_JDKLIB="$LDFLAGS_JDKLIB $UBSAN_LDFLAGS" LDFLAGS_JDKEXE="$LDFLAGS_JDKEXE $UBSAN_LDFLAGS" + LDFLAGS_STATIC_JDK="$LDFLAGS_STATIC_JDK $UBSAN_LDFLAGS" ]) if test "x$UBSAN_ENABLED" = xfalse; then UBSAN_CFLAGS="" diff --git a/make/autoconf/spec.gmk.template b/make/autoconf/spec.gmk.template index bcd54058c28fc..18770c6d36031 100644 --- a/make/autoconf/spec.gmk.template +++ b/make/autoconf/spec.gmk.template @@ -559,6 +559,9 @@ LDFLAGS_JDKLIB := @LDFLAGS_JDKLIB@ # LDFLAGS used to link the jdk native launchers (C-code) LDFLAGS_JDKEXE := @LDFLAGS_JDKEXE@ +# LDFLAGS used to link the static jdk library +LDFLAGS_STATIC_JDK := @LDFLAGS_STATIC_JDK@ + # LDFLAGS specific to C++ linking. LDFLAGS_CXX_JDK := @LDFLAGS_CXX_JDK@ diff --git a/make/common/FileUtils.gmk b/make/common/FileUtils.gmk index d3cc4872ebb8f..d546ab94a58f0 100644 --- a/make/common/FileUtils.gmk +++ b/make/common/FileUtils.gmk @@ -307,3 +307,26 @@ ifeq ($(DISABLE_CACHE_FIND), true) else FindFiles = $(CacheFindFiles) endif + +# Find native debuginfo files in a directory +# +# Param 1 - dir to find debuginfo files in +FindDebuginfoFiles = \ + $(wildcard $(addprefix $1/*, $(DEBUGINFO_SUFFIXES)) \ + $(addprefix $1/*/*, $(DEBUGINFO_SUFFIXES)) \ + $(addprefix $1/*/*/*, $(DEBUGINFO_SUFFIXES))) + +# Pick the correct debug info files to copy, either zipped or not. +ifeq ($(ZIP_EXTERNAL_DEBUG_SYMBOLS), true) + DEBUGINFO_SUFFIXES += .diz +else + DEBUGINFO_SUFFIXES := .debuginfo .pdb .map + # On Macosx, if debug symbols have not been zipped, find all files inside *.dSYM + # dirs. + ifeq ($(call isTargetOs, macosx), true) + $(call FillFindCache, \ + $(SUPPORT_OUTPUTDIR)/modules_libs $(SUPPORT_OUTPUTDIR)/modules_cmds) + FindDebuginfoFiles = \ + $(if $(wildcard $1), $(call containing, .dSYM/, $(call FindFiles, $1))) + endif +endif diff --git a/make/common/JdkNativeCompilation.gmk b/make/common/JdkNativeCompilation.gmk index 52b6dea672594..ca0f1429c6165 100644 --- a/make/common/JdkNativeCompilation.gmk +++ b/make/common/JdkNativeCompilation.gmk @@ -275,6 +275,8 @@ JDK_RCFLAGS=$(RCFLAGS) \ # and EXTRA_HEADER_DIRS will be added. # JDK_LIBS_ or JDK_LIBS_ -- additional JDK_LIBS for the given OS # or OS type only +# ONLY_EXPORTED -- if true, this library will be flagged as not +# to be included for this module when building static libs # EXTRA_RCFLAGS -- additional RCFLAGS to append. # RC_FILEDESC -- override the default FILEDESC for Windows version.rc # DEFAULT_LIBCXX -- if false, do not add LIBCXX to LIBS for C++ compilations @@ -303,6 +305,15 @@ define SetupJdkNativeCompilationBody $1_RC_FTYPE := 0x2L endif + ifneq ($$(MODULE), ) + # Record the fact that this native library is part of the current module + # (unless told otherwise). This variable stores information about all + # created libraries, and is read by ModuleWrapper. + ifneq ($$($1_ONLY_EXPORTED), true) + $$(MODULE)_INCLUDED_LIBS += $$($1_NAME) + endif + endif + ifeq ($$($1_OUTPUT_DIR), ) ifneq ($$(MODULE), ) ifeq ($$($1_TYPE), STATIC_LIBRARY) @@ -422,10 +433,10 @@ define SetupJdkNativeCompilationBody ifneq ($$($1_DEFAULT_LDFLAGS), false) ifeq ($$($1_TYPE), EXECUTABLE) # Set the default flags first to be able to override - $1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKEXE)) $$($1_LDFLAGS) + $1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKEXE) $$($1_LDFLAGS)) else # Set the default flags first to be able to override - $1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKLIB)) $$($1_LDFLAGS) + $1_LDFLAGS := $$(filter-out $$($1_LDFLAGS_FILTER_OUT), $$(LDFLAGS_JDKLIB) $$($1_LDFLAGS)) endif endif diff --git a/make/common/modules/LauncherCommon.gmk b/make/common/modules/LauncherCommon.gmk index b522df076f324..77f39457b4c2d 100644 --- a/make/common/modules/LauncherCommon.gmk +++ b/make/common/modules/LauncherCommon.gmk @@ -62,6 +62,7 @@ JAVA_MANIFEST := $(TOPDIR)/src/java.base/windows/native/launcher/java.manifest # OPTIMIZATION Override default optimization level (LOW) # OUTPUT_DIR Override default output directory # VERSION_INFO_RESOURCE Override default Windows resource file +# STATIC_LAUNCHER If true, will use settings for building a static launcher SetupBuildLauncher = $(NamedParamsMacroTemplate) define SetupBuildLauncherBody # Setup default values (unless overridden) @@ -120,6 +121,15 @@ define SetupBuildLauncherBody $1_EXTRA_FILES += $(TOPDIR)/make/data/lsan/lsan_default_options.c endif + ifneq ($$($1_STATIC_LAUNCHER), true) + $1_JDK_LIBS := java.base:libjli + $1_JDK_LIBS_windows := java.base:libjava + else + ifneq ($(findstring $(TOOLCHAIN_TYPE), gcc clang), ) + $1_LDFLAGS_FILTER_OUT := -Wl$(COMMA)--exclude-libs$(COMMA)ALL + endif + endif + ############################################################################## ## Build launcher "$1" ############################################################################## @@ -140,8 +150,9 @@ define SetupBuildLauncherBody LDFLAGS := $$($1_LDFLAGS), \ LDFLAGS_linux := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \ LDFLAGS_macosx := $$(call SET_EXECUTABLE_ORIGIN,/../lib), \ - JDK_LIBS := java.base:libjli, \ - JDK_LIBS_windows := java.base:libjava, \ + LDFLAGS_FILTER_OUT := $$($1_LDFLAGS_FILTER_OUT), \ + JDK_LIBS := $$($1_JDK_LIBS), \ + JDK_LIBS_windows := $$($1_JDK_LIBS_windows), \ LIBS := $$($1_LIBS), \ LIBS_unix := $(LIBZ_LIBS), \ LIBS_linux := $(LIBDL) -lpthread, \ @@ -150,6 +161,7 @@ define SetupBuildLauncherBody -framework Cocoa \ -framework Security, \ OUTPUT_DIR := $$($1_OUTPUT_DIR), \ + OBJECT_DIR := $$($1_OBJECT_DIR), \ VERSIONINFO_RESOURCE := $$($1_VERSION_INFO_RESOURCE), \ EXTRA_RCFLAGS := $$($1_EXTRA_RCFLAGS), \ MANIFEST := $(JAVA_MANIFEST), \ diff --git a/make/common/native/Link.gmk b/make/common/native/Link.gmk index 23977e954cad3..1461f7302dc43 100644 --- a/make/common/native/Link.gmk +++ b/make/common/native/Link.gmk @@ -119,6 +119,7 @@ define CreateStaticLibrary $(if $$($1_LINK_OBJS_RELATIVE), $$(CD) $$(OUTPUTDIR) ; ) \ $$($1_AR) $$(ARFLAGS) -r -cs $$($1_TARGET) \ $$($1_AR_OBJ_ARG) $$($1_RES)) + $$(ECHO) $$(strip $$($1_LIBS) $$($1_EXTRA_LIBS)) > $$($1_TARGET).lib-flags.txt endef ################################################################################ diff --git a/make/common/native/LinkMicrosoft.gmk b/make/common/native/LinkMicrosoft.gmk index cb457034a7e3b..7c895a9507d18 100644 --- a/make/common/native/LinkMicrosoft.gmk +++ b/make/common/native/LinkMicrosoft.gmk @@ -54,7 +54,8 @@ define CreateStaticLibraryMicrosoft $$(call MakeDir, $$($1_OUTPUT_DIR) $$($1_SYMBOLS_DIR)) $$(call ExecuteWithLog, $$($1_OBJECT_DIR)/$$($1_SAFE_NAME)_run_lib, \ $$($1_LIB) -nologo $$(LIBFLAGS) -out:$$($1_TARGET) \ - $$($1_LD_OBJ_ARG) $$($1_RES)) + $$($1_LD_OBJ_ARG)) + $$(ECHO) $$(strip $$($1_LIBS) $$($1_EXTRA_LIBS)) > $$($1_TARGET).lib-flags.txt endef ################################################################################ diff --git a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java index 8865e3908ae6b..55dd6a8d6ad5b 100644 --- a/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java +++ b/make/jdk/src/classes/build/tools/cldrconverter/CLDRConverter.java @@ -33,6 +33,7 @@ import java.time.*; import java.util.*; import java.util.ResourceBundle.Control; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.IntStream; import java.util.stream.Stream; @@ -1242,7 +1243,8 @@ private static Stream zidMapEntry() { private static Stream tzDataLinkEntry() { try { return Files.walk(Paths.get(tzDataDir), 1) - .filter(p -> !Files.isDirectory(p)) + .filter(p -> p.toFile().isFile()) + .filter(p -> p.getFileName().toString().matches("africa|antarctica|asia|australasia|backward|etcetera|europe|northamerica|southamerica")) .flatMap(CLDRConverter::extractLinks) .sorted(); } catch (IOException e) { @@ -1273,8 +1275,27 @@ private static Stream extractLinks(Path tzFile) { // Note: the entries are alphabetically sorted, *except* the "world" region // code, i.e., "001". It should be the last entry for the same windows time // zone name entries. (cf. TimeZone_md.c) + // + // The default entries from CLDR's windowsZones.xml file can be modified + // with /tzmappings.override where mapping overrides + // can be specified. + private static Pattern OVERRIDE_PATTERN = Pattern.compile("(?([^:]+:[^:]+)):(?[^:]+):"); private static void generateWindowsTZMappings() throws Exception { Files.createDirectories(Paths.get(DESTINATION_DIR, "windows", "conf")); + var override = Path.of(tzDataDir, "tzmappings.override"); + if (override.toFile().exists()) { + Files.readAllLines(override).stream() + .map(String::trim) + .filter(o -> !o.isBlank() && !o.startsWith("#")) + .forEach(o -> { + var m = OVERRIDE_PATTERN.matcher(o); + if (m.matches()) { + handlerWinZones.put(m.group("win"), m.group("java")); + } else { + System.out.printf("Unrecognized tzmappings override: %s. Ignored%n", o); + } + }); + } Files.write(Paths.get(DESTINATION_DIR, "windows", "conf", "tzmappings"), handlerWinZones.keySet().stream() .filter(k -> k.endsWith(":001") || diff --git a/make/modules/java.desktop/lib/AwtLibraries.gmk b/make/modules/java.desktop/lib/AwtLibraries.gmk index 90eda1c4e64cf..5ba7c819008b5 100644 --- a/make/modules/java.desktop/lib/AwtLibraries.gmk +++ b/make/modules/java.desktop/lib/AwtLibraries.gmk @@ -168,10 +168,16 @@ ifeq ($(call isTargetOs, windows macosx), false) # static libraries cause linking errors due to duplicate symbols. LIBAWT_HEADLESS_STATIC_EXCLUDE_OBJS := systemScale.o + ifneq ($(ENABLE_HEADLESS_ONLY), true) + # We cannot link with both awt_headless and awt_xawt at the same time + LIBAWT_HEADLESS_ONLY_EXPORTED := true + endif + $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_HEADLESS, \ NAME := awt_headless, \ EXTRA_SRC := $(LIBAWT_HEADLESS_EXTRA_SRC), \ EXCLUDES := medialib, \ + ONLY_EXPORTED := $(LIBAWT_HEADLESS_ONLY_EXPORTED), \ OPTIMIZATION := LOW, \ CFLAGS := -DHEADLESS=true $(CUPS_CFLAGS) $(FONTCONFIG_CFLAGS) \ $(X_CFLAGS), \ @@ -308,6 +314,8 @@ ifeq ($(call isTargetOs, macosx), true) LIBAWT_LWAWT_EXCLUDE_FILES := fontpath.c awt_Font.c X11Color.c LIBAWT_LWAWT_EXCLUDES := $(TOPDIR)/src/$(MODULE)/unix/native/common/awt/medialib + LIBAWT_LWAWT_STATIC_EXCLUDE_OBJS := systemScale.o + $(eval $(call SetupJdkLibrary, BUILD_LIBAWT_LWAWT, \ NAME := awt_lwawt, \ EXTRA_SRC := $(LIBAWT_LWAWT_EXTRA_SRC), \ @@ -346,6 +354,7 @@ ifeq ($(call isTargetOs, macosx), true) -framework OpenGL \ -framework QuartzCore \ -framework Security, \ + STATIC_LIB_EXCLUDE_OBJS := $(LIBAWT_LWAWT_STATIC_EXCLUDE_OBJS), \ )) TARGETS += $(BUILD_LIBAWT_LWAWT) diff --git a/make/modules/java.desktop/lib/ClientLibraries.gmk b/make/modules/java.desktop/lib/ClientLibraries.gmk index 313230217806d..87f6e2e509994 100644 --- a/make/modules/java.desktop/lib/ClientLibraries.gmk +++ b/make/modules/java.desktop/lib/ClientLibraries.gmk @@ -155,6 +155,9 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) ifeq ($(USE_EXTERNAL_LIBJPEG), false) LIBSPLASHSCREEN_EXTRA_SRC += libjavajpeg + LIBJAVA_JPEG_OBJS := $(sort $(patsubst %.c,%.o, $(filter-out imageioJPEG.c, \ + $(notdir $(wildcard $(TOPDIR)/src/java.desktop/share/native/libjavajpeg/*.c))))) + LIBSPLASHSCREEN_STATIC_LIB_EXCLUDE_OBJS += $(LIBJAVA_JPEG_OBJS) endif ifeq ($(USE_EXTERNAL_LIBPNG), false) @@ -165,6 +168,10 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) ifeq ($(USE_EXTERNAL_LIBZ), false) LIBSPLASHSCREEN_EXTRA_SRC += java.base:libzip/zlib + LIBZIP_SRC_PATH := $(TOPDIR)/src/java.base/share/native/libzip + LIBZIP_OBJS := $(sort $(patsubst %.c,%.o, $(notdir \ + $(wildcard $(LIBZIP_SRC_PATH)/*.c $(LIBZIP_SRC_PATH)/zlib/*.c)))) + LIBSPLASHSCREEN_STATIC_LIB_EXCLUDE_OBJS += $(LIBZIP_OBJS) endif LIBSPLASHSCREEN_CFLAGS += -DSPLASHSCREEN -DPNG_NO_MMX_CODE \ @@ -207,6 +214,8 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) LIBSPLASHSCREEN_CFLAGS += -DWITH_X11 $(X_CFLAGS) endif + LIBSPLASHSCREEN_STATIC_LIB_EXCLUDE_OBJS += systemScale.o + $(eval $(call SetupJdkLibrary, BUILD_LIBSPLASHSCREEN, \ NAME := splashscreen, \ EXTRA_SRC := $(LIBSPLASHSCREEN_EXTRA_SRC), \ @@ -257,6 +266,7 @@ ifeq ($(ENABLE_HEADLESS_ONLY), false) -framework Security, \ LIBS_aix := $(LIBDL) -liconv $(X_LIBS) -lX11 -lXext, \ LIBS_windows := delayimp.lib gdi32.lib kernel32.lib user32.lib, \ + STATIC_LIB_EXCLUDE_OBJS := $(LIBSPLASHSCREEN_STATIC_LIB_EXCLUDE_OBJS), \ )) TARGETS += $(BUILD_LIBSPLASHSCREEN) diff --git a/make/modules/java.xml/Java.gmk b/make/modules/java.xml/Java.gmk index 22c1dde2c2b17..0c174f2113e84 100644 --- a/make/modules/java.xml/Java.gmk +++ b/make/modules/java.xml/Java.gmk @@ -27,5 +27,5 @@ DISABLED_WARNINGS_java += dangling-doc-comments lossy-conversions this-escape DOCLINT += -Xdoclint:all/protected \ '-Xdoclint/package:$(call CommaList, javax.xml.catalog javax.xml.datatype \ javax.xml.transform javax.xml.validation javax.xml.xpath)' -COPY += .dtd .xsd .xml +COPY += .dtd .xsd .xml .ent .mod CLEAN += .properties diff --git a/make/modules/jdk.accessibility/Lib.gmk b/make/modules/jdk.accessibility/Lib.gmk index 6a429a56375ea..6323049c98577 100644 --- a/make/modules/jdk.accessibility/Lib.gmk +++ b/make/modules/jdk.accessibility/Lib.gmk @@ -38,6 +38,7 @@ ifeq ($(call isTargetOs, windows), true) NAME := javaaccessbridge, \ EXTRA_SRC := common, \ OPTIMIZATION := LOW, \ + ONLY_EXPORTED := true, \ DISABLED_WARNINGS_microsoft := 4311 4302 4312, \ CXXFLAGS_FILTER_OUT := -MD, \ CXXFLAGS := -MT -DACCESSBRIDGE_ARCH_64, \ @@ -67,6 +68,7 @@ ifeq ($(call isTargetOs, windows), true) CXXFLAGS := -DACCESSBRIDGE_ARCH_64, \ EXTRA_HEADER_DIRS := \ include/bridge, \ + ONLY_EXPORTED := true, \ LDFLAGS := \ -def:$(ACCESSIBILITY_SRCDIR)/libwindowsaccessbridge/WinAccessBridge.DEF, \ LIBS_windows := advapi32.lib comdlg32.lib gdi32.lib kernel32.lib \ diff --git a/make/modules/jdk.jpackage/Lib.gmk b/make/modules/jdk.jpackage/Lib.gmk index 75548133019a4..33d10336e6e47 100644 --- a/make/modules/jdk.jpackage/Lib.gmk +++ b/make/modules/jdk.jpackage/Lib.gmk @@ -49,6 +49,7 @@ $(eval $(call SetupJdkExecutable, BUILD_JPACKAGEAPPLAUNCHER, \ LINK_TYPE := $(JPACKAGEAPPLAUNCHER_LINK_TYPE), \ OUTPUT_DIR := $(JPACKAGE_OUTPUT_DIR), \ SYMBOLS_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/jpackageapplauncher, \ + ONLY_EXPORTED := true, \ SRC := applauncher, \ EXTRA_SRC := common, \ INCLUDE_FILES := $(JPACKAGEAPPLAUNCHER_INCLUDE_FILES), \ @@ -83,6 +84,7 @@ ifeq ($(call isTargetOs, linux), true) OUTPUT_DIR := $(JPACKAGE_OUTPUT_DIR), \ SYMBOLS_DIR := \ $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjpackageapplauncheraux, \ + ONLY_EXPORTED := true, \ SRC := libapplauncher, \ EXTRA_SRC := \ applauncher \ @@ -127,6 +129,7 @@ ifeq ($(call isTargetOs, windows), true) NAME := wixhelper, \ OUTPUT_DIR := $(JPACKAGE_OUTPUT_DIR), \ SYMBOLS_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libwixhelper, \ + ONLY_EXPORTED := true, \ OPTIMIZATION := LOW, \ EXTRA_SRC := common, \ CXXFLAGS_FILTER_OUT := -MD, \ @@ -146,6 +149,7 @@ ifeq ($(call isTargetOs, windows), true) NAME := msiwrapper, \ OUTPUT_DIR := $(JPACKAGE_OUTPUT_DIR), \ SYMBOLS_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/msiwrapper, \ + ONLY_EXPORTED := true, \ EXTRA_SRC := common, \ CXXFLAGS_FILTER_OUT := -MD, \ CXXFLAGS_windows := -MT $(JPACKAGE_CXXFLAGS_windows), \ @@ -164,6 +168,7 @@ ifeq ($(call isTargetOs, windows), true) OUTPUT_DIR := $(JPACKAGE_OUTPUT_DIR), \ SYMBOLS_DIR := \ $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/jpackageapplauncherw, \ + ONLY_EXPORTED := true, \ SRC := applauncher, \ EXTRA_SRC := common, \ OPTIMIZATION := LOW, \ diff --git a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp index 213aa5efe1ef8..dee64d3db265c 100644 --- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp @@ -2539,13 +2539,11 @@ void LIR_Assembler::emit_typecheck_helper(LIR_OpTypeCheck *op, Label* success, L } else { bool need_slow_path = !k->is_loaded() || ((int) k->super_check_offset() == in_bytes(Klass::secondary_super_cache_offset())); - intptr_t super_check_offset = k->is_loaded() ? k->super_check_offset() : -1L; __ load_klass(klass_RInfo, obj); // Perform the fast part of the checking logic. __ check_klass_subtype_fast_path(klass_RInfo, k_RInfo, Rtmp1, (need_slow_path ? success_target : nullptr), - failure_target, nullptr, - RegisterOrConstant(super_check_offset)); + failure_target, nullptr); if (need_slow_path) { // Call out-of-line instance of __ check_klass_subtype_slow_path(...): address a = Runtime1::entry_for (C1StubId::slow_subtype_check_id); diff --git a/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp b/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp index 8b30adb478559..0ada76ccef780 100644 --- a/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp +++ b/src/hotspot/cpu/s390/c1_Runtime1_s390.cpp @@ -557,7 +557,12 @@ OopMapSet* Runtime1::generate_code_for(C1StubId id, StubAssembler* sasm) { __ z_lg(Rsubklass, 0*BytesPerWord + FrameMap::first_available_sp_in_frame + frame_size, Z_SP); __ z_lg(Rsuperklass, 1*BytesPerWord + FrameMap::first_available_sp_in_frame + frame_size, Z_SP); - __ check_klass_subtype_slow_path(Rsubklass, Rsuperklass, Rarray_ptr, Rlength, nullptr, &miss); + __ check_klass_subtype_slow_path(Rsubklass, + Rsuperklass, + Rarray_ptr /* temp_reg */, + Rlength /* temp2_reg */, + nullptr /* L_success */, + &miss /* L_failure */); // Match falls through here. i = 0; diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/hotspot/cpu/s390/macroAssembler_s390.cpp index 9e1c5cbced364..aacfb894c72d8 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -2981,21 +2981,15 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, Label* L_success, Label* L_failure, Label* L_slow_path, - RegisterOrConstant super_check_offset) { + Register super_check_offset) { + // Input registers must not overlap. + assert_different_registers(sub_klass, super_klass, temp1_reg, super_check_offset); - const int sc_offset = in_bytes(Klass::secondary_super_cache_offset()); const int sco_offset = in_bytes(Klass::super_check_offset_offset()); - - bool must_load_sco = (super_check_offset.constant_or_zero() == -1); - bool need_slow_path = (must_load_sco || - super_check_offset.constant_or_zero() == sc_offset); + bool must_load_sco = ! super_check_offset->is_valid(); // Input registers must not overlap. - assert_different_registers(sub_klass, super_klass, temp1_reg); - if (super_check_offset.is_register()) { - assert_different_registers(sub_klass, super_klass, - super_check_offset.as_register()); - } else if (must_load_sco) { + if (must_load_sco) { assert(temp1_reg != noreg, "supply either a temp or a register offset"); } @@ -3006,9 +3000,7 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, if (L_success == nullptr) { L_success = &L_fallthrough; label_nulls++; } if (L_failure == nullptr) { L_failure = &L_fallthrough; label_nulls++; } if (L_slow_path == nullptr) { L_slow_path = &L_fallthrough; label_nulls++; } - assert(label_nulls <= 1 || - (L_slow_path == &L_fallthrough && label_nulls <= 2 && !need_slow_path), - "at most one null in the batch, usually"); + assert(label_nulls <= 1 || (L_slow_path == &L_fallthrough && label_nulls <= 2), "at most one null in the batch, usually"); BLOCK_COMMENT("check_klass_subtype_fast_path {"); // If the pointers are equal, we are done (e.g., String[] elements). @@ -3023,10 +3015,12 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, // Check the supertype display, which is uint. if (must_load_sco) { z_llgf(Rsuper_check_offset, sco_offset, super_klass); - super_check_offset = RegisterOrConstant(Rsuper_check_offset); + super_check_offset = Rsuper_check_offset; } + Address super_check_addr(sub_klass, super_check_offset, 0); z_cg(super_klass, super_check_addr); // compare w/ displayed supertype + branch_optimized(Assembler::bcondEqual, *L_success); // This check has worked decisively for primary supers. // Secondary supers are sought in the super_cache ('super_cache_addr'). @@ -3044,46 +3038,27 @@ void MacroAssembler::check_klass_subtype_fast_path(Register sub_klass, if (&(label) == &L_fallthrough) { /*do nothing*/ } \ else { branch_optimized(Assembler::bcondAlways, label); } /*omit semicolon*/ - if (super_check_offset.is_register()) { - branch_optimized(Assembler::bcondEqual, *L_success); - z_cfi(super_check_offset.as_register(), sc_offset); - if (L_failure == &L_fallthrough) { - branch_optimized(Assembler::bcondEqual, *L_slow_path); - } else { - branch_optimized(Assembler::bcondNotEqual, *L_failure); - final_jmp(*L_slow_path); - } - } else if (super_check_offset.as_constant() == sc_offset) { - // Need a slow path; fast failure is impossible. - if (L_slow_path == &L_fallthrough) { - branch_optimized(Assembler::bcondEqual, *L_success); - } else { - branch_optimized(Assembler::bcondNotEqual, *L_slow_path); - final_jmp(*L_success); - } + z_cfi(super_check_offset, in_bytes(Klass::secondary_super_cache_offset())); + if (L_failure == &L_fallthrough) { + branch_optimized(Assembler::bcondEqual, *L_slow_path); } else { - // No slow path; it's a fast decision. - if (L_failure == &L_fallthrough) { - branch_optimized(Assembler::bcondEqual, *L_success); - } else { - branch_optimized(Assembler::bcondNotEqual, *L_failure); - final_jmp(*L_success); - } + branch_optimized(Assembler::bcondNotEqual, *L_failure); + final_jmp(*L_slow_path); } bind(L_fallthrough); -#undef local_brc #undef final_jmp BLOCK_COMMENT("} check_klass_subtype_fast_path"); // fallthru (to slow path) } -void MacroAssembler::check_klass_subtype_slow_path(Register Rsubklass, - Register Rsuperklass, - Register Rarray_ptr, // tmp - Register Rlength, // tmp - Label* L_success, - Label* L_failure) { +void MacroAssembler::check_klass_subtype_slow_path_linear(Register Rsubklass, + Register Rsuperklass, + Register Rarray_ptr, // tmp + Register Rlength, // tmp + Label* L_success, + Label* L_failure, + bool set_cond_codes /* unused */) { // Input registers must not overlap. // Also check for R1 which is explicitly used here. assert_different_registers(Z_R1, Rsubklass, Rsuperklass, Rarray_ptr, Rlength); @@ -3106,7 +3081,7 @@ void MacroAssembler::check_klass_subtype_slow_path(Register Rsubklass, NearLabel loop_iterate, loop_count, match; - BLOCK_COMMENT("check_klass_subtype_slow_path {"); + BLOCK_COMMENT("check_klass_subtype_slow_path_linear {"); z_lg(Rarray_ptr, ss_offset, Rsubklass); load_and_test_int(Rlength, Address(Rarray_ptr, length_offset)); @@ -3134,18 +3109,151 @@ void MacroAssembler::check_klass_subtype_slow_path(Register Rsubklass, branch_optimized(Assembler::bcondAlways, *L_failure); // Got a hit. Return success (zero result). Set cache. - // Cache load doesn't happen here. For speed it is directly emitted by the compiler. + // Cache load doesn't happen here. For speed, it is directly emitted by the compiler. BIND(match); - z_stg(Rsuperklass, sc_offset, Rsubklass); // Save result to cache. - + if (UseSecondarySupersCache) { + z_stg(Rsuperklass, sc_offset, Rsubklass); // Save result to cache. + } final_jmp(*L_success); // Exit to the surrounding code. BIND(L_fallthrough); -#undef local_brc #undef final_jmp + BLOCK_COMMENT("} check_klass_subtype_slow_path_linear"); +} + +// If Register r is invalid, remove a new register from +// available_regs, and add new register to regs_to_push. +Register MacroAssembler::allocate_if_noreg(Register r, + RegSetIterator &available_regs, + RegSet ®s_to_push) { + if (!r->is_valid()) { + r = *available_regs++; + regs_to_push += r; + } + return r; +} + +// check_klass_subtype_slow_path_table() looks for super_klass in the +// hash table belonging to super_klass, branching to L_success or +// L_failure as appropriate. This is essentially a shim which +// allocates registers as necessary and then calls +// lookup_secondary_supers_table() to do the work. Any of the temp +// regs may be noreg, in which case this logic will choose some +// registers push and pop them from the stack. +void MacroAssembler::check_klass_subtype_slow_path_table(Register sub_klass, + Register super_klass, + Register temp_reg, + Register temp2_reg, + Register temp3_reg, + Register temp4_reg, + Register result_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes) { + BLOCK_COMMENT("check_klass_subtype_slow_path_table {"); + + RegSet temps = RegSet::of(temp_reg, temp2_reg, temp3_reg, temp4_reg); + + assert_different_registers(sub_klass, super_klass, temp_reg, temp2_reg, temp4_reg); + + Label L_fallthrough; + int label_nulls = 0; + if (L_success == nullptr) { L_success = &L_fallthrough; label_nulls++; } + if (L_failure == nullptr) { L_failure = &L_fallthrough; label_nulls++; } + assert(label_nulls <= 1, "at most one null in the batch"); + + RegSetIterator available_regs + // Z_R0 will be used to hold Z_R15(Z_SP) while pushing a new frame, So don't use that here. + // Z_R1 will be used to hold r_bitmap in lookup_secondary_supers_table_var, so can't be used + // Z_R2, Z_R3, Z_R4 will be used in secondary_supers_verify, for the failure reporting + = (RegSet::range(Z_R0, Z_R15) - temps - sub_klass - super_klass - Z_R1_scratch - Z_R0_scratch - Z_R2 - Z_R3 - Z_R4).begin(); + + RegSet pushed_regs; + + temp_reg = allocate_if_noreg(temp_reg, available_regs, pushed_regs); + temp2_reg = allocate_if_noreg(temp2_reg, available_regs, pushed_regs); + temp3_reg = allocate_if_noreg(temp3_reg, available_regs, pushed_regs);; + temp4_reg = allocate_if_noreg(temp4_reg, available_regs, pushed_regs); + result_reg = allocate_if_noreg(result_reg, available_regs, pushed_regs); + + const int frame_size = pushed_regs.size() * BytesPerWord + frame::z_abi_160_size; + + // Push & save registers + { + int i = 0; + save_return_pc(); + push_frame(frame_size); + + for (auto it = pushed_regs.begin(); *it != noreg; i++) { + z_stg(*it++, i * BytesPerWord + frame::z_abi_160_size, Z_SP); + } + assert(i * BytesPerWord + frame::z_abi_160_size == frame_size, "sanity"); + } + + lookup_secondary_supers_table_var(sub_klass, + super_klass, + temp_reg, temp2_reg, temp3_reg, temp4_reg, result_reg); + + // NOTE: Condition Code should not be altered before jump instruction below !!!! + z_cghi(result_reg, 0); + + { + int i = 0; + for (auto it = pushed_regs.begin(); *it != noreg; ++i) { + z_lg(*it++, i * BytesPerWord + frame::z_abi_160_size, Z_SP); + } + assert(i * BytesPerWord + frame::z_abi_160_size == frame_size, "sanity"); + pop_frame(); + restore_return_pc(); + } + + // NB! Callers may assume that, when set_cond_codes is true, this + // code sets temp2_reg to a nonzero value. + if (set_cond_codes) { + z_lghi(temp2_reg, 1); + } + + branch_optimized(bcondNotEqual, *L_failure); + + if(L_success != &L_fallthrough) { + z_bru(*L_success); + } + + bind(L_fallthrough); + BLOCK_COMMENT("} check_klass_subtype_slow_path_table"); +} + +void MacroAssembler::check_klass_subtype_slow_path(Register sub_klass, + Register super_klass, + Register temp_reg, + Register temp2_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes) { + BLOCK_COMMENT("check_klass_subtype_slow_path {"); + if (UseSecondarySupersTable) { + check_klass_subtype_slow_path_table(sub_klass, + super_klass, + temp_reg, + temp2_reg, + /*temp3*/noreg, + /*temp4*/noreg, + /*result*/noreg, + L_success, + L_failure, + set_cond_codes); + } else { + check_klass_subtype_slow_path_linear(sub_klass, + super_klass, + temp_reg, + temp2_reg, + L_success, + L_failure, + set_cond_codes); + } BLOCK_COMMENT("} check_klass_subtype_slow_path"); } @@ -3206,17 +3314,17 @@ do { \ } while(0) // Note: this method also kills Z_R1_scratch register on machines older than z15 -void MacroAssembler::lookup_secondary_supers_table(Register r_sub_klass, - Register r_super_klass, - Register r_temp1, - Register r_temp2, - Register r_temp3, - Register r_temp4, - Register r_result, - u1 super_klass_slot) { +void MacroAssembler::lookup_secondary_supers_table_const(Register r_sub_klass, + Register r_super_klass, + Register r_temp1, + Register r_temp2, + Register r_temp3, + Register r_temp4, + Register r_result, + u1 super_klass_slot) { NearLabel L_done, L_failure; - BLOCK_COMMENT("lookup_secondary_supers_table {"); + BLOCK_COMMENT("lookup_secondary_supers_table_const {"); const Register r_array_base = r_temp1, @@ -3291,7 +3399,7 @@ void MacroAssembler::lookup_secondary_supers_table(Register r_sub_klass, z_lghi(r_result, 1); bind(L_done); - BLOCK_COMMENT("} lookup_secondary_supers_table"); + BLOCK_COMMENT("} lookup_secondary_supers_table_const"); if (VerifySecondarySupers) { verify_secondary_supers_table(r_sub_klass, r_super_klass, r_result, @@ -3299,6 +3407,116 @@ void MacroAssembler::lookup_secondary_supers_table(Register r_sub_klass, } } +// At runtime, return 0 in result if r_super_klass is a superclass of +// r_sub_klass, otherwise return nonzero. Use this version of +// lookup_secondary_supers_table() if you don't know ahead of time +// which superclass will be searched for. Used by interpreter and +// runtime stubs. It is larger and has somewhat greater latency than +// the version above, which takes a constant super_klass_slot. +void MacroAssembler::lookup_secondary_supers_table_var(Register r_sub_klass, + Register r_super_klass, + Register temp1, + Register temp2, + Register temp3, + Register temp4, + Register result) { + assert_different_registers(r_sub_klass, r_super_klass, temp1, temp2, temp3, temp4, result, Z_R1_scratch); + + Label L_done, L_failure; + + BLOCK_COMMENT("lookup_secondary_supers_table_var {"); + + const Register + r_array_index = temp3, + slot = temp4, // NOTE: "slot" can't be Z_R0 otherwise z_sllg and z_rllg instructions below will mess up!!!! + r_bitmap = Z_R1_scratch; + + z_llgc(slot, Address(r_super_klass, Klass::hash_slot_offset())); + + // Initialize r_result with 0 (indicating success). If searching fails, r_result will be loaded + // with 1 (failure) at the end of this method. + clear_reg(result, true /* whole_reg */, false /* set_cc */); // result = 0 + + z_lg(r_bitmap, Address(r_sub_klass, Klass::secondary_supers_bitmap_offset())); + + // First check the bitmap to see if super_klass might be present. If + // the bit is zero, we are certain that super_klass is not one of + // the secondary supers. + z_xilf(slot, (u1)(Klass::SECONDARY_SUPERS_TABLE_SIZE - 1)); // slot ^ 63 === 63 - slot (mod 64) + z_sllg(r_array_index, r_bitmap, /*d2 = */ 0, /* b2 = */ slot); + + testbit(r_array_index, Klass::SECONDARY_SUPERS_TABLE_SIZE - 1); + branch_optimized(bcondAllZero, L_failure); + + const Register + r_array_base = temp1, + r_array_length = temp2; + + // Get the first array index that can contain super_klass into r_array_index. + // NOTE: Z_R1_scratch is holding bitmap (look above for r_bitmap). So let's try to save it. + // On the other hand, r_array_base/temp1 is free at current moment (look at the load operation below). + pop_count_long(r_array_index, r_array_index, temp1); // kills r_array_base/temp1 on machines older than z15 + + // The value i in r_array_index is >= 1, so even though r_array_base + // points to the length, we don't need to adjust it to point to the data. + assert(Array::base_offset_in_bytes() == wordSize, "Adjust this code"); + assert(Array::length_offset_in_bytes() == 0, "Adjust this code"); + + // We will consult the secondary-super array. + z_lg(r_array_base, Address(r_sub_klass, in_bytes(Klass::secondary_supers_offset()))); + + // NB! r_array_index is off by 1. It is compensated by keeping r_array_base off by 1 word. + z_sllg(r_array_index, r_array_index, LogBytesPerWord); // scale, r_array_index is loaded by popcnt above + + z_cg(r_super_klass, Address(r_array_base, r_array_index)); + branch_optimized(bcondEqual, L_done); // found a match + + // Note: this is a small hack: + // + // The operation "(slot ^ 63) === 63 - slot (mod 64)" has already been performed above. + // Since we lack a rotate-right instruction, we achieve the same effect by rotating left + // by "64 - slot" positions. This produces the result equivalent to a right rotation by "slot" positions. + // + // => initial slot value + // => slot = 63 - slot // done above with that z_xilf instruction + // => slot = 64 - slot // need to do for rotating right by "slot" positions + // => slot = 64 - (63 - slot) + // => slot = slot - 63 + 64 + // => slot = slot + 1 + // + // So instead of rotating-left by 64-slot times, we can, for now, just rotate left by slot+1 and it would be fine. + + // Linear probe. Rotate the bitmap so that the next bit to test is + // in Bit 1. + z_aghi(slot, 1); // slot = slot + 1 + + z_rllg(r_bitmap, r_bitmap, /*d2=*/ 0, /*b2=*/ slot); + testbit(r_bitmap, 1); + branch_optimized(bcondAllZero, L_failure); + + // The slot we just inspected is at secondary_supers[r_array_index - 1]. + // The next slot to be inspected, by the logic we're about to call, + // is secondary_supers[r_array_index]. Bits 0 and 1 in the bitmap + // have been checked. + lookup_secondary_supers_table_slow_path(r_super_klass, r_array_base, r_array_index, + r_bitmap, /*temp=*/ r_array_length, result, /*is_stub*/false); + + // pass whatever we got from slow path + z_bru(L_done); + + bind(L_failure); + z_lghi(result, 1); // load 1 to represent failure + + bind(L_done); + + BLOCK_COMMENT("} lookup_secondary_supers_table_var"); + + if (VerifySecondarySupers) { + verify_secondary_supers_table(r_sub_klass, r_super_klass, result, + temp1, temp2, temp3); + } +} + // Called by code generated by check_klass_subtype_slow_path // above. This is called when there is a collision in the hashed // lookup in the secondary supers array. @@ -3306,15 +3524,18 @@ void MacroAssembler::lookup_secondary_supers_table_slow_path(Register r_super_kl Register r_array_base, Register r_array_index, Register r_bitmap, + Register r_temp, Register r_result, - Register r_temp1) { - assert_different_registers(r_super_klass, r_array_base, r_array_index, r_bitmap, r_result, r_temp1); + bool is_stub) { + assert_different_registers(r_super_klass, r_array_base, r_array_index, r_bitmap, r_result, r_temp); const Register - r_array_length = r_temp1, + r_array_length = r_temp, r_sub_klass = noreg; - LOOKUP_SECONDARY_SUPERS_TABLE_REGISTERS; + if(is_stub) { + LOOKUP_SECONDARY_SUPERS_TABLE_REGISTERS; + } BLOCK_COMMENT("lookup_secondary_supers_table_slow_path {"); NearLabel L_done, L_failure; @@ -3343,8 +3564,10 @@ void MacroAssembler::lookup_secondary_supers_table_slow_path(Register r_super_kl { // This is conventional linear probing, but instead of terminating // when a null entry is found in the table, we maintain a bitmap // in which a 0 indicates missing entries. - // The check above guarantees there are 0s in the bitmap, so the loop - // eventually terminates. + // As long as the bitmap is not completely full, + // array_length == popcount(bitmap). The array_length check above + // guarantees there are 0s in the bitmap, so the loop eventually + // terminates. #ifdef ASSERT // r_result is set to 0 by lookup_secondary_supers_table. @@ -3417,8 +3640,6 @@ void MacroAssembler::verify_secondary_supers_table(Register r_sub_klass, const Register r_one = Z_R0_scratch; z_lghi(r_one, 1); // for locgr down there, to a load result for failure - LOOKUP_SECONDARY_SUPERS_TABLE_REGISTERS; - BLOCK_COMMENT("verify_secondary_supers_table {"); Label L_passed, L_failure; diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.hpp b/src/hotspot/cpu/s390/macroAssembler_s390.hpp index 7806fef3ce8ba..91703fac994af 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp @@ -694,7 +694,7 @@ class MacroAssembler: public Assembler { Label* L_success, Label* L_failure, Label* L_slow_path, - RegisterOrConstant super_check_offset = RegisterOrConstant(-1)); + Register super_check_offset = noreg); // The rest of the type check; must be wired to a corresponding fast path. // It does not repeat the fast path logic, so don't use it standalone. @@ -706,25 +706,62 @@ class MacroAssembler: public Assembler { Register Rarray_ptr, // tmp Register Rlength, // tmp Label* L_success, - Label* L_failure); + Label* L_failure, + bool set_cond_codes = false); + + void check_klass_subtype_slow_path_linear(Register sub_klass, + Register super_klass, + Register temp_reg, + Register temp2_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes = false); + + void check_klass_subtype_slow_path_table(Register sub_klass, + Register super_klass, + Register temp_reg, + Register temp2_reg, + Register temp3_reg, + Register temp4_reg, + Register result_reg, + Label* L_success, + Label* L_failure, + bool set_cond_codes = false); + + // If r is valid, return r. + // If r is invalid, remove a register r2 from available_regs, add r2 + // to regs_to_push, then return r2. + Register allocate_if_noreg(const Register r, + RegSetIterator &available_regs, + RegSet ®s_to_push); void repne_scan(Register r_addr, Register r_value, Register r_count, Register r_scratch); - void lookup_secondary_supers_table(Register r_sub_klass, - Register r_super_klass, - Register r_temp1, - Register r_temp2, - Register r_temp3, - Register r_temp4, - Register r_result, - u1 super_klass_slot); + // Secondary subtype checking + void lookup_secondary_supers_table_var(Register sub_klass, + Register r_super_klass, + Register temp1, + Register temp2, + Register temp3, + Register temp4, + Register result); + + void lookup_secondary_supers_table_const(Register r_sub_klass, + Register r_super_klass, + Register r_temp1, + Register r_temp2, + Register r_temp3, + Register r_temp4, + Register r_result, + u1 super_klass_slot); void lookup_secondary_supers_table_slow_path(Register r_super_klass, Register r_array_base, Register r_array_index, Register r_bitmap, + Register r_temp, Register r_result, - Register r_temp1); + bool is_stub); void verify_secondary_supers_table(Register r_sub_klass, Register r_super_klass, diff --git a/src/hotspot/cpu/s390/s390.ad b/src/hotspot/cpu/s390/s390.ad index e1a98139992f8..0f1d98d54b929 100644 --- a/src/hotspot/cpu/s390/s390.ad +++ b/src/hotspot/cpu/s390/s390.ad @@ -9979,8 +9979,9 @@ instruct ShouldNotReachHere() %{ instruct partialSubtypeCheck(rarg1RegP index, rarg2RegP sub, rarg3RegP super, flagsReg pcc, rarg4RegP scratch1, rarg5RegP scratch2) %{ match(Set index (PartialSubtypeCheck sub super)); + predicate(!UseSecondarySupersTable); effect(KILL pcc, KILL scratch1, KILL scratch2); - ins_cost(10 * DEFAULT_COST); + ins_cost(20 * DEFAULT_COST); // slightly larger than the next version // TODO: s390 port size(FIXED_SIZE); format %{ " CALL PartialSubtypeCheck\n" %} ins_encode %{ @@ -9991,21 +9992,45 @@ instruct partialSubtypeCheck(rarg1RegP index, rarg2RegP sub, rarg3RegP super, fl ins_pipe(pipe_class_dummy); %} +// Two versions of partialSubtypeCheck, both used when we need to +// search for a super class in the secondary supers array. The first +// is used when we don't know _a priori_ the class being searched +// for. The second, far more common, is used when we do know: this is +// used for instanceof, checkcast, and any case where C2 can determine +// it by constant propagation. +instruct partialSubtypeCheckVarSuper(rarg2RegP sub, rarg3RegP super, + r11TempRegP result, + rarg1RegP temp1, rarg4RegP temp2, rarg5RegP temp3, r10TempRegP temp4, + flagsReg pcc) %{ + match(Set result (PartialSubtypeCheck sub super)); + predicate(UseSecondarySupersTable); + effect(KILL pcc, TEMP temp1, TEMP temp2, TEMP temp3, TEMP temp4); + ins_cost(10 * DEFAULT_COST); // slightly larger than the next version + format %{ "partialSubtypeCheck $result, $sub, $super" %} + ins_encode %{ + __ lookup_secondary_supers_table_var($sub$$Register, $super$$Register, + $temp1$$Register, $temp2$$Register, $temp3$$Register, $temp4$$Register, + $result$$Register); + %} + ins_pipe(pipe_class_dummy); +%} + + instruct partialSubtypeCheckConstSuper(rarg2RegP sub, rarg1RegP super, immP super_con, r11TempRegP result, rarg5RegP temp1, rarg4RegP temp2, rarg3RegP temp3, r10TempRegP temp4, flagsReg pcc) %{ match(Set result (PartialSubtypeCheck sub (Binary super super_con))); predicate(UseSecondarySupersTable); effect(KILL pcc, TEMP temp1, TEMP temp2, TEMP temp3, TEMP temp4); - ins_cost(7 * DEFAULT_COST); // needs to be less than competing nodes + ins_cost(5 * DEFAULT_COST); // smaller than the next version format %{ "partialSubtypeCheck $result, $sub, $super, $super_con" %} ins_encode %{ u1 super_klass_slot = ((Klass*)$super_con$$constant)->hash_slot(); if (InlineSecondarySupersTest) { - __ lookup_secondary_supers_table($sub$$Register, $super$$Register, - $temp1$$Register, $temp2$$Register, $temp3$$Register, - $temp4$$Register, $result$$Register, super_klass_slot); + __ lookup_secondary_supers_table_const($sub$$Register, $super$$Register, + $temp1$$Register, $temp2$$Register, $temp3$$Register, + $temp4$$Register, $result$$Register, super_klass_slot); } else { AddressLiteral stub_address(StubRoutines::lookup_secondary_supers_table_stub(super_klass_slot)); __ load_const_optimized(Z_ARG4, stub_address); @@ -10017,21 +10042,6 @@ instruct partialSubtypeCheckConstSuper(rarg2RegP sub, rarg1RegP super, immP supe ins_pipe(pipe_class_dummy); %} -instruct partialSubtypeCheck_vs_zero(flagsReg pcc, rarg2RegP sub, rarg3RegP super, immP0 zero, - rarg1RegP index, rarg4RegP scratch1, rarg5RegP scratch2) %{ - match(Set pcc (CmpI (PartialSubtypeCheck sub super) zero)); - effect(KILL scratch1, KILL scratch2, KILL index); - ins_cost(10 * DEFAULT_COST); - // TODO: s390 port size(FIXED_SIZE); - format %{ "CALL PartialSubtypeCheck_vs_zero\n" %} - ins_encode %{ - AddressLiteral stub_address(StubRoutines::zarch::partial_subtype_check()); - __ load_const_optimized(Z_ARG4, stub_address); - __ z_basr(Z_R14, Z_ARG4); - %} - ins_pipe(pipe_class_dummy); -%} - // ============================================================================ // inlined locking and unlocking diff --git a/src/hotspot/cpu/s390/stubGenerator_s390.cpp b/src/hotspot/cpu/s390/stubGenerator_s390.cpp index dd9ed4c95462b..9e33cd3abe88a 100644 --- a/src/hotspot/cpu/s390/stubGenerator_s390.cpp +++ b/src/hotspot/cpu/s390/stubGenerator_s390.cpp @@ -635,9 +635,9 @@ class StubGenerator: public StubCodeGenerator { r_result = Z_R11; address start = __ pc(); - __ lookup_secondary_supers_table(r_sub_klass, r_super_klass, - r_array_base, r_array_length, r_array_index, - r_bitmap, r_result, super_klass_index); + __ lookup_secondary_supers_table_const(r_sub_klass, r_super_klass, + r_array_base, r_array_length, r_array_index, + r_bitmap, r_result, super_klass_index); __ z_br(Z_R14); @@ -659,7 +659,7 @@ class StubGenerator: public StubCodeGenerator { r_result = Z_R11; __ lookup_secondary_supers_table_slow_path(r_super_klass, r_array_base, - r_array_index, r_bitmap, r_result, r_temp1); + r_array_index, r_bitmap, r_temp1, r_result, /* is_stub */ true); __ z_br(Z_R14); diff --git a/src/hotspot/cpu/x86/assembler_x86.cpp b/src/hotspot/cpu/x86/assembler_x86.cpp index 36a122d29464d..c2fcbcea71e24 100644 --- a/src/hotspot/cpu/x86/assembler_x86.cpp +++ b/src/hotspot/cpu/x86/assembler_x86.cpp @@ -2968,7 +2968,7 @@ void Assembler::movb(Register dst, Address src) { } void Assembler::movddup(XMMRegister dst, XMMRegister src) { - NOT_LP64(assert(VM_Version::supports_sse3(), "")); + assert(VM_Version::supports_sse3(), ""); int vector_len = VM_Version::supports_avx512novl() ? AVX_512bit : AVX_128bit; InstructionAttr attributes(vector_len, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); attributes.set_rex_vex_w_reverted(); @@ -2977,7 +2977,7 @@ void Assembler::movddup(XMMRegister dst, XMMRegister src) { } void Assembler::movddup(XMMRegister dst, Address src) { - NOT_LP64(assert(VM_Version::supports_sse3(), "")); + assert(VM_Version::supports_sse3(), ""); InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_DUP, /* input_size_in_bits */ EVEX_64bit); @@ -4614,7 +4614,7 @@ void Assembler::vpacksswb(XMMRegister dst, XMMRegister nds, XMMRegister src, int } void Assembler::packssdw(XMMRegister dst, XMMRegister src) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int16(0x6B, (0xC0 | encode)); @@ -4820,7 +4820,7 @@ void Assembler::pcmpestri(XMMRegister dst, XMMRegister src, int imm8) { // In this context, the dst vector contains the components that are equal, non equal components are zeroed in dst void Assembler::pcmpeqb(XMMRegister dst, XMMRegister src) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int16(0x74, (0xC0 | encode)); @@ -4968,7 +4968,7 @@ void Assembler::evpcmpeqb(KRegister kdst, KRegister mask, XMMRegister nds, Addre // In this context, the dst vector contains the components that are equal, non equal components are zeroed in dst void Assembler::pcmpeqw(XMMRegister dst, XMMRegister src) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int16(0x75, (0xC0 | encode)); @@ -5017,7 +5017,7 @@ void Assembler::evpcmpeqw(KRegister kdst, XMMRegister nds, Address src, int vect // In this context, the dst vector contains the components that are equal, non equal components are zeroed in dst void Assembler::pcmpeqd(XMMRegister dst, XMMRegister src) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int16(0x76, (0xC0 | encode)); @@ -5122,7 +5122,7 @@ void Assembler::pcmpgtq(XMMRegister dst, XMMRegister src) { } void Assembler::pmovmskb(Register dst, XMMRegister src) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ true, /* no_mask_reg */ true, /* uses_vl */ false); int encode = simd_prefix_and_encode(as_XMMRegister(dst->encoding()), xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int16((unsigned char)0xD7, (0xC0 | encode)); @@ -5188,7 +5188,7 @@ void Assembler::pextrq(Address dst, XMMRegister src, int imm8) { } void Assembler::pextrw(Register dst, XMMRegister src, int imm8) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ false); int encode = simd_prefix_and_encode(as_XMMRegister(dst->encoding()), xnoreg, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int24((unsigned char)0xC5, (0xC0 | encode), imm8); @@ -5274,14 +5274,14 @@ void Assembler::vpinsrq(XMMRegister dst, XMMRegister nds, Register src, int imm8 } void Assembler::pinsrw(XMMRegister dst, Register src, int imm8) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ false); int encode = simd_prefix_and_encode(dst, dst, as_XMMRegister(src->encoding()), VEX_SIMD_66, VEX_OPCODE_0F, &attributes, true); emit_int24((unsigned char)0xC4, (0xC0 | encode), imm8); } void Assembler::pinsrw(XMMRegister dst, Address src, int imm8) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionMark im(this); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ false); attributes.set_address_attributes(/* tuple_type */ EVEX_T1S, /* input_size_in_bits */ EVEX_16bit); @@ -8712,7 +8712,7 @@ void Assembler::pmulld(XMMRegister dst, XMMRegister src) { } void Assembler::pmuludq(XMMRegister dst, XMMRegister src) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int16((unsigned char)0xF4, (0xC0 | encode)); @@ -8813,7 +8813,7 @@ void Assembler::vpminsb(XMMRegister dst, XMMRegister nds, XMMRegister src, int v } void Assembler::pminsw(XMMRegister dst, XMMRegister src) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int16((unsigned char)0xEA, (0xC0 | encode)); @@ -8892,7 +8892,7 @@ void Assembler::vpmaxsb(XMMRegister dst, XMMRegister nds, XMMRegister src, int v } void Assembler::pmaxsw(XMMRegister dst, XMMRegister src) { - assert(VM_Version::supports_sse2(), ""); + NOT_LP64(assert(VM_Version::supports_sse2(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int16((unsigned char)0xEE, (0xC0 | encode)); @@ -12401,7 +12401,7 @@ void Assembler::evpternlogq(XMMRegister dst, int imm8, KRegister mask, XMMRegist void Assembler::gf2p8affineqb(XMMRegister dst, XMMRegister src, int imm8) { assert(VM_Version::supports_gfni(), ""); - assert(VM_Version::supports_sse(), ""); + NOT_LP64(assert(VM_Version::supports_sse(), "");) InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ false); int encode = simd_prefix_and_encode(dst, dst, src, VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); emit_int24((unsigned char)0xCE, (unsigned char)(0xC0 | encode), imm8); @@ -12409,7 +12409,7 @@ void Assembler::gf2p8affineqb(XMMRegister dst, XMMRegister src, int imm8) { void Assembler::vgf2p8affineqb(XMMRegister dst, XMMRegister src2, XMMRegister src3, int imm8, int vector_len) { assert(VM_Version::supports_gfni(), "requires GFNI support"); - assert(VM_Version::supports_sse(), ""); + NOT_LP64(assert(VM_Version::supports_sse(), "");) InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); int encode = vex_prefix_and_encode(dst->encoding(), src2->encoding(), src3->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); emit_int24((unsigned char)0xCE, (unsigned char)(0xC0 | encode), imm8); diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index c08e535ee0e11..a798dea08cc79 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -5445,7 +5445,6 @@ void MacroAssembler::vallones(XMMRegister dst, int vector_len) { } else if (VM_Version::supports_avx()) { vpcmpeqd(dst, dst, dst, vector_len); } else { - assert(VM_Version::supports_sse2(), ""); pcmpeqd(dst, dst); } } diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index d51ca8a5ffb5f..d85120f3f1dc3 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -562,6 +562,7 @@ void os::init_system_properties_values() { // Base path of extensions installed on the system. #define SYS_EXT_DIR "/usr/java/packages" #define EXTENSIONS_DIR "/lib/ext" +#define JVM_LIB_NAME "libjvm.so" // Buffer that fits several snprintfs. // Note that the space for the colon and the trailing null are provided @@ -576,22 +577,32 @@ void os::init_system_properties_values() { char *pslash; os::jvm_path(buf, bufsize); - // Found the full path to libjvm.so. - // Now cut the path to /jre if we can. + // Found the full path to the binary. It is normally of this structure: + // /lib//libjvm.so + // but can also be like this for a statically linked binary: + // /bin/ pslash = strrchr(buf, '/'); if (pslash != nullptr) { - *pslash = '\0'; // Get rid of /libjvm.so. - } - pslash = strrchr(buf, '/'); - if (pslash != nullptr) { - *pslash = '\0'; // Get rid of /{client|server|hotspot}. + if (strncmp(pslash + 1, JVM_LIB_NAME, strlen(JVM_LIB_NAME)) == 0) { + // Binary name is libjvm.so. Get rid of /libjvm.so. + *pslash = '\0'; + } + + // Get rid of /, if binary is libjvm.so, + // or cut off /, if it is a statically linked binary. + pslash = strrchr(buf, '/'); + if (pslash != nullptr) { + *pslash = '\0'; + } } Arguments::set_dll_dir(buf); + // Get rid of /lib, if binary is libjvm.so, + // or cut off /bin, if it is a statically linked binary. if (pslash != nullptr) { pslash = strrchr(buf, '/'); if (pslash != nullptr) { - *pslash = '\0'; // Get rid of /lib. + *pslash = '\0'; } } Arguments::set_java_home(buf); diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp index 7d418d4ad43a2..61214a4296998 100644 --- a/src/hotspot/os/posix/os_posix.cpp +++ b/src/hotspot/os/posix/os_posix.cpp @@ -854,6 +854,12 @@ void os::dll_unload(void *lib) { LINUX_ONLY(os::free(l_pathdup)); } +void* os::lookup_function(const char* name) { + // This returns the global symbol in the main executable and its dependencies, + // as well as shared objects dynamically loaded with RTLD_GLOBAL flag. + return dlsym(RTLD_DEFAULT, name); +} + jlong os::lseek(int fd, jlong offset, int whence) { return (jlong) ::lseek(fd, offset, whence); } @@ -935,51 +941,6 @@ void os::naked_yield() { sched_yield(); } -// Builds a platform dependent Agent_OnLoad_ function name -// which is used to find statically linked in agents. -// Parameters: -// sym_name: Symbol in library we are looking for -// lib_name: Name of library to look in, null for shared libs. -// is_absolute_path == true if lib_name is absolute path to agent -// such as "/a/b/libL.so" -// == false if only the base name of the library is passed in -// such as "L" -char* os::build_agent_function_name(const char *sym_name, const char *lib_name, - bool is_absolute_path) { - char *agent_entry_name; - size_t len; - size_t name_len; - size_t prefix_len = strlen(JNI_LIB_PREFIX); - size_t suffix_len = strlen(JNI_LIB_SUFFIX); - const char *start; - - if (lib_name != nullptr) { - name_len = strlen(lib_name); - if (is_absolute_path) { - // Need to strip path, prefix and suffix - if ((start = strrchr(lib_name, *os::file_separator())) != nullptr) { - lib_name = ++start; - } - if (strlen(lib_name) <= (prefix_len + suffix_len)) { - return nullptr; - } - lib_name += prefix_len; - name_len = strlen(lib_name) - suffix_len; - } - } - len = (lib_name != nullptr ? name_len : 0) + strlen(sym_name) + 2; - agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread); - if (agent_entry_name == nullptr) { - return nullptr; - } - strcpy(agent_entry_name, sym_name); - if (lib_name != nullptr) { - strcat(agent_entry_name, "_"); - strncat(agent_entry_name, lib_name, name_len); - } - return agent_entry_name; -} - // Sleep forever; naked call to OS-specific sleep; use with CAUTION void os::infinite_sleep() { while (true) { // sleep forever ... @@ -2225,4 +2186,3 @@ const void* os::get_saved_assert_context(const void** sigInfo) { *sigInfo = nullptr; return nullptr; } - diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 8bb3789bbad14..849fc0c29f051 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -1401,6 +1401,12 @@ void* os::dll_lookup(void *lib, const char *name) { return ret; } +void* os::lookup_function(const char* name) { + // This is needed only for static builds which are not supported on Windows + ShouldNotReachHere(); + return nullptr; // Satisfy compiler +} + // Directory routines copied from src/win32/native/java/io/dirent_md.c // * dirent_md.c 1.15 00/02/02 // @@ -5829,57 +5835,6 @@ void* os::get_default_process_handle() { return (void*)GetModuleHandle(nullptr); } -// Builds a platform dependent Agent_OnLoad_ function name -// which is used to find statically linked in agents. -// Parameters: -// sym_name: Symbol in library we are looking for -// lib_name: Name of library to look in, null for shared libs. -// is_absolute_path == true if lib_name is absolute path to agent -// such as "C:/a/b/L.dll" -// == false if only the base name of the library is passed in -// such as "L" -char* os::build_agent_function_name(const char *sym_name, const char *lib_name, - bool is_absolute_path) { - char *agent_entry_name; - size_t len; - size_t name_len; - size_t prefix_len = strlen(JNI_LIB_PREFIX); - size_t suffix_len = strlen(JNI_LIB_SUFFIX); - const char *start; - - if (lib_name != nullptr) { - len = name_len = strlen(lib_name); - if (is_absolute_path) { - // Need to strip path, prefix and suffix - if ((start = strrchr(lib_name, *os::file_separator())) != nullptr) { - lib_name = ++start; - } else { - // Need to check for drive prefix - if ((start = strchr(lib_name, ':')) != nullptr) { - lib_name = ++start; - } - } - if (len <= (prefix_len + suffix_len)) { - return nullptr; - } - lib_name += prefix_len; - name_len = strlen(lib_name) - suffix_len; - } - } - len = (lib_name != nullptr ? name_len : 0) + strlen(sym_name) + 2; - agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread); - if (agent_entry_name == nullptr) { - return nullptr; - } - - strcpy(agent_entry_name, sym_name); - if (lib_name != nullptr) { - strcat(agent_entry_name, "_"); - strncat(agent_entry_name, lib_name, name_len); - } - return agent_entry_name; -} - /* All the defined signal names for Windows. diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp index 3ea2f54cfa9fb..3571f11bb6e36 100644 --- a/src/hotspot/share/cds/metaspaceShared.cpp +++ b/src/hotspot/share/cds/metaspaceShared.cpp @@ -1014,9 +1014,7 @@ void VM_PopulateDumpSharedSpace::dump_java_heap_objects(GrowableArray* k Klass* k = klasses->at(i); if (k->is_instance_klass()) { InstanceKlass* ik = InstanceKlass::cast(k); - if (ik->is_linked()) { - ik->constants()->add_dumped_interned_strings(); - } + ik->constants()->add_dumped_interned_strings(); } } if (_extra_interned_strings != nullptr) { diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index 1b34f2ebedef9..aac312c36a3c8 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -949,16 +949,35 @@ void* ClassLoader::dll_lookup(void* lib, const char* name, const char* path) { void ClassLoader::load_java_library() { assert(CanonicalizeEntry == nullptr, "should not load java library twice"); + if (is_vm_statically_linked()) { + CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, os::lookup_function("JDK_Canonicalize")); + assert(CanonicalizeEntry != nullptr, "could not lookup JDK_Canonicalize"); + return; + } + void *javalib_handle = os::native_java_library(); if (javalib_handle == nullptr) { vm_exit_during_initialization("Unable to load java library", nullptr); } CanonicalizeEntry = CAST_TO_FN_PTR(canonicalize_fn_t, dll_lookup(javalib_handle, "JDK_Canonicalize", nullptr)); + assert(CanonicalizeEntry != nullptr, "could not lookup JDK_Canonicalize in java library"); } void ClassLoader::load_jimage_library() { assert(JImageOpen == nullptr, "should not load jimage library twice"); + + if (is_vm_statically_linked()) { + JImageOpen = CAST_TO_FN_PTR(JImageOpen_t, os::lookup_function("JIMAGE_Open")); + JImageClose = CAST_TO_FN_PTR(JImageClose_t, os::lookup_function("JIMAGE_Close")); + JImageFindResource = CAST_TO_FN_PTR(JImageFindResource_t, os::lookup_function("JIMAGE_FindResource")); + JImageGetResource = CAST_TO_FN_PTR(JImageGetResource_t, os::lookup_function("JIMAGE_GetResource")); + assert(JImageOpen != nullptr && JImageClose != nullptr && + JImageFindResource != nullptr && JImageGetResource != nullptr, + "could not lookup all jimage library functions"); + return; + } + char path[JVM_MAXPATHLEN]; char ebuf[1024]; void* handle = nullptr; @@ -973,6 +992,9 @@ void ClassLoader::load_jimage_library() { JImageClose = CAST_TO_FN_PTR(JImageClose_t, dll_lookup(handle, "JIMAGE_Close", path)); JImageFindResource = CAST_TO_FN_PTR(JImageFindResource_t, dll_lookup(handle, "JIMAGE_FindResource", path)); JImageGetResource = CAST_TO_FN_PTR(JImageGetResource_t, dll_lookup(handle, "JIMAGE_GetResource", path)); + assert(JImageOpen != nullptr && JImageClose != nullptr && + JImageFindResource != nullptr && JImageGetResource != nullptr, + "could not lookup all jimage library functions in jimage library"); } int ClassLoader::crc32(int crc, const char* buf, int len) { diff --git a/src/hotspot/share/classfile/verifier.cpp b/src/hotspot/share/classfile/verifier.cpp index 9a36584916d8d..0ac2cc350b18d 100644 --- a/src/hotspot/share/classfile/verifier.cpp +++ b/src/hotspot/share/classfile/verifier.cpp @@ -85,15 +85,20 @@ static verify_byte_codes_fn_t verify_byte_codes_fn() { if (_verify_byte_codes_fn != nullptr) return _verify_byte_codes_fn; + void *lib_handle = nullptr; // Load verify dll - char buffer[JVM_MAXPATHLEN]; - char ebuf[1024]; - if (!os::dll_locate_lib(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify")) - return nullptr; // Caller will throw VerifyError + if (is_vm_statically_linked()) { + lib_handle = os::get_default_process_handle(); + } else { + char buffer[JVM_MAXPATHLEN]; + char ebuf[1024]; + if (!os::dll_locate_lib(buffer, sizeof(buffer), Arguments::get_dll_dir(), "verify")) + return nullptr; // Caller will throw VerifyError - void *lib_handle = os::dll_load(buffer, ebuf, sizeof(ebuf)); - if (lib_handle == nullptr) - return nullptr; // Caller will throw VerifyError + lib_handle = os::dll_load(buffer, ebuf, sizeof(ebuf)); + if (lib_handle == nullptr) + return nullptr; // Caller will throw VerifyError + } void *fn = os::dll_lookup(lib_handle, "VerifyClassForMajorVersion"); if (fn == nullptr) diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp index 6a6f7754c509e..46c156a54452a 100644 --- a/src/hotspot/share/classfile/vmSymbols.hpp +++ b/src/hotspot/share/classfile/vmSymbols.hpp @@ -739,10 +739,15 @@ class SerializeClosure; template(toFileURL_signature, "(Ljava/lang/String;)Ljava/net/URL;") \ template(url_array_classloader_void_signature, "([Ljava/net/URL;Ljava/lang/ClassLoader;)V") \ \ - /* Thread.dump_to_file jcmd */ \ + /* jcmd Thread.dump_to_file */ \ template(jdk_internal_vm_ThreadDumper, "jdk/internal/vm/ThreadDumper") \ template(dumpThreads_name, "dumpThreads") \ template(dumpThreadsToJson_name, "dumpThreadsToJson") \ + \ + /* jcmd Thread.vthread_scheduler and Thread.vthread_pollers */ \ + template(jdk_internal_vm_JcmdVThreadCommands, "jdk/internal/vm/JcmdVThreadCommands") \ + template(printScheduler_name, "printScheduler") \ + template(printPollers_name, "printPollers") \ /*end*/ diff --git a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp index 4239fc37a267b..a9c5e47c5c2bd 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoah_globals.hpp @@ -134,7 +134,6 @@ "GC mode to use. Among other things, this defines which " \ "barriers are in in use. Possible values are:" \ " satb - snapshot-at-the-beginning concurrent GC (three pass mark-evac-update);" \ - " iu - incremental-update concurrent GC (three pass mark-evac-update);" \ " passive - stop the world GC only (either degenerated or full);" \ " generational - generational concurrent GC") \ \ @@ -183,7 +182,7 @@ range(0,100) \ \ product(uintx, ShenandoahInitFreeThreshold, 70, EXPERIMENTAL, \ - "When less than this amount of memory is free within the" \ + "When less than this amount of memory is free within the " \ "heap or generation, trigger a learning cycle if we are " \ "in learning mode. Learning mode happens during initialization " \ "and following a drastic state change, such as following a " \ diff --git a/src/hotspot/share/gc/z/zDirector.cpp b/src/hotspot/share/gc/z/zDirector.cpp index 3c0cb660206a2..48e426f068aa6 100644 --- a/src/hotspot/share/gc/z/zDirector.cpp +++ b/src/hotspot/share/gc/z/zDirector.cpp @@ -33,6 +33,8 @@ #include "gc/z/zStat.hpp" #include "logging/log.hpp" +#include + ZDirector* ZDirector::_director; constexpr double one_in_1000 = 3.290527; @@ -453,16 +455,22 @@ static double calculate_extra_young_gc_time(const ZDirectorStats& stats) { // relocation headroom into account to avoid in-place relocation. const size_t old_used = stats._old_stats._general._used; const size_t old_live = stats._old_stats._stat_heap._live_at_mark_end; - const size_t old_garbage = old_used - old_live; + const double old_garbage = double(old_used - old_live); const double young_gc_time = gc_time(stats._young_stats); // Calculate how much memory young collections are predicted to free. - const size_t reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; + const double reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; // Calculate current YC time and predicted YC time after an old collection. - const double current_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc); - const double potential_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc + old_garbage); + const double current_young_gc_time_per_bytes_freed = young_gc_time / reclaimed_per_young_gc; + const double potential_young_gc_time_per_bytes_freed = young_gc_time / (reclaimed_per_young_gc + old_garbage); + + if (current_young_gc_time_per_bytes_freed == std::numeric_limits::infinity()) { + // Young collection's are not reclaiming any memory. Return infinity as a signal + // to trigger an old collection, regardless of the amount of old garbage. + return std::numeric_limits::infinity(); + } // Calculate extra time per young collection inflicted by *not* doing an // old collection that frees up memory in the old generation. @@ -483,13 +491,12 @@ static bool rule_major_allocation_rate(const ZDirectorStats& stats) { const double young_gc_time = gc_time(stats._young_stats); // Calculate how much memory collections are predicted to free. - const size_t reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; - const size_t reclaimed_per_old_gc = stats._old_stats._stat_heap._reclaimed_avg; + const double reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; + const double reclaimed_per_old_gc = stats._old_stats._stat_heap._reclaimed_avg; // Calculate the GC cost for each reclaimed byte - const double current_young_gc_time_per_bytes_freed = double(young_gc_time) / double(reclaimed_per_young_gc); - const double current_old_gc_time_per_bytes_freed = reclaimed_per_old_gc == 0 ? std::numeric_limits::infinity() - : (double(old_gc_time) / double(reclaimed_per_old_gc)); + const double current_young_gc_time_per_bytes_freed = young_gc_time / reclaimed_per_young_gc; + const double current_old_gc_time_per_bytes_freed = old_gc_time / reclaimed_per_old_gc; // Calculate extra time per young collection inflicted by *not* doing an // old collection that frees up memory in the old generation. @@ -531,10 +538,10 @@ static double calculate_young_to_old_worker_ratio(const ZDirectorStats& stats) { const double young_gc_time = gc_time(stats._young_stats); const double old_gc_time = gc_time(stats._old_stats); - const size_t reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; - const size_t reclaimed_per_old_gc = stats._old_stats._stat_heap._reclaimed_avg; - const double current_young_bytes_freed_per_gc_time = double(reclaimed_per_young_gc) / double(young_gc_time); - const double current_old_bytes_freed_per_gc_time = double(reclaimed_per_old_gc) / double(old_gc_time); + const double reclaimed_per_young_gc = stats._young_stats._stat_heap._reclaimed_avg; + const double reclaimed_per_old_gc = stats._old_stats._stat_heap._reclaimed_avg; + const double current_young_bytes_freed_per_gc_time = reclaimed_per_young_gc / young_gc_time; + const double current_old_bytes_freed_per_gc_time = reclaimed_per_old_gc / old_gc_time; if (current_young_bytes_freed_per_gc_time == 0.0) { if (current_old_bytes_freed_per_gc_time == 0.0) { diff --git a/src/hotspot/share/gc/z/zStat.cpp b/src/hotspot/share/gc/z/zStat.cpp index 56b3590960f7c..96cfa7d3a3718 100644 --- a/src/hotspot/share/gc/z/zStat.cpp +++ b/src/hotspot/share/gc/z/zStat.cpp @@ -46,6 +46,8 @@ #include "utilities/debug.hpp" #include "utilities/ticks.hpp" +#include + #define ZSIZE_FMT SIZE_FORMAT "M(%.0f%%)" #define ZSIZE_ARGS_WITH_MAX(size, max) ((size) / M), (percent_of(size, max)) #define ZSIZE_ARGS(size) ZSIZE_ARGS_WITH_MAX(size, ZStatHeap::max_capacity()) @@ -1849,8 +1851,9 @@ void ZStatHeap::at_relocate_end(const ZPageAllocatorStats& stats, bool record_st } } -size_t ZStatHeap::reclaimed_avg() { - return (size_t)_reclaimed_bytes.davg(); +double ZStatHeap::reclaimed_avg() { + // Make sure the reclaimed average is greater than 0.0 to avoid division by zero. + return _reclaimed_bytes.davg() + std::numeric_limits::denorm_min(); } size_t ZStatHeap::max_capacity() { diff --git a/src/hotspot/share/gc/z/zStat.hpp b/src/hotspot/share/gc/z/zStat.hpp index d7fff6d7b8e13..d169385791890 100644 --- a/src/hotspot/share/gc/z/zStat.hpp +++ b/src/hotspot/share/gc/z/zStat.hpp @@ -588,7 +588,7 @@ class ZStatReferences : public AllStatic { struct ZStatHeapStats { size_t _live_at_mark_end; size_t _used_at_relocate_end; - size_t _reclaimed_avg; + double _reclaimed_avg; }; // @@ -699,7 +699,7 @@ class ZStatHeap { size_t stalls_at_relocate_start() const; size_t stalls_at_relocate_end() const; - size_t reclaimed_avg(); + double reclaimed_avg(); ZStatHeapStats stats(); diff --git a/src/hotspot/share/oops/constantPool.cpp b/src/hotspot/share/oops/constantPool.cpp index 31644f33797f8..22896d9e00fb1 100644 --- a/src/hotspot/share/oops/constantPool.cpp +++ b/src/hotspot/share/oops/constantPool.cpp @@ -53,6 +53,7 @@ #include "oops/array.hpp" #include "oops/constantPool.inline.hpp" #include "oops/cpCache.inline.hpp" +#include "oops/fieldStreams.inline.hpp" #include "oops/instanceKlass.hpp" #include "oops/klass.inline.hpp" #include "oops/objArrayKlass.hpp" @@ -61,6 +62,7 @@ #include "oops/typeArrayOop.inline.hpp" #include "prims/jvmtiExport.hpp" #include "runtime/atomic.hpp" +#include "runtime/fieldDescriptor.inline.hpp" #include "runtime/handles.inline.hpp" #include "runtime/init.hpp" #include "runtime/javaCalls.hpp" @@ -403,18 +405,38 @@ void ConstantPool::find_required_hidden_classes() { } void ConstantPool::add_dumped_interned_strings() { - objArrayOop rr = resolved_references(); - if (rr != nullptr) { - int rr_len = rr->length(); - for (int i = 0; i < rr_len; i++) { - oop p = rr->obj_at(i); - if (java_lang_String::is_instance(p) && - !ArchiveHeapWriter::is_string_too_large_to_archive(p)) { - HeapShared::add_to_dumped_interned_strings(p); + InstanceKlass* ik = pool_holder(); + if (!ik->is_linked()) { + // resolved_references() doesn't exist yet, so we have no resolved CONSTANT_String entries. However, + // some static final fields may have default values that were initialized when the class was parsed. + // We need to enter those into the CDS archive strings table. + for (JavaFieldStream fs(ik); !fs.done(); fs.next()) { + if (fs.access_flags().is_static()) { + fieldDescriptor& fd = fs.field_descriptor(); + if (fd.field_type() == T_OBJECT) { + int offset = fd.offset(); + check_and_add_dumped_interned_string(ik->java_mirror()->obj_field(offset)); + } + } + } + } else { + objArrayOop rr = resolved_references(); + if (rr != nullptr) { + int rr_len = rr->length(); + for (int i = 0; i < rr_len; i++) { + check_and_add_dumped_interned_string(rr->obj_at(i)); } } } } + +void ConstantPool::check_and_add_dumped_interned_string(oop obj) { + if (obj != nullptr && java_lang_String::is_instance(obj) && + !ArchiveHeapWriter::is_string_too_large_to_archive(obj)) { + HeapShared::add_to_dumped_interned_strings(obj); + } +} + #endif #if INCLUDE_CDS diff --git a/src/hotspot/share/oops/constantPool.hpp b/src/hotspot/share/oops/constantPool.hpp index 9ada3e29d49b0..935151c7cda7d 100644 --- a/src/hotspot/share/oops/constantPool.hpp +++ b/src/hotspot/share/oops/constantPool.hpp @@ -162,6 +162,7 @@ class ConstantPool : public Metadata { assert(is_within_bounds(cp_index), "index out of bounds"); return (jdouble*) &base()[cp_index]; } + static void check_and_add_dumped_interned_string(oop obj); ConstantPool(Array* tags); ConstantPool(); diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index deb2c30500c11..f631556858ff2 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -513,6 +513,11 @@ static void* _native_java_library = nullptr; void* os::native_java_library() { if (_native_java_library == nullptr) { + if (is_vm_statically_linked()) { + _native_java_library = get_default_process_handle(); + return _native_java_library; + } + char buffer[JVM_MAXPATHLEN]; char ebuf[1024]; @@ -2476,3 +2481,61 @@ jint os::set_minimum_stack_sizes() { } return JNI_OK; } + +// Builds a platform dependent Agent_OnLoad_ function name +// which is used to find statically linked in agents. +// Parameters: +// sym_name: Symbol in library we are looking for +// lib_name: Name of library to look in, null for shared libs. +// is_absolute_path == true if lib_name is absolute path to agent +// such as "C:/a/b/L.dll" or "/a/b/libL.so" +// == false if only the base name of the library is passed in +// such as "L" +char* os::build_agent_function_name(const char *sym_name, const char *lib_name, + bool is_absolute_path) { + char *agent_entry_name; + size_t len = 0; + size_t name_len = 0; + size_t prefix_len = strlen(JNI_LIB_PREFIX); + size_t suffix_len = strlen(JNI_LIB_SUFFIX); + size_t underscore_len = 0; // optional underscore if lib_name is set + const char *start; + + if (lib_name != nullptr) { + if (is_absolute_path) { + // Need to strip path, prefix and suffix + if ((start = strrchr(lib_name, *os::file_separator())) != nullptr) { + lib_name = ++start; + } +#ifdef WINDOWS + else { // Need to check for drive prefix e.g. C:L.dll + if ((start = strchr(lib_name, ':')) != nullptr) { + lib_name = ++start; + } + } +#endif + name_len = strlen(lib_name); + if (name_len <= (prefix_len + suffix_len)) { + return nullptr; + } + lib_name += prefix_len; + name_len = strlen(lib_name) - suffix_len; + } else { + name_len = strlen(lib_name); + } + underscore_len = 1; + } + // Total buffer length to allocate - includes null terminator. + len = strlen(sym_name) + underscore_len + name_len + 1; + agent_entry_name = NEW_C_HEAP_ARRAY_RETURN_NULL(char, len, mtThread); + if (agent_entry_name == nullptr) { + return nullptr; + } + + strcpy(agent_entry_name, sym_name); + if (lib_name != nullptr) { + strcat(agent_entry_name, "_"); + strncat(agent_entry_name, lib_name, name_len); + } + return agent_entry_name; +} diff --git a/src/hotspot/share/runtime/os.hpp b/src/hotspot/share/runtime/os.hpp index 2e52440ead4b9..db4f0f8c79076 100644 --- a/src/hotspot/share/runtime/os.hpp +++ b/src/hotspot/share/runtime/os.hpp @@ -763,6 +763,9 @@ class os: AllStatic { // Unload library static void dll_unload(void *lib); + // Lookup the named function. This is used by the static JDK. + static void* lookup_function(const char* name); + // Callback for loaded module information // Input parameters: // char* module_file_name, diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp index b081ce29e26ce..e4dff47c84f1d 100644 --- a/src/hotspot/share/services/diagnosticCommand.cpp +++ b/src/hotspot/share/services/diagnosticCommand.cpp @@ -128,6 +128,8 @@ void DCmd::register_dcmds(){ #endif // INCLUDE_JVMTI DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); + DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); + DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); DCmdFactory::register_DCmdFactory(new DCmdFactoryImpl(full_export, true, false)); @@ -1073,13 +1075,6 @@ void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const cha Symbol* sym = vmSymbols::jdk_internal_vm_ThreadDumper(); Klass* k = SystemDictionary::resolve_or_fail(sym, true, CHECK); - InstanceKlass* ik = InstanceKlass::cast(k); - if (HAS_PENDING_EXCEPTION) { - java_lang_Throwable::print(PENDING_EXCEPTION, output()); - output()->cr(); - CLEAR_PENDING_EXCEPTION; - return; - } // invoke the ThreadDump method to dump to file JavaValue result(T_OBJECT); @@ -1110,6 +1105,45 @@ void ThreadDumpToFileDCmd::dumpToFile(Symbol* name, Symbol* signature, const cha output()->print_raw((const char*)addr, ba->length()); } +// Calls a static no-arg method on jdk.internal.vm.JcmdVThreadCommands that returns a byte[] with +// the output. If the method completes successfully then the bytes are copied to the output stream. +// If the method fails then the exception is printed to the output stream. +static void execute_vthread_command(Symbol* method_name, outputStream* output, TRAPS) { + ResourceMark rm(THREAD); + HandleMark hm(THREAD); + + Klass* k = SystemDictionary::resolve_or_fail(vmSymbols::jdk_internal_vm_JcmdVThreadCommands(), true, CHECK); + + JavaValue result(T_OBJECT); + JavaCallArguments args; + JavaCalls::call_static(&result, + k, + method_name, + vmSymbols::void_byte_array_signature(), + &args, + THREAD); + if (HAS_PENDING_EXCEPTION) { + java_lang_Throwable::print(PENDING_EXCEPTION, output); + output->cr(); + CLEAR_PENDING_EXCEPTION; + return; + } + + // copy the bytes to the output stream + oop res = cast_to_oop(result.get_jobject()); + typeArrayOop ba = typeArrayOop(res); + jbyte* addr = typeArrayOop(res)->byte_at_addr(0); + output->print_raw((const char*)addr, ba->length()); +} + +void VThreadSchedulerDCmd::execute(DCmdSource source, TRAPS) { + execute_vthread_command(vmSymbols::printScheduler_name(), output(), CHECK); +} + +void VThreadPollersDCmd::execute(DCmdSource source, TRAPS) { + execute_vthread_command(vmSymbols::printPollers_name(), output(), CHECK); +} + CompilationMemoryStatisticDCmd::CompilationMemoryStatisticDCmd(outputStream* output, bool heap) : DCmdWithParser(output, heap), _human_readable("-H", "Human readable format", "BOOLEAN", false, "false"), diff --git a/src/hotspot/share/services/diagnosticCommand.hpp b/src/hotspot/share/services/diagnosticCommand.hpp index 30b2be2a61b68..83e818e16d299 100644 --- a/src/hotspot/share/services/diagnosticCommand.hpp +++ b/src/hotspot/share/services/diagnosticCommand.hpp @@ -776,6 +776,33 @@ class ThreadDumpToFileDCmd : public DCmdWithParser { virtual void execute(DCmdSource source, TRAPS); }; +class VThreadSchedulerDCmd : public DCmd { +public: + VThreadSchedulerDCmd(outputStream* output, bool heap) : DCmd(output, heap) { } + static const char* name() { + return "Thread.vthread_scheduler"; + } + static const char* description() { + return "Print the virtual thread scheduler, and the delayed task schedulers that support " + "virtual threads doing timed operations."; + } + static const char* impact() { return "Low"; } + virtual void execute(DCmdSource source, TRAPS); +}; + +class VThreadPollersDCmd : public DCmd { +public: + VThreadPollersDCmd(outputStream* output, bool heap) : DCmd(output, heap) { } + static const char* name() { + return "Thread.vthread_pollers"; + } + static const char* description() { + return "Print the I/O pollers that support virtual threads doing blocking network I/O operations."; + } + static const char* impact() { return "Low"; } + virtual void execute(DCmdSource source, TRAPS); +}; + class CompilationMemoryStatisticDCmd: public DCmdWithParser { protected: DCmdArgument _human_readable; diff --git a/src/hotspot/share/utilities/globalDefinitions.hpp b/src/hotspot/share/utilities/globalDefinitions.hpp index 25af626c6286b..ccd3106b471a2 100644 --- a/src/hotspot/share/utilities/globalDefinitions.hpp +++ b/src/hotspot/share/utilities/globalDefinitions.hpp @@ -560,6 +560,9 @@ const jfloat min_jfloat = jfloat_cast(min_jintFloat); const jint max_jintFloat = (jint)(0x7f7fffff); const jfloat max_jfloat = jfloat_cast(max_jintFloat); +// A named constant for the integral representation of a Java null. +const intptr_t NULL_WORD = 0; + //---------------------------------------------------------------------------------------------------- // JVM spec restrictions diff --git a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp index e5decbcd53693..863e588d18032 100644 --- a/src/hotspot/share/utilities/globalDefinitions_gcc.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_gcc.hpp @@ -71,24 +71,6 @@ #include #endif // LINUX || _ALLBSD_SOURCE -// NULL vs NULL_WORD: -// On Linux NULL is defined as a special type '__null'. Assigning __null to -// integer variable will cause gcc warning. Use NULL_WORD in places where a -// pointer is stored as integer value. On some platforms, sizeof(intptr_t) > -// sizeof(void*), so here we want something which is integer type, but has the -// same size as a pointer. -#ifdef __GNUC__ - #ifdef _LP64 - #define NULL_WORD 0L - #else - // Cast 0 to intptr_t rather than int32_t since they are not the same type - // on platforms such as Mac OS X. - #define NULL_WORD ((intptr_t)0) - #endif -#else - #define NULL_WORD NULL -#endif - // checking for nanness #if defined(__APPLE__) inline int g_isnan(double f) { return isnan(f); } diff --git a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp index 237d12baa6da8..5f26a082d7cb0 100644 --- a/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp +++ b/src/hotspot/share/utilities/globalDefinitions_visCPP.hpp @@ -72,12 +72,6 @@ // 64-bit integer-suffix (LL) instead. #define NULL 0LL -// NULL vs NULL_WORD: -// On Linux NULL is defined as a special type '__null'. Assigning __null to -// integer variable will cause gcc warning. Use NULL_WORD in places where a -// pointer is stored as integer value. -#define NULL_WORD NULL - typedef int64_t ssize_t; // Non-standard stdlib-like stuff: diff --git a/src/hotspot/share/utilities/zipLibrary.cpp b/src/hotspot/share/utilities/zipLibrary.cpp index 57b3e501f56e9..0b3c307c29143 100644 --- a/src/hotspot/share/utilities/zipLibrary.cpp +++ b/src/hotspot/share/utilities/zipLibrary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, 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 @@ -60,6 +60,10 @@ static inline bool not_loaded() { } static void* dll_lookup(const char* name, const char* path, bool vm_exit_on_failure) { + if (is_vm_statically_linked()) { + return os::lookup_function(name); + } + assert(_zip_handle != nullptr, "invariant"); void* func = os::dll_lookup(_zip_handle, name); if (func == nullptr && vm_exit_on_failure) { @@ -87,16 +91,23 @@ static void store_function_pointers(const char* path, bool vm_exit_on_failure) { static void load_zip_library(bool vm_exit_on_failure) { assert(!is_loaded(), "should not load zip library twice"); char path[JVM_MAXPATHLEN]; - if (os::dll_locate_lib(&path[0], sizeof path, Arguments::get_dll_dir(), "zip")) { - char ebuf[1024]; - _zip_handle = os::dll_load(&path[0], &ebuf[0], sizeof ebuf); - } - if (_zip_handle == nullptr) { - if (vm_exit_on_failure) { - vm_exit_during_initialization("Unable to load zip library", &path[0]); + + if (is_vm_statically_linked()) { + _zip_handle = os::get_default_process_handle(); + } else { + // Load the libzip shared library and lookup the needed functions. + if (os::dll_locate_lib(&path[0], sizeof path, Arguments::get_dll_dir(), "zip")) { + char ebuf[1024]; + _zip_handle = os::dll_load(&path[0], &ebuf[0], sizeof ebuf); + } + if (_zip_handle == nullptr) { + if (vm_exit_on_failure) { + vm_exit_during_initialization("Unable to load zip library", &path[0]); + } + return; } - return; } + store_function_pointers(&path[0], vm_exit_on_failure); Atomic::release_store(&_loaded, true); assert(is_loaded(), "invariant"); diff --git a/src/java.base/macosx/classes/apple/security/AppleProvider.java b/src/java.base/macosx/classes/apple/security/AppleProvider.java index 3f584be336b90..0835f1f0dd305 100644 --- a/src/java.base/macosx/classes/apple/security/AppleProvider.java +++ b/src/java.base/macosx/classes/apple/security/AppleProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ -75,20 +75,14 @@ public Object newInstance(Object ctrParamObj) } - @SuppressWarnings("removal") public AppleProvider() { /* We are the Apple provider */ super("Apple", PROVIDER_VER, info); final Provider p = this; - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - putService(new ProviderService(p, "KeyStore", - "KeychainStore", "apple.security.KeychainStore$USER")); - putService(new ProviderService(p, "KeyStore", - "KeychainStore-ROOT", "apple.security.KeychainStore$ROOT")); - return null; - } - }); + putService(new ProviderService(p, "KeyStore", + "KeychainStore", "apple.security.KeychainStore$USER")); + putService(new ProviderService(p, "KeyStore", + "KeychainStore-ROOT", "apple.security.KeychainStore$ROOT")); } } diff --git a/src/java.base/macosx/classes/apple/security/KeychainStore.java b/src/java.base/macosx/classes/apple/security/KeychainStore.java index c8bb717d8ad1a..6f70fccbb244b 100644 --- a/src/java.base/macosx/classes/apple/security/KeychainStore.java +++ b/src/java.base/macosx/classes/apple/security/KeychainStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, 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 @@ -188,15 +188,6 @@ static class TrustedCertEntry { jdk.internal.loader.BootLoader.loadLibrary("osxsecurity"); } - private static void permissionCheck() { - @SuppressWarnings("removal") - SecurityManager sec = System.getSecurityManager(); - - if (sec != null) { - sec.checkPermission(new RuntimePermission("useKeychainStore")); - } - } - private final String storeName; /** @@ -228,8 +219,6 @@ private KeychainStore(String name) { public Key engineGetKey(String alias, char[] password) throws NoSuchAlgorithmException, UnrecoverableKeyException { - permissionCheck(); - // An empty password is rejected by MacOS API, no private key data // is exported. If no password is passed (as is the case when // this implementation is used as browser keystore in various @@ -332,8 +321,6 @@ public Key engineGetKey(String alias, char[] password) * key entry without a certificate chain). */ public Certificate[] engineGetCertificateChain(String alias) { - permissionCheck(); - Object entry = entries.get(alias.toLowerCase(Locale.ROOT)); if (entry instanceof KeyEntry keyEntry) { @@ -363,8 +350,6 @@ public Certificate[] engineGetCertificateChain(String alias) { * does not contain a certificate. */ public Certificate engineGetCertificate(String alias) { - permissionCheck(); - Object entry = entries.get(alias.toLowerCase(Locale.ROOT)); if (entry != null) { @@ -420,8 +405,6 @@ public KeyStore.Entry engineGetEntry(String alias, KeyStore.ProtectionParameter * not exist */ public Date engineGetCreationDate(String alias) { - permissionCheck(); - Object entry = entries.get(alias.toLowerCase(Locale.ROOT)); if (entry != null) { @@ -461,8 +444,6 @@ public void engineSetKeyEntry(String alias, Key key, char[] password, Certificate[] chain) throws KeyStoreException { - permissionCheck(); - synchronized(entries) { try { KeyEntry entry = new KeyEntry(); @@ -532,8 +513,6 @@ public void engineSetKeyEntry(String alias, byte[] key, Certificate[] chain) throws KeyStoreException { - permissionCheck(); - synchronized(entries) { // key must be encoded as EncryptedPrivateKeyInfo as defined in // PKCS#8 @@ -582,8 +561,6 @@ public void engineSetCertificateEntry(String alias, Certificate cert) public void engineDeleteEntry(String alias) throws KeyStoreException { - permissionCheck(); - String lowerAlias = alias.toLowerCase(Locale.ROOT); synchronized(entries) { Object entry = entries.remove(lowerAlias); @@ -597,7 +574,6 @@ public void engineDeleteEntry(String alias) * @return enumeration of the alias names */ public Enumeration engineAliases() { - permissionCheck(); return entries.keys(); } @@ -609,7 +585,6 @@ public Enumeration engineAliases() { * @return true if the alias exists, false otherwise */ public boolean engineContainsAlias(String alias) { - permissionCheck(); return entries.containsKey(alias.toLowerCase(Locale.ROOT)); } @@ -619,7 +594,6 @@ public boolean engineContainsAlias(String alias) { * @return the number of entries in this keystore */ public int engineSize() { - permissionCheck(); return entries.size(); } @@ -631,7 +605,6 @@ public int engineSize() { * key entry, false otherwise. */ public boolean engineIsKeyEntry(String alias) { - permissionCheck(); Object entry = entries.get(alias.toLowerCase(Locale.ROOT)); return entry instanceof KeyEntry; } @@ -644,7 +617,6 @@ public boolean engineIsKeyEntry(String alias) { * trusted certificate entry, false otherwise. */ public boolean engineIsCertificateEntry(String alias) { - permissionCheck(); Object entry = entries.get(alias.toLowerCase(Locale.ROOT)); return entry instanceof TrustedCertEntry; } @@ -666,7 +638,6 @@ public boolean engineIsCertificateEntry(String alias) { * or null if no such entry exists in this keystore. */ public String engineGetCertificateAlias(Certificate cert) { - permissionCheck(); Certificate certElem; for (Enumeration e = entries.keys(); e.hasMoreElements(); ) { @@ -704,8 +675,6 @@ public String engineGetCertificateAlias(Certificate cert) { public void engineStore(OutputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException { - permissionCheck(); - // Delete items that do have a keychain item ref. for (Enumeration e = deletedEntries.keys(); e.hasMoreElements(); ) { String alias = e.nextElement(); @@ -795,8 +764,6 @@ private long addCertificateToKeychain(String alias, Certificate cert) { public void engineLoad(InputStream stream, char[] password) throws IOException, NoSuchAlgorithmException, CertificateException { - permissionCheck(); - // Release any stray keychain references before clearing out the entries. synchronized(entries) { for (Enumeration e = entries.keys(); e.hasMoreElements(); ) { diff --git a/src/java.base/macosx/native/libjli/java_md_macosx.m b/src/java.base/macosx/native/libjli/java_md_macosx.m index c836ae903e5f0..2b205a65ba16f 100644 --- a/src/java.base/macosx/native/libjli/java_md_macosx.m +++ b/src/java.base/macosx/native/libjli/java_md_macosx.m @@ -336,29 +336,31 @@ static void MacOSXStartup(int argc, char *argv[]) { int argc = *pargc; char **argv = *pargv; - /* Find out where the JDK is that we will be using. */ - if (!GetJDKInstallRoot(jdkroot, so_jdkroot, JNI_FALSE) ) { - JLI_ReportErrorMessage(LAUNCHER_ERROR1); - exit(2); - } - JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg", - jdkroot, FILESEP, FILESEP); - /* Find the specified JVM type */ - if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) { - JLI_ReportErrorMessage(CFG_ERROR7); - exit(1); - } + if (!JLI_IsStaticallyLinked()) { + /* Find out where the JDK is that we will be using. */ + if (!GetJDKInstallRoot(jdkroot, so_jdkroot, JNI_FALSE) ) { + JLI_ReportErrorMessage(LAUNCHER_ERROR1); + exit(2); + } + JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg", + jdkroot, FILESEP, FILESEP); + /* Find the specified JVM type */ + if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) { + JLI_ReportErrorMessage(CFG_ERROR7); + exit(1); + } - jvmpath[0] = '\0'; - jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE); - if (JLI_StrCmp(jvmtype, "ERROR") == 0) { - JLI_ReportErrorMessage(CFG_ERROR9); - exit(4); - } + jvmpath[0] = '\0'; + jvmtype = CheckJvmType(pargc, pargv, JNI_FALSE); + if (JLI_StrCmp(jvmtype, "ERROR") == 0) { + JLI_ReportErrorMessage(CFG_ERROR9); + exit(4); + } - if (!GetJVMPath(jdkroot, jvmtype, jvmpath, so_jvmpath)) { - JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); - exit(4); + if (!GetJVMPath(jdkroot, jvmtype, jvmpath, so_jvmpath)) { + JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); + exit(4); + } } /* diff --git a/src/java.base/share/classes/com/sun/crypto/provider/KeyProtector.java b/src/java.base/share/classes/com/sun/crypto/provider/KeyProtector.java index f2d3efd685c06..06ccf6cba392b 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/KeyProtector.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/KeyProtector.java @@ -89,7 +89,7 @@ final class KeyProtector { */ static { int iterationCount = DEFAULT_ITERATION_COUNT; - String ic = SecurityProperties.privilegedGetOverridable( + String ic = SecurityProperties.getOverridableProperty( "jdk.jceks.iterationCount"); if (ic != null && !ic.isEmpty()) { try { diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index 771084384c805..23b8ac3fb9093 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -53,6 +53,7 @@ import java.lang.reflect.TypeVariable; import java.lang.constant.Constable; import java.net.URL; +import java.security.AllPermission; import java.security.Permissions; import java.security.ProtectionDomain; import java.util.ArrayList; @@ -89,7 +90,6 @@ import sun.reflect.generics.repository.MethodRepository; import sun.reflect.generics.repository.ConstructorRepository; import sun.reflect.generics.scope.ClassScope; -import sun.security.util.SecurityConstants; import sun.reflect.annotation.*; import sun.reflect.misc.ReflectUtil; @@ -2720,7 +2720,7 @@ private static class Holder { private static final ProtectionDomain allPermDomain; static { Permissions perms = new Permissions(); - perms.add(SecurityConstants.ALL_PERMISSION); + perms.add(new AllPermission()); allPermDomain = new ProtectionDomain(null, perms); } } diff --git a/src/java.base/share/classes/java/lang/System.java b/src/java.base/share/classes/java/lang/System.java index e5e8d4df27a93..11c77d48bf01c 100644 --- a/src/java.base/share/classes/java/lang/System.java +++ b/src/java.base/share/classes/java/lang/System.java @@ -55,6 +55,7 @@ import java.util.ResourceBundle; import java.util.Set; import java.util.concurrent.Executor; +import java.util.concurrent.ScheduledExecutorService; import java.util.function.Supplier; import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Stream; @@ -2304,6 +2305,10 @@ public Executor virtualThreadDefaultScheduler() { return VirtualThread.defaultScheduler(); } + public Stream virtualThreadDelayedTaskSchedulers() { + return VirtualThread.delayedTaskSchedulers(); + } + public StackWalker newStackWalkerInstance(Set options, ContinuationScope contScope, Continuation continuation) { diff --git a/src/java.base/share/classes/java/lang/VirtualThread.java b/src/java.base/share/classes/java/lang/VirtualThread.java index 1f8e1941c1d90..dc8c6a852d047 100644 --- a/src/java.base/share/classes/java/lang/VirtualThread.java +++ b/src/java.base/share/classes/java/lang/VirtualThread.java @@ -24,6 +24,7 @@ */ package java.lang; +import java.util.Arrays; import java.util.Locale; import java.util.Objects; import java.util.concurrent.CountDownLatch; @@ -32,12 +33,12 @@ import java.util.concurrent.ForkJoinPool; import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory; import java.util.concurrent.ForkJoinTask; -import java.util.concurrent.ForkJoinWorkerThread; import java.util.concurrent.Future; import java.util.concurrent.RejectedExecutionException; import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import java.util.stream.Stream; import jdk.internal.event.VirtualThreadEndEvent; import jdk.internal.event.VirtualThreadStartEvent; import jdk.internal.event.VirtualThreadSubmitFailedEvent; @@ -192,6 +193,13 @@ static Executor defaultScheduler() { return DEFAULT_SCHEDULER; } + /** + * Returns a stream of the delayed task schedulers used to support timed operations. + */ + static Stream delayedTaskSchedulers() { + return Arrays.stream(DELAYED_TASK_SCHEDULERS); + } + /** * Returns the continuation scope used for virtual threads. */ diff --git a/src/java.base/share/classes/java/lang/foreign/Linker.java b/src/java.base/share/classes/java/lang/foreign/Linker.java index bfa205e2fadf3..c8e4cf4746b69 100644 --- a/src/java.base/share/classes/java/lang/foreign/Linker.java +++ b/src/java.base/share/classes/java/lang/foreign/Linker.java @@ -852,8 +852,6 @@ static Option firstVariadicArg(int index) { * // use errno * } * } - *

- * This linker option can not be combined with {@link #critical}. * * @param capturedState the names of the values to save * @throws IllegalArgumentException if at least one of the provided diff --git a/src/java.base/share/classes/java/net/IDN.java b/src/java.base/share/classes/java/net/IDN.java index 6f11643264f8c..0aaac84076607 100644 --- a/src/java.base/share/classes/java/net/IDN.java +++ b/src/java.base/share/classes/java/net/IDN.java @@ -66,6 +66,9 @@ * Applications are responsible for taking adequate security measures when using * international domain names. * + *

Unless otherwise specified, passing a {@code null} argument to any method + * in this class will cause a {@link NullPointerException} to be thrown. + * * @spec https://www.rfc-editor.org/info/rfc1122 * RFC 1122: Requirements for Internet Hosts - Communication Layers * @spec https://www.rfc-editor.org/info/rfc1123 diff --git a/src/java.base/share/classes/java/net/InterfaceAddress.java b/src/java.base/share/classes/java/net/InterfaceAddress.java index f5b76ec9f90ce..979ed9cc7f53f 100644 --- a/src/java.base/share/classes/java/net/InterfaceAddress.java +++ b/src/java.base/share/classes/java/net/InterfaceAddress.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, 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 @@ -42,10 +42,9 @@ public class InterfaceAddress { private short maskLength = 0; /* - * Package private constructor. Can't be built directly, instances are - * obtained through the NetworkInterface class. + * This constructor is called via JNI in NetworkInterface.c */ - InterfaceAddress() { + private InterfaceAddress() { } /** diff --git a/src/java.base/share/classes/java/net/Socket.java b/src/java.base/share/classes/java/net/Socket.java index 83c0dec682ca1..929e99b530339 100644 --- a/src/java.base/share/classes/java/net/Socket.java +++ b/src/java.base/share/classes/java/net/Socket.java @@ -454,6 +454,7 @@ private Socket(SocketAddress address, SocketAddress localAddr, boolean stream) throws IOException { Objects.requireNonNull(address); + assert address instanceof InetSocketAddress; // create the SocketImpl and the underlying socket SocketImpl impl = createImpl(); @@ -463,16 +464,13 @@ private Socket(SocketAddress address, SocketAddress localAddr, boolean stream) this.state = SOCKET_CREATED; try { - if (localAddr != null) + if (localAddr != null) { bind(localAddr); - connect(address); - } catch (IOException | IllegalArgumentException e) { - try { - close(); - } catch (IOException ce) { - e.addSuppressed(ce); } - throw e; + connect(address); + } catch (Throwable throwable) { + closeSuppressingExceptions(throwable); + throw throwable; } } @@ -571,6 +569,10 @@ void setConnected() { /** * Connects this socket to the server. * + *

If the endpoint is an unresolved {@link InetSocketAddress}, or the + * connection cannot be established, then the socket is closed, and an + * {@link IOException} is thrown. + * *

This method is {@linkplain Thread#interrupt() interruptible} in the * following circumstances: *

    @@ -589,6 +591,8 @@ void setConnected() { * @param endpoint the {@code SocketAddress} * @throws IOException if an error occurs during the connection, the socket * is already connected or the socket is closed + * @throws UnknownHostException if the endpoint is an unresolved + * {@link InetSocketAddress} * @throws java.nio.channels.IllegalBlockingModeException * if this socket has an associated channel, * and the channel is in non-blocking mode @@ -605,6 +609,11 @@ public void connect(SocketAddress endpoint) throws IOException { * A timeout of zero is interpreted as an infinite timeout. The connection * will then block until established or an error occurs. * + *

    If the endpoint is an unresolved {@link InetSocketAddress}, the + * connection cannot be established, or the timeout expires before the + * connection is established, then the socket is closed, and an + * {@link IOException} is thrown. + * *

    This method is {@linkplain Thread#interrupt() interruptible} in the * following circumstances: *

      @@ -625,6 +634,8 @@ public void connect(SocketAddress endpoint) throws IOException { * @throws IOException if an error occurs during the connection, the socket * is already connected or the socket is closed * @throws SocketTimeoutException if timeout expires before connecting + * @throws UnknownHostException if the endpoint is an unresolved + * {@link InetSocketAddress} * @throws java.nio.channels.IllegalBlockingModeException * if this socket has an associated channel, * and the channel is in non-blocking mode @@ -644,26 +655,25 @@ public void connect(SocketAddress endpoint, int timeout) throws IOException { if (isClosed(s)) throw new SocketException("Socket is closed"); if (isConnected(s)) - throw new SocketException("already connected"); + throw new SocketException("Already connected"); if (!(endpoint instanceof InetSocketAddress epoint)) throw new IllegalArgumentException("Unsupported address type"); + if (epoint.isUnresolved()) { + var uhe = new UnknownHostException(epoint.getHostName()); + closeSuppressingExceptions(uhe); + throw uhe; + } + InetAddress addr = epoint.getAddress(); - int port = epoint.getPort(); checkAddress(addr, "connect"); try { getImpl().connect(epoint, timeout); - } catch (SocketTimeoutException e) { - throw e; - } catch (InterruptedIOException e) { - Thread thread = Thread.currentThread(); - if (thread.isVirtual() && thread.isInterrupted()) { - close(); - throw new SocketException("Closed by interrupt"); - } - throw e; + } catch (IOException error) { + closeSuppressingExceptions(error); + throw error; } // connect will bind the socket if not previously bound @@ -1589,6 +1599,14 @@ public boolean getReuseAddress() throws SocketException { return ((Boolean) (getImpl().getOption(SocketOptions.SO_REUSEADDR))).booleanValue(); } + private void closeSuppressingExceptions(Throwable parentException) { + try { + close(); + } catch (IOException exception) { + parentException.addSuppressed(exception); + } + } + /** * Closes this socket. *

      diff --git a/src/java.base/share/classes/java/security/AccessControlContext.java b/src/java.base/share/classes/java/security/AccessControlContext.java index 6c73e6339fb71..01c7244fe2c65 100644 --- a/src/java.base/share/classes/java/security/AccessControlContext.java +++ b/src/java.base/share/classes/java/security/AccessControlContext.java @@ -44,14 +44,6 @@ public final class AccessControlContext { private ProtectionDomain[] context; - // isPrivileged and isAuthorized are referenced by the VM - do not remove - // or change their names - private boolean isPrivileged; - private boolean isAuthorized = false; - - // Note: This field is directly used by the virtual machine - // native codes. Don't touch it. - private AccessControlContext privilegedContext; @SuppressWarnings("removal") private DomainCombiner combiner = null; diff --git a/src/java.base/share/classes/java/security/Identity.java b/src/java.base/share/classes/java/security/Identity.java index f717f5576b071..e23f2043c02f3 100644 --- a/src/java.base/share/classes/java/security/Identity.java +++ b/src/java.base/share/classes/java/security/Identity.java @@ -178,7 +178,6 @@ public PublicKey getPublicKey() { /* Should we throw an exception if this is already set? */ public void setPublicKey(PublicKey key) throws KeyManagementException { - check("setIdentityPublicKey"); this.publicKey = key; certificates = new Vector<>(); } @@ -191,7 +190,6 @@ public void setPublicKey(PublicKey key) throws KeyManagementException { * @see #getInfo */ public void setInfo(String info) { - check("setIdentityInfo"); this.info = info; } @@ -221,8 +219,6 @@ public String getInfo() { public void addCertificate(Certificate certificate) throws KeyManagementException { - check("addIdentityCertificate"); - if (certificates == null) { certificates = new Vector<>(); } @@ -260,7 +256,6 @@ private boolean keyEquals(PublicKey aKey, PublicKey anotherKey) { */ public void removeCertificate(Certificate certificate) throws KeyManagementException { - check("removeIdentityCertificate"); if (certificates != null) { certificates.removeElement(certificate); } @@ -358,7 +353,6 @@ String fullName() { * name of its scope (if any). */ public String toString() { - check("printIdentity"); String printable = name; if (scope != null) { printable += "[" + scope.getName() + "]"; @@ -429,11 +423,4 @@ String printCertificates() { public int hashCode() { return name.hashCode(); } - - private static void check(String directive) { - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkSecurityAccess(directive); - } - } } diff --git a/src/java.base/share/classes/java/security/IdentityScope.java b/src/java.base/share/classes/java/security/IdentityScope.java index 73128d0e010df..aedbd51bdf9f9 100644 --- a/src/java.base/share/classes/java/security/IdentityScope.java +++ b/src/java.base/share/classes/java/security/IdentityScope.java @@ -76,13 +76,7 @@ class IdentityScope extends Identity { // initialize the system scope private static void initializeSystemScope() { - String classname = AccessController.doPrivileged( - new PrivilegedAction<>() { - public String run() { - return Security.getProperty("system.scope"); - } - }); - + String classname = Security.getProperty("system.scope"); if (classname == null) { return; @@ -153,7 +147,6 @@ public static IdentityScope getSystemScope() { * @see #getSystemScope */ protected static void setSystemScope(IdentityScope scope) { - check("setSystemScope"); IdentityScope.scope = scope; } @@ -241,12 +234,4 @@ public abstract void removeIdentity(Identity identity) public String toString() { return super.toString() + "[" + size() + "]"; } - - private static void check(String directive) { - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkSecurityAccess(directive); - } - } - } diff --git a/src/java.base/share/classes/java/security/KeyStore.java b/src/java.base/share/classes/java/security/KeyStore.java index 0370b5e988494..b420cc69aa6e2 100644 --- a/src/java.base/share/classes/java/security/KeyStore.java +++ b/src/java.base/share/classes/java/security/KeyStore.java @@ -987,9 +987,7 @@ public static KeyStore getInstance(String type, Provider provider) * @see java.security.Security security properties */ public static final String getDefaultType() { - @SuppressWarnings("removal") - String kstype = AccessController.doPrivileged((PrivilegedAction) () -> - Security.getProperty(KEYSTORE_TYPE)); + String kstype = Security.getProperty(KEYSTORE_TYPE); if (kstype == null) { kstype = "pkcs12"; } @@ -1993,9 +1991,7 @@ public static Builder newInstance(String type, Provider provider, ("File does not exist or it does not refer " + "to a normal file: " + file); } - @SuppressWarnings("removal") - var acc = AccessController.getContext(); - return new FileBuilder(type, provider, file, protection, acc); + return new FileBuilder(type, provider, file, protection); } /** @@ -2048,24 +2044,19 @@ private static final class FileBuilder extends Builder { private final File file; private final ProtectionParameter protection; private ProtectionParameter keyProtection; - @SuppressWarnings("removal") - private final AccessControlContext context; private KeyStore keyStore; private Throwable oldException; FileBuilder(String type, Provider provider, File file, - ProtectionParameter protection, - @SuppressWarnings("removal") AccessControlContext context) { + ProtectionParameter protection) { this.type = type; this.provider = provider; this.file = file; this.protection = protection; - this.context = context; } - @SuppressWarnings("removal") public synchronized KeyStore getKeyStore() throws KeyStoreException { if (keyStore != null) { @@ -2076,19 +2067,18 @@ public synchronized KeyStore getKeyStore() throws KeyStoreException ("Previous KeyStore instantiation failed", oldException); } - PrivilegedExceptionAction action = - new PrivilegedExceptionAction() { - public KeyStore run() throws Exception { - if (!(protection instanceof CallbackHandlerProtection)) { - return run0(); - } + try { + if (!(protection instanceof CallbackHandlerProtection)) { + keyStore = getKeyStore0(); + } else { // when using a CallbackHandler, // reprompt if the password is wrong int tries = 0; while (true) { tries++; try { - return run0(); + keyStore = getKeyStore0(); + break; } catch (IOException e) { if ((tries < MAX_CALLBACK_TRIES) && (e.getCause() instanceof UnrecoverableKeyException)) { @@ -2098,58 +2088,53 @@ public KeyStore run() throws Exception { } } } - public KeyStore run0() throws Exception { - KeyStore ks; - char[] password; + } catch (Exception e) { + oldException = e; + throw new KeyStoreException + ("KeyStore instantiation failed", oldException); + } + return keyStore; + } - // Acquire keystore password - if (protection instanceof PasswordProtection) { - password = - ((PasswordProtection)protection).getPassword(); - keyProtection = protection; - } else { - CallbackHandler handler = - ((CallbackHandlerProtection)protection) - .getCallbackHandler(); - PasswordCallback callback = new PasswordCallback - ("Password for keystore " + file.getName(), - false); - handler.handle(new Callback[] {callback}); - password = callback.getPassword(); - if (password == null) { - throw new KeyStoreException("No password" + - " provided"); - } - callback.clearPassword(); - keyProtection = new PasswordProtection(password); - } + private KeyStore getKeyStore0() throws Exception { + KeyStore ks; + char[] password; - if (type.isEmpty()) { - // Instantiate keystore and load keystore data - ks = KeyStore.getInstance(file, password); - } else { - // Instantiate keystore - if (provider == null) { - ks = KeyStore.getInstance(type); - } else { - ks = KeyStore.getInstance(type, provider); - } - // Load keystore data - try (InputStream in = new FileInputStream(file)) { - ks.load(in, password); - } - } - return ks; + // Acquire keystore password + if (protection instanceof PasswordProtection) { + password = ((PasswordProtection)protection).getPassword(); + keyProtection = protection; + } else { + CallbackHandler handler = + ((CallbackHandlerProtection)protection) + .getCallbackHandler(); + PasswordCallback callback = new PasswordCallback + ("Password for keystore " + file.getName(), false); + handler.handle(new Callback[] {callback}); + password = callback.getPassword(); + if (password == null) { + throw new KeyStoreException("No password" + " provided"); + } + callback.clearPassword(); + keyProtection = new PasswordProtection(password); + } + + if (type.isEmpty()) { + // Instantiate keystore and load keystore data + ks = KeyStore.getInstance(file, password); + } else { + // Instantiate keystore + if (provider == null) { + ks = KeyStore.getInstance(type); + } else { + ks = KeyStore.getInstance(type, provider); + } + // Load keystore data + try (InputStream in = new FileInputStream(file)) { + ks.load(in, password); } - }; - try { - keyStore = AccessController.doPrivileged(action, context); - return keyStore; - } catch (PrivilegedActionException e) { - oldException = e.getCause(); - throw new KeyStoreException - ("KeyStore instantiation failed", oldException); } + return ks; } public synchronized ProtectionParameter @@ -2195,16 +2180,18 @@ public static Builder newInstance(final String type, if ((type == null) || (protection == null)) { throw new NullPointerException(); } - @SuppressWarnings("removal") - final AccessControlContext context = AccessController.getContext(); return new Builder() { private volatile boolean getCalled; private IOException oldException; - private final PrivilegedExceptionAction action - = new PrivilegedExceptionAction<>() { - - public KeyStore run() throws Exception { + public synchronized KeyStore getKeyStore() + throws KeyStoreException { + if (oldException != null) { + throw new KeyStoreException + ("Previous KeyStore instantiation failed", + oldException); + } + try { KeyStore ks; if (provider == null) { ks = KeyStore.getInstance(type); @@ -2237,23 +2224,9 @@ public KeyStore run() throws Exception { } getCalled = true; return ks; - } - }; - - @SuppressWarnings("removal") - public synchronized KeyStore getKeyStore() - throws KeyStoreException { - if (oldException != null) { - throw new KeyStoreException - ("Previous KeyStore instantiation failed", - oldException); - } - try { - return AccessController.doPrivileged(action, context); - } catch (PrivilegedActionException e) { - Throwable cause = e.getCause(); + } catch (Exception e) { throw new KeyStoreException - ("KeyStore instantiation failed", cause); + ("KeyStore instantiation failed", e); } } diff --git a/src/java.base/share/classes/java/security/Provider.java b/src/java.base/share/classes/java/security/Provider.java index 7012bcc9eebac..da3f53b963241 100644 --- a/src/java.base/share/classes/java/security/Provider.java +++ b/src/java.base/share/classes/java/security/Provider.java @@ -345,12 +345,6 @@ public String toString() { return name + " version " + versionStr; } - /* - * override the following methods to ensure that provider - * information can only be changed if the caller has the appropriate - * permissions. - */ - /** * Clears this {@code Provider} so that it no longer contains the properties * used to look up facilities implemented by the {@code Provider}. @@ -359,7 +353,7 @@ public String toString() { */ @Override public synchronized void clear() { - check("clearProviderProperties."+name); + checkInitialized(); if (debug != null) { debug.println("Remove " + name + " provider properties"); } @@ -376,7 +370,7 @@ public synchronized void clear() { */ @Override public synchronized void load(InputStream inStream) throws IOException { - check("putProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Load " + name + " provider properties"); } @@ -394,7 +388,7 @@ public synchronized void load(InputStream inStream) throws IOException { */ @Override public synchronized void putAll(Map t) { - check("putProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Put all " + name + " provider properties"); } @@ -461,7 +455,7 @@ public Collection values() { */ @Override public synchronized Object put(Object key, Object value) { - check("putProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Set " + name + " provider property [" + key + "/" + value +"]"); @@ -478,7 +472,7 @@ public synchronized Object put(Object key, Object value) { */ @Override public synchronized Object putIfAbsent(Object key, Object value) { - check("putProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Set " + name + " provider property [" + key + "/" + value +"]"); @@ -494,7 +488,7 @@ public synchronized Object putIfAbsent(Object key, Object value) { */ @Override public synchronized Object remove(Object key) { - check("removeProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Remove " + name + " provider property " + key); } @@ -509,7 +503,7 @@ public synchronized Object remove(Object key) { */ @Override public synchronized boolean remove(Object key, Object value) { - check("removeProviderProperty."+name); + checkInitialized(); if (debug != null) { debug.println("Remove " + name + " provider property " + key); } @@ -525,7 +519,7 @@ public synchronized boolean remove(Object key, Object value) { @Override public synchronized boolean replace(Object key, Object oldValue, Object newValue) { - check("putProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("Replace " + name + " provider property " + key); } @@ -540,7 +534,7 @@ public synchronized boolean replace(Object key, Object oldValue, */ @Override public synchronized Object replace(Object key, Object value) { - check("putProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("Replace " + name + " provider property " + key); } @@ -558,7 +552,7 @@ public synchronized Object replace(Object key, Object value) { @Override public synchronized void replaceAll(BiFunction function) { - check("putProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("ReplaceAll " + name + " provider property "); } @@ -575,8 +569,7 @@ public synchronized void replaceAll(BiFunction remappingFunction) { - check("putProviderProperty." + name); - check("removeProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("Compute " + name + " provider property " + key); } @@ -594,8 +587,7 @@ public synchronized Object compute(Object key, BiFunction mappingFunction) { - check("putProviderProperty." + name); - check("removeProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("ComputeIfAbsent " + name + " provider property " + key); @@ -613,8 +605,7 @@ public synchronized Object computeIfAbsent(Object key, public synchronized Object computeIfPresent(Object key, BiFunction remappingFunction) { - check("putProviderProperty." + name); - check("removeProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("ComputeIfPresent " + name + " provider property " + key); @@ -635,8 +626,7 @@ public synchronized Object computeIfPresent(Object key, public synchronized Object merge(Object key, Object value, BiFunction remappingFunction) { - check("putProviderProperty." + name); - check("removeProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println("Merge " + name + " provider property " + key); } @@ -694,15 +684,6 @@ private void checkInitialized() { } } - private void check(String directive) { - checkInitialized(); - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkSecurityAccess(directive); - } - } - // legacyMap changed since last call to getServices() private transient volatile boolean legacyChanged; // serviceMap changed since last call to getServices() @@ -789,8 +770,6 @@ private static boolean checkLegacy(Object key) { /** * Copies all the mappings from the specified Map to this provider. - * Internal method to be called AFTER the security check has been - * performed. */ private void implPutAll(Map t) { for (Map.Entry e : t.entrySet()) { @@ -1239,7 +1218,7 @@ public Set getServices() { * @since 1.5 */ protected void putService(Service s) { - check("putProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println(name + ".putService(): " + s); } @@ -1303,7 +1282,7 @@ Service getDefaultSecureRandomService() { private void putPropertyStrings(Service s) { String type = s.getType(); String algorithm = s.getAlgorithm(); - // use super() to avoid permission check and other processing + // use super() to avoid other processing super.put(type + "." + algorithm, s.getClassName()); for (String alias : s.getAliases()) { super.put(ALIAS_PREFIX + type + "." + alias, algorithm); @@ -1321,7 +1300,7 @@ private void putPropertyStrings(Service s) { private void removePropertyStrings(Service s) { String type = s.getType(); String algorithm = s.getAlgorithm(); - // use super() to avoid permission check and other processing + // use super() to avoid other processing super.remove(type + "." + algorithm); for (String alias : s.getAliases()) { super.remove(ALIAS_PREFIX + type + "." + alias); @@ -1346,7 +1325,7 @@ private void removePropertyStrings(Service s) { * @since 1.5 */ protected void removeService(Service s) { - check("removeProviderProperty." + name); + checkInitialized(); if (debug != null) { debug.println(name + ".removeService(): " + s); } diff --git a/src/java.base/share/classes/java/security/SecureRandom.java b/src/java.base/share/classes/java/security/SecureRandom.java index 734f25e6615a7..e6cc1134c09b6 100644 --- a/src/java.base/share/classes/java/security/SecureRandom.java +++ b/src/java.base/share/classes/java/security/SecureRandom.java @@ -942,11 +942,7 @@ private static final class StrongPatternHolder { public static SecureRandom getInstanceStrong() throws NoSuchAlgorithmException { - @SuppressWarnings("removal") - String property = AccessController.doPrivileged( - (PrivilegedAction) () -> Security.getProperty( - "securerandom.strongAlgorithms")); - + String property = Security.getProperty("securerandom.strongAlgorithms"); if (property == null || property.isEmpty()) { throw new NoSuchAlgorithmException( "Null/empty securerandom.strongAlgorithms Security Property"); diff --git a/src/java.base/share/classes/java/security/Security.java b/src/java.base/share/classes/java/security/Security.java index aab793b98e98e..6969fe8a8e142 100644 --- a/src/java.base/share/classes/java/security/Security.java +++ b/src/java.base/share/classes/java/security/Security.java @@ -312,14 +312,7 @@ private static void debugLoad(boolean start, Object source) { } static { - // doPrivileged here because there are multiple - // things in initialize that might require privs. - // (the FileInputStream call and the File.exists call, etc) - @SuppressWarnings("removal") - var dummy = AccessController.doPrivileged((PrivilegedAction) () -> { - initialize(); - return null; - }); + initialize(); // Set up JavaSecurityPropertiesAccess in SharedSecrets SharedSecrets.setJavaSecurityPropertiesAccess(new JavaSecurityPropertiesAccess() { @Override @@ -475,15 +468,13 @@ public static String getAlgorithmProperty(String algName, */ public static synchronized int insertProviderAt(Provider provider, int position) { - String providerName = provider.getName(); - checkInsertProvider(providerName); ProviderList list = Providers.getFullProviderList(); ProviderList newList = ProviderList.insertAt(list, provider, position - 1); if (list == newList) { return -1; } Providers.setProviderList(newList); - return newList.getIndex(providerName) + 1; + return newList.getIndex(provider.getName()) + 1; } /** @@ -527,7 +518,6 @@ public static int addProvider(Provider provider) { * @see #addProvider */ public static synchronized void removeProvider(String name) { - check("removeProvider." + name); ProviderList list = Providers.getFullProviderList(); ProviderList newList = ProviderList.remove(list, name); Providers.setProviderList(newList); @@ -822,7 +812,6 @@ static Object[] getImpl(String algorithm, String type, Provider provider, */ public static String getProperty(String key) { SecPropLoader.checkReservedKey(key); - check("getProperty." + key); String name = props.getProperty(key); if (name != null) name = name.trim(); // could be a class name with trailing ws @@ -845,7 +834,6 @@ public static String getProperty(String key) { */ public static void setProperty(String key, String datum) { SecPropLoader.checkReservedKey(key); - check("setProperty." + key); props.put(key, datum); SecurityPropertyModificationEvent spe = new SecurityPropertyModificationEvent(); @@ -859,32 +847,6 @@ public static void setProperty(String key, String datum) { } } - private static void check(String directive) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkSecurityAccess(directive); - } - } - - private static void checkInsertProvider(String name) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - try { - security.checkSecurityAccess("insertProvider"); - } catch (SecurityException se1) { - try { - security.checkSecurityAccess("insertProvider." + name); - } catch (SecurityException se2) { - // throw first exception, but add second to suppressed - se1.addSuppressed(se2); - throw se1; - } - } - } - } - private static class Criteria { private final String serviceName; private final String algName; diff --git a/src/java.base/share/classes/java/security/Signer.java b/src/java.base/share/classes/java/security/Signer.java index 4bdbff00b6951..44ad9d031f8af 100644 --- a/src/java.base/share/classes/java/security/Signer.java +++ b/src/java.base/share/classes/java/security/Signer.java @@ -99,7 +99,6 @@ public Signer(String name, IdentityScope scope) * not yet been set. */ public PrivateKey getPrivateKey() { - check("getSignerPrivateKey"); return privateKey; } @@ -115,24 +114,13 @@ public PrivateKey getPrivateKey() { */ public final void setKeyPair(KeyPair pair) throws InvalidParameterException, KeyException { - check("setSignerKeyPair"); - final PublicKey pub = pair.getPublic(); + PublicKey pub = pair.getPublic(); PrivateKey priv = pair.getPrivate(); if (pub == null || priv == null) { throw new InvalidParameterException(); } - try { - AccessController.doPrivileged( - new PrivilegedExceptionAction<>() { - public Void run() throws KeyManagementException { - setPublicKey(pub); - return null; - } - }); - } catch (PrivilegedActionException pae) { - throw (KeyManagementException) pae.getException(); - } + setPublicKey(pub); privateKey = priv; } @@ -156,12 +144,4 @@ String printKeys() { public String toString() { return "[Signer]" + super.toString(); } - - private static void check(String directive) { - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkSecurityAccess(directive); - } - } - } diff --git a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java index 62ce8020d802f..f4ba247caf113 100644 --- a/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java +++ b/src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java @@ -45,6 +45,7 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.Executor; import java.util.concurrent.RejectedExecutionException; +import java.util.concurrent.ScheduledExecutorService; import java.util.stream.Stream; import jdk.internal.loader.NativeLibraries; @@ -595,6 +596,11 @@ public interface JavaLangAccess { */ Executor virtualThreadDefaultScheduler(); + /** + * Returns a stream of the delayed task schedulers used for virtual threads. + */ + Stream virtualThreadDelayedTaskSchedulers(); + /** * Creates a new StackWalker */ diff --git a/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java b/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java index 97417efaa8ca3..a52881b047b18 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java +++ b/src/java.base/share/classes/jdk/internal/foreign/AbstractMemorySegmentImpl.java @@ -889,23 +889,27 @@ public void setAtIndex(AddressLayout layout, long index, MemorySegment value) { layout.varHandle().set((MemorySegment)this, index * layout.byteSize(), value); } + @ForceInline @Override public String getString(long offset) { return getString(offset, sun.nio.cs.UTF_8.INSTANCE); } + @ForceInline @Override public String getString(long offset, Charset charset) { Objects.requireNonNull(charset); return StringSupport.read(this, offset, charset); } + @ForceInline @Override public void setString(long offset, String str) { Objects.requireNonNull(str); setString(offset, str, sun.nio.cs.UTF_8.INSTANCE); } + @ForceInline @Override public void setString(long offset, String str, Charset charset) { Objects.requireNonNull(charset); diff --git a/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java b/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java index d928f8fc425fe..068db1bf593c6 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java +++ b/src/java.base/share/classes/jdk/internal/foreign/SegmentBulkOperations.java @@ -28,7 +28,6 @@ import jdk.internal.misc.ScopedMemoryAccess; import jdk.internal.util.Architecture; import jdk.internal.util.ArraysSupport; -import jdk.internal.util.ByteArrayLittleEndian; import jdk.internal.vm.annotation.ForceInline; import jdk.internal.vm.annotation.Stable; @@ -50,6 +49,7 @@ public final class SegmentBulkOperations { private SegmentBulkOperations() {} private static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess(); + private static final long LONG_MASK = ~7L; // The last three bits are zero // All the threshold values below MUST be a power of two and should preferably be // greater or equal to 2^3. @@ -75,21 +75,21 @@ public static MemorySegment fill(AbstractMemorySegmentImpl dst, byte value) { int offset = 0; // 0...0X...X000 final int limit = (int) (dst.length & (NATIVE_THRESHOLD_FILL - 8)); - for (; offset < limit; offset += 8) { + for (; offset < limit; offset += Long.BYTES) { SCOPED_MEMORY_ACCESS.putLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + offset, longValue, !Architecture.isLittleEndian()); } int remaining = (int) dst.length - limit; // 0...0X00 - if (remaining >= 4) { + if (remaining >= Integer.BYTES) { SCOPED_MEMORY_ACCESS.putIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + offset, (int) longValue, !Architecture.isLittleEndian()); - offset += 4; - remaining -= 4; + offset += Integer.BYTES; + remaining -= Integer.BYTES; } // 0...00X0 - if (remaining >= 2) { + if (remaining >= Short.BYTES) { SCOPED_MEMORY_ACCESS.putShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + offset, (short) longValue, !Architecture.isLittleEndian()); - offset += 2; - remaining -= 2; + offset += Short.BYTES; + remaining -= Short.BYTES; } // 0...000X if (remaining == 1) { @@ -123,26 +123,26 @@ public static void copy(AbstractMemorySegmentImpl src, long srcOffset, // is an overlap, we could tolerate one particular direction of overlap (but not the other). // 0...0X...X000 - final int limit = (int) (size & (NATIVE_THRESHOLD_COPY - 8)); + final int limit = (int) (size & (NATIVE_THRESHOLD_COPY - Long.BYTES)); int offset = 0; - for (; offset < limit; offset += 8) { + for (; offset < limit; offset += Long.BYTES) { final long v = SCOPED_MEMORY_ACCESS.getLongUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcOffset + offset, !Architecture.isLittleEndian()); SCOPED_MEMORY_ACCESS.putLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset + offset, v, !Architecture.isLittleEndian()); } int remaining = (int) size - offset; // 0...0X00 - if (remaining >= 4) { + if (remaining >= Integer.BYTES) { final int v = SCOPED_MEMORY_ACCESS.getIntUnaligned(src.sessionImpl(), src.unsafeGetBase(),src.unsafeGetOffset() + srcOffset + offset, !Architecture.isLittleEndian()); SCOPED_MEMORY_ACCESS.putIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset + offset, v, !Architecture.isLittleEndian()); - offset += 4; - remaining -= 4; + offset += Integer.BYTES; + remaining -= Integer.BYTES; } // 0...00X0 - if (remaining >= 2) { + if (remaining >= Short.BYTES) { final short v = SCOPED_MEMORY_ACCESS.getShortUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcOffset + offset, !Architecture.isLittleEndian()); SCOPED_MEMORY_ACCESS.putShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstOffset + offset, v, !Architecture.isLittleEndian()); - offset += 2; - remaining -=2; + offset += Short.BYTES; + remaining -= Short.BYTES; } // 0...000X if (remaining == 1) { @@ -202,9 +202,9 @@ public static int contentHash(AbstractMemorySegmentImpl segment, long fromOffset return 1; } int result = 1; - final long longBytes = length & ((1L << 62) - 8); + final long longBytes = length & LONG_MASK; final long limit = fromOffset + longBytes; - for (; fromOffset < limit; fromOffset += 8) { + for (; fromOffset < limit; fromOffset += Long.BYTES) { long val = SCOPED_MEMORY_ACCESS.getLongUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + fromOffset, !Architecture.isLittleEndian()); result = result * POWERS_OF_31[7] + ((byte) (val >>> 56)) * POWERS_OF_31[6] @@ -218,24 +218,24 @@ public static int contentHash(AbstractMemorySegmentImpl segment, long fromOffset } int remaining = (int) (length - longBytes); // 0...0X00 - if (remaining >= 4) { + if (remaining >= Integer.BYTES) { int val = SCOPED_MEMORY_ACCESS.getIntUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + fromOffset, !Architecture.isLittleEndian()); result = result * POWERS_OF_31[3] + ((byte) (val >>> 24)) * POWERS_OF_31[2] + ((byte) (val >>> 16)) * POWERS_OF_31[1] + ((byte) (val >>> 8)) * POWERS_OF_31[0] + ((byte) val); - fromOffset += 4; - remaining -= 4; + fromOffset += Integer.BYTES; + remaining -= Integer.BYTES; } // 0...00X0 - if (remaining >= 2) { + if (remaining >= Short.BYTES) { short val = SCOPED_MEMORY_ACCESS.getShortUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + fromOffset, !Architecture.isLittleEndian()); result = result * POWERS_OF_31[1] + ((byte) (val >>> 8)) * POWERS_OF_31[0] + ((byte) val); - fromOffset += 2; - remaining -= 2; + fromOffset += Short.BYTES; + remaining -= Short.BYTES; } // 0...000X if (remaining == 1) { @@ -288,7 +288,7 @@ private static long mismatch(AbstractMemorySegmentImpl src, long srcFromOffset, long start, int length, boolean srcAndDstBytesDiffer) { int offset = 0; final int limit = length & (NATIVE_THRESHOLD_MISMATCH - 8); - for (; offset < limit; offset += 8) { + for (; offset < limit; offset += Long.BYTES) { final long s = SCOPED_MEMORY_ACCESS.getLongUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false); final long d = SCOPED_MEMORY_ACCESS.getLongUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false); if (s != d) { @@ -298,24 +298,24 @@ private static long mismatch(AbstractMemorySegmentImpl src, long srcFromOffset, int remaining = length - offset; // 0...0X00 - if (remaining >= 4) { + if (remaining >= Integer.BYTES) { final int s = SCOPED_MEMORY_ACCESS.getIntUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false); final int d = SCOPED_MEMORY_ACCESS.getIntUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false); if (s != d) { return start + offset + mismatch(s, d); } - offset += 4; - remaining -= 4; + offset += Integer.BYTES; + remaining -= Integer.BYTES; } // 0...00X0 - if (remaining >= 2) { + if (remaining >= Short.BYTES) { final short s = SCOPED_MEMORY_ACCESS.getShortUnaligned(src.sessionImpl(), src.unsafeGetBase(), src.unsafeGetOffset() + srcFromOffset + offset, false); final short d = SCOPED_MEMORY_ACCESS.getShortUnaligned(dst.sessionImpl(), dst.unsafeGetBase(), dst.unsafeGetOffset() + dstFromOffset + offset, false); if (s != d) { return start + offset + mismatch(s, d); } - offset += 2; - remaining -= 2; + offset += Short.BYTES; + remaining -= Short.BYTES; } // 0...000X if (remaining == 1) { diff --git a/src/java.base/share/classes/jdk/internal/foreign/StringSupport.java b/src/java.base/share/classes/jdk/internal/foreign/StringSupport.java index 78550c56136d5..8f182f3b33845 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/StringSupport.java +++ b/src/java.base/share/classes/jdk/internal/foreign/StringSupport.java @@ -27,8 +27,10 @@ import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; -import jdk.internal.foreign.abi.SharedUtils; +import jdk.internal.misc.ScopedMemoryAccess; +import jdk.internal.util.Architecture; import jdk.internal.util.ArraysSupport; +import jdk.internal.vm.annotation.ForceInline; import java.lang.foreign.MemorySegment; import java.nio.charset.Charset; @@ -40,11 +42,14 @@ */ public final class StringSupport { - static final JavaLangAccess JAVA_LANG_ACCESS = SharedSecrets.getJavaLangAccess(); + private static final JavaLangAccess JAVA_LANG_ACCESS = SharedSecrets.getJavaLangAccess(); + private static final ScopedMemoryAccess SCOPED_MEMORY_ACCESS = ScopedMemoryAccess.getScopedMemoryAccess(); + private static final long LONG_MASK = ~7L; // The last three bits are zero private StringSupport() {} - public static String read(MemorySegment segment, long offset, Charset charset) { + @ForceInline + public static String read(AbstractMemorySegmentImpl segment, long offset, Charset charset) { return switch (CharsetKind.of(charset)) { case SINGLE_BYTE -> readByte(segment, offset, charset); case DOUBLE_BYTE -> readShort(segment, offset, charset); @@ -52,7 +57,8 @@ public static String read(MemorySegment segment, long offset, Charset charset) { }; } - public static void write(MemorySegment segment, long offset, Charset charset, String string) { + @ForceInline + public static void write(AbstractMemorySegmentImpl segment, long offset, Charset charset, String string) { switch (CharsetKind.of(charset)) { case SINGLE_BYTE -> writeByte(segment, offset, charset, string); case DOUBLE_BYTE -> writeShort(segment, offset, charset, string); @@ -60,111 +66,183 @@ public static void write(MemorySegment segment, long offset, Charset charset, St } } - private static String readByte(MemorySegment segment, long offset, Charset charset) { - long len = chunkedStrlenByte(segment, offset); - byte[] bytes = new byte[(int)len]; - MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, (int)len); + @ForceInline + private static String readByte(AbstractMemorySegmentImpl segment, long offset, Charset charset) { + final int len = strlenByte(segment, offset, segment.byteSize()); + final byte[] bytes = new byte[len]; + MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, len); return new String(bytes, charset); } - private static void writeByte(MemorySegment segment, long offset, Charset charset, String string) { + @ForceInline + private static void writeByte(AbstractMemorySegmentImpl segment, long offset, Charset charset, String string) { int bytes = copyBytes(string, segment, charset, offset); segment.set(JAVA_BYTE, offset + bytes, (byte)0); } - private static String readShort(MemorySegment segment, long offset, Charset charset) { - long len = chunkedStrlenShort(segment, offset); - byte[] bytes = new byte[(int)len]; - MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, (int)len); + @ForceInline + private static String readShort(AbstractMemorySegmentImpl segment, long offset, Charset charset) { + int len = strlenShort(segment, offset, segment.byteSize()); + byte[] bytes = new byte[len]; + MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, len); return new String(bytes, charset); } - private static void writeShort(MemorySegment segment, long offset, Charset charset, String string) { + @ForceInline + private static void writeShort(AbstractMemorySegmentImpl segment, long offset, Charset charset, String string) { int bytes = copyBytes(string, segment, charset, offset); segment.set(JAVA_SHORT_UNALIGNED, offset + bytes, (short)0); } - private static String readInt(MemorySegment segment, long offset, Charset charset) { - long len = strlenInt(segment, offset); - byte[] bytes = new byte[(int)len]; - MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, (int)len); + @ForceInline + private static String readInt(AbstractMemorySegmentImpl segment, long offset, Charset charset) { + int len = strlenInt(segment, offset, segment.byteSize()); + byte[] bytes = new byte[len]; + MemorySegment.copy(segment, JAVA_BYTE, offset, bytes, 0, len); return new String(bytes, charset); } - private static void writeInt(MemorySegment segment, long offset, Charset charset, String string) { + @ForceInline + private static void writeInt(AbstractMemorySegmentImpl segment, long offset, Charset charset, String string) { int bytes = copyBytes(string, segment, charset, offset); segment.set(JAVA_INT_UNALIGNED, offset + bytes, 0); } /** - * {@return the shortest distance beginning at the provided {@code start} - * to the encountering of a zero byte in the provided {@code segment}} + * {@return the index of the first zero byte beginning at the provided + * {@code fromOffset} to the encountering of a zero byte in the provided + * {@code segment} checking bytes before the {@code toOffset}} *

      - * The method divides the region of interest into three distinct regions: - *

        - *
      • head (access made on a byte-by-byte basis) (if any)
      • - *
      • body (access made with eight bytes at a time at physically 64-bit-aligned memory) (if any)
      • - *
      • tail (access made on a byte-by-byte basis) (if any)
      • - *
      - *

      - * The body is using a heuristic method to determine if a long word - * contains a zero byte. The method might have false positives but - * never false negatives. + * The method is using a heuristic method to determine if a long word contains a + * zero byte. The method might have false positives but never false negatives. *

      * This method is inspired by the `glibc/string/strlen.c` implementation * - * @param segment to examine - * @param start from where examination shall begin + * @param segment to examine + * @param fromOffset from where examination shall begin (inclusive) + * @param toOffset to where examination shall end (exclusive) * @throws IllegalArgumentException if the examined region contains no zero bytes * within a length that can be accepted by a String */ - public static int chunkedStrlenByte(MemorySegment segment, long start) { - - // Handle the first unaligned "head" bytes separately - int headCount = (int)SharedUtils.remainsToAlignment(segment.address() + start, Long.BYTES); - - int offset = 0; - for (; offset < headCount; offset++) { - byte curr = segment.get(JAVA_BYTE, start + offset); - if (curr == 0) { - return offset; + @ForceInline + public static int strlenByte(final AbstractMemorySegmentImpl segment, + final long fromOffset, + final long toOffset) { + final long length = toOffset - fromOffset; + segment.checkBounds(fromOffset, length); + if (length == 0) { + // The state has to be checked explicitly for zero-length segments + segment.scope.checkValidState(); + throw nullNotFound(segment, fromOffset, toOffset); + } + final long longBytes = length & LONG_MASK; + final long longLimit = fromOffset + longBytes; + long offset = fromOffset; + for (; offset < longLimit; offset += Long.BYTES) { + long val = SCOPED_MEMORY_ACCESS.getLongUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset, !Architecture.isLittleEndian()); + if (mightContainZeroByte(val)) { + for (int j = 0; j < Long.BYTES; j++) { + if (SCOPED_MEMORY_ACCESS.getByte(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset + j) == 0) { + return requireWithinStringSize(offset + j - fromOffset, segment, fromOffset, toOffset); + } + } + } + } + // Handle the tail + for (; offset < toOffset; offset++) { + byte val = SCOPED_MEMORY_ACCESS.getByte(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset); + if (val == 0) { + return requireWithinStringSize(offset - fromOffset, segment, fromOffset, toOffset); } } + throw nullNotFound(segment, fromOffset, toOffset); + } - // We are now on a long-aligned boundary so this is the "body" - int bodyCount = bodyCount(segment.byteSize() - start - headCount); - - for (; offset < bodyCount; offset += Long.BYTES) { - // We know we are `long` aligned so, we can save on alignment checking here - long curr = segment.get(JAVA_LONG_UNALIGNED, start + offset); - // Is this a candidate? - if (mightContainZeroByte(curr)) { - for (int j = 0; j < 8; j++) { - if (segment.get(JAVA_BYTE, start + offset + j) == 0) { - return offset + j; + @ForceInline + public static int strlenShort(final AbstractMemorySegmentImpl segment, + final long fromOffset, + final long toOffset) { + final long length = toOffset - fromOffset; + segment.checkBounds(fromOffset, length); + if (length == 0) { + segment.scope.checkValidState(); + throw nullNotFound(segment, fromOffset, toOffset); + } + final long longBytes = length & LONG_MASK; + final long longLimit = fromOffset + longBytes; + long offset = fromOffset; + for (; offset < longLimit; offset += Long.BYTES) { + long val = SCOPED_MEMORY_ACCESS.getLongUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset, !Architecture.isLittleEndian()); + if (mightContainZeroShort(val)) { + for (int j = 0; j < Long.BYTES; j += Short.BYTES) { + if (SCOPED_MEMORY_ACCESS.getShortUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset + j, !Architecture.isLittleEndian()) == 0) { + return requireWithinStringSize(offset + j - fromOffset, segment, fromOffset, toOffset); } } } } + // Handle the tail + // Prevent over scanning as we step by 2 + final long endScan = toOffset & ~1; // The last bit is zero + for (; offset < endScan; offset += Short.BYTES) { + short val = SCOPED_MEMORY_ACCESS.getShortUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset, !Architecture.isLittleEndian()); + if (val == 0) { + return requireWithinStringSize(offset - fromOffset, segment, fromOffset, toOffset); + } + } + throw nullNotFound(segment, fromOffset, toOffset); + } - // Handle the "tail" - return requireWithinArraySize((long) offset + strlenByte(segment, start + offset)); + @ForceInline + public static int strlenInt(final AbstractMemorySegmentImpl segment, + final long fromOffset, + final long toOffset) { + final long length = toOffset - fromOffset; + segment.checkBounds(fromOffset, length); + if (length == 0) { + segment.scope.checkValidState(); + throw nullNotFound(segment, fromOffset, toOffset); + } + final long longBytes = length & LONG_MASK; + final long longLimit = fromOffset + longBytes; + long offset = fromOffset; + for (; offset < longLimit; offset += Long.BYTES) { + long val = SCOPED_MEMORY_ACCESS.getLongUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset, !Architecture.isLittleEndian()); + if (mightContainZeroInt(val)) { + for (int j = 0; j < Long.BYTES; j += Integer.BYTES) { + if (SCOPED_MEMORY_ACCESS.getIntUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset + j, !Architecture.isLittleEndian()) == 0) { + return requireWithinStringSize(offset + j - fromOffset, segment, fromOffset, toOffset); + } + } + } + } + // Handle the tail + // Prevent over scanning as we step by 4 + final long endScan = toOffset & ~3; // The last two bit are zero + for (; offset < endScan; offset += Integer.BYTES) { + int val = SCOPED_MEMORY_ACCESS.getIntUnaligned(segment.sessionImpl(), segment.unsafeGetBase(), segment.unsafeGetOffset() + offset, !Architecture.isLittleEndian()); + if (val == 0) { + return requireWithinStringSize(offset - fromOffset, segment, fromOffset, toOffset); + } + } + throw nullNotFound(segment, fromOffset, toOffset); } - /* Bits 63 and N * 8 (N = 1..7) of this number are zero. Call these bits - the "holes". Note that there is a hole just to the left of - each byte, with an extra at the end: + /* + Bits 63 and N * 8 (N = 1..7) of this number are zero. Call these bits + the "holes". Note that there is a hole just to the left of + each byte, with an extra at the end: - bits: 01111110 11111110 11111110 11111110 11111110 11111110 11111110 11111111 - bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE FFFFFFFF GGGGGGGG HHHHHHHH + bits: 01111110 11111110 11111110 11111110 11111110 11111110 11111110 11111111 + bytes: AAAAAAAA BBBBBBBB CCCCCCCC DDDDDDDD EEEEEEEE FFFFFFFF GGGGGGGG HHHHHHHH - The 1-bits make sure that carries propagate to the next 0-bit. - The 0-bits provide holes for carries to fall into. + The 1-bits make sure that carries propagate to the next 0-bit. + The 0-bits provide holes for carries to fall into. */ private static final long HIMAGIC_FOR_BYTES = 0x8080_8080_8080_8080L; private static final long LOMAGIC_FOR_BYTES = 0x0101_0101_0101_0101L; - static boolean mightContainZeroByte(long l) { + private static boolean mightContainZeroByte(long l) { return ((l - LOMAGIC_FOR_BYTES) & (~l) & HIMAGIC_FOR_BYTES) != 0; } @@ -175,99 +253,40 @@ static boolean mightContainZeroShort(long l) { return ((l - LOMAGIC_FOR_SHORTS) & (~l) & HIMAGIC_FOR_SHORTS) != 0; } - static int requireWithinArraySize(long size) { - if (size > ArraysSupport.SOFT_MAX_ARRAY_LENGTH) { - throw newIaeStringTooLarge(); - } - return (int) size; - } - - static int bodyCount(long remaining) { - return (int) Math.min( - // Make sure we do not wrap around - Integer.MAX_VALUE - Long.BYTES, - // Remaining bytes to consider - remaining) - & -Long.BYTES; // Mask 0xFFFFFFF8 - } + private static final long HIMAGIC_FOR_INTS = 0x8000_0000_8000_0000L; + private static final long LOMAGIC_FOR_INTS = 0x0000_0001_0000_0001L; - private static int strlenByte(MemorySegment segment, long start) { - for (int offset = 0; offset < ArraysSupport.SOFT_MAX_ARRAY_LENGTH; offset += 1) { - byte curr = segment.get(JAVA_BYTE, start + offset); - if (curr == 0) { - return offset; - } - } - throw newIaeStringTooLarge(); + static boolean mightContainZeroInt(long l) { + return ((l - LOMAGIC_FOR_INTS) & (~l) & HIMAGIC_FOR_INTS) != 0; } - /** - * {@return the shortest distance beginning at the provided {@code start} - * to the encountering of a zero short in the provided {@code segment}} - *

      - * Note: The inspected region must be short aligned. - * - * @see #chunkedStrlenByte(MemorySegment, long) for more information - * - * @param segment to examine - * @param start from where examination shall begin - * @throws IllegalArgumentException if the examined region contains no zero shorts - * within a length that can be accepted by a String - */ - public static int chunkedStrlenShort(MemorySegment segment, long start) { - - // Handle the first unaligned "head" bytes separately - int headCount = (int)SharedUtils.remainsToAlignment(segment.address() + start, Long.BYTES); - int offset = 0; - for (; offset < headCount; offset += Short.BYTES) { - short curr = segment.get(JAVA_SHORT_UNALIGNED, start + offset); - if (curr == 0) { - return offset; - } - } - - // We are now on a long-aligned boundary so this is the "body" - int bodyCount = bodyCount(segment.byteSize() - start - headCount); - - for (; offset < bodyCount; offset += Long.BYTES) { - // We know we are `long` aligned so, we can save on alignment checking here - long curr = segment.get(JAVA_LONG_UNALIGNED, start + offset); - // Is this a candidate? - if (mightContainZeroShort(curr)) { - for (int j = 0; j < Long.BYTES; j += Short.BYTES) { - if (segment.get(JAVA_SHORT_UNALIGNED, start + offset + j) == 0) { - return offset + j; - } - } - } + private static int requireWithinStringSize(long size, + AbstractMemorySegmentImpl segment, + long fromOffset, + long toOffset) { + if (size > ArraysSupport.SOFT_MAX_ARRAY_LENGTH) { + throw stringTooLarge(segment, fromOffset, toOffset); } + return (int) size; + } - // Handle the "tail" - return requireWithinArraySize((long) offset + strlenShort(segment, start + offset)); + private static IllegalArgumentException stringTooLarge(AbstractMemorySegmentImpl segment, + long fromOffset, + long toOffset) { + return new IllegalArgumentException("String too large: " + exceptionInfo(segment, fromOffset, toOffset)); } - private static int strlenShort(MemorySegment segment, long start) { - for (int offset = 0; offset < ArraysSupport.SOFT_MAX_ARRAY_LENGTH; offset += Short.BYTES) { - short curr = segment.get(JAVA_SHORT_UNALIGNED, start + offset); - if (curr == (short)0) { - return offset; - } - } - throw newIaeStringTooLarge(); + private static IndexOutOfBoundsException nullNotFound(AbstractMemorySegmentImpl segment, + long fromOffset, + long toOffset) { + return new IndexOutOfBoundsException("No null terminator found: " + exceptionInfo(segment, fromOffset, toOffset)); } - // The gain of using `long` wide operations for `int` is lower than for the two other `byte` and `short` variants - // so, there is only one method for ints. - public static int strlenInt(MemorySegment segment, long start) { - for (int offset = 0; offset < ArraysSupport.SOFT_MAX_ARRAY_LENGTH; offset += Integer.BYTES) { - // We are guaranteed to be aligned here so, we can use unaligned access. - int curr = segment.get(JAVA_INT_UNALIGNED, start + offset); - if (curr == 0) { - return offset; - } - } - throw newIaeStringTooLarge(); + private static String exceptionInfo(AbstractMemorySegmentImpl segment, + long fromOffset, + long toOffset) { + return segment + " using region [" + fromOffset + ", " + toOffset + ")"; } public enum CharsetKind { @@ -323,9 +342,4 @@ public static int copyBytes(String string, MemorySegment segment, Charset charse public static void copyToSegmentRaw(String string, MemorySegment segment, long offset) { JAVA_LANG_ACCESS.copyToSegmentRaw(string, segment, offset); } - - private static IllegalArgumentException newIaeStringTooLarge() { - return new IllegalArgumentException("String too large"); - } - } diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java index e301f6921678e..5aad4ccc890dc 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ -195,6 +195,10 @@ public boolean needsTransition() { return !linkerOptions.isCritical(); } + public boolean usingAddressPairs() { + return linkerOptions.allowsHeapAccess(); + } + public int numLeadingParams() { return 2 + (linkerOptions.hasCapturedCallState() ? 1 : 0); // 2 for addr, allocator } diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java index f24de62c807a4..a03c20d317349 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/CallingSequenceBuilder.java @@ -108,9 +108,18 @@ public CallingSequence build() { MethodType calleeMethodType; if (!forUpcall) { if (linkerOptions.hasCapturedCallState()) { - addArgumentBinding(0, MemorySegment.class, ValueLayout.ADDRESS, List.of( - Binding.unboxAddress(), - Binding.vmStore(abi.capturedStateStorage(), long.class))); + if (linkerOptions.allowsHeapAccess()) { + addArgumentBinding(0, MemorySegment.class, ValueLayout.ADDRESS, List.of( + Binding.dup(), + Binding.segmentBase(), + Binding.vmStore(abi.capturedStateStorage(), Object.class), + Binding.segmentOffsetAllowHeap(), + Binding.vmStore(null, long.class))); + } else { + addArgumentBinding(0, MemorySegment.class, ValueLayout.ADDRESS, List.of( + Binding.unboxAddress(), + Binding.vmStore(abi.capturedStateStorage(), long.class))); + } } addArgumentBinding(0, MemorySegment.class, ValueLayout.ADDRESS, List.of( Binding.unboxAddress(), diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java index 627de9f076562..2df30edb32626 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/DowncallLinker.java @@ -84,7 +84,8 @@ public MethodHandle getBoundMethodHandle() { leafType, callingSequence.needsReturnBuffer(), callingSequence.capturedStateMask(), - callingSequence.needsTransition() + callingSequence.needsTransition(), + callingSequence.usingAddressPairs() ); MethodHandle handle = JLIA.nativeMethodHandle(nep); diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java b/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java index fcc98ecccc071..9a19b5a8511aa 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/LinkerOptions.java @@ -63,11 +63,7 @@ private static LinkerOptions forShared(BiConsumer 1 != needsReturnBuffer) { throw new AssertionError("Multiple register return, but needsReturnBuffer was false"); } - checkType(methodType, needsReturnBuffer, capturedStateMask); + checkMethodType(methodType, needsReturnBuffer, capturedStateMask, usingAddressPairs); CacheKey key = new CacheKey(methodType, abi, Arrays.asList(argMoves), Arrays.asList(returnMoves), needsReturnBuffer, capturedStateMask, needsTransition); @@ -80,14 +81,26 @@ public static NativeEntryPoint make(ABIDescriptor abi, }); } - private static void checkType(MethodType methodType, boolean needsReturnBuffer, int savedValueMask) { - if (methodType.parameterType(0) != long.class) { - throw new AssertionError("Address expected as first param: " + methodType); + private static void checkMethodType(MethodType methodType, boolean needsReturnBuffer, int savedValueMask, + boolean usingAddressPairs) { + int checkIdx = 0; + checkParamType(methodType, checkIdx++, long.class, "Function address"); + if (needsReturnBuffer) { + checkParamType(methodType, checkIdx++, long.class, "Return buffer address"); } - int checkIdx = 1; - if ((needsReturnBuffer && methodType.parameterType(checkIdx++) != long.class) - || (savedValueMask != 0 && methodType.parameterType(checkIdx) != long.class)) { - throw new AssertionError("return buffer and/or preserved value address expected: " + methodType); + if (savedValueMask != 0) { // capturing call state + if (usingAddressPairs) { + checkParamType(methodType, checkIdx++, Object.class, "Capture state heap base"); + checkParamType(methodType, checkIdx, long.class, "Capture state offset"); + } else { + checkParamType(methodType, checkIdx, long.class, "Capture state address"); + } + } + } + + private static void checkParamType(MethodType methodType, int checkIdx, Class expectedType, String name) { + if (methodType.parameterType(checkIdx) != expectedType) { + throw new AssertionError(name + " expected at index " + checkIdx + ": " + methodType); } } diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java index ad5e4b97175fb..54906d9fef2ed 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/FallbackLinker.java @@ -163,8 +163,14 @@ private static Object doDowncall(SegmentAllocator returnAllocator, Object[] args acquiredSessions.add(targetImpl); MemorySegment capturedState = null; + Object captureStateHeapBase = null; if (invData.capturedStateMask() != 0) { capturedState = SharedUtils.checkCaptureSegment((MemorySegment) args[argStart++]); + if (!invData.allowsHeapAccess) { + SharedUtils.checkNative(capturedState); + } else { + captureStateHeapBase = capturedState.heapBase().orElse(null); + } MemorySessionImpl capturedStateImpl = ((AbstractMemorySegmentImpl) capturedState).sessionImpl(); capturedStateImpl.acquire0(); acquiredSessions.add(capturedStateImpl); @@ -199,7 +205,8 @@ private static Object doDowncall(SegmentAllocator returnAllocator, Object[] args retSeg = (invData.returnLayout() instanceof GroupLayout ? returnAllocator : arena).allocate(invData.returnLayout); } - LibFallback.doDowncall(invData.cif, target, retSeg, argPtrs, capturedState, invData.capturedStateMask(), + LibFallback.doDowncall(invData.cif, target, retSeg, argPtrs, + captureStateHeapBase, capturedState, invData.capturedStateMask(), heapBases, args.length); Reference.reachabilityFence(invData.cif()); diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java index b68b1ed4bad6d..6fe8dd5f91ccf 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/fallback/LibFallback.java @@ -90,10 +90,11 @@ private static boolean tryLoadLibrary() { * @see jdk.internal.foreign.abi.CapturableState */ static void doDowncall(MemorySegment cif, MemorySegment target, MemorySegment retPtr, MemorySegment argPtrs, - MemorySegment capturedState, int capturedStateMask, + Object captureStateHeapBase, MemorySegment capturedState, int capturedStateMask, Object[] heapBases, int numArgs) { doDowncall(cif.address(), target.address(), retPtr == null ? 0 : retPtr.address(), argPtrs.address(), + captureStateHeapBase, capturedState == null ? 0 : capturedState.address(), capturedStateMask, heapBases, numArgs); } @@ -212,7 +213,7 @@ private static void checkStatus(int code) { private static native int createClosure(long cif, Object userData, long[] ptrs); private static native void freeClosure(long closureAddress, long globalTarget); private static native void doDowncall(long cif, long fn, long rvalue, long avalues, - long capturedState, int capturedStateMask, + Object captureStateHeapBase, long capturedState, int capturedStateMask, Object[] heapBases, int numArgs); private static native int ffi_prep_cif(long cif, int abi, int nargs, long rtype, long atypes); diff --git a/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java b/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java index 54f0c7c563d47..e6c5aa5db2edd 100644 --- a/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java +++ b/src/java.base/share/classes/jdk/internal/reflect/DirectMethodHandleAccessor.java @@ -47,7 +47,7 @@ class DirectMethodHandleAccessor extends MethodAccessorImpl { * Creates a MethodAccessorImpl for a non-native method. */ static MethodAccessorImpl methodAccessor(Method method, MethodHandle target) { - assert !Modifier.isNative(method.getModifiers()); + assert !MethodHandleAccessorFactory.isSignaturePolymorphicMethod(method); return new DirectMethodHandleAccessor(method, target, false); } diff --git a/src/java.base/share/classes/jdk/internal/reflect/MethodHandleAccessorFactory.java b/src/java.base/share/classes/jdk/internal/reflect/MethodHandleAccessorFactory.java index 3a367272315e1..93a208662d572 100644 --- a/src/java.base/share/classes/jdk/internal/reflect/MethodHandleAccessorFactory.java +++ b/src/java.base/share/classes/jdk/internal/reflect/MethodHandleAccessorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -28,6 +28,7 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; +import java.lang.invoke.VarHandle; import java.lang.reflect.Constructor; import java.lang.reflect.Executable; import java.lang.reflect.Field; @@ -209,7 +210,7 @@ static FieldAccessorImpl newFieldAccessor(Field field, boolean isReadOnly) { } private static MethodHandle getDirectMethod(Method method, boolean callerSensitive) throws IllegalAccessException { - var mtype = methodType(method.getReturnType(), method.getParameterTypes()); + var mtype = methodType(method.getReturnType(), reflectionFactory.getExecutableSharedParameterTypes(method)); var isStatic = Modifier.isStatic(method.getModifiers()); var dmh = isStatic ? JLIA.findStatic(method.getDeclaringClass(), method.getName(), mtype) : JLIA.findVirtual(method.getDeclaringClass(), method.getName(), mtype); @@ -231,7 +232,7 @@ private static MethodHandle getDirectMethod(Method method, boolean callerSensiti private static MethodHandle findCallerSensitiveAdapter(Method method) throws IllegalAccessException { String name = method.getName(); // append a Class parameter - MethodType mtype = methodType(method.getReturnType(), method.getParameterTypes()) + MethodType mtype = methodType(method.getReturnType(), reflectionFactory.getExecutableSharedParameterTypes(method)) .appendParameterTypes(Class.class); boolean isStatic = Modifier.isStatic(method.getModifiers()); @@ -347,36 +348,39 @@ static void ensureClassInitialized(Class defc) { * Native accessor, i.e. VM reflection implementation, is used if one of * the following conditions is met: * 1. during VM early startup before method handle support is fully initialized - * 2. a Java native method - * 3. -Djdk.reflect.useNativeAccessorOnly=true is set + * 2. -Djdk.reflect.useNativeAccessorOnly=true is set + * 3. a signature polymorphic method * 4. the member takes a variable number of arguments and the last parameter * is not an array (see details below) * 5. the member's method type has an arity >= 255 * + * Conditions 3-5 are due to the restrictions of method handles. * Otherwise, direct invocation of method handles is used. */ private static boolean useNativeAccessor(Executable member) { if (!VM.isJavaLangInvokeInited()) return true; - if (Modifier.isNative(member.getModifiers())) + if (ReflectionFactory.useNativeAccessorOnly()) // for testing only return true; - if (ReflectionFactory.useNativeAccessorOnly()) // for testing only + // java.lang.invoke cannot find the underlying native stubs of signature + // polymorphic methods that core reflection must invoke. + // Fall back to use the native implementation instead. + if (member instanceof Method method && isSignaturePolymorphicMethod(method)) return true; - // MethodHandle::withVarargs on a member with varargs modifier bit set - // verifies that the last parameter of the member must be an array type. - // The JVMS does not require the last parameter descriptor of the method descriptor - // is an array type if the ACC_VARARGS flag is set in the access_flags item. - // Hence the reflection implementation does not check the last parameter type - // if ACC_VARARGS flag is set. Workaround this by invoking through - // the native accessor. + // For members with ACC_VARARGS bit set, MethodHandles produced by lookup + // always have variable arity set and hence the last parameter of the member + // must be an array type. Such restriction does not exist in core reflection + // and the JVM, which always use fixed-arity invocations. Fall back to use + // the native implementation instead. int paramCount = member.getParameterCount(); if (member.isVarArgs() && - (paramCount == 0 || !(member.getParameterTypes()[paramCount-1].isArray()))) { + (paramCount == 0 || !(reflectionFactory.getExecutableSharedParameterTypes(member)[paramCount-1].isArray()))) { return true; } + // A method handle cannot be created if its type has an arity >= 255 // as the method handle's invoke method consumes an extra argument // of the method handle itself. Fall back to use the native implementation. @@ -396,7 +400,7 @@ private static boolean useNativeAccessor(Executable member) { */ private static int slotCount(Executable member) { int slots = 0; - Class[] ptypes = member.getParameterTypes(); + Class[] ptypes = reflectionFactory.getExecutableSharedParameterTypes(member); for (Class ptype : ptypes) { if (ptype == double.class || ptype == long.class) { slots++; @@ -406,6 +410,31 @@ private static int slotCount(Executable member) { (Modifier.isStatic(member.getModifiers()) ? 0 : 1); } + /** + * Signature-polymorphic methods. Lookup has special rules for these methods, + * but core reflection must observe them as they are declared, and reflective + * invocation must invoke the native method stubs that throw UOE. + * + * @param method the method to check + * @return {@code true} if this method is signature polymorphic + * @jls 15.12.3 Compile-Time Step 3: Is the Chosen Method Appropriate? + * @jvms 2.9.3 Signature Polymorphic Methods + */ + public static boolean isSignaturePolymorphicMethod(Method method) { + // ACC_NATIVE and ACC_VARARGS + if (!method.isVarArgs() || !Modifier.isNative(method.getModifiers())) { + return false; + } + // Declared in MethodHandle or VarHandle + var declaringClass = method.getDeclaringClass(); + if (declaringClass != MethodHandle.class && declaringClass != VarHandle.class) { + return false; + } + // Single parameter of declared type Object[] + Class[] parameters = reflectionFactory.getExecutableSharedParameterTypes(method); + return parameters.length == 1 && parameters[0] == Object[].class; + } + /* * Delay initializing these static fields until java.lang.invoke is fully initialized. */ @@ -414,4 +443,5 @@ static class LazyStaticHolder { } private static final Unsafe UNSAFE = Unsafe.getUnsafe(); + private static final ReflectionFactory reflectionFactory = ReflectionFactory.getReflectionFactory(); } diff --git a/src/java.base/share/classes/jdk/internal/vm/JcmdVThreadCommands.java b/src/java.base/share/classes/jdk/internal/vm/JcmdVThreadCommands.java new file mode 100644 index 0000000000000..66ac6c2aca9fc --- /dev/null +++ b/src/java.base/share/classes/jdk/internal/vm/JcmdVThreadCommands.java @@ -0,0 +1,112 @@ +/* + * Copyright (c) 2023, 2024, 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.vm; + +import java.nio.charset.StandardCharsets; +import java.util.List; +import java.util.stream.IntStream; +import jdk.internal.access.JavaLangAccess; +import jdk.internal.access.SharedSecrets; +import sun.nio.ch.Poller; + +/** + * The implementation for the jcmd Thread.vthread_* diagnostic commands. These methods are + * called from the "Attach Listener" thread. + */ +public class JcmdVThreadCommands { + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); + + private JcmdVThreadCommands() { } + + /** + * Invoked by the VM to print the virtual scheduler to a byte[]. + */ + private static byte[] printScheduler() { + StringBuilder sb = new StringBuilder(); + + // virtual thread scheduler + sb.append(JLA.virtualThreadDefaultScheduler()) + .append(System.lineSeparator()); + + // break + sb.append(System.lineSeparator()); + + // delayed task schedulers + sb.append("Delayed task schedulers:").append(System.lineSeparator()); + var delayedTaskSchedulers = JLA.virtualThreadDelayedTaskSchedulers().toList(); + IntStream.range(0, delayedTaskSchedulers.size()) + .forEach(i -> sb.append('[') + .append(i) + .append("] ") + .append(delayedTaskSchedulers.get(i)) + .append(System.lineSeparator())); + + return sb.toString().getBytes(StandardCharsets.UTF_8); + } + + /** + * Invoked by the VM to print the I/O pollers to a byte[]. + */ + private static byte[] printPollers() { + StringBuilder sb = new StringBuilder(); + + Poller masterPoller = Poller.masterPoller(); + List readPollers = Poller.readPollers(); + List writePollers = Poller.writePollers(); + + if (masterPoller != null) { + sb.append("Master I/O poller:") + .append(System.lineSeparator()) + .append(masterPoller) + .append(System.lineSeparator()); + + // break + sb.append(System.lineSeparator()); + } + + sb.append("Read I/O pollers:"); + sb.append(System.lineSeparator()); + IntStream.range(0, readPollers.size()) + .forEach(i -> sb.append('[') + .append(i) + .append("] ") + .append(readPollers.get(i)) + .append(System.lineSeparator())); + + // break + sb.append(System.lineSeparator()); + + sb.append("Write I/O pollers:"); + sb.append(System.lineSeparator()); + IntStream.range(0, writePollers.size()) + .forEach(i -> sb.append('[') + .append(i) + .append("] ") + .append(writePollers.get(i)) + .append(System.lineSeparator())); + + return sb.toString().getBytes(StandardCharsets.UTF_8); + } +} diff --git a/src/java.base/share/classes/sun/nio/ch/Net.java b/src/java.base/share/classes/sun/nio/ch/Net.java index 03dcf04a50f37..5c922aff676b9 100644 --- a/src/java.base/share/classes/sun/nio/ch/Net.java +++ b/src/java.base/share/classes/sun/nio/ch/Net.java @@ -40,6 +40,7 @@ import java.net.StandardSocketOptions; import java.net.UnknownHostException; import java.nio.channels.AlreadyBoundException; +import java.nio.channels.AlreadyConnectedException; import java.nio.channels.ClosedChannelException; import java.nio.channels.NotYetBoundException; import java.nio.channels.NotYetConnectedException; @@ -166,6 +167,8 @@ else if (x instanceof NotYetConnectedException) nx = newSocketException("Socket is not connected"); else if (x instanceof AlreadyBoundException) nx = newSocketException("Already bound"); + else if (x instanceof AlreadyConnectedException) + nx = newSocketException("Already connected"); else if (x instanceof NotYetBoundException) nx = newSocketException("Socket is not bound yet"); else if (x instanceof UnsupportedAddressTypeException) @@ -190,32 +193,12 @@ private static SocketException newSocketException(String msg) { return new SocketException(msg); } - static void translateException(Exception x, - boolean unknownHostForUnresolved) - throws IOException - { + static void translateException(Exception x) throws IOException { if (x instanceof IOException ioe) throw ioe; - // Throw UnknownHostException from here since it cannot - // be thrown as a SocketException - if (unknownHostForUnresolved && - (x instanceof UnresolvedAddressException)) - { - throw new UnknownHostException(); - } translateToSocketException(x); } - static void translateException(Exception x) - throws IOException - { - translateException(x, false); - } - - private static InetSocketAddress getLoopbackAddress(int port) { - return new InetSocketAddress(InetAddress.getLoopbackAddress(), port); - } - private static final InetAddress ANY_LOCAL_INET4ADDRESS; private static final InetAddress ANY_LOCAL_INET6ADDRESS; private static final InetAddress INET4_LOOPBACK_ADDRESS; diff --git a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java index 40bc3156680a4..7c64d6721e2c7 100644 --- a/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java +++ b/src/java.base/share/classes/sun/nio/ch/NioSocketImpl.java @@ -599,8 +599,11 @@ protected void connect(SocketAddress remote, int millis) throws IOException { } } catch (IOException ioe) { close(); - if (ioe instanceof InterruptedIOException) { + if (ioe instanceof SocketTimeoutException) { throw ioe; + } else if (ioe instanceof InterruptedIOException) { + assert Thread.currentThread().isVirtual(); + throw new SocketException("Closed by interrupt"); } else { throw SocketExceptions.of(ioe, isa); } diff --git a/src/java.base/share/classes/sun/nio/ch/Poller.java b/src/java.base/share/classes/sun/nio/ch/Poller.java index d25dfec7f4221..4a2cb4d8fdf82 100644 --- a/src/java.base/share/classes/sun/nio/ch/Poller.java +++ b/src/java.base/share/classes/sun/nio/ch/Poller.java @@ -36,6 +36,7 @@ import java.util.concurrent.locks.LockSupport; import java.util.function.BooleanSupplier; import jdk.internal.misc.InnocuousThread; +import jdk.internal.vm.annotation.Stable; /** * Polls file descriptors. Virtual threads invoke the poll method to park @@ -53,6 +54,9 @@ public abstract class Poller { } } + // the poller or sub-poller thread + private @Stable Thread owner; + // maps file descriptors to parked Thread private final Map map = new ConcurrentHashMap<>(); @@ -238,6 +242,7 @@ private void wakeup(int fdVal) { * descriptor that is polled. */ private void pollerLoop() { + owner = Thread.currentThread(); try { for (;;) { poll(-1); @@ -258,6 +263,7 @@ private void pollerLoop() { */ private void subPollerLoop(Poller masterPoller) { assert Thread.currentThread().isVirtual(); + owner = Thread.currentThread(); try { int polled = 0; for (;;) { @@ -282,7 +288,8 @@ public int registered() { @Override public String toString() { - return Objects.toIdentityString(this) + " [registered = " + registered() + "]"; + return String.format("%s [registered = %d, owner = %s]", + Objects.toIdentityString(this), registered(), owner); } /** @@ -442,4 +449,25 @@ private void startPlatformThread(String name, Runnable task) { } } } + + /** + * Return the master poller or null if there is no master poller. + */ + public static Poller masterPoller() { + return POLLERS.masterPoller(); + } + + /** + * Return the list of read pollers. + */ + public static List readPollers() { + return POLLERS.readPollers(); + } + + /** + * Return the list of write pollers. + */ + public static List writePollers() { + return POLLERS.writePollers(); + } } diff --git a/src/java.base/share/classes/sun/nio/ch/SocketAdaptor.java b/src/java.base/share/classes/sun/nio/ch/SocketAdaptor.java index cbcfd79378c3b..d8ed1cfb675e9 100644 --- a/src/java.base/share/classes/sun/nio/ch/SocketAdaptor.java +++ b/src/java.base/share/classes/sun/nio/ch/SocketAdaptor.java @@ -35,6 +35,7 @@ import java.net.SocketException; import java.net.SocketOption; import java.net.StandardSocketOptions; +import java.net.UnknownHostException; import java.nio.channels.SocketChannel; import java.util.Set; @@ -85,6 +86,14 @@ public void connect(SocketAddress remote) throws IOException { public void connect(SocketAddress remote, int timeout) throws IOException { if (remote == null) throw new IllegalArgumentException("connect: The address can't be null"); + if (remote instanceof InetSocketAddress isa && isa.isUnresolved()) { + if (!sc.isOpen()) + throw new SocketException("Socket is closed"); + if (sc.isConnected()) + throw new SocketException("Already connected"); + close(); + throw new UnknownHostException(remote.toString()); + } if (timeout < 0) throw new IllegalArgumentException("connect: timeout can't be negative"); try { @@ -95,7 +104,7 @@ public void connect(SocketAddress remote, int timeout) throws IOException { sc.blockingConnect(remote, Long.MAX_VALUE); } } catch (Exception e) { - Net.translateException(e, true); + Net.translateException(e); } } diff --git a/src/java.base/share/classes/sun/security/action/GetBooleanAction.java b/src/java.base/share/classes/sun/security/action/GetBooleanAction.java deleted file mode 100644 index d41954601e819..0000000000000 --- a/src/java.base/share/classes/sun/security/action/GetBooleanAction.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.action; - -import java.security.AccessController; - -/** - * A convenience class for retrieving the boolean value of a system property - * as a privileged action. - * - *

      An instance of this class can be used as the argument of - * AccessController.doPrivileged. - * - *

      The following code retrieves the boolean value of the system - * property named "prop" as a privileged action: - * - *

      - * boolean b = java.security.AccessController.doPrivileged
      - *              (new GetBooleanAction("prop")).booleanValue();
      - * 
      - * - * @author Roland Schemers - * @see java.security.PrivilegedAction - * @see java.security.AccessController - * @since 1.2 - */ - -public class GetBooleanAction - implements java.security.PrivilegedAction { - private final String theProp; - - /** - * Constructor that takes the name of the system property whose boolean - * value needs to be determined. - * - * @param theProp the name of the system property. - */ - public GetBooleanAction(String theProp) { - this.theProp = theProp; - } - - /** - * Determines the boolean value of the system property whose name was - * specified in the constructor. - * - * @return the Boolean value of the system property. - */ - public Boolean run() { - return Boolean.getBoolean(theProp); - } - - /** - * Convenience method to get a property without going through doPrivileged - * if no security manager is present. This is unsafe for inclusion in a - * public API but allowable here since this class is now encapsulated. - * - * Note that this method performs a privileged action using caller-provided - * inputs. The caller of this method should take care to ensure that the - * inputs are not tainted and the returned property is not made accessible - * to untrusted code if it contains sensitive information. - * - * @param theProp the name of the system property. - */ - @SuppressWarnings("removal") - public static boolean privilegedGetProperty(String theProp) { - if (System.getSecurityManager() == null) { - return Boolean.getBoolean(theProp); - } else { - return AccessController.doPrivileged( - new GetBooleanAction(theProp)); - } - } -} diff --git a/src/java.base/share/classes/sun/security/action/GetIntegerAction.java b/src/java.base/share/classes/sun/security/action/GetIntegerAction.java deleted file mode 100644 index 2d9a598149cc7..0000000000000 --- a/src/java.base/share/classes/sun/security/action/GetIntegerAction.java +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.action; - -import java.security.AccessController; - -/** - * A convenience class for retrieving the integer value of a system property - * as a privileged action. - * - *

      An instance of this class can be used as the argument of - * AccessController.doPrivileged. - * - *

      The following code retrieves the integer value of the system - * property named "prop" as a privileged action. Since it does - * not pass a default value to be used in case the property - * "prop" is not defined, it has to check the result for - * null: - * - *

      - * Integer tmp = java.security.AccessController.doPrivileged
      - *     (new sun.security.action.GetIntegerAction("prop"));
      - * int i;
      - * if (tmp != null) {
      - *     i = tmp.intValue();
      - * }
      - * 
      - * - *

      The following code retrieves the integer value of the system - * property named "prop" as a privileged action, and also passes - * a default value to be used in case the property "prop" is not - * defined: - * - *

      - * int i = ((Integer)java.security.AccessController.doPrivileged(
      - *                         new GetIntegerAction("prop", 3))).intValue();
      - * 
      - * - * @author Roland Schemers - * @see java.security.PrivilegedAction - * @see java.security.AccessController - * @since 1.2 - */ - -public class GetIntegerAction - implements java.security.PrivilegedAction { - private final String theProp; - private final int defaultVal; - private final boolean defaultSet; - - /** - * Constructor that takes the name of the system property whose integer - * value needs to be determined. - * - * @param theProp the name of the system property. - */ - public GetIntegerAction(String theProp) { - this.theProp = theProp; - this.defaultVal = 0; - this.defaultSet = false; - } - - /** - * Constructor that takes the name of the system property and the default - * value of that property. - * - * @param theProp the name of the system property. - * @param defaultVal the default value. - */ - public GetIntegerAction(String theProp, int defaultVal) { - this.theProp = theProp; - this.defaultVal = defaultVal; - this.defaultSet = true; - } - - /** - * Determines the integer value of the system property whose name was - * specified in the constructor. - * - *

      If there is no property of the specified name, or if the property - * does not have the correct numeric format, then an Integer - * object representing the default value that was specified in the - * constructor is returned, or null if no default value was - * specified. - * - * @return the Integer value of the property. - */ - public Integer run() { - Integer value = Integer.getInteger(theProp); - if ((value == null) && defaultSet) - return defaultVal; - return value; - } - - /** - * Convenience method to get a property without going through doPrivileged - * if no security manager is present. This is unsafe for inclusion in a - * public API but allowable here since this class is now encapsulated. - * - * Note that this method performs a privileged action using caller-provided - * inputs. The caller of this method should take care to ensure that the - * inputs are not tainted and the returned property is not made accessible - * to untrusted code if it contains sensitive information. - * - * @param theProp the name of the system property. - */ - @SuppressWarnings("removal") - public static Integer privilegedGetProperty(String theProp) { - if (System.getSecurityManager() == null) { - return Integer.getInteger(theProp); - } else { - return AccessController.doPrivileged( - new GetIntegerAction(theProp)); - } - } - - /** - * Convenience method to get a property without going through doPrivileged - * if no security manager is present. This is unsafe for inclusion in a - * public API but allowable here since this class is now encapsulated. - * - * Note that this method performs a privileged action using caller-provided - * inputs. The caller of this method should take care to ensure that the - * inputs are not tainted and the returned property is not made accessible - * to untrusted code if it contains sensitive information. - * - * @param theProp the name of the system property. - * @param defaultVal the default value. - */ - @SuppressWarnings("removal") - public static Integer privilegedGetProperty(String theProp, - int defaultVal) { - Integer value; - if (System.getSecurityManager() == null) { - value = Integer.getInteger(theProp); - } else { - value = AccessController.doPrivileged( - new GetIntegerAction(theProp)); - } - return (value != null) ? value : defaultVal; - } -} diff --git a/src/java.base/share/classes/sun/security/action/GetLongAction.java b/src/java.base/share/classes/sun/security/action/GetLongAction.java deleted file mode 100644 index 795f3af239e77..0000000000000 --- a/src/java.base/share/classes/sun/security/action/GetLongAction.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.action; - -/** - * A convenience class for retrieving the Long value of a system - * property as a privileged action. - * - *

      An instance of this class can be used as the argument of - * AccessController.doPrivileged. - * - *

      The following code retrieves the Long value of the system - * property named "prop" as a privileged action. Since it does - * not pass a default value to be used in case the property - * "prop" is not defined, it has to check the result for - * null: - * - *

      - * Long tmp = java.security.AccessController.doPrivileged
      - *     (new sun.security.action.GetLongAction("prop"));
      - * long l;
      - * if (tmp != null) {
      - *     l = tmp.longValue();
      - * }
      - * 
      - * - *

      The following code retrieves the Long value of the system - * property named "prop" as a privileged action, and also passes - * a default value to be used in case the property "prop" is not - * defined: - * - *

      - * long l = java.security.AccessController.doPrivileged
      - *      (new GetLongAction("prop")).longValue();
      - * 
      - * - * @author Roland Schemers - * @see java.security.PrivilegedAction - * @see java.security.AccessController - * @since 1.2 - */ - -public class GetLongAction implements java.security.PrivilegedAction { - private final String theProp; - private final long defaultVal; - private final boolean defaultSet; - - /** - * Constructor that takes the name of the system property whose - * Long value needs to be determined. - * - * @param theProp the name of the system property. - */ - public GetLongAction(String theProp) { - this.theProp = theProp; - this.defaultVal = 0; - this.defaultSet = false; - } - - /** - * Constructor that takes the name of the system property and the default - * value of that property. - * - * @param theProp the name of the system property. - * @param defaultVal the default value. - */ - public GetLongAction(String theProp, long defaultVal) { - this.theProp = theProp; - this.defaultVal = defaultVal; - this.defaultSet = true; - } - - /** - * Determines the Long value of the system property whose - * name was specified in the constructor. - * - *

      If there is no property of the specified name, or if the property - * does not have the correct numeric format, then a Long - * object representing the default value that was specified in the - * constructor is returned, or null if no default value was - * specified. - * - * @return the Long value of the property. - */ - public Long run() { - Long value = Long.getLong(theProp); - if ((value == null) && defaultSet) - return defaultVal; - return value; - } -} diff --git a/src/java.base/share/classes/sun/security/action/GetPropertyAction.java b/src/java.base/share/classes/sun/security/action/GetPropertyAction.java index 347072de9f90d..8954c615cbae0 100644 --- a/src/java.base/share/classes/sun/security/action/GetPropertyAction.java +++ b/src/java.base/share/classes/sun/security/action/GetPropertyAction.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,9 +27,7 @@ import java.security.AccessController; import java.security.PrivilegedAction; -import java.util.Locale; import java.util.Properties; -import sun.security.util.Debug; /** * A convenience class for retrieving the string value of a system @@ -162,99 +160,4 @@ public Properties run() { ); } } - - /** - * Convenience method for fetching System property values that are timeouts. - * Accepted timeout values may be purely numeric, a numeric value - * followed by "s" (both interpreted as seconds), or a numeric value - * followed by "ms" (interpreted as milliseconds). - * - * @param prop the name of the System property - * @param def a default value (in milliseconds) - * @param dbg a Debug object, if null no debug messages will be sent - * - * @return an integer value corresponding to the timeout value in the System - * property in milliseconds. If the property value is empty, negative, - * or contains non-numeric characters (besides a trailing "s" or "ms") - * then the default value will be returned. If a negative value for - * the "def" parameter is supplied, zero will be returned if the - * property's value does not conform to the allowed syntax. - */ - public static int privilegedGetTimeoutProp(String prop, int def, Debug dbg) { - if (def < 0) { - def = 0; - } - - String rawPropVal = privilegedGetProperty(prop, "").trim(); - if (rawPropVal.length() == 0) { - return def; - } - - // Determine if "ms" or just "s" is on the end of the string. - // We may do a little surgery on the value so we'll retain - // the original value in rawPropVal for debug messages. - boolean isMillis = false; - String propVal = rawPropVal; - if (rawPropVal.toLowerCase(Locale.ROOT).endsWith("ms")) { - propVal = rawPropVal.substring(0, rawPropVal.length() - 2); - isMillis = true; - } else if (rawPropVal.toLowerCase(Locale.ROOT).endsWith("s")) { - propVal = rawPropVal.substring(0, rawPropVal.length() - 1); - } - - // Next check to make sure the string is built only from digits - if (propVal.matches("^\\d+$")) { - try { - int timeout = Integer.parseInt(propVal); - return isMillis ? timeout : timeout * 1000; - } catch (NumberFormatException nfe) { - if (dbg != null) { - dbg.println("Warning: Unexpected " + nfe + - " for timeout value " + rawPropVal + - ". Using default value of " + def + " msec."); - } - return def; - } - } else { - if (dbg != null) { - dbg.println("Warning: Incorrect syntax for timeout value " + - rawPropVal + ". Using default value of " + def + - " msec."); - } - return def; - } - } - - /** - * Convenience method for fetching System property values that are booleans. - * - * @param prop the name of the System property - * @param def a default value - * @param dbg a Debug object, if null no debug messages will be sent - * - * @return a boolean value corresponding to the value in the System property. - * If the property value is neither "true" or "false", the default value - * will be returned. - */ - public static boolean privilegedGetBooleanProp(String prop, boolean def, Debug dbg) { - String rawPropVal = privilegedGetProperty(prop, ""); - if ("".equals(rawPropVal)) { - return def; - } - - String lower = rawPropVal.toLowerCase(Locale.ROOT); - if ("true".equals(lower)) { - return true; - } else if ("false".equals(lower)) { - return false; - } else { - if (dbg != null) { - dbg.println("Warning: Unexpected value for " + prop + - ": " + rawPropVal + - ". Using default value: " + def); - } - return def; - } - } - } diff --git a/src/java.base/share/classes/sun/security/action/PutAllAction.java b/src/java.base/share/classes/sun/security/action/PutAllAction.java deleted file mode 100644 index d8b17993213e7..0000000000000 --- a/src/java.base/share/classes/sun/security/action/PutAllAction.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.action; - -import java.util.Map; - -import java.security.Provider; -import java.security.PrivilegedAction; - -/** - * A convenience PrivilegedAction class for setting the properties of - * a provider. See the SunRsaSign provider for a usage example. - * - * @see sun.security.rsa.SunRsaSign - * @author Andreas Sterbenz - * @since 1.5 - */ -public class PutAllAction implements PrivilegedAction { - - private final Provider provider; - private final Map map; - - public PutAllAction(Provider provider, Map map) { - this.provider = provider; - this.map = map; - } - - public Void run() { - provider.putAll(map); - return null; - } - -} diff --git a/src/java.base/share/classes/sun/security/ec/SunEC.java b/src/java.base/share/classes/sun/security/ec/SunEC.java index 7f8c4dba00250..ce38ffe9f53e5 100644 --- a/src/java.base/share/classes/sun/security/ec/SunEC.java +++ b/src/java.base/share/classes/sun/security/ec/SunEC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024, 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,10 +25,8 @@ package sun.security.ec; -import java.security.AccessController; import java.security.InvalidParameterException; import java.security.NoSuchAlgorithmException; -import java.security.PrivilegedAction; import java.security.Provider; import java.security.ProviderException; import java.util.HashMap; @@ -180,15 +178,9 @@ public Object newInstance(Object ctrParamObj) } } - @SuppressWarnings("removal") public SunEC() { super("SunEC", PROVIDER_VER, "Sun Elliptic Curve provider"); - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - putEntries(); - return null; - } - }); + putEntries(); } void putEntries() { diff --git a/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java b/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java index 21b9db9790911..fa19acfaeb695 100644 --- a/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java +++ b/src/java.base/share/classes/sun/security/internal/spec/TlsRsaPremasterSecretParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, 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 @@ package sun.security.internal.spec; -import sun.security.action.GetBooleanAction; - import java.security.spec.AlgorithmParameterSpec; /** @@ -54,8 +52,8 @@ public class TlsRsaPremasterSecretParameterSpec * Default is "false" (old behavior) for compatibility reasons in * SSLv3/TLSv1. Later protocols (TLSv1.1+) do not use this property. */ - private static final boolean rsaPreMasterSecretFix = GetBooleanAction - .privilegedGetProperty("com.sun.net.ssl.rsaPreMasterSecretFix"); + private static final boolean rsaPreMasterSecretFix = + Boolean.getBoolean("com.sun.net.ssl.rsaPreMasterSecretFix"); private final int clientVersion; private final int serverVersion; diff --git a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java index ace87630dac8c..ce954b3b6a5fc 100644 --- a/src/java.base/share/classes/sun/security/jca/ProviderConfig.java +++ b/src/java.base/share/classes/sun/security/jca/ProviderConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -94,23 +94,11 @@ final class ProviderConfig { // avoid if not available (pre Solaris 10) to reduce startup time // or if disabled via system property private void checkSunPKCS11Solaris() { - @SuppressWarnings("removal") - Boolean o = AccessController.doPrivileged( - new PrivilegedAction() { - public Boolean run() { - File file = new File("/usr/lib/libpkcs11.so"); - if (file.exists() == false) { - return Boolean.FALSE; - } - if ("false".equalsIgnoreCase(System.getProperty - ("sun.security.pkcs11.enable-solaris"))) { - return Boolean.FALSE; - } - return Boolean.TRUE; - } - }); - if (o == Boolean.FALSE) { - tries = MAX_LOAD_TRIES; + File file = new File("/usr/lib/libpkcs11.so"); + if (file.exists() == false || + ("false".equalsIgnoreCase(System.getProperty + ("sun.security.pkcs11.enable-solaris")))) { + tries = MAX_LOAD_TRIES; } } @@ -190,28 +178,22 @@ Provider getProvider() { case "Apple", "apple.security.AppleProvider" -> { // Reflection is needed for compile time as the class // is not available for non-macosx systems - @SuppressWarnings("removal") - var tmp = AccessController.doPrivileged( - new PrivilegedAction() { - public Provider run() { - try { - Class c = Class.forName( - "apple.security.AppleProvider"); - if (Provider.class.isAssignableFrom(c)) { - @SuppressWarnings("deprecation") - Object tmp = c.newInstance(); - return (Provider) tmp; - } - } catch (Exception ex) { - if (debug != null) { - debug.println("Error loading provider Apple"); - ex.printStackTrace(); - } - } - return null; - } - }); - yield tmp; + Provider ap = null; + try { + Class c = Class.forName( + "apple.security.AppleProvider"); + if (Provider.class.isAssignableFrom(c)) { + @SuppressWarnings("deprecation") + Object tmp = c.newInstance(); + ap = (Provider) tmp; + } + } catch (Exception ex) { + if (debug != null) { + debug.println("Error loading provider Apple"); + ex.printStackTrace(); + } + } + yield ap; } default -> { if (isLoading) { @@ -240,83 +222,69 @@ public Provider run() { /** * Load and instantiate the Provider described by this class. * - * NOTE use of doPrivileged(). - * * @return null if the Provider could not be loaded * * @throws ProviderException if executing the Provider's constructor * throws a ProviderException. All other Exceptions are ignored. */ - @SuppressWarnings("removal") private Provider doLoadProvider() { - return AccessController.doPrivileged(new PrivilegedAction() { - public Provider run() { + if (debug != null) { + debug.println("Loading provider " + ProviderConfig.this); + } + try { + Provider p = ProviderLoader.INSTANCE.load(provName); + if (p != null) { + if (hasArgument()) { + p = p.configure(argument); + } if (debug != null) { - debug.println("Loading provider " + ProviderConfig.this); + debug.println("Loaded provider " + p.getName()); } - try { - Provider p = ProviderLoader.INSTANCE.load(provName); - if (p != null) { - if (hasArgument()) { - p = p.configure(argument); - } - if (debug != null) { - debug.println("Loaded provider " + p.getName()); - } - } else { - if (debug != null) { - debug.println("Error loading provider " + - ProviderConfig.this); - } - disableLoad(); - } - return p; - } catch (Exception e) { - if (e instanceof ProviderException) { - // pass up - throw e; - } else { - if (debug != null) { - debug.println("Error loading provider " + - ProviderConfig.this); - e.printStackTrace(); - } - disableLoad(); - return null; - } - } catch (ExceptionInInitializerError err) { - // no sufficient permission to initialize provider class - if (debug != null) { - debug.println("Error loading provider " + ProviderConfig.this); - err.printStackTrace(); - } - disableLoad(); - return null; + } else { + if (debug != null) { + debug.println("Error loading provider " + + ProviderConfig.this); } + disableLoad(); + } + return p; + } catch (Exception e) { + if (e instanceof ProviderException) { + // pass up + throw e; + } else { + if (debug != null) { + debug.println("Error loading provider " + + ProviderConfig.this); + e.printStackTrace(); + } + disableLoad(); + return null; } - }); + } catch (ExceptionInInitializerError err) { + // unable to initialize provider class + if (debug != null) { + debug.println("Error loading provider " + ProviderConfig.this); + err.printStackTrace(); + } + disableLoad(); + return null; + } } /** * Perform property expansion of the provider value. - * - * NOTE use of doPrivileged(). */ - @SuppressWarnings("removal") private static String expand(final String value) { // shortcut if value does not contain any properties if (value.contains("${") == false) { return value; } - return AccessController.doPrivileged(new PrivilegedAction() { - public String run() { - try { - return PropertyExpander.expand(value); - } catch (GeneralSecurityException e) { - throw new ProviderException(e); - } - } - }); + try { + return PropertyExpander.expand(value); + } catch (GeneralSecurityException e) { + throw new ProviderException(e); + } } // Inner class for loading security providers listed in java.security file @@ -356,9 +324,9 @@ public Provider load(String pn) { if (pName.equals(pn)) { return p; } - } catch (SecurityException | ServiceConfigurationError | + } catch (ServiceConfigurationError | InvalidParameterException ex) { - // if provider loading fail due to security permission, + // if provider loading failed // log it and move on to next provider if (debug != null) { debug.println("Encountered " + ex + @@ -385,6 +353,7 @@ public Provider load(String pn) { } } + @SuppressWarnings("deprecation") // Class.newInstance private Provider legacyLoad(String classname) { if (debug != null) { @@ -403,15 +372,7 @@ private Provider legacyLoad(String classname) { return null; } - @SuppressWarnings("removal") - Provider p = AccessController.doPrivileged - (new PrivilegedExceptionAction() { - @SuppressWarnings("deprecation") // Class.newInstance - public Provider run() throws Exception { - return (Provider) provClass.newInstance(); - } - }); - return p; + return (Provider) provClass.newInstance(); } catch (Exception e) { Throwable t; if (e instanceof InvocationTargetException) { @@ -429,7 +390,7 @@ public Provider run() throws Exception { } return null; } catch (ExceptionInInitializerError | NoClassDefFoundError err) { - // no sufficient permission to access/initialize provider class + // unable to access/initialize provider class if (debug != null) { debug.println("Error loading legacy provider " + classname); err.printStackTrace(); diff --git a/src/java.base/share/classes/sun/security/jca/ProviderList.java b/src/java.base/share/classes/sun/security/jca/ProviderList.java index 033ad2e9210c4..b83571405434e 100644 --- a/src/java.base/share/classes/sun/security/jca/ProviderList.java +++ b/src/java.base/share/classes/sun/security/jca/ProviderList.java @@ -27,8 +27,6 @@ import java.util.*; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.Provider; import java.security.Provider.Service; import java.security.Security; @@ -87,15 +85,8 @@ public Service getService(String type, String algorithm) { // construct a ProviderList from the security properties // (static provider configuration in the java.security file) - @SuppressWarnings("removal") static ProviderList fromSecurityProperties() { - // doPrivileged() because of Security.getProperty() - return AccessController.doPrivileged( - new PrivilegedAction() { - public ProviderList run() { - return new ProviderList(); - } - }); + return new ProviderList(); } public static ProviderList add(ProviderList providerList, Provider p) { diff --git a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java index 52393f0466aba..bee898567567a 100644 --- a/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java +++ b/src/java.base/share/classes/sun/security/pkcs12/PKCS12KeyStore.java @@ -26,7 +26,6 @@ package sun.security.pkcs12; import java.io.*; -import java.security.AccessController; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.security.Key; @@ -36,7 +35,6 @@ import java.security.KeyStoreException; import java.security.PKCS12Attribute; import java.security.PrivateKey; -import java.security.PrivilegedAction; import java.security.UnrecoverableEntryException; import java.security.UnrecoverableKeyException; import java.security.SecureRandom; @@ -66,7 +64,6 @@ import javax.security.auth.x500.X500Principal; import jdk.internal.access.SharedSecrets; -import sun.security.action.GetPropertyAction; import sun.security.tools.KeyStoreUtil; import sun.security.util.*; import sun.security.pkcs.ContentInfo; @@ -2651,15 +2648,14 @@ public boolean engineProbe(InputStream stream) throws IOException { // key entries. private static boolean useLegacy() { - return GetPropertyAction.privilegedGetProperty( - USE_LEGACY_PROP) != null; + return System.getProperty(USE_LEGACY_PROP) != null; } private static String defaultCertProtectionAlgorithm() { if (useLegacy()) { return LEGACY_CERT_PBE_ALGORITHM; } - String result = SecurityProperties.privilegedGetOverridable( + String result = SecurityProperties.getOverridableProperty( "keystore.pkcs12.certProtectionAlgorithm"); return (result != null && !result.isEmpty()) ? result : DEFAULT_CERT_PBE_ALGORITHM; @@ -2669,7 +2665,7 @@ private static int defaultCertPbeIterationCount() { if (useLegacy()) { return LEGACY_PBE_ITERATION_COUNT; } - String result = SecurityProperties.privilegedGetOverridable( + String result = SecurityProperties.getOverridableProperty( "keystore.pkcs12.certPbeIterationCount"); return (result != null && !result.isEmpty()) ? string2IC("certPbeIterationCount", result) @@ -2682,27 +2678,18 @@ private static String defaultKeyProtectionAlgorithm() { if (useLegacy()) { return LEGACY_KEY_PBE_ALGORITHM; } - @SuppressWarnings("removal") - String result = AccessController.doPrivileged(new PrivilegedAction() { - public String run() { - String result; - String name1 = "keystore.pkcs12.keyProtectionAlgorithm"; - String name2 = "keystore.PKCS12.keyProtectionAlgorithm"; - result = System.getProperty(name1); - if (result != null) { - return result; - } - result = System.getProperty(name2); - if (result != null) { - return result; - } + String name1 = "keystore.pkcs12.keyProtectionAlgorithm"; + String name2 = "keystore.PKCS12.keyProtectionAlgorithm"; + String result = System.getProperty(name1); + if (result == null) { + result = System.getProperty(name2); + if (result == null) { result = Security.getProperty(name1); - if (result != null) { - return result; + if (result == null) { + result = Security.getProperty(name2); } - return Security.getProperty(name2); } - }); + } return (result != null && !result.isEmpty()) ? result : DEFAULT_KEY_PBE_ALGORITHM; } @@ -2711,7 +2698,7 @@ private static int defaultKeyPbeIterationCount() { if (useLegacy()) { return LEGACY_PBE_ITERATION_COUNT; } - String result = SecurityProperties.privilegedGetOverridable( + String result = SecurityProperties.getOverridableProperty( "keystore.pkcs12.keyPbeIterationCount"); return (result != null && !result.isEmpty()) ? string2IC("keyPbeIterationCount", result) @@ -2722,7 +2709,7 @@ private static String defaultMacAlgorithm() { if (useLegacy()) { return LEGACY_MAC_ALGORITHM; } - String result = SecurityProperties.privilegedGetOverridable( + String result = SecurityProperties.getOverridableProperty( "keystore.pkcs12.macAlgorithm"); return (result != null && !result.isEmpty()) ? result : DEFAULT_MAC_ALGORITHM; @@ -2732,7 +2719,7 @@ private static int defaultMacIterationCount() { if (useLegacy()) { return LEGACY_MAC_ITERATION_COUNT; } - String result = SecurityProperties.privilegedGetOverridable( + String result = SecurityProperties.getOverridableProperty( "keystore.pkcs12.macIterationCount"); return (result != null && !result.isEmpty()) ? string2IC("macIterationCount", result) diff --git a/src/java.base/share/classes/sun/security/provider/ConfigFile.java b/src/java.base/share/classes/sun/security/provider/ConfigFile.java index 775e36c61baa6..3642463ade875 100644 --- a/src/java.base/share/classes/sun/security/provider/ConfigFile.java +++ b/src/java.base/share/classes/sun/security/provider/ConfigFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, 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 @@ -29,15 +29,10 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.security.PrivilegedActionException; -import java.security.PrivilegedExceptionAction; import java.security.Security; import java.security.URIParameter; import java.text.MessageFormat; import java.util.*; -import javax.security.auth.AuthPermission; import javax.security.auth.login.AppConfigurationEntry; import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag; import javax.security.auth.login.Configuration; @@ -159,34 +154,18 @@ public Spi(URI uri) { } } - @SuppressWarnings("removal") public Spi(final Configuration.Parameters params) throws IOException { - // call in a doPrivileged - // - // We have already passed the Configuration.getInstance - // security check. Also, this class is not freely accessible - // (it is in the "sun" package). - - try { - AccessController.doPrivileged(new PrivilegedExceptionAction() { - public Void run() throws IOException { - if (params == null) { - init(); - } else { - if (!(params instanceof URIParameter)) { - throw new IllegalArgumentException - ("Unrecognized parameter: " + params); - } - URIParameter uriParam = (URIParameter)params; - url = uriParam.getURI().toURL(); - init(); - } - return null; - } - }); - } catch (PrivilegedActionException pae) { - throw (IOException)pae.getException(); + if (params == null) { + init(); + } else { + if (!(params instanceof URIParameter)) { + throw new IllegalArgumentException + ("Unrecognized parameter: " + params); + } + URIParameter uriParam = (URIParameter)params; + url = uriParam.getURI().toURL(); + init(); } // if init() throws some other RuntimeException, @@ -198,8 +177,6 @@ public Void run() throws IOException { * configured URL. * * @throws IOException if the Configuration can not be initialized - * @throws SecurityException if the caller does not have permission - * to initialize the Configuration */ private void init() throws IOException { @@ -377,31 +354,15 @@ private void init(URL config, /** * Refresh and reload the Configuration by re-reading all the * login configurations. - * - * @throws SecurityException if the caller does not have permission - * to refresh the Configuration. */ - @SuppressWarnings("removal") @Override public synchronized void engineRefresh() { - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPermission( - new AuthPermission("refreshLoginConfiguration")); + try { + init(); + } catch (IOException ioe) { + throw new SecurityException(ioe.getLocalizedMessage(), ioe); } - - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - try { - init(); - } catch (IOException ioe) { - throw new SecurityException(ioe.getLocalizedMessage(), - ioe); - } - return null; - } - }); } private void readConfig(Reader reader, diff --git a/src/java.base/share/classes/sun/security/provider/DRBG.java b/src/java.base/share/classes/sun/security/provider/DRBG.java index 01958285e430a..a340a866068cf 100644 --- a/src/java.base/share/classes/sun/security/provider/DRBG.java +++ b/src/java.base/share/classes/sun/security/provider/DRBG.java @@ -27,9 +27,7 @@ import java.io.IOException; import java.io.InvalidObjectException; -import java.security.AccessController; import java.security.DrbgParameters; -import java.security.PrivilegedAction; import java.security.SecureRandomParameters; import java.security.SecureRandomSpi; import java.security.Security; @@ -93,10 +91,7 @@ public DRBG(SecureRandomParameters params) { byte[] nonce = null; // Can be configured with a security property - - @SuppressWarnings("removal") - String config = AccessController.doPrivileged((PrivilegedAction) - () -> Security.getProperty(PROP_NAME)); + String config = Security.getProperty(PROP_NAME); if (config != null && !config.isEmpty()) { for (String part : config.split(",")) { diff --git a/src/java.base/share/classes/sun/security/provider/FileInputStreamPool.java b/src/java.base/share/classes/sun/security/provider/FileInputStreamPool.java index 67ad6946806b9..a0aae674d6902 100644 --- a/src/java.base/share/classes/sun/security/provider/FileInputStreamPool.java +++ b/src/java.base/share/classes/sun/security/provider/FileInputStreamPool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, 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 @@ -65,9 +65,6 @@ class FileInputStreamPool { * @throws FileNotFoundException if the file does not exist, is a directory * rather than a regular file, or for some * other reason cannot be opened for reading. - * @throws SecurityException if a security manager exists and its - * checkRead method denies read - * access to the file. */ static InputStream getInputStream(File file) throws IOException { @@ -78,9 +75,6 @@ static InputStream getInputStream(File file) throws IOException { } // canonicalize the path - // (this also checks the read permission on the file if SecurityManager - // is present, so no checking is needed later when we just return the - // already opened stream) File cfile = file.getCanonicalFile(); // check if it exists in pool diff --git a/src/java.base/share/classes/sun/security/provider/MD4.java b/src/java.base/share/classes/sun/security/provider/MD4.java index 80cd85a837873..97b8a39c0d628 100644 --- a/src/java.base/share/classes/sun/security/provider/MD4.java +++ b/src/java.base/share/classes/sun/security/provider/MD4.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, 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,13 +69,7 @@ public final class MD4 extends DigestBase { @java.io.Serial private static final long serialVersionUID = -8850464997518327965L; }; - @SuppressWarnings("removal") - var dummy = AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - md4Provider.put("MessageDigest.MD4", "sun.security.provider.MD4"); - return null; - } - }); + md4Provider.put("MessageDigest.MD4", "sun.security.provider.MD4"); } public static MessageDigest getInstance() { diff --git a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java index b4c9355bccf55..892afced83eb1 100644 --- a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java +++ b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, 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 @@ -149,7 +149,6 @@ public static void generateSeed(byte[] result) { /** * Retrieve some system information, hashed. */ - @SuppressWarnings("removal") static byte[] getSystemEntropy() { final MessageDigest md; @@ -164,57 +163,48 @@ static byte[] getSystemEntropy() { byte b =(byte)System.currentTimeMillis(); md.update(b); - java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction<>() { - @Override - public Void run() { - try { - // System properties can change from machine to machine - Properties p = System.getProperties(); - for (String s: p.stringPropertyNames()) { - md.update(s.getBytes()); - md.update(p.getProperty(s).getBytes()); - } + try { + // System properties can change from machine to machine + Properties p = System.getProperties(); + for (String s: p.stringPropertyNames()) { + md.update(s.getBytes()); + md.update(p.getProperty(s).getBytes()); + } - // Include network adapter names (and a Mac address) - addNetworkAdapterInfo(md); - - // The temporary dir - File f = new File(p.getProperty("java.io.tmpdir")); - int count = 0; - try ( - DirectoryStream stream = - Files.newDirectoryStream(f.toPath())) { - // We use a Random object to choose what file names - // should be used. Otherwise, on a machine with too - // many files, the same first 1024 files always get - // used. Any, We make sure the first 512 files are - // always used. - Random r = new Random(); - for (Path entry: stream) { - if (count < 512 || r.nextBoolean()) { - md.update(entry.getFileName() - .toString().getBytes()); - } - if (count++ > 1024) { - break; - } - } - } - } catch (Exception ex) { - md.update((byte)ex.hashCode()); + // Include network adapter names (and a Mac address) + addNetworkAdapterInfo(md); + + // The temporary dir + File f = new File(p.getProperty("java.io.tmpdir")); + int count = 0; + try (DirectoryStream stream = + Files.newDirectoryStream(f.toPath())) { + // We use a Random object to choose what file names + // should be used. Otherwise, on a machine with too + // many files, the same first 1024 files always get + // used. Any, We make sure the first 512 files are + // always used. + Random r = new Random(); + for (Path entry: stream) { + if (count < 512 || r.nextBoolean()) { + md.update(entry.getFileName().toString().getBytes()); } + if (count++ > 1024) { + break; + } + } + } + } catch (Exception ex) { + md.update((byte)ex.hashCode()); + } - // get Runtime memory stats - Runtime rt = Runtime.getRuntime(); - byte[] memBytes = longToByteArray(rt.totalMemory()); - md.update(memBytes, 0, memBytes.length); - memBytes = longToByteArray(rt.freeMemory()); - md.update(memBytes, 0, memBytes.length); + // get Runtime memory stats + Runtime rt = Runtime.getRuntime(); + byte[] memBytes = longToByteArray(rt.totalMemory()); + md.update(memBytes, 0, memBytes.length); + memBytes = longToByteArray(rt.freeMemory()); + md.update(memBytes, 0, memBytes.length); - return null; - } - }); return md.digest(); } @@ -293,29 +283,19 @@ private static class ThreadedSeedGenerator extends SeedGenerator , e); } - final ThreadGroup[] finalsg = new ThreadGroup[1]; - @SuppressWarnings("removal") - Thread t = java.security.AccessController.doPrivileged - (new java.security.PrivilegedAction<>() { - @Override - public Thread run() { - ThreadGroup parent, group = - Thread.currentThread().getThreadGroup(); - while ((parent = group.getParent()) != null) { - group = parent; - } - finalsg[0] = new ThreadGroup - (group, "SeedGenerator ThreadGroup"); - Thread newT = new Thread(finalsg[0], - ThreadedSeedGenerator.this, - "SeedGenerator Thread", - 0, - false); - newT.setPriority(Thread.MIN_PRIORITY); - newT.setDaemon(true); - return newT; - } - }); + ThreadGroup[] finalsg = new ThreadGroup[1]; + ThreadGroup parent, group = Thread.currentThread().getThreadGroup(); + while ((parent = group.getParent()) != null) { + group = parent; + } + finalsg[0] = new ThreadGroup(group, "SeedGenerator ThreadGroup"); + Thread t = new Thread(finalsg[0], + ThreadedSeedGenerator.this, + "SeedGenerator Thread", + 0, + false); + t.setPriority(Thread.MIN_PRIORITY); + t.setDaemon(true); seedGroup = finalsg[0]; t.start(); } @@ -502,34 +482,25 @@ static class URLSeedGenerator extends SeedGenerator { init(); } - @SuppressWarnings("removal") private void init() throws IOException { @SuppressWarnings("deprecation") - final URL device = new URL(deviceName); + URL device = new URL(deviceName); try { - seedStream = java.security.AccessController.doPrivileged - (new java.security.PrivilegedExceptionAction<>() { - @Override - public InputStream run() throws IOException { - /* - * return a shared InputStream for file URLs and - * avoid buffering. - * The URL.openStream() call wraps InputStream in a - * BufferedInputStream which - * can buffer up to 8K bytes. This read is a - * performance issue for entropy sources which - * can be slow to replenish. - */ - if (device.getProtocol().equalsIgnoreCase("file")) { - File deviceFile = - SunEntries.getDeviceFile(device); - return FileInputStreamPool - .getInputStream(deviceFile); - } else { - return device.openStream(); - } - } - }); + /* + * return a shared InputStream for file URLs and + * avoid buffering. + * The URL.openStream() call wraps InputStream in a + * BufferedInputStream which + * can buffer up to 8K bytes. This read is a + * performance issue for entropy sources which + * can be slow to replenish. + */ + if (device.getProtocol().equalsIgnoreCase("file")) { + File deviceFile = SunEntries.getDeviceFile(device); + seedStream = FileInputStreamPool.getInputStream(deviceFile); + } else { + seedStream = device.openStream(); + } } catch (Exception e) { throw new IOException( "Failed to open " + deviceName, e.getCause()); diff --git a/src/java.base/share/classes/sun/security/provider/Sun.java b/src/java.base/share/classes/sun/security/provider/Sun.java index 9c441216ceead..fbd19ef633e06 100644 --- a/src/java.base/share/classes/sun/security/provider/Sun.java +++ b/src/java.base/share/classes/sun/security/provider/Sun.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, 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 @@ -47,7 +47,6 @@ public final class Sun extends Provider { "PKIX CertPathBuilder; LDAP, Collection CertStores, JavaPolicy Policy; " + "JavaLoginConfig Configuration)"; - @SuppressWarnings("removal") public Sun() { /* We are the SUN provider */ super("SUN", PROVIDER_VER, INFO); @@ -55,24 +54,8 @@ public Sun() { Provider p = this; Iterator serviceIter = new SunEntries(p).iterator(); - // if there is no security manager installed, put directly into - // the provider - if (System.getSecurityManager() == null) { - putEntries(serviceIter); - } else { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - putEntries(serviceIter); - return null; - } - }); - } - } - - void putEntries(Iterator i) { - while (i.hasNext()) { - putService(i.next()); + while (serviceIter.hasNext()) { + putService(serviceIter.next()); } } } diff --git a/src/java.base/share/classes/sun/security/provider/SunEntries.java b/src/java.base/share/classes/sun/security/provider/SunEntries.java index 36278ae445f16..9f5e3447aeb56 100644 --- a/src/java.base/share/classes/sun/security/provider/SunEntries.java +++ b/src/java.base/share/classes/sun/security/provider/SunEntries.java @@ -30,8 +30,6 @@ import java.net.URI; import java.net.URISyntaxException; import java.net.URL; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.Provider; import java.security.Security; import java.util.HashMap; @@ -39,7 +37,6 @@ import java.util.LinkedHashSet; import jdk.internal.util.StaticProperty; -import sun.security.action.GetBooleanAction; import static sun.security.util.SecurityProviderConstants.getAliases; @@ -345,29 +342,24 @@ private void addWithAlias(Provider p, String type, String algo, String cn, private static final String PROP_RNDSOURCE = "securerandom.source"; private static final boolean useLegacyDSA = - GetBooleanAction.privilegedGetProperty - ("jdk.security.legacyDSAKeyPairGenerator"); + Boolean.getBoolean("jdk.security.legacyDSAKeyPairGenerator"); static final String URL_DEV_RANDOM = "file:/dev/random"; static final String URL_DEV_URANDOM = "file:/dev/urandom"; - @SuppressWarnings("removal") - private static final String seedSource = AccessController.doPrivileged( - new PrivilegedAction() { - - @Override - public String run() { - String egdSource = System.getProperty(PROP_EGD, ""); - if (egdSource.length() != 0) { - return egdSource; - } - egdSource = Security.getProperty(PROP_RNDSOURCE); - if (egdSource == null) { - return ""; - } - return egdSource; - } - }); + private static final String seedSource = getOverridableSeedSource(); + + private static String getOverridableSeedSource() { + String egdSource = System.getProperty(PROP_EGD, ""); + if (egdSource.length() != 0) { + return egdSource; + } + egdSource = Security.getProperty(PROP_RNDSOURCE); + if (egdSource == null) { + return ""; + } + return egdSource; + } static { DEF_SECURE_RANDOM_ALGO = (NativePRNG.isAvailable() && @@ -386,8 +378,6 @@ static String getSeedSource() { * URISyntaxException we make a best effort for backwards * compatibility. e.g. space character in deviceName string. * - * Method called within PrivilegedExceptionAction block. - * * Moved from SeedGenerator to avoid initialization problems with * signed providers. */ diff --git a/src/java.base/share/classes/sun/security/provider/VerificationProvider.java b/src/java.base/share/classes/sun/security/provider/VerificationProvider.java index 5734a6f4c3bdd..7f5959b8e77f9 100644 --- a/src/java.base/share/classes/sun/security/provider/VerificationProvider.java +++ b/src/java.base/share/classes/sun/security/provider/VerificationProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, 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 @@ -61,7 +61,6 @@ public final class VerificationProvider extends Provider { ACTIVE = b; } - @SuppressWarnings("removal") public VerificationProvider() { super("SunJarVerification", PROVIDER_VER, "Jar Verification Provider"); // register all algorithms normally registered by the Sun and SunRsaSign @@ -75,20 +74,8 @@ public VerificationProvider() { Iterator rsaIter = new SunRsaSignEntries(p).iterator(); - // if there is no security manager installed, put directly into - // the provider - if (System.getSecurityManager() == null) { - putEntries(sunIter); - putEntries(rsaIter); - } else { - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - putEntries(sunIter); - putEntries(rsaIter); - return null; - } - }); - } + putEntries(sunIter); + putEntries(rsaIter); } void putEntries(Iterator i) { diff --git a/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java b/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java index 6f1f7b6ad737a..a32d88605c574 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java @@ -38,10 +38,10 @@ import java.util.List; import java.util.Map; -import sun.security.action.GetPropertyAction; import sun.security.util.Debug; import sun.security.util.Event; import sun.security.util.IOUtils; +import sun.security.util.SecurityProperties; import sun.security.x509.AccessDescription; import sun.security.x509.AuthorityInfoAccessExtension; import sun.security.x509.GeneralName; @@ -114,7 +114,7 @@ public final class OCSP { */ private static int initializeTimeout(String prop, int def) { int timeoutVal = - GetPropertyAction.privilegedGetTimeoutProp(prop, def, debug); + SecurityProperties.getTimeoutSystemProp(prop, def, debug); if (debug != null) { debug.println(prop + " set to " + timeoutVal + " milliseconds"); } @@ -123,7 +123,7 @@ private static int initializeTimeout(String prop, int def) { private static boolean initializeBoolean(String prop, boolean def) { boolean value = - GetPropertyAction.privilegedGetBooleanProp(prop, def, debug); + SecurityProperties.getBooleanSystemProp(prop, def, debug); if (debug != null) { debug.println(prop + " set to " + value); } diff --git a/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java b/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java index 44f11cb098550..28729a56dbdcd 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/URICertStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, 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 @@ -51,12 +51,12 @@ import java.util.List; import java.util.Locale; -import sun.security.action.GetPropertyAction; import sun.security.x509.AccessDescription; import sun.security.x509.GeneralNameInterface; import sun.security.x509.URIName; import sun.security.util.Cache; import sun.security.util.Debug; +import sun.security.util.SecurityProperties; /** * A CertStore that retrieves Certificates or @@ -175,7 +175,7 @@ class URICertStore extends CertStoreSpi { */ private static int initializeTimeout(String prop, int def) { int timeoutVal = - GetPropertyAction.privilegedGetTimeoutProp(prop, def, debug); + SecurityProperties.getTimeoutSystemProp(prop, def, debug); if (debug != null) { debug.println(prop + " set to " + timeoutVal + " milliseconds"); } diff --git a/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java b/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java index 6a9cf6edbf8e7..c6fa1cf8980d1 100644 --- a/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java +++ b/src/java.base/share/classes/sun/security/rsa/RSAKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,7 +32,6 @@ import java.security.spec.*; import java.util.Arrays; -import sun.security.action.GetPropertyAction; import sun.security.rsa.RSAUtil.KeyType; /** @@ -91,7 +90,7 @@ public class RSAKeyFactory extends KeyFactorySpi { public static final int MAX_RESTRICTED_EXPLEN = 64; private static final boolean restrictExpLen = - "true".equalsIgnoreCase(GetPropertyAction.privilegedGetProperty( + "true".equalsIgnoreCase(System.getProperty( "sun.security.rsa.restrictRSAExponent", "true")); static RSAKeyFactory getInstance(KeyType type) { diff --git a/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java b/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java index 642b97933d5f7..664881ba6af96 100644 --- a/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java +++ b/src/java.base/share/classes/sun/security/rsa/SunRsaSign.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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,26 +43,11 @@ public final class SunRsaSign extends Provider { @java.io.Serial private static final long serialVersionUID = 866040293550393045L; - @SuppressWarnings("removal") public SunRsaSign() { super("SunRsaSign", PROVIDER_VER, "Sun RSA signature provider"); Provider p = this; - Iterator serviceIter = new SunRsaSignEntries(p).iterator(); - - if (System.getSecurityManager() == null) { - putEntries(serviceIter); - } else { - AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Void run() { - putEntries(serviceIter); - return null; - } - }); - } - } - void putEntries(Iterator i) { + Iterator i = new SunRsaSignEntries(p).iterator(); while (i.hasNext()) { putService(i.next()); } diff --git a/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/src/java.base/share/classes/sun/security/tools/keytool/Main.java index 3afd5b2142a5c..e10b05eceae92 100644 --- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java +++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java @@ -981,9 +981,9 @@ void doCommands(PrintStream out) throws Exception { // if certProtectionAlgorithm and macAlgorithm are both NONE. if (storetype.equalsIgnoreCase("pkcs12")) { isPasswordlessKeyStore = - "NONE".equals(SecurityProperties.privilegedGetOverridable( + "NONE".equals(SecurityProperties.getOverridableProperty( "keystore.pkcs12.certProtectionAlgorithm")) - && "NONE".equals(SecurityProperties.privilegedGetOverridable( + && "NONE".equals(SecurityProperties.getOverridableProperty( "keystore.pkcs12.macAlgorithm")); } diff --git a/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java b/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java index 28f32742a6127..dc5b1aafb2017 100644 --- a/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java +++ b/src/java.base/share/classes/sun/security/util/AbstractAlgorithmConstraints.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, 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,9 +25,7 @@ package sun.security.util; -import java.security.AccessController; import java.security.AlgorithmConstraints; -import java.security.PrivilegedAction; import java.security.Security; import java.util.Arrays; import java.util.Collections; @@ -48,14 +46,7 @@ protected AbstractAlgorithmConstraints(AlgorithmDecomposer decomposer) { // Get algorithm constraints from the specified security property. static Set getAlgorithms(String propertyName) { - @SuppressWarnings("removal") - String property = AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public String run() { - return Security.getProperty(propertyName); - } - }); + String property = Security.getProperty(propertyName); String[] algorithmsInProperty = null; if (property != null && !property.isEmpty()) { diff --git a/src/java.base/share/classes/sun/security/util/Debug.java b/src/java.base/share/classes/sun/security/util/Debug.java index 9f344601e7e38..59bc810ca575a 100644 --- a/src/java.base/share/classes/sun/security/util/Debug.java +++ b/src/java.base/share/classes/sun/security/util/Debug.java @@ -34,7 +34,6 @@ import java.util.regex.Pattern; import java.util.regex.Matcher; import java.util.Locale; -import sun.security.action.GetPropertyAction; /** * A utility class for debugging. @@ -54,10 +53,9 @@ public class Debug { private static final String THREAD_OPTION = "+thread"; static { - args = GetPropertyAction.privilegedGetProperty("java.security.debug"); + args = System.getProperty("java.security.debug"); - String args2 = GetPropertyAction - .privilegedGetProperty("java.security.auth.debug"); + String args2 = System.getProperty("java.security.auth.debug"); if (args == null) { args = args2; diff --git a/src/java.base/share/classes/sun/security/util/DomainName.java b/src/java.base/share/classes/sun/security/util/DomainName.java index 5182ad1b5caf7..53a646c8102ed 100644 --- a/src/java.base/share/classes/sun/security/util/DomainName.java +++ b/src/java.base/share/classes/sun/security/util/DomainName.java @@ -32,8 +32,6 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.IOException; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; @@ -205,21 +203,12 @@ private static Rules createRules(String tld) { } private static InputStream getPubSuffixStream() { - @SuppressWarnings("removal") - InputStream is = AccessController.doPrivileged( - new PrivilegedAction<>() { - @Override - public InputStream run() { - File f = new File(StaticProperty.javaHome(), - "lib/security/public_suffix_list.dat"); - try { - return new FileInputStream(f); - } catch (FileNotFoundException e) { - return null; - } - } - } - ); + InputStream is = null; + File f = new File(System.getProperty("java.home"), + "lib/security/public_suffix_list.dat"); + try { + is = new FileInputStream(f); + } catch (FileNotFoundException e) { } if (is == null) { if (SSLLogger.isOn && SSLLogger.isOn("ssl") && SSLLogger.isOn("trustmanager")) { diff --git a/src/java.base/share/classes/sun/security/util/FilePermCompat.java b/src/java.base/share/classes/sun/security/util/FilePermCompat.java index 1bba80df544a3..72db4eb93bc05 100644 --- a/src/java.base/share/classes/sun/security/util/FilePermCompat.java +++ b/src/java.base/share/classes/sun/security/util/FilePermCompat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -40,7 +40,7 @@ public class FilePermCompat { public static final boolean compat; static { - String flag = SecurityProperties.privilegedGetOverridable( + String flag = SecurityProperties.getOverridableProperty( "jdk.io.permissionsUseCanonicalPath"); if (flag == null) { flag = "false"; diff --git a/src/java.base/share/classes/sun/security/util/HostnameChecker.java b/src/java.base/share/classes/sun/security/util/HostnameChecker.java index 71a491813eb96..1374bc6d53521 100644 --- a/src/java.base/share/classes/sun/security/util/HostnameChecker.java +++ b/src/java.base/share/classes/sun/security/util/HostnameChecker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -153,7 +153,7 @@ private static void matchIP(String expectedIP, X509Certificate cert) InetAddress.getByName(ipAddress))) { return; } - } catch (UnknownHostException | SecurityException e) {} + } catch (UnknownHostException e) {} } } } diff --git a/src/java.base/share/classes/sun/security/util/KeyStoreDelegator.java b/src/java.base/share/classes/sun/security/util/KeyStoreDelegator.java index fb8816ce02b2e..b98ccf7ca12ad 100644 --- a/src/java.base/share/classes/sun/security/util/KeyStoreDelegator.java +++ b/src/java.base/share/classes/sun/security/util/KeyStoreDelegator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, 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 @@ -64,9 +64,7 @@ public KeyStoreDelegator( Class secondaryKeyStore) { // Check whether compatibility mode has been disabled - @SuppressWarnings("removal") - var prop = AccessController.doPrivileged((PrivilegedAction) () -> - Security.getProperty(KEYSTORE_TYPE_COMPAT)); + var prop = Security.getProperty(KEYSTORE_TYPE_COMPAT); compatModeEnabled = "true".equalsIgnoreCase(prop); if (compatModeEnabled) { diff --git a/src/java.base/share/classes/sun/security/util/LazyCodeSourcePermissionCollection.java b/src/java.base/share/classes/sun/security/util/LazyCodeSourcePermissionCollection.java deleted file mode 100644 index 68a1f70bb0161..0000000000000 --- a/src/java.base/share/classes/sun/security/util/LazyCodeSourcePermissionCollection.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.security.util; - -import java.io.File; -import java.io.FilePermission; -import java.io.IOException; -import java.net.URL; -import java.security.CodeSource; -import java.security.Permission; -import java.security.PermissionCollection; -import java.util.Enumeration; - -/** - * This {@code PermissionCollection} implementation delegates to another - * {@code PermissionCollection}, taking care to lazily add the permission needed - * to read from the given {@code CodeSource} at first use, i.e., when either of - * {@link #elements}, {@link #implies} or {@link #toString} is called, or when - * the collection is serialized. - */ -public final class LazyCodeSourcePermissionCollection - extends PermissionCollection -{ - @java.io.Serial - private static final long serialVersionUID = -6727011328946861783L; - private final PermissionCollection perms; - private final CodeSource cs; - private volatile boolean permissionAdded; - - public LazyCodeSourcePermissionCollection(PermissionCollection perms, - CodeSource cs) { - this.perms = perms; - this.cs = cs; - } - - private void ensureAdded() { - if (!permissionAdded) { - synchronized(perms) { - if (permissionAdded) - return; - - // open connection to determine the permission needed - URL location = cs.getLocation(); - if (location != null) { - try { - Permission p = location.openConnection().getPermission(); - if (p != null) { - // for directories then need recursive access - if (p instanceof FilePermission) { - String path = p.getName(); - if (path.endsWith(File.separator)) { - path += "-"; - p = new FilePermission(path, - SecurityConstants.FILE_READ_ACTION); - } - } - perms.add(p); - } - } catch (IOException ioe) { - } - } - if (isReadOnly()) { - perms.setReadOnly(); - } - permissionAdded = true; - } - } - } - - @Override - public void add(Permission permission) { - if (isReadOnly()) - throw new SecurityException( - "attempt to add a Permission to a readonly PermissionCollection"); - perms.add(permission); - } - - @Override - public boolean implies(Permission permission) { - ensureAdded(); - return perms.implies(permission); - } - - @Override - public Enumeration elements() { - ensureAdded(); - return perms.elements(); - } - - @Override - public String toString() { - ensureAdded(); - return perms.toString(); - } - - /** - * On serialization, initialize and replace with the underlying - * permissions. This removes the laziness on deserialization. - */ - @java.io.Serial - private Object writeReplace() { - ensureAdded(); - return perms; - } -} diff --git a/src/java.base/share/classes/sun/security/util/LocalizedMessage.java b/src/java.base/share/classes/sun/security/util/LocalizedMessage.java index 99742b3b80f68..ffe092a6b6d4b 100644 --- a/src/java.base/share/classes/sun/security/util/LocalizedMessage.java +++ b/src/java.base/share/classes/sun/security/util/LocalizedMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, 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 @@ -49,8 +49,8 @@ public class LocalizedMessage { /** * A LocalizedMessage can be instantiated with a key and formatted with * arguments later in the style of MessageFormat. This organization - * allows the actual formatting (and associated permission checks) to be - * avoided unless the resulting string is needed. + * allows the actual formatting to be avoided unless the resulting string + * is needed. * @param key */ public LocalizedMessage(String key) { diff --git a/src/java.base/share/classes/sun/security/util/SecurityConstants.java b/src/java.base/share/classes/sun/security/util/SecurityConstants.java index 9d49bbba0a1a7..34f80faa3ab36 100644 --- a/src/java.base/share/classes/sun/security/util/SecurityConstants.java +++ b/src/java.base/share/classes/sun/security/util/SecurityConstants.java @@ -25,12 +25,7 @@ package sun.security.util; -import java.lang.reflect.ReflectPermission; -import java.net.NetPermission; -import java.net.SocketPermission; import java.security.AllPermission; -import java.security.SecurityPermission; -import sun.security.action.GetPropertyAction; /** * Permission constants and string constants used to create permissions @@ -63,72 +58,9 @@ private SecurityConstants () { // Permission constants used in the various checkPermission() calls in JDK. - // java.lang.Class, java.lang.SecurityManager, java.lang.System, - // java.net.URLConnection, java.security.AllPermission, java.security.Policy, - // sun.security.provider.PolicyFile + // java.net.URLConnection, java.security.AllPermission public static final AllPermission ALL_PERMISSION = new AllPermission(); - // java.net.URL - public static final NetPermission SPECIFY_HANDLER_PERMISSION = - new NetPermission("specifyStreamHandler"); - - // java.net.ServerSocket, java.net.Socket - public static final NetPermission SET_SOCKETIMPL_PERMISSION = - new NetPermission("setSocketImpl"); - - // java.lang.SecurityManager, sun.applet.AppletPanel - public static final RuntimePermission CREATE_CLASSLOADER_PERMISSION = - new RuntimePermission("createClassLoader"); - - // java.lang.SecurityManager - public static final RuntimePermission CHECK_MEMBER_ACCESS_PERMISSION = - new RuntimePermission("accessDeclaredMembers"); - - // java.lang.SecurityManager, sun.applet.AppletSecurity - public static final RuntimePermission MODIFY_THREAD_PERMISSION = - new RuntimePermission("modifyThread"); - - // java.lang.SecurityManager, sun.applet.AppletSecurity - public static final RuntimePermission MODIFY_THREADGROUP_PERMISSION = - new RuntimePermission("modifyThreadGroup"); - - // java.lang.Class - public static final RuntimePermission GET_PD_PERMISSION = - new RuntimePermission("getProtectionDomain"); - - // java.lang.Thread - public static final RuntimePermission GET_STACK_TRACE_PERMISSION = - new RuntimePermission("getStackTrace"); - - // java.lang.Thread - public static final RuntimePermission SUBCLASS_IMPLEMENTATION_PERMISSION = - new RuntimePermission("enableContextClassLoaderOverride"); - - // java.security.AccessControlContext - public static final SecurityPermission CREATE_ACC_PERMISSION = - new SecurityPermission("createAccessControlContext"); - - // java.security.AccessControlContext - public static final SecurityPermission GET_COMBINER_PERMISSION = - new SecurityPermission("getDomainCombiner"); - - // java.security.Policy, java.security.ProtectionDomain - public static final SecurityPermission GET_POLICY_PERMISSION = - new SecurityPermission ("getPolicy"); - - // java.lang.SecurityManager - public static final SocketPermission LOCAL_LISTEN_PERMISSION = - new SocketPermission("localhost:0", SOCKET_LISTEN_ACTION); - public static final String PROVIDER_VER = - GetPropertyAction.privilegedGetProperty("java.specification.version"); - - // java.lang.reflect.AccessibleObject - public static final ReflectPermission ACCESS_PERMISSION = - new ReflectPermission("suppressAccessChecks"); - - // sun.reflect.ReflectionFactory - public static final RuntimePermission REFLECTION_FACTORY_ACCESS_PERMISSION = - new RuntimePermission("reflectionFactoryAccess"); - + System.getProperty("java.specification.version"); } diff --git a/src/java.base/share/classes/sun/security/util/SecurityProperties.java b/src/java.base/share/classes/sun/security/util/SecurityProperties.java index a07c9b743fc62..98bc71d829bec 100644 --- a/src/java.base/share/classes/sun/security/util/SecurityProperties.java +++ b/src/java.base/share/classes/sun/security/util/SecurityProperties.java @@ -26,10 +26,12 @@ package sun.security.util; -import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.Security; +import java.util.Locale; +/** + * Utility methods for retrieving security and system properties. + */ public class SecurityProperties { public static final boolean INCLUDE_JAR_NAME_IN_EXCEPTIONS @@ -42,15 +44,6 @@ public class SecurityProperties { * @param propName the name of the system or security property * @return the value of the system or security property */ - @SuppressWarnings("removal") - public static String privilegedGetOverridable(String propName) { - if (System.getSecurityManager() == null) { - return getOverridableProperty(propName); - } else { - return AccessController.doPrivileged((PrivilegedAction) () -> getOverridableProperty(propName)); - } - } - public static String getOverridableProperty(String propName) { String val = System.getProperty(propName); if (val == null) { @@ -69,7 +62,7 @@ public static String getOverridableProperty(String propName) { * contains refName, false otherwise */ public static boolean includedInExceptions(String refName) { - String val = privilegedGetOverridable("jdk.includeInExceptions"); + String val = getOverridableProperty("jdk.includeInExceptions"); if (val == null) { return false; } @@ -83,4 +76,98 @@ public static boolean includedInExceptions(String refName) { } return false; } + + /** + * Convenience method for fetching System property values that are timeouts. + * Accepted timeout values may be purely numeric, a numeric value + * followed by "s" (both interpreted as seconds), or a numeric value + * followed by "ms" (interpreted as milliseconds). + * + * @param prop the name of the System property + * @param def a default value (in milliseconds) + * @param dbg a Debug object, if null no debug messages will be sent + * + * @return an integer value corresponding to the timeout value in the System + * property in milliseconds. If the property value is empty, negative, + * or contains non-numeric characters (besides a trailing "s" or "ms") + * then the default value will be returned. If a negative value for + * the "def" parameter is supplied, zero will be returned if the + * property's value does not conform to the allowed syntax. + */ + public static int getTimeoutSystemProp(String prop, int def, Debug dbg) { + if (def < 0) { + def = 0; + } + + String rawPropVal = System.getProperty(prop, "").trim(); + if (rawPropVal.length() == 0) { + return def; + } + + // Determine if "ms" or just "s" is on the end of the string. + // We may do a little surgery on the value so we'll retain + // the original value in rawPropVal for debug messages. + boolean isMillis = false; + String propVal = rawPropVal; + if (rawPropVal.toLowerCase(Locale.ROOT).endsWith("ms")) { + propVal = rawPropVal.substring(0, rawPropVal.length() - 2); + isMillis = true; + } else if (rawPropVal.toLowerCase(Locale.ROOT).endsWith("s")) { + propVal = rawPropVal.substring(0, rawPropVal.length() - 1); + } + + // Next check to make sure the string is built only from digits + if (propVal.matches("^\\d+$")) { + try { + int timeout = Integer.parseInt(propVal); + return isMillis ? timeout : timeout * 1000; + } catch (NumberFormatException nfe) { + if (dbg != null) { + dbg.println("Warning: Unexpected " + nfe + + " for timeout value " + rawPropVal + + ". Using default value of " + def + " msec."); + } + return def; + } + } else { + if (dbg != null) { + dbg.println("Warning: Incorrect syntax for timeout value " + + rawPropVal + ". Using default value of " + def + + " msec."); + } + return def; + } + } + + /** + * Convenience method for fetching System property values that are booleans. + * + * @param prop the name of the System property + * @param def a default value + * @param dbg a Debug object, if null no debug messages will be sent + * + * @return a boolean value corresponding to the value in the System property. + * If the property value is neither "true" or "false", the default value + * will be returned. + */ + public static boolean getBooleanSystemProp(String prop, boolean def, Debug dbg) { + String rawPropVal = System.getProperty(prop, ""); + if ("".equals(rawPropVal)) { + return def; + } + + String lower = rawPropVal.toLowerCase(Locale.ROOT); + if ("true".equals(lower)) { + return true; + } else if ("false".equals(lower)) { + return false; + } else { + if (dbg != null) { + dbg.println("Warning: Unexpected value for " + prop + + ": " + rawPropVal + + ". Using default value: " + def); + } + return def; + } + } } diff --git a/src/java.base/share/classes/sun/security/util/SecurityProviderConstants.java b/src/java.base/share/classes/sun/security/util/SecurityProviderConstants.java index 66c88cd63a970..3ae9375fae195 100644 --- a/src/java.base/share/classes/sun/security/util/SecurityProviderConstants.java +++ b/src/java.base/share/classes/sun/security/util/SecurityProviderConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,6 @@ import java.security.NoSuchAlgorithmException; import javax.crypto.Cipher; import javax.crypto.spec.DHParameterSpec; -import sun.security.action.GetPropertyAction; /** * Various constants such as version number, default key length, used by @@ -175,8 +174,7 @@ public static final int getDefAESKeySize() { "jdk.security.defaultKeySize"; static { - String keyLengthStr = GetPropertyAction.privilegedGetProperty - (KEY_LENGTH_PROP); + String keyLengthStr = System.getProperty(KEY_LENGTH_PROP); int dsaKeySize = 2048; int rsaKeySize = 3072; int rsaSsaPssKeySize = rsaKeySize; // default to same value as RSA diff --git a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java index 1576388b65322..7accd3cbf10bb 100644 --- a/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java +++ b/src/java.base/share/classes/sun/security/util/SignatureFileVerifier.java @@ -37,7 +37,6 @@ import java.util.jar.Manifest; import jdk.internal.util.ArraysSupport; -import sun.security.action.GetIntegerAction; import sun.security.jca.Providers; import sun.security.pkcs.PKCS7; import sun.security.pkcs.SignerInfo; @@ -847,8 +846,7 @@ private static int initializeMaxSigFileSize() { * the maximum allowed number of bytes for the signature-related files * in a JAR file. */ - int tmp = GetIntegerAction.privilegedGetProperty( - "jdk.jar.maxSignatureFileSize", 16000000); + int tmp = Integer.getInteger("jdk.jar.maxSignatureFileSize", 16000000); if (tmp < 0 || tmp > MAX_ARRAY_SIZE) { if (debug != null) { debug.println("The default signature file size of 16000000 bytes " + diff --git a/src/java.base/share/data/tzdata/tzmappings.override b/src/java.base/share/data/tzdata/tzmappings.override new file mode 100644 index 0000000000000..0f0e0c1372c83 --- /dev/null +++ b/src/java.base/share/data/tzdata/tzmappings.override @@ -0,0 +1,32 @@ +# +# Copyright (c) 2024, 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. +# + +# Extra definitions for Windows /lib/tzmappings file. These entries +# replace the existing (Windows Zone Name):(REGION) entries, or are added +# as new entries + +# Example entries +# Foo Standard Time:US:America/Los_Angeles: +# Bar Standard Time:001:Asia/Tokyo: diff --git a/src/java.base/share/native/libfallbackLinker/fallbackLinker.c b/src/java.base/share/native/libfallbackLinker/fallbackLinker.c index 2ee64fb05bc7a..1548fb49e268b 100644 --- a/src/java.base/share/native/libfallbackLinker/fallbackLinker.c +++ b/src/java.base/share/native/libfallbackLinker/fallbackLinker.c @@ -112,12 +112,16 @@ static void do_capture_state(int32_t* value_ptr, int captured_state_mask) { JNIEXPORT void JNICALL Java_jdk_internal_foreign_abi_fallback_LibFallback_doDowncall(JNIEnv* env, jclass cls, jlong cif, jlong fn, jlong rvalue, - jlong avalues, jlong jcaptured_state, jint captured_state_mask, + jlong avalues, + jarray capture_state_heap_base, jlong captured_state_offset, + jint captured_state_mask, jarray heapBases, jint numArgs) { void** carrays; + int capture_state_hb_offset = numArgs; + int32_t* captured_state_addr = jlong_to_ptr(captured_state_offset); if (heapBases != NULL) { void** aptrs = jlong_to_ptr(avalues); - carrays = malloc(sizeof(void*) * numArgs); + carrays = malloc(sizeof(void*) * (numArgs + 1)); for (int i = 0; i < numArgs; i++) { jarray hb = (jarray) (*env)->GetObjectArrayElement(env, heapBases, i); if (hb != NULL) { @@ -130,10 +134,20 @@ Java_jdk_internal_foreign_abi_fallback_LibFallback_doDowncall(JNIEnv* env, jclas *((void**)aptrs[i]) = arrayPtr + offset; } } + if (capture_state_heap_base != NULL) { + jboolean isCopy; + jbyte* arrayPtr = (*env)->GetPrimitiveArrayCritical(env, capture_state_heap_base, &isCopy); + carrays[capture_state_hb_offset] = arrayPtr; + captured_state_addr = (int32_t*) (arrayPtr + captured_state_offset); + } } ffi_call(jlong_to_ptr(cif), jlong_to_ptr(fn), jlong_to_ptr(rvalue), jlong_to_ptr(avalues)); + if (captured_state_mask != 0) { + do_capture_state(captured_state_addr, captured_state_mask); + } + if (heapBases != NULL) { for (int i = 0; i < numArgs; i++) { jarray hb = (jarray) (*env)->GetObjectArrayElement(env, heapBases, i); @@ -141,13 +155,11 @@ Java_jdk_internal_foreign_abi_fallback_LibFallback_doDowncall(JNIEnv* env, jclas (*env)->ReleasePrimitiveArrayCritical(env, hb, carrays[i], JNI_COMMIT); } } + if (capture_state_heap_base != NULL) { + (*env)->ReleasePrimitiveArrayCritical(env, capture_state_heap_base, carrays[capture_state_hb_offset], JNI_COMMIT); + } free(carrays); } - - if (captured_state_mask != 0) { - int32_t* captured_state = jlong_to_ptr(jcaptured_state); - do_capture_state(captured_state, captured_state_mask); - } } static void do_upcall(ffi_cif* cif, void* ret, void** args, void* user_data) { diff --git a/src/java.base/unix/classes/sun/security/provider/NativePRNG.java b/src/java.base/unix/classes/sun/security/provider/NativePRNG.java index edc5197df2c0a..a814746d96016 100644 --- a/src/java.base/unix/classes/sun/security/provider/NativePRNG.java +++ b/src/java.base/unix/classes/sun/security/provider/NativePRNG.java @@ -126,75 +126,68 @@ private static URL getEgdUrl() { /** * Create a RandomIO object for all I/O of this Variant type. */ - @SuppressWarnings("removal") private static RandomIO initIO(final Variant v) { - return AccessController.doPrivileged( - new PrivilegedAction<>() { - @Override - public RandomIO run() { - - File seedFile; - File nextFile; - - switch(v) { - case MIXED: - URL egdUrl; - File egdFile = null; - - if ((egdUrl = getEgdUrl()) != null) { - try { - egdFile = SunEntries.getDeviceFile(egdUrl); - } catch (IOException e) { - // Swallow, seedFile is still null - } - } - // Try egd first. - if ((egdFile != null) && egdFile.canRead()) { - seedFile = egdFile; - } else { - // fall back to /dev/random. - seedFile = new File(NAME_RANDOM); - } - nextFile = new File(NAME_URANDOM); - break; - - case BLOCKING: - seedFile = new File(NAME_RANDOM); - nextFile = new File(NAME_RANDOM); - break; - - case NONBLOCKING: - seedFile = new File(NAME_URANDOM); - nextFile = new File(NAME_URANDOM); - break; - - default: - // Shouldn't happen! - return null; - } + File seedFile; + File nextFile; - if (debug != null) { - debug.println("NativePRNG." + v + - " seedFile: " + seedFile + - " nextFile: " + nextFile); - } + switch(v) { + case MIXED: + URL egdUrl; + File egdFile = null; - if (!seedFile.canRead() || !nextFile.canRead()) { - if (debug != null) { - debug.println("NativePRNG." + v + - " Couldn't read Files."); - } - return null; - } - - try { - return new RandomIO(seedFile, nextFile); - } catch (Exception e) { - return null; - } + if ((egdUrl = getEgdUrl()) != null) { + try { + egdFile = SunEntries.getDeviceFile(egdUrl); + } catch (IOException e) { + // Swallow, seedFile is still null } - }); + } + + // Try egd first. + if ((egdFile != null) && egdFile.canRead()) { + seedFile = egdFile; + } else { + // fall back to /dev/random. + seedFile = new File(NAME_RANDOM); + } + nextFile = new File(NAME_URANDOM); + break; + + case BLOCKING: + seedFile = new File(NAME_RANDOM); + nextFile = new File(NAME_RANDOM); + break; + + case NONBLOCKING: + seedFile = new File(NAME_URANDOM); + nextFile = new File(NAME_URANDOM); + break; + + default: + // Shouldn't happen! + return null; + } + + if (debug != null) { + debug.println("NativePRNG." + v + + " seedFile: " + seedFile + + " nextFile: " + nextFile); + } + + if (!seedFile.canRead() || !nextFile.canRead()) { + if (debug != null) { + debug.println("NativePRNG." + v + + " Couldn't read Files."); + } + return null; + } + + try { + return new RandomIO(seedFile, nextFile); + } catch (Exception e) { + return null; + } } // return whether the NativePRNG is available @@ -457,22 +450,15 @@ private byte[] implGenerateSeed(int numBytes) { // supply random bytes to the OS // write to "seed" if possible // always add the seed to our mixing random - @SuppressWarnings("removal") private void implSetSeed(byte[] seed) { synchronized (LOCK_SET_SEED) { if (seedOutInitialized == false) { seedOutInitialized = true; - seedOut = AccessController.doPrivileged( - new PrivilegedAction<>() { - @Override - public OutputStream run() { - try { - return new FileOutputStream(seedFile, true); - } catch (Exception e) { - return null; - } - } - }); + try { + seedOut = new FileOutputStream(seedFile, true); + } catch (Exception e) { + seedOut = null; + } } if (seedOut != null) { try { diff --git a/src/java.base/unix/native/libjli/java_md.c b/src/java.base/unix/native/libjli/java_md.c index c2d2ac93f361b..2c25a7668c396 100644 --- a/src/java.base/unix/native/libjli/java_md.c +++ b/src/java.base/unix/native/libjli/java_md.c @@ -276,6 +276,13 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, char jdkroot[], jint so_jdkroot, char jvmpath[], jint so_jvmpath, char jvmcfg[], jint so_jvmcfg) { + if (JLI_IsStaticallyLinked()) { + // With static builds, all JDK and VM natives are statically linked + // with the launcher executable. No need to manipulate LD_LIBRARY_PATH + // by adding /lib and etc. The 'jrepath', 'jvmpath' and + // 'jvmcfg' are not used by the caller for static builds. Simply return. + return; + } char * jvmtype = NULL; char **argv = *pargv; @@ -318,6 +325,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); exit(4); } + /* * we seem to have everything we need, so without further ado * we return back, otherwise proceed to set the environment. @@ -519,11 +527,15 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) JLI_TraceLauncher("JVM path is %s\n", jvmpath); - libjvm = dlopen(jvmpath, RTLD_NOW + RTLD_GLOBAL); - if (libjvm == NULL) { - JLI_ReportErrorMessage(DLL_ERROR1, __LINE__); - JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror()); - return JNI_FALSE; + if (JLI_IsStaticallyLinked()) { + libjvm = dlopen(NULL, RTLD_NOW + RTLD_GLOBAL); + } else { + libjvm = dlopen(jvmpath, RTLD_NOW + RTLD_GLOBAL); + if (libjvm == NULL) { + JLI_ReportErrorMessage(DLL_ERROR1, __LINE__); + JLI_ReportErrorMessage(DLL_ERROR2, jvmpath, dlerror()); + return JNI_FALSE; + } } ifn->CreateJavaVM = (CreateJavaVM_t) @@ -600,22 +612,26 @@ void* SplashProcAddress(const char* name) { char jdkRoot[MAXPATHLEN]; char splashPath[MAXPATHLEN]; - if (!GetJDKInstallRoot(jdkRoot, sizeof(jdkRoot), JNI_FALSE)) { - JLI_ReportErrorMessage(LAUNCHER_ERROR1); - return NULL; - } - ret = JLI_Snprintf(splashPath, sizeof(splashPath), "%s/lib/%s", + if (JLI_IsStaticallyLinked()) { + hSplashLib = dlopen(NULL, RTLD_LAZY); + } else { + if (!GetJDKInstallRoot(jdkRoot, sizeof(jdkRoot), JNI_FALSE)) { + JLI_ReportErrorMessage(LAUNCHER_ERROR1); + return NULL; + } + ret = JLI_Snprintf(splashPath, sizeof(splashPath), "%s/lib/%s", jdkRoot, SPLASHSCREEN_SO); - if (ret >= (int) sizeof(splashPath)) { - JLI_ReportErrorMessage(LAUNCHER_ERROR3); - return NULL; - } - if (ret < 0) { - JLI_ReportErrorMessage(LAUNCHER_ERROR5); - return NULL; + if (ret >= (int) sizeof(splashPath)) { + JLI_ReportErrorMessage(LAUNCHER_ERROR3); + return NULL; + } + if (ret < 0) { + JLI_ReportErrorMessage(LAUNCHER_ERROR5); + return NULL; + } + hSplashLib = dlopen(splashPath, RTLD_LAZY | RTLD_GLOBAL); } - hSplashLib = dlopen(splashPath, RTLD_LAZY | RTLD_GLOBAL); JLI_TraceLauncher("Info: loaded %s\n", splashPath); } if (hSplashLib) { diff --git a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java index 231a5e34c62b7..59461b54a2bba 100644 --- a/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java +++ b/src/java.compiler/share/classes/javax/lang/model/SourceVersion.java @@ -77,7 +77,10 @@ public enum SourceVersion { * switch in preview, module Import Declarations in preview, * implicitly declared classes and instance main in third * preview, flexible constructor bodies in second preview) - * 24: tbd + * 24: no changes (primitive Types in Patterns, instanceof, and + * switch in second preview, module Import Declarations in second + * preview, simple source files and instance main in fourth + * preview, flexible constructor bodies in third preview) */ /** diff --git a/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java b/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java index 2f847416d216b..7ace8d90c7c2a 100644 --- a/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java +++ b/src/java.desktop/macosx/classes/com/apple/eio/FileManager.java @@ -130,11 +130,6 @@ public static int OSTypeToInt(String type) { * @since 1.4 */ public static void setFileTypeAndCreator(String filename, int type, int creator) throws IOException { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkWrite(filename); - } _setFileTypeAndCreator(filename, type, creator); } private static native void _setFileTypeAndCreator(String filename, int type, int creator) throws IOException; @@ -145,11 +140,6 @@ public static void setFileTypeAndCreator(String filename, int type, int creator) * @since 1.4 */ public static void setFileType(String filename, int type) throws IOException { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkWrite(filename); - } _setFileType(filename, type); } private static native void _setFileType(String filename, int type) throws IOException; @@ -160,11 +150,6 @@ public static void setFileType(String filename, int type) throws IOException { * @since 1.4 */ public static void setFileCreator(String filename, int creator) throws IOException { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkWrite(filename); - } _setFileCreator(filename, creator); } private static native void _setFileCreator(String filename, int creator) throws IOException; @@ -175,11 +160,6 @@ public static void setFileCreator(String filename, int creator) throws IOExcepti * @since 1.4 */ public static int getFileType(String filename) throws IOException { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(filename); - } return _getFileType(filename); } private static native int _getFileType(String filename) throws IOException; @@ -190,11 +170,6 @@ public static int getFileType(String filename) throws IOException { * @since 1.4 */ public static int getFileCreator(String filename) throws IOException { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(filename); - } return _getFileCreator(filename); } private static native int _getFileCreator(String filename) throws IOException; @@ -358,10 +333,6 @@ public static boolean moveToTrash(final File file) throws FileNotFoundException if (file == null) throw new FileNotFoundException(); final String fileName = file.getAbsolutePath(); - @SuppressWarnings("removal") - final SecurityManager security = System.getSecurityManager(); - if (security != null) security.checkDelete(fileName); - return _moveToTrash(fileName); } @@ -382,10 +353,6 @@ public static boolean revealInFinder(final File file) throws FileNotFoundExcepti if (file == null || !file.exists()) throw new FileNotFoundException(); final String fileName = file.getAbsolutePath(); - @SuppressWarnings("removal") - final SecurityManager security = System.getSecurityManager(); - if (security != null) security.checkRead(fileName); - return _revealInFinder(fileName); } diff --git a/src/java.desktop/share/classes/com/sun/beans/finder/ClassFinder.java b/src/java.desktop/share/classes/com/sun/beans/finder/ClassFinder.java index cdd022fcaf783..a8299458757e8 100644 --- a/src/java.desktop/share/classes/com/sun/beans/finder/ClassFinder.java +++ b/src/java.desktop/share/classes/com/sun/beans/finder/ClassFinder.java @@ -64,7 +64,7 @@ public static Class findClass(String name) throws ClassNotFoundException { return Class.forName(name, false, loader); } - } catch (ClassNotFoundException | SecurityException exception) { + } catch (ClassNotFoundException exception) { // use current class loader instead } return Class.forName(name); @@ -95,7 +95,7 @@ public static Class findClass(String name, ClassLoader loader) throws ClassNo if (loader != null) { try { return Class.forName(name, false, loader); - } catch (ClassNotFoundException | SecurityException exception) { + } catch (ClassNotFoundException exception) { // use default class loader instead } } diff --git a/src/java.desktop/share/classes/com/sun/beans/introspect/ClassInfo.java b/src/java.desktop/share/classes/com/sun/beans/introspect/ClassInfo.java index dce0469c7c9f3..6578011ccca73 100644 --- a/src/java.desktop/share/classes/com/sun/beans/introspect/ClassInfo.java +++ b/src/java.desktop/share/classes/com/sun/beans/introspect/ClassInfo.java @@ -45,11 +45,7 @@ public static ClassInfo get(Class type) { if (type == null) { return DEFAULT; } - try { - return CACHE.get(type); - } catch (SecurityException exception) { - return DEFAULT; - } + return CACHE.get(type); } public static void clear() { diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java index b9c2ce914d4ae..cc7a1333b643b 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/GTKStyle.java @@ -27,7 +27,6 @@ import java.awt.*; import java.lang.reflect.*; -import java.security.*; import java.util.*; import javax.swing.*; import javax.swing.plaf.*; diff --git a/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java b/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java index 4f01291c22d2a..b0afee9871a41 100644 --- a/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java +++ b/src/java.desktop/share/classes/com/sun/media/sound/AudioSynthesizer.java @@ -89,8 +89,6 @@ public interface AudioSynthesizer extends Synthesizer { * * @throws MidiUnavailableException thrown if the synthesizer cannot be * opened due to resource restrictions. - * @throws SecurityException thrown if the synthesizer cannot be - * opened due to security restrictions. * * @see #close * @see #isOpen @@ -119,8 +117,6 @@ void open(SourceDataLine line, Map info) * * @throws MidiUnavailableException thrown if the synthesizer cannot be * opened due to resource restrictions. - * @throws SecurityException thrown if the synthesizer cannot be - * opened due to security restrictions. * * @see #close * @see #isOpen diff --git a/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java b/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java index 4c33416e4709a..6aaddb3e484c9 100644 --- a/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java +++ b/src/java.desktop/share/classes/com/sun/media/sound/SoftSynthesizer.java @@ -1111,7 +1111,7 @@ public void open(SourceDataLine line, Map info) throws MidiUnava line = testline; } else { // can throw LineUnavailableException, - // IllegalArgumentException, SecurityException + // IllegalArgumentException line = AudioSystem.getSourceDataLine(getFormat()); } } @@ -1122,7 +1122,7 @@ public void open(SourceDataLine line, Map info) throws MidiUnava int bufferSize = getFormat().getFrameSize() * (int)(getFormat().getFrameRate() * (latency/1000000f)); // can throw LineUnavailableException, - // IllegalArgumentException, SecurityException + // IllegalArgumentException line.open(getFormat(), bufferSize); // Remember that we opened that line @@ -1166,8 +1166,7 @@ public void open(SourceDataLine line, Map info) throws MidiUnava weakstream.sourceDataLine = sourceDataLine; } - } catch (final LineUnavailableException | SecurityException - | IllegalArgumentException e) { + } catch (final LineUnavailableException | IllegalArgumentException e) { if (isOpen()) { close(); } diff --git a/src/java.desktop/share/classes/java/awt/Font.java b/src/java.desktop/share/classes/java/awt/Font.java index 4de614737077e..bbd6ee83e51b7 100644 --- a/src/java.desktop/share/classes/java/awt/Font.java +++ b/src/java.desktop/share/classes/java/awt/Font.java @@ -893,23 +893,8 @@ public static Font getFont(Map attributes) { * If a thread can create temp files anyway, no point in counting * font bytes. */ - @SuppressWarnings("removal") private static boolean hasTempPermission() { - - if (System.getSecurityManager() == null) { - return true; - } - File f = null; - boolean hasPerm = false; - try { - f = Files.createTempFile("+~JT", ".tmp").toFile(); - f.delete(); - f = null; - hasPerm = true; - } catch (Throwable t) { - /* inc. any kind of SecurityException */ - } - return hasPerm; + return true; } @@ -1757,11 +1742,7 @@ public static Font decode(String str) { * @see #decode(String) */ public static Font getFont(String nm, Font font) { - String str = null; - try { - str =System.getProperty(nm); - } catch(SecurityException e) { - } + String str = System.getProperty(nm); if (str == null) { return font; } diff --git a/src/java.desktop/share/classes/java/awt/Window.java b/src/java.desktop/share/classes/java/awt/Window.java index 9d12b0cd3c0f0..4e576f3dc9ea9 100644 --- a/src/java.desktop/share/classes/java/awt/Window.java +++ b/src/java.desktop/share/classes/java/awt/Window.java @@ -598,10 +598,7 @@ private void ownedInit(Window owner) { if (owner != null) { owner.addOwnedWindow(weakThis); if (owner.isAlwaysOnTop()) { - try { - setAlwaysOnTop(true); - } catch (SecurityException ignore) { - } + setAlwaysOnTop(true); } } @@ -1305,10 +1302,7 @@ public void toBack() { // to insure that it cannot be overridden by client subclasses. final void toBack_NoClientCode() { if(isAlwaysOnTop()) { - try { - setAlwaysOnTop(false); - }catch(SecurityException e) { - } + setAlwaysOnTop(false); } if (visible) { WindowPeer peer = (WindowPeer)this.peer; @@ -2191,10 +2185,7 @@ private void setOwnedWindowsAlwaysOnTop(boolean alwaysOnTop) { for (WeakReference ref : ownedWindowArray) { Window window = ref.get(); if (window != null) { - try { - window.setAlwaysOnTop(alwaysOnTop); - } catch (SecurityException ignore) { - } + window.setAlwaysOnTop(alwaysOnTop); } } } @@ -3032,7 +3023,7 @@ private void readObject(ObjectInputStream s) setModalExclusionType(et); // since 6.0 boolean aot = f.get("alwaysOnTop", false); if(aot) { - setAlwaysOnTop(aot); // since 1.5; subject to permission check + setAlwaysOnTop(aot); } shape = (Shape)f.get("shape", null); opacity = (Float)f.get("opacity", 1.0f); diff --git a/src/java.desktop/share/classes/java/awt/print/PrinterJob.java b/src/java.desktop/share/classes/java/awt/print/PrinterJob.java index 0d2d2d76b5343..b31cf32094cc3 100644 --- a/src/java.desktop/share/classes/java/awt/print/PrinterJob.java +++ b/src/java.desktop/share/classes/java/awt/print/PrinterJob.java @@ -64,11 +64,6 @@ public abstract class PrinterJob { * @return a new {@code PrinterJob}. */ public static PrinterJob getPrinterJob() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } return sun.print.PlatformPrinterJobProxy.getPrinterJob(); } diff --git a/src/java.desktop/share/classes/java/beans/Beans.java b/src/java.desktop/share/classes/java/beans/Beans.java index e35a751a42ef3..5320d12ecd2a3 100644 --- a/src/java.desktop/share/classes/java/beans/Beans.java +++ b/src/java.desktop/share/classes/java/beans/Beans.java @@ -189,12 +189,7 @@ public static Object instantiate(ClassLoader cls, String beanName, // Note that calls on the system class loader will // look in the bootstrap class loader first. if (cls == null) { - try { - cls = ClassLoader.getSystemClassLoader(); - } catch (SecurityException ex) { - // We're not allowed to access the system class loader. - // Drop through. - } + cls = ClassLoader.getSystemClassLoader(); } // Try to find a serialized object with this name @@ -438,11 +433,6 @@ public static boolean isGuiAvailable() { */ public static void setDesignTime(boolean isDesignTime) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } ThreadGroupContext.getContext().setDesignTime(isDesignTime); } @@ -454,11 +444,6 @@ public static void setDesignTime(boolean isDesignTime) { */ public static void setGuiAvailable(boolean isGuiAvailable) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } ThreadGroupContext.getContext().setGuiAvailable(isGuiAvailable); } } diff --git a/src/java.desktop/share/classes/java/beans/Introspector.java b/src/java.desktop/share/classes/java/beans/Introspector.java index 7dfd2e60a8e47..c526190808e1e 100644 --- a/src/java.desktop/share/classes/java/beans/Introspector.java +++ b/src/java.desktop/share/classes/java/beans/Introspector.java @@ -335,11 +335,6 @@ public static String[] getBeanInfoSearchPath() { */ public static void setBeanInfoSearchPath(String[] path) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } ThreadGroupContext.getContext().getBeanInfoFinder().setPackages(path); } diff --git a/src/java.desktop/share/classes/java/beans/PropertyEditorManager.java b/src/java.desktop/share/classes/java/beans/PropertyEditorManager.java index d6cb76e058c74..b776e3f3615cd 100644 --- a/src/java.desktop/share/classes/java/beans/PropertyEditorManager.java +++ b/src/java.desktop/share/classes/java/beans/PropertyEditorManager.java @@ -71,11 +71,6 @@ public PropertyEditorManager() {} * @param editorClass the class object of the editor class */ public static void registerEditor(Class targetType, Class editorClass) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } ThreadGroupContext.getContext().getPropertyEditorFinder().register(targetType, editorClass); } @@ -109,11 +104,6 @@ public static String[] getEditorSearchPath() { * @param path Array of package names. */ public static void setEditorSearchPath(String[] path) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm != null) { - sm.checkPropertiesAccess(); - } ThreadGroupContext.getContext().getPropertyEditorFinder().setPackages(path); } } diff --git a/src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java b/src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java index 1ea7146ae4ae3..09fa1eb202b6c 100644 --- a/src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java +++ b/src/java.desktop/share/classes/javax/imageio/spi/IIORegistry.java @@ -162,7 +162,6 @@ private void registerStandardSpis() { * @see javax.imageio.ImageIO#scanForPlugins * @see ClassLoader#getResources */ - @SuppressWarnings("removal") public void registerApplicationClasspathSpis() { // FIX: load only from application classpath @@ -175,22 +174,8 @@ public void registerApplicationClasspathSpis() { Iterator riter = ServiceLoader.load(c, loader).iterator(); while (riter.hasNext()) { - try { - // Note that the next() call is required to be inside - // the try/catch block; see 6342404. - IIOServiceProvider r = riter.next(); - registerServiceProvider(r); - } catch (ServiceConfigurationError err) { - if (System.getSecurityManager() != null) { - // In the applet case, we will catch the error so - // registration of other plugins can proceed - err.printStackTrace(); - } else { - // In the application case, we will throw the - // error to indicate app/system misconfiguration - throw err; - } - } + IIOServiceProvider r = riter.next(); + registerServiceProvider(r); } } } diff --git a/src/java.desktop/share/classes/javax/print/PrintServiceLookup.java b/src/java.desktop/share/classes/javax/print/PrintServiceLookup.java index 29c7b420f7c51..15a7fbbaa00fd 100644 --- a/src/java.desktop/share/classes/javax/print/PrintServiceLookup.java +++ b/src/java.desktop/share/classes/javax/print/PrintServiceLookup.java @@ -393,16 +393,7 @@ private static ArrayList getServices(DocFlavor flavor, /* * add any directly registered services */ - ArrayList registeredServices = null; - try { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } - registeredServices = getRegisteredServices(); - } catch (SecurityException se) { - } + ArrayList registeredServices = getRegisteredServices(); if (registeredServices != null) { PrintService[] services = registeredServices.toArray( new PrintService[registeredServices.size()]); @@ -458,16 +449,7 @@ private static ArrayList getMultiDocServices(DocFlavor[] f /* * add any directly registered services */ - ArrayList registeredServices = null; - try { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } - registeredServices = getRegisteredServices(); - } catch (Exception e) { - } + ArrayList registeredServices = getRegisteredServices(); if (registeredServices != null) { PrintService[] services = registeredServices.toArray(new PrintService[registeredServices.size()]); diff --git a/src/java.desktop/share/classes/javax/print/ServiceUI.java b/src/java.desktop/share/classes/javax/print/ServiceUI.java index 873d4448ffcaa..bb25207d6a1d6 100644 --- a/src/java.desktop/share/classes/javax/print/ServiceUI.java +++ b/src/java.desktop/share/classes/javax/print/ServiceUI.java @@ -203,10 +203,7 @@ public static PrintService printDialog(GraphicsConfiguration gc, flavor, attributes, owner); if (setOnTop) { - try { - dialog.setAlwaysOnTop(true); - } catch (SecurityException e) { - } + dialog.setAlwaysOnTop(true); } Rectangle dlgBounds = dialog.getBounds(); diff --git a/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java b/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java index c353fb7f390a2..055f3f1066b6f 100644 --- a/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java +++ b/src/java.desktop/share/classes/javax/sound/midi/Synthesizer.java @@ -345,10 +345,8 @@ public interface Synthesizer extends MidiDevice { * * @throws MidiUnavailableException if the receiver is cannot be opened, * usually because the MIDI device is in use by another application - * @throws SecurityException if the receiver cannot be opened due to - * security restrictions */ - // abstract void open() throws MidiUnavailableException, SecurityException; + // abstract void open() throws MidiUnavailableException; /** * Closes the receiver. diff --git a/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java b/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java index a0750a13bfaa2..628c8f6e68c06 100644 --- a/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java +++ b/src/java.desktop/share/classes/javax/swing/DefaultListCellRenderer.java @@ -82,7 +82,6 @@ public class DefaultListCellRenderer extends JLabel * getListCellRendererComponent method and set the border * of the returned component directly. */ - private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); /** * No focus border @@ -100,20 +99,14 @@ public DefaultListCellRenderer() { setName("List.cellRenderer"); } - @SuppressWarnings("removal") private Border getNoFocusBorder() { Border border = DefaultLookup.getBorder(this, ui, "List.cellNoFocusBorder"); - if (System.getSecurityManager() != null) { - if (border != null) return border; - return SAFE_NO_FOCUS_BORDER; - } else { - if (border != null && - (noFocusBorder == null || - noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) { - return border; - } - return noFocusBorder; + if (border != null && + (noFocusBorder == null || + noFocusBorder == DEFAULT_NO_FOCUS_BORDER)) { + return border; } + return noFocusBorder; } public Component getListCellRendererComponent( diff --git a/src/java.desktop/share/classes/javax/swing/FocusManager.java b/src/java.desktop/share/classes/javax/swing/FocusManager.java index 9aa923efafbda..5e9ca85afcefd 100644 --- a/src/java.desktop/share/classes/javax/swing/FocusManager.java +++ b/src/java.desktop/share/classes/javax/swing/FocusManager.java @@ -99,10 +99,6 @@ public static FocusManager getCurrentManager() { * @see java.awt.DefaultKeyboardFocusManager */ public static void setCurrentManager(FocusManager aFocusManager) { - // Note: This method is not backward-compatible with 1.3 and earlier - // releases. It now throws a SecurityException in an applet, whereas - // in previous releases, it did not. This issue was discussed at - // length, and ultimately approved by Hans. KeyboardFocusManager toSet = (aFocusManager instanceof DelegatingDefaultFocusManager) ? ((DelegatingDefaultFocusManager)aFocusManager).getDelegate() diff --git a/src/java.desktop/share/classes/javax/swing/JFrame.java b/src/java.desktop/share/classes/javax/swing/JFrame.java index 1e4c9a1bf761e..8bde7e18f03b7 100644 --- a/src/java.desktop/share/classes/javax/swing/JFrame.java +++ b/src/java.desktop/share/classes/javax/swing/JFrame.java @@ -380,13 +380,6 @@ public void setDefaultCloseOperation(int operation) { + " DISPOSE_ON_CLOSE, or EXIT_ON_CLOSE"); } - if (operation == EXIT_ON_CLOSE) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkExit(0); - } - } if (this.defaultCloseOperation != operation) { int oldValue = this.defaultCloseOperation; this.defaultCloseOperation = operation; diff --git a/src/java.desktop/share/classes/javax/swing/JInternalFrame.java b/src/java.desktop/share/classes/javax/swing/JInternalFrame.java index e7d0eec76fb3c..2f4ab1dcc1d8c 100644 --- a/src/java.desktop/share/classes/javax/swing/JInternalFrame.java +++ b/src/java.desktop/share/classes/javax/swing/JInternalFrame.java @@ -1781,12 +1781,8 @@ public void dispose() { isClosed = true; } fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED); - try { - java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( - new sun.awt.UngrabEvent(this)); - } catch (SecurityException e) { - this.dispatchEvent(new sun.awt.UngrabEvent(this)); - } + java.awt.Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent( + new sun.awt.UngrabEvent(this)); } /** diff --git a/src/java.desktop/share/classes/javax/swing/JTable.java b/src/java.desktop/share/classes/javax/swing/JTable.java index 0ff490d45eac9..77d787172cf61 100644 --- a/src/java.desktop/share/classes/javax/swing/JTable.java +++ b/src/java.desktop/share/classes/javax/swing/JTable.java @@ -5560,7 +5560,6 @@ public boolean stopCellEditing() { return super.stopCellEditing(); } - SwingUtilities2.checkAccess(constructor.getModifiers()); value = constructor.newInstance(new Object[]{s}); } catch (Exception e) { @@ -5584,7 +5583,6 @@ public Component getTableCellEditorComponent(JTable table, Object value, if (type == Object.class) { type = String.class; } - SwingUtilities2.checkAccess(type.getModifiers()); constructor = type.getConstructor(argTypes); } catch (Exception e) { @@ -6366,9 +6364,6 @@ public boolean print(PrintMode printMode, } } - // Get a PrinterJob. - // Do this before anything with side-effects since it may throw a - // security exception - in which case we don't want to do anything else. final PrinterJob job = PrinterJob.getPrinterJob(); if (isEditing()) { diff --git a/src/java.desktop/share/classes/javax/swing/Popup.java b/src/java.desktop/share/classes/javax/swing/Popup.java index acc69f82fe3e8..3d4329915bba2 100644 --- a/src/java.desktop/share/classes/javax/swing/Popup.java +++ b/src/java.desktop/share/classes/javax/swing/Popup.java @@ -242,15 +242,7 @@ static class HeavyWeightWindow extends JWindow implements ModalExclude { // Popups are typically transient and most likely won't benefit // from true double buffering. Turn it off here. getRootPane().setUseTrueDoubleBuffering(false); - // Try to set "always-on-top" for the popup window. - // Applets usually don't have sufficient permissions to do it. - // In this case simply ignore the exception. - try { - setAlwaysOnTop(true); - } catch (SecurityException se) { - // setAlwaysOnTop is restricted, - // the exception is ignored - } + setAlwaysOnTop(true); } public void update(Graphics g) { diff --git a/src/java.desktop/share/classes/javax/swing/TimerQueue.java b/src/java.desktop/share/classes/javax/swing/TimerQueue.java index 249593caa7e02..44dc0c6e6af07 100644 --- a/src/java.desktop/share/classes/javax/swing/TimerQueue.java +++ b/src/java.desktop/share/classes/javax/swing/TimerQueue.java @@ -179,7 +179,6 @@ public void run() { // Allow run other threads on systems without kernel threads timer.getLock().newCondition().awaitNanos(1); - } catch (SecurityException ignore) { } finally { timer.getLock().unlock(); } diff --git a/src/java.desktop/share/classes/javax/swing/UIDefaults.java b/src/java.desktop/share/classes/javax/swing/UIDefaults.java index 53eb870d3e61d..13bd6e723b4f6 100644 --- a/src/java.desktop/share/classes/javax/swing/UIDefaults.java +++ b/src/java.desktop/share/classes/javax/swing/UIDefaults.java @@ -1141,7 +1141,6 @@ public Object createValue(final UIDefaults table) { } } c = Class.forName(className, true, (ClassLoader)cl); - SwingUtilities2.checkAccess(c.getModifiers()); if (methodName != null) { Class[] types = getClassArray(args); Method m = c.getMethod(methodName, types); @@ -1149,7 +1148,6 @@ public Object createValue(final UIDefaults table) { } else { Class[] types = getClassArray(args); Constructor constructor = c.getConstructor(types); - SwingUtilities2.checkAccess(constructor.getModifiers()); return constructor.newInstance(args); } } catch(Exception e) { diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxRenderer.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxRenderer.java index 06539e15ff131..a4c95f02c8667 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxRenderer.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicComboBoxRenderer.java @@ -57,7 +57,6 @@ public class BasicComboBoxRenderer extends JLabel * the setBorder method. */ protected static Border noFocusBorder = new EmptyBorder(1, 1, 1, 1); - private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); /** * Constructs a new instance of {@code BasicComboBoxRenderer}. @@ -68,13 +67,8 @@ public BasicComboBoxRenderer() { setBorder(getNoFocusBorder()); } - @SuppressWarnings("removal") private static Border getNoFocusBorder() { - if (System.getSecurityManager() != null) { - return SAFE_NO_FOCUS_BORDER; - } else { - return noFocusBorder; - } + return noFocusBorder; } public Dimension getPreferredSize() { diff --git a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java index 68847cb1ebb99..fab31c78d740d 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicLabelUI.java @@ -66,7 +66,6 @@ public class BasicLabelUI extends LabelUI implements PropertyChangeListener * name in defaults table under the key "LabelUI". */ protected static BasicLabelUI labelUI = new BasicLabelUI(); - private static final Object BASIC_LABEL_UI_KEY = new Object(); private Rectangle paintIconR = new Rectangle(); private Rectangle paintTextR = new Rectangle(); @@ -466,18 +465,7 @@ protected void uninstallKeyboardActions(JLabel c) { * @param c a component * @return an instance of {@code BasicLabelUI} */ - @SuppressWarnings("removal") public static ComponentUI createUI(JComponent c) { - if (System.getSecurityManager() != null) { - AppContext appContext = AppContext.getAppContext(); - BasicLabelUI safeBasicLabelUI = - (BasicLabelUI) appContext.get(BASIC_LABEL_UI_KEY); - if (safeBasicLabelUI == null) { - safeBasicLabelUI = new BasicLabelUI(); - appContext.put(BASIC_LABEL_UI_KEY, safeBasicLabelUI); - } - return safeBasicLabelUI; - } return labelUI; } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java index 3578f2fc2109e..d3b7b4a836c1f 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalLabelUI.java @@ -54,8 +54,6 @@ public class MetalLabelUI extends BasicLabelUI */ protected static MetalLabelUI metalLabelUI = new MetalLabelUI(); - private static final Object METAL_LABEL_UI_KEY = new Object(); - /** * Constructs a {@code MetalLabelUI}. */ @@ -67,18 +65,7 @@ public MetalLabelUI() {} * @param c a component * @return an instance of {@code MetalLabelUI} */ - @SuppressWarnings("removal") public static ComponentUI createUI(JComponent c) { - if (System.getSecurityManager() != null) { - AppContext appContext = AppContext.getAppContext(); - MetalLabelUI safeMetalLabelUI = - (MetalLabelUI) appContext.get(METAL_LABEL_UI_KEY); - if (safeMetalLabelUI == null) { - safeMetalLabelUI = new MetalLabelUI(); - appContext.put(METAL_LABEL_UI_KEY, safeMetalLabelUI); - } - return safeMetalLabelUI; - } return metalLabelUI; } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSliderUI.java b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSliderUI.java index c31ee81c729e6..bdded64b788fd 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSliderUI.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/metal/MetalSliderUI.java @@ -105,9 +105,6 @@ public class MetalSliderUI extends BasicSliderUI { */ protected static Icon vertThumbIcon; - private static Icon SAFE_HORIZ_THUMB_ICON; - private static Icon SAFE_VERT_THUMB_ICON; - /** * Property for {@code JSlider.isFilled}. */ @@ -130,31 +127,19 @@ public MetalSliderUI() { super( null ); } - @SuppressWarnings("removal") private static Icon getHorizThumbIcon() { - if (System.getSecurityManager() != null) { - return SAFE_HORIZ_THUMB_ICON; - } else { - return horizThumbIcon; - } + return horizThumbIcon; } - @SuppressWarnings("removal") private static Icon getVertThumbIcon() { - if (System.getSecurityManager() != null) { - return SAFE_VERT_THUMB_ICON; - } else { - return vertThumbIcon; - } + return vertThumbIcon; } public void installUI( JComponent c ) { trackWidth = ((Integer)UIManager.get( "Slider.trackWidth" )).intValue(); tickLength = safeLength = ((Integer)UIManager.get( "Slider.majorTickLength" )).intValue(); - horizThumbIcon = SAFE_HORIZ_THUMB_ICON = - UIManager.getIcon( "Slider.horizontalThumbIcon" ); - vertThumbIcon = SAFE_VERT_THUMB_ICON = - UIManager.getIcon( "Slider.verticalThumbIcon" ); + horizThumbIcon = UIManager.getIcon( "Slider.horizontalThumbIcon" ); + vertThumbIcon = UIManager.getIcon( "Slider.verticalThumbIcon" ); super.installUI( c ); diff --git a/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java b/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java index 28e324166b598..8b4d7bec2c048 100644 --- a/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java +++ b/src/java.desktop/share/classes/javax/swing/table/DefaultTableCellRenderer.java @@ -93,7 +93,6 @@ public class DefaultTableCellRenderer extends JLabel * getTableCellRendererComponent method and set the border * of the returned component directly. */ - private static final Border SAFE_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); private static final Border DEFAULT_NO_FOCUS_BORDER = new EmptyBorder(1, 1, 1, 1); /** * A border without focus. @@ -117,13 +116,9 @@ public DefaultTableCellRenderer() { setName("Table.cellRenderer"); } - @SuppressWarnings("removal") private Border getNoFocusBorder() { Border border = DefaultLookup.getBorder(this, ui, "Table.cellNoFocusBorder"); - if (System.getSecurityManager() != null) { - if (border != null) return border; - return SAFE_NO_FOCUS_BORDER; - } else if (border != null) { + if (border != null) { if (noFocusBorder == null || noFocusBorder == DEFAULT_NO_FOCUS_BORDER) { return border; } diff --git a/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java b/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java index bed18fc3fc3dd..81edfd1f5043a 100644 --- a/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java +++ b/src/java.desktop/share/classes/javax/swing/text/DefaultCaret.java @@ -1431,8 +1431,6 @@ private Clipboard getSystemSelection() { return component.getToolkit().getSystemSelection(); } catch (HeadlessException he) { // do nothing... there is no system clipboard - } catch (SecurityException se) { - // do nothing... there is no allowed system clipboard } return null; } diff --git a/src/java.desktop/share/classes/javax/swing/text/DefaultFormatter.java b/src/java.desktop/share/classes/javax/swing/text/DefaultFormatter.java index 38ea1cda125ba..a0f6a963926ae 100644 --- a/src/java.desktop/share/classes/javax/swing/text/DefaultFormatter.java +++ b/src/java.desktop/share/classes/javax/swing/text/DefaultFormatter.java @@ -247,7 +247,6 @@ public Object stringToValue(String string) throws ParseException { Constructor cons; try { - SwingUtilities2.checkAccess(vc.getModifiers()); cons = vc.getConstructor(new Class[]{String.class}); } catch (NoSuchMethodException nsme) { @@ -256,7 +255,6 @@ public Object stringToValue(String string) throws ParseException { if (cons != null) { try { - SwingUtilities2.checkAccess(cons.getModifiers()); return cons.newInstance(new Object[] { string }); } catch (Throwable ex) { throw new ParseException("Error creating instance", 0); diff --git a/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java b/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java index f3e9a8d2a58d1..8abc78e5ade19 100644 --- a/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java +++ b/src/java.desktop/share/classes/javax/swing/text/NumberFormatter.java @@ -436,11 +436,9 @@ private Object toggleSign(boolean positive) throws ParseException { valueClass = value.getClass(); } try { - SwingUtilities2.checkAccess(valueClass.getModifiers()); Constructor cons = valueClass.getConstructor( new Class[] { String.class }); if (cons != null) { - SwingUtilities2.checkAccess(cons.getModifiers()); return cons.newInstance(new Object[]{string}); } } catch (Throwable ex) { } diff --git a/src/java.desktop/share/classes/javax/swing/text/html/CSS.java b/src/java.desktop/share/classes/javax/swing/text/html/CSS.java index 8239565a53f21..ef422a8d4e957 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/CSS.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/CSS.java @@ -38,6 +38,7 @@ import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; +import java.util.Map; import java.util.Objects; import javax.swing.ImageIcon; @@ -1089,7 +1090,7 @@ private static int getTableBorder(AttributeSet tableAttr) { * Therefore, the value associated with each HTML.Attribute. * key ends up being an array of CSS.Attribute.* objects. */ - private static final Hashtable htmlAttrToCssAttrMap = new Hashtable(20); + private static final Map htmlAttrToCssAttrMap; /** * The hashtable and static initialization that follows sets @@ -1113,53 +1114,57 @@ private static int getTableBorder(AttributeSet tableAttr) { valueMap.put(Value.allValues[i].toString(), Value.allValues[i]); } - - htmlAttrToCssAttrMap.put(HTML.Attribute.COLOR, - new CSS.Attribute[]{CSS.Attribute.COLOR}); - htmlAttrToCssAttrMap.put(HTML.Attribute.TEXT, - new CSS.Attribute[]{CSS.Attribute.COLOR}); - htmlAttrToCssAttrMap.put(HTML.Attribute.CLEAR, - new CSS.Attribute[]{CSS.Attribute.CLEAR}); - htmlAttrToCssAttrMap.put(HTML.Attribute.BACKGROUND, - new CSS.Attribute[]{CSS.Attribute.BACKGROUND_IMAGE}); - htmlAttrToCssAttrMap.put(HTML.Attribute.BGCOLOR, - new CSS.Attribute[]{CSS.Attribute.BACKGROUND_COLOR}); - htmlAttrToCssAttrMap.put(HTML.Attribute.WIDTH, - new CSS.Attribute[]{CSS.Attribute.WIDTH}); - htmlAttrToCssAttrMap.put(HTML.Attribute.HEIGHT, - new CSS.Attribute[]{CSS.Attribute.HEIGHT}); - htmlAttrToCssAttrMap.put(HTML.Attribute.BORDER, - new CSS.Attribute[]{CSS.Attribute.BORDER_TOP_WIDTH, CSS.Attribute.BORDER_RIGHT_WIDTH, CSS.Attribute.BORDER_BOTTOM_WIDTH, CSS.Attribute.BORDER_LEFT_WIDTH}); - htmlAttrToCssAttrMap.put(HTML.Attribute.CELLPADDING, - new CSS.Attribute[]{CSS.Attribute.PADDING}); - htmlAttrToCssAttrMap.put(HTML.Attribute.CELLSPACING, - new CSS.Attribute[]{CSS.Attribute.BORDER_SPACING}); - htmlAttrToCssAttrMap.put(HTML.Attribute.MARGINWIDTH, - new CSS.Attribute[]{CSS.Attribute.MARGIN_LEFT, - CSS.Attribute.MARGIN_RIGHT}); - htmlAttrToCssAttrMap.put(HTML.Attribute.MARGINHEIGHT, - new CSS.Attribute[]{CSS.Attribute.MARGIN_TOP, - CSS.Attribute.MARGIN_BOTTOM}); - htmlAttrToCssAttrMap.put(HTML.Attribute.HSPACE, - new CSS.Attribute[]{CSS.Attribute.PADDING_LEFT, - CSS.Attribute.PADDING_RIGHT}); - htmlAttrToCssAttrMap.put(HTML.Attribute.VSPACE, - new CSS.Attribute[]{CSS.Attribute.PADDING_BOTTOM, - CSS.Attribute.PADDING_TOP}); - htmlAttrToCssAttrMap.put(HTML.Attribute.FACE, - new CSS.Attribute[]{CSS.Attribute.FONT_FAMILY}); - htmlAttrToCssAttrMap.put(HTML.Attribute.SIZE, - new CSS.Attribute[]{CSS.Attribute.FONT_SIZE}); - htmlAttrToCssAttrMap.put(HTML.Attribute.VALIGN, - new CSS.Attribute[]{CSS.Attribute.VERTICAL_ALIGN}); - htmlAttrToCssAttrMap.put(HTML.Attribute.ALIGN, - new CSS.Attribute[]{CSS.Attribute.VERTICAL_ALIGN, - CSS.Attribute.TEXT_ALIGN, - CSS.Attribute.FLOAT}); - htmlAttrToCssAttrMap.put(HTML.Attribute.TYPE, - new CSS.Attribute[]{CSS.Attribute.LIST_STYLE_TYPE}); - htmlAttrToCssAttrMap.put(HTML.Attribute.NOWRAP, - new CSS.Attribute[]{CSS.Attribute.WHITE_SPACE}); + htmlAttrToCssAttrMap = Map.ofEntries( + Map.entry(HTML.Attribute.COLOR, + new CSS.Attribute[]{CSS.Attribute.COLOR}), + Map.entry(HTML.Attribute.TEXT, + new CSS.Attribute[]{CSS.Attribute.COLOR}), + Map.entry(HTML.Attribute.CLEAR, + new CSS.Attribute[]{CSS.Attribute.CLEAR}), + Map.entry(HTML.Attribute.BACKGROUND, + new CSS.Attribute[]{CSS.Attribute.BACKGROUND_IMAGE}), + Map.entry(HTML.Attribute.BGCOLOR, + new CSS.Attribute[]{CSS.Attribute.BACKGROUND_COLOR}), + Map.entry(HTML.Attribute.WIDTH, + new CSS.Attribute[]{CSS.Attribute.WIDTH}), + Map.entry(HTML.Attribute.HEIGHT, + new CSS.Attribute[]{CSS.Attribute.HEIGHT}), + Map.entry(HTML.Attribute.BORDER, + new CSS.Attribute[]{CSS.Attribute.BORDER_TOP_WIDTH, + CSS.Attribute.BORDER_RIGHT_WIDTH, + CSS.Attribute.BORDER_BOTTOM_WIDTH, + CSS.Attribute.BORDER_LEFT_WIDTH}), + Map.entry(HTML.Attribute.CELLPADDING, + new CSS.Attribute[]{CSS.Attribute.PADDING}), + Map.entry(HTML.Attribute.CELLSPACING, + new CSS.Attribute[]{CSS.Attribute.BORDER_SPACING}), + Map.entry(HTML.Attribute.MARGINWIDTH, + new CSS.Attribute[]{CSS.Attribute.MARGIN_LEFT, + CSS.Attribute.MARGIN_RIGHT}), + Map.entry(HTML.Attribute.MARGINHEIGHT, + new CSS.Attribute[]{CSS.Attribute.MARGIN_TOP, + CSS.Attribute.MARGIN_BOTTOM}), + Map.entry(HTML.Attribute.HSPACE, + new CSS.Attribute[]{CSS.Attribute.PADDING_LEFT, + CSS.Attribute.PADDING_RIGHT}), + Map.entry(HTML.Attribute.VSPACE, + new CSS.Attribute[]{CSS.Attribute.PADDING_BOTTOM, + CSS.Attribute.PADDING_TOP}), + Map.entry(HTML.Attribute.FACE, + new CSS.Attribute[]{CSS.Attribute.FONT_FAMILY}), + Map.entry(HTML.Attribute.SIZE, + new CSS.Attribute[]{CSS.Attribute.FONT_SIZE}), + Map.entry(HTML.Attribute.VALIGN, + new CSS.Attribute[]{CSS.Attribute.VERTICAL_ALIGN}), + Map.entry(HTML.Attribute.ALIGN, + new CSS.Attribute[]{CSS.Attribute.VERTICAL_ALIGN, + CSS.Attribute.TEXT_ALIGN, + CSS.Attribute.FLOAT}), + Map.entry(HTML.Attribute.TYPE, + new CSS.Attribute[]{CSS.Attribute.LIST_STYLE_TYPE}), + Map.entry(HTML.Attribute.NOWRAP, + new CSS.Attribute[]{CSS.Attribute.WHITE_SPACE}) + ); // initialize StyleConstants mapping styleConstantToCssMap.put(StyleConstants.FontFamily, diff --git a/src/java.desktop/share/classes/sun/awt/OSInfo.java b/src/java.desktop/share/classes/sun/awt/OSInfo.java index 509bac362f22d..b278032c45fc8 100644 --- a/src/java.desktop/share/classes/sun/awt/OSInfo.java +++ b/src/java.desktop/share/classes/sun/awt/OSInfo.java @@ -64,7 +64,7 @@ and so the method getWindowsVersion() will return the constant for known OS. private static final Map windowsVersionMap = new HashMap(); // Cache the OSType for getOSType() - private static final OSType CURRENT_OSTYPE = getOSTypeImpl(); // No DoPriv needed + private static final OSType CURRENT_OSTYPE = getOSTypeImpl(); static { @@ -101,7 +101,7 @@ private static OSType getOSTypeImpl() { }; } - public static WindowsVersion getWindowsVersion() throws SecurityException { + public static WindowsVersion getWindowsVersion() { String osVersion = System.getProperty(OS_VERSION); if (osVersion == null) { diff --git a/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/src/java.desktop/share/classes/sun/awt/SunToolkit.java index b630148f809e8..9bf805a580899 100644 --- a/src/java.desktop/share/classes/sun/awt/SunToolkit.java +++ b/src/java.desktop/share/classes/sun/awt/SunToolkit.java @@ -701,7 +701,6 @@ static Image getImageFromHash(Toolkit tk, URL url) { static Image getImageFromHash(Toolkit tk, String filename) { - checkPermissions(filename); synchronized (fileImgCache) { Image img = (Image)fileImgCache.get(filename); if (img == null) { @@ -757,7 +756,6 @@ protected Image getImageWithResolutionVariant(URL url, @Override public Image createImage(String filename) { - checkPermissions(filename); return createImage(new FileImageSource(filename)); } @@ -870,7 +868,6 @@ protected static boolean imageCached(URL url) { protected static boolean imageExists(String filename) { if (filename != null) { - checkPermissions(filename); return new File(filename).exists(); } return false; @@ -888,14 +885,6 @@ protected static boolean imageExists(URL url) { return false; } - private static void checkPermissions(String filename) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(filename); - } - } - /** * Scans {@code imageList} for best-looking image of specified dimensions. * Image can be scaled and/or padded with transparency. diff --git a/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java b/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java index ee0f32d91c0ee..af1b7c74b59a0 100644 --- a/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java +++ b/src/java.desktop/share/classes/sun/awt/shell/ShellFolder.java @@ -232,7 +232,7 @@ public Image getIcon(int width, int height) { managerClass = null; } // swallow the exceptions below and use default shell folder - } catch (ClassNotFoundException | SecurityException | NullPointerException e) { + } catch (ClassNotFoundException | NullPointerException e) { } if (managerClass == null) { diff --git a/src/java.desktop/share/classes/sun/awt/shell/ShellFolderManager.java b/src/java.desktop/share/classes/sun/awt/shell/ShellFolderManager.java index 868a5bb3910b6..10d0b53928519 100644 --- a/src/java.desktop/share/classes/sun/awt/shell/ShellFolderManager.java +++ b/src/java.desktop/share/classes/sun/awt/shell/ShellFolderManager.java @@ -28,8 +28,6 @@ import java.io.File; import java.io.FileNotFoundException; import java.util.concurrent.Callable; -import java.util.stream.Stream; - /** * @author Michael Martak @@ -70,13 +68,13 @@ public Object get(String key) { // Return the default shellfolder for a new filechooser File homeDir = new File(System.getProperty("user.home")); try { - return checkFile(createShellFolder(homeDir)); + return createShellFolder(homeDir); } catch (FileNotFoundException e) { - return checkFile(homeDir); + return homeDir; } } else if (key.equals("roots")) { // The root(s) of the displayable hierarchy - return checkFiles(File.listRoots()); + return File.listRoots(); } else if (key.equals("fileChooserComboBoxFolders")) { // Return an array of ShellFolders representing the list to // show by default in the file chooser's combobox @@ -86,44 +84,12 @@ public Object get(String key) { // folders, such as Desktop, Documents, History, Network, Home, etc. // This is used in the shortcut panel of the filechooser on Windows 2000 // and Windows Me - return checkFiles(new File[] { (File)get("fileChooserDefaultFolder") }); + return new File[] { (File)get("fileChooserDefaultFolder") }; } return null; } - private static File checkFile(File f) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - return (sm == null || f == null) ? f : checkFile(f, sm); - } - - private static File checkFile(File f, @SuppressWarnings("removal") SecurityManager sm) { - try { - sm.checkRead(f.getPath()); - if (f instanceof ShellFolder) { - ShellFolder sf = (ShellFolder)f; - if (sf.isLink()) { - sm.checkRead(sf.getLinkLocation().getPath()); - } - } - return f; - } catch (SecurityException | FileNotFoundException e) { - return null; - } - } - - private static File[] checkFiles(File[] fs) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - return (sm == null || fs == null) ? fs : checkFiles(Stream.of(fs), sm); - } - - private static File[] checkFiles(Stream fs, @SuppressWarnings("removal") SecurityManager sm) { - return fs.filter(f -> f != null && checkFile(f, sm) != null) - .toArray(File[]::new); - } - /** * Does {@code dir} represent a "computer" such as a node on the network, or * "My Computer" on the desktop. diff --git a/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java b/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java index 303b57626d6f6..c942ec4e8f89e 100644 --- a/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java +++ b/src/java.desktop/share/classes/sun/awt/util/PerformanceLogger.java @@ -126,9 +126,7 @@ public class PerformanceLogger { /** * Returns status of whether logging is enabled or not. This is - * provided as a convenience method so that users do not have to - * perform the same GetPropertyAction check as above to determine whether - * to enable performance logging. + * provided as a convenience method. */ public static boolean loggingEnabled() { return perfLoggingOn; diff --git a/src/java.desktop/share/classes/sun/print/PSStreamPrintJob.java b/src/java.desktop/share/classes/sun/print/PSStreamPrintJob.java index 3a75a3232b514..e9e9aa142b25d 100644 --- a/src/java.desktop/share/classes/sun/print/PSStreamPrintJob.java +++ b/src/java.desktop/share/classes/sun/print/PSStreamPrintJob.java @@ -434,12 +434,7 @@ public void pageableJob(Pageable pageable, } /* add the user name to the job */ - String userName = ""; - try { - userName = System.getProperty("user.name"); - } catch (SecurityException se) { - } - + String userName = System.getProperty("user.name"); if (userName == null || userName.isEmpty()) { RequestingUserName ruName = (RequestingUserName)reqSet.get(RequestingUserName.class); diff --git a/src/java.desktop/share/classes/sun/print/PrintJob2D.java b/src/java.desktop/share/classes/sun/print/PrintJob2D.java index fbec484435f82..fb0fdbb17c5c3 100644 --- a/src/java.desktop/share/classes/sun/print/PrintJob2D.java +++ b/src/java.desktop/share/classes/sun/print/PrintJob2D.java @@ -310,12 +310,6 @@ private void initPrintJob2D(Frame frame, String doctitle, JobAttributes jobAttributes, PageAttributes pageAttributes) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } - if (frame == null && (jobAttributes == null || jobAttributes.getDialog() == DialogType.NATIVE)) { @@ -366,11 +360,6 @@ private void initPrintJob2D(Frame frame, String doctitle, } catch (IOException ioe) { throw new IllegalArgumentException("Cannot write to file:"+ destStr); - } catch (SecurityException se) { - //There is already file read/write access so at this point - // only delete access is denied. Just ignore it because in - // most cases the file created in createNewFile gets overwritten - // anyway. } File pFile = f.getParentFile(); @@ -676,29 +665,18 @@ private void copyAttributes(PrintService printServ) { attributes.add(defaultDest); } else { URI uri = null; - try { - if (fileName != null) { - if (fileName.isEmpty()) { - fileName = "."; - } - } else { - // defaultDest should not be null. The following code - // is only added to safeguard against a possible - // buggy implementation of a PrintService having a - // null default Destination. - fileName = "out.prn"; - } - uri = (new File(fileName)).toURI(); - } catch (SecurityException se) { - try { - // '\\' file separator is illegal character in opaque - // part and causes URISyntaxException, so we replace - // it with '/' - fileName = fileName.replace('\\', '/'); - uri = new URI("file:"+fileName); - } catch (URISyntaxException e) { + if (fileName != null) { + if (fileName.isEmpty()) { + fileName = "."; } + } else { + // defaultDest should not be null. The following code + // is only added to safeguard against a possible + // buggy implementation of a PrintService having a + // null default Destination. + fileName = "out.prn"; } + uri = (new File(fileName)).toURI(); if (uri != null) { attributes.add(new Destination(uri)); } diff --git a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java index 4e096f506e5b9..dbd7999fdc088 100644 --- a/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java +++ b/src/java.desktop/share/classes/sun/print/RasterPrinterJob.java @@ -816,10 +816,7 @@ public PageFormat pageDialog(final PrintRequestAttributeSet attributes) DocFlavor.SERVICE_FORMATTED.PAGEABLE, attributes, w); if (setOnTop) { - try { - pageDialog.setAlwaysOnTop(true); - } catch (SecurityException e) { - } + pageDialog.setAlwaysOnTop(true); } Rectangle dlgBounds = pageDialog.getBounds(); @@ -948,15 +945,6 @@ public boolean printDialog(final PrintRequestAttributeSet attributes) } - /* A security check has already been performed in the - * java.awt.print.printerJob.getPrinterJob method. - * So by the time we get here, it is OK for the current thread - * to print either to a file (from a Dialog we control!) or - * to a chosen printer. - * - * We raise privilege when we put up the dialog, to avoid - * the "warning applet window" banner. - */ GraphicsConfiguration grCfg = null; Window w = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow(); if (w != null) { @@ -1311,11 +1299,7 @@ protected void setAttributes(PrintRequestAttributeSet attributes) (!fidelity && userName != null)) { userNameAttr = userName.getValue(); } else { - try { - userNameAttr = getUserName(); - } catch (SecurityException e) { - userNameAttr = ""; - } + userNameAttr = getUserName(); } /* OpenBook is used internally only when app uses Printable. @@ -1654,11 +1638,6 @@ protected void validateDestination(String dest) throws PrinterException { } catch (IOException ioe) { throw new PrinterException("Cannot write to file:"+ dest); - } catch (SecurityException se) { - //There is already file read/write access so at this point - // only delete access is denied. Just ignore it because in - // most cases the file created in createNewFile gets overwritten - // anyway. } File pFile = f.getParentFile(); @@ -1818,7 +1797,6 @@ protected int getCopiesInt() { /** * Get the name of the printing user. - * The caller must have security permission to read system properties. */ public String getUserName() { return System.getProperty("user.name"); @@ -1831,11 +1809,7 @@ protected String getUserNameInt() { if (userNameAttr != null) { return userNameAttr; } else { - try { - return getUserName(); - } catch (SecurityException e) { - return ""; - } + return getUserName(); } } diff --git a/src/java.desktop/share/classes/sun/print/ServiceDialog.java b/src/java.desktop/share/classes/sun/print/ServiceDialog.java index ba530bbf58fb8..d6d3b92ee8d44 100644 --- a/src/java.desktop/share/classes/sun/print/ServiceDialog.java +++ b/src/java.desktop/share/classes/sun/print/ServiceDialog.java @@ -169,10 +169,7 @@ void initPrintDialog(int x, int y, * on top property */ if ((getOwner() == null) || (owner.getOwner() != getOwner())) { - try { - setAlwaysOnTop(true); - } catch (SecurityException e) { - } + setAlwaysOnTop(true); } } Container c = getContentPane(); @@ -255,10 +252,7 @@ void initPageDialog(int x, int y, /* See comments in same block in initPrintDialog */ DialogOwner owner = (DialogOwner)attributes.get(DialogOwner.class); if ((getOwner() == null) || (owner.getOwner() != getOwner())) { - try { - setAlwaysOnTop(true); - } catch (SecurityException e) { - } + setAlwaysOnTop(true); } } @@ -2937,13 +2931,7 @@ public void setSelected(boolean selected) { private static class ValidatingFileChooser extends JFileChooser { public void approveSelection() { File selected = getSelectedFile(); - boolean exists; - - try { - exists = selected.exists(); - } catch (SecurityException e) { - exists = false; - } + boolean exists = selected.exists(); if (exists) { int val; @@ -2966,11 +2954,6 @@ public void approveSelection() { getMsg("dialog.owtitle"), JOptionPane.WARNING_MESSAGE); return; - } catch (SecurityException se) { - //There is already file read/write access so at this point - // only delete access is denied. Just ignore it because in - // most cases the file created in createNewFile gets - // overwritten anyway. } File pFile = selected.getParentFile(); if ((selected.exists() && diff --git a/src/java.desktop/share/classes/sun/print/ServiceNotifier.java b/src/java.desktop/share/classes/sun/print/ServiceNotifier.java index 8df17defd0538..cac06750330e7 100644 --- a/src/java.desktop/share/classes/sun/print/ServiceNotifier.java +++ b/src/java.desktop/share/classes/sun/print/ServiceNotifier.java @@ -55,12 +55,9 @@ class ServiceNotifier extends Thread { super(null, null, service.getName() + " notifier", 0, false); this.service = service; listeners = new Vector<>(); - try { - setPriority(Thread.NORM_PRIORITY-1); - setDaemon(true); - start(); - } catch (SecurityException e) { - } + setPriority(Thread.NORM_PRIORITY-1); + setDaemon(true); + start(); } void addListener(PrintServiceAttributeListener listener) { @@ -93,10 +90,7 @@ void stopNotifier() { * immediate notification of listeners. */ void wake() { - try { - interrupt(); - } catch (SecurityException e) { - } + interrupt(); } /* A heuristic is used to calculate sleep time. diff --git a/src/java.desktop/share/classes/sun/swing/FilePane.java b/src/java.desktop/share/classes/sun/swing/FilePane.java index 395cf058b7d6f..052e7a96ac431 100644 --- a/src/java.desktop/share/classes/sun/swing/FilePane.java +++ b/src/java.desktop/share/classes/sun/swing/FilePane.java @@ -2119,24 +2119,20 @@ public boolean canWrite(File f) { return false; } - try { - if (f instanceof ShellFolder) { - return f.canWrite(); - } else { - if (usesShellFolder(getFileChooser())) { - try { - return ShellFolder.getShellFolder(f).canWrite(); - } catch (FileNotFoundException ex) { - // File doesn't exist - return false; - } - } else { - // Ordinary file - return f.canWrite(); + if (f instanceof ShellFolder) { + return f.canWrite(); + } else { + if (usesShellFolder(getFileChooser())) { + try { + return ShellFolder.getShellFolder(f).canWrite(); + } catch (FileNotFoundException ex) { + // File doesn't exist + return false; } + } else { + // Ordinary file + return f.canWrite(); } - } catch (SecurityException e) { - return false; } } diff --git a/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java b/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java index 181d2d5d33b46..20a07c608a070 100644 --- a/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java +++ b/src/java.desktop/share/classes/sun/swing/SwingUtilities2.java @@ -1462,20 +1462,6 @@ public static boolean canAccessSystemClipboard() { return !GraphicsEnvironment.isHeadless(); } - /** - * Utility method that throws SecurityException if SecurityManager is set - * and modifiers are not public - * - * @param modifiers a set of modifiers - */ - @SuppressWarnings("removal") - public static void checkAccess(int modifiers) { - if (System.getSecurityManager() != null - && !Modifier.isPublic(modifiers)) { - throw new SecurityException("Resource is not accessible"); - } - } - public static String displayPropertiesToCSS(Font font, Color fg) { StringBuilder rule = new StringBuilder("body {"); if (font != null) { diff --git a/src/java.desktop/unix/classes/sun/print/IPPPrintService.java b/src/java.desktop/unix/classes/sun/print/IPPPrintService.java index 4d217ec6e3e18..06533781571b5 100644 --- a/src/java.desktop/unix/classes/sun/print/IPPPrintService.java +++ b/src/java.desktop/unix/classes/sun/print/IPPPrintService.java @@ -511,11 +511,6 @@ private void initAttributes() { public DocPrintJob createPrintJob() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } // REMIND: create IPPPrintJob return new UnixPrintJob(this); } @@ -587,15 +582,7 @@ public DocPrintJob createPrintJob() { if (flavor == null || flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || flavor.equals(DocFlavor.SERVICE_FORMATTED.PRINTABLE)) { - try { return new Destination((new File("out.ps")).toURI()); - } catch (SecurityException se) { - try { - return new Destination(new URI("file:out.ps")); - } catch (URISyntaxException e) { - return null; - } - } } return null; } else if (category == Fidelity.class) { @@ -797,11 +784,7 @@ public DocPrintJob createPrintJob() { return null; } } else if (category == RequestingUserName.class) { - String userName = ""; - try { - userName = System.getProperty("user.name", ""); - } catch (SecurityException se) { - } + String userName = System.getProperty("user.name", ""); return new RequestingUserName(userName, null); } else if (category == Sides.class) { // The printer takes care of Sides so if short-edge @@ -1574,15 +1557,7 @@ public boolean isAttributeValueSupported(Attribute attr, } else if (category == Chromaticity.class) { return Chromaticity.COLOR; } else if (category == Destination.class) { - try { - return new Destination((new File("out.ps")).toURI()); - } catch (SecurityException se) { - try { - return new Destination(new URI("file:out.ps")); - } catch (URISyntaxException e) { - return null; - } - } + return new Destination((new File("out.ps")).toURI()); } else if (category == Fidelity.class) { return Fidelity.FIDELITY_FALSE; } else if (category == Finishings.class) { @@ -1674,11 +1649,7 @@ public boolean isAttributeValueSupported(Attribute attr, return new PageRanges(1, Integer.MAX_VALUE); } } else if (category == RequestingUserName.class) { - String userName = ""; - try { - userName = System.getProperty("user.name", ""); - } catch (SecurityException se) { - } + String userName = System.getProperty("user.name", ""); return new RequestingUserName(userName, null); } else if (category == SheetCollate.class) { return SheetCollate.UNCOLLATED; diff --git a/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java b/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java index 15025d43d6f5d..e91ef99ab3726 100644 --- a/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java +++ b/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java @@ -210,12 +210,6 @@ public PrintServiceLookupProvider() { * lead people to assume its guaranteed. */ public synchronized PrintService[] getPrintServices() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } - if (printServices == null || !pollServices) { refreshServices(); } @@ -549,11 +543,6 @@ private PrintService getServiceByName(PrinterName nameAttr) { */ public PrintService[] getPrintServices(DocFlavor flavor, AttributeSet attributes) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } PrintRequestAttributeSet requestSet = null; PrintServiceAttributeSet serviceSet = null; @@ -613,22 +602,11 @@ public PrintService[] getPrintServices(DocFlavor flavor, public MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } return new MultiDocPrintService[0]; } public synchronized PrintService getDefaultPrintService() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } - // clear defaultPrintService defaultPrintService = null; String psuri = null; diff --git a/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java b/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java index 1249d29ec72fd..b8c455a7d00d3 100644 --- a/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java +++ b/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java @@ -707,12 +707,7 @@ public void pageableJob(Pageable pageable) throws PrintException { } /* add the user name to the job */ - String userName = ""; - try { - userName = System.getProperty("user.name"); - } catch (SecurityException se) { - } - + String userName = System.getProperty("user.name"); if (userName == null || userName.isEmpty()) { RequestingUserName ruName = (RequestingUserName)reqSet.get(RequestingUserName.class); @@ -791,17 +786,6 @@ private void getAttributeValues(DocFlavor flavor) throws PrintException { } catch (Exception e) { throw new PrintException(e); } - // check write access - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - try { - security.checkWrite(mDestination); - } catch (SecurityException se) { - notifyEvent(PrintJobEvent.JOB_FAILED); - throw new PrintException(se); - } - } } } else if (category == JobSheets.class) { if ((JobSheets)attr == JobSheets.NONE) { diff --git a/src/java.desktop/unix/classes/sun/print/UnixPrintService.java b/src/java.desktop/unix/classes/sun/print/UnixPrintService.java index 201487e9ca46e..8185abc6005f3 100644 --- a/src/java.desktop/unix/classes/sun/print/UnixPrintService.java +++ b/src/java.desktop/unix/classes/sun/print/UnixPrintService.java @@ -416,11 +416,6 @@ private boolean isSupportedMedia(MediaSizeName msn) { } public DocPrintJob createPrintJob() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } return new UnixPrintJob(this); } @@ -627,15 +622,7 @@ public Class[] getSupportedAttributeCategories() { } else if (category == Chromaticity.class) { return Chromaticity.COLOR; } else if (category == Destination.class) { - try { - return new Destination((new File("out.ps")).toURI()); - } catch (SecurityException se) { - try { - return new Destination(new URI("file:out.ps")); - } catch (URISyntaxException e) { - return null; - } - } + return new Destination((new File("out.ps")).toURI()); } else if (category == Fidelity.class) { return Fidelity.FIDELITY_FALSE; } else if (category == JobName.class) { @@ -672,11 +659,7 @@ public Class[] getSupportedAttributeCategories() { } else if (category == PageRanges.class) { return new PageRanges(1, Integer.MAX_VALUE); } else if (category == RequestingUserName.class) { - String userName = ""; - try { - userName = System.getProperty("user.name", ""); - } catch (SecurityException se) { - } + String userName = System.getProperty("user.name", ""); return new RequestingUserName(userName, null); } else if (category == SheetCollate.class) { return SheetCollate.UNCOLLATED; @@ -733,15 +716,7 @@ private boolean isAutoSense(DocFlavor flavor) { return null; } } else if (category == Destination.class) { - try { return new Destination((new File("out.ps")).toURI()); - } catch (SecurityException se) { - try { - return new Destination(new URI("file:out.ps")); - } catch (URISyntaxException e) { - return null; - } - } } else if (category == JobName.class) { return new JobName("Java Printing", null); } else if (category == JobSheets.class) { @@ -750,11 +725,7 @@ private boolean isAutoSense(DocFlavor flavor) { arr[1] = JobSheets.STANDARD; return arr; } else if (category == RequestingUserName.class) { - String userName = ""; - try { - userName = System.getProperty("user.name", ""); - } catch (SecurityException se) { - } + String userName = System.getProperty("user.name", ""); return new RequestingUserName(userName, null); } else if (category == OrientationRequested.class) { if (flavor == null || isServiceFormattedFlavor(flavor)) { diff --git a/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c b/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c index 389e25caaec0c..f24a4eb9a2cea 100644 --- a/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c +++ b/src/java.desktop/unix/native/libawt/awt/awt_LoadLibrary.c @@ -132,7 +132,9 @@ AWT_OnLoad(JavaVM *vm, void *reserved) } #endif - if (!JVM_IsStaticallyLinked()) { + if (JVM_IsStaticallyLinked()) { + awtHandle = dlopen(NULL, RTLD_LAZY); + } else { /* Get address of this library and the directory containing it. */ dladdr((void *)AWT_OnLoad, &dlinfo); realpath((char *)dlinfo.dli_fname, buf); diff --git a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java index 24e2bb45df8f3..0a4fb12cda6c7 100644 --- a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java +++ b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolder2.java @@ -666,13 +666,6 @@ public String call() throws IOException { return getFileSystemPath0(csidl); } }, IOException.class); - if (path != null) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(path); - } - } return path; } @@ -750,11 +743,6 @@ private native long getEnumObjects(long pIShellFolder, boolean isDesktop, * {@code null} if this shellfolder does not denote a directory. */ public File[] listFiles(final boolean includeHiddenFiles) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkRead(getPath()); - } try { File[] files = invoke(new Callable() { @@ -813,7 +801,7 @@ && pidlsEqual(pIShellFolder, childPIDL, personal.disposer.relativePIDL)) { } }, InterruptedException.class); - return Win32ShellFolderManager2.checkFiles(files); + return files; } catch (InterruptedException e) { return new File[0]; } diff --git a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java index 810b25b55fde6..53653f07f34b1 100644 --- a/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java +++ b/src/java.desktop/windows/classes/sun/awt/shell/Win32ShellFolderManager2.java @@ -42,7 +42,6 @@ import java.util.concurrent.ThreadFactory; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; -import java.util.stream.Stream; import sun.awt.OSInfo; import sun.awt.util.ThreadGroupUtils; @@ -167,9 +166,6 @@ static Win32ShellFolder2 getDesktop() { if (desktop == null) { try { desktop = new Win32ShellFolder2(DESKTOP); - } catch (final SecurityException ignored) { - // Ignore, the message may have sensitive information, not - // accessible other ways } catch (IOException | InterruptedException e) { if (log.isLoggable(PlatformLogger.Level.WARNING)) { log.warning("Cannot access 'Desktop'", e); @@ -183,9 +179,6 @@ static Win32ShellFolder2 getDrives() { if (drives == null) { try { drives = new Win32ShellFolder2(DRIVES); - } catch (final SecurityException ignored) { - // Ignore, the message may have sensitive information, not - // accessible other ways } catch (IOException | InterruptedException e) { if (log.isLoggable(PlatformLogger.Level.WARNING)) { log.warning("Cannot access 'Drives'", e); @@ -202,9 +195,6 @@ static Win32ShellFolder2 getRecent() { if (path != null) { recent = createShellFolder(getDesktop(), new File(path)); } - } catch (final SecurityException ignored) { - // Ignore, the message may have sensitive information, not - // accessible other ways } catch (InterruptedException | IOException e) { if (log.isLoggable(PlatformLogger.Level.WARNING)) { log.warning("Cannot access 'Recent'", e); @@ -218,9 +208,6 @@ static Win32ShellFolder2 getNetwork() { if (network == null) { try { network = new Win32ShellFolder2(NETWORK); - } catch (final SecurityException ignored) { - // Ignore, the message may have sensitive information, not - // accessible other ways } catch (IOException | InterruptedException e) { if (log.isLoggable(PlatformLogger.Level.WARNING)) { log.warning("Cannot access 'Network'", e); @@ -244,9 +231,6 @@ static Win32ShellFolder2 getPersonal() { personal.setIsPersonal(); } } - } catch (final SecurityException ignored) { - // Ignore, the message may have sensitive information, not - // accessible other ways } catch (InterruptedException | IOException e) { if (log.isLoggable(PlatformLogger.Level.WARNING)) { log.warning("Cannot access 'Personal'", e); @@ -287,7 +271,7 @@ public Object get(String key) { if (file == null) { file = getDesktop(); } - return checkFile(file); + return file; } else if (key.equals("roots")) { // Should be "History" and "Desktop" ? if (roots == null) { @@ -298,11 +282,11 @@ public Object get(String key) { roots = (File[])super.get(key); } } - return checkFiles(roots); + return roots; } else if (key.equals("fileChooserComboBoxFolders")) { Win32ShellFolder2 desktop = getDesktop(); - if (desktop != null && checkFile(desktop) != null) { + if (desktop != null) { ArrayList folders = new ArrayList(); Win32ShellFolder2 drives = getDrives(); @@ -313,7 +297,7 @@ public Object get(String key) { folders.add(desktop); // Add all second level folders - File[] secondLevelFolders = checkFiles(desktop.listFiles()); + File[] secondLevelFolders = desktop.listFiles(); Arrays.sort(secondLevelFolders); for (File secondLevelFolder : secondLevelFolders) { Win32ShellFolder2 folder = (Win32ShellFolder2) secondLevelFolder; @@ -321,7 +305,7 @@ public Object get(String key) { folders.add(folder); // Add third level for "My Computer" if (folder.equals(drives)) { - File[] thirdLevelFolders = checkFiles(folder.listFiles()); + File[] thirdLevelFolders = folder.listFiles(); if (thirdLevelFolders != null && thirdLevelFolders.length > 0) { List thirdLevelFoldersList = Arrays.asList(thirdLevelFolders); @@ -331,7 +315,7 @@ public Object get(String key) { } } } - return checkFiles(folders); + return folders.toArray(new File[folders.size()]); } else { return super.get(key); } @@ -374,7 +358,7 @@ public Object get(String key) { } } } - return checkFiles(folders); + return folders.toArray(new File[folders.size()]); } else if (key.startsWith("fileChooserIcon ")) { String name = key.substring(key.indexOf(" ") + 1); @@ -421,53 +405,6 @@ public Object get(String key) { return null; } - private static File checkFile(File file) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - return (sm == null || file == null) ? file : checkFile(file, sm); - } - - private static File checkFile(File file, @SuppressWarnings("removal") SecurityManager sm) { - try { - sm.checkRead(file.getPath()); - - if (file instanceof Win32ShellFolder2) { - Win32ShellFolder2 f = (Win32ShellFolder2)file; - if (f.isLink()) { - Win32ShellFolder2 link = (Win32ShellFolder2)f.getLinkLocation(); - if (link != null) - sm.checkRead(link.getPath()); - } - } - return file; - } catch (SecurityException se) { - return null; - } - } - - static File[] checkFiles(File[] files) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm == null || files == null || files.length == 0) { - return files; - } - return checkFiles(Arrays.stream(files), sm); - } - - private static File[] checkFiles(List files) { - @SuppressWarnings("removal") - SecurityManager sm = System.getSecurityManager(); - if (sm == null || files.isEmpty()) { - return files.toArray(new File[files.size()]); - } - return checkFiles(files.stream(), sm); - } - - private static File[] checkFiles(Stream filesStream, @SuppressWarnings("removal") SecurityManager sm) { - return filesStream.filter((file) -> checkFile(file, sm) != null) - .toArray(File[]::new); - } - /** * Does {@code dir} represent a "computer" such as a node on the network, or * "My Computer" on the desktop. diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java b/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java index 0d41aacde2f8a..970b317a8a8ae 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WPrinterJob.java @@ -1913,16 +1913,7 @@ private void setNativeAttributes(int flags, int fields, int values) { Destination destPrn = (Destination)attributes.get( Destination.class); if (destPrn == null) { - try { - attributes.add(new Destination( - new File("./out.prn").toURI())); - } catch (SecurityException se) { - try { - attributes.add(new Destination( - new URI("file:out.prn"))); - } catch (URISyntaxException e) { - } - } + attributes.add(new Destination(new File("./out.prn").toURI())); } } else { attributes.remove(Destination.class); diff --git a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java index 44173fb2abf2a..aaaae37c6f5a4 100644 --- a/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java +++ b/src/java.desktop/windows/classes/sun/print/PrintServiceLookupProvider.java @@ -106,11 +106,6 @@ public PrintServiceLookupProvider() { * lead people to assume its guaranteed. */ public synchronized PrintService[] getPrintServices() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } if (printServices == null) { refreshServices(); } @@ -207,11 +202,6 @@ boolean matchingService(PrintService service, public PrintService[] getPrintServices(DocFlavor flavor, AttributeSet attributes) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } PrintRequestAttributeSet requestSet = null; PrintServiceAttributeSet serviceSet = null; @@ -273,22 +263,11 @@ public PrintService[] getPrintServices(DocFlavor flavor, public MultiDocPrintService[] getMultiDocPrintServices(DocFlavor[] flavors, AttributeSet attributes) { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } return new MultiDocPrintService[0]; } public synchronized PrintService getDefaultPrintService() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } - // Windows does not have notification for a change in default // so we always get the latest. diff --git a/src/java.desktop/windows/classes/sun/print/Win32PrintJob.java b/src/java.desktop/windows/classes/sun/print/Win32PrintJob.java index 53fe183e8610e..008641418d2c5 100644 --- a/src/java.desktop/windows/classes/sun/print/Win32PrintJob.java +++ b/src/java.desktop/windows/classes/sun/print/Win32PrintJob.java @@ -592,11 +592,7 @@ public void pageableJob(Pageable pageable) throws PrintException { } /* add the user name to the job */ - String userName = ""; - try { - userName = System.getProperty("user.name"); - } catch (SecurityException se) { - } + String userName = System.getProperty("user.name"); if (userName == null || userName.isEmpty()) { RequestingUserName ruName = @@ -674,17 +670,6 @@ private void getAttributeValues(DocFlavor flavor) throws PrintException { } catch (Exception e) { throw new PrintException(e); } - // check write access - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - try { - security.checkWrite(mDestination); - } catch (SecurityException se) { - notifyEvent(PrintJobEvent.JOB_FAILED); - throw new PrintException(se); - } - } } } else if (category == JobName.class) { jobName = ((JobName)attr).getValue(); diff --git a/src/java.desktop/windows/classes/sun/print/Win32PrintService.java b/src/java.desktop/windows/classes/sun/print/Win32PrintService.java index 3eb3549ad844c..4706e05a8ff1c 100644 --- a/src/java.desktop/windows/classes/sun/print/Win32PrintService.java +++ b/src/java.desktop/windows/classes/sun/print/Win32PrintService.java @@ -858,11 +858,6 @@ private boolean isSupportedResolution(PrinterResolution res) { } public DocPrintJob createPrintJob() { - @SuppressWarnings("removal") - SecurityManager security = System.getSecurityManager(); - if (security != null) { - security.checkPrintJobAccess(); - } return new Win32PrintJob(this); } @@ -1174,15 +1169,7 @@ public Class[] getSupportedAttributeCategories() { } else if (category == SunAlternateMedia.class) { return null; } else if (category == Destination.class) { - try { - return new Destination((new File("out.prn")).toURI()); - } catch (SecurityException se) { - try { - return new Destination(new URI("file:out.prn")); - } catch (URISyntaxException e) { - return null; - } - } + return new Destination((new File("out.prn")).toURI()); } else if (category == Sides.class) { switch(defSides) { case DMDUP_VERTICAL : @@ -1223,11 +1210,7 @@ public Class[] getSupportedAttributeCategories() { } } } else if (category == RequestingUserName.class) { - String userName = ""; - try { - userName = System.getProperty("user.name", ""); - } catch (SecurityException se) { - } + String userName = System.getProperty("user.name", ""); return new RequestingUserName(userName, null); } else if (category == SheetCollate.class) { if (defCollate == DMCOLLATE_TRUE) { @@ -1302,11 +1285,7 @@ private boolean isAutoSense(DocFlavor flavor) { if (category == JobName.class) { return new JobName("Java Printing", null); } else if (category == RequestingUserName.class) { - String userName = ""; - try { - userName = System.getProperty("user.name", ""); - } catch (SecurityException se) { - } + String userName = System.getProperty("user.name", ""); return new RequestingUserName(userName, null); } else if (category == ColorSupported.class) { int caps = getPrinterCapabilities(); @@ -1343,15 +1322,7 @@ private boolean isAutoSense(DocFlavor flavor) { return null; } } else if (category == Destination.class) { - try { - return new Destination((new File("out.prn")).toURI()); - } catch (SecurityException se) { - try { - return new Destination(new URI("file:out.prn")); - } catch (URISyntaxException e) { - return null; - } - } + return new Destination((new File("out.prn")).toURI()); } else if (category == OrientationRequested.class) { if (flavor == null || flavor.equals(DocFlavor.SERVICE_FORMATTED.PAGEABLE) || diff --git a/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java b/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java index a80b59927d3d9..c7d50778d7bfa 100644 --- a/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java +++ b/src/java.naming/share/classes/com/sun/naming/internal/ObjectFactoriesFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, 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 @@ -220,7 +220,7 @@ private static ConfiguredFilter initializeFilter(String filterPropertyName, // Get security or system property value private static String getFilterPropertyValue(String propertyName, String defaultValue) { - String propVal = SecurityProperties.privilegedGetOverridable(propertyName); + String propVal = SecurityProperties.getOverridableProperty(propertyName); return propVal != null ? propVal : defaultValue; } } diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/Config.java b/src/java.security.jgss/share/classes/sun/security/krb5/Config.java index a9ea9d23eb11c..c92a106850ba6 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/Config.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/Config.java @@ -72,7 +72,7 @@ public class Config { static { String disableReferralsProp = - SecurityProperties.privilegedGetOverridable( + SecurityProperties.getOverridableProperty( "sun.security.krb5.disableReferrals"); if (disableReferralsProp != null) { DISABLE_REFERRALS = "true".equalsIgnoreCase(disableReferralsProp); @@ -82,7 +82,7 @@ public class Config { int maxReferralsValue = 5; String maxReferralsProp = - SecurityProperties.privilegedGetOverridable( + SecurityProperties.getOverridableProperty( "sun.security.krb5.maxReferrals"); try { maxReferralsValue = Integer.parseInt(maxReferralsProp); diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java b/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java index 9482177c17410..f9076a9b0dd6c 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/Credentials.java @@ -67,7 +67,7 @@ public class Credentials { private static boolean alreadyTried = false; public static final boolean S4U2PROXY_ACCEPT_NON_FORWARDABLE - = "true".equalsIgnoreCase(SecurityProperties.privilegedGetOverridable( + = "true".equalsIgnoreCase(SecurityProperties.getOverridableProperty( "jdk.security.krb5.s4u2proxy.acceptNonForwardableServiceTicket")); private Credentials proxy = null; diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java b/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java index 130f2c23f8670..400843ff41742 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/PrincipalName.java @@ -99,7 +99,6 @@ public class PrincipalName implements Cloneable { * TGS Name */ public static final String TGS_DEFAULT_SRV_NAME = "krbtgt"; - public static final int TGS_DEFAULT_NT = KRB_NT_SRV_INST; public static final char NAME_COMPONENT_SEPARATOR = '/'; public static final char NAME_REALM_SEPARATOR = '@'; @@ -107,11 +106,10 @@ public class PrincipalName implements Cloneable { public static final String NAME_COMPONENT_SEPARATOR_STR = "/"; public static final String NAME_REALM_SEPARATOR_STR = "@"; - public static final String REALM_COMPONENT_SEPARATOR_STR = "."; private static final boolean NAME_CASE_SENSITIVE_IN_MATCH = "true".equalsIgnoreCase( - SecurityProperties.privilegedGetOverridable( + SecurityProperties.getOverridableProperty( "jdk.security.krb5.name.case.sensitive")); @@ -135,12 +133,6 @@ public class PrincipalName implements Cloneable { private final Realm nameRealm; // not null - /** - * When constructing a PrincipalName, whether the realm is included in - * the input, or deduced from default realm or domain-realm mapping. - */ - private final boolean realmDeduced; - // cached default salt, not used in clone private transient String salt = null; @@ -161,7 +153,6 @@ public PrincipalName(int nameType, String[] nameStrings, Realm nameRealm) { this.nameType = nameType; this.nameStrings = nameStrings.clone(); this.nameRealm = nameRealm; - this.realmDeduced = false; } // Warning: called by NativeCreds.c @@ -251,7 +242,6 @@ public PrincipalName(DerValue encoding, Realm realm) if (realm == null) { throw new IllegalArgumentException("Null realm not allowed"); } - realmDeduced = false; nameRealm = realm; DerValue der; if (encoding == null) { @@ -405,9 +395,6 @@ public PrincipalName(String name, int type, String realm) realm = Realm.parseRealmAtSeparator(name); } - // No realm info from parameter and string, must deduce later - realmDeduced = realm == null; - switch (type) { case KRB_NT_SRV_HST: if (nameParts.length >= 2) { @@ -437,8 +424,8 @@ public PrincipalName(String name, int type, String realm) hostName.toLowerCase(Locale.ENGLISH) + ".")) { hostName = canonicalized; } - } catch (UnknownHostException | SecurityException e) { - // not canonicalized or no permission to do so, use old + } catch (UnknownHostException e) { + // not canonicalized, use old } if (hostName.endsWith(".")) { hostName = hostName.substring(0, hostName.length() - 1); @@ -726,8 +713,4 @@ static String mapHostToRealm(String name) { } return result; } - - public boolean isRealmDeduced() { - return realmDeduced; - } } diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/Realm.java b/src/java.security.jgss/share/classes/sun/security/krb5/Realm.java index 93dbfe2b23733..758c0ce4f64bc 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/Realm.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/Realm.java @@ -47,9 +47,6 @@ */ public class Realm implements Cloneable { - public static final boolean AUTODEDUCEREALM = - Boolean.getBoolean("sun.security.krb5.autodeducerealm"); - private final String realm; // not null nor empty public Realm(String name) throws RealmException { diff --git a/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java b/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java index 8599ffd81b8f9..a5b128f7129de 100644 --- a/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java +++ b/src/java.security.jgss/share/classes/sun/security/krb5/internal/ccache/FileCredentialsCache.java @@ -358,7 +358,7 @@ public sun.security.krb5.Credentials getInitialCreds() { } boolean force; - String prop = SecurityProperties.privilegedGetOverridable( + String prop = SecurityProperties.getOverridableProperty( "jdk.security.krb5.default.initiate.credential"); if (prop == null) { prop = "always-impersonate"; diff --git a/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java b/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java index 20a76e38b2ed2..9ec28f926ec38 100644 --- a/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java +++ b/src/java.sql.rowset/share/classes/javax/sql/rowset/BaseRowSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -1892,7 +1892,7 @@ public void setDouble(int parameterIndex, double x) throws SQLException { /** * Sets the designated parameter to the given - * java.lang.BigDecimal value. The driver converts this to + * java.math.BigDecimal value. The driver converts this to * an SQL NUMERIC value when it sends it to the database. *

      * The parameter value set by this method is stored internally and diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java index aa7b62151d1ed..3b08dd7e89b3e 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java @@ -1209,11 +1209,12 @@ public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) th // Step 1: custom Entity resolver XMLInputSource xmlInputSource = null; - + boolean resolveByResolver = false; if (fEntityResolver != null) { resourceIdentifier.setBaseSystemId(baseSystemId); resourceIdentifier.setExpandedSystemId(expandedSystemId); xmlInputSource = fEntityResolver.resolveEntity(resourceIdentifier); + resolveByResolver = xmlInputSource != null; } // Step 2: custom catalog if specified @@ -1229,7 +1230,8 @@ public XMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) th } // Step 3: use the default JDK Catalog Resolver if Step 2's resolve is continue - if (xmlInputSource == null + if ((xmlInputSource == null || (!resolveByResolver && xmlInputSource.getSystemId() != null + && xmlInputSource.getSystemId().equals(literalSystemId))) && (publicId != null || literalSystemId != null) && JdkXmlUtils.isResolveContinue(fCatalogFeatures)) { initJdkCatalogResolver(); diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/JDKCatalog.xml b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/JDKCatalog.xml index 3919dd4981d75..74ba003250150 100644 --- a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/JDKCatalog.xml +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/JDKCatalog.xml @@ -1,7 +1,7 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/XMLSchema.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/XMLSchema.dtd new file mode 100644 index 0000000000000..64aa2d9701924 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/XMLSchema.dtd @@ -0,0 +1,513 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +%xs-datatypes; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/datatypes.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/datatypes.dtd new file mode 100644 index 0000000000000..f9352bae1c4f7 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/schema10/datatypes.dtd @@ -0,0 +1,222 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-lat1.ent b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-lat1.ent new file mode 100644 index 0000000000000..ffee223eb1056 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-lat1.ent @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-special.ent b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-special.ent new file mode 100644 index 0000000000000..ca358b2fec722 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-special.ent @@ -0,0 +1,80 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-symbol.ent b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-symbol.ent new file mode 100644 index 0000000000000..63c2abfa6f450 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml-symbol.ent @@ -0,0 +1,237 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-frameset.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-frameset.dtd new file mode 100644 index 0000000000000..d814a6f37edbb --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-frameset.dtd @@ -0,0 +1,1235 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-strict.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-strict.dtd new file mode 100644 index 0000000000000..b449108daf98d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-strict.dtd @@ -0,0 +1,978 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-transitional.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-transitional.dtd new file mode 100644 index 0000000000000..c62c02a5fa03c --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml10/xhtml1-transitional.dtd @@ -0,0 +1,1201 @@ + + + + + +%HTMLlat1; + + +%HTMLsymbol; + + +%HTMLspecial; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-attribs-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-attribs-1.mod new file mode 100644 index 0000000000000..178da950ed38b --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-attribs-1.mod @@ -0,0 +1,142 @@ + + + + + + + + + +]]> + + + + +]]> + + + + +]]> + + + + + + + + +]]> + + + + + + + + + + + +]]> + + +]]> + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-base-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-base-1.mod new file mode 100644 index 0000000000000..ba47b40fdd851 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-base-1.mod @@ -0,0 +1,53 @@ + + + + + + + + + + + + +]]> + + + +]]> + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-bdo-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-bdo-1.mod new file mode 100644 index 0000000000000..062de5cb8dc6e --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-bdo-1.mod @@ -0,0 +1,47 @@ + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkphras-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkphras-1.mod new file mode 100644 index 0000000000000..9172463960cc0 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkphras-1.mod @@ -0,0 +1,164 @@ + + + + + + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkpres-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkpres-1.mod new file mode 100644 index 0000000000000..c342f8b2016b1 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkpres-1.mod @@ -0,0 +1,40 @@ + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkstruct-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkstruct-1.mod new file mode 100644 index 0000000000000..ce6a95c2e53a3 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-blkstruct-1.mod @@ -0,0 +1,57 @@ + + + + + + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-charent-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-charent-1.mod new file mode 100644 index 0000000000000..824c3ed262a8d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-charent-1.mod @@ -0,0 +1,39 @@ + + + + + + + +%xhtml-lat1; + + +%xhtml-symbol; + + +%xhtml-special; + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-csismap-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-csismap-1.mod new file mode 100644 index 0000000000000..2bae98cce1f0a --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-csismap-1.mod @@ -0,0 +1,114 @@ + + + + + + + + + + +]]> + + + + + + +]]> + + + + + + + + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-datatypes-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-datatypes-1.mod new file mode 100644 index 0000000000000..dde43e83e19c2 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-datatypes-1.mod @@ -0,0 +1,103 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-edit-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-edit-1.mod new file mode 100644 index 0000000000000..b2a328e474ef2 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-edit-1.mod @@ -0,0 +1,66 @@ + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-events-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-events-1.mod new file mode 100644 index 0000000000000..03fd46cbb5c01 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-events-1.mod @@ -0,0 +1,135 @@ + + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-form-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-form-1.mod new file mode 100644 index 0000000000000..de68a757dcbf4 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-form-1.mod @@ -0,0 +1,292 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-framework-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-framework-1.mod new file mode 100644 index 0000000000000..7d9d9729dacc5 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-framework-1.mod @@ -0,0 +1,97 @@ + + + + + + + + +%xhtml-arch.mod;]]> + + + +%xhtml-notations.mod;]]> + + + +%xhtml-datatypes.mod;]]> + + + +%xhtml-xlink.mod; + + + +%xhtml-qname.mod;]]> + + + +%xhtml-events.mod;]]> + + + +%xhtml-attribs.mod;]]> + + + +%xhtml-model.redecl; + + + +%xhtml-model.mod;]]> + + + +%xhtml-charent.mod;]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-hypertext-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-hypertext-1.mod new file mode 100644 index 0000000000000..7a7d8caebd69f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-hypertext-1.mod @@ -0,0 +1,54 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-image-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-image-1.mod new file mode 100644 index 0000000000000..856176181a990 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-image-1.mod @@ -0,0 +1,51 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlphras-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlphras-1.mod new file mode 100644 index 0000000000000..d749b2e38bec3 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlphras-1.mod @@ -0,0 +1,203 @@ + + + + + + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlpres-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlpres-1.mod new file mode 100644 index 0000000000000..8717d54ed44b3 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlpres-1.mod @@ -0,0 +1,138 @@ + + + + + + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstruct-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstruct-1.mod new file mode 100644 index 0000000000000..3d43d28756333 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstruct-1.mod @@ -0,0 +1,62 @@ + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstyle-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstyle-1.mod new file mode 100644 index 0000000000000..305680ff60cab --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-inlstyle-1.mod @@ -0,0 +1,34 @@ + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-legacy-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-legacy-1.mod new file mode 100644 index 0000000000000..c4eee72790a37 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-legacy-1.mod @@ -0,0 +1,400 @@ + + + + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +%xhtml-frames.mod;]]> + + + + + +%xhtml-iframe.mod;]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-link-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-link-1.mod new file mode 100644 index 0000000000000..2b4f92c7d854d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-link-1.mod @@ -0,0 +1,59 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-list-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-list-1.mod new file mode 100644 index 0000000000000..6c85f205f823d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-list-1.mod @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-meta-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-meta-1.mod new file mode 100644 index 0000000000000..24a0b228061c7 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-meta-1.mod @@ -0,0 +1,47 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-object-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-object-1.mod new file mode 100644 index 0000000000000..0d14cc51d6644 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-object-1.mod @@ -0,0 +1,60 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-param-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-param-1.mod new file mode 100644 index 0000000000000..c101bedd3d6c3 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-param-1.mod @@ -0,0 +1,48 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-pres-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-pres-1.mod new file mode 100644 index 0000000000000..6a2f34de325a7 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-pres-1.mod @@ -0,0 +1,38 @@ + + + + + + + + +%xhtml-inlpres.mod;]]> + + + +%xhtml-blkpres.mod;]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-qname-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-qname-1.mod new file mode 100644 index 0000000000000..c7586a53c7055 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-qname-1.mod @@ -0,0 +1,318 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + +%xhtml-qname-extra.mod; + + + + + + + + + +]]> + + + + + + + + + + + + + + + + + + + +]]> + + + + + + + +]]> + + + + +%xhtml-qname.redecl; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ruby-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ruby-1.mod new file mode 100644 index 0000000000000..68931769c2e5e --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ruby-1.mod @@ -0,0 +1,242 @@ + + + + + + + + + + + + + + + + + + + + + + + +]]> + +]]> + + + +]]> + + + + + + + + + + + + + +]]> + + + + + + +]]> + + + + + + +]]> +]]> + + + + + + + +]]> + + + + + + + + +]]> + + + + +]]> +]]> + + + + + + +]]> +]]> + + + + + + + + + + +]]> + + + + + +]]> + + + + + +]]> +]]> + + + + + +]]> + + + + + +]]> + + + + + +]]> +]]> +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-script-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-script-1.mod new file mode 100644 index 0000000000000..aa702f1f01471 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-script-1.mod @@ -0,0 +1,67 @@ + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ssismap-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ssismap-1.mod new file mode 100644 index 0000000000000..4e2b8d7ed6350 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-ssismap-1.mod @@ -0,0 +1,32 @@ + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-struct-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-struct-1.mod new file mode 100644 index 0000000000000..4bb420ee7b151 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-struct-1.mod @@ -0,0 +1,136 @@ + + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-style-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-style-1.mod new file mode 100644 index 0000000000000..3105b2a47307f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-style-1.mod @@ -0,0 +1,48 @@ + + + + + + + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-table-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-table-1.mod new file mode 100644 index 0000000000000..3fc03608f1db6 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-table-1.mod @@ -0,0 +1,333 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-text-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-text-1.mod new file mode 100644 index 0000000000000..07ccb81a7fe9f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml-text-1.mod @@ -0,0 +1,52 @@ + + + + + + + + +%xhtml-inlstruct.mod;]]> + + + +%xhtml-inlphras.mod;]]> + + + +%xhtml-blkstruct.mod;]]> + + + +%xhtml-blkphras.mod;]]> + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11-model-1.mod b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11-model-1.mod new file mode 100644 index 0000000000000..229e9a9d0a262 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11-model-1.mod @@ -0,0 +1,250 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11.dtd new file mode 100644 index 0000000000000..8f14c406cfb2e --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xhtml11/xhtml11.dtd @@ -0,0 +1,323 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + + + + + +%xhtml-inlstyle.mod;]]> + + + + + + + + +%xhtml-datatypes.mod;]]> + + + + + + +%xhtml-framework.mod;]]> + + + + +]]> + + + + +%xhtml-text.mod;]]> + + + + +%xhtml-hypertext.mod;]]> + + + + +%xhtml-list.mod;]]> + + + + + + +%xhtml-edit.mod;]]> + + + + +%xhtml-bdo.mod;]]> + + + + + + +%xhtml-ruby.mod;]]> + + + + +%xhtml-pres.mod;]]> + + + + +%xhtml-link.mod;]]> + + + + +%xhtml-meta.mod;]]> + + + + +%xhtml-base.mod;]]> + + + + +%xhtml-script.mod;]]> + + + + +%xhtml-style.mod;]]> + + + + +%xhtml-image.mod;]]> + + + + +%xhtml-csismap.mod;]]> + + + + +%xhtml-ssismap.mod;]]> + + + + +%xhtml-param.mod;]]> + + + + +%xhtml-object.mod;]]> + + + + +%xhtml-table.mod;]]> + + + + +%xhtml-form.mod;]]> + + + + +%xhtml-legacy.mod;]]> + + + + +%xhtml-struct.mod;]]> + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xmlspec2_10/xmlspec.dtd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xmlspec2_10/xmlspec.dtd new file mode 100644 index 0000000000000..f720913be4494 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/dtd/xmlspec2_10/xmlspec.dtd @@ -0,0 +1,2778 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + +]]> + + + + + + + + + +]]> + + + + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + +]]> + + + + +]]> + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + + + + +]]> + + +]]> + + + + + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + + + +]]> + + +]]> + + + + + +]]> + + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + + + + + +]]> + + +]]> + + + + + +]]> + + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + + + + + +]]> + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + +]]> + + + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + + + + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + + + + + +]]> + + +]]> + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + + + +]]> + + + +]]> + + + + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + + + + + + + + + + + + + + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]]> + + +]]> + + + + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + + + +]]> + + +]]> + + + + + + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + + +]]> + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + +]]> + + +]]> + + + + + + +]]> + + + +]]> + + + + +]]> + + + +]]> + + + + + + +]]> + + +]]> + + + + + +]]> + + +]]> + + + + + + +]]> + + +]]> + + + + +]]> + + + +]]> + + + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + +]]> + + + + +]]> + + + + +]]> + + + + +]]> + + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + +]]> + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + +]]> + + + + +]]> + + + + + + + + + + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + +]]> + + + +]]> + + +]]> + + +]]> + + +]]> + + + +]]> + + +]]> + + +]]> + + +]]> + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema-datatypes.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema-datatypes.xsd new file mode 100644 index 0000000000000..574949db19c49 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema-datatypes.xsd @@ -0,0 +1,154 @@ + + + + +]> + + + Note this schema is NOT a normative schema - - + It contains types derived from all the builtin simple type definitions + with the same local name but in a distinct namespace, for use + by applications which do no wish to import the full XMLSchema + schema. Since derivation is not symmetric, unexpected results may + follow from mixing references to these definitions with references + to the definitions in the XMLSchema namespace. For example, + although dt:positiveInteger is derived from xs:integer, the converse + does not hold. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema.xsd new file mode 100644 index 0000000000000..169ade092547c --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/schema10/XMLSchema.xsd @@ -0,0 +1,2364 @@ + + + + + + + + + + + Part 1 version: Id: structures.xsd,v 1.2 2004/01/15 11:34:25 ht Exp + Part 2 version: Id: datatypes.xsd,v 1.3 2004/01/23 18:11:13 ht Exp + + + + + + The schema corresponding to this document is normative, + with respect to the syntactic constraints it expresses in the + XML Schema language. The documentation (within <documentation> elements) + below, is not normative, but rather highlights important aspects of + the W3C Recommendation of which this is a part + + + + + The simpleType element and all of its members are defined + towards the end of this schema document + + + + + + Get access to the xml: attribute groups for xml:lang + as declared on 'schema' and 'documentation' below + + + + + + + + This type is extended by almost all schema types + to allow attributes from other namespaces to be + added to user schemas. + + + + + + + + + + + + + This type is extended by all types which allow annotation + other than <schema> itself + + + + + + + + + + + + + + + + This group is for the + elements which occur freely at the top level of schemas. + All of their types are based on the "annotated" type by extension. + + + + + + + + + + + + + This group is for the + elements which can self-redefine (see <redefine> below). + + + + + + + + + + + + + A utility type, not for public use + + + + + + + + + + + A utility type, not for public use + + + + + + + + + + + A utility type, not for public use + + #all or (possibly empty) subset of {extension, restriction} + + + + + + + + + + + + + + + + + A utility type, not for public use + + + + + + + + + + + + + A utility type, not for public use + + #all or (possibly empty) subset of {extension, restriction, list, union} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + for maxOccurs + + + + + + + + + + + + for all particles + + + + + + + for element, group and attributeGroup, + which both define and reference + + + + + + + + 'complexType' uses this + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This branch is short for + <complexContent> + <restriction base="xs:anyType"> + ... + </restriction> + </complexContent> + + + + + + + + + + + + + + + Will be restricted to required or forbidden + + + + + + Not allowed if simpleContent child is chosen. + May be overriden by setting on complexContent child. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This choice is added simply to + make this a valid restriction per the REC + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Overrides any setting on complexType parent. + + + + + + + + + + + + + + + This choice is added simply to + make this a valid restriction per the REC + + + + + + + + + + + + + + + + + No typeDefParticle group reference + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A utility type, not for public use + + #all or (possibly empty) subset of {substitution, extension, + restriction} + + + + + + + + + + + + + + + + + + + + + + + + + The element element can be used either + at the top level to define an element-type binding globally, + or within a content model to either reference a globally-defined + element or type or declare an element-type binding locally. + The ref form is not allowed at the top level. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + group type for explicit groups, named top-level groups and + group references + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + group type for the three kinds of group + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + This choice with min/max is here to + avoid a pblm with the Elt:All/Choice/Seq + Particle derivation constraint + + + + + + + + + + restricted max/min + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Only elements allowed inside + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + simple type for the value of the 'namespace' attr of + 'any' and 'anyAttribute' + + + + Value is + ##any - - any non-conflicting WFXML/attribute at all + + ##other - - any non-conflicting WFXML/attribute from + namespace other than targetNS + + ##local - - any unqualified non-conflicting WFXML/attribute + + one or - - any non-conflicting WFXML/attribute from + more URI the listed namespaces + references + (space separated) + + ##targetNamespace or ##local may appear in the above list, to + refer to the targetNamespace of the enclosing + schema or an absent targetNamespace respectively + + + + + + A utility type, not for public use + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A subset of XPath expressions for use +in selectors + A utility type, not for public +use + + + + The following pattern is intended to allow XPath + expressions per the following EBNF: + Selector ::= Path ( '|' Path )* + Path ::= ('.//')? Step ( '/' Step )* + Step ::= '.' | NameTest + NameTest ::= QName | '*' | NCName ':' '*' + child:: is also allowed + + + + + + + + + + + + + + + + + + + + + + + A subset of XPath expressions for use +in fields + A utility type, not for public +use + + + + The following pattern is intended to allow XPath + expressions per the same EBNF as for selector, + with the following change: + Path ::= ('.//')? ( Step '/' )* ( Step | '@' NameTest ) + + + + + + + + + + + + + + + + + + + + + + + + + + + The three kinds of identity constraints, all with + type of or derived from 'keybase'. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A utility type, not for public use + + A public identifier, per ISO 8879 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + notations for use within XML Schema schemas + + + + + + + + + Not the real urType, but as close an approximation as we can + get in the XML representation + + + + + + + + + + First the built-in primitive datatypes. These definitions are for + information only, the real built-in definitions are magic. + + + + For each built-in datatype in this schema (both primitive and + derived) can be uniquely addressed via a URI constructed + as follows: + 1) the base URI is the URI of the XML Schema namespace + 2) the fragment identifier is the name of the datatype + + For example, to address the int datatype, the URI is: + + http://www.w3.org/2001/XMLSchema#int + + Additionally, each facet definition element can be uniquely + addressed via a URI constructed as follows: + 1) the base URI is the URI of the XML Schema namespace + 2) the fragment identifier is the name of the facet + + For example, to address the maxInclusive facet, the URI is: + + http://www.w3.org/2001/XMLSchema#maxInclusive + + Additionally, each facet usage in a built-in datatype definition + can be uniquely addressed via a URI constructed as follows: + 1) the base URI is the URI of the XML Schema namespace + 2) the fragment identifier is the name of the datatype, followed + by a period (".") followed by the name of the facet + + For example, to address the usage of the maxInclusive facet in + the definition of int, the URI is: + + http://www.w3.org/2001/XMLSchema#int.maxInclusive + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + NOTATION cannot be used directly in a schema; rather a type + must be derived from it by specifying at least one enumeration + facet whose value is the name of a NOTATION declared in the + schema. + + + + + + + + + + Now the derived primitive types + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pattern specifies the content of section 2.12 of XML 1.0e2 + and RFC 3066 (Revised version of RFC 1766). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pattern matches production 7 from the XML spec + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + pattern matches production 5 from the XML spec + + + + + + + + + + + + + + + pattern matches production 4 from the Namespaces in XML spec + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + A utility type, not for public use + + + + + + + + + + + + + + + + + + + + + + #all or (possibly empty) subset of {restriction, union, list} + + + A utility type, not for public use + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Can be restricted to required or forbidden + + + + + + + + + + + + + + + + + + Required at the top level + + + + + + + + + + + + + + + + + + + Forbidden when nested + + + + + + + + + + + + + + + + + + + We should use a substitution group for facets, but + that's ruled out because it would allow users to + add their own, which we're not ready for yet. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + base attribute and simpleType child are mutually + exclusive, but one or other is required + + + + + + + + + + + + + + + + itemType attribute and simpleType child are mutually + exclusive, but one or other is required + + + + + + + + + + + + + + + + + + memberTypes attribute must be non-empty or there must be + at least one simpleType child + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-frameset.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-frameset.xsd new file mode 100644 index 0000000000000..0518a6145dd08 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-frameset.xsd @@ -0,0 +1,2847 @@ + + + + + + XHTML 1.0 (Second Edition) Frameset in XML Schema + + This is the same as HTML 4 Frameset except for + changes due to the differences between XML and SGML. + + Namespace = http://www.w3.org/1999/xhtml + + For further information, see: http://www.w3.org/TR/xhtml1 + + Copyright (c) 1998-2002 W3C (MIT, INRIA, Keio), + All Rights Reserved. + + The DTD version is identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" + + $Id: xhtml1-frameset.xsd,v 1.5 2002/08/28 09:53:29 mimasa Exp $ + + + + + + + + ================ Character mnemonic entities ========================= + + XHTML entity sets are identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent" + + PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent" + + PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent" + + + + + + ================== Imported Names ==================================== + + + + + + + media type, as per [RFC2045] + + + + + + + + + comma-separated list of media types, as per [RFC2045] + + + + + + + + + a character encoding, as per [RFC2045] + + + + + + + + + a space separated list of character encodings, as per [RFC2045] + + + + + + + + + a language code, as per [RFC3066] + + + + + + + + + a single character, as per section 2.2 of [XML] + + + + + + + + + + + one or more digits + + + + + + + + + + + tabindex attribute specifies the position of the current element + in the tabbing order for the current document. This value must be + a number between 0 and 32767. User agents should ignore leading zeros. + + + + + + + + + + + + space-separated list of link types + + + + + + + + + single or comma-separated list of media descriptors + + + + + + + + + + + a Uniform Resource Identifier, see [RFC2396] + + + + + + + + + a space separated list of Uniform Resource Identifiers + + + + + + + + + date and time information. ISO date format + + + + + + + + + script expression + + + + + + + + + style sheet data + + + + + + + + + used for titles etc. + + + + + + + + + render in this frame + + + + + + + + + + + nn for pixels or nn% for percentage length + + + + + + + + + + + pixel, percentage, or relative + + + + + + + + + + + comma-separated list of MultiLength + + + + + + + + + + + integer representing length in pixels + + + + + + + + these are used for image maps + + + + + + + + + + + + + + + + comma separated list of lengths + + + + + + + + + + + used for object, applet, img, input and iframe + + + + + + + + + + + + + + + a color using sRGB: #RRGGBB as Hex values + + There are also 16 widely known color names with their sRGB values: + + Black = #000000 Green = #008000 + Silver = #C0C0C0 Lime = #00FF00 + Gray = #808080 Olive = #808000 + White = #FFFFFF Yellow = #FFFF00 + Maroon = #800000 Navy = #000080 + Red = #FF0000 Blue = #0000FF + Purple = #800080 Teal = #008080 + Fuchsia= #FF00FF Aqua = #00FFFF + + + + + + + + + + =================== Generic Attributes =============================== + + + + + + + core attributes common to most elements + id document-wide unique id + class space separated list of classes + style associated style info + title advisory title/amplification + + + + + + + + + + + + internationalization attributes + lang language code (backwards compatible) + xml:lang language code (as per XML 1.0 spec) + dir direction for weak/neutral text + + + + + + + + + + + + + + + + + + attributes for common UI events + onclick a pointer button was clicked + ondblclick a pointer button was double clicked + onmousedown a pointer button was pressed down + onmouseup a pointer button was released + onmousemove a pointer was moved onto the element + onmouseout a pointer was moved away from the element + onkeypress a key was pressed and released + onkeydown a key was pressed down + onkeyup a key was released + + + + + + + + + + + + + + + + + + attributes for elements that can get the focus + accesskey accessibility key character + tabindex position in tabbing order + onfocus the element got the focus + onblur the element lost the focus + + + + + + + + + + + + + + + + + + text alignment for p, div, h1-h6. The default is + align="left" for ltr headings, "right" for rtl + + + + + + + + + + + + + + + + + =================== Text Elements ==================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + these can only occur at block level + + + + + + + + + + + + + these can only occur at block level + + + + + + + + + + + + + + + + + + + + + + "Inline" covers inline or "text-level" element + + + + + + + + + + + ================== Block level elements ============================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "Flow" mixes block and inline and is used for list items etc. + + + + + + + + + + + + + ================== Content models for exclusions ===================== + + + + + + + a elements use "Inline" excluding a + + + + + + + + + + + + + + + pre uses "Inline" excluding img, object, applet, big, small, + sub, sup, font, or basefont + + + + + + + + + + + + + + + + form uses "Flow" excluding form + + + + + + + + + + + + + button uses "Flow" but excludes a, form, form controls, iframe + + + + + + + + + + + + + + + + + + + + + + + + + ================ Document Structure ================================== + + + + + + + + + + + + + + + + + ================ Document Head ======================================= + + + + + + + + + + + + + + + + + + + + content model is "head.misc" combined with a single + title and an optional base element in any order + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The title element is not considered part of the flow of text. + It should be displayed, for example as the page header or + window title. Exactly one title is required per document. + + + + + + + + + + + + document base URI + + + + + + + + + + + + + generic metainformation + + + + + + + + + + + + + + + + Relationship values can be used in principle: + + a) for document specific toolbars/menus when used + with the link element in document head e.g. + start, contents, previous, next, index, end, help + b) to link to a separate style sheet (rel="stylesheet") + c) to make a link to a script (rel="script") + d) by stylesheets to control how collections of + html nodes are rendered into printed documents + e) to make a link to a printable version of this document + e.g. a PostScript or PDF version (rel="alternate" media="print") + + + + + + + + + + + + + + + + + + + style info, which may include CDATA sections + + + + + + + + + + + + + + + + script statements, which may include CDATA sections + + + + + + + + + + + + + + + + + + + + + + + alternate content container for non script-based rendering + + + + + + + + + + + + + + ======================= Frames ======================================= + + + + + + + only one noframes element permitted per document + + + + + + + + + + + + + + + + + + + reserved frame names start with "_" otherwise starts with letter + + + + + + + tiled window within frameset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + inline subwindow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + alternate content container for non frame-based rendering + + + + + + + + + + + + + =================== Document Body ==================================== + + + + + + + + + + + + + + + + + + + + + + + + + generic language/style container + + + + + + + + + + + + + + + =================== Paragraphs ======================================= + + + + + + + + + + + + + + + + + =================== Headings ========================================= + + There are six levels of headings from h1 (the most important) + to h6 (the least important). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Lists ============================================ + + + + + + + Unordered list bullet styles + + + + + + + + + + + + + Unordered list + + + + + + + + + + + + + + + + + + + + + + Ordered list numbering style + + 1 arabic numbers 1, 2, 3, ... + a lower alpha a, b, c, ... + A upper alpha A, B, C, ... + i lower roman i, ii, iii, ... + I upper roman I, II, III, ... + + The style is applied to the sequence number which by default + is reset to 1 for the first list item in an ordered list. + + + + + + + + + Ordered (numbered) list + + + + + + + + + + + + + + + + + + + + + + + single column list (DEPRECATED) + + + + + + + + + + + + + + + + + + + + + multiple column list (DEPRECATED) + + + + + + + + + + + + + + + + + + + + + LIStyle is constrained to: "(ULStyle|OLStyle)" + + + + + + + + + list item + + + + + + + + + + + + + + + + definition lists - dt for term, dd for its definition + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Address ========================================== + + + + + + + information on author + + + + + + + + + + + + + + + =================== Horizontal Rule ================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Preformatted Text ================================ + + + + + + + content is "Inline" excluding + "img|object|applet|big|small|sub|sup|font|basefont" + + + + + + + + + + + + + + + + =================== Block-like Quotes ================================ + + + + + + + + + + + + + + + + + =================== Text alignment =================================== + + + + + + + center content + + + + + + + + + + + + + + =================== Inserted/Deleted Text ============================ + + ins/del are allowed in block and inline content, but its + inappropriate to include block content within an ins element + occurring in inline content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================== The Anchor Element ================================ + + + + + + + content is "Inline" except that anchors shouldn't be nested + + + + + + + + + + + + + + + + + + + + + + + + + ===================== Inline Elements ================================ + + + + + + + generic language/style container + + + + + + + + + + + + + + + I18N BiDi over-ride + + + + + + + + + + + + + + + + + + + + + + + + + + forced line break + + + + + + + + + + + + + + + + + + + + + emphasis + + + + + + + + + + + + + + + strong emphasis + + + + + + + + + + + + + + + definitional + + + + + + + + + + + + + + + program code + + + + + + + + + + + + + + + sample + + + + + + + + + + + + + + + something user would type + + + + + + + + + + + + + + + variable + + + + + + + + + + + + + + + citation + + + + + + + + + + + + + + + abbreviation + + + + + + + + + + + + + + + acronym + + + + + + + + + + + + + + + inlined quote + + + + + + + + + + + + + + + + subscript + + + + + + + + + + + + + + + superscript + + + + + + + + + + + + + + + fixed pitch font + + + + + + + + + + + + + + + italic font + + + + + + + + + + + + + + + bold font + + + + + + + + + + + + + + + bigger font + + + + + + + + + + + + + + + smaller font + + + + + + + + + + + + + + + underline + + + + + + + + + + + + + + + strike-through + + + + + + + + + + + + + + + strike-through + + + + + + + + + + + + + + + base font size + + + + + + + + + + + + + + local change to font + + + + + + + + + + + + + + + + + + ==================== Object ====================================== + + object is used to embed objects as part of HTML pages. + param elements should precede other content. Parameters + can also be expressed as attribute/value pairs on the + object element itself when brevity is desired. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + param is used to supply a named property value. + In XML it would seem natural to follow RDF and support an + abbreviated syntax where the param elements are replaced + by attribute value pairs on the object start tag. + + + + + + + + + + + + + + + + + + + + + + =================== Java applet ================================== + + One of code or object attributes must be present. + Place param elements before other content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Images =========================================== + + To avoid accessibility problems for people who aren't + able to see the image, you should provide a text + description using the alt and longdesc attributes. + In addition, avoid the use of server-side image maps. + + + + + + + + + + + + + + + + usemap points to a map element which may be in this document + or an external document, although the latter is not widely supported + + + + + + + + + + + + + + + + + + + + ================== Client-side image maps ============================ + + These can be placed in the same document or grouped in a + separate document although this isn't yet widely supported + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================ Forms =============================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Each label must not contain more than ONE field + Label elements shouldn't be nested. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + form control + + + + + + + + + + the name attribute is required for all but submit & reset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option selector + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option group + + + + + + + + + + + + + + + + + + + + + + selectable choice + + + + + + + + + + + + + + + + + + + + + + + + + + + multi-line text field + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The fieldset element is used to group form fields. + Only one legend element should occur in the content + and if present should only be preceded by whitespace. + + NOTE: this content model is different from the XHTML 1.0 DTD, + closer to the intended content model in HTML4 DTD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fieldset label + + + + + + + + + + + + + + + + + Content is "Flow" excluding a, form and form controls + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + single-line text input control (DEPRECATED) + + + + + + + + + + + + ======================= Tables ======================================= + + Derived from IETF HTML table standard, see [RFC1942] + + + + + + + The border attribute sets the thickness of the frame around the + table. The default units are screen pixels. + + The frame attribute specifies which parts of the frame around + the table should be rendered. The values are not the same as + CALS to avoid a name clash with the valign attribute. + + + + + + + + + + + + + + + + + + + The rules attribute defines which rules to draw between cells: + + If rules is absent then assume: + "none" if border is absent or border="0" otherwise "all" + + + + + + + + + + + + + + + horizontal placement of table relative to document + + + + + + + + + + + + + horizontal alignment attributes for cell contents + + char alignment char, e.g. char=":" + charoff offset for alignment char + + + + + + + + + + + + + + + + + + + + + vertical alignment attributes for cell contents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Use thead to duplicate headers when breaking table + across page boundaries, or for static headers when + tbody sections are rendered in scrolling panel. + + Use tfoot to duplicate footers when breaking table + across page boundaries, or for static footers when + tbody sections are rendered in scrolling panel. + + Use multiple tbody sections when rules are needed + between groups of table rows. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + colgroup groups a set of col elements. It allows you to group + several semantically related columns together. + + + + + + + + + + + + + + + + + + col elements define the alignment properties for cells in + one or more columns. + + The width attribute specifies the width of the columns, e.g. + + width=64 width in screen pixels + width=0.5* relative width of 0.5 + + The span attribute causes the attributes of one + col element to apply to more than one column. + + + + + + + + + + + + + + + + + + + + + + + + + + + + Scope is simpler than headers attribute for common tables + + + + + + + + + + + + + th is for headers, td for data and for cells acting as both + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-strict.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-strict.xsd new file mode 100644 index 0000000000000..93b80b6678826 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-strict.xsd @@ -0,0 +1,2211 @@ + + + + + + XHTML 1.0 (Second Edition) Strict in XML Schema + + This is the same as HTML 4 Strict except for + changes due to the differences between XML and SGML. + + Namespace = http://www.w3.org/1999/xhtml + + For further information, see: http://www.w3.org/TR/xhtml1 + + Copyright (c) 1998-2002 W3C (MIT, INRIA, Keio), + All Rights Reserved. + + The DTD version is identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" + + $Id: xhtml1-strict.xsd,v 1.2 2002/08/28 08:05:44 mimasa Exp $ + + + + + + + + ================ Character mnemonic entities ========================= + + XHTML entity sets are identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent" + + PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent" + + PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent" + + + + + + ================== Imported Names ==================================== + + + + + + + media type, as per [RFC2045] + + + + + + + + + comma-separated list of media types, as per [RFC2045] + + + + + + + + + a character encoding, as per [RFC2045] + + + + + + + + + a space separated list of character encodings, as per [RFC2045] + + + + + + + + + a language code, as per [RFC3066] + + + + + + + + + a single character, as per section 2.2 of [XML] + + + + + + + + + + + one or more digits + + + + + + + + + + + tabindex attribute specifies the position of the current element + in the tabbing order for the current document. This value must be + a number between 0 and 32767. User agents should ignore leading zeros. + + + + + + + + + + + + space-separated list of link types + + + + + + + + + single or comma-separated list of media descriptors + + + + + + + + + + + a Uniform Resource Identifier, see [RFC2396] + + + + + + + + + a space separated list of Uniform Resource Identifiers + + + + + + + + + date and time information. ISO date format + + + + + + + + + script expression + + + + + + + + + style sheet data + + + + + + + + + used for titles etc. + + + + + + + + + nn for pixels or nn% for percentage length + + + + + + + + + + + pixel, percentage, or relative + + + + + + + + + + + integer representing length in pixels + + + + + + + + these are used for image maps + + + + + + + + + + + + + + + + comma separated list of lengths + + + + + + + + + + =================== Generic Attributes =============================== + + + + + + + core attributes common to most elements + id document-wide unique id + class space separated list of classes + style associated style info + title advisory title/amplification + + + + + + + + + + + + internationalization attributes + lang language code (backwards compatible) + xml:lang language code (as per XML 1.0 spec) + dir direction for weak/neutral text + + + + + + + + + + + + + + + + + + attributes for common UI events + onclick a pointer button was clicked + ondblclick a pointer button was double clicked + onmousedown a pointer button was pressed down + onmouseup a pointer button was released + onmousemove a pointer was moved onto the element + onmouseout a pointer was moved away from the element + onkeypress a key was pressed and released + onkeydown a key was pressed down + onkeyup a key was released + + + + + + + + + + + + + + + + + + attributes for elements that can get the focus + accesskey accessibility key character + tabindex position in tabbing order + onfocus the element got the focus + onblur the element lost the focus + + + + + + + + + + + + + + + + + =================== Text Elements ==================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + these can only occur at block level + + + + + + + + + + + + + + + + + + + + + + "Inline" covers inline or "text-level" elements + + + + + + + + + + + ================== Block level elements ============================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "Flow" mixes block and inline and is used for list items etc. + + + + + + + + + + + + + ================== Content models for exclusions ===================== + + + + + + + a elements use "Inline" excluding a + + + + + + + + + + + + + + + pre uses "Inline" excluding big, small, sup or sup + + + + + + + + + + + + + + + + form uses "Block" excluding form + + + + + + + + + + + + button uses "Flow" but excludes a, form and form controls + + + + + + + + + + + + + + + + + + + ================ Document Structure ================================== + + + + + + + + + + + + + + + + + ================ Document Head ======================================= + + + + + + + + + + + + + + + + + + + content model is "head.misc" combined with a single + title and an optional base element in any order + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The title element is not considered part of the flow of text. + It should be displayed, for example as the page header or + window title. Exactly one title is required per document. + + + + + + + + + + + + document base URI + + + + + + + + + + + + generic metainformation + + + + + + + + + + + + + + + + Relationship values can be used in principle: + + a) for document specific toolbars/menus when used + with the link element in document head e.g. + start, contents, previous, next, index, end, help + b) to link to a separate style sheet (rel="stylesheet") + c) to make a link to a script (rel="script") + d) by stylesheets to control how collections of + html nodes are rendered into printed documents + e) to make a link to a printable version of this document + e.g. a PostScript or PDF version (rel="alternate" media="print") + + + + + + + + + + + + + + + + + + style info, which may include CDATA sections + + + + + + + + + + + + + + + + script statements, which may include CDATA sections + + + + + + + + + + + + + + + + + + + + + + alternate content container for non script-based rendering + + + + + + + + + + + + + + =================== Document Body ==================================== + + + + + + + + + + + + + + + + + + + generic language/style container + + + + + + + + + + + + + + =================== Paragraphs ======================================= + + + + + + + + + + + + + + + + =================== Headings ========================================= + + There are six levels of headings from h1 (the most important) + to h6 (the least important). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Lists ============================================ + + + + + + + Unordered list + + + + + + + + + + + + + + Ordered (numbered) list + + + + + + + + + + + + + + list item + + + + + + + + + + + + + + definition lists - dt for term, dd for its definition + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Address ========================================== + + + + + + + information on author + + + + + + + + + + + + + + =================== Horizontal Rule ================================== + + + + + + + + + + + + =================== Preformatted Text ================================ + + + + + + + content is "Inline" excluding "img|object|big|small|sub|sup" + + + + + + + + + + + + + + + =================== Block-like Quotes ================================ + + + + + + + + + + + + + + + + + =================== Inserted/Deleted Text ============================ + + ins/del are allowed in block and inline content, but its + inappropriate to include block content within an ins element + occurring in inline content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================== The Anchor Element ================================ + + + + + + + content is "Inline" except that anchors shouldn't be nested + + + + + + + + + + + + + + + + + + + + + + + + ===================== Inline Elements ================================ + + + + + + + generic language/style container + + + + + + + + + + + + + + + I18N BiDi over-ride + + + + + + + + + + + + + + + + + + + + + + + + + + forced line break + + + + + + + + + + + emphasis + + + + + + + + + + + + + + + strong emphasis + + + + + + + + + + + + + + + definitional + + + + + + + + + + + + + + + program code + + + + + + + + + + + + + + + sample + + + + + + + + + + + + + + + something user would type + + + + + + + + + + + + + + + variable + + + + + + + + + + + + + + + citation + + + + + + + + + + + + + + + abbreviation + + + + + + + + + + + + + + + acronym + + + + + + + + + + + + + + + inlined quote + + + + + + + + + + + + + + + + subscript + + + + + + + + + + + + + + + superscript + + + + + + + + + + + + + + + fixed pitch font + + + + + + + + + + + + + + + italic font + + + + + + + + + + + + + + + bold font + + + + + + + + + + + + + + + bigger font + + + + + + + + + + + + + + + smaller font + + + + + + + + + + + + + + ==================== Object ====================================== + + object is used to embed objects as part of HTML pages. + param elements should precede other content. Parameters + can also be expressed as attribute/value pairs on the + object element itself when brevity is desired. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + param is used to supply a named property value. + In XML it would seem natural to follow RDF and support an + abbreviated syntax where the param elements are replaced + by attribute value pairs on the object start tag. + + + + + + + + + + + + + + + + + + + + + + =================== Images =========================================== + + To avoid accessibility problems for people who aren't + able to see the image, you should provide a text + description using the alt and longdesc attributes. + In addition, avoid the use of server-side image maps. + Note that in this DTD there is no name attribute. That + is only available in the transitional and frameset DTD. + + + + + + + + + + + + + + + usemap points to a map element which may be in this document + or an external document, although the latter is not widely supported + + + + + + + + + + + + + + + + ================== Client-side image maps ============================ + + These can be placed in the same document or grouped in a + separate document although this isn't yet widely supported + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================ Forms =============================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Each label must not contain more than ONE field + Label elements shouldn't be nested. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + form control + + + + + + + + + + the name attribute is required for all but submit & reset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option selector + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option group + + + + + + + + + + + + + + + + + + + + + + selectable choice + + + + + + + + + + + + + + + + + + + + + + + + + + + multi-line text field + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The fieldset element is used to group form fields. + Only one legend element should occur in the content + and if present should only be preceded by whitespace. + + NOTE: this content model is different from the XHTML 1.0 DTD, + closer to the intended content model in HTML4 DTD + + + + + + + + + + + + + + + + + + + + fieldset label + + + + + + + + + + + + + + + + Content is "Flow" excluding a, form and form controls + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ======================= Tables ======================================= + + Derived from IETF HTML table standard, see [RFC1942] + + + + + + + The border attribute sets the thickness of the frame around the + table. The default units are screen pixels. + + The frame attribute specifies which parts of the frame around + the table should be rendered. The values are not the same as + CALS to avoid a name clash with the valign attribute. + + + + + + + + + + + + + + + + + + + The rules attribute defines which rules to draw between cells: + + If rules is absent then assume: + "none" if border is absent or border="0" otherwise "all" + + + + + + + + + + + + + + + horizontal alignment attributes for cell contents + + char alignment char, e.g. char=':' + charoff offset for alignment char + + + + + + + + + + + + + + + + + + + + + vertical alignment attributes for cell contents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Use thead to duplicate headers when breaking table + across page boundaries, or for static headers when + tbody sections are rendered in scrolling panel. + + Use tfoot to duplicate footers when breaking table + across page boundaries, or for static footers when + tbody sections are rendered in scrolling panel. + + Use multiple tbody sections when rules are needed + between groups of table rows. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + colgroup groups a set of col elements. It allows you to group + several semantically related columns together. + + + + + + + + + + + + + + + + + + col elements define the alignment properties for cells in + one or more columns. + + The width attribute specifies the width of the columns, e.g. + + width=64 width in screen pixels + width=0.5* relative width of 0.5 + + The span attribute causes the attributes of one + col element to apply to more than one column. + + + + + + + + + + + + + + + + + + + + + + + + + + + Scope is simpler than headers attribute for common tables + + + + + + + + + + + + + th is for headers, td for data and for cells acting as both + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-transitional.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-transitional.xsd new file mode 100644 index 0000000000000..8ce44fb9aff62 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml10/xhtml1-transitional.xsd @@ -0,0 +1,2755 @@ + + + + + + XHTML 1.0 (Second Edition) Transitional in XML Schema + + This is the same as HTML 4 Transitional except for + changes due to the differences between XML and SGML. + + Namespace = http://www.w3.org/1999/xhtml + + For further information, see: http://www.w3.org/TR/xhtml1 + + Copyright (c) 1998-2002 W3C (MIT, INRIA, Keio), + All Rights Reserved. + + The DTD version is identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" + + $Id: xhtml1-transitional.xsd,v 1.5 2002/08/28 09:53:29 mimasa Exp $ + + + + + + + + ================ Character mnemonic entities ========================= + + XHTML entity sets are identified by the PUBLIC and SYSTEM identifiers: + + PUBLIC "-//W3C//ENTITIES Latin 1 for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-lat1.ent" + + PUBLIC "-//W3C//ENTITIES Special for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent" + + PUBLIC "-//W3C//ENTITIES Symbols for XHTML//EN" + SYSTEM "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent" + + + + + + ================== Imported Names ==================================== + + + + + + + media type, as per [RFC2045] + + + + + + + + + comma-separated list of media types, as per [RFC2045] + + + + + + + + + a character encoding, as per [RFC2045] + + + + + + + + + a space separated list of character encodings, as per [RFC2045] + + + + + + + + + a language code, as per [RFC3066] + + + + + + + + + a single character, as per section 2.2 of [XML] + + + + + + + + + + + one or more digits + + + + + + + + + + + tabindex attribute specifies the position of the current element + in the tabbing order for the current document. This value must be + a number between 0 and 32767. User agents should ignore leading zeros. + + + + + + + + + + + + space-separated list of link types + + + + + + + + + single or comma-separated list of media descriptors + + + + + + + + + + + a Uniform Resource Identifier, see [RFC2396] + + + + + + + + + a space separated list of Uniform Resource Identifiers + + + + + + + + + date and time information. ISO date format + + + + + + + + + script expression + + + + + + + + + style sheet data + + + + + + + + + used for titles etc. + + + + + + + + + render in this frame + + + + + + + + + + + nn for pixels or nn% for percentage length + + + + + + + + + + + pixel, percentage, or relative + + + + + + + + + + + integer representing length in pixels + + + + + + + + these are used for image maps + + + + + + + + + + + + + + + + comma separated list of lengths + + + + + + + + + + + used for object, applet, img, input and iframe + + + + + + + + + + + + + + + a color using sRGB: #RRGGBB as Hex values + + There are also 16 widely known color names with their sRGB values: + + Black = #000000 Green = #008000 + Silver = #C0C0C0 Lime = #00FF00 + Gray = #808080 Olive = #808000 + White = #FFFFFF Yellow = #FFFF00 + Maroon = #800000 Navy = #000080 + Red = #FF0000 Blue = #0000FF + Purple = #800080 Teal = #008080 + Fuchsia= #FF00FF Aqua = #00FFFF + + + + + + + + + + =================== Generic Attributes =============================== + + + + + + + core attributes common to most elements + id document-wide unique id + class space separated list of classes + style associated style info + title advisory title/amplification + + + + + + + + + + + + internationalization attributes + lang language code (backwards compatible) + xml:lang language code (as per XML 1.0 spec) + dir direction for weak/neutral text + + + + + + + + + + + + + + + + + + attributes for common UI events + onclick a pointer button was clicked + ondblclick a pointer button was double clicked + onmousedown a pointer button was pressed down + onmouseup a pointer button was released + onmousemove a pointer was moved onto the element + onmouseout a pointer was moved away from the element + onkeypress a key was pressed and released + onkeydown a key was pressed down + onkeyup a key was released + + + + + + + + + + + + + + + + + + attributes for elements that can get the focus + accesskey accessibility key character + tabindex position in tabbing order + onfocus the element got the focus + onblur the element lost the focus + + + + + + + + + + + + + + + + + + text alignment for p, div, h1-h6. The default is + align="left" for ltr headings, "right" for rtl + + + + + + + + + + + + + + + + + =================== Text Elements ==================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + these can only occur at block level + + + + + + + + + + + + + these can only occur at block level + + + + + + + + + + + + + + + + + + + + + + "Inline" covers inline or "text-level" element + + + + + + + + + + + ================== Block level elements ============================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + "Flow" mixes block and inline and is used for list items etc. + + + + + + + + + + + + + ================== Content models for exclusions ===================== + + + + + + + a elements use "Inline" excluding a + + + + + + + + + + + + + + + pre uses "Inline" excluding img, object, applet, big, small, + font, or basefont + + + + + + + + + + + + + + + + form uses "Flow" excluding form + + + + + + + + + + + + + button uses "Flow" but excludes a, form, form controls, iframe + + + + + + + + + + + + + + + + + + + + + + + + + ================ Document Structure ================================== + + + + + + + + + + + + + + + + + ================ Document Head ======================================= + + + + + + + + + + + + + + + + + + + + content model is "head.misc" combined with a single + title and an optional base element in any order + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The title element is not considered part of the flow of text. + It should be displayed, for example as the page header or + window title. Exactly one title is required per document. + + + + + + + + + + + + document base URI + + + + + + + + + + + + + generic metainformation + + + + + + + + + + + + + + + + Relationship values can be used in principle: + + a) for document specific toolbars/menus when used + with the link element in document head e.g. + start, contents, previous, next, index, end, help + b) to link to a separate style sheet (rel="stylesheet") + c) to make a link to a script (rel="script") + d) by stylesheets to control how collections of + html nodes are rendered into printed documents + e) to make a link to a printable version of this document + e.g. a PostScript or PDF version (rel="alternate" media="print") + + + + + + + + + + + + + + + + + + + style info, which may include CDATA sections + + + + + + + + + + + + + + + + script statements, which may include CDATA sections + + + + + + + + + + + + + + + + + + + + + + + alternate content container for non script-based rendering + + + + + + + + + + + + + + ======================= Frames ======================================= + + + + + + + inline subwindow + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + alternate content container for non frame-based rendering + + + + + + + + + + + + + + =================== Document Body ==================================== + + + + + + + + + + + + + + + + + + + + + + + + + generic language/style container + + + + + + + + + + + + + + + =================== Paragraphs ======================================= + + + + + + + + + + + + + + + + + =================== Headings ========================================= + + There are six levels of headings from h1 (the most important) + to h6 (the least important). + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Lists ============================================ + + + + + + + Unordered list bullet styles + + + + + + + + + + + + + Unordered list + + + + + + + + + + + + + + + + + + + + + + Ordered list numbering style + + 1 arabic numbers 1, 2, 3, ... + a lower alpha a, b, c, ... + A upper alpha A, B, C, ... + i lower roman i, ii, iii, ... + I upper roman I, II, III, ... + + The style is applied to the sequence number which by default + is reset to 1 for the first list item in an ordered list. + + + + + + + + + Ordered (numbered) list + + + + + + + + + + + + + + + + + + + + + + + single column list (DEPRECATED) + + + + + + + + + + + + + + + + + + + + + multiple column list (DEPRECATED) + + + + + + + + + + + + + + + + + + + + + LIStyle is constrained to: "(ULStyle|OLStyle)" + + + + + + + + + list item + + + + + + + + + + + + + + + + definition lists - dt for term, dd for its definition + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Address ========================================== + + + + + + + information on author + + + + + + + + + + + + + + + =================== Horizontal Rule ================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Preformatted Text ================================ + + + + + + + content is "Inline" excluding + "img|object|applet|big|small|sub|sup|font|basefont" + + + + + + + + + + + + + + + + =================== Block-like Quotes ================================ + + + + + + + + + + + + + + + + + =================== Text alignment =================================== + + + + + + + center content + + + + + + + + + + + + + + =================== Inserted/Deleted Text ============================ + + ins/del are allowed in block and inline content, but its + inappropriate to include block content within an ins element + occurring in inline content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================== The Anchor Element ================================ + + + + + + + content is "Inline" except that anchors shouldn't be nested + + + + + + + + + + + + + + + + + + + + + + + + + ===================== Inline Elements ================================ + + + + + + + generic language/style container + + + + + + + + + + + + + + + I18N BiDi over-ride + + + + + + + + + + + + + + + + + + + + + + + + + + forced line break + + + + + + + + + + + + + + + + + + + + + emphasis + + + + + + + + + + + + + + + strong emphasis + + + + + + + + + + + + + + + definitional + + + + + + + + + + + + + + + program code + + + + + + + + + + + + + + + sample + + + + + + + + + + + + + + + something user would type + + + + + + + + + + + + + + + variable + + + + + + + + + + + + + + + citation + + + + + + + + + + + + + + + abbreviation + + + + + + + + + + + + + + + acronym + + + + + + + + + + + + + + + inlined quote + + + + + + + + + + + + + + + + subscript + + + + + + + + + + + + + + + superscript + + + + + + + + + + + + + + + fixed pitch font + + + + + + + + + + + + + + + italic font + + + + + + + + + + + + + + + bold font + + + + + + + + + + + + + + + bigger font + + + + + + + + + + + + + + + smaller font + + + + + + + + + + + + + + + underline + + + + + + + + + + + + + + + strike-through + + + + + + + + + + + + + + + strike-through + + + + + + + + + + + + + + + base font size + + + + + + + + + + + + + + local change to font + + + + + + + + + + + + + + + + + + ==================== Object ====================================== + + object is used to embed objects as part of HTML pages. + param elements should precede other content. Parameters + can also be expressed as attribute/value pairs on the + object element itself when brevity is desired. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + param is used to supply a named property value. + In XML it would seem natural to follow RDF and support an + abbreviated syntax where the param elements are replaced + by attribute value pairs on the object start tag. + + + + + + + + + + + + + + + + + + + + + + =================== Java applet ================================== + + One of code or object attributes must be present. + Place param elements before other content. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + =================== Images =========================================== + + To avoid accessibility problems for people who aren't + able to see the image, you should provide a text + description using the alt and longdesc attributes. + In addition, avoid the use of server-side image maps. + + + + + + + + + + + + + + + + usemap points to a map element which may be in this document + or an external document, although the latter is not widely supported + + + + + + + + + + + + + + + + + + + + ================== Client-side image maps ============================ + + These can be placed in the same document or grouped in a + separate document although this isn't yet widely supported + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ================ Forms =============================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Each label must not contain more than ONE field + Label elements shouldn't be nested. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + form control + + + + + + + + + + the name attribute is required for all but submit & reset + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option selector + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + option group + + + + + + + + + + + + + + + + + + + + + + selectable choice + + + + + + + + + + + + + + + + + + + + + + + + + + + multi-line text field + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + The fieldset element is used to group form fields. + Only one legend element should occur in the content + and if present should only be preceded by whitespace. + + NOTE: this content model is different from the XHTML 1.0 DTD, + closer to the intended content model in HTML4 DTD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + fieldset label + + + + + + + + + + + + + + + + + Content is "Flow" excluding a, form and form controls + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + single-line text input control (DEPRECATED) + + + + + + + + + + + + ======================= Tables ======================================= + + Derived from IETF HTML table standard, see [RFC1942] + + + + + + + The border attribute sets the thickness of the frame around the + table. The default units are screen pixels. + + The frame attribute specifies which parts of the frame around + the table should be rendered. The values are not the same as + CALS to avoid a name clash with the valign attribute. + + + + + + + + + + + + + + + + + + + The rules attribute defines which rules to draw between cells: + + If rules is absent then assume: + "none" if border is absent or border="0" otherwise "all" + + + + + + + + + + + + + + + horizontal placement of table relative to document + + + + + + + + + + + + + horizontal alignment attributes for cell contents + + char alignment char, e.g. char=':' + charoff offset for alignment char + + + + + + + + + + + + + + + + + + + + + vertical alignment attributes for cell contents + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Use thead to duplicate headers when breaking table + across page boundaries, or for static headers when + tbody sections are rendered in scrolling panel. + + Use tfoot to duplicate footers when breaking table + across page boundaries, or for static footers when + tbody sections are rendered in scrolling panel. + + Use multiple tbody sections when rules are needed + between groups of table rows. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + colgroup groups a set of col elements. It allows you to group + several semantically related columns together. + + + + + + + + + + + + + + + + + + col elements define the alignment properties for cells in + one or more columns. + + The width attribute specifies the width of the columns, e.g. + + width=64 width in screen pixels + width=0.5* relative width of 0.5 + + The span attribute causes the attributes of one + col element to apply to more than one column. + + + + + + + + + + + + + + + + + + + + + + + + + + + + Scope is simpler than headers attribute for common tables + + + + + + + + + + + + + th is for headers, td for data and for cells acting as both + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-attribs-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-attribs-1.xsd new file mode 100644 index 0000000000000..f07528a9ef1bf --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-attribs-1.xsd @@ -0,0 +1,73 @@ + + + + + + + This is the XML Schema common attributes module for XHTML + $Id: xhtml-attribs-1.xsd,v 1.9 2009/11/18 17:59:51 ahby Exp $ + + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-base-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-base-1.xsd new file mode 100644 index 0000000000000..a23df79d4e1ba --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-base-1.xsd @@ -0,0 +1,36 @@ + + + + + + + Base element + This is the XML Schema Base Element module for XHTML + + * base + + This module declares the base element type and its attributes, + used to define a base URI against which relative URIs in the + document will be resolved. + + $Id: xhtml-base-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-bdo-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-bdo-1.xsd new file mode 100644 index 0000000000000..15251c61cca02 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-bdo-1.xsd @@ -0,0 +1,71 @@ + + + + + + Bidirectional Override (bdo) Element + This is the XML Schema BDO Element module for XHTML + + This modules declares the element 'bdo' and 'dir' attributes, + Used to override the Unicode bidirectional algorithm for selected + fragments of text. + Bidirectional text support includes both the bdo element and + the 'dir' attribute. + + $Id: xhtml-bdo-1.xsd,v 1.6 2009/11/18 17:59:51 ahby Exp $ + + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkphras-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkphras-1.xsd new file mode 100644 index 0000000000000..9a795f8f0ce4c --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkphras-1.xsd @@ -0,0 +1,160 @@ + + + + + + + + + This is the XML Schema Block Phrasal support module for XHTML + $Id: xhtml-blkphras-1.xsd,v 1.7 2008/07/05 04:11:00 ahby Exp $ + + + + + + Block Phrasal + This module declares the elements and their attributes used to + support block-level phrasal markup. + This is the XML Schema block phrasal elements module for XHTML + + * address, blockquote, pre, h1, h2, h3, h4, h5, h6 + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkpres-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkpres-1.xsd new file mode 100644 index 0000000000000..cf42303a686ce --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkpres-1.xsd @@ -0,0 +1,37 @@ + + + + + + This is the XML SchemaBlock presentation element module for XHTML + $Id: xhtml-blkpres-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + Block Presentational Elements + + * hr + + This module declares the elements and their attributes used to + support block-level presentational markup. + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkstruct-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkstruct-1.xsd new file mode 100644 index 0000000000000..1e658580e7a3a --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-blkstruct-1.xsd @@ -0,0 +1,49 @@ + + + + + + Block Structural + + * div, p + + This module declares the elements and their attributes used to + support block-level structural markup. + + This is the XML Schema Block Structural module for XHTML + $Id: xhtml-blkstruct-1.xsd,v 1.3 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-copyright-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-copyright-1.xsd new file mode 100644 index 0000000000000..24c84fd476d2d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-copyright-1.xsd @@ -0,0 +1,29 @@ + + + + + + This is XHTML, a reformulation of HTML as a modular XML application + The Extensible HyperText Markup Language (XHTML) + Copyright ©1998-2005 World Wide Web Consortium + (Massachusetts Institute of Technology, European Research Consortium + for Informatics and Mathematics, Keio University). + All Rights Reserved. + + Permission to use, copy, modify and distribute the XHTML Schema + modules and their accompanying xs:documentation for any purpose + and without fee is hereby granted in perpetuity, provided that the above + copyright notice and this paragraph appear in all copies. + The copyright holders make no representation about the suitability of + these XML Schema modules for any purpose. + + They are provided "as is" without expressed or implied warranty. + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-csismap-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-csismap-1.xsd new file mode 100644 index 0000000000000..42f802d0f7989 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-csismap-1.xsd @@ -0,0 +1,96 @@ + + + + + + + Client-side Image Maps + This is the XML Schema Client-side Image Maps module for XHTML + + * area, map + + This module declares elements and attributes to support client-side + image maps. + + $Id: xhtml-csismap-1.xsd,v 1.3 2009/09/30 15:12:48 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-datatypes-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-datatypes-1.xsd new file mode 100644 index 0000000000000..ab7bac0ee858c --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-datatypes-1.xsd @@ -0,0 +1,242 @@ + + + + + XHTML Datatypes + This is the XML Schema datatypes module for XHTML + + Defines containers for the XHTML datatypes, many of + these imported from other specifications and standards. + + $Id: xhtml-datatypes-1.xsd,v 1.12 2009/09/30 15:12:48 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-edit-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-edit-1.xsd new file mode 100644 index 0000000000000..44380b23e0ef8 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-edit-1.xsd @@ -0,0 +1,39 @@ + + + + + + + Editing Elements + This is the XML Schema Editing Markup module for XHTML + + * ins, del + + This module declares element types and attributes used to indicate + inserted and deleted content while editing a document. + + $Id: xhtml-edit-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-events-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-events-1.xsd new file mode 100644 index 0000000000000..381f6dd506881 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-events-1.xsd @@ -0,0 +1,130 @@ + + + + + + + This is the XML Schema Intrinsic Events module for XHTML + $Id: xhtml-events-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $ + + + + + + Intrinsic Event Attributes + These are the event attributes defined in HTML 4, + Section 18.2.3 "Intrinsic Events". + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-form-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-form-1.xsd new file mode 100644 index 0000000000000..d7a970f4f238f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-form-1.xsd @@ -0,0 +1,327 @@ + + + + + + + Forms + This is the XML Schema Forms module for XHTML + + * form, label, input, select, optgroup, option, + textarea, fieldset, legend, button + + This module declares markup to provide support for online + forms, based on the features found in HTML 4.0 forms. + + + $Id: xhtml-form-1.xsd,v 1.4 2009/09/30 15:22:38 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-framework-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-framework-1.xsd new file mode 100644 index 0000000000000..05b906d44806c --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-framework-1.xsd @@ -0,0 +1,66 @@ + + + + + This is the XML Schema Modular Framework support module for XHTML + $Id: xhtml-framework-1.xsd,v 1.5 2005/09/26 23:37:47 ahby Exp $ + + + + + + XHTML Modular Framework + This required module instantiates the necessary modules + needed to support the XHTML modularization framework. + + The Schema modules instantiated are: + + notations + + datatypes + + common attributes + + character entities + + + + + + + + This module defines XHTML Attribute DataTypes + + + + + + + + This module defines Common attributes for XHTML + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-hypertext-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-hypertext-1.xsd new file mode 100644 index 0000000000000..2f4c81bc89578 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-hypertext-1.xsd @@ -0,0 +1,47 @@ + + + + + + + Hypertext Module + This is the XML Schema Hypertext module for XHTML + + * a + + This module declares the anchor ('a') element type, which + defines the source of a hypertext link. The destination + (or link 'target') is identified via its 'id' attribute + rather than the 'name' attribute as was used in HTML. + + $Id: xhtml-hypertext-1.xsd,v 1.4 2005/09/26 23:37:47 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-image-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-image-1.xsd new file mode 100644 index 0000000000000..4d6e9ab1645f4 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-image-1.xsd @@ -0,0 +1,46 @@ + + + + + + + Images + This is the XML Schema Images module for XHTML + + * img + + This module provides markup to support basic image embedding. + + To avoid problems with text-only UAs as well as to make + image content understandable and navigable to users of + non-visual UAs, you need to provide a description with + the 'alt' attribute, and avoid server-side image maps. + + + $Id: xhtml-image-1.xsd,v 1.3 2009/09/30 15:22:38 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlphras-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlphras-1.xsd new file mode 100644 index 0000000000000..919c59de3b332 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlphras-1.xsd @@ -0,0 +1,163 @@ + + + + + + + This is the XML Schema Inline Phrasal support module for XHTML + $Id: xhtml-inlphras-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $ + + + + + + Inline Phrasal. + This module declares the elements and their attributes used to + support inline-level phrasal markup. + This is the XML Schema Inline Phrasal module for XHTML + + * abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var + + $Id: xhtml-inlphras-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlpres-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlpres-1.xsd new file mode 100644 index 0000000000000..a053447c284e9 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlpres-1.xsd @@ -0,0 +1,39 @@ + + + + + + This is the XML Schema Inline Presentation element module for XHTML + $Id: xhtml-inlpres-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + Inline Presentational Elements + + * b, big, i, small, sub, sup, tt + + This module declares the elements and their attributes used to + support inline-level presentational markup. + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstruct-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstruct-1.xsd new file mode 100644 index 0000000000000..635eb5f193dd1 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstruct-1.xsd @@ -0,0 +1,50 @@ + + + + + + This is the XML Schema Inline Structural support module for XHTML + $Id: xhtml-inlstruct-1.xsd,v 1.4 2005/09/26 22:54:53 ahby Exp $ + + + + + + Inline Structural. + This module declares the elements and their attributes + used to support inline-level structural markup. + This is the XML Schema Inline Structural element module for XHTML + + * br, span + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstyle-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstyle-1.xsd new file mode 100644 index 0000000000000..ef93c2dcefac4 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-inlstyle-1.xsd @@ -0,0 +1,27 @@ + + + + + + Inline Style module + This is the XML Schema Inline Style module for XHTML + + * styloe attribute + + This module declares the 'style' attribute, used to support inline + style markup. + + $Id: xhtml-inlstyle-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-link-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-link-1.xsd new file mode 100644 index 0000000000000..f210d84a11d26 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-link-1.xsd @@ -0,0 +1,45 @@ + + + + + + This is the XML Schema Link Element module for XHTML + $Id: xhtml-link-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + Link element + + * link + + This module declares the link element type and its attributes, + which could (in principle) be used to define document-level links + to external resources. + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-list-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-list-1.xsd new file mode 100644 index 0000000000000..cc22ba88f603d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-list-1.xsd @@ -0,0 +1,99 @@ + + + + + + List Module + This is the XML Schema Lists module for XHTML + List Module Elements + + * dl, dt, dd, ol, ul, li + + This module declares the list-oriented element types + and their attributes. + $Id: xhtml-list-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-meta-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-meta-1.xsd new file mode 100644 index 0000000000000..010137b37da84 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-meta-1.xsd @@ -0,0 +1,54 @@ + + + + + + + This is the XML Schema Metainformation module for XHTML + $Id: xhtml-meta-1.xsd,v 1.3 2008/07/05 04:11:00 ahby Exp $ + + + + + + Meta Information + + * meta + + This module declares the meta element type and its attributes, + used to provide declarative document metainformation. + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-notations-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-notations-1.xsd new file mode 100644 index 0000000000000..8ca35cd6ff8ba --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-notations-1.xsd @@ -0,0 +1,69 @@ + + + + + + Notations module + This is the XML Schema module for data type notations for XHTML + $Id: xhtml-notations-1.xsd,v 1.5 2005/09/26 22:54:53 ahby Exp $ + + + + + + Notations module + Defines the XHTML notations, many of these imported from + other specifications and standards. When an existing FPI is + known, it is incorporated here. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-object-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-object-1.xsd new file mode 100644 index 0000000000000..a32efb0fa964f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-object-1.xsd @@ -0,0 +1,76 @@ + + + + + + + This is the XML Schema Embedded Object module for XHTML + $Id: xhtml-object-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + This module declares the object element type and its attributes, + used to embed external objects as part of XHTML pages. In the + document, place param elements prior to the object elements + that require their content. + + Note that use of this module requires instantiation of the + Param Element Module prior to this module. + + Elements defined here: + + * object (param) + + + + + + + Param module + + Elements defined here: + * param + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-param-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-param-1.xsd new file mode 100644 index 0000000000000..ba34ff41290ae --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-param-1.xsd @@ -0,0 +1,51 @@ + + + + + + This is the XML Schema Param Element module for XHTML + $Id: xhtml-param-1.xsd,v 1.3 2005/09/26 22:54:53 ahby Exp $ + + + + + + Parameters for Java Applets and Embedded Objects + + * param + + This module provides declarations for the param element, + used to provide named property values for the applet + and object elements. + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-pres-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-pres-1.xsd new file mode 100644 index 0000000000000..bc36fc48f7740 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-pres-1.xsd @@ -0,0 +1,51 @@ + + + + + + This is the XML Schema Presentation module for XHTML + This is a REQUIRED module. + $Id: xhtml-pres-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + Presentational Elements + + This module defines elements and their attributes for + simple presentation-related markup. + + Elements defined here: + + * hr + * b, big, i, small, sub, sup, tt + + + + + + + Block Presentational module + Elements defined here: + + * hr + + + + + + + Inline Presentational module + Elements defined here: + + * b, big, i, small, sub, sup, tt + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ruby-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ruby-1.xsd new file mode 100644 index 0000000000000..666f81bd2b93d --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ruby-1.xsd @@ -0,0 +1,170 @@ + + + + + + This is the Ruby module for XHTML + $Id: xhtml-ruby-1.xsd,v 1.7 2010/05/02 17:22:08 ahby Exp $ + + + + + + + "Ruby" are short runs of text alongside the base text, typically + used in East Asian documents to indicate pronunciation or to + provide a short annotation. The full specification for Ruby is here: + + http://www.w3.org/TR/2001/REC-ruby-20010531/ + + This module defines "Ruby " or "complex Ruby" as described + in the specification: + + http://www.w3.org/TR/2001/REC-ruby-20010531/#complex + + Simple or Basic Ruby are defined in a separate module. + + This module declares the elements and their attributes used to + support complex ruby annotation markup. Elements defined here + * ruby, rbc, rtc, rb, rt, rp + + This module expects the document model to define the + following content models + + InlNoRuby.mix + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-script-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-script-1.xsd new file mode 100644 index 0000000000000..5ba6e20e036ee --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-script-1.xsd @@ -0,0 +1,71 @@ + + + + + + This is the XML Schema Scripting module for XHTML + $Id: xhtml-script-1.xsd,v 1.5 2006/09/11 08:50:41 ahby Exp $ + + + + + + Scripting + + * script, noscript + + This module declares element types and attributes used to provide + support for executable scripts as well as an alternate content + container where scripts are not supported. + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ssismap-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ssismap-1.xsd new file mode 100644 index 0000000000000..4e120107ebaab --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-ssismap-1.xsd @@ -0,0 +1,43 @@ + + + + + + This is the XML Schema Server-side Image Maps module for XHTML + $Id: xhtml-ssismap-1.xsd,v 1.3 2005/09/26 22:54:53 ahby Exp $ + + + + + + Server-side Image Maps + + This adds the 'ismap' attribute to the img element to + support server-side processing of a user selection. + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-struct-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-struct-1.xsd new file mode 100644 index 0000000000000..a0d21300e8965 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-struct-1.xsd @@ -0,0 +1,130 @@ + + + + + + This is the XML Schema Document Structure module for XHTML + Document Structure + + * title, head, body, html + + The Structure Module defines the major structural elements and + their attributes. + + $Id: xhtml-struct-1.xsd,v 1.11 2009/09/30 14:13:35 ahby Exp $ + + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-style-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-style-1.xsd new file mode 100644 index 0000000000000..c20da4a7088fa --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-style-1.xsd @@ -0,0 +1,53 @@ + + + + + + + This is the XML Schema Stylesheets module for XHTML + $Id: xhtml-style-1.xsd,v 1.5 2006/09/11 10:14:57 ahby Exp $ + + + + + + Stylesheets + + * style + + This module declares the style element type and its attributes, + used to embed stylesheet information in the document head element. + + + + + + + This import brings in the XML namespace attributes + The module itself does not provide the schemaLocation + and expects the driver schema to provide the + actual SchemaLocation. + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-table-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-table-1.xsd new file mode 100644 index 0000000000000..ec76db3ca8b3f --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-table-1.xsd @@ -0,0 +1,272 @@ + + + + + + + This is the XML Schema Tables module for XHTML + $Id: xhtml-table-1.xsd,v 1.3 2005/09/26 22:54:53 ahby Exp $ + + + + + + Tables + + * table, caption, thead, tfoot, tbody, colgroup, col, tr, th, td + + This module declares element types and attributes used to provide + table markup similar to HTML 4.0, including features that enable + better accessibility for non-visual user agents. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-target-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-target-1.xsd new file mode 100644 index 0000000000000..d8f2770d28e2b --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-target-1.xsd @@ -0,0 +1,49 @@ + + + + + + This is the XML Schema Target module for XHTML + $Id: xhtml-target-1.xsd,v 1.3 2007/04/03 18:27:01 ahby Exp $ + + + + + + + Target + + * target + + This module declares the 'target' attribute used for opening windows + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-text-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-text-1.xsd new file mode 100644 index 0000000000000..432bdad7ac3cf --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml-text-1.xsd @@ -0,0 +1,67 @@ + + + + + + Textual Content + This is the XML Schema Text module for XHTML + + The Text module includes declarations for all core + text container elements and their attributes. + + + block phrasal + + block structural + + inline phrasal + + inline structural + + $Id: xhtml-text-1.xsd,v 1.2 2005/09/26 22:54:53 ahby Exp $ + + + + + + + + Block Phrasal module + Elements defined here: + + * address, blockquote, pre, h1, h2, h3, h4, h5, h6 + + + + + + + Block Structural module + Elements defined here: + + * div, p + + + + + + + Inline Phrasal module + Elements defined here: + + * abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var + + + + + + + Inline Structural module + Elements defined here: + + * br,span + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-model-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-model-1.xsd new file mode 100644 index 0000000000000..a1c138d84882e --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-model-1.xsd @@ -0,0 +1,716 @@ + + + + + + This is the XML Schema module of common content models for XHTML11 + + $Id: xhtml11-model-1.xsd,v 1.9 2009/02/03 15:14:49 ahby Exp $ + + + + + + XHTML Document Model + This module describes the groupings of elements/attributes + that make up common content models for XHTML elements. + XHTML has following basic content models: + xhtml.Inline.mix; character-level elements + xhtml.Block.mix; block-like elements, e.g., paragraphs and lists + xhtml.Flow.mix; any block or inline elements + xhtml.HeadOpts.mix; Head Elements + xhtml.InlinePre.mix; Special class for pre content model + xhtml.InlineNoAnchor.mix; Content model for Anchor + + Any groups declared in this module may be used to create + element content models, but the above are considered 'global' + (insofar as that term applies here). XHTML has the + following Attribute Groups + xhtml.Core.extra.attrib + xhtml.I18n.extra.attrib + xhtml.Common.extra + + The above attribute Groups are considered Global + + + + + Extended I18n attribute + + + + + "dir" Attribute from Bi Directional Text (bdo) Module + + + + + + + + Extended Common Attributes + + + + + "style" attribute from Inline Style Module + + + + + + + Attributes from Events Module + + + + + + + Extend Core Attributes + + + + + Extended Global Core Attributes + + + + + Extended Global I18n attributes + + + + + Extended Global Common Attributes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-modules-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-modules-1.xsd new file mode 100644 index 0000000000000..676706760a535 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11-modules-1.xsd @@ -0,0 +1,605 @@ + + + + + + + This schema includes all modules for XHTML1.1 Document Type. + $Id: xhtml11-modules-1.xsd,v 1.10 2009/02/03 15:14:49 ahby Exp $ + + + + + + This schema includes all modules (and redefinitions) + for XHTML1.1 Document Type. + XHTML1.1 Document Type includes the following Modules + + XHTML Core modules (Required for XHTML Family Conformance) + + text + + hypertext + + lists + + structure + + Other XHTML modules + + Edit + + Bdo + + Presentational + + Link + + Meta + + Base + + Scripting + + Style + + Image + + Applet + + Object + + Param (Applet/Object modules require Param Module) + + Tables + + Target + + Forms + + Client side image maps + + Server side image maps + + + + + + + Schema Framework Component Modules: + + notations + + datatypes + + common attributes + + character entities + + + + + + + + Text module + + The Text module includes declarations for all core + text container elements and their attributes. + + + block phrasal + + block structural + + inline phrasal + + inline structural + + Elements defined here: + * address, blockquote, pre, h1, h2, h3, h4, h5, h6 + * div, p + * abbr, acronym, cite, code, dfn, em, kbd, q, samp, strong, var + * br, span + + + + + + + + Hypertext module + + Elements defined here: + * a + + + + + + + + + Redefinition by Client Side Image Map Module + + + + + + + Redefinition by XHTML Event Attribute Module + + + + + + + Target Module - A Attribute Additions + + + + + + + + + Lists module + + Elements defined here: + * dt, dd, dl, ol, ul, li + + + + + + + + Structural module + + Elements defined here: + * title, head, body, html + + + + + + + Redefinition by the XHTML11 Markup (for value of version attr) + + + + + + + + + Original Body Attlist + + + + + + + Redefinition by XHTML Event Attribute Module + + + + + + + + + Edit module + + Elements defined here: + * ins, del + + + + + + + + Bidirectional element module + + Elements defined here: + * bdo + + + + + + + + Presentational module + + Elements defined here: + * hr, b, big, i, small,sub, sup, tt + + + + + + + + Link module + + Elements defined here: + * link + + + + + + + Changes to XHTML Link Attlist + + + + + + Original Link Attributes (declared in Link Module) + + + + + + + XHTML Target Module - Attribute additions + + + + + + + + + Meta module + + Elements defined here: + * meta + + + + + + + + Base module + + Elements defined here: + * base + + + + + + + Changes to XHTML base Attlist + + + + + + Original Base Attributes (declared in Base Module) + + + + + + + XHTML Target Module - Attribute additions + + + + + + + + + Scripting module + + Elements defined here: + * script, noscript + + + + + + + + Style module + + Elements defined here: + * style + + + + + + + + Style attribute module + + Attribute defined here: + * style + + + + + + + + Image module + + Elements defined here: + * img + + + + + + + + Original Image Attributes (in Image Module) + + + + + + + Redefinition by Client Side Image Map Module + + + + + + + Redefinition by Server Side Image Module + + + + + + + + + Client-side mage maps module + + Elements defined here: + * area, map + + + + + + + + Original Area Attributes (in CSI Module) + + + + + + + Redefinition by Events Attribute Module + + + + + + + Target Module - Area Attribute Additions + + + + + + + + + Server-side image maps module + + Attributes defined here: + * ismap on img + + + + + + + + Object module + + Elements defined here: + * object + + + + + + + + Original Object Attlist + + + + + + + Redefinition by Client Image Map Module + + + + + + + + + Param module + + Elements defined here: + * param + + + + + + + Tables module + + Elements defined here: + * table, caption, thead, tfoot, tbody, colgroup, col, tr, th, td + + + + + + + + Forms module + + Elements defined here: + * form, label, input, select, optgroup, option, + * textarea, fieldset, legend, button + + + + + + + Changes to XHTML Form Attlist + + + + + + Original Form Attributes (declared in Forms Module) + + + + + + + XHTML Events Module - Attribute additions + + + + + + + XHTML Target Module - Attribute additions + + + + + + + + Changes to XHTML Form Input Element + + + + + + Original Input Attributes (in Forms Module) + + + + + + + Redefinition by Client Side Image Map Module + + + + + + + Redefinition by Server Side Image Map Module + + + + + + + Redefinition by Event Attribute Module + + + + + + + + + Original Label Attributes (in Forms Module) + + + + + + + Redefinition by Event Attribute Module + + + + + + + + + Original Select Attributes (in Forms Module) + + + + + + + Redefinition by Event Attribute Module + + + + + + + + + Original TextArea Attributes (in Forms Module) + + + + + + + Redefinition by Event Attribute Module + + + + + + + + + Original Button Attributes (in Forms Module) + + + + + + + Redefinition by Event Attribute Module + + + + + + + + + Ruby module + + Elements defined here: + * ruby, rbc, rtc, rb, rt, rp + + Note that either Ruby or Basic Ruby should be used but not both + + + + + + + + XHTML Events Modules + + Attributes defined here: + XHTML Event Types + + + + + + + + XHTML Target Attribute Module + + Attributes defined here: + target + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11.xsd new file mode 100644 index 0000000000000..341699935d278 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xhtml11.xsd @@ -0,0 +1,104 @@ + + + + + This is the XML Schema driver for XHTML 1.1. + Please use this namespace for XHTML elements: + + "http://www.w3.org/1999/xhtml" + + $Id: xhtml11.xsd,v 1.7 2009/02/03 15:14:49 ahby Exp $ + + + + + + This is XHTML, a reformulation of HTML as a modular XML application + The Extensible HyperText Markup Language (XHTML) + Copyright ©1998-2007 World Wide Web Consortium + (Massachusetts Institute of Technology, European Research Consortium + for Informatics and Mathematics, Keio University). + All Rights Reserved. + + Permission to use, copy, modify and distribute the XHTML Schema + modules and their accompanying xs:documentation for any purpose + and without fee is hereby granted in perpetuity, provided that the above + copyright notice and this paragraph appear in all copies. + The copyright holders make no representation about the suitability of + these XML Schema modules for any purpose. + + They are provided "as is" without expressed or implied warranty. + + + + + This is the Schema Driver file for XHTML1.1 + Document Type + + This schema + + imports external schemas (xml.xsd) + + refedines (and include)s schema modules for XHTML1.1 Document Type. + + includes Schema for Named content model for the + XHTML1.1 Document Type + + XHTML1.1 Document Type includes the following Modules + XHTML Core modules (Required for XHTML Family Conformance) + + text + + hypertext + + lists + + structure + Other XHTML modules + + Edit + + Bdo + + Presentational + + Link + + Meta + + Base + + Scripting + + Style + + Image + + Applet + + Object + + Param (Applet/Object modules require Param Module) + + Tables + + Forms + + Client side image maps + + Server side image maps + + Ruby + + + + + + This import brings in the XML namespace attributes + The XML attributes are used by various modules. + + + + + + + Document Model module for the XHTML1.1 Document Type. + This schema file defines all named models used by XHTML + Modularization Framework for XHTML1.1 Document Type + + + + + + + Schema that includes all modules (and redefinitions) + for XHTML1.1 Document Type. + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-1.xsd new file mode 100644 index 0000000000000..0d53b8a52a2bb --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-1.xsd @@ -0,0 +1,73 @@ + + + + + + This is the XML Schema for XML Events + + URI: http://www.w3.org/MarkUp/SCHEMA/xml-events-1.xsd + $Id: xml-events-1.xsd,v 1.8 2004/11/22 17:09:15 ahby Exp $ + + + + + + + XML Events element listener + + This module defines the listener element for XML Events. + This element can be used to define event listeners. This + module relies upon the XmlEvents.attlist attribute group + defined in xml-events-attribs-1.xsd. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-copyright-1.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-copyright-1.xsd new file mode 100644 index 0000000000000..ebe0e9240030e --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xhtml11/xml-events-copyright-1.xsd @@ -0,0 +1,34 @@ + + + + + + This is XML Events, a generalized event model for XML-based + markup languages. + + Copyright 2001-2003 World Wide Web Consortium + (Massachusetts Institute of Technology, European Research + Consortium for Informatics and Mathematics, Keio University). + All Rights Reserved. + + Permission to use, copy, modify and distribute the + XML Events Schema modules and their accompanying xs:documentation + for any purpose and without fee is hereby granted in perpetuity, + provided that the above copyright notice and this paragraph appear + in all copies. + + The copyright holders make no representation about the suitability of + these XML Schema modules for any purpose. + + They are provided "as is" without expressed or implied warranty. + + + + diff --git a/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xmlNS2001/xml.xsd b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xmlNS2001/xml.xsd new file mode 100644 index 0000000000000..cd234ef748a89 --- /dev/null +++ b/src/java.xml/share/classes/jdk/xml/internal/jdkcatalog/w3c/xsd/xmlNS2001/xml.xsd @@ -0,0 +1,117 @@ + + + + + + + See http://www.w3.org/XML/1998/namespace.html and + http://www.w3.org/TR/REC-xml for information about this namespace. + + This schema document describes the XML namespace, in a form + suitable for import by other schema documents. + + Note that local names in this namespace are intended to be defined + only by the World Wide Web Consortium or its subgroups. The + following names are currently defined in this namespace and should + not be used with conflicting semantics by any Working Group, + specification, or document instance: + + base (as an attribute name): denotes an attribute whose value + provides a URI to be used as the base for interpreting any + relative URIs in the scope of the element on which it + appears; its value is inherited. This name is reserved + by virtue of its definition in the XML Base specification. + + lang (as an attribute name): denotes an attribute whose value + is a language code for the natural language of the content of + any element; its value is inherited. This name is reserved + by virtue of its definition in the XML specification. + + space (as an attribute name): denotes an attribute whose + value is a keyword indicating what whitespace processing + discipline is intended for the content of the element; its + value is inherited. This name is reserved by virtue of its + definition in the XML specification. + + Father (in any context at all): denotes Jon Bosak, the chair of + the original XML Working Group. This name is reserved by + the following decision of the W3C XML Plenary and + XML Coordination groups: + + In appreciation for his vision, leadership and dedication + the W3C XML Plenary on this 10th day of February, 2000 + reserves for Jon Bosak in perpetuity the XML name + xml:Father + + + + + This schema defines attributes and an attribute group + suitable for use by + schemas wishing to allow xml:base, xml:lang or xml:space attributes + on elements they define. + + To enable this, such a schema must import this schema + for the XML namespace, e.g. as follows: + <schema . . .> + . . . + <import namespace="http://www.w3.org/XML/1998/namespace" + schemaLocation="http://www.w3.org/2001/03/xml.xsd"/> + + Subsequently, qualified reference to any of the attributes + or the group defined below will have the desired effect, e.g. + + <type . . .> + . . . + <attributeGroup ref="xml:specialAttrs"/> + + will define a type which will schema-validate an instance + element with any of those attributes + + + + In keeping with the XML Schema WG's standard versioning + policy, this schema document will persist at + http://www.w3.org/2001/03/xml.xsd. + At the date of issue it can also be found at + http://www.w3.org/2001/xml.xsd. + The schema document at that URI may however change in the future, + in order to remain compatible with the latest version of XML Schema + itself. In other words, if the XML Schema namespace changes, the version + of this document at + http://www.w3.org/2001/xml.xsd will change + accordingly; the version at + http://www.w3.org/2001/03/xml.xsd will not change. + + + + + + In due course, we should install the relevant ISO 2- and 3-letter + codes as the enumerated possible values . . . + + + + + + + + + + + + + + + See http://www.w3.org/TR/xmlbase/ for + information about this attribute. + + + + + + + + + + \ No newline at end of file diff --git a/src/java.xml/share/classes/module-info.java b/src/java.xml/share/classes/module-info.java index e5c421261b082..a12fd3e8f4536 100644 --- a/src/java.xml/share/classes/module-info.java +++ b/src/java.xml/share/classes/module-info.java @@ -417,11 +417,97 @@ * * *

      JDK built-in Catalog

      - * The JDK has a built-in catalog that hosts the following DTDs defined by the Java Platform: - *
        - *
      • DTD for {@link java.util.prefs.Preferences java.util.prefs.Preferences}, preferences.dtd
      • - *
      • DTD for {@link java.util.Properties java.util.Properties}, properties.dtd
      • - *
      + * The JDK has a built-in catalog that hosts DTDs and XSDs list in the following table. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
      DTDs and XSDs in JDK built-in Catalog
      SourceFiles
      + * {@link java.util.prefs.Preferences java.util.prefs.Preferences} + * preferences.dtd + *
      + * {@link java.util.Properties java.util.Properties} + * properties.dtd + *
      + * XML Schema Part 1: Structures Second Edition
      + * XML Schema Part 2: Datatypes Second Edition + *
      + * XMLSchema.dtd
      + * datatypes.dtd
      + * XMLSchema.xsd
      + * datatypes.xsd + *
      + * XHTML™ 1.0 The Extensible HyperText Markup Language + * + * xhtml1-frameset.dtd
      + * xhtml1-strict.dtd
      + * xhtml1-transitional.dtd + *
      + * XHTML™ 1.0 in XML Schema + * + * xhtml1-frameset.xsd
      + * xhtml1-strict.xsd
      + * xhtml1-transitional.xsd + *
      + * XHTML™ 1.1 - Module-based XHTML - Second Edition + * + * xhtml11.dtd + *
      + * XHTML 1.1 XML Schema Definition + * + * xhtml11.xsd + *
      + * XML DTD for W3C specifications + * + * xmlspec.dtd + *
      + * The "xml:" Namespace + * + * xml.xsd + *
      *

      * The catalog is loaded once when the first JAXP processor factory is created. * diff --git a/src/java.xml/share/legal/schema10part1.md b/src/java.xml/share/legal/schema10part1.md new file mode 100644 index 0000000000000..bd7498b9e4727 --- /dev/null +++ b/src/java.xml/share/legal/schema10part1.md @@ -0,0 +1,51 @@ +## XML Schema Part 1: Structures Second Edition + +### W3C Software and Document license +

      +Software and Document license - 2023 version
      +
      +Copied from:  https://www.w3.org/copyright/software-license-2023
      +
      +License
      +
      +By obtaining and/or copying this work, you (the licensee) agree that you have
      +read, understood, and will comply with the following terms and conditions.
      +
      +Permission to copy, modify, and distribute this work, with or without modification,
      +for any purpose and without fee or royalty is hereby granted, provided that you
      +include the following on ALL copies of the work or portions thereof, including
      +modifications:
      +
      +    The full text of this NOTICE in a location viewable to users of the
      +    redistributed or derivative work.
      +    Any pre-existing intellectual property disclaimers, notices, or terms and
      +    conditions. If none exist, the W3C software and document short notice should
      +    be included.
      +    Notice of any changes or modifications, through a copyright statement on the
      +    new code or document such as "This software or document includes material
      +    copied from or derived from [title and URI of the W3C document]. Copyright ©
      +    [$year-of-document] World Wide Web Consortium.
      +    https://www.w3.org/copyright/software-license-2023/"
      +
      +Disclaimers
      +
      +THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
      +WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF
      +MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE
      +SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
      +TRADEMARKS OR OTHER RIGHTS.
      +
      +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
      +CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
      +
      +The name and trademarks of copyright holders may NOT be used in advertising or
      +publicity pertaining to the work without specific, written prior permission.
      +Title to copyright in this work will at all times remain with copyright holders.
      +
      +------
      +
      +Copyright © 2004 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability,
      +trademark and document use rules apply.
      +
      +
      +
      diff --git a/src/java.xml/share/legal/schema10part2.md b/src/java.xml/share/legal/schema10part2.md new file mode 100644 index 0000000000000..601b06db18be7 --- /dev/null +++ b/src/java.xml/share/legal/schema10part2.md @@ -0,0 +1,50 @@ +## XML Schema Part 2: Datatypes Second Edition + +### W3C Software and Document license +
      +Software and Document license - 2023 version
      +
      +Copied from:  https://www.w3.org/copyright/software-license-2023
      +
      +License
      +
      +By obtaining and/or copying this work, you (the licensee) agree that you have
      +read, understood, and will comply with the following terms and conditions.
      +
      +Permission to copy, modify, and distribute this work, with or without modification,
      +for any purpose and without fee or royalty is hereby granted, provided that you
      +include the following on ALL copies of the work or portions thereof, including
      +modifications:
      +
      +    The full text of this NOTICE in a location viewable to users of the
      +    redistributed or derivative work.
      +    Any pre-existing intellectual property disclaimers, notices, or terms and
      +    conditions. If none exist, the W3C software and document short notice should
      +    be included.
      +    Notice of any changes or modifications, through a copyright statement on the
      +    new code or document such as "This software or document includes material
      +    copied from or derived from [title and URI of the W3C document]. Copyright ©
      +    [$year-of-document] World Wide Web Consortium.
      +    https://www.w3.org/copyright/software-license-2023/"
      +
      +Disclaimers
      +
      +THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
      +WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF
      +MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE
      +SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
      +TRADEMARKS OR OTHER RIGHTS.
      +
      +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
      +CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
      +
      +The name and trademarks of copyright holders may NOT be used in advertising or
      +publicity pertaining to the work without specific, written prior permission.
      +Title to copyright in this work will at all times remain with copyright holders.
      +
      +------
      +
      +Copyright © 2004 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability,
      +trademark and document use rules apply.
      +
      +
      diff --git a/src/java.xml/share/legal/xhtml10.md b/src/java.xml/share/legal/xhtml10.md new file mode 100644 index 0000000000000..765584b6c3818 --- /dev/null +++ b/src/java.xml/share/legal/xhtml10.md @@ -0,0 +1,57 @@ +## XHTMLâ„¢ 1.0 The Extensible HyperText Markup Language + +### W3C Software Notice and License +
      +W3C(R) SOFTWARE NOTICE AND LICENSE
      +
      +Copyright (c) 1994-2002 World Wide Web Consortium, (Massachusetts
      +Institute of Technology, Institut National de Recherche en
      +Informatique et en Automatique, Keio University). All Rights
      +Reserved. http://www.w3.org/Consortium/Legal/
      +
      +This W3C work (including software, documents, or other related items)
      +is being provided by the copyright holders under the following
      +license. By obtaining, using and/or copying this work, you (the
      +licensee) agree that you have read, understood, and will comply with
      +the following terms and conditions:
      +
      +Permission to use, copy, modify, and distribute this software and its
      +documentation, with or without modification, for any purpose and
      +without fee or royalty is hereby granted, provided that you include
      +the following on ALL copies of the software and documentation or
      +portions thereof, including modifications, that you make:
      +
      +    The full text of this NOTICE in a location viewable to users of
      +    the redistributed or derivative work.
      +
      +    Any pre-existing intellectual property disclaimers, notices, or
      +    terms and conditions. If none exist, a short notice of the following
      +    form (hypertext is preferred, text is permitted) should be used within
      +    the body of any redistributed or derivative code: "Copyright (C)
      +    [$date-of-software] World Wide Web Consortium, (Massachusetts
      +    Institute of Technology, Institut National de Recherche en
      +    Informatique et en Automatique, Keio University). All Rights
      +    Reserved. http://www.w3.org/Consortium/Legal/"
      +
      +    Notice of any changes or modifications to the W3C files, including
      +    the date changes were made. (We recommend you provide URIs to the
      +    location from which the code is derived.)
      +
      +THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT
      +HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
      +INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS
      +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR
      +DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
      +TRADEMARKS OR OTHER RIGHTS.
      +
      +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL
      +OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR
      +DOCUMENTATION.
      +
      +The name and trademarks of copyright holders may NOT be used in
      +advertising or publicity pertaining to the software without specific,
      +written prior permission. Title to copyright in this software and any
      +associated documentation will at all times remain with copyright
      +holders.
      +
      +
      diff --git a/src/java.xml/share/legal/xhtml10schema.md b/src/java.xml/share/legal/xhtml10schema.md new file mode 100644 index 0000000000000..b638568755163 --- /dev/null +++ b/src/java.xml/share/legal/xhtml10schema.md @@ -0,0 +1,150 @@ +## XHTML™ 1.0 in XML Schema + +### W3C® Intellectual Rights Notice and Legal Disclaimers +
      +Copyright © 1994-2002 W3C ® (Massachusetts Institute of Technology,
      +Institut National de Recherche en Informatique et en Automatique, Keio University),
      +All Rights Reserved.
      +
      +World Wide Web Consortium (W3C®) web site pages may contain other proprietary
      +notices and copyright information, the terms of which must be observed and
      +followed. Specific notices do exist for W3C documents and software. Also, there
      +are specific usage policies associated with some of the W3C Icons. Please see
      +our Intellectual Rights FAQ for common questions about using materials from our site.
      +
      +Notice and Disclaimers
      +
      +1. Unless otherwise noted, all materials contained in this Site are copyrighted
      +and may not be used except as provided in these terms and conditions or in the
      +copyright notice (documents and software) or other proprietary notice provided
      +with the relevant materials.
      +
      +2. The materials contained in the Site may be downloaded or copied provided that
      +ALL copies retain the copyright and any other proprietary notices contained on
      +the materials. No material may be modified, edited or taken out of context such
      +that its use creates a false or misleading statement or impression as to the
      +positions, statements or actions of W3C.
      +
      +3. The name and trademarks of copyright holders may NOT be used in advertising
      +or publicity pertaining to the Web site, its content, specifications, or
      +software without specific, written prior permission. Title to copyright in
      +Web site documents will at all times remain with copyright holders. Use of W3C
      +trademarks and service marks is covered by the W3C Trademark and Servicemark
      +License.
      +
      +4. Caches of W3C materials should comply with the "maximum time to live"
      +information provided with the materials. After such materials have expired
      +they should not be served from caches without first validating the contents
      +of the W3C Site. Organizations that want to mirror W3C content must abide by
      +the W3C Mirroring Policy.
      +
      +W3C®Trademarks and Generic Terms
      +Trademarks owned by W3C host institutions on behalf of W3C and generic terms
      +used by the W3C
      +
      +5. The trademarks, logos, and service marks (collectively the "Trademarks")
      +displayed on the Site are registered and unregistered Trademarks of the
      +Massachusetts Institute of Technology (MIT), Institut National de Recherche
      +en Informatique et en Automatique (INRIA), or Keio University (Keio). All use
      +of the W3C Trademarks is governed by the W3C Trademark and Servicemark License.
      +No additional rights are granted by implication, estoppel, or otherwise. Terms
      +which claimed as generic are not governed by any W3C license and are used as
      +common descriptors by the W3C.
      +
      +The following is a list of W3C terms claimed as a trademark or generic term
      +by MIT, INRIA, and/or Keio on behalf of the W3C:
      +
      +    W3C®, World Wide Web Consortium  (registered in numerous countries)
      +    Amayaâ„¢, a Web Browser
      +    CSSâ„¢, Cascading Style Sheets Specification
      +    DOMâ„¢, Document Object Model
      +    HTML (generic), HyperText Markup Language
      +    HTTP (generic), Hypertext Transfer Protocol
      +    MathMLâ„¢, Mathematical Markup Language
      +    Metadata (generic)
      +    P3Pâ„¢, Platform for Privacy Preferences Project
      +    PICSâ„¢, Platform for Internet Content Selection
      +    RDF (generic), Resource Description Framework
      +    SMILâ„¢, Synchronized Multimedia Integration Language
      +    SVGâ„¢, Scalable Vector Graphics
      +    WAIâ„¢, Web Accessibility Initiative
      +    XENC (generic), XML Encryption
      +    XHTMLâ„¢, The Extensible HyperText Markup Language
      +    XML (generic), Extensible Markup Language
      +    XSLâ„¢,  Extensible Stylesheet Language
      +
      +    ACSSâ„¢, Aural Cascading Style Sheets
      +    DSigâ„¢, Digital Signature Initiative
      +    JEPIâ„¢, Joint Electronic Payment Initiative
      +    Jigsawâ„¢
      +    PICSRulesâ„¢
      +    WebFontsâ„¢
      +
      +The absence of a product or service name or logo from this list does not
      +constitute a waiver of MIT's, INRIA's, or Keio's trademark or other intellectual
      +rights concerning that name or logo.
      +
      +Any questions concerning the use, status, or standing of W3C trademarks should
      +be directed to: site-policy@w3.org or to W3C (c/o Joseph Reagle), Laboratory
      +for Computer Science NE43-358, Massachusetts Institute of Technology, 200
      +Technology Square, Cambridge, MA 02139.
      +
      +Non-W3C Trademarks; Member Trademarks
      +
      +The trademarks, logos, and service marks not owned on behalf of the W3C and
      +that are displayed on the Site are the registered and unregistered marks of
      +their respective owners. No rights are granted by the W3C to use such marks,
      +whether by implication, estoppel, or otherwise.
      +
      +"METADATA" is a trademark of the Metadata Company. W3C uses the term "metadata"
      +in a descriptive sense, meaning "data about data". W3C is not in any way
      +affiliated with the Metadata Company.
      +Legal Disclaimers
      +
      +6. W3C has not reviewed any or all of the web sites linked to this Site and is
      +not responsible for the content of any off-site pages or any other web sites
      +linked to this Site. Please understand that any non-W3C web site is independent
      +from W3C, and W3C has no control over the content on that web site.
      +In addition, a link to a non-W3C web site does not mean that W3C endorses or
      +accepts any responsibility for the content, or the use, of such site. It is
      +the user's responsibility to take precautions to ensure that whatever is
      +selected is free of such items as viruses, worms, Trojan horses and other
      +items of a destructive nature.
      +
      +7. Information W3C publishes on its Site may contain references or cross
      +references to W3C specifications, projects, programs and services that are
      +not announced or available in your country. Such references do not imply that
      +W3C intends to announce such specifications, projects, programs or services
      +in your country.
      +
      +8. Information on this Site may contain technical inaccuracies or typographical
      +errors. Information may be changed or updated without notice. W3C may make
      +improvements and/or changes in the materials contained in or described on this
      +site at any time without notice. W3C may also make changes in these Terms and
      +Conditions without notice. User is bound by such revisions and should therefore
      +periodically visit this page to review the then current Terms and Conditions.
      +
      +9. Limitation on Warranties.
      +
      +ALL MATERIALS ON THE W3C SITE ARE PROVIDED "AS IS." W3C, MIT, INRIA, AND KEIO
      +MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT
      +LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE,
      +TITLE OR NON-INFRINGEMENT. AS TO DOCUMENTS AND GRAPHICS PUBLISHED ON THIS SITE,
      +W3C, MIT, INRIA, AND KEIO MAKE NO REPRESENTATION OR WARRANTY THAT THE CONTENTS
      +OF SUCH DOCUMENT OR GRAPHICS ARE FREE FROM ERROR OR SUITABLE FOR ANY PURPOSE;
      +NOR THAT IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY
      +PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
      +
      +Please note that some jurisdictions may not allow the exclusion of implied
      + warranties, so some of the above exclusions may not apply to you.
      +
      +10. Limitation on Liability.
      +
      +IN NO EVENT WILL W3C, MIT, INRIA, AND KEIO BE LIABLE TO ANY PARTY FOR ANY
      +DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES FOR ANY USE OF THIS SITE,
      +OR ON ANY OTHER HYPERLINKED WEB SITE, INCLUDING, WITHOUT LIMITATION, ANY LOST
      +PROFITS, BUSINESS INTERRUPTION, LOSS OF PROGRAMS OR OTHER DATA ON YOUR
      +INFORMATION HANDLING SYSTEM OR OTHERWISE, EVEN IF W3C, MIT, INRIA, OR KEIO
      +IS EXPRESSLY ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
      +
      +
      diff --git a/src/java.xml/share/legal/xhtml11.md b/src/java.xml/share/legal/xhtml11.md new file mode 100644 index 0000000000000..b447a5ac9e4f0 --- /dev/null +++ b/src/java.xml/share/legal/xhtml11.md @@ -0,0 +1,68 @@ +## XHTMLâ„¢ 1.1 - Module-based XHTML - Second Edition + +### W3C Document license +
      +From: https://www.w3.org/copyright/document-license-2023
      +
      +Copied 10/15/2024
      +
      +License
      +
      +By using and/or copying this document, or the W3C document from which this
      +statement is linked, you (the licensee) agree that you have read, understood,
      +and will comply with the following terms and conditions:
      +
      +Permission to copy, and distribute the contents of this document, or the W3C
      +document from which this statement is linked, in any medium for any purpose
      +and without fee or royalty is hereby granted, provided that you include the
      +following on ALL copies of the document, or portions thereof, that you use:
      +
      +    A link or URL to the original W3C document.
      +    The pre-existing copyright notice of the original author, or if it doesn't
      +    exist, a notice (hypertext is preferred, but a textual representation is
      +    permitted) of the form: "Copyright © [$date-of-document] World Wide Web
      +    Consortium. https://www.w3.org/copyright/document-license-2023/"
      +    If it exists, the STATUS of the W3C document.
      +
      +When space permits, inclusion of the full text of this NOTICE should be provided.
      +We request that authorship attribution be provided in any software, documents,
      +or other items or products that you create pursuant to the implementation of the
      +contents of this document, or any portion thereof.
      +
      +No right to create modifications or derivatives of W3C documents is granted
      +pursuant to this license, except as follows: To facilitate implementation of
      +the technical specifications set forth in this document, anyone may prepare
      +and distribute derivative works and portions of this document in software,
      +in supporting materials accompanying software, and in documentation of software,
      +PROVIDED that all such works include the notice below. HOWEVER, the publication
      +of derivative works of this document for use as a technical specification is
      +expressly prohibited.
      +
      +In addition, "Code Components" —Web IDL in sections clearly marked as Web IDL;
      +and W3C-defined markup (HTML, CSS, etc.) and computer programming language code
      +clearly marked as code examples— are licensed under the W3C Software License.
      +
      +The notice is:
      +
      +"Copyright © 2023 W3C®. This software or document includes material copied from
      +or derived from [title and URI of the W3C document]."
      +
      +Disclaimers §anchor
      +
      +THIS DOCUMENT IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS
      +OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, WARRANTIES OF
      +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, OR TITLE;
      +THAT THE CONTENTS OF THE DOCUMENT ARE SUITABLE FOR ANY PURPOSE; NOR THAT THE
      +IMPLEMENTATION OF SUCH CONTENTS WILL NOT INFRINGE ANY THIRD PARTY PATENTS,
      +COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
      +
      +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
      +CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE DOCUMENT OR THE PERFORMANCE
      +OR IMPLEMENTATION OF THE CONTENTS THEREOF.
      +
      +The name and trademarks of copyright holders may NOT be used in advertising or
      +publicity pertaining to this document or its contents without specific, written
      +prior permission. Title to copyright in this document will at all times remain
      +with copyright holders.
      +
      +
      diff --git a/src/java.xml/share/legal/xhtml11schema.md b/src/java.xml/share/legal/xhtml11schema.md new file mode 100644 index 0000000000000..c7a2f0efda4f4 --- /dev/null +++ b/src/java.xml/share/legal/xhtml11schema.md @@ -0,0 +1,60 @@ +## XHTML 1.1 XML Schema Definition + +### W3C® SOFTWARE NOTICE AND LICENSE +
      +http://www.w3.org/Consortium/Legal/copyright-software-19980720
      +
      +W3C® SOFTWARE NOTICE AND LICENSE
      +
      +Copyright © 1994-2002 World Wide Web Consortium, (Massachusetts Institute of
      +Technology, Institut National de Recherche en Informatique et en Automatique,
      +Keio University). All Rights Reserved. http://www.w3.org/Consortium/Legal/
      +
      +This W3C work (including software, documents, or other related items) is
      +being provided by the copyright holders under the following license. By
      +obtaining, using and/or copying this work, you (the licensee) agree that you
      +have read, understood, and will comply with the following terms and conditions:
      +Permission to use, copy, modify, and distribute this software and its
      +documentation, with or without modification,  for any purpose and without fee
      +or royalty is hereby granted, provided that you include the following on ALL
      +copies of the software and documentation or portions thereof, including
      +modifications, that you make:
      +
      +1.      The full text of this NOTICE in a location viewable to users of the
      +redistributed or derivative work.
      +
      +2.      Any pre-existing intellectual property disclaimers, notices, or terms
      +and conditions. If none exist, a short notice of the following form (hypertext
      +is preferred, text is permitted) should be used within the body of any
      +redistributed or derivative code: "Copyright © [$date-of-software] World Wide
      +Web Consortium, (Massachusetts Institute of Technology, Institut National de
      +Recherche en Informatique et en Automatique, Keio University). All Rights
      +Reserved. http://www.w3.org/Consortium/Legal/"
      +
      +3.      Notice of any changes or modifications to the W3C files, including the
      +date changes were made. (We recommend you provide URIs to the location from
      +which the code is derived.)
      +
      +THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
      +NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
      +TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
      +THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
      +PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
      +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
      +CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
      +
      +The name and trademarks of copyright holders may NOT be used in advertising or
      +publicity pertaining to the software without specific, written prior permission.
      +Title to copyright in this software and any associated documentation will at all
      +times remain with copyright holders.
      +
      +The formulation of W3C's notice and license became active on August 14 1998 so
      +as to improve compatibility with GPL. This version ensures that W3C software
      +licensing terms are no more restrictive than GPL and consequently W3C software
      +may be distributed in GPL packages. See the older formulation for the policy
      +prior to this date. Please see our Copyright FAQ for common questions about
      +using materials from our site, including specific terms and conditions for
      +packages like libwww, Amaya, and Jigsaw. Other questions about this notice can
      +be directed to site-policy@w3.org.
      +
      +
      diff --git a/src/java.xml/share/legal/xmlspec.md b/src/java.xml/share/legal/xmlspec.md new file mode 100644 index 0000000000000..bfb7d4f6ed380 --- /dev/null +++ b/src/java.xml/share/legal/xmlspec.md @@ -0,0 +1,63 @@ +## XML DTD for W3C specifications + +### W3C Software Notice and License +
      +W3C(R) SOFTWARE NOTICE AND LICENSE
      +
      +Copyright (c) 1994-2002 World Wide Web Consortium, (Massachusetts
      +Institute of Technology, Institut National de Recherche en
      +Informatique et en Automatique, Keio University). All Rights
      +Reserved. http://www.w3.org/Consortium/Legal/
      +
      +This W3C work (including software, documents, or other related items)
      +is being provided by the copyright holders under the following
      +license. By obtaining, using and/or copying this work, you (the
      +licensee) agree that you have read, understood, and will comply with
      +the following terms and conditions:
      +
      +Permission to use, copy, modify, and distribute this software and its
      +documentation, with or without modification, for any purpose and
      +without fee or royalty is hereby granted, provided that you include
      +the following on ALL copies of the software and documentation or
      +portions thereof, including modifications, that you make:
      +
      +    The full text of this NOTICE in a location viewable to users of
      +    the redistributed or derivative work.
      +
      +    Any pre-existing intellectual property disclaimers, notices, or
      +    terms and conditions. If none exist, a short notice of the following
      +    form (hypertext is preferred, text is permitted) should be used within
      +    the body of any redistributed or derivative code: "Copyright (C)
      +    [$date-of-software] World Wide Web Consortium, (Massachusetts
      +    Institute of Technology, Institut National de Recherche en
      +    Informatique et en Automatique, Keio University). All Rights
      +    Reserved. http://www.w3.org/Consortium/Legal/"
      +
      +    Notice of any changes or modifications to the W3C files, including
      +    the date changes were made. (We recommend you provide URIs to the
      +    location from which the code is derived.)
      +
      +THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT
      +HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED,
      +INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS
      +FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR
      +DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
      +TRADEMARKS OR OTHER RIGHTS.
      +
      +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL
      +OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR
      +DOCUMENTATION.
      +
      +The name and trademarks of copyright holders may NOT be used in
      +advertising or publicity pertaining to the software without specific,
      +written prior permission. Title to copyright in this software and any
      +associated documentation will at all times remain with copyright
      +holders.
      +
      +----------
      +
      +COPYRIGHT:
      +
      +  Copyright (C) 2000, 2001, 2002, 2003 Sun Microsystems, Inc. All Rights Reserved.
      +
      +
      diff --git a/src/java.xml/share/legal/xmlxsd.md b/src/java.xml/share/legal/xmlxsd.md new file mode 100644 index 0000000000000..163e26e9f7725 --- /dev/null +++ b/src/java.xml/share/legal/xmlxsd.md @@ -0,0 +1,43 @@ +## The "xml:" Namespace + +### W3C Software and Document license +
      +From: https://www.w3.org/copyright/software-license-2023/
      +Copied on 2024/10/15
      +
      +License
      +
      +By obtaining and/or copying this work, you (the licensee) agree that you have
      +read, understood, and will comply with the following terms and conditions.
      +
      +Permission to copy, modify, and distribute this work, with or without modification,
      +for any purpose and without fee or royalty is hereby granted, provided that you
      +include the following on ALL copies of the work or portions thereof, including
      +modifications:
      +
      +    The full text of this NOTICE in a location viewable to users of the
      +    redistributed or derivative work.
      +    Any pre-existing intellectual property disclaimers, notices, or terms and
      +    conditions. If none exist, the W3C software and document short notice should
      +    be included.
      +    Notice of any changes or modifications, through a copyright statement on the
      +    new code or document such as "This software or document includes material
      +    copied from or derived from [title and URI of the W3C document]. Copyright ©
      +    [$year-of-document] World Wide Web Consortium.
      +    https://www.w3.org/copyright/software-license-2023/"
      +
      +Disclaimers §anchor
      +
      +THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR
      +WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF
      +MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE
      +SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS,
      +TRADEMARKS OR OTHER RIGHTS.
      +
      +COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
      +CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
      +
      +The name and trademarks of copyright holders may NOT be used in advertising or
      +publicity pertaining to the work without specific, written prior permission.
      +Title to copyright in this work will at all times remain with copyright holders.
      +
      diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java index c55c2db98def9..a02945dee3c49 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -3428,7 +3428,7 @@ PatternResult analyzePattern(int lookahead) { case GTGT: typeDepth--; case GT: typeDepth--; - if (typeDepth == 0) { + if (typeDepth == 0 && !peekToken(lookahead, DOT)) { return peekToken(lookahead, LAX_IDENTIFIER) || peekToken(lookahead, tk -> tk == LPAREN) ? PatternResult.PATTERN : PatternResult.EXPRESSION; diff --git a/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java b/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java index ea2845f56f56c..ebcbaa3a773db 100644 --- a/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java +++ b/src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpExchange.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, 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 @@ -233,22 +233,29 @@ protected HttpExchange() { public abstract String getProtocol(); /** - * {@link Filter} modules may store arbitrary objects with {@code HttpExchange} - * instances as an out-of-band communication mechanism. Other filters + * Returns the attribute's value from this exchange's + * {@linkplain HttpContext#getAttributes() context attributes}. + * + * @apiNote {@link Filter} modules may store arbitrary objects as attributes through + * {@code HttpExchange} instances as an out-of-band communication mechanism. Other filters * or the exchange handler may then access these objects. * *

      Each {@code Filter} class will document the attributes which they make * available. * * @param name the name of the attribute to retrieve - * @return the attribute object, or {@code null} if it does not exist + * @return the attribute's value or {@code null} if either the attribute isn't set + * or the attribute value is {@code null} * @throws NullPointerException if name is {@code null} */ public abstract Object getAttribute(String name); /** - * {@link Filter} modules may store arbitrary objects with {@code HttpExchange} - * instances as an out-of-band communication mechanism. Other filters + * Sets an attribute with the given {@code name} and {@code value} in this exchange's + * {@linkplain HttpContext#getAttributes() context attributes}. + * + * @apiNote {@link Filter} modules may store arbitrary objects as attributes through + * {@code HttpExchange} instances as an out-of-band communication mechanism. Other filters * or the exchange handler may then access these objects. * *

      Each {@code Filter} class will document the attributes which they make diff --git a/src/jdk.jcmd/share/man/jcmd.md b/src/jdk.jcmd/share/man/jcmd.md index 2d2e08bc9f500..4e67e7a450230 100644 --- a/src/jdk.jcmd/share/man/jcmd.md +++ b/src/jdk.jcmd/share/man/jcmd.md @@ -737,6 +737,17 @@ The following commands are available: - `-e`: (Optional) Print extended thread information (BOOLEAN, false) - `-l`: (Optional) Prints `java.util.concurrent` locks (BOOLEAN, false) +`Thread.vthread_scheduler` +: Print the virtual thread scheduler, and the delayed task schedulers that support + virtual threads doing timed operations. + + Impact: Low + +`Thread.vthread_pollers` +: Print the I/O pollers that support virtual threads doing blocking network I/O operations. + + Impact: Low + `VM.cds` \[*arguments*\] : Dump a static or dynamic shared archive that includes all currently loaded classes. diff --git a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java index f1dcadf8b6818..6168ddb28329f 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/Recording.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/Recording.java @@ -97,6 +97,7 @@ public Map toMap() { * support, or if the file repository can't be created or accessed) * * @see jdk.jfr + * @since 11 */ public Recording(Map settings) { Objects.requireNonNull(settings, "settings"); diff --git a/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/java/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java b/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/java/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java index 378e3bb6d40ec..95a0b71c16df3 100644 --- a/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/java/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java +++ b/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/java/com/sun/hotspot/igv/servercompiler/ServerCompilerScheduler.java @@ -382,7 +382,7 @@ private void scheduleLocal() { }; private List scheduleBlock(Collection nodes) { - List schedule = new ArrayList<>(); + LinkedHashSet schedule = new LinkedHashSet(); // Initialize ready priority queue with nodes without predecessors. Queue ready = new PriorityQueue<>(schedulePriority); @@ -407,7 +407,7 @@ private List scheduleBlock(Collection nodes) { } boolean allPredsScheduled = true; for (Node p : s.preds) { - if (!visited.contains(p)) { + if (!schedule.contains(p.inputNode)) { allPredsScheduled = false; break; } @@ -419,7 +419,7 @@ private List scheduleBlock(Collection nodes) { } } assert(schedule.size() == nodes.size()); - return schedule; + return new ArrayList(schedule); } // Return latest block that dominates all successors of n, or null if any diff --git a/test/failure_handler/src/share/conf/common.properties b/test/failure_handler/src/share/conf/common.properties index dd51dc1add91a..5cd2c1c13ca89 100644 --- a/test/failure_handler/src/share/conf/common.properties +++ b/test/failure_handler/src/share/conf/common.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ onTimeout=\ jcmd.vm.classloader_stats jcmd.vm.stringtable \ jcmd.vm.symboltable jcmd.vm.uptime jcmd.vm.dynlibs \ jcmd.vm.system_properties jcmd.vm.info \ - jcmd.gc.heap_info jcmd.gc.class_histogram jcmd.gc.finalizer_info jcmd.thread.dump_to_file \ + jcmd.gc.heap_info jcmd.gc.class_histogram jcmd.gc.finalizer_info jcmd.thread.dump_to_file jcmd.thread.vthread_scheduler \ jstack jhsdb.jstack.live.default jhsdb.jstack.live.mixed jinfo.app=jinfo @@ -61,6 +61,8 @@ jcmd.thread.dump_to_file.args=%p Thread.dump_to_file -format=json JavaThread.dum jcmd.thread.dump_to_file.params.repeat=6 jcmd.thread.dump_to_file.params.successArtifacts=JavaThread.dump.%p.%iterCount +jcmd.thread.vthread_scheduler.args=%p Thread.vthread_scheduler + jstack.app=jstack jstack.args=-e -l %p jstack.params.repeat=6 diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java index 1d586e972be3d..1eb6251b2bbba 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java @@ -254,6 +254,46 @@ public class IRNode { vectorNode(ADD_VL, "AddVL", TYPE_LONG); } + public static final String SATURATING_ADD_VB = VECTOR_PREFIX + "SATURATING_ADD_VB" + POSTFIX; + static { + vectorNode(SATURATING_ADD_VB, "SaturatingAddV", TYPE_BYTE); + } + + public static final String SATURATING_ADD_VS = VECTOR_PREFIX + "SATURATING_ADD_VS" + POSTFIX; + static { + vectorNode(SATURATING_ADD_VS, "SaturatingAddV", TYPE_SHORT); + } + + public static final String SATURATING_ADD_VI = VECTOR_PREFIX + "SATURATING_ADD_VI" + POSTFIX; + static { + vectorNode(SATURATING_ADD_VI, "SaturatingAddV", TYPE_INT); + } + + public static final String SATURATING_ADD_VL = VECTOR_PREFIX + "SATURATING_ADD_VL" + POSTFIX; + static { + vectorNode(SATURATING_ADD_VL, "SaturatingAddV", TYPE_LONG); + } + + public static final String SATURATING_SUB_VB = VECTOR_PREFIX + "SATURATING_SUB_VB" + POSTFIX; + static { + vectorNode(SATURATING_SUB_VB, "SaturatingSubV", TYPE_BYTE); + } + + public static final String SATURATING_SUB_VS = VECTOR_PREFIX + "SATURATING_SUB_VS" + POSTFIX; + static { + vectorNode(SATURATING_SUB_VS, "SaturatingSubV", TYPE_SHORT); + } + + public static final String SATURATING_SUB_VI = VECTOR_PREFIX + "SATURATING_SUB_VI" + POSTFIX; + static { + vectorNode(SATURATING_SUB_VI, "SaturatingSubV", TYPE_INT); + } + + public static final String SATURATING_SUB_VL = VECTOR_PREFIX + "SATURATING_SUB_VL" + POSTFIX; + static { + vectorNode(SATURATING_SUB_VL, "SaturatingSubV", TYPE_LONG); + } + public static final String ADD_REDUCTION_V = PREFIX + "ADD_REDUCTION_V" + POSTFIX; static { beforeMatchingNameRegex(ADD_REDUCTION_V, "AddReductionV(B|S|I|L|F|D)"); diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorSaturatedOperationsTest.java b/test/hotspot/jtreg/compiler/vectorapi/VectorSaturatedOperationsTest.java new file mode 100644 index 0000000000000..f4ef254a98022 --- /dev/null +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorSaturatedOperationsTest.java @@ -0,0 +1,547 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** +* @test +* @bug 8338021 8342677 +* @summary Add IR validation tests for newly added saturated vector add / sub operations +* @modules jdk.incubator.vector +* @library /test/lib / +* @run driver compiler.vectorapi.VectorSaturatedOperationsTest +*/ + +package compiler.vectorapi; + +import jdk.incubator.vector.*; +import compiler.lib.ir_framework.*; +import java.util.Random; +import java.util.stream.IntStream; + +public class VectorSaturatedOperationsTest { + private static final int COUNT = 2048; + private static final VectorSpecies lspec = LongVector.SPECIES_PREFERRED; + private static final VectorSpecies ispec = IntVector.SPECIES_PREFERRED; + private static final VectorSpecies sspec = ShortVector.SPECIES_PREFERRED; + private static final VectorSpecies bspec = ByteVector.SPECIES_PREFERRED; + + private long[] long_in1; + private int[] int_in1; + private short[] short_in1; + private byte[] byte_in1; + + private long[] long_in2; + private int[] int_in2; + private short[] short_in2; + private byte[] byte_in2; + + private long[] long_out; + private int[] int_out; + private short[] short_out; + private byte[] byte_out; + + public static void main(String[] args) { + TestFramework testFramework = new TestFramework(); + testFramework.setDefaultWarmup(5000) + .addFlags("--add-modules=jdk.incubator.vector") + .start(); + } + + public void setup_delimiting_byte_inputs() { + // Saturating add + byte_in1[COUNT - 1] = Byte.MAX_VALUE; + byte_in2[COUNT - 1] = 100; + // Saturating sub + byte_in1[COUNT - 2] = Byte.MIN_VALUE; + byte_in2[COUNT - 2] = 100; + // Saturating unsigned add + byte_in1[COUNT - 3] = -1; + byte_in2[COUNT - 3] = 100; + // Saturating unsigned sub + byte_in1[COUNT - 4] = 0; + byte_in2[COUNT - 4] = 100; + } + + public void setup_delimiting_short_inputs() { + // Saturating add + short_in1[COUNT - 1] = Short.MAX_VALUE; + short_in2[COUNT - 1] = 100; + // Saturating sub + short_in1[COUNT - 2] = Short.MIN_VALUE; + short_in2[COUNT - 2] = 100; + // Saturating unsigned add + short_in1[COUNT - 3] = -1; + short_in2[COUNT - 3] = 100; + // Saturating unsigned sub + short_in1[COUNT - 4] = 0; + short_in2[COUNT - 4] = 100; + } + + public void setup_delimiting_int_inputs() { + // Saturating add + int_in1[COUNT - 1] = Integer.MAX_VALUE; + int_in2[COUNT - 1] = 100; + // Saturating sub + int_in1[COUNT - 2] = Integer.MIN_VALUE; + int_in2[COUNT - 2] = 100; + // Saturating unsigned add + int_in1[COUNT - 3] = -1; + int_in2[COUNT - 3] = 100; + // Saturating unsigned sub + int_in1[COUNT - 4] = 0; + int_in2[COUNT - 4] = 100; + } + + public void setup_delimiting_long_inputs() { + // Saturating add + long_in1[COUNT - 1] = Long.MAX_VALUE; + long_in2[COUNT - 1] = 100; + // Saturating sub + long_in1[COUNT - 2] = Long.MIN_VALUE; + long_in2[COUNT - 2] = 100; + // Saturating unsigned add + long_in1[COUNT - 3] = -1L; + long_in2[COUNT - 3] = 100; + // Saturating unsigned sub + long_in1[COUNT - 4] = 0; + long_in2[COUNT - 4] = 100; + } + + public VectorSaturatedOperationsTest() { + Random r = jdk.test.lib.Utils.getRandomInstance(); + byte_in1 = new byte[COUNT]; + short_in1 = new short[COUNT]; + int_in1 = new int[COUNT]; + long_in1 = new long[COUNT]; + + byte_in2 = new byte[COUNT]; + short_in2 = new short[COUNT]; + int_in2 = new int[COUNT]; + long_in2 = new long[COUNT]; + IntStream.range(0, COUNT-4).forEach( + i -> { + long_in1[i] = r.nextLong(Long.MIN_VALUE, Long.MAX_VALUE); + long_in2[i] = r.nextLong(Long.MIN_VALUE, Long.MAX_VALUE); + int_in1[i] = r.nextInt(Integer.MIN_VALUE, Integer.MAX_VALUE); + int_in2[i] = r.nextInt(Integer.MIN_VALUE, Integer.MAX_VALUE); + short_in1[i] = (short)r.nextInt(Short.MIN_VALUE, Short.MAX_VALUE); + short_in2[i] = (short)r.nextInt(Short.MIN_VALUE, Short.MAX_VALUE); + byte_in1[i] = (byte)r.nextInt(Byte.MIN_VALUE, Byte.MAX_VALUE); + byte_in2[i] = (byte)r.nextInt(Byte.MIN_VALUE, Byte.MAX_VALUE); + } + ); + + setup_delimiting_byte_inputs(); + setup_delimiting_short_inputs(); + setup_delimiting_int_inputs(); + setup_delimiting_long_inputs(); + + long_out = new long[COUNT]; + int_out = new int[COUNT]; + short_out = new short[COUNT]; + byte_out = new byte[COUNT]; + } + + @Test + @IR(counts = {IRNode.SATURATING_ADD_VB, " >0 "}, applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void sadd_byte() { + for (int i = 0; i < COUNT; i += bspec.length()) { + ByteVector.fromArray(bspec, byte_in1, i) + .lanewise(VectorOperators.SADD, + ByteVector.fromArray(bspec, byte_in2, i)) + .intoArray(byte_out, i); + } + } + + @Check(test = "sadd_byte") + public void sadd_byte_verify() { + for (int i = 0; i < COUNT; i++) { + byte actual = byte_out[i]; + byte expected = VectorMath.addSaturating(byte_in1[i], byte_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_ADD_VS, " >0 "}, applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void sadd_short() { + for (int i = 0; i < COUNT; i += sspec.length()) { + ShortVector.fromArray(sspec, short_in1, i) + .lanewise(VectorOperators.SADD, + ShortVector.fromArray(sspec, short_in2, i)) + .intoArray(short_out, i); + } + } + + @Check(test = "sadd_short") + public void sadd_short_verify() { + for (int i = 0; i < COUNT; i++) { + short actual = short_out[i]; + short expected = VectorMath.addSaturating(short_in1[i], short_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_ADD_VI, " >0 "}, applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void sadd_int() { + for (int i = 0; i < COUNT; i += ispec.length()) { + IntVector.fromArray(ispec, int_in1, i) + .lanewise(VectorOperators.SADD, + IntVector.fromArray(ispec, int_in2, i)) + .intoArray(int_out, i); + } + } + + @Check(test = "sadd_int") + public void sadd_int_verify() { + for (int i = 0; i < COUNT; i++) { + int actual = int_out[i]; + int expected = VectorMath.addSaturating(int_in1[i], int_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_ADD_VL, " >0 "}, applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void sadd_long() { + for (int i = 0; i < COUNT; i += lspec.length()) { + LongVector.fromArray(lspec, long_in1, i) + .lanewise(VectorOperators.SADD, + LongVector.fromArray(lspec, long_in2, i)) + .intoArray(long_out, i); + } + } + + @Check(test = "sadd_long") + public void sadd_long_verify() { + for (int i = 0; i < COUNT; i++) { + long actual = long_out[i]; + long expected = VectorMath.addSaturating(long_in1[i], long_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_ADD_VB, " >0 " , "unsigned_vector_node", " >0 "}, + phase = {CompilePhase.BEFORE_MATCHING}, + applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void suadd_byte() { + for (int i = 0; i < COUNT; i += bspec.length()) { + ByteVector.fromArray(bspec, byte_in1, i) + .lanewise(VectorOperators.SUADD, + ByteVector.fromArray(bspec, byte_in2, i)) + .intoArray(byte_out, i); + } + } + + @Check(test = "suadd_byte") + public void suadd_byte_verify() { + for (int i = 0; i < COUNT; i++) { + byte actual = byte_out[i]; + byte expected = VectorMath.addSaturatingUnsigned(byte_in1[i], byte_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_ADD_VS, " >0 ", "unsigned_vector_node", " >0 "}, + phase = {CompilePhase.BEFORE_MATCHING}, + applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void suadd_short() { + for (int i = 0; i < COUNT; i += sspec.length()) { + ShortVector.fromArray(sspec, short_in1, i) + .lanewise(VectorOperators.SUADD, + ShortVector.fromArray(sspec, short_in2, i)) + .intoArray(short_out, i); + } + } + + @Check(test = "suadd_short") + public void suadd_short_verify() { + for (int i = 0; i < COUNT; i++) { + short actual = short_out[i]; + short expected = VectorMath.addSaturatingUnsigned(short_in1[i], short_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_ADD_VI, " >0 ", "unsigned_vector_node", " >0 "}, + phase = {CompilePhase.BEFORE_MATCHING}, + applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void suadd_int() { + for (int i = 0; i < COUNT; i += ispec.length()) { + IntVector.fromArray(ispec, int_in1, i) + .lanewise(VectorOperators.SUADD, + IntVector.fromArray(ispec, int_in2, i)) + .intoArray(int_out, i); + } + } + + @Check(test = "suadd_int") + public void suadd_int_verify() { + for (int i = 0; i < COUNT; i++) { + int actual = int_out[i]; + int expected = VectorMath.addSaturatingUnsigned(int_in1[i], int_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_ADD_VL, " >0 ", "unsigned_vector_node", " >0 "}, + phase = {CompilePhase.BEFORE_MATCHING}, + applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void suadd_long() { + for (int i = 0; i < COUNT; i += lspec.length()) { + LongVector.fromArray(lspec, long_in1, i) + .lanewise(VectorOperators.SUADD, + LongVector.fromArray(lspec, long_in2, i)) + .intoArray(long_out, i); + } + } + + @Check(test = "suadd_long") + public void suadd_long_verify() { + for (int i = 0; i < COUNT; i++) { + long actual = long_out[i]; + long expected = VectorMath.addSaturatingUnsigned(long_in1[i], long_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_SUB_VB, " >0 "}, applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void ssub_byte() { + for (int i = 0; i < COUNT; i += bspec.length()) { + ByteVector.fromArray(bspec, byte_in1, i) + .lanewise(VectorOperators.SSUB, + ByteVector.fromArray(bspec, byte_in2, i)) + .intoArray(byte_out, i); + } + } + + @Check(test = "ssub_byte") + public void ssub_byte_verify() { + for (int i = 0; i < COUNT; i++) { + byte actual = byte_out[i]; + byte expected = VectorMath.subSaturating(byte_in1[i], byte_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_SUB_VS, " >0 "}, applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void ssub_short() { + for (int i = 0; i < COUNT; i += sspec.length()) { + ShortVector.fromArray(sspec, short_in1, i) + .lanewise(VectorOperators.SSUB, + ShortVector.fromArray(sspec, short_in2, i)) + .intoArray(short_out, i); + } + } + + @Check(test = "ssub_short") + public void ssub_short_verify() { + for (int i = 0; i < COUNT; i++) { + short actual = short_out[i]; + short expected = VectorMath.subSaturating(short_in1[i], short_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_SUB_VI, " >0 "}, applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void ssub_int() { + for (int i = 0; i < COUNT; i += ispec.length()) { + IntVector.fromArray(ispec, int_in1, i) + .lanewise(VectorOperators.SSUB, + IntVector.fromArray(ispec, int_in2, i)) + .intoArray(int_out, i); + } + } + + @Check(test = "ssub_int") + public void ssub_int_verify() { + for (int i = 0; i < COUNT; i++) { + int actual = int_out[i]; + int expected = VectorMath.subSaturating(int_in1[i], int_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_SUB_VL, " >0 "}, applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void ssub_long() { + for (int i = 0; i < COUNT; i += lspec.length()) { + LongVector.fromArray(lspec, long_in1, i) + .lanewise(VectorOperators.SSUB, + LongVector.fromArray(lspec, long_in2, i)) + .intoArray(long_out, i); + } + } + + @Check(test = "ssub_long") + public void ssub_long_verify() { + for (int i = 0; i < COUNT; i++) { + long actual = long_out[i]; + long expected = VectorMath.subSaturating(long_in1[i], long_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_SUB_VB, " >0 " , "unsigned_vector_node", " >0 "}, + phase = {CompilePhase.BEFORE_MATCHING}, + applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void susub_byte() { + for (int i = 0; i < COUNT; i += bspec.length()) { + ByteVector.fromArray(bspec, byte_in1, i) + .lanewise(VectorOperators.SUSUB, + ByteVector.fromArray(bspec, byte_in2, i)) + .intoArray(byte_out, i); + } + } + + @Check(test = "susub_byte") + public void susub_byte_verify() { + for (int i = 0; i < COUNT; i++) { + byte actual = byte_out[i]; + byte expected = VectorMath.subSaturatingUnsigned(byte_in1[i], byte_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_SUB_VS, " >0 ", "unsigned_vector_node", " >0 "}, + phase = {CompilePhase.BEFORE_MATCHING}, + applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void susub_short() { + for (int i = 0; i < COUNT; i += sspec.length()) { + ShortVector.fromArray(sspec, short_in1, i) + .lanewise(VectorOperators.SUSUB, + ShortVector.fromArray(sspec, short_in2, i)) + .intoArray(short_out, i); + } + } + + @Check(test = "susub_short") + public void susub_short_verify() { + for (int i = 0; i < COUNT; i++) { + short actual = short_out[i]; + short expected = VectorMath.subSaturatingUnsigned(short_in1[i], short_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_SUB_VI, " >0 ", "unsigned_vector_node", " >0 "}, + phase = {CompilePhase.BEFORE_MATCHING}, + applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void susub_int() { + for (int i = 0; i < COUNT; i += ispec.length()) { + IntVector.fromArray(ispec, int_in1, i) + .lanewise(VectorOperators.SUSUB, + IntVector.fromArray(ispec, int_in2, i)) + .intoArray(int_out, i); + } + } + + @Check(test = "susub_int") + public void susub_int_verify() { + for (int i = 0; i < COUNT; i++) { + int actual = int_out[i]; + int expected = VectorMath.subSaturatingUnsigned(int_in1[i], int_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } + + @Test + @IR(counts = {IRNode.SATURATING_SUB_VL, " >0 ", "unsigned_vector_node", " >0 "}, + phase = {CompilePhase.BEFORE_MATCHING}, + applyIfCPUFeature = {"avx", "true"}) + @Warmup(value = 10000) + public void susub_long() { + for (int i = 0; i < COUNT; i += lspec.length()) { + LongVector.fromArray(lspec, long_in1, i) + .lanewise(VectorOperators.SUSUB, + LongVector.fromArray(lspec, long_in2, i)) + .intoArray(long_out, i); + } + } + + @Check(test = "susub_long") + public void susub_long_verify() { + for (int i = 0; i < COUNT; i++) { + long actual = long_out[i]; + long expected = VectorMath.subSaturatingUnsigned(long_in1[i], long_in2[i]); + if (actual != expected) { + throw new AssertionError("Result Mismatch : actual (" + actual + ") != expected (" + expected + ")"); + } + } + } +} diff --git a/test/jdk/sun/security/action/GetLongAction/ReturnNullIfNoDefault.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/OldClassWithStaticString.jasm similarity index 52% rename from test/jdk/sun/security/action/GetLongAction/ReturnNullIfNoDefault.java rename to test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/OldClassWithStaticString.jasm index be46557501929..d36f0e1d21245 100644 --- a/test/jdk/sun/security/action/GetLongAction/ReturnNullIfNoDefault.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/OldClassWithStaticString.jasm @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, 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 @@ -19,36 +19,31 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. + * */ /* - * @test - * @bug 4173993 - * @summary Make sure "null" is returned if property does not exist (or has - * wrong numeric format) and no default has been specified. - * @modules java.base/sun.security.action - */ -import sun.security.action.*; +// Compiled from this source, but we want the version to be 49.0 to use the old verifier. -public class ReturnNullIfNoDefault { - - public static void main(String[] args) throws Exception { - long larg = 1234567890L; +class OldClassWithStaticString { + static final String s = "xxxx123yyyy456"; + static final String t = "OldClassWithStaticString"; +} - GetLongAction ac = new GetLongAction("test"); - if (ac.run() != null) - throw new Exception("Returned value is not null"); +*/ - ac = new GetLongAction("test", larg); - long ret = ((Long)ac.run()).longValue(); - if (ret != larg) - throw new Exception("Returned value differs from default"); +public super class OldClassWithStaticString + version 49:0 +{ + public static final Field s:"Ljava/lang/String;" = String "xxxx123yyyy456"; + public static final Field t:"Ljava/lang/String;" = String "OldClassWithStaticString"; - System.setProperty("test", Long.toString(larg)); - ac = new GetLongAction("test"); - ret = ((Long)ac.run()).longValue(); - if (ret != larg) - throw new Exception("Returned value differs from property"); + Method "":"()V" + stack 1 locals 1 + { + aload_0; + invokespecial Method java/lang/Object."":"()V"; + return; } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/StaticStringInOldClass.java b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/StaticStringInOldClass.java new file mode 100644 index 0000000000000..f282b0c664dcb --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/sharedStrings/StaticStringInOldClass.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +/** + * @test + * @bug 8344904 + * @summary make sure all interned strings in old classes are archived. + * @requires vm.cds.write.archived.java.heap + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * @build OldClassWithStaticString + * @build StaticStringInOldClass + * @run driver jdk.test.lib.helpers.ClassFileInstaller + * -jar StaticStringInOldClass.jar StaticStringInOldClass StaticStringInOldClassApp OldClassWithStaticString + * @run driver StaticStringInOldClass + */ + +import java.lang.reflect.Field; +import jdk.test.lib.process.OutputAnalyzer; +import jdk.test.lib.helpers.ClassFileInstaller; + +public class StaticStringInOldClass { + static final String appClass = StaticStringInOldClassApp.class.getName(); + static String[] classes = { + appClass, + OldClassWithStaticString.class.getName(), + }; + + public static void main(String[] args) throws Exception { + String appJar = ClassFileInstaller.getJarPath("StaticStringInOldClass.jar"); + OutputAnalyzer output; + output = TestCommon.testDump(appJar, TestCommon.list(classes)); + output = TestCommon.exec(appJar, appClass); + TestCommon.checkExec(output, "Hello"); + } +} + +class StaticStringInOldClassApp { + static String a = "xxxx123"; + public static void main(String args[]) throws Exception { + System.out.println("Hello"); + String x = (a + "yyyy456").intern(); + Class c = OldClassWithStaticString.class; + Field f = c.getField("s"); + String y = (String)(f.get(null)); + if (x != y) { + throw new RuntimeException("Interned strings not equal: " + + "\"" + x + "\" @ " + System.identityHashCode(x) + " vs " + + "\"" + y + "\" @ " + System.identityHashCode(y)); + } + } +} diff --git a/test/hotspot/jtreg/serviceability/dcmd/thread/VThreadCommandsTest.java b/test/hotspot/jtreg/serviceability/dcmd/thread/VThreadCommandsTest.java new file mode 100644 index 0000000000000..de2b72496124b --- /dev/null +++ b/test/hotspot/jtreg/serviceability/dcmd/thread/VThreadCommandsTest.java @@ -0,0 +1,133 @@ +/* + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8337199 + * @summary Basic test for jcmd Thread.vthread_scheduler and Thread.vthread_pollers + * @requires vm.continuations + * @modules jdk.jcmd + * @library /test/lib + * @run junit/othervm VThreadCommandsTest + */ + +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketTimeoutException; +import java.util.List; +import java.util.Objects; +import java.util.concurrent.Executors; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.ForkJoinWorkerThread; +import java.util.concurrent.ScheduledThreadPoolExecutor; +import java.util.concurrent.atomic.AtomicBoolean; +import java.lang.management.ManagementFactory; +import jdk.management.VirtualThreadSchedulerMXBean; + +import jdk.test.lib.dcmd.PidJcmdExecutor; +import jdk.test.lib.process.OutputAnalyzer; +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +class VThreadCommandsTest { + + /** + * Thread.vthread_scheduler + */ + @Test + void testVThreadScheduler() { + // ensure default scheduler and timeout schedulers are initialized + Thread.startVirtualThread(() -> { }); + + jcmd("Thread.vthread_scheduler") + .shouldContain(Objects.toIdentityString(defaultScheduler())) + .shouldContain("Delayed task schedulers:") + .shouldContain("[0] " + ScheduledThreadPoolExecutor.class.getName()); + } + + /** + * Thread.vthread_pollers + */ + @Test + void testVThreadPollers() throws Exception { + // do blocking I/O op on a virtual thread to ensure poller mechanism is initialized + try (var executor = Executors.newVirtualThreadPerTaskExecutor()) { + executor.submit(() -> { + try (var listener = new ServerSocket()) { + InetAddress lb = InetAddress.getLoopbackAddress(); + listener.bind(new InetSocketAddress(lb, 0)); + listener.setSoTimeout(200); + try (Socket s = listener.accept()) { + System.err.format("Connection from %s ??%n", s.getRemoteSocketAddress()); + } catch (SocketTimeoutException e) { + // expected + } + } + return null; + }).get(); + } + + jcmd("Thread.vthread_pollers") + .shouldContain("Read I/O pollers:") + .shouldContain("Write I/O pollers:") + .shouldMatch("^\\[0\\] sun\\.nio\\.ch\\..+ \\[registered = [\\d]+, owner = .+\\]$"); + } + + private OutputAnalyzer jcmd(String cmd) { + return new PidJcmdExecutor().execute(cmd); + } + + /** + * Returns the virtual thread default scheduler. This implementation works by finding + * all FJ worker threads and mapping them to their pool. VirtualThreadSchedulerMXBean + * is used to temporarily changing target parallelism to an "unique" value, make it + * possbile to find the right pool. + */ + private ForkJoinPool defaultScheduler() { + var done = new AtomicBoolean(); + Thread vthread = Thread.startVirtualThread(() -> { + while (!done.get()) { + Thread.onSpinWait(); + } + }); + var bean = ManagementFactory.getPlatformMXBean(VirtualThreadSchedulerMXBean.class); + int parallelism = bean.getParallelism(); + try { + bean.setParallelism(133); + return Thread.getAllStackTraces() + .keySet() + .stream() + .filter(ForkJoinWorkerThread.class::isInstance) + .map(t -> ((ForkJoinWorkerThread) t).getPool()) + .filter(p -> p.getParallelism() == 133) + .findAny() + .orElseThrow(); + } finally { + bean.setParallelism(parallelism); + done.set(true); + } + } +} diff --git a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java index 5bd748c3d870f..ecb88de193283 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java +++ b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java @@ -51,7 +51,7 @@ /* * @test - * @bug 8158084 8162438 8162442 8163535 8166220 + * @bug 8158084 8162438 8162442 8163535 8166220 8344800 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm catalog.CatalogSupport2 * @summary extends CatalogSupport tests, verifies that the use of the Catalog may @@ -234,7 +234,7 @@ public Object[][] getDataSchemaC() { return new Object[][]{ // for resolving DTD in xsd - {false, true, xml_catalog, xsd_xmlSchema, null}, + {false, true, xml_catalog, xsd_val_test_dtd, null}, // for resolving xsd import {false, true, xml_catalog, xsd_xmlSchema_import, null}, // for resolving xsd include diff --git a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java index 0b2c019869994..4d44ce80fe644 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java +++ b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java @@ -51,7 +51,7 @@ /* * @test - * @bug 8158084 8162438 8162442 8163535 8166220 + * @bug 8158084 8162438 8162442 8163535 8166220 8344800 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm catalog.CatalogSupport3 * @summary extends CatalogSupport tests, verifies that the use of the Catalog may @@ -236,7 +236,7 @@ public Object[][] getDataSchemaC() { return new Object[][]{ // for resolving DTD in xsd - {true, false, xml_catalog, xsd_xmlSchema, null}, + {true, false, xml_catalog, xsd_val_test_dtd, null}, // for resolving xsd import {true, false, xml_catalog, xsd_xmlSchema_import, null}, // for resolving xsd include diff --git a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java index e22c1edf6c295..faa260b275e04 100644 --- a/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java +++ b/test/jaxp/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, 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 @@ -126,7 +126,7 @@ protected void setUp() { // For the xsd import and include String xsd_xmlSchema, dtd_xmlSchema, dtd_datatypes; String xsd_xmlSchema_import, xsd_xml; - String xml_val_test, xml_val_test_id, xsd_val_test; + String xml_val_test, xml_val_test_id, xsd_val_test, xsd_val_test_dtd; String xsd_include_company, xsd_include_person, xsd_include_product; String xsl_include, xsl_includeDTD, xsl_import_html, xsl_include_header, xsl_include_footer; @@ -254,6 +254,7 @@ void initFiles() { xml_val_test = filepath + "/val_test.xml"; xml_val_test_id = "file://" + slash + xml_val_test; xsd_val_test = filepath + "/val_test.xsd"; + xsd_val_test_dtd = Paths.get(filepath + "val_test_dtd.xsd").toUri().toASCIIString(); xml_xsl = "\n" + "\n" + @@ -375,7 +376,11 @@ public void testValidation(boolean setUseCatalog, boolean useCatalog, String cat factory.setProperty(CatalogFeatures.Feature.FILES.getPropertyName(), catalog); } - Schema schema = factory.newSchema(new StreamSource(new StringReader(xsd))); + if (xsd.endsWith(".xsd")) { + Schema schema = factory.newSchema(new StreamSource(xsd)); + } else { + Schema schema = factory.newSchema(new StreamSource(new StringReader(xsd))); + } success("XMLSchema.dtd and datatypes.dtd are resolved."); } diff --git a/test/jaxp/javax/xml/jaxp/unittest/catalog/val_test_dtd.xsd b/test/jaxp/javax/xml/jaxp/unittest/catalog/val_test_dtd.xsd new file mode 100644 index 0000000000000..1c320079e173e --- /dev/null +++ b/test/jaxp/javax/xml/jaxp/unittest/catalog/val_test_dtd.xsd @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + diff --git a/test/jdk/com/sun/net/httpserver/ExchangeAttributeTest.java b/test/jdk/com/sun/net/httpserver/ExchangeAttributeTest.java index 2ce3dfd016d00..84c7837e0b33d 100644 --- a/test/jdk/com/sun/net/httpserver/ExchangeAttributeTest.java +++ b/test/jdk/com/sun/net/httpserver/ExchangeAttributeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,16 +23,19 @@ /* * @test - * @bug 8288109 + * @bug 8288109 8235786 * @summary Tests for HttpExchange set/getAttribute * @library /test/lib * @run junit/othervm ExchangeAttributeTest */ +import com.sun.net.httpserver.Filter; +import com.sun.net.httpserver.HttpContext; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; import jdk.test.lib.net.URIBuilder; +import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -53,44 +56,87 @@ public class ExchangeAttributeTest { - static final InetAddress LOOPBACK_ADDR = InetAddress.getLoopbackAddress(); - static final boolean ENABLE_LOGGING = true; - static final Logger logger = Logger.getLogger("com.sun.net.httpserver"); + private static final InetAddress LOOPBACK_ADDR = InetAddress.getLoopbackAddress(); + private static final boolean ENABLE_LOGGING = true; + private static final Logger logger = Logger.getLogger("com.sun.net.httpserver"); + + private static HttpServer server; @BeforeAll - public static void setup() { + public static void setup() throws Exception { if (ENABLE_LOGGING) { ConsoleHandler ch = new ConsoleHandler(); logger.setLevel(Level.ALL); ch.setLevel(Level.ALL); logger.addHandler(ch); } + server = HttpServer.create(new InetSocketAddress(LOOPBACK_ADDR, 0), 10); + server.createContext("/normal", new AttribHandler()); + final HttpContext filteredCtx = server.createContext("/filtered", new AttribHandler()); + filteredCtx.getFilters().add(new AttributeAddingFilter()); + server.start(); + System.out.println("Server started at " + server.getAddress()); + } + + @AfterAll + public static void afterAll() { + if (server != null) { + System.out.println("Stopping server " + server.getAddress()); + server.stop(0); + } } + /* + * Verifies that HttpExchange.setAttribute() allows for null value. + */ @Test - public void testExchangeAttributes() throws Exception { - var handler = new AttribHandler(); - var server = HttpServer.create(new InetSocketAddress(LOOPBACK_ADDR,0), 10); - server.createContext("/", handler); - server.start(); - try { - var client = HttpClient.newBuilder().proxy(NO_PROXY).build(); - var request = HttpRequest.newBuilder(uri(server, "")).build(); + public void testNullAttributeValue() throws Exception { + try (var client = HttpClient.newBuilder().proxy(NO_PROXY).build()) { + var request = HttpRequest.newBuilder(uri(server, "/normal", null)).build(); var response = client.send(request, HttpResponse.BodyHandlers.ofString()); assertEquals(200, response.statusCode()); - } finally { - server.stop(0); + } + } + + /* + * Verifies that an attribute set on one exchange is accessible to another exchange that + * belongs to the same HttpContext. + */ + @Test + public void testSharedAttribute() throws Exception { + try (var client = HttpClient.newBuilder().proxy(NO_PROXY).build()) { + final var firstReq = HttpRequest.newBuilder(uri(server, "/filtered", "firstreq")) + .build(); + System.out.println("issuing request " + firstReq); + final var firstResp = client.send(firstReq, HttpResponse.BodyHandlers.ofString()); + assertEquals(200, firstResp.statusCode()); + + // issue the second request + final var secondReq = HttpRequest.newBuilder(uri(server, "/filtered", "secondreq")) + .build(); + System.out.println("issuing request " + secondReq); + final var secondResp = client.send(secondReq, HttpResponse.BodyHandlers.ofString()); + assertEquals(200, secondResp.statusCode()); + + // verify that the filter was invoked for both the requests. the filter internally + // does the setAttribute() and getAttribute() and asserts that the attribute value + // set by the first exchange was available through the second exchange. + assertTrue(AttributeAddingFilter.filteredFirstReq, "Filter wasn't invoked for " + + firstReq.uri()); + assertTrue(AttributeAddingFilter.filteredSecondReq, "Filter wasn't invoked for " + + secondReq.uri()); } } // --- infra --- - static URI uri(HttpServer server, String path) throws URISyntaxException { + static URI uri(HttpServer server, String path, String query) throws URISyntaxException { return URIBuilder.newBuilder() .scheme("http") .loopback() .port(server.getAddress().getPort()) .path(path) + .query(query) .build(); } @@ -112,4 +158,54 @@ public void handle(HttpExchange exchange) throws IOException { } } } + + private static final class AttributeAddingFilter extends Filter { + + private static final String ATTR_NAME ="foo-bar"; + private static final String ATTR_VAL ="hello-world"; + private static volatile boolean filteredFirstReq; + private static volatile boolean filteredSecondReq; + + @Override + public void doFilter(final HttpExchange exchange, final Chain chain) throws IOException { + if (exchange.getRequestURI().getQuery().contains("firstreq")) { + filteredFirstReq = true; + // add a request attribute through the exchange, for this first request + // and at the same time verify that the attribute doesn't already exist + final Object attrVal = exchange.getAttribute(ATTR_NAME); + if (attrVal != null) { + throw new IOException("attribute " + ATTR_NAME + " with value: " + attrVal + + " unexpectedly present in exchange: " + exchange.getRequestURI()); + } + // set the value + exchange.setAttribute(ATTR_NAME, ATTR_VAL); + System.out.println(exchange.getRequestURI() + " set attribute " + + ATTR_NAME + "=" + ATTR_VAL); + } else if (exchange.getRequestURI().getQuery().contains("secondreq")) { + filteredSecondReq = true; + // verify the attribute is already set and the value is the expected one. + final Object attrVal = exchange.getAttribute(ATTR_NAME); + if (attrVal == null) { + throw new IOException("attribute " + ATTR_NAME + " is missing in exchange: " + + exchange.getRequestURI()); + } + if (!ATTR_VAL.equals(attrVal)) { + throw new IOException("unexpected value: " + attrVal + " for attribute " + + ATTR_NAME + " in exchange: " + exchange.getRequestURI()); + } + System.out.println(exchange.getRequestURI() + " found attribute " + + ATTR_NAME + "=" + attrVal); + } else { + // unexpected request + throw new IOException("unexpected request " + exchange.getRequestURI()); + } + // let the request proceed + chain.doFilter(exchange); + } + + @Override + public String description() { + return "AttributeAddingFilter"; + } + } } diff --git a/test/jdk/java/foreign/TestIllegalLink.java b/test/jdk/java/foreign/TestIllegalLink.java index b5052b4346c7e..2a9d5ad37826d 100644 --- a/test/jdk/java/foreign/TestIllegalLink.java +++ b/test/jdk/java/foreign/TestIllegalLink.java @@ -192,11 +192,6 @@ public static Object[][] types() { NO_OPTIONS, "has unexpected size" }, - { - FunctionDescriptor.ofVoid(), - new Linker.Option[]{Linker.Option.critical(false), Linker.Option.captureCallState("errno")}, - "Incompatible linker options: captureCallState, critical" - }, })); for (ValueLayout illegalLayout : List.of(C_CHAR, ValueLayout.JAVA_CHAR, C_BOOL, C_SHORT, C_FLOAT)) { diff --git a/test/jdk/java/foreign/TestStringEncoding.java b/test/jdk/java/foreign/TestStringEncoding.java index 4caef6fbd09b4..94732943b9d36 100644 --- a/test/jdk/java/foreign/TestStringEncoding.java +++ b/test/jdk/java/foreign/TestStringEncoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, 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 @@ -39,6 +39,7 @@ import java.util.Random; import java.util.function.UnaryOperator; +import jdk.internal.foreign.AbstractMemorySegmentImpl; import jdk.internal.foreign.StringSupport; import org.testng.annotations.*; @@ -53,6 +54,20 @@ public class TestStringEncoding { + @Test + public void emptySegment() { + for (Charset charset : standardCharsets()) { + for (Arena arena : arenas()) { + try (arena) { + var segment = arena.allocate(0); + var e = expectThrows(IndexOutOfBoundsException.class, () -> + segment.getString(0, charset)); + assertTrue(e.getMessage().contains("No null terminator found")); + } + } + } + } + @Test(dataProvider = "strings") public void testStrings(String testString) { for (Charset charset : Charset.availableCharsets().values()) { @@ -87,7 +102,6 @@ public void testStrings(String testString) { } } - @Test(dataProvider = "strings") public void testStringsHeap(String testString) { for (Charset charset : singleByteCharsets()) { @@ -198,8 +212,9 @@ public void testOffset(String testString) { try (arena) { MemorySegment inSegment = arena.allocateFrom(testString, charset); for (int i = 0; i < 3; i++) { + String expected = testString.substring(i); String actual = inSegment.getString(i, charset); - assertEquals(actual, testString.substring(i)); + assertEquals(actual, expected); } } } @@ -249,6 +264,32 @@ public void segmentationFault() { } } + // This test ensures that we do not address outside the segment even though there + // are odd bytes at the end. + @Test(dataProvider = "strings") + public void offBoundaryTrailingBytes(String testString) { + if (testString.length() < 3 || !containsOnlyRegularCharacters(testString)) { + return; + } + for (var charset : standardCharsets()) { + for (var arena: arenas()) { + try (arena) { + MemorySegment strSegment = arena.allocateFrom(testString, charset); + // Add an odd byte at the end + MemorySegment inSegment = arena.allocate(strSegment.byteSize() + 1); + // Make sure there are no null-terminators so that we will try to scan + // the entire segment. + inSegment.fill((byte) 1); + for (int i = 0; i < 4; i++) { + final int offset = i; + var e = expectThrows(IndexOutOfBoundsException.class, () -> inSegment.getString(offset, charset)); + assertTrue(e.getMessage().contains("No null terminator found")); + } + } + } + } + } + private static final int TEST_LENGTH_MAX = 277; private Random deterministicRandom() { @@ -271,9 +312,15 @@ public void chunked_strlen_byte() { } segment.setAtIndex(JAVA_BYTE, len, (byte) 0); for (int j = 0; j < len; j++) { - int actual = StringSupport.chunkedStrlenByte(segment, j); + int actual = StringSupport.strlenByte((AbstractMemorySegmentImpl) segment, j, segment.byteSize()); assertEquals(actual, len - j); } + // Test end offset + for (int j = 0; j < len - 1; j++) { + final long toOffset = j; + expectThrows(IndexOutOfBoundsException.class, () -> + StringSupport.strlenByte((AbstractMemorySegmentImpl) segment, 0, toOffset)); + } } } } @@ -295,7 +342,7 @@ public void chunked_strlen_short() { } segment.setAtIndex(JAVA_SHORT, len, (short) 0); for (int j = 0; j < len; j++) { - int actual = StringSupport.chunkedStrlenShort(segment, j * Short.BYTES); + int actual = StringSupport.strlenShort((AbstractMemorySegmentImpl) segment, j * Short.BYTES, segment.byteSize()); assertEquals(actual, (len - j) * Short.BYTES); } } @@ -319,7 +366,7 @@ public void strlen_int() { } segment.setAtIndex(JAVA_INT, len, 0); for (int j = 0; j < len; j++) { - int actual = StringSupport.strlenInt(segment, j * Integer.BYTES); + int actual = StringSupport.strlenInt((AbstractMemorySegmentImpl) segment, j * Integer.BYTES, segment.byteSize()); assertEquals(actual, (len - j) * Integer.BYTES); } } diff --git a/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java b/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java index 51c91ce0f961a..a1bf1183fb59a 100644 --- a/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java +++ b/test/jdk/java/foreign/capturecallstate/TestCaptureCallState.java @@ -61,12 +61,18 @@ public class TestCaptureCallState extends NativeTestHelper { } } - private record SaveValuesCase(String nativeTarget, FunctionDescriptor nativeDesc, String threadLocalName, Consumer resultCheck) {} + private record SaveValuesCase(String nativeTarget, FunctionDescriptor nativeDesc, String threadLocalName, + Consumer resultCheck, boolean critical) {} @Test(dataProvider = "cases") public void testSavedThreadLocal(SaveValuesCase testCase) throws Throwable { - Linker.Option stl = Linker.Option.captureCallState(testCase.threadLocalName()); - MethodHandle handle = downcallHandle(testCase.nativeTarget(), testCase.nativeDesc(), stl); + List options = new ArrayList<>(); + options.add(Linker.Option.captureCallState(testCase.threadLocalName())); + if (testCase.critical()) { + options.add(Linker.Option.critical(false)); + } + MethodHandle handle = downcallHandle(testCase.nativeTarget(), testCase.nativeDesc(), + options.toArray(Linker.Option[]::new)); StructLayout capturedStateLayout = Linker.Option.captureStateLayout(); VarHandle errnoHandle = capturedStateLayout.varHandle(groupElement(testCase.threadLocalName())); @@ -86,9 +92,14 @@ public void testSavedThreadLocal(SaveValuesCase testCase) throws Throwable { @Test(dataProvider = "invalidCaptureSegmentCases") public void testInvalidCaptureSegment(MemorySegment captureSegment, - Class expectedExceptionType, String expectedExceptionMessage) { - Linker.Option stl = Linker.Option.captureCallState("errno"); - MethodHandle handle = downcallHandle("set_errno_V", FunctionDescriptor.ofVoid(C_INT), stl); + Class expectedExceptionType, String expectedExceptionMessage, + Linker.Option[] extraOptions) { + List options = new ArrayList<>(); + options.add(Linker.Option.captureCallState("errno")); + for (Linker.Option extra : extraOptions) { + options.add(extra); + } + MethodHandle handle = downcallHandle("set_errno_V", FunctionDescriptor.ofVoid(C_INT), options.toArray(Linker.Option[]::new)); try { int testValue = 42; @@ -103,32 +114,39 @@ public void testInvalidCaptureSegment(MemorySegment captureSegment, public static Object[][] cases() { List cases = new ArrayList<>(); - cases.add(new SaveValuesCase("set_errno_V", FunctionDescriptor.ofVoid(JAVA_INT), "errno", o -> {})); - cases.add(new SaveValuesCase("set_errno_I", FunctionDescriptor.of(JAVA_INT, JAVA_INT), "errno", o -> assertEquals((int) o, 42))); - cases.add(new SaveValuesCase("set_errno_D", FunctionDescriptor.of(JAVA_DOUBLE, JAVA_INT), "errno", o -> assertEquals((double) o, 42.0))); - - cases.add(structCase("SL", Map.of(JAVA_LONG.withName("x"), 42L))); - cases.add(structCase("SLL", Map.of(JAVA_LONG.withName("x"), 42L, - JAVA_LONG.withName("y"), 42L))); - cases.add(structCase("SLLL", Map.of(JAVA_LONG.withName("x"), 42L, - JAVA_LONG.withName("y"), 42L, - JAVA_LONG.withName("z"), 42L))); - cases.add(structCase("SD", Map.of(JAVA_DOUBLE.withName("x"), 42D))); - cases.add(structCase("SDD", Map.of(JAVA_DOUBLE.withName("x"), 42D, - JAVA_DOUBLE.withName("y"), 42D))); - cases.add(structCase("SDDD", Map.of(JAVA_DOUBLE.withName("x"), 42D, - JAVA_DOUBLE.withName("y"), 42D, - JAVA_DOUBLE.withName("z"), 42D))); - - if (IS_WINDOWS) { - cases.add(new SaveValuesCase("SetLastError", FunctionDescriptor.ofVoid(JAVA_INT), "GetLastError", o -> {})); - cases.add(new SaveValuesCase("WSASetLastError", FunctionDescriptor.ofVoid(JAVA_INT), "WSAGetLastError", o -> {})); + for (boolean critical : new boolean[]{ true, false }) { + cases.add(new SaveValuesCase("set_errno_V", FunctionDescriptor.ofVoid(JAVA_INT), + "errno", o -> {}, critical)); + cases.add(new SaveValuesCase("set_errno_I", FunctionDescriptor.of(JAVA_INT, JAVA_INT), + "errno", o -> assertEquals((int) o, 42), critical)); + cases.add(new SaveValuesCase("set_errno_D", FunctionDescriptor.of(JAVA_DOUBLE, JAVA_INT), + "errno", o -> assertEquals((double) o, 42.0), critical)); + + cases.add(structCase("SL", Map.of(JAVA_LONG.withName("x"), 42L), critical)); + cases.add(structCase("SLL", Map.of(JAVA_LONG.withName("x"), 42L, + JAVA_LONG.withName("y"), 42L), critical)); + cases.add(structCase("SLLL", Map.of(JAVA_LONG.withName("x"), 42L, + JAVA_LONG.withName("y"), 42L, + JAVA_LONG.withName("z"), 42L), critical)); + cases.add(structCase("SD", Map.of(JAVA_DOUBLE.withName("x"), 42D), critical)); + cases.add(structCase("SDD", Map.of(JAVA_DOUBLE.withName("x"), 42D, + JAVA_DOUBLE.withName("y"), 42D), critical)); + cases.add(structCase("SDDD", Map.of(JAVA_DOUBLE.withName("x"), 42D, + JAVA_DOUBLE.withName("y"), 42D, + JAVA_DOUBLE.withName("z"), 42D), critical)); + + if (IS_WINDOWS) { + cases.add(new SaveValuesCase("SetLastError", FunctionDescriptor.ofVoid(JAVA_INT), + "GetLastError", o -> {}, critical)); + cases.add(new SaveValuesCase("WSASetLastError", FunctionDescriptor.ofVoid(JAVA_INT), + "WSAGetLastError", o -> {}, critical)); + } } return cases.stream().map(tc -> new Object[] {tc}).toArray(Object[][]::new); } - static SaveValuesCase structCase(String name, Map fields) { + static SaveValuesCase structCase(String name, Map fields, boolean critical) { StructLayout layout = MemoryLayout.structLayout(fields.keySet().toArray(MemoryLayout[]::new)); Consumer check = o -> {}; @@ -139,16 +157,19 @@ static SaveValuesCase structCase(String name, Map fields) check = check.andThen(o -> assertEquals(fieldHandle.get(o, 0L), value)); } - return new SaveValuesCase("set_errno_" + name, FunctionDescriptor.of(layout, JAVA_INT), "errno", check); + return new SaveValuesCase("set_errno_" + name, FunctionDescriptor.of(layout, JAVA_INT), + "errno", check, critical); } @DataProvider public static Object[][] invalidCaptureSegmentCases() { return new Object[][]{ - {Arena.ofAuto().allocate(1), IndexOutOfBoundsException.class, ".*Out of bound access on segment.*"}, - {MemorySegment.NULL, IllegalArgumentException.class, ".*Capture segment is NULL.*"}, + {Arena.ofAuto().allocate(1), IndexOutOfBoundsException.class, ".*Out of bound access on segment.*", new Linker.Option[0]}, + {MemorySegment.NULL, IllegalArgumentException.class, ".*Capture segment is NULL.*", new Linker.Option[0]}, {Arena.ofAuto().allocate(Linker.Option.captureStateLayout().byteSize() + 3).asSlice(3), // misaligned - IllegalArgumentException.class, ".*Target offset incompatible with alignment constraints.*"}, + IllegalArgumentException.class, ".*Target offset incompatible with alignment constraints.*", new Linker.Option[0]}, + {MemorySegment.ofArray(new byte[(int) Linker.Option.captureStateLayout().byteSize()]), // misaligned + IllegalArgumentException.class, ".*Target offset incompatible with alignment constraints.*", new Linker.Option[0]}, }; } } diff --git a/test/jdk/java/foreign/critical/TestCritical.java b/test/jdk/java/foreign/critical/TestCritical.java index ab5d6017abaac..85aa962383b9b 100644 --- a/test/jdk/java/foreign/critical/TestCritical.java +++ b/test/jdk/java/foreign/critical/TestCritical.java @@ -45,12 +45,16 @@ import java.util.ArrayList; import java.util.List; import java.util.function.IntFunction; +import java.util.stream.Collectors; import java.util.stream.Stream; import static org.testng.Assert.assertEquals; public class TestCritical extends NativeTestHelper { + static final MemoryLayout CAPTURE_STATE_LAYOUT = Linker.Option.captureStateLayout(); + static final VarHandle ERRNO_HANDLE = CAPTURE_STATE_LAYOUT.varHandle(MemoryLayout.PathElement.groupElement("errno")); + static { System.loadLibrary("Critical"); } @@ -87,11 +91,16 @@ public void testWithReturnBuffer() throws Throwable { } public record AllowHeapCase(IntFunction newArraySegment, ValueLayout elementLayout, - String fName, FunctionDescriptor fDesc, boolean readOnly) {} + String fName, FunctionDescriptor fDesc, boolean readOnly, boolean captureErrno) {} @Test(dataProvider = "allowHeapCases") public void testAllowHeap(AllowHeapCase testCase) throws Throwable { - MethodHandle handle = downcallHandle(testCase.fName(), testCase.fDesc(), Linker.Option.critical(true)); + List options = new ArrayList<>(); + options.add(Linker.Option.critical(true)); + if (testCase.captureErrno()) { + options.add(Linker.Option.captureCallState("errno")); + } + MethodHandle handle = downcallHandle(testCase.fName(), testCase.fDesc(), options.toArray(Linker.Option[]::new)); int elementCount = 10; MemorySegment heapSegment = testCase.newArraySegment().apply(elementCount); if (testCase.readOnly()) { @@ -101,29 +110,36 @@ public void testAllowHeap(AllowHeapCase testCase) throws Throwable { try (Arena arena = Arena.ofConfined()) { TestValue[] tvs = genTestArgs(testCase.fDesc(), arena); - Object[] args = Stream.of(tvs).map(TestValue::value).toArray(); + List args = Stream.of(tvs).map(TestValue::value).collect(Collectors.toCollection(ArrayList::new)); + MemorySegment captureSegment = testCase.captureErrno() + ? MemorySegment.ofArray(new int[((int) CAPTURE_STATE_LAYOUT.byteSize() + 3) / 4]) + : null; // inject our custom last three arguments - args[args.length - 1] = (int) sequence.byteSize(); + args.set(args.size() - 1, (int) sequence.byteSize()); TestValue sourceSegment = genTestValue(sequence, arena); - args[args.length - 2] = sourceSegment.value(); - args[args.length - 3] = heapSegment; + args.set(args.size() - 2, sourceSegment.value()); + args.set(args.size() - 3, heapSegment); + if (testCase.captureErrno()) { + args.add(0, captureSegment); + } if (handle.type().parameterType(0) == SegmentAllocator.class) { - Object[] newArgs = new Object[args.length + 1]; - newArgs[0] = arena; - System.arraycopy(args, 0, newArgs, 1, args.length); - args = newArgs; + args.add(0, arena); } Object o = handle.invokeWithArguments(args); - if (o != null) { tvs[0].check(o); } // check that writes went through to array sourceSegment.check(heapSegment); + + if (testCase.captureErrno()) { + int errno = (int) ERRNO_HANDLE.get(captureSegment, 0L); + assertEquals(errno, 42); + } } } @@ -149,14 +165,16 @@ public Object[][] allowHeapCases() { List cases = new ArrayList<>(); - for (HeapSegmentFactory hsf : HeapSegmentFactory.values()) { - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void", voidDesc, false)); - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_int", intDesc, false)); - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_return_buffer", L2Desc, false)); - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_imr", L3Desc, false)); - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void_stack", stackDesc, false)); - // readOnly - cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void", voidDesc, true)); + for (boolean doCapture : new boolean[]{ true, false }) { + for (HeapSegmentFactory hsf : HeapSegmentFactory.values()) { + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void", voidDesc, false, doCapture)); + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_int", intDesc, false, doCapture)); + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_return_buffer", L2Desc, false, doCapture)); + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_imr", L3Desc, false, doCapture)); + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void_stack", stackDesc, false, doCapture)); + // readOnly + cases.add(new AllowHeapCase(hsf.newArray, hsf.elementLayout, "test_allow_heap_void", voidDesc, true, doCapture)); + } } return cases.stream().map(e -> new Object[]{ e }).toArray(Object[][]::new); diff --git a/test/jdk/java/foreign/critical/libCritical.c b/test/jdk/java/foreign/critical/libCritical.c index cc03db3c43cfd..c901df0a36893 100644 --- a/test/jdk/java/foreign/critical/libCritical.c +++ b/test/jdk/java/foreign/critical/libCritical.c @@ -53,12 +53,14 @@ EXPORT void test_allow_heap_void(unsigned char* heapArr, unsigned char* nativeAr for (int i = 0; i < numBytes; i++) { heapArr[i] = nativeArr[i]; } + errno = 42; } EXPORT int test_allow_heap_int(int a0, unsigned char* heapArr, unsigned char* nativeArr, int numBytes) { for (int i = 0; i < numBytes; i++) { heapArr[i] = nativeArr[i]; } + errno = 42; return a0; } @@ -71,6 +73,7 @@ EXPORT struct L2 test_allow_heap_return_buffer(struct L2 a0, unsigned char* heap for (int i = 0; i < numBytes; i++) { heapArr[i] = nativeArr[i]; } + errno = 42; return a0; } @@ -84,6 +87,7 @@ EXPORT struct L3 test_allow_heap_imr(struct L3 a0, unsigned char* heapArr, unsig for (int i = 0; i < numBytes; i++) { heapArr[i] = nativeArr[i]; } + errno = 42; return a0; } @@ -94,4 +98,5 @@ EXPORT void test_allow_heap_void_stack(long long a0, long long a1, long long a2, for (int i = 0; i < numBytes; i++) { heapArr[i] = nativeArr[i]; } + errno = 42; } diff --git a/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java b/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java index d75e827fbc631..abd793b31da2e 100644 --- a/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java +++ b/test/jdk/java/foreign/enablenativeaccess/TestEnableNativeAccessJarManifest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024 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 @@ -21,7 +21,7 @@ * questions. */ -/** +/* * @test * @summary Basic test for Enable-Native-Access attribute in the * manifest of a main application JAR @@ -78,7 +78,6 @@ public void testEnableNativeAccessInJarManifest(String action, String cls, Resul // java -jar test.jar List command = new ArrayList<>(List.of( - "--enable-preview", "-Djava.library.path=" + System.getProperty("java.library.path") )); command.addAll(vmArgs); diff --git a/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java b/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java index fadcdf1ba2446..375c672a60695 100644 --- a/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java +++ b/test/jdk/java/foreign/passheapsegment/TestPassHeapSegment.java @@ -31,8 +31,7 @@ import org.testng.annotations.Test; import java.io.IOException; -import java.lang.foreign.FunctionDescriptor; -import java.lang.foreign.MemorySegment; +import java.lang.foreign.*; import java.lang.invoke.MethodHandle; import static java.lang.foreign.ValueLayout.ADDRESS; @@ -51,6 +50,19 @@ public void testNoHeapArgs() throws Throwable { handle.invoke(segment); // should throw } + @Test(expectedExceptions = IllegalArgumentException.class, + expectedExceptionsMessageRegExp = ".*Heap segment not allowed.*") + public void testNoHeapCaptureCallState() throws Throwable { + MethodHandle handle = downcallHandle("test_args", FunctionDescriptor.ofVoid(ADDRESS), + Linker.Option.captureCallState("errno")); + try (Arena arena = Arena.ofConfined()) { + assert Linker.Option.captureStateLayout().byteAlignment() % 4 == 0; + MemorySegment captureHeap = MemorySegment.ofArray(new int[(int) Linker.Option.captureStateLayout().byteSize() / 4]); + MemorySegment segment = arena.allocateFrom(C_CHAR, new byte[]{ 0, 1, 2 }); + handle.invoke(captureHeap, segment); // should throw for captureHeap + } + } + @Test(dataProvider = "specs") public void testNoHeapReturns(boolean spec) throws IOException, InterruptedException { runInNewProcess(Runner.class, spec) diff --git a/test/jdk/java/net/IDNTest.java b/test/jdk/java/net/IDNTest.java new file mode 100644 index 0000000000000..aa58e472bf36b --- /dev/null +++ b/test/jdk/java/net/IDNTest.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.net.IDN; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +/* + * @test + * @bug 7038838 + * @summary verify the behaviour of the methods on java.net.IDN class + * @run junit IDNTest + */ +public class IDNTest { + + /* + * Verify that various methods on the IDN class throw a NullPointerException + * for any null parameter. + */ + @Test + public void testNullPointerException() throws Exception { + assertThrows(NullPointerException.class, () -> IDN.toASCII(null)); + assertThrows(NullPointerException.class, () -> IDN.toASCII(null, 0)); + assertThrows(NullPointerException.class, () -> IDN.toUnicode(null)); + assertThrows(NullPointerException.class, () -> IDN.toUnicode(null, 0)); + } +} \ No newline at end of file diff --git a/test/jdk/java/net/Socket/ConnectFailTest.java b/test/jdk/java/net/Socket/ConnectFailTest.java new file mode 100644 index 0000000000000..7cc46ce4a4dd6 --- /dev/null +++ b/test/jdk/java/net/Socket/ConnectFailTest.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import jdk.test.lib.Utils; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import java.io.IOException; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.nio.channels.SocketChannel; +import java.util.List; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/* + * @test + * @bug 8343791 + * @summary verifies that `connect()` failures throw the expected exception and leave socket in the expected state + * @library /test/lib + * @run junit ConnectFailTest + */ +class ConnectFailTest { + + private static final int DEAD_SERVER_PORT = 0xDEAD; + + private static final InetSocketAddress REFUSING_SOCKET_ADDRESS = Utils.refusingEndpoint(); + + private static final InetSocketAddress UNRESOLVED_ADDRESS = + InetSocketAddress.createUnresolved("no.such.host", DEAD_SERVER_PORT); + + @Test + void testUnresolvedAddress() { + assertTrue(UNRESOLVED_ADDRESS.isUnresolved()); + } + + /** + * Verifies that an unbound socket is closed when {@code connect()} fails. + */ + @ParameterizedTest + @MethodSource("sockets") + void testUnboundSocket(Socket socket) throws IOException { + try (socket) { + assertFalse(socket.isBound()); + assertFalse(socket.isConnected()); + assertThrows(IOException.class, () -> socket.connect(REFUSING_SOCKET_ADDRESS)); + assertTrue(socket.isClosed()); + } + } + + /** + * Verifies that a bound socket is closed when {@code connect()} fails. + */ + @ParameterizedTest + @MethodSource("sockets") + void testBoundSocket(Socket socket) throws IOException { + try (socket) { + socket.bind(new InetSocketAddress(0)); + assertTrue(socket.isBound()); + assertFalse(socket.isConnected()); + assertThrows(IOException.class, () -> socket.connect(REFUSING_SOCKET_ADDRESS)); + assertTrue(socket.isClosed()); + } + } + + /** + * Verifies that a connected socket is not closed when {@code connect()} fails. + */ + @ParameterizedTest + @MethodSource("sockets") + void testConnectedSocket(Socket socket) throws Throwable { + try (socket; ServerSocket serverSocket = createEphemeralServerSocket()) { + socket.connect(serverSocket.getLocalSocketAddress()); + try (Socket _ = serverSocket.accept()) { + assertTrue(socket.isBound()); + assertTrue(socket.isConnected()); + SocketException exception = assertThrows( + SocketException.class, + () -> socket.connect(REFUSING_SOCKET_ADDRESS)); + assertEquals("Already connected", exception.getMessage()); + assertFalse(socket.isClosed()); + } + } + } + + /** + * Verifies that an unbound socket is closed when {@code connect()} is invoked using an unresolved address. + */ + @ParameterizedTest + @MethodSource("sockets") + void testUnboundSocketWithUnresolvedAddress(Socket socket) throws IOException { + try (socket) { + assertFalse(socket.isBound()); + assertFalse(socket.isConnected()); + assertThrows(UnknownHostException.class, () -> socket.connect(UNRESOLVED_ADDRESS)); + assertTrue(socket.isClosed()); + } + } + + /** + * Verifies that a bound socket is closed when {@code connect()} is invoked using an unresolved address. + */ + @ParameterizedTest + @MethodSource("sockets") + void testBoundSocketWithUnresolvedAddress(Socket socket) throws IOException { + try (socket) { + socket.bind(new InetSocketAddress(0)); + assertTrue(socket.isBound()); + assertFalse(socket.isConnected()); + assertThrows(UnknownHostException.class, () -> socket.connect(UNRESOLVED_ADDRESS)); + assertTrue(socket.isClosed()); + } + } + + /** + * Verifies that a connected socket is not closed when {@code connect()} is invoked using an unresolved address. + */ + @ParameterizedTest + @MethodSource("sockets") + void testConnectedSocketWithUnresolvedAddress(Socket socket) throws Throwable { + try (socket; ServerSocket serverSocket = createEphemeralServerSocket()) { + socket.connect(serverSocket.getLocalSocketAddress()); + try (Socket _ = serverSocket.accept()) { + assertTrue(socket.isBound()); + assertTrue(socket.isConnected()); + assertThrows(IOException.class, () -> socket.connect(UNRESOLVED_ADDRESS)); + assertFalse(socket.isClosed()); + } + } + } + + static List sockets() throws Exception { + Socket socket = new Socket(); + @SuppressWarnings("resource") + Socket channelSocket = SocketChannel.open().socket(); + return List.of(socket, channelSocket); + } + + private static ServerSocket createEphemeralServerSocket() throws IOException { + return new ServerSocket(0, 0, InetAddress.getLoopbackAddress()); + } + +} diff --git a/test/jdk/java/security/KeyStore/EntryMethods.java b/test/jdk/java/security/KeyStore/EntryMethods.java index 38c1ab56ae8c3..b21cd40362194 100644 --- a/test/jdk/java/security/KeyStore/EntryMethods.java +++ b/test/jdk/java/security/KeyStore/EntryMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, 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 @@ -70,15 +70,9 @@ public EntryMethods() throws Exception { pre15fis = new FileInputStream (System.getProperty("test.src") + "/EntryMethods.pre15.keystore"); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - put("KeyStore.Pre15KeyStore", "EntryMethods$Pre15"); - put("KeyStore.Post15KeyStore", "EntryMethods$Post15"); - put("KeyStore.UnrecoverableKeyStore", - "EntryMethods$UnrecoverableKS"); - return null; - } - }); + put("KeyStore.Pre15KeyStore", "EntryMethods$Pre15"); + put("KeyStore.Post15KeyStore", "EntryMethods$Post15"); + put("KeyStore.UnrecoverableKeyStore", "EntryMethods$UnrecoverableKS"); } public static void main(String[] args) throws Exception { diff --git a/test/jdk/javax/swing/Action/8133039/bug8133039.java b/test/jdk/javax/swing/Action/8133039/bug8133039.java index f36b1b1ab10f8..48de406aaaf02 100644 --- a/test/jdk/javax/swing/Action/8133039/bug8133039.java +++ b/test/jdk/javax/swing/Action/8133039/bug8133039.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, 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 @@ -39,8 +39,8 @@ * @bug 8133039 * @summary Provide public API to sun.swing.UIAction#isEnabled(Object) * @modules java.desktop/sun.swing - * @author Alexander Scherbatiy */ + public class bug8133039 { private static volatile int ACTION_PERFORMED_CALLS = 0; @@ -91,6 +91,7 @@ private static void testPopupAction() throws Exception { Robot robot = new Robot(); robot.setAutoDelay(100); robot.waitForIdle(); + robot.delay(1000); robot.keyPress(KeyEvent.VK_A); robot.keyRelease(KeyEvent.VK_A); diff --git a/test/jdk/lib/client/ExtendedRobot.java b/test/jdk/lib/client/ExtendedRobot.java index 3f77da887503e..1bcf8e18dfa7c 100644 --- a/test/jdk/lib/client/ExtendedRobot.java +++ b/test/jdk/lib/client/ExtendedRobot.java @@ -57,11 +57,6 @@ public class ExtendedRobot extends Robot { private final int syncDelay = DEFAULT_SYNC_DELAY; - //TODO: uncomment three lines below after moving functionality to java.awt.Robot - //{ - // syncDelay = AccessController.doPrivileged(new GetIntegerAction("java.awt.robotdelay", DEFAULT_SYNC_DELAY)); - //} - /** * Constructs an ExtendedRobot object in the coordinate system of the primary screen. * diff --git a/test/jdk/sun/security/action/Generify.java b/test/jdk/sun/security/action/Generify.java index 09cbb3fbb4235..4ddbc299a47a1 100644 --- a/test/jdk/sun/security/action/Generify.java +++ b/test/jdk/sun/security/action/Generify.java @@ -35,37 +35,8 @@ public class Generify { public static void main(String[] args) throws Exception { - long larg = 1234567890L; - - System.setProperty("boolean", "true"); - System.setProperty("integer", "9"); - System.setProperty("long", Long.toString(larg)); System.setProperty("property", "propertyvalue"); - Boolean b = AccessController.doPrivileged - (new GetBooleanAction("boolean")); - if (b.booleanValue() == true) { - System.out.println("boolean test passed"); - } else { - throw new SecurityException("boolean test failed"); - } - - Integer i = AccessController.doPrivileged - (new GetIntegerAction("integer")); - if (i.intValue() == 9) { - System.out.println("integer test passed"); - } else { - throw new SecurityException("integer test failed"); - } - - Long l = AccessController.doPrivileged - (new GetLongAction("long")); - if (l.longValue() == larg) { - System.out.println("long test passed"); - } else { - throw new SecurityException("long test failed"); - } - String prop = AccessController.doPrivileged (new GetPropertyAction("property")); if (prop.equals("propertyvalue")) { diff --git a/test/jdk/sun/security/krb5/name/Constructors.java b/test/jdk/sun/security/krb5/name/Constructors.java index f3943cc88ef3f..733a9e421f832 100644 --- a/test/jdk/sun/security/krb5/name/Constructors.java +++ b/test/jdk/sun/security/krb5/name/Constructors.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, 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,23 +41,22 @@ public static void main(String[] args) throws Exception { // Good ones type = PrincipalName.KRB_NT_UNKNOWN; - checkName("a", type, "R", "R", false, "a"); - checkName("a@R2", type, "R", "R", false, "a"); - checkName("a/b", type, "R", "R", false, "a", "b"); - checkName("a/b@R2", type, "R", "R", false, "a", "b"); - checkName("a/b/c", type, "R", "R", false, "a", "b", "c"); - checkName("a/b/c@R2", type, "R", "R", false, "a", "b", "c"); + checkName("a", type, "R", "R", "a"); + checkName("a@R2", type, "R", "R", "a"); + checkName("a/b", type, "R", "R", "a", "b"); + checkName("a/b@R2", type, "R", "R", "a", "b"); + checkName("a/b/c", type, "R", "R", "a", "b", "c"); + checkName("a/b/c@R2", type, "R", "R", "a", "b", "c"); // Weird ones - checkName("a\\/b", type, "R", "R", false, "a/b"); - checkName("a\\/b\\/c", type, "R", "R", false, "a/b/c"); - checkName("a\\/b\\@R2", type, "R", "R", false, "a/b@R2"); + checkName("a\\/b", type, "R", "R", "a/b"); + checkName("a\\/b\\/c", type, "R", "R", "a/b/c"); + checkName("a\\/b\\@R2", type, "R", "R", "a/b@R2"); // Bad ones - checkName("a", type, "", null, false); - checkName("a/", type, "R", null, false); - checkName("/a", type, "R", null, false); - checkName("a//b", type, "R", null, false); - checkName("a@", type, null, null, false); - type = PrincipalName.KRB_NT_SRV_HST; + checkName("a", type, "", null); + checkName("a/", type, "R", null); + checkName("/a", type, "R", null); + checkName("a//b", type, "R", null); + checkName("a@", type, null, null); // Part 2: on realm choices @@ -78,17 +77,17 @@ public static void main(String[] args) throws Exception { if (testNoDefaultDomain) { type = PrincipalName.KRB_NT_UNKNOWN; - checkName("a", type, "R1", "R1", false, "a"); // arg - checkName("a@R1", type, null, "R1", false, "a"); // or r in name - checkName("a@R2", type, "R1", "R1", false, "a"); // arg over r - checkName("a", type, null, null, false); // fail if none - checkName("a/b@R1", type, null, "R1", false, "a", "b"); + checkName("a", type, "R1", "R1", "a"); // arg + checkName("a@R1", type, null, "R1", "a"); // or r in name + checkName("a@R2", type, "R1", "R1", "a"); // arg over r + checkName("a", type, null, null); // fail if none + checkName("a/b@R1", type, null, "R1", "a", "b"); type = PrincipalName.KRB_NT_SRV_HST; // Let's pray "b.h" won't be canonicalized - checkName("a/b.h", type, "R1", "R1", false, "a", "b.h"); // arg - checkName("a/b.h@R1", type, null, "R1", false, "a", "b.h"); // or r in name - checkName("a/b.h@R1", type, "R2", "R2", false, "a", "b.h"); // arg over r - checkName("a/b.h", type, null, null, false); // fail if none + checkName("a/b.h", type, "R1", "R1", "a", "b.h"); // arg + checkName("a/b.h@R1", type, null, "R1", "a", "b.h"); // or r in name + checkName("a/b.h@R1", type, "R2", "R2", "a", "b.h"); // arg over r + checkName("a/b.h", type, null, null); // fail if none } // When there is default realm @@ -97,25 +96,25 @@ public static void main(String[] args) throws Exception { Config.refresh(); type = PrincipalName.KRB_NT_UNKNOWN; - checkName("a", type, "R1", "R1", false, "a"); // arg - checkName("a@R1", type, null, "R1", false, "a"); // or r in name - checkName("a@R2", type, "R1", "R1", false, "a"); // arg over r - checkName("a", type, null, "R", true, "a"); // default - checkName("a/b", type, null, "R", true, "a", "b"); + checkName("a", type, "R1", "R1", "a"); // arg + checkName("a@R1", type, null, "R1", "a"); // or r in name + checkName("a@R2", type, "R1", "R1", "a"); // arg over r + checkName("a", type, null, "R", "a"); // default + checkName("a/b", type, null, "R", "a", "b"); type = PrincipalName.KRB_NT_SRV_HST; - checkName("a/b.h3", type, "R1", "R1", false, "a", "b.h3"); // arg - checkName("a/b.h@R1", type, null, "R1", false, "a", "b.h"); // or r in name - checkName("a/b.h3@R2", type, "R1", "R1", false, "a", "b.h3"); // arg over r - checkName("a/b.h2", type, "R1", "R1", false, "a", "b.h2"); // arg over map - checkName("a/b.h2@R1", type, null, "R1", false, "a", "b.h2"); // r over map - checkName("a/b.h2", type, null, "R2", true, "a", "b.h2"); // map - checkName("a/b.h", type, null, "R", true, "a", "b.h"); // default + checkName("a/b.h3", type, "R1", "R1", "a", "b.h3"); // arg + checkName("a/b.h@R1", type, null, "R1", "a", "b.h"); // or r in name + checkName("a/b.h3@R2", type, "R1", "R1", "a", "b.h3"); // arg over r + checkName("a/b.h2", type, "R1", "R1", "a", "b.h2"); // arg over map + checkName("a/b.h2@R1", type, null, "R1", "a", "b.h2"); // r over map + checkName("a/b.h2", type, null, "R2", "a", "b.h2"); // map + checkName("a/b.h", type, null, "R", "a", "b.h"); // default } // Check if the creation matches the expected output. // Note: realm == null means creation failure static void checkName(String n, int t, String s, - String realm, boolean deduced, String... parts) + String realm, String... parts) throws Exception { PrincipalName pn = null; try { @@ -132,8 +131,5 @@ static void checkName(String n, int t, String s, throw new Exception(pn.toString() + " vs " + Arrays.toString(parts) + "@" + realm); } - if (deduced != pn.isRealmDeduced()) { - throw new Exception("pn.realmDeduced is " + pn.isRealmDeduced()); - } } } diff --git a/test/jdk/tools/sincechecker/modules/java.scripting/JavaScriptingCheckSince.java b/test/jdk/tools/sincechecker/modules/java.scripting/JavaScriptingCheckSince.java new file mode 100644 index 0000000000000..06458b07907e4 --- /dev/null +++ b/test/jdk/tools/sincechecker/modules/java.scripting/JavaScriptingCheckSince.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8343780 + * @summary Test for `@since` in java.scripting module + * @library /test/lib /test/jdk/tools/sincechecker + * @run main SinceChecker java.scripting + */ diff --git a/test/jdk/tools/sincechecker/modules/jdk.dynalink/JdkDynalinkCheckSince.java b/test/jdk/tools/sincechecker/modules/jdk.dynalink/JdkDynalinkCheckSince.java new file mode 100644 index 0000000000000..5d38713eb0a79 --- /dev/null +++ b/test/jdk/tools/sincechecker/modules/jdk.dynalink/JdkDynalinkCheckSince.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8343780 + * @summary Test for `@since` in jdk.dynalik module + * @library /test/lib /test/jdk/tools/sincechecker + * @run main SinceChecker jdk.dynalink + */ diff --git a/test/jdk/tools/sincechecker/modules/jdk.jartool/JdkJartoolCheckSince.java b/test/jdk/tools/sincechecker/modules/jdk.jartool/JdkJartoolCheckSince.java new file mode 100644 index 0000000000000..628aa8d2f34c8 --- /dev/null +++ b/test/jdk/tools/sincechecker/modules/jdk.jartool/JdkJartoolCheckSince.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8343780 + * @summary Test for `@since` in jdk.jartool module + * @library /test/lib /test/jdk/tools/sincechecker + * @run main SinceChecker jdk.jartool + */ diff --git a/test/jdk/tools/sincechecker/modules/jdk.jlink/JdkJlinkCheckSince.java b/test/jdk/tools/sincechecker/modules/jdk.jlink/JdkJlinkCheckSince.java new file mode 100644 index 0000000000000..effeb778a3adb --- /dev/null +++ b/test/jdk/tools/sincechecker/modules/jdk.jlink/JdkJlinkCheckSince.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8343780 + * @summary Test for `@since` in jdk.jlink module + * @library /test/lib /test/jdk/tools/sincechecker + * @run main SinceChecker jdk.jlink + */ diff --git a/test/jdk/tools/sincechecker/modules/jdk.jsobject/JdkJsobjectCheckSince.java b/test/jdk/tools/sincechecker/modules/jdk.jsobject/JdkJsobjectCheckSince.java new file mode 100644 index 0000000000000..705c7259b71db --- /dev/null +++ b/test/jdk/tools/sincechecker/modules/jdk.jsobject/JdkJsobjectCheckSince.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8343780 + * @summary Test for `@since` in jdk.jsobject module + * @library /test/lib /test/jdk/tools/sincechecker + * @run main SinceChecker jdk.jsobject + */ diff --git a/test/langtools/tools/javac/patterns/T8343932.java b/test/langtools/tools/javac/patterns/T8343932.java new file mode 100644 index 0000000000000..346d0d6f79c2a --- /dev/null +++ b/test/langtools/tools/javac/patterns/T8343932.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +/** + * @test + * @bug 8343932 + * @summary Error when parsing qualified generic type test pattern in switch + * @compile T8343932.java + */ +public class T8343932 { + abstract sealed class J permits X.S, A {} + final class A extends J {} + + public class X { + final class S extends J { + abstract sealed class J permits XX.SS, AA {} + final class AA extends J {} + + public class XX { + final class SS extends J {} + } + } + + static int test(J ji) { + return switch (ji) { + case A a -> 42; + case X.S e -> 4200; // level 1 + }; + } + + static int test(X.S.J ji) { + return switch (ji) { + case X.S.AA a -> 42; + case X.S.XX.SS e -> 4200; // level 2 + }; + } + } +} \ No newline at end of file diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java b/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java index 2db15bfe2652d..b7867efd77109 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,6 +22,8 @@ */ package org.openjdk.bench.java.lang.foreign; +import jdk.internal.foreign.AbstractMemorySegmentImpl; +import jdk.internal.foreign.StringSupport; import org.openjdk.jmh.annotations.Benchmark; import org.openjdk.jmh.annotations.BenchmarkMode; import org.openjdk.jmh.annotations.Fork; @@ -43,20 +45,20 @@ import java.util.stream.Stream; import static java.lang.foreign.ValueLayout.*; -import static jdk.internal.foreign.StringSupport.*; @BenchmarkMode(Mode.AverageTime) @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgs = {"--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED", "--enable-native-access=ALL-UNNAMED", "--enable-preview"}) +@Fork(value = 3, jvmArgs = {"--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED", + "--enable-native-access=ALL-UNNAMED"}) public class InternalStrLen { - private MemorySegment singleByteSegment; - private MemorySegment singleByteSegmentMisaligned; - private MemorySegment doubleByteSegment; - private MemorySegment quadByteSegment; + private AbstractMemorySegmentImpl singleByteSegment; + private AbstractMemorySegmentImpl singleByteSegmentMisaligned; + private AbstractMemorySegmentImpl doubleByteSegment; + private AbstractMemorySegmentImpl quadByteSegment; @Param({"1", "4", "16", "251", "1024"}) int size; @@ -64,10 +66,9 @@ public class InternalStrLen { @Setup public void setup() { var arena = Arena.ofAuto(); - singleByteSegment = arena.allocate((size + 1L) * Byte.BYTES); - singleByteSegmentMisaligned = arena.allocate((size + 1L) * Byte.BYTES); - doubleByteSegment = arena.allocate((size + 1L) * Short.BYTES); - quadByteSegment = arena.allocate((size + 1L) * Integer.BYTES); + singleByteSegment = (AbstractMemorySegmentImpl) arena.allocate((size + 1L) * Byte.BYTES); + doubleByteSegment = (AbstractMemorySegmentImpl) arena.allocate((size + 1L) * Short.BYTES); + quadByteSegment = (AbstractMemorySegmentImpl) arena.allocate((size + 1L) * Integer.BYTES); Stream.of(singleByteSegment, doubleByteSegment, quadByteSegment) .forEach(s -> IntStream.range(0, (int) s.byteSize() - 1) .forEach(i -> s.set( @@ -78,7 +79,7 @@ public void setup() { singleByteSegment.set(ValueLayout.JAVA_BYTE, singleByteSegment.byteSize() - Byte.BYTES, (byte) 0); doubleByteSegment.set(ValueLayout.JAVA_SHORT, doubleByteSegment.byteSize() - Short.BYTES, (short) 0); quadByteSegment.set(ValueLayout.JAVA_INT, quadByteSegment.byteSize() - Integer.BYTES, 0); - singleByteSegmentMisaligned = arena.allocate(singleByteSegment.byteSize() + 1). + singleByteSegmentMisaligned = (AbstractMemorySegmentImpl) arena.allocate(singleByteSegment.byteSize() + 1). asSlice(1); MemorySegment.copy(singleByteSegment, 0, singleByteSegmentMisaligned, 0, singleByteSegment.byteSize()); } @@ -105,22 +106,22 @@ public int elementQuad() { @Benchmark public int chunkedSingle() { - return chunkedStrlenByte(singleByteSegment, 0); + return StringSupport.strlenByte(singleByteSegment, 0, singleByteSegment.byteSize()); } @Benchmark public int chunkedSingleMisaligned() { - return chunkedStrlenByte(singleByteSegmentMisaligned, 0); + return StringSupport.strlenByte(singleByteSegmentMisaligned, 0, singleByteSegment.byteSize()); } @Benchmark public int chunkedDouble() { - return chunkedStrlenShort(doubleByteSegment, 0); + return StringSupport.strlenShort(doubleByteSegment, 0, doubleByteSegment.byteSize()); } @Benchmark public int changedElementQuad() { - return strlenInt(quadByteSegment, 0); + return StringSupport.strlenInt(quadByteSegment, 0, quadByteSegment.byteSize()); } // These are the legacy methods diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java index 02b1a47d03fe2..7a0639b29bb12 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024 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 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "--enable-preview", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class ToJavaStringTest { private MemorySegment strSegment; diff --git a/test/micro/org/openjdk/bench/java/lang/reflect/NativeMethodInvoke.java b/test/micro/org/openjdk/bench/java/lang/reflect/NativeMethodInvoke.java new file mode 100644 index 0000000000000..b48cef5803741 --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/reflect/NativeMethodInvoke.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package org.openjdk.bench.java.lang.reflect; + +import org.openjdk.jmh.annotations.Benchmark; +import org.openjdk.jmh.annotations.BenchmarkMode; +import org.openjdk.jmh.annotations.Fork; +import org.openjdk.jmh.annotations.Measurement; +import org.openjdk.jmh.annotations.Mode; +import org.openjdk.jmh.annotations.OutputTimeUnit; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; +import org.openjdk.jmh.annotations.Warmup; +import org.openjdk.jmh.infra.Blackhole; + +import java.lang.reflect.Method; +import java.util.concurrent.TimeUnit; + +/** + * Benchmark for regression in native method invocation. + */ +@BenchmarkMode(Mode.AverageTime) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@State(Scope.Thread) +@Warmup(iterations = 10, time = 1, timeUnit = TimeUnit.SECONDS) +@Measurement(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS) +@Fork(3) +public class NativeMethodInvoke { + + private Method objectHashCode; + private Method threadCurrentThread; + + private Object[] objects; + + @Setup + public void setup() throws ReflectiveOperationException { + objects = new Object[]{ + 1, 5L, + 5.6d, 23.11f, + Boolean.TRUE, 'd' + }; + + objectHashCode = Object.class.getDeclaredMethod("hashCode"); + threadCurrentThread = Thread.class.getDeclaredMethod("currentThread"); + } + + @Benchmark + public void objectHashCode(Blackhole bh) throws ReflectiveOperationException { + for (var obj : objects) { + bh.consume(objectHashCode.invoke(obj)); + } + } + + @Benchmark + public Object threadCurrentThread() throws ReflectiveOperationException { + return threadCurrentThread.invoke(null); + } +}